Commit e8de79e4 by charguer

### vars

parent 274c256e
 ... ... @@ -36,9 +36,9 @@ Definition Formula := forall `{Enc A}, hprop -> (A -> hprop) -> Prop. Global Instance Inhab_Formula : Inhab Formula. Proof using. apply (Inhab_of_val (fun _ _ _ _ => True)). Qed. Notation "' F H Q" := ((F:Formula) _ _ H Q) Notation "^ F H Q" := ((F:Formula) _ _ H Q) (at level 65, F at level 0, H at level 0, Q at level 0, format "' F H Q") : charac. format "^ F H Q") : charac. (** Constructor to force the return type of a Formula *) Definition Formula_typed `{Enc A1} (F : hprop->(A1->hprop)->Prop) : Formula := ... ... @@ -85,23 +85,23 @@ Definition Cf_val (v:val) : Formula := Definition Cf_if_val (v:val) (F1 F2 : Formula) : Formula := fun `{Enc A} H (Q:A->hprop) => exists (b:bool), v = enc b /\ (b = true -> 'F1 H Q) /\ (b = false -> 'F2 H Q). (b = true -> ^F1 H Q) /\ (b = false -> ^F2 H Q). Definition Cf_seq (F1 : Formula) (F2 : Formula) : Formula := fun `{Enc A} H (Q:A->hprop) => exists (Q1:unit->hprop), 'F1 H Q1 /\ 'F2 (Q1 tt) Q. exists (Q1:unit->hprop), ^F1 H Q1 /\ ^F2 (Q1 tt) Q. Definition Cf_let (F1 : Formula) (F2of : forall `{EA1:Enc A1}, A1 -> Formula) : Formula := fun `{Enc A} H (Q:A->hprop) => exists (A1:Type) (EA1:Enc A1) (Q1:A1->hprop), 'F1 H Q1 /\ (forall (X:A1), '(F2of X) (Q1 X) Q). ^F1 H Q1 /\ (forall (X:A1), ^(F2of X) (Q1 X) Q). Definition Cf_let_typed `{EA1:Enc A1} (F1 : Formula) (F2of : A1 -> Formula) : Formula := fun `{Enc A} H (Q:A->hprop) => exists (Q1:A1->hprop), 'F1 H Q1 /\ (forall (X:A1), '(F2of X) (Q1 X) Q). ^F1 H Q1 /\ (forall (X:A1), ^(F2of X) (Q1 X) Q). Definition Cf_if (F0 F1 F2 : Formula) : Formula := Cf_let_typed F0 (fun (X:bool) => Local (Cf_if_val (enc X) F1 F2)). ... ... @@ -114,18 +114,18 @@ Definition Cf_while (F1 F2 : Formula) : Formula := fun `{Enc A} H (Q:A->hprop) => forall (F:Formula), is_local (@F unit _) -> (forall H' (Q':unit->hprop), '(Local (Cf_if F1 (Local (Cf_seq F2 (F:Formula))) (Local (Cf_val val_unit)))) H' Q' -> '(F:Formula) H' Q') -> '(F:Formula) H Q. ^(Local (Cf_if F1 (Local (Cf_seq F2 (F:Formula))) (Local (Cf_val val_unit)))) H' Q' -> ^(F:Formula) H' Q') -> ^(F:Formula) H Q. *) Definition Cf_while (F1 F2 : Formula) : Formula := Formula_typed (fun H (Q:unit->hprop) => forall (F:Formula), is_local (@F unit _) -> (forall H' (Q':unit->hprop), '(Local (Cf_if F1 (Local (Cf_seq F2 (F:Formula))) (Local (Cf_val val_unit)))) H' Q' -> '(F:Formula) H' Q') -> '(F:Formula) H Q). ^(Local (Cf_if F1 (Local (Cf_seq F2 (F:Formula))) (Local (Cf_val val_unit)))) H' Q' -> ^(F:Formula) H' Q') -> ^(F:Formula) H Q). Definition Cf_for (n1 n2 : int) (F1 : int->Formula) : Formula := (* Formula_typed (fun H (Q:unit->hprop) => *) ... ... @@ -133,8 +133,8 @@ Definition Cf_for (n1 n2 : int) (F1 : int->Formula) : Formula := forall (S:int->Formula), (forall i, is_local (@S i unit _)) -> let F i := Local (If (i <= n2) then (Local (Cf_seq (F1 i) (S (i+1)))) else (Local (Cf_val val_unit))) in (forall i H' Q', '(F i) H' Q' -> '(S i) H' Q') -> '(S n1) H Q. (forall i H' Q', ^(F i) H' Q' -> ^(S i) H' Q') -> ^(S n1) H Q. (* ---------------------------------------------------------------------- *) ... ... @@ -195,7 +195,7 @@ Proof. Qed. Definition Sound_for (t:trm) (F:Formula) := forall `{EA:Enc A} H (Q:A->hprop), 'F H Q -> Triple t H Q. forall `{EA:Enc A} H (Q:A->hprop), ^F H Q -> Triple t H Q. Lemma Sound_for_Local : forall t (F:Formula), Sound_for t F -> ... ... @@ -269,7 +269,7 @@ Proof using. Qed. Theorem Triple_of_Cf : forall (t:trm) A `{EA:Enc A} H (Q:A->hprop), '(Cf t) H Q -> ^(Cf t) H Q -> Triple t H Q. Proof using. intros. applys* Sound_for_Cf. Qed. ... ... @@ -383,14 +383,14 @@ Definition Cf_while_inv (F1 F2 : Formula) := fun (H:hprop) (Q:unit->hprop) => wf R /\ (H ==> Hexists b X, I b X \* H') /\ (forall (F:Formula), is_local (@F unit _) -> forall b X, (forall b' X', R X' X -> 'F (I b' X') (fun (_:unit) => Hexists Y, I false Y)) -> '(Local (Cf_if F1 (Local (Cf_seq F2 F)) (Local (Cf_val val_unit)))) (forall b' X', R X' X -> ^F (I b' X') (fun (_:unit) => Hexists Y, I false Y)) -> ^(Local (Cf_if F1 (Local (Cf_seq F2 F)) (Local (Cf_val val_unit)))) (I b X) (fun (_:unit) => Hexists Y, I false Y)) /\ ((fun (_:unit) => Hexists X, I false X \* H') ===> Q). Lemma Cf_while_of_Cf_while_inv : forall (F1 F2 : Formula) (H:hprop) (Q:unit->hprop), (Cf_while_inv F1 F2) H Q -> '(Cf_while F1 F2) H Q. ^(Cf_while F1 F2) H Q. Proof using. introv (A&I&R&H'&MR&MH&MB&MQ). exists Q; split; [|applys @PostChange_refl]. intros F LF HF. xchange MH. xpull ;=> b X. ... ... @@ -709,9 +709,9 @@ Proof using. intros. hnf. exists A1 EA1 Q1. auto. Qed. Lemma Cf_let_intro : forall A1 (EA1:Enc A1) (Q1:A1->hprop) (F1 : Formula) (F2of : forall A1 `{EA1:Enc A1}, A1 -> Formula), forall A (EA:Enc A) H (Q:A->hprop), 'F1 H Q1 -> (forall (X:A1), '(F2of A1 X) (Q1 X) Q) -> '(Cf_let F1 F2of) H Q. ^F1 H Q1 -> (forall (X:A1), ^(F2of A1 X) (Q1 X) Q) -> ^(Cf_let F1 F2of) H Q. Proof using. intros. hnf. exists A1 EA1 Q1. auto. Qed. Ltac xlet_untyped_core tt := ... ...
 ... ... @@ -248,6 +248,69 @@ End Red. (* ********************************************************************** *) (* * Notation for terms *) (* ---------------------------------------------------------------------- *) (** Notation for program variables *) Notation "''a'" := ("a":var) : var_scope. Notation "''b'" := ("b":var) : var_scope. Notation "''c'" := ("c":var) : var_scope. Notation "''d'" := ("d":var) : var_scope. Notation "''e'" := ("e":var) : var_scope. Notation "''f'" := ("f":var) : var_scope. Notation "''g'" := ("g":var) : var_scope. Notation "''h'" := ("h":var) : var_scope. Notation "''i'" := ("i":var) : var_scope. Notation "''j'" := ("j":var) : var_scope. Notation "''k'" := ("k":var) : var_scope. Notation "''l'" := ("l":var) : var_scope. Notation "''m'" := ("m":var) : var_scope. Notation "''n'" := ("n":var) : var_scope. Notation "''o'" := ("o":var) : var_scope. Notation "''p'" := ("p":var) : var_scope. Notation "''q'" := ("q":var) : var_scope. Notation "''r'" := ("r":var) : var_scope. Notation "''s'" := ("s":var) : var_scope. Notation "''t'" := ("t":var) : var_scope. Notation "''u'" := ("u":var) : var_scope. Notation "''v'" := ("v":var) : var_scope. Notation "''w'" := ("w":var) : var_scope. Notation "''x'" := ("x":var) : var_scope. Notation "''y'" := ("y":var) : var_scope. Notation "''z'" := ("z":var) : var_scope. Notation "''A'" := ("A":var) : var_scope. Notation "''B'" := ("B":var) : var_scope. Notation "''C'" := ("C":var) : var_scope. Notation "''D'" := ("D":var) : var_scope. Notation "''E'" := ("E":var) : var_scope. Notation "''F'" := ("F":var) : var_scope. Notation "''G'" := ("G":var) : var_scope. Notation "''H'" := ("H":var) : var_scope. Notation "''I'" := ("I":var) : var_scope. Notation "''J'" := ("J":var) : var_scope. Notation "''K'" := ("K":var) : var_scope. Notation "''L'" := ("L":var) : var_scope. Notation "''M'" := ("M":var) : var_scope. Notation "''N'" := ("N":var) : var_scope. Notation "''O'" := ("O":var) : var_scope. Notation "''P'" := ("P":var) : var_scope. Notation "''Q'" := ("Q":var) : var_scope. Notation "''R'" := ("R":var) : var_scope. Notation "''S'" := ("S":var) : var_scope. Notation "''T'" := ("T":var) : var_scope. Notation "''U'" := ("U":var) : var_scope. Notation "''V'" := ("V":var) : var_scope. Notation "''W'" := ("W":var) : var_scope. Notation "''X'" := ("X":var) : var_scope. Notation "''Y'" := ("Y":var) : var_scope. Notation "''Z'" := ("Z":var) : var_scope. Open Scope var_scope. (* Note: for variable names with several letters, add your own definition *) (* ---------------------------------------------------------------------- *) (** Notation for concrete programs *) ... ...