Commit 94cd4223 authored by Jacques-Henri Jourdan's avatar Jacques-Henri Jourdan

Solve Admits.

parent 16caa857
...@@ -122,10 +122,7 @@ Qed. ...@@ -122,10 +122,7 @@ Qed.
Lemma RO_Box_fold : forall p q n, Lemma RO_Box_fold : forall p q n,
RO (p ~~~> q \* q ~~~> n) ==> RO (p ~> Box n). RO (p ~~~> q \* q ~~~> n) ==> RO (p ~> Box n).
Proof using. Proof using. iIntros (???) "?". xunfold Box. by iExists _. Qed.
intros. xunfold Box. rewrite RO_hexists. hsimpl.
(* TODO: use proof mode *)
Qed.
Arguments Box_fold : clear implicits. Arguments Box_fold : clear implicits.
Arguments Box_unfold : clear implicits. Arguments Box_unfold : clear implicits.
...@@ -140,13 +137,10 @@ Definition val_box_get := ...@@ -140,13 +137,10 @@ Definition val_box_get :=
val_get 'q. val_get 'q.
Tactic Notation "xletapp" constr(M) := Tactic Notation "xletapp" constr(M) :=
ram_apply_let M; ram_apply_let M;
[ solve [ auto 20 with iFrame ] [ solve [ auto 20 with iFrame ]
| unlock; xpull; simpl ]. | unlock; xpull; simpl ].
Tactic Notation "xapp" constr(M) :=
apply rule_htop_post; ram_apply M.
Lemma rule_box_get : forall p n, Lemma rule_box_get : forall p n,
triple (val_box_get p) triple (val_box_get p)
PRE (RO (p ~> Box n)) PRE (RO (p ~> Box n))
...@@ -154,9 +148,8 @@ Lemma rule_box_get : forall p n, ...@@ -154,9 +148,8 @@ Lemma rule_box_get : forall p n,
Proof using. Proof using.
intros. xdef. xchanges (RO_Box_unfold p) ;=> q. intros. xdef. xchanges (RO_Box_unfold p) ;=> q.
xletapp rule_get_ro => ? ->. xletapp rule_get_ro => ? ->.
xapp rule_get_ro. ram_apply rule_get_ro. admit. (* TODO: complete proof *)
iIntros. iFrame. iIntros. admit. (* TODO: complete proof *) Admitted.
Qed.
(* detailed proof (to keep somewhere for debugging): (* detailed proof (to keep somewhere for debugging):
intros. xdef. xchange (RO_Box_unfold p). xpull ;=> q. intros. xdef. xchange (RO_Box_unfold p). xpull ;=> q.
...@@ -227,9 +220,9 @@ Qed. ...@@ -227,9 +220,9 @@ Qed.
Arguments RO_Box_fold : clear implicits. Arguments RO_Box_fold : clear implicits.
Lemma rule_box_twice : forall (F:int->int) n (f:val) p, Lemma rule_box_twice : forall (F:int->int) n (f:val) p,
(forall (x:int) (H:hprop), triple (f x) (forall (x:int), triple (f x)
PRE (RO(p ~> Box n) \* H) PRE (RO(p ~> Box n))
POST (fun r => \[r = val_int (F x)] \* H)) -> POST (fun r => \[r = val_int (F x)])) ->
triple (val_box_twice f p) triple (val_box_twice f p)
PRE (p ~> Box n) PRE (p ~> Box n)
POST (fun r => \[r = val_unit] \* p ~> Box (2 * F n)). POST (fun r => \[r = val_unit] \* p ~> Box (2 * F n)).
...@@ -237,44 +230,28 @@ Proof using. ...@@ -237,44 +230,28 @@ Proof using.
introv M. xdef. xchange (Box_unfold p). xpull ;=> q. introv M. xdef. xchange (Box_unfold p). xpull ;=> q.
xletapp rule_get_ro => ? ->. xletapp rule_get_ro => ? ->.
xletapp rule_get_ro => ? ->. xletapp rule_get_ro => ? ->.
(* details of above: ram_apply_let M.
ram_apply_let rule_get_ro. { auto with iFrame. } { rewrite -RO_Box_fold. iIntros "Hq Hp". iCombine "Hp Hq" as "H".
unlock. move=>? /=. xpull=>->. *) auto with iFrame. }
applys rule_let' __ (q ~~~> n \* p ~~~> q). hsimpl. unlock. xpull => /= a1 ->.
{ applys rule_frame_read_only_conseq (q ~~~> n \* p ~~~> q).
{ hsimpl. }
{ typeclass. }
{ xchange (RO_Box_fold p q n). rewrite hstar_comm. hsimpl.
applys M. }
{ applys refl_rel_incl'. } }
xpull => /= a1 ->.
xletapp rule_get_ro => ? ->. xletapp rule_get_ro => ? ->.
applys rule_let' __ (q ~~~> n \* p ~~~> q). hsimpl. ram_apply_let M.
{ applys rule_frame_read_only_conseq (q ~~~> n \* p ~~~> q). { rewrite -RO_Box_fold. iIntros "Hq Hp". iCombine "Hp Hq" as "H".
{ hsimpl. } auto with iFrame. }
{ typeclass. } unlock. xpull => /= a2 ->.
{ xchange (RO_Box_fold p q n). rewrite hstar_comm. hsimpl. xletapp rule_add => ? ->.
applys M. } ram_apply rule_set.
{ applys refl_rel_incl'. } } iIntros "Hp $ !> % -> Hq". iSplitR; [done|]. iApply Box_fold. iFrame.
xpull => /= a2 ->. by math_rewrite (2 * F n = F n + F n)%Z.
xletapp rule_add => ? ->. Qed.
xapp rule_set.
admit.
(* todo {
iIntros "$ Hp !> % -> Hq". iSplitR; [done|].
math_rewrite (2 * F n = F n + F n)%Z. iApply Box_fold. iFrame. } *)
Admitted.
Arguments rule_box_twice : clear implicits. Arguments rule_box_twice : clear implicits.
Definition val_box_demo := Definition val_box_demo :=
ValFun 'n := ValFun 'n :=
Let 'q := val_ref 'n in Let 'q := val_ref 'n in
Let 'p := val_ref 'q in Let 'p := val_ref 'q in
LetFun 'f 'x := LetFun 'f 'x :=
Let 'a := val_box_get 'p in Let 'a := val_box_get 'p in
'x '+ 'a in 'x '+ 'a in
Let 'u := val_box_twice 'f 'p in Let 'u := val_box_twice 'f 'p in
...@@ -286,7 +263,6 @@ Definition val_box_demo := ...@@ -286,7 +263,6 @@ Definition val_box_demo :=
but requires proving rule_seq, similar to rule_let. but requires proving rule_seq, similar to rule_let.
*) *)
Tactic Notation "xletfun" := Tactic Notation "xletfun" :=
applys rule_letfun; simpl; xpull. applys rule_letfun; simpl; xpull.
...@@ -304,9 +280,6 @@ Tactic Notation "xdef'" := (* todo: this replaces xdef *) ...@@ -304,9 +280,6 @@ Tactic Notation "xdef'" := (* todo: this replaces xdef *)
end end
end. end.
Lemma rule_box_demo : forall (n:int), Lemma rule_box_demo : forall (n:int),
triple (val_box_demo n) triple (val_box_demo n)
PRE \[] PRE \[]
...@@ -317,17 +290,15 @@ Proof using. ...@@ -317,17 +290,15 @@ Proof using.
xletapp rule_ref => ? p ->. xletapp rule_ref => ? p ->.
xletfun => F HF. xletfun => F HF.
ram_apply_let (rule_box_twice (fun (x:int) => (x + n)%Z) n). ram_apply_let (rule_box_twice (fun (x:int) => (x + n)%Z) n).
{ intros. xdef'. clear HF. { intros. xdef'. xletapp rule_box_get => m ->.
xletapp rule_box_get => m ->. ram_apply rule_add. { iIntros. admit. (* todo *) } }
xapp rule_add. { iIntros. iFrame. admit. (* todo *) } } { iIntros "Hq Hp". iDestruct (Box_fold with "[$Hq $Hp]") as "$".
{ admit. (* todo *) } auto with iFrame. }
{ intros u. simpl. (* auto *) unlock. xpull=> u /= _. ram_apply rule_box_get.
instantiate (1 := (fun (u:val) => p ~> Box (4*n))).
xapp rule_box_get. { admit. } (* todo *) }
Admitted.
assert (forall x, Normal (p ~> Box x)). admit.
math_rewrite (2 * (n + n) = 4 * n)%Z.
iIntros "$".
admit.
Qed.
...@@ -1791,10 +1791,11 @@ Proof. ...@@ -1791,10 +1791,11 @@ Proof.
apply bi.forall_elim. apply bi.forall_elim.
Qed. Qed.
Instance ROFrame_from_sep (P Q : hprop) : FromSep (ROFrame P Q) P Q. (* We do not wnad this instance to be picked by iCombine => low priority. *)
Instance ROFrame_from_sep (P Q : hprop) : FromSep (ROFrame P Q) P Q | 1000.
Proof. apply ROFrame_intro. Qed. Proof. apply ROFrame_intro. Qed.
Instance ROFrame_from_and (P Q : hprop) : Instance ROFrame_from_and (P Q : hprop) :
FromAnd (P Q) P Q FromAnd (ROFrame P Q) P Q. FromAnd (P Q) P Q FromAnd (ROFrame P Q) P Q | 1000.
Proof. rewrite /FromAnd=>->. apply ROFrame_intro. Qed. Proof. rewrite /FromAnd=>->. apply ROFrame_intro. Qed.
(** Frame instances *) (** Frame instances *)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment