Skip to content

Commit 4d31659

Browse files
author
Tiago Campos
committed
Add pivots when elaborate drup
1 parent f514316 commit 4d31659

File tree

10 files changed

+67
-86
lines changed

10 files changed

+67
-86
lines changed

carcara.code-workspace

+2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
22
"folders": [
33
{
4+
"name": "carcara",
45
"path": "."
56
},
67
{
8+
"name": "cvc5",
79
"path": "../cvc5"
810
}
911
],

carcara/src/checker/rules/drup.rs

+56
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,59 @@ pub fn drup(
1717
Err(err) => Err(CheckerError::DrupFormatError(err))
1818
}
1919
}
20+
21+
22+
#[cfg(test)]
23+
mod tests {
24+
#[test]
25+
fn drup() {
26+
test_cases! {
27+
definitions = "
28+
(declare-const a Bool)
29+
(declare-const b Bool)
30+
(declare-const c Bool)
31+
(declare-const d Bool)
32+
(declare-const e Bool)
33+
",
34+
"Simple working examples" {
35+
"(assume a0 (or a c))
36+
(assume a1 (or a (not c) d))
37+
(assume a2 (or (not d) e))
38+
(assume a3 (or (not d) (not e)))
39+
(assume a4 (not a))
40+
(assume a5 (not b))
41+
(step t0 (cl a c) :rule or :premises (a0))
42+
(step t1 (cl a (not c) d) :rule or :premises (a1))
43+
(step t2 (cl (not d) e) :rule or :premises (a2))
44+
(step t3 (cl (not d) (not e)) :rule or :premises (a3))
45+
(step t4 (cl a b) :rule drup :premises (t0 t1 t2 t3) :args ((cl a b)))": true,
46+
47+
"
48+
(assume a1 (not a))
49+
(assume a2 (not b))
50+
(assume a3 (or a b))
51+
(step t0 (cl a b) :rule or :premises (a3))
52+
(step t1 (cl) :rule drup :premises (a1 a2 t0) :args ((cl)))": true,
53+
}
54+
55+
"Simple false-working examples" {
56+
"(assume a0 (or a c))
57+
(assume a1 (or a (not c) d))
58+
(assume a2 (or (not d) e))
59+
(assume a4 (not a))
60+
(assume a5 (not b))
61+
(step t0 (cl a c) :rule or :premises (a0))
62+
(step t1 (cl a (not c) d) :rule or :premises (a1))
63+
(step t2 (cl (not d) e) :rule or :premises (a2))
64+
(step t4 (cl a) :rule drup :premises (t0 t1 t2) :args ((cl a b)))": false,
65+
66+
"
67+
(assume a1 (not a))
68+
(assume a3 (or a b))
69+
(step t0 (cl a b) :rule or :premises (a3))
70+
(step t1 (cl) :rule drup :premises (a1 t0) :args ((cl)))": false,
71+
}
72+
73+
}
74+
}
75+
}

carcara/src/drup.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ pub enum DrupFormatError {
3131
#[error("couldn't find conclusion term in the premise clauses")]
3232
NoConclusionInPremise,
3333
#[error(
34-
"couldn't elaborate drup because bottom wasn't derived from the premises and argument"
34+
"couldn't elaborate drup because bottom wasn't derived from the premises and the argument"
3535
)]
3636
NoFinalBottomInDrup,
37-
#[error("couldn't elaborate drup because the argument might not be in RUP or the premises derive bottom alone")]
37+
#[error("couldn't elaborate drup because the argument might not be in RUP")]
3838
PotentialNoDrupFormat,
3939
}
4040

carcara/src/elaborator/drup.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub fn elaborate_drup(
1313
#[derive(Debug)]
1414
enum ResolutionStep<'a> {
1515
Resolvent(
16+
&'a(bool, Rc<Term>),
1617
u64,
1718
u64,
1819
(Vec<Rc<Term>>, IndexSet<(bool, &'a Rc<Term>)>, u64),
@@ -95,6 +96,7 @@ pub fn elaborate_drup(
9596
let resolvent_hash = hash_term(pool, resolvent.as_slice());
9697

9798
resolutions.push(ResolutionStep::Resolvent(
99+
pivot,
98100
rup[i].1,
99101
rup[i + 1].1,
100102
(resolvent, resolvent_indexset.clone(), resolvent_hash),
@@ -108,7 +110,7 @@ pub fn elaborate_drup(
108110
}
109111

110112
match &resolutions[resolutions.len() - 1] {
111-
ResolutionStep::Resolvent(_, _, (resolvent, _, _)) => {
113+
ResolutionStep::Resolvent(_, _, _, (resolvent, _, _)) => {
112114
if resolvent.len() > 0 {
113115
return Err(CheckerError::DrupFormatError(
114116
DrupFormatError::NoFinalBottomInDrup,
@@ -125,7 +127,7 @@ pub fn elaborate_drup(
125127
}
126128

127129
resolutions.retain(|step| match step {
128-
ResolutionStep::Resolvent(_, _, (resolvent, _, _)) => {
130+
ResolutionStep::Resolvent(_, _, _, (resolvent, _, _)) => {
129131
resolvent.len() > 0 || rup_clause.len() == 0
130132
}
131133
ResolutionStep::UnChanged(_, _) => false, // Since unchanged are trivally avaliable we can ignore them
@@ -134,6 +136,7 @@ pub fn elaborate_drup(
134136
for (i, resolution_step) in resolutions.iter().enumerate() {
135137
match resolution_step {
136138
ResolutionStep::Resolvent(
139+
pivot,
137140
c,
138141
d,
139142
(resolvent, resolvent_indexset, resolvent_hash),
@@ -151,7 +154,7 @@ pub fn elaborate_drup(
151154
(*premises.get(d).unwrap()).clone(),
152155
],
153156
discharge: Vec::new(),
154-
args: Vec::new(),
157+
args: vec![pivot.1.clone(), pool.bool_constant(pivot.0)],
155158
previous_step: None,
156159
}));
157160

cli/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ struct ElaborationOptions {
239239
arg_enum,
240240
long,
241241
multiple = true,
242-
default_values = &["polyeq", "lia-generic", "reordering", "local", "uncrowd", "hole"]
242+
default_values = &["polyeq", "lia-generic", "local", "uncrowd", "reordering", "hole"]
243243
)]
244244
pipeline: Vec<ElaborationStep>,
245245
}

test.smt2

-18
This file was deleted.

test.smt2.aleth

-18
This file was deleted.

test2.smt2

-15
This file was deleted.

test2.smt2.aleth

-13
This file was deleted.

test3.smt2.aleth

-16
This file was deleted.

0 commit comments

Comments
 (0)