-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This tactic allows to change an expression in a statement by some other expression. When applied, the user has to prove that the two expressions are equal (generalizing over all the program variables) This tactic applies to any program logic. The syntax is: proc change <side?> <codepos> : <form> This tactic is in the TCB. Test plan: - unit test (tests/prochange.ec)
- Loading branch information
Showing
6 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
(* -------------------------------------------------------------------- *) | ||
open EcParsetree | ||
open EcAst | ||
open EcCoreGoal | ||
open EcModules | ||
open EcFol | ||
|
||
(* -------------------------------------------------------------------- *) | ||
let process_change | ||
(side : side option) | ||
(pos : codepos) | ||
(form : pformula) | ||
(tc : tcenv1) | ||
= | ||
let concl = FApi.tc1_goal tc in | ||
|
||
let change i = | ||
let (e, mk) = | ||
match i.i_node with | ||
| Sasgn (lv, e) -> (e, (fun e -> i_asgn (lv, e))) | ||
| Srnd (lv, e) -> (e, (fun e -> i_rnd (lv, e))) | ||
| _ -> assert false in | ||
|
||
let m, e' = EcProofTyping.tc1_process_Xhl_form ?side tc e.e_ty form in | ||
let mid = EcMemory.memory m in | ||
let e' = expr_of_form mid e' in | ||
|
||
let f = form_of_expr mid e in | ||
let f' = form_of_expr mid e' in | ||
|
||
([f_forall_mems [m] (f_eq f f')], [mk e']) | ||
in | ||
|
||
let kinds = [`Hoare `Stmt; `EHoare `Stmt; `PHoare `Stmt; `Equiv `Stmt] in | ||
|
||
if not (EcLowPhlGoal.is_program_logic concl kinds) then | ||
assert false; | ||
|
||
let s = EcLowPhlGoal.tc1_get_stmt side tc in | ||
let goals, s = EcMatching.Zipper.map pos change s in | ||
let concl = EcLowPhlGoal.hl_set_stmt side concl s in | ||
|
||
FApi.xmutate1 tc `ProcChange (goals @ [concl]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(* -------------------------------------------------------------------- *) | ||
open EcParsetree | ||
open EcCoreGoal.FApi | ||
|
||
(* -------------------------------------------------------------------- *) | ||
val process_change : side option -> codepos -> pformula -> backward |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require import AllCore. | ||
|
||
module M = { | ||
proc f(x : int) = { | ||
x <- x + 0; | ||
} | ||
}. | ||
|
||
lemma L : equiv[M.f ~ M.f : true ==> true]. | ||
proof. | ||
proc. | ||
proc change {1} 1 : x. | ||
- smt(). | ||
abort. |