Skip to content

Commit b13ba6f

Browse files
authored
Prevent double-definitions of propositions (#488)
* prevent double-definitions * add cvc5 testing
1 parent e0703dd commit b13ba6f

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

crates/filament/src/ir_passes/discharge.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use fil_ast as ast;
99
use fil_ir::{self as ir, Ctx, DisplayCtx};
1010
use fil_utils::GlobalPositionTable;
1111
use itertools::Itertools;
12-
use std::collections::HashMap;
12+
use std::collections::{HashMap, HashSet};
1313
use std::{fs, iter};
1414
use term::termcolor::{ColorChoice, StandardStream};
1515

@@ -608,6 +608,9 @@ impl Visitor for Discharge {
608608
}
609609

610610
let bs = self.sol.bool_sort();
611+
612+
let mut interned_props = HashSet::new();
613+
611614
// Declare all expressions
612615
for (idx, expr) in data
613616
.comp
@@ -622,6 +625,9 @@ impl Visitor for Discharge {
622625
.map(|i| (i, data.comp.get(i)));
623626

624627
for (pidx, prop) in relevant_props {
628+
// Save the proposition in the interned_props set
629+
interned_props.insert(pidx);
630+
625631
let assign = self.prop_to_sexp(prop);
626632
let sexp = self
627633
.sol
@@ -675,6 +681,8 @@ impl Visitor for Discharge {
675681
.props()
676682
.iter()
677683
.filter(|(idx, _)| idx.valid(&data.comp))
684+
// Filter out propositions that are already defined in expressions
685+
.filter(|(idx, _)| !interned_props.contains(idx))
678686
{
679687
// Define assertion equating the proposition to its assignment
680688
let assign = self.prop_to_sexp(prop);

runt.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@ ver = "0.4.1"
22

33

44
[[tests]]
5-
name = "check"
5+
name = "check-z3"
66
paths = ["tests/check/*.fil", "primitives/*.fil"]
77
cmd = """
8-
./target/debug/filament {} --check
8+
./target/debug/filament {} --check --solver z3
9+
"""
10+
expect_dir = "tests/check/"
11+
12+
[[tests]]
13+
name = "check-cvc5"
14+
paths = ["tests/check/*.fil", "primitives/*.fil"]
15+
cmd = """
16+
./target/debug/filament {} --check --solver cvc5
917
"""
1018
expect_dir = "tests/check/"
1119

0 commit comments

Comments
 (0)