Skip to content

Commit

Permalink
Add a test case for asserting universally-quantified statements.
Browse files Browse the repository at this point in the history
Fixes #1037
  • Loading branch information
robdockins committed Aug 16, 2022
1 parent 3e2e449 commit b7168af
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions intTests/test_univ_assert/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This is a test of the capability to assert first-order statements
to the solver. Here, we are reasoning abstractly over about
generic properties of addition and multiplication (essentially,
some of the ring axioms).
33 changes: 33 additions & 0 deletions intTests/test_univ_assert/test.saw
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
enable_experimental;

let {{
type vec_t = [384]
mul : vec_t -> vec_t -> vec_t
mul x y = undefined // this would be e.g. multiplication modulo p
add : vec_t -> vec_t -> vec_t
add x y = undefined

term1 x y z1 z2 z3 = add (mul (add (mul (add (mul x y) z1) x) z2) x) z3
term2 x y z1 z2 z3 = add (mul y (mul x (mul x x))) (add (mul z1 (mul x x)) (add (mul z2 x) z3))
}};

// Assume some of the ring axioms
lemmas <- for
[ {{ \x y -> mul x y == mul y x }}
, {{ \x y -> add x y == add y x }}
, {{ \x y z -> mul (mul x y) z == mul x (mul y z) }}
, {{ \x y z -> add (add x y) z == add x (add y z) }}
, {{ \x y z -> mul (add x y) z == add (mul x z) (mul y z) }}
]
(prove_print assume_unsat);

// Use those axioms to prove a nonmtrivial equality
thm <- prove_print
(do {
unfolding ["term1","term2"];
for lemmas goal_insert;
w4_unint_z3 ["mul","add"];
})
{{ \x y z1 z2 z3 -> term1 x y z1 z2 z3 == term2 x y z1 z2 z3 }};

print thm;
1 change: 1 addition & 0 deletions intTests/test_univ_assert/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$SAW test.saw

0 comments on commit b7168af

Please sign in to comment.