Commit 66c45c70 by Martin Clochard

### mini-compiler: cleanup

parent f7f8465e
This diff is collapsed.
This diff is collapsed.
No preview for this file type
 theory Imp use import state.State use import bool.Bool use import int.Int ... ... @@ -29,84 +30,57 @@ theory Imp (* ************************ SEMANTICS ************************ *) function aeval (st: state) (e: aexpr) : int = function aeval (st:state) (e:aexpr) : int = match e with | Anum n -> n | Avar x -> st[x] | Aadd e1 e2 -> aeval st e1 + aeval st e2 | Asub e1 e2 -> aeval st e1 - aeval st e2 | Amul e1 e2 -> aeval st e1 * aeval st e2 end function beval (st:state) (b:bexpr) : bool = match b with | Btrue -> true | Bfalse -> false | Bnot b' -> notb (beval st b') | Band b1 b2 -> andb (beval st b1) (beval st b2) | Beq a1 a2 -> aeval st a1 = aeval st a2 | Ble a1 a2 -> aeval st a1 <= aeval st a2 end function beval (st : state) (b: bexpr) : bool = match b with | Btrue -> True | Bfalse -> False | Bnot b' -> notb (beval st b') | Band b1 b2 -> andb (beval st b1) (beval st b2) | Beq a1 a2 -> if (aeval st a1) = (aeval st a2) then True else False | Ble a1 a2 -> if (aeval st a1) <= (aeval st a2) then True else False end (* lemma inversion_beval_t : forall a1 a2: aexpr, m: state. beval m (Beq a1 a2) = True -> aeval m a1 = aeval m a2 lemma inversion_beval_f : forall a1 a2: aexpr, m: state. beval m (Beq a1 a2) = False -> aeval m a1 <> aeval m a2 *) inductive ceval state com state = (* skip *) | E_Skip : forall m: state. ceval m Cskip m (* assignement *) | E_Ass : forall m: state, a: aexpr, n: int, x: id. aeval m a = n -> ceval m (Cassign x a) m[x <- n] (* sequence *) | E_Seq : forall cmd1 cmd2: com, m0 m1 m2: state. ceval m0 cmd1 m1 -> ceval m1 cmd2 m2 -> ceval m0 (Cseq cmd1 cmd2) m2 (* if then else *) | E_IfTrue : forall m0 m1: state, cond: bexpr, cmd1 cmd2: com. beval m0 cond = True -> ceval m0 cmd1 m1 -> ceval m0 (Cif cond cmd1 cmd2) m1 | E_IfFalse : forall m0 m1: state, cond: bexpr, cmd1 cmd2: com. beval m0 cond = False -> ceval m0 cmd2 m1 -> ceval m0 (Cif cond cmd1 cmd2) m1 (* while *) | E_WhileEnd : forall cond: bexpr, m: state, body: com. beval m cond = False -> ceval m (Cwhile cond body) m | E_WhileLoop : forall mi mj mf: state, cond: bexpr, body: com. beval mi cond = True -> ceval mi body mj -> ceval mj (Cwhile cond body) mf -> ceval mi (Cwhile cond body) mf lemma ceval_deterministic_aux : forall c mi mf1. ceval mi c mf1 -> forall mf2. ("inversion" ceval mi c mf2) -> mf1 = mf2 lemma ceval_deterministic : forall c mi mf1 mf2. ceval mi c mf1 -> ceval mi c mf2 -> mf1 = mf2 end \ No newline at end of file inductive ceval state com state = (* skip *) | E_Skip : forall m. ceval m Cskip m (* assignement *) | E_Ass : forall m a x. ceval m (Cassign x a) m[x <- aeval m a] (* sequence *) | E_Seq : forall cmd1 cmd2 m0 m1 m2. ceval m0 cmd1 m1 -> ceval m1 cmd2 m2 -> ceval m0 (Cseq cmd1 cmd2) m2 (* if then else *) | E_IfTrue : forall m0 m1 cond cmd1 cmd2. beval m0 cond -> ceval m0 cmd1 m1 -> ceval m0 (Cif cond cmd1 cmd2) m1 | E_IfFalse : forall m0 m1 cond cmd1 cmd2. not beval m0 cond -> ceval m0 cmd2 m1 -> ceval m0 (Cif cond cmd1 cmd2) m1 (* while *) | E_WhileEnd : forall cond m body. not beval m cond -> ceval m (Cwhile cond body) m | E_WhileLoop : forall mi mj mf cond body. beval mi cond -> ceval mi body mj -> ceval mj (Cwhile cond body) mf -> ceval mi (Cwhile cond body) mf lemma ceval_deterministic_aux : forall c mi mf1. ceval mi c mf1 -> forall mf2. ("inversion" ceval mi c mf2) -> mf1 = mf2 lemma ceval_deterministic : forall c mi mf1 mf2. ceval mi c mf1 -> ceval mi c mf2 -> mf1 = mf2 end
 ... ... @@ -5,9 +5,9 @@ ... ... @@ -42,13 +42,13 @@ ... ... @@ -185,8 +185,8 @@ ... ...
No preview for this file type
This diff is collapsed.
 ... ... @@ -6,8 +6,8 @@ ... ... @@ -23,7 +23,7 @@ ... ... @@ -63,9 +63,6 @@ ... ...
No preview for this file type
This diff is collapsed.
This diff is collapsed.
No preview for this file type
 theory State clone export map.Map type id = Id int type state = map id int (*...*) end
This diff is collapsed.
 ... ... @@ -3,31 +3,29 @@ "http://why3.lri.fr/why3session.dtd"> ... ...
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!