Skip to content

Commit

Permalink
Merge pull request #3091 from mtzguido/3089
Browse files Browse the repository at this point in the history
Fixing #3089, and some unifier fixes
  • Loading branch information
mtzguido authored Nov 14, 2023
2 parents def881f + 5eeac92 commit 085657b
Show file tree
Hide file tree
Showing 12 changed files with 472 additions and 294 deletions.
2 changes: 2 additions & 0 deletions examples/miniparse/MiniParse.Impl.List.fst
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ let serialize_nlist_impl_inv
ser == Seq.append (B.as_seq h bl) (serialize (serialize_nlist (n - i) s) ll)
))

#push-options "--z3rlimit 128"
inline_for_extraction
let serialize_nlist_impl_body
(n: nat)
Expand Down Expand Up @@ -376,6 +377,7 @@ let serialize_nlist_impl_body
in
phi ();
false
#pop-options

inline_for_extraction
let serialize_nlist_impl
Expand Down
103 changes: 32 additions & 71 deletions examples/miniparse/MiniParse.Impl.List.fst.hints

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions examples/miniparse/MiniParse.Tac.Impl.fst.hints

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/miniparse/MiniParseExample.fst.hints

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 16 additions & 7 deletions examples/tactics/Canon.fst
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ open FStar.Tactics.V2
open FStar.Tactics.Canon
open FStar.Mul

assume val w : int
assume val x : int
assume val y : int
assume val z : int

// Testing the canonicalizer, it should be the only thing needed for this file
let check_canon () =
canon ();
Expand All @@ -32,11 +27,25 @@ let check_canon () =
(fun () -> dump "`canon` left the following goals";
fail "")

let lem0 = assert (x * (y * z) == (x * y) * z) by check_canon ()
let lem0' = assert (w * (x * (y * z)) == ((z * y) * x) * w) by check_canon ()
let test_neg (b : pos) =
assert (b - 1 == b + (-1))
by (check_canon ())

// TODO: for now, canon is not enough as we don't collect factors, so we
// leave the rest to the SMT
let test_neg2 (b c : pos) =
assert (b * (c-1) + b == b*c)
by (canon ())

assume val w : int
assume val x : int
assume val y : int
assume val z : int

let lem0 = assert (x * (y * z) == (x * y) * z) by check_canon ()
let lem0' = assert (w * (x * (y * z)) == ((z * y) * x) * w) by check_canon ()

// Idem test_neg2
let lem1 =
assert ((x + y) * (z + z) == 2 * z * (y + x))
by canon ()
Expand Down
16 changes: 10 additions & 6 deletions examples/tactics/Normalization.fst
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,19 @@ let _ = assert True
then ()
else fail "Test 1")

(* GM, 2023/11/09: this is now no longer true. The unifier does trigger
primitive steps computations, and the trefl() call above
will instantiate the RHS with the WHNF of the LHS, which is also 4. *)

(* If we only allow for Delta steps, then there's no primitive computation and we
* end up with (2 + 1) + 1 *)
let four' : int = _ by (normalize [delta] (add_2 2))
(* let four' : int = _ by (normalize [delta] (add_2 2)) *)

let _ = assert True
by (let t = def_of four' in
if compare_term t (`((2 + 1) + 1)) = FStar.Order.Eq
then ()
else fail "Test 2")
(* let _ = assert True *)
(* by (let t = def_of four' in *)
(* if compare_term t (`((2 + 1) + 1)) = FStar.Order.Eq *)
(* then () *)
(* else fail "Test 2") *)

(* Here, we allow for primitive computation but don't allow for `add_2` to be expanded to
* its definition, so the final result is `add_2 1` *)
Expand Down
131 changes: 88 additions & 43 deletions ocaml/fstar-lib/generated/FStar_Tactics_Canon.ml

Large diffs are not rendered by default.

Loading

0 comments on commit 085657b

Please sign in to comment.