Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a fixed name for the while loop counter (loop_ctr) #47

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/Vale/src/emit_common_lemmas.fs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ let rec build_lemma_stmt (senv:stmt_env) (s:stmt):ghost * bool * stmt list =
let codeBody = vaApp "get_whileBody" [code] in
let i1 = string (gen_lemma_sym ()) in
let i2 = string (gen_lemma_sym ()) in
let (n1, s1, sw1, fw1) = (Reserved ("n" + i1), Reserved ("s" + i1), Reserved ("sW" + i1), Reserved ("fW" + i1)) in
let (n1, s1, sw1, fw1) = (Id "loop_ctr", Reserved ("s" + i1), Reserved ("sW" + i1), Reserved ("fW" + i1)) in
let (sw2, fw2) = (Reserved ("sW" + i2), Reserved ("fW" + i2)) in
let (codeCond, codeBody, sCodeVars) =
if !fstar then
Expand Down
2 changes: 1 addition & 1 deletion tools/Vale/src/emit_dafny_text.fs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ let rec emit_stmt (ps:print_state) (s:stmt):unit =
ps.PrintLine ("ghost var " + (String.concat ", " (List.map string_of_lhs_formal lhss)) + " := " + (string_of_exp e) + ";")
| SAssign _ -> emit_stmts ps (eliminate_assign_lhss s)
| SLetUpdates _ -> internalErr "SLetUpdates"
| SBlock ss -> notImplemented "block"
| SBlock ss -> emit_block ps ss
| SIfElse (_, e, ss1, []) ->
ps.PrintLine ("if (" + (string_of_exp e) + ")");
emit_block ps ss1
Expand Down
1 change: 1 addition & 0 deletions tools/Vale/src/typechecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,7 @@ let rec tc_stmt (env:env) (s:stmt):stmt =
SIfElse (g, e, b1, b2)
| SWhile (e, invs, ed, b) ->
let (t, e) = tc_exp env e (Some tBool) in
let env = push_id env (Id "loop_ctr") (TInt (NegInf, Inf)) in
let invs = List_mapSnd (fun e -> let (_, e) = tc_exp env e (Some tProp) in e) invs in
let ed = mapSnd (List.map (fun e -> let (_, e) = tc_exp env e None in e)) ed in
let (_, b) = tc_stmts env b in
Expand Down