Skip to content
Snippets Groups Projects
Commit b1446252 authored by Amin Timany's avatar Amin Timany
Browse files

fix minor issues

parent e7d42f1d
No related branches found
No related tags found
1 merge request!64logrel: Change nat to int
Pipeline #97150 passed
...@@ -86,7 +86,7 @@ Section fact_equiv. ...@@ -86,7 +86,7 @@ Section fact_equiv.
iExists (#nv _); iFrame; eauto. } iExists (#nv _); iFrame; eauto. }
generalize 1%Z as l => l. generalize 1%Z as l => l.
iLöb as "IH" forall (n l). iLöb as "IH" forall (n l).
destruct (decide (n = 0)) as [->|]. destruct (decide (n = 0)%Z) as [->|].
- iApply wp_pure_step_later; auto. - iApply wp_pure_step_later; auto.
iIntros "!> _"; simpl; asimpl. iIntros "!> _"; simpl; asimpl.
rewrite fact_acc_body_unfold. rewrite fact_acc_body_unfold.
...@@ -117,12 +117,14 @@ Section fact_equiv. ...@@ -117,12 +117,14 @@ Section fact_equiv.
iApply wp_pure_step_later; auto. iApply wp_pure_step_later; auto.
iIntros "!> _"; simpl. iIntros "!> _"; simpl.
iApply wp_value. simpl. iApply wp_value. simpl.
destruct Z.eq_dec; first lia. destruct (decide (n = 0)%Z); first lia.
rewrite bool_decide_eq_false_2; last done.
iMod (do_step_pure _ _ (IfCtx _ _ :: _) with "[$Hj]") as "Hj"; auto. iMod (do_step_pure _ _ (IfCtx _ _ :: _) with "[$Hj]") as "Hj"; auto.
simpl. simpl.
iApply wp_pure_step_later; auto. iApply wp_pure_step_later; auto.
iIntros "!> _"; simpl. iIntros "!> _"; simpl.
destruct Z.eq_dec; first lia. destruct (decide (n = 0)%Z); first lia.
rewrite bool_decide_eq_false_2; last done.
iMod (do_step_pure with "[$Hj]") as "Hj"; auto. iMod (do_step_pure with "[$Hj]") as "Hj"; auto.
asimpl. asimpl.
iApply (wp_bind (fill [BinOpRCtx _ (#nv _)])). iApply (wp_bind (fill [BinOpRCtx _ (#nv _)])).
...@@ -201,12 +203,14 @@ Section fact_equiv. ...@@ -201,12 +203,14 @@ Section fact_equiv.
iApply wp_pure_step_later; auto. iApply wp_pure_step_later; auto.
iIntros "!> _"; simpl. iIntros "!> _"; simpl.
iApply wp_value. simpl. iApply wp_value. simpl.
destruct Z.eq_dec; first done. destruct (decide (n = 0)%Z); first lia.
rewrite bool_decide_eq_false_2; last done.
iMod (do_step_pure _ _ (IfCtx _ _ :: _) with "[$Hj]") as "Hj"; auto. iMod (do_step_pure _ _ (IfCtx _ _ :: _) with "[$Hj]") as "Hj"; auto.
simpl. simpl.
iApply wp_pure_step_later; auto. iApply wp_pure_step_later; auto.
iIntros "!> _"; simpl. iIntros "!> _"; simpl.
destruct Z.eq_dec; first done. destruct (decide (n = 0)%Z); first lia.
rewrite bool_decide_eq_false_2; last done.
iMod (do_step_pure with "[$Hj]") as "Hj"; auto. iMod (do_step_pure with "[$Hj]") as "Hj"; auto.
iMod (do_step_pure _ _ (AppRCtx (RecV _):: BinOpRCtx _ (#nv _) :: _) iMod (do_step_pure _ _ (AppRCtx (RecV _):: BinOpRCtx _ (#nv _) :: _)
with "[$Hj]") as "Hj"; eauto. with "[$Hj]") as "Hj"; eauto.
......
...@@ -94,22 +94,18 @@ Module F_mu_ref_conc. ...@@ -94,22 +94,18 @@ Module F_mu_ref_conc.
| Add => λ a b, #nv(a + b) | Add => λ a b, #nv(a + b)
| Sub => λ a b, #nv(a - b) | Sub => λ a b, #nv(a - b)
| Mult => λ a b, #nv(a * b) | Mult => λ a b, #nv(a * b)
| Eq => λ a b, if (Z.eq_dec a b) then #♭v true else #♭v false | Eq => λ a b, #♭v (bool_decide (a = b))
| Le => λ a b, if (Z.le_dec a b) then #♭v true else #♭v false | Le => λ a b, #♭v (bool_decide (a b)%Z)
| Lt => λ a b, if (Z.lt_dec a b) then #♭v true else #♭v false | Lt => λ a b, #♭v (bool_decide (a < b)%Z)
end. end.
Definition binop_eval (op : binop) : val val option val := Definition binop_eval (op : binop) : val val option val :=
match op with match op with
| Eq => λ a b, Some (#♭v (bool_decide (a = b))) | Eq => λ a b, Some (#♭v (bool_decide (a = b)))
| _ => λ a b, | _ => λ a b,
match a with match a, b with
| IntV an => | IntV an, IntV bn => Some (int_binop_eval op an bn)
match b with | _, _ => None
| IntV bn => Some (int_binop_eval op an bn)
| _ => None
end
| _ => None
end end
end. end.
......
...@@ -102,7 +102,9 @@ Section symbol_nat_sem_typ. ...@@ -102,7 +102,9 @@ Section symbol_nat_sem_typ.
iModIntro. iModIntro.
simpl. simpl.
iApply wp_pure_step_later; auto. iIntros "!> _". iApply wp_pure_step_later; auto. iIntros "!> _".
simpl. destruct Z.lt_dec; last lia. simpl.
destruct (decide (m < t)%Z); last lia.
rewrite bool_decide_eq_true_2; last done.
iApply wp_value. iApply wp_value.
iApply wp_pure_step_later; auto. iIntros "!> _". iApply wp_pure_step_later; auto. iIntros "!> _".
iApply wp_value; eauto. iApply wp_value; eauto.
......
...@@ -142,7 +142,15 @@ Section lang_rules. ...@@ -142,7 +142,15 @@ Section lang_rules.
Local Ltac solve_exec_safe := Local Ltac solve_exec_safe :=
intros; subst; do 3 eexists; econstructor; simpl; eauto. intros; subst; do 3 eexists; econstructor; simpl; eauto.
Local Ltac solve_exec_puredet := simpl; intros; by inv_base_step. Local Ltac solve_exec_puredet :=
simpl; intros;
by inv_base_step;
repeat match goal with
|- context [bool_decide ?A] =>
destruct (decide A);
[rewrite (bool_decide_eq_true_2 A); last done|
rewrite (bool_decide_eq_false_2 A); last done]
end; simplify_eq/=; auto.
Local Ltac solve_pure_exec := Local Ltac solve_pure_exec :=
unfold IntoVal in *; unfold IntoVal in *;
repeat match goal with H : AsVal _ |- _ => destruct H as [??] end; subst; repeat match goal with H : AsVal _ |- _ => destruct H as [??] end; subst;
...@@ -202,31 +210,10 @@ Section lang_rules. ...@@ -202,31 +210,10 @@ Section lang_rules.
Global Instance wp_int_binop op a b : Global Instance wp_int_binop op a b :
PureExec True 1 (BinOp op (#n a) (#n b)) (of_val (int_binop_eval op a b)). PureExec True 1 (BinOp op (#n a) (#n b)) (of_val (int_binop_eval op a b)).
Proof. Proof. destruct op; solve_pure_exec. Qed.
destruct op;
(unfold IntoVal in *;
repeat match goal with H : AsVal _ |- _ => destruct H as [??] end; subst;
intros ?; apply nsteps_once, pure_base_step_pure_step;
constructor; [solve_exec_safe |try solve_exec_puredet]); [].
intros; simpl in *; inv_base_step.
destruct Z.eq_dec as [->|];
[rewrite bool_decide_eq_true_2; done|
rewrite bool_decide_eq_false_2; eauto with congruence].
Qed.
Global Instance wp_Eq_binop `{!AsVal e1} `{!AsVal e2} : Global Instance wp_Eq_binop `{!AsVal e1} `{!AsVal e2} :
PureExec True 1 (BinOp Eq e1 e2) (#♭ (bool_decide (e1 = e2))). PureExec True 1 (BinOp Eq e1 e2) (#♭ (bool_decide (e1 = e2))).
Proof. Proof. solve_pure_exec. Qed.
unfold IntoVal in *;
repeat match goal with H : AsVal _ |- _ => destruct H as [??] end; subst;
intros ?; apply nsteps_once, pure_base_step_pure_step;
constructor; [solve_exec_safe |]; [].
intros; simpl in *; inv_base_step.
match goal with |- context[ bool_decide (?A = ?B)] =>
destruct (decide (A = B)) as [->|] end;
[rewrite !bool_decide_eq_true_2; done|
rewrite !bool_decide_eq_false_2; eauto].
intros ?%of_val_inj; done.
Qed.
End lang_rules. End lang_rules.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment