Commit 2772669f by MARCHE Claude

### hoare logic: consequence rule

parent 8146bf11
 ... ... @@ -149,15 +149,6 @@ lemma steps_non_neg: forall s1 s2:state, i1 i2:stmt, n:int. many_steps s1 i1 s2 i2 n -> n >= 0 (* lemma many_steps_seq_rec: forall s1 s3:state, i i3:stmt. many_steps s1 i s3 i3 -> i3 = Sskip -> forall i1 i2:stmt. i = Sseq i1 i2 -> exists s2:state. many_steps s1 i1 s2 Sskip /\ many_steps s2 i2 s3 Sskip *) lemma many_steps_seq: forall s1 s3:state, i1 i2:stmt, n:int. many_steps s1 (Sseq i1 i2) s3 Sskip n -> ... ... @@ -173,12 +164,14 @@ type fmla = | Fterm expr | Fand fmla fmla | Fnot fmla | Fimplies fmla fmla predicate eval_fmla (s:state) (f:fmla) = match f with | Fterm e -> eval_expr s e <> 0 | Fand f1 f2 -> eval_fmla s f1 /\ eval_fmla s f2 | Fnot f -> not (eval_fmla s f) | Fimplies f1 f2 -> eval_fmla s f1 -> eval_fmla s f2 end (* substitution *) ... ... @@ -200,12 +193,15 @@ function subst (f:fmla) (x:ident) (t:expr) : fmla = | Fterm e -> Fterm (subst_expr e x t) | Fand f1 f2 -> Fand (subst f1 x t) (subst f2 x t) | Fnot f -> Fnot (subst f x t) | Fimplies f1 f2 -> Fimplies (subst f1 x t) (subst f2 x t) end lemma eval_subst: forall s:state, f:fmla, x:ident, t:expr. eval_fmla s (subst f x t) <-> eval_fmla (IdMap.set s x (eval_expr s t)) f predicate valid_fmla (p:fmla) = forall s:state. eval_fmla s p (* Hoare triples *) predicate valid_triple (p:fmla) (i:stmt) (q:fmla) = ... ... @@ -233,21 +229,18 @@ lemma if_rule: valid_triple (Fand p (Fnot (Fterm e))) i2 q -> valid_triple p (Sif e i1 i2) q (* lemma while_rule_rec: forall e:expr, inv:fmla, i:stmt. valid_triple (Fand (Fterm e) inv) i inv -> forall s s':state, l skip:stmt. many_steps s l s' skip -> l = (Swhile e i) -> skip = Sskip -> eval_fmla s inv -> eval_fmla s' (Fand (Fnot (Fterm e)) inv) *) lemma while_rule: forall e:expr, inv:fmla, i:stmt. valid_triple (Fand (Fterm e) inv) i inv -> valid_triple inv (Swhile e i) (Fand (Fnot (Fterm e)) inv) lemma consequence_rule: forall p p' q q':fmla, i:stmt. valid_fmla (Fimplies p' p) -> valid_triple p i q -> valid_fmla (Fimplies q q') -> valid_triple p' i q' end ... ...
 ... ... @@ -118,7 +118,8 @@ Axiom many_steps_seq : forall (s1:(map ident Z)) (s3:(map ident Z)) (i1:stmt) Inductive fmla := | Fterm : expr -> fmla | Fand : fmla -> fmla -> fmla | Fnot : fmla -> fmla . | Fnot : fmla -> fmla | Fimplies : fmla -> fmla -> fmla . Set Implicit Arguments. Fixpoint eval_fmla(s:(map ident Z)) (f:fmla) {struct f}: Prop := ... ... @@ -126,6 +127,7 @@ Fixpoint eval_fmla(s:(map ident Z)) (f:fmla) {struct f}: Prop := | (Fterm e) => ~ ((eval_expr s e) = 0%Z) | (Fand f1 f2) => (eval_fmla s f1) /\ (eval_fmla s f2) | (Fnot f1) => ~ (eval_fmla s f1) | (Fimplies f1 f2) => (eval_fmla s f1) -> (eval_fmla s f2) end. Unset Implicit Arguments. ... ... @@ -151,6 +153,7 @@ Fixpoint subst(f:fmla) (x:ident) (t:expr) {struct f}: fmla := | (Fterm e) => (Fterm (subst_expr e x t)) | (Fand f1 f2) => (Fand (subst f1 x t) (subst f2 x t)) | (Fnot f1) => (Fnot (subst f1 x t)) | (Fimplies f1 f2) => (Fimplies (subst f1 x t) (subst f2 x t)) end. Unset Implicit Arguments. ... ... @@ -176,6 +179,12 @@ simpl. intros x t. rewrite IHf. tauto. simpl. intros x t. rewrite IHf1. rewrite IHf2. tauto. Qed. (* DO NOT EDIT BELOW *) ... ...
 ... ... @@ -49,11 +49,11 @@ expanded="true"> expanded="true"> ... ... @@ -205,12 +205,12 @@ timelimit="3" edited="imp_n_Imp_eval_subst_expr_1.v" obsolete="false"> ... ... @@ -219,12 +219,12 @@ timelimit="3" edited="imp_n_Imp_eval_subst_1.v" obsolete="false"> ... ... @@ -233,12 +233,12 @@ timelimit="3" edited="" obsolete="false"> ... ... @@ -247,12 +247,12 @@ timelimit="3" edited="imp_n_Imp_assign_rule_1.v" obsolete="false"> ... ... @@ -261,12 +261,12 @@ timelimit="3" edited="imp_n_Imp_seq_rule_1.v" obsolete="false"> ... ... @@ -275,12 +275,12 @@ timelimit="3" edited="imp_n_Imp_if_rule_1.v" obsolete="false"> ... ... @@ -289,7 +289,28 @@ timelimit="3" edited="imp_n_Imp_while_rule_1.v" obsolete="false"> ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!