Skip to content

Commit 26a5a3e

Browse files
HanielBclaude
andcommitted
Add unit tests for and_intro rule
Cover success and failure cases: conjunction from unit premises in order, non-unit premises corresponding to disjunctions, premise ordering, disjunct ordering, mismatched conjuncts, wrong premise count, and a non-conjunction conclusion. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent cc9abb0 commit 26a5a3e

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

carcara/tests/rules/extras.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,70 @@ fn weakening() {
128128
}
129129
}
130130

131+
#[test]
132+
fn and_intro() {
133+
test_cases! {
134+
definitions = "
135+
(declare-fun p () Bool)
136+
(declare-fun q () Bool)
137+
(declare-fun r () Bool)
138+
",
139+
"Simple working examples" {
140+
"(assume h1 p)
141+
(assume h2 q)
142+
(step t1 (cl (and p q)) :rule and_intro :premises (h1 h2))": true,
143+
144+
"(assume h1 p)
145+
(assume h2 q)
146+
(assume h3 r)
147+
(step t1 (cl (and p q r)) :rule and_intro :premises (h1 h2 h3))": true,
148+
}
149+
"Non-unit premise corresponds to a disjunction" {
150+
"(step t1 (cl p q) :rule hole)
151+
(assume h2 r)
152+
(step t2 (cl (and (or p q) r)) :rule and_intro :premises (t1 h2))": true,
153+
154+
// A unit premise whose term is itself an `or` matches the same conjunct.
155+
"(assume h1 (or p q))
156+
(assume h2 r)
157+
(step t1 (cl (and (or p q) r)) :rule and_intro :premises (h1 h2))": true,
158+
}
159+
"Premises must be in the right order" {
160+
"(assume h1 p)
161+
(assume h2 q)
162+
(step t1 (cl (and q p)) :rule and_intro :premises (h1 h2))": false,
163+
}
164+
"A conjunct does not match its premise" {
165+
"(assume h1 p)
166+
(assume h2 q)
167+
(step t1 (cl (and p r)) :rule and_intro :premises (h1 h2))": false,
168+
169+
// The disjuncts of the conjunct must match the clause order.
170+
"(step t1 (cl p q) :rule hole)
171+
(assume h2 r)
172+
(step t2 (cl (and (or q p) r)) :rule and_intro :premises (t1 h2))": false,
173+
174+
// A non-unit premise must correspond to an `or`, not a single literal.
175+
"(step t1 (cl p q) :rule hole)
176+
(assume h2 r)
177+
(step t2 (cl (and p r)) :rule and_intro :premises (t1 h2))": false,
178+
}
179+
"Wrong number of premises" {
180+
"(assume h1 p)
181+
(step t1 (cl (and p q)) :rule and_intro :premises (h1))": false,
182+
183+
"(assume h1 p)
184+
(assume h2 q)
185+
(assume h3 r)
186+
(step t1 (cl (and p q)) :rule and_intro :premises (h1 h2 h3))": false,
187+
}
188+
"Conclusion is not a conjunction" {
189+
"(assume h1 p)
190+
(step t1 (cl p) :rule and_intro :premises (h1))": false,
191+
}
192+
}
193+
}
194+
131195
#[test]
132196
fn bind_let() {
133197
test_cases! {

0 commit comments

Comments
 (0)