Skip to content

Commit

Permalink
Merge branch 'master' of gh:FStarLang/FStar into nik_3353
Browse files Browse the repository at this point in the history
  • Loading branch information
mtzguido committed Jul 17, 2024
2 parents f2cf1b5 + 56ec5d4 commit 190ac0d
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 52 deletions.
15 changes: 11 additions & 4 deletions ocaml/fstar-lib/generated/FStar_TypeChecker_Err.ml

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

16 changes: 3 additions & 13 deletions ocaml/fstar-lib/generated/FStar_TypeChecker_Normalize.ml

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

28 changes: 15 additions & 13 deletions ocaml/fstar-lib/generated/FStar_TypeChecker_TcTerm.ml

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

7 changes: 5 additions & 2 deletions src/typechecker/FStar.TypeChecker.Err.fst
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,11 @@ let inferred_type_causes_variable_to_escape env t x =
(N.term_to_string env t) (Print.bv_to_string x)))

let expected_function_typ env t =
(Errors.Fatal_FunctionTypeExpected, (format1 "Expected a function; got an expression of type \"%s\""
(N.term_to_string env t)))
(Errors.Fatal_FunctionTypeExpected, [
text "Expected a function.";
prefix 2 1 (text "Got an expression of type:")
(N.term_to_doc env t);
])

let expected_poly_typ env f t targ =
(Errors.Fatal_PolyTypeExpected, (format3 "Expected a polymorphic function; got an expression \"%s\" of type \"%s\" applied to a type \"%s\""
Expand Down
14 changes: 5 additions & 9 deletions src/typechecker/FStar.TypeChecker.Normalize.fst
Original file line number Diff line number Diff line change
Expand Up @@ -1291,15 +1291,11 @@ let rec norm : cfg -> env -> stack -> term -> term =
for_extraction=cfg.steps.for_extraction})
; delta_level = delta_level
; normalize_pure_lets = true } in
let stack' =
let debug =
if cfg.debug.print_normalized
then Some (tm, BU.now())
else None
in
Cfg (cfg, debug)::stack
in
norm cfg' env stack' tm
(* We reduce the term in an empty stack to prevent unwanted interactions.
Later, we rebuild the normalized term with the current stack. This is
not a tail-call, but this happens rarely enough that it should not be a problem. *)
let tm_normed = norm cfg' env [] tm in
rebuild cfg env stack tm_normed
end

| Tm_type u ->
Expand Down
5 changes: 3 additions & 2 deletions src/typechecker/FStar.TypeChecker.TcTerm.fst
Original file line number Diff line number Diff line change
Expand Up @@ -2909,7 +2909,8 @@ and check_application_args env head (chead:comp) ghead args expected_topt : term
in //end tc_args

let rec check_function_app tf guard =
match (N.unfold_whnf env tf).n with
let tf = N.unfold_whnf env tf in
match (U.unmeta tf).n with
| Tm_uvar _
| Tm_app {hd={n=Tm_uvar _}} ->
let bs, guard =
Expand Down Expand Up @@ -2954,7 +2955,7 @@ and check_application_args env head (chead:comp) ghead args expected_topt : term
check_function_app t guard

| _ ->
raise_error (Err.expected_function_typ env tf) head.pos in
raise_error_doc (Err.expected_function_typ env tf) head.pos in

check_function_app thead Env.trivial_guard

Expand Down
36 changes: 27 additions & 9 deletions tests/vale/X64.Poly1305.Math_i.fst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ lemma_BitwiseMul64()

// private unfold let op_Star = op_Multiply

#reset-options "--z3cliopt smt.QI.EAGER_THRESHOLD=100 --z3cliopt smt.CASE_SPLIT=3 --z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 0 --smtencoding.elim_box true --smtencoding.nl_arith_repr wrapped --smtencoding.l_arith_repr native"
// GM 2024-07-17: this file is rather particular with options. It had
// #reset-options pragmas everywher, but no real explanations. I've changed
// it to use push/pop, where the push only states the difference instead
// of the full thing again.
#set-options "--z3cliopt smt.QI.EAGER_THRESHOLD=100 \
--z3cliopt smt.CASE_SPLIT=3 \
--z3cliopt smt.arith.nl=false \
--fuel 0 --ifuel 0 \
--smtencoding.elim_box true \
--smtencoding.nl_arith_repr wrapped \
--smtencoding.l_arith_repr native"

(*
let heapletTo128_preserved (m:mem) (m':mem) (i:int) (len:nat) =
Expand Down Expand Up @@ -79,7 +89,9 @@ let reveal_poly1305_heap_blocks (h:int) (pad:int) (r:int) (m:mem) (i:int) (k) =

let lemma_heap_blocks_preserved (m:mem) (h:int) (pad:int) (r:int) (ptr num_bytes i:int) (k) = admit()

#reset-options "--smtencoding.elim_box true --z3cliopt smt.arith.nl=true --max_fuel 1 --max_ifuel 1 --smtencoding.nl_arith_repr native --z3rlimit 100 --using_facts_from Prims --using_facts_from FStar.Math.Lemmas"
#push-options "--z3cliopt smt.arith.nl=true --fuel 1 --ifuel 1 \
--smtencoding.nl_arith_repr native --z3rlimit 100 \
--using_facts_from Prims --using_facts_from FStar.Math.Lemmas"

val lemma_mul_div_comm: a:nat -> b:pos -> c:nat ->
Lemma (requires (c % b = 0 /\ a % b = 0))
Expand Down Expand Up @@ -107,8 +119,9 @@ val swap_add: a:int -> b:int -> c:int -> Lemma
(a + b + c = a + c + b)
let swap_add a b c = ()

#pop-options

#reset-options "--z3cliopt smt.QI.EAGER_THRESHOLD=100 --z3cliopt smt.CASE_SPLIT=3 --z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 1 --smtencoding.elim_box true --smtencoding.nl_arith_repr wrapped --smtencoding.l_arith_repr native --z3rlimit 8"
#push-options "--ifuel 1"

let lemma_poly_multiply (n:int) (p:pos) (r:int) (h:int) (r0:int) (r1:nat) (h0:int) (h1:int)
(h2:int) (s1:int) (d0:int) (d1:int) (d2:int) (hh:int) = admit()
Expand Down Expand Up @@ -161,6 +174,9 @@ let lemma_poly_multiply (n:int) (p:pos) (r:int) (h:int) (r0:int) (r1:nat) (h0:in
let lemma_poly_reduce (n:int) (p:pos) (h:nat) (h2:nat) (h10:int) (c:int) (hh:int) =
lemma_div_mod h (n*n);
assert (h == (n*n)*h2 + h10);
admit();
// this chain below got broken after a normalizer patch to not leaks
// configs of norm requests.
tcalc(
h
&= (n*n)*h2 + h10 &| using (lemma_div_mod h (n*n))
Expand Down Expand Up @@ -210,16 +226,16 @@ let lemma_mod_factors(x0:nat) (x1:nat) (y:nat) (z:pos) :
nat_times_nat_is_nat y x1;
lemma_mod_plus x0 (y*x1) z;
assert ((y*z)*x1 == (y*x1)*z) by canon ()
#pop-options

#reset-options "--initial_fuel 0 --max_fuel 0 --smtencoding.elim_box true"
let lemma_mul_pos_pos_is_pos_inverse (x:pos) (y:int) :
Lemma (requires y*x > 0)
(ensures y > 0) =
if y = 0 then assert_norm (0*x == 0)
else if y < 0 then assume(False)
else ()

#reset-options "--z3cliopt smt.QI.EAGER_THRESHOLD=100 --z3cliopt smt.CASE_SPLIT=3 --z3cliopt smt.arith.nl=false --max_fuel 0 --max_ifuel 1 --smtencoding.elim_box true --smtencoding.nl_arith_repr wrapped --smtencoding.l_arith_repr native --z3rlimit 8"
#push-options "--ifuel 1"
let lemma_mod_factor_lo(x0:nat64) (x1:nat64) (y:int) (z:pos) :
Lemma (requires z < 0x10000000000000000 /\
y * z == 0x10000000000000000)
Expand Down Expand Up @@ -253,9 +269,9 @@ let lemma_mod_breakdown (a:nat) (b:pos) (c:pos) :
lemma_mul_pos_pos_is_pos b c;
nat_over_pos_is_nat a b;
admit ()
#pop-options


#reset-options "--smtencoding.elim_box true --z3rlimit 8 --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native"
#push-options "--smtencoding.nl_arith_repr native"
// using tcalc it was not even proving the first equation, look into this later
let lemma_mod_hi (x0:nat64) (x1:nat64) (z:nat64) =
let n = 0x10000000000000000 in
Expand All @@ -269,9 +285,9 @@ let lemma_mod_hi (x0:nat64) (x1:nat64) (z:nat64) =

let lemma_poly_demod (p:pos) (h:int) (x:int) (r:int) =
admit()
#pop-options


#reset-options "--z3cliopt smt.QI.EAGER_THRESHOLD=100 --z3cliopt smt.CASE_SPLIT=3 --z3cliopt smt.arith.nl=false --max_fuel 2 --max_ifuel 1 --smtencoding.elim_box true --smtencoding.nl_arith_repr wrapped --smtencoding.l_arith_repr native --z3rlimit 50"
#push-options "--fuel 2 --ifuel 1 --z3rlimit 50"
let lemma_reduce128 (h:int) (h2:nat64) (h1:nat64) (h0:nat64) (g:int) (g2:nat64) (g1:nat64) (g0:nat64) =
admit()
(*
Expand Down Expand Up @@ -333,3 +349,5 @@ let lemma_poly1305_heap_hash_blocks (h:int) (pad:int) (r:int) (m:mem) (i:int) (k

let lemma_add_mod128 (x y :int) =
reveal_opaque mod2_128'

#pop-options

0 comments on commit 190ac0d

Please sign in to comment.