@@ -34,9 +34,8 @@ def setRiskFun : Fun :=
3434def checkHealthFun : Fun :=
3535 { name := "checkHealth"
3636 args := []
37- body := unless
37+ body := revertIf
3838 (Expr.lt (sloadSlot 0 ) (Expr.mul (sloadSlot 1 ) (sloadSlot 2 )))
39- Stmt.skip
4039 ret := none }
4140
4241-- Execution facts.
@@ -52,13 +51,13 @@ theorem setRisk_updates (collateral debt minHF : Nat) :
5251theorem checkHealth_ok (collateral debt minHF : Nat) (h : debt * minHF <= collateral) :
5352 execFun checkHealthFun [] (riskStore collateral debt minHF) [] =
5453 ExecResult.ok (bindArgs emptyEnv [] []) (riskStore collateral debt minHF) := by
55- simp [checkHealthFun, unless , sloadSlot, execFun, execStmt, evalExpr, riskStore,
54+ simp [checkHealthFun, revertIf , sloadSlot, execFun, execStmt, evalExpr, riskStore,
5655 bindArgs, emptyEnv, updateEnv, updateStore, not_lt_of_ge h]
5756
5857theorem checkHealth_reverts (collateral debt minHF : Nat) (h : collateral < debt * minHF) :
5958 execFun checkHealthFun [] (riskStore collateral debt minHF) [] =
6059 ExecResult.reverted := by
61- simp [checkHealthFun, unless , sloadSlot, execFun, execStmt, evalExpr, riskStore,
60+ simp [checkHealthFun, revertIf , sloadSlot, execFun, execStmt, evalExpr, riskStore,
6261 bindArgs, emptyEnv, updateEnv, updateStore, h]
6362
6463-- Risk specs (Store-level).
@@ -95,7 +94,7 @@ theorem checkHealth_meets_spec (s : Store) :
9594 | ExecResult.ok _ s' => checkHealthSpec.ensures s s'
9695 | _ => False) := by
9796 intro hreq
98- simp [checkHealthSpec, riskOk, checkHealthFun, unless , sloadSlot, execFun, execStmt,
97+ simp [checkHealthSpec, riskOk, checkHealthFun, revertIf , sloadSlot, execFun, execStmt,
9998 evalExpr, bindArgs, emptyEnv, updateEnv, updateStore, not_lt_of_ge hreq]
10099
101100theorem checkHealth_meets_specR_ok (s : Store) :
@@ -104,14 +103,14 @@ theorem checkHealth_meets_specR_ok (s : Store) :
104103 | ExecResult.ok _ s' => checkHealthSpecR.ensures s s'
105104 | _ => False) := by
106105 intro hreq
107- simp [checkHealthSpecR, riskOk, checkHealthFun, unless , sloadSlot, execFun, execStmt,
106+ simp [checkHealthSpecR, riskOk, checkHealthFun, revertIf , sloadSlot, execFun, execStmt,
108107 evalExpr, bindArgs, emptyEnv, updateEnv, updateStore, not_lt_of_ge hreq]
109108
110109theorem checkHealth_meets_specR_reverts (s : Store) :
111110 checkHealthSpecR.reverts s ->
112111 execFun checkHealthFun [] s [] = ExecResult.reverted := by
113112 intro hrev
114- simp [checkHealthSpecR, checkHealthFun, unless , sloadSlot, execFun, execStmt, evalExpr,
113+ simp [checkHealthSpecR, checkHealthFun, revertIf , sloadSlot, execFun, execStmt, evalExpr,
115114 bindArgs, emptyEnv, updateEnv, updateStore, hrev]
116115
117116end DumbContracts.Examples
0 commit comments