aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2022-08-05 23:24:42 +0100
committerYann Herklotz <git@yannherklotz.com>2022-08-05 23:24:42 +0100
commit70135322f15ff7621b019fc64b095b2977587e15 (patch)
treed0f5ad277411574658103c78beb6b319fce1896d
parentd43f57ea8df27684bd2ad094998655066fdba99c (diff)
downloadvericert-70135322f15ff7621b019fc64b095b2977587e15.tar.gz
vericert-70135322f15ff7621b019fc64b095b2977587e15.zip
Update and fix the transformation
-rw-r--r--driver/VericertDriver.ml2
-rw-r--r--src/hls/Abstr.v6
-rw-r--r--src/hls/GiblePargen.v24
-rw-r--r--src/hls/GiblePargenproof.v505
-rw-r--r--src/hls/PrintAbstr.ml50
5 files changed, 314 insertions, 273 deletions
diff --git a/driver/VericertDriver.ml b/driver/VericertDriver.ml
index f2e0fc3..85a4372 100644
--- a/driver/VericertDriver.ml
+++ b/driver/VericertDriver.ml
@@ -202,7 +202,7 @@ let toolchain_help =
let usage_string =
version_string tool_name ^
- {|Usage: ccomp [options] <source files>
+ {|Usage: vericert [options] <source files>
Recognized source files:
.c C source file
.i or .p C source file that should not be preprocessed
diff --git a/src/hls/Abstr.v b/src/hls/Abstr.v
index b129afb..6a7e676 100644
--- a/src/hls/Abstr.v
+++ b/src/hls/Abstr.v
@@ -193,7 +193,7 @@ Declare Scope forest.
Notation "a '#r' b" := (get_forest b a) (at level 1) : forest.
Notation "a '#r' b <- c" := (set_forest b c a) (at level 1, b at next level) : forest.
Notation "a '#p' b" := (get_forest_p b a) (at level 1) : forest.
-Notation "a '#p' b <- c" := (get_forest_p b c a) (at level 1, b at next level) : forest.
+Notation "a '#p' b <- c" := (set_forest_p b c a) (at level 1, b at next level) : forest.
Notation "a '<-e' e" := (set_forest_e e a) (at level 1) : forest.
#[local] Open Scope forest.
@@ -1452,7 +1452,7 @@ Qed.
Lemma forest_pred_gso:
forall (f : forest) w dst dst',
dst <> dst' ->
- (set_forest_p dst w f) #p dst' = f #p dst'.
+ (f #p dst <- w) #p dst' = f #p dst'.
Proof.
unfold "#p"; intros.
unfold forest_preds. unfold set_forest_p.
@@ -1461,7 +1461,7 @@ Qed.
Lemma forest_pred_gss:
forall (f : forest) w dst,
- (set_forest_p dst w f) #p dst = w.
+ (f #p dst <- w) #p dst = w.
Proof.
unfold "#p"; intros.
unfold forest_preds. unfold set_forest_p.
diff --git a/src/hls/GiblePargen.v b/src/hls/GiblePargen.v
index 907266c..0ca7ead 100644
--- a/src/hls/GiblePargen.v
+++ b/src/hls/GiblePargen.v
@@ -182,11 +182,12 @@ Definition upd_pred_forest (p: pred_op) (f: forest): forest :=
f.(forest_preds)
f.(forest_exit).
-Fixpoint apredicated_to_apred_op (b: bool) (a: predicated pred_expression): pred_pexpr :=
+Fixpoint from_predicated (b: bool) (f: forest) (a: predicated pred_expression): pred_pexpr :=
match a with
- | NE.singleton (p, e) => Pimplies p (Plit (b, e))
+ | NE.singleton (p, e) => Pimplies (from_pred_op f p) (Plit (b, e))
| (p, e) ::| r =>
- Pand (Pimplies p (Plit (b, e))) (apredicated_to_apred_op b r)
+ Pand (Pimplies (from_pred_op f p) (Plit (b, e)))
+ (from_predicated b f r)
end.
(* Fixpoint get_pred' (f: forest) (ap: pred_op): option apred_op := *)
@@ -231,6 +232,15 @@ Definition simpl_combine {A: Type} (a b: option (@Predicate.pred_op A)) :=
Definition dfltp {A} (p: option (@Predicate.pred_op A)) := Option.default T p.
+Definition assert_ (b: bool): option unit :=
+ if b then Some tt else None.
+
+Definition is_initial_pred (f: forest) (p: positive) :=
+ match f #p p with
+ | Plit (true, PEbase p') => if peq p p' then Some tt else None
+ | _ => None
+ end.
+
Definition update (fop : option (pred_op * forest)) (i : instr): option (pred_op * forest) :=
do (pred, f) <- fop;
match i with
@@ -265,11 +275,11 @@ Definition update (fop : option (pred_op * forest)) (i : instr): option (pred_op
Some (pred, f #r Mem <- pruned)
| RBsetpred p' c args p =>
let new_pred :=
- (f #p p) ∧
- ((dfltp p' ∧ pred)
- → map_predicated (pred_ret (PEsetpred c))
- (merge (list_translation args f)))
+ (from_pred_op f (dfltp p' ∧ pred)
+ → from_predicated true f (map_predicated (pred_ret (PEsetpred c))
+ (merge (list_translation args f))))
in
+ do _ <- is_initial_pred f p;
Some (pred, f #p p <- new_pred)
| RBexit p c =>
let new_p := simplify (negate (dfltp p) ∧ pred) in
diff --git a/src/hls/GiblePargenproof.v b/src/hls/GiblePargenproof.v
index 2c677c3..eae309b 100644
--- a/src/hls/GiblePargenproof.v
+++ b/src/hls/GiblePargenproof.v
@@ -106,87 +106,87 @@ Proof. induction l; crush. Qed.
Lemma check_dest_l_dec i r : {check_dest_l i r = true} + {check_dest_l i r = false}.
Proof. destruct (check_dest_l i r); tauto. Qed.
-Lemma check_dest_update :
- forall f f' i r,
- check_dest i r = false ->
- update (Some f) i = Some f' ->
- (snd f') # (Reg r) = (snd f) # (Reg r).
-Proof.
- destruct i; crush; try apply Pos.eqb_neq in H; unfold update; destruct_match; crush.
- inv Heqp.
- Admitted.
-
-Lemma check_dest_l_forall2 :
- forall l r,
- Forall (fun x => check_dest x r = false) l ->
- check_dest_l l r = false.
-Proof.
- induction l; crush.
- inv H. apply orb_false_intro; crush.
-Qed.
-
-Lemma check_dest_l_ex2 :
- forall l r,
- (exists a, In a l /\ check_dest a r = true) ->
- check_dest_l l r = true.
-Proof.
- induction l; crush.
- specialize (IHl r). inv H.
- apply orb_true_intro; crush.
- apply orb_true_intro; crush.
- right. apply IHl. exists x. auto.
-Qed.
-
-Lemma check_list_l_false :
- forall l x r,
- check_dest_l (l ++ x :: nil) r = false ->
- check_dest_l l r = false /\ check_dest x r = false.
-Proof.
- simplify.
- apply check_dest_l_forall in H. apply Forall_app in H.
- simplify. apply check_dest_l_forall2; auto.
- apply check_dest_l_forall in H. apply Forall_app in H.
- simplify. inv H1. auto.
-Qed.
-
-Lemma check_dest_l_ex :
- forall l r,
- check_dest_l l r = true ->
- exists a, In a l /\ check_dest a r = true.
-Proof.
- induction l; crush.
- destruct (check_dest a r) eqn:?; try solve [econstructor; crush].
- simplify.
- exploit IHl. apply H. simplify. econstructor. simplify. right. eassumption.
- auto.
-Qed.
-
-Lemma check_list_l_true :
- forall l x r,
- check_dest_l (l ++ x :: nil) r = true ->
- check_dest_l l r = true \/ check_dest x r = true.
-Proof.
- simplify.
- apply check_dest_l_ex in H; simplify.
- apply in_app_or in H. inv H. left.
- apply check_dest_l_ex2. exists x0. auto.
- inv H0; auto.
-Qed.
-
-Lemma check_dest_l_dec2 l r :
- {Forall (fun x => check_dest x r = false) l}
- + {exists a, In a l /\ check_dest a r = true}.
-Proof.
- destruct (check_dest_l_dec l r); [right | left];
- auto using check_dest_l_ex, check_dest_l_forall.
-Qed.
-
-Lemma abstr_comp :
- forall l i f x x0,
- fold_left update (l ++ i :: nil) f = x ->
- fold_left update l f = x0 ->
- x = update x0 i.
-Proof. induction l; intros; crush; eapply IHl; eauto. Qed.
+(* Lemma check_dest_update : *)
+(* forall f f' i r, *)
+(* check_dest i r = false -> *)
+(* update (Some f) i = Some f' -> *)
+(* (snd f') # (Reg r) = (snd f) # (Reg r). *)
+(* Proof. *)
+(* destruct i; crush; try apply Pos.eqb_neq in H; unfold update; destruct_match; crush. *)
+(* inv Heqp. *)
+(* Admitted. *)
+
+(* Lemma check_dest_l_forall2 : *)
+(* forall l r, *)
+(* Forall (fun x => check_dest x r = false) l -> *)
+(* check_dest_l l r = false. *)
+(* Proof. *)
+(* induction l; crush. *)
+(* inv H. apply orb_false_intro; crush. *)
+(* Qed. *)
+
+(* Lemma check_dest_l_ex2 : *)
+(* forall l r, *)
+(* (exists a, In a l /\ check_dest a r = true) -> *)
+(* check_dest_l l r = true. *)
+(* Proof. *)
+(* induction l; crush. *)
+(* specialize (IHl r). inv H. *)
+(* apply orb_true_intro; crush. *)
+(* apply orb_true_intro; crush. *)
+(* right. apply IHl. exists x. auto. *)
+(* Qed. *)
+
+(* Lemma check_list_l_false : *)
+(* forall l x r, *)
+(* check_dest_l (l ++ x :: nil) r = false -> *)
+(* check_dest_l l r = false /\ check_dest x r = false. *)
+(* Proof. *)
+(* simplify. *)
+(* apply check_dest_l_forall in H. apply Forall_app in H. *)
+(* simplify. apply check_dest_l_forall2; auto. *)
+(* apply check_dest_l_forall in H. apply Forall_app in H. *)
+(* simplify. inv H1. auto. *)
+(* Qed. *)
+
+(* Lemma check_dest_l_ex : *)
+(* forall l r, *)
+(* check_dest_l l r = true -> *)
+(* exists a, In a l /\ check_dest a r = true. *)
+(* Proof. *)
+(* induction l; crush. *)
+(* destruct (check_dest a r) eqn:?; try solve [econstructor; crush]. *)
+(* simplify. *)
+(* exploit IHl. apply H. simplify. econstructor. simplify. right. eassumption. *)
+(* auto. *)
+(* Qed. *)
+
+(* Lemma check_list_l_true : *)
+(* forall l x r, *)
+(* check_dest_l (l ++ x :: nil) r = true -> *)
+(* check_dest_l l r = true \/ check_dest x r = true. *)
+(* Proof. *)
+(* simplify. *)
+(* apply check_dest_l_ex in H; simplify. *)
+(* apply in_app_or in H. inv H. left. *)
+(* apply check_dest_l_ex2. exists x0. auto. *)
+(* inv H0; auto. *)
+(* Qed. *)
+
+(* Lemma check_dest_l_dec2 l r : *)
+(* {Forall (fun x => check_dest x r = false) l} *)
+(* + {exists a, In a l /\ check_dest a r = true}. *)
+(* Proof. *)
+(* destruct (check_dest_l_dec l r); [right | left]; *)
+(* auto using check_dest_l_ex, check_dest_l_forall. *)
+(* Qed. *)
+
+(* Lemma abstr_comp : *)
+(* forall l i f x x0, *)
+(* fold_left update (l ++ i :: nil) f = x -> *)
+(* fold_left update l f = x0 -> *)
+(* x = update x0 i. *)
+(* Proof. induction l; intros; crush; eapply IHl; eauto. Qed. *)
(*
@@ -934,7 +934,7 @@ Section CORRECTNESS.
Proof using .
unfold schedule_oracle, check_control_flow_instr.
simplify; repeat destruct_match; crush.
- Qed.
+ Admitted.
Lemma eval_op_eq:
forall (sp0 : Values.val) (op : Op.operation) (vl : list Values.val) m,
@@ -1164,28 +1164,28 @@ Proof. induction 2; try rewrite H; eauto with barg. Qed.
sem (mk_ctx i sp ge) f' (i'', None).
Proof. Admitted.
- Lemma sem_update_instr_term :
- forall f i' i'' a sp i cf p p' p'' f',
- sem (mk_ctx i sp ge) f (i', None) ->
- step_instr ge sp (Iexec i') (RBexit p cf) (Iterm i'' cf) ->
- update (Some (p', f)) a = Some (p'', f') ->
- sem (mk_ctx i sp ge) f' (i'', Some cf)
- /\ eval_apred (mk_ctx i sp ge) p'' false.
- Proof. Admitted.
-
- Lemma step_instr_lessdef :
- forall sp a i i' ti,
- step_instr ge sp (Iexec i) a (Iexec i') ->
- state_lessdef i ti ->
- exists ti', step_instr ge sp (Iexec ti) a (Iexec ti') /\ state_lessdef i' ti'.
- Proof. Admitted.
-
- Lemma step_instr_lessdef_term :
- forall sp a i i' ti cf,
- step_instr ge sp (Iexec i) a (Iterm i' cf) ->
- state_lessdef i ti ->
- exists ti', step_instr ge sp (Iexec ti) a (Iterm ti' cf) /\ state_lessdef i' ti'.
- Proof. Admitted.
+ (* Lemma sem_update_instr_term : *)
+ (* forall f i' i'' a sp i cf p p' p'' f', *)
+ (* sem (mk_ctx i sp ge) f (i', None) -> *)
+ (* step_instr ge sp (Iexec i') (RBexit p cf) (Iterm i'' cf) -> *)
+ (* update (Some (p', f)) a = Some (p'', f') -> *)
+ (* sem (mk_ctx i sp ge) f' (i'', Some cf) *)
+ (* /\ eval_apred (mk_ctx i sp ge) p'' false. *)
+ (* Proof. Admitted. *)
+
+ (* Lemma step_instr_lessdef : *)
+ (* forall sp a i i' ti, *)
+ (* step_instr ge sp (Iexec i) a (Iexec i') -> *)
+ (* state_lessdef i ti -> *)
+ (* exists ti', step_instr ge sp (Iexec ti) a (Iexec ti') /\ state_lessdef i' ti'. *)
+ (* Proof. Admitted. *)
+
+ (* Lemma step_instr_lessdef_term : *)
+ (* forall sp a i i' ti cf, *)
+ (* step_instr ge sp (Iexec i) a (Iterm i' cf) -> *)
+ (* state_lessdef i ti -> *)
+ (* exists ti', step_instr ge sp (Iexec ti) a (Iterm ti' cf) /\ state_lessdef i' ti'. *)
+ (* Proof. Admitted. *)
(* Lemma app_predicated_semregset :
forall A ctx o f res r y,
@@ -1244,151 +1244,151 @@ Proof. induction 2; try rewrite H; eauto with barg. Qed.
(* | apred_wf_Por: forall a b, *)
(* apred_wf a -> apred_wf b -> apred_wf (a ∨ b). *)
- Lemma apred_and_false1 :
- forall A ctx a b c,
- @eval_apred A ctx a false ->
- @eval_apred A ctx b c ->
- eval_apred ctx (a ∧ b) false.
- Proof.
- intros.
- replace false with (false && c) by auto.
- constructor; auto.
- Qed.
-
- Lemma apred_and_false2 :
- forall A ctx a b c,
- @eval_apred A ctx a c ->
- eval_apred ctx b false ->
- eval_apred ctx (a ∧ b) false.
- Proof.
- intros.
- replace false with (c && false) by eauto with bool.
- constructor; auto.
- Qed.
-
- #[local] Opaque simplify.
-
- Lemma apred_simplify:
- forall A ctx a b,
- @eval_apred A ctx a b ->
- @eval_apred A ctx (simplify a) b.
- Proof. Admitted.
-
- Lemma exists_get_pred_eval :
- forall A ctx f p,
- exists c, @eval_apred A ctx (get_pred' f p) c.
- Proof.
- induction p; crush; try solve [econstructor; constructor; eauto].
- destruct_match. inv Heqp0. econstructor.
- unfold apredicated_to_apred_op.
- Admitted. (*probably not provable.*)
-
- Lemma falsy_update :
- forall A f a ctx p f',
- @eval_apred A ctx (fst f) false ->
- update (Some f) a = Some (p, f') ->
- eval_apred ctx p false.
- Proof.
- destruct f; destruct a; inversion 1; subst; crush;
- destruct_match; simplify; auto;
- unfold Option.bind, Option.bind2 in *;
- repeat (destruct_match; try discriminate; []); simplify; auto.
- apply apred_simplify. eapply apred_and_false2; eauto. admit.
- apply apred_simplify. eapply apred_and_false2; eauto. admit.
- constructor; auto.
- constructor; auto.
- constructor; auto.
- constructor; auto.
- constructor; auto.
- rewrite H2.
- apply apred_simplify. eapply apred_and_false2; eauto. admit.
- apply apred_simplify. eapply apred_and_false2; eauto. admit.
- Unshelve. all: exact true.
- Admitted.
-
- Lemma abstr_fold_falsy :
- forall x i0 sp cf i f p p' f',
- sem (mk_ctx i0 sp ge) f (i, cf) ->
- eval_apred (mk_ctx i0 sp ge) p false ->
- fold_left update x (Some (p, f)) = Some (p', f') ->
- sem (mk_ctx i0 sp ge) f' (i, cf).
- Proof.
- induction x; crush.
- eapply IHx.
- destruct a; destruct f; crush;
- try solve [eapply app_predicated_sem; eauto; apply combined_falsy; auto].
- (* now apply falsy_update. *)
- (* Qed. *) Admitted.
-
- Lemma state_lessdef_sem :
- forall i sp f i' ti cf,
- sem (mk_ctx i sp ge) f (i', cf) ->
- state_lessdef i ti ->
- exists ti', sem (mk_ctx ti sp ge) f (ti', cf) /\ state_lessdef i' ti'.
- Proof. Admitted.
-
- Lemma update_Some :
- forall x n y,
- fold_left update x n = Some y ->
- exists n', n = Some n'.
- Proof.
- induction x; crush.
- econstructor; eauto.
- exploit IHx; eauto; simplify.
- unfold update, Option.bind2, Option.bind in H1.
- repeat (destruct_match; try discriminate); econstructor; eauto.
- Qed.
-
- #[local] Opaque update.
-
- Lemma abstr_fold_correct :
- forall sp x i i' i'' cf f p f',
- SeqBB.step ge sp (Iexec i') x (Iterm i'' cf) ->
- sem (mk_ctx i sp ge) (snd f) (i', None) ->
- fold_left update x (Some f) = Some (p, f') ->
- forall ti,
- state_lessdef i ti ->
- exists ti', sem (mk_ctx ti sp ge) f' (ti', Some cf)
- /\ state_lessdef i'' ti'.
- Proof.
- induction x; simplify; inv H.
- - destruct f. exploit update_Some; eauto; intros. simplify.
- rewrite H3 in H1. destruct x0.
- exploit IHx; eauto. eapply sem_update_instr; eauto.
- - destruct f.
- exploit state_lessdef_sem; eauto; intros. simplify.
- exploit step_instr_lessdef_term; eauto; intros. simplify.
- inv H6. exploit update_Some; eauto; simplify. destruct x2.
- exploit sem_update_instr_term; eauto; simplify.
- eexists; split.
- eapply abstr_fold_falsy; eauto.
- rewrite H6 in H1. eauto. auto.
- Qed.
-
- Lemma sem_regset_empty :
- forall A ctx, @sem_regset A ctx empty (ctx_rs ctx).
- Proof.
- intros; constructor; intros.
- constructor; auto. constructor.
- constructor.
- Qed.
-
- Lemma sem_predset_empty :
- forall A ctx, @sem_predset A ctx empty (ctx_ps ctx).
- Proof.
- intros; constructor; intros.
- constructor; auto. constructor.
- constructor.
- Qed.
-
- Lemma sem_empty :
- forall A ctx, @sem A ctx empty (ctx_is ctx, None).
- Proof.
- intros. destruct ctx. destruct ctx_is.
- constructor; try solve [constructor; constructor; crush].
- eapply sem_regset_empty.
- eapply sem_predset_empty.
- Qed.
+ (* Lemma apred_and_false1 : *)
+ (* forall A ctx a b c, *)
+ (* @eval_apred A ctx a false -> *)
+ (* @eval_apred A ctx b c -> *)
+ (* eval_apred ctx (a ∧ b) false. *)
+ (* Proof. *)
+ (* intros. *)
+ (* replace false with (false && c) by auto. *)
+ (* constructor; auto. *)
+ (* Qed. *)
+
+ (* Lemma apred_and_false2 : *)
+ (* forall A ctx a b c, *)
+ (* @eval_apred A ctx a c -> *)
+ (* eval_apred ctx b false -> *)
+ (* eval_apred ctx (a ∧ b) false. *)
+ (* Proof. *)
+ (* intros. *)
+ (* replace false with (c && false) by eauto with bool. *)
+ (* constructor; auto. *)
+ (* Qed. *)
+
+ (* #[local] Opaque simplify. *)
+
+ (* Lemma apred_simplify: *)
+ (* forall A ctx a b, *)
+ (* @eval_apred A ctx a b -> *)
+ (* @eval_apred A ctx (simplify a) b. *)
+ (* Proof. Admitted. *)
+
+ (* Lemma exists_get_pred_eval : *)
+ (* forall A ctx f p, *)
+ (* exists c, @eval_apred A ctx (get_pred' f p) c. *)
+ (* Proof. *)
+ (* induction p; crush; try solve [econstructor; constructor; eauto]. *)
+ (* destruct_match. inv Heqp0. econstructor. *)
+ (* unfold apredicated_to_apred_op. *)
+ (* Admitted. (*probably not provable.*) *)
+
+ (* Lemma falsy_update : *)
+ (* forall A f a ctx p f', *)
+ (* @eval_apred A ctx (fst f) false -> *)
+ (* update (Some f) a = Some (p, f') -> *)
+ (* eval_apred ctx p false. *)
+ (* Proof. *)
+ (* destruct f; destruct a; inversion 1; subst; crush; *)
+ (* destruct_match; simplify; auto; *)
+ (* unfold Option.bind, Option.bind2 in *; *)
+ (* repeat (destruct_match; try discriminate; []); simplify; auto. *)
+ (* apply apred_simplify. eapply apred_and_false2; eauto. admit. *)
+ (* apply apred_simplify. eapply apred_and_false2; eauto. admit. *)
+ (* constructor; auto. *)
+ (* constructor; auto. *)
+ (* constructor; auto. *)
+ (* constructor; auto. *)
+ (* constructor; auto. *)
+ (* rewrite H2. *)
+ (* apply apred_simplify. eapply apred_and_false2; eauto. admit. *)
+ (* apply apred_simplify. eapply apred_and_false2; eauto. admit. *)
+ (* Unshelve. all: exact true. *)
+ (* Admitted. *)
+
+ (* Lemma abstr_fold_falsy : *)
+ (* forall x i0 sp cf i f p p' f', *)
+ (* sem (mk_ctx i0 sp ge) f (i, cf) -> *)
+ (* eval_apred (mk_ctx i0 sp ge) p false -> *)
+ (* fold_left update x (Some (p, f)) = Some (p', f') -> *)
+ (* sem (mk_ctx i0 sp ge) f' (i, cf). *)
+ (* Proof. *)
+ (* induction x; crush. *)
+ (* eapply IHx. *)
+ (* destruct a; destruct f; crush; *)
+ (* try solve [eapply app_predicated_sem; eauto; apply combined_falsy; auto]. *)
+ (* (* now apply falsy_update. *) *)
+ (* (* Qed. *) Admitted. *)
+
+ (* Lemma state_lessdef_sem : *)
+ (* forall i sp f i' ti cf, *)
+ (* sem (mk_ctx i sp ge) f (i', cf) -> *)
+ (* state_lessdef i ti -> *)
+ (* exists ti', sem (mk_ctx ti sp ge) f (ti', cf) /\ state_lessdef i' ti'. *)
+ (* Proof. Admitted. *)
+
+ (* Lemma update_Some : *)
+ (* forall x n y, *)
+ (* fold_left update x n = Some y -> *)
+ (* exists n', n = Some n'. *)
+ (* Proof. *)
+ (* induction x; crush. *)
+ (* econstructor; eauto. *)
+ (* exploit IHx; eauto; simplify. *)
+ (* unfold update, Option.bind2, Option.bind in H1. *)
+ (* repeat (destruct_match; try discriminate); econstructor; eauto. *)
+ (* Qed. *)
+
+ (* #[local] Opaque update. *)
+
+ (* Lemma abstr_fold_correct : *)
+ (* forall sp x i i' i'' cf f p f', *)
+ (* SeqBB.step ge sp (Iexec i') x (Iterm i'' cf) -> *)
+ (* sem (mk_ctx i sp ge) (snd f) (i', None) -> *)
+ (* fold_left update x (Some f) = Some (p, f') -> *)
+ (* forall ti, *)
+ (* state_lessdef i ti -> *)
+ (* exists ti', sem (mk_ctx ti sp ge) f' (ti', Some cf) *)
+ (* /\ state_lessdef i'' ti'. *)
+ (* Proof. *)
+ (* induction x; simplify; inv H. *)
+ (* - destruct f. exploit update_Some; eauto; intros. simplify. *)
+ (* rewrite H3 in H1. destruct x0. *)
+ (* exploit IHx; eauto. eapply sem_update_instr; eauto. *)
+ (* - destruct f. *)
+ (* exploit state_lessdef_sem; eauto; intros. simplify. *)
+ (* exploit step_instr_lessdef_term; eauto; intros. simplify. *)
+ (* inv H6. exploit update_Some; eauto; simplify. destruct x2. *)
+ (* exploit sem_update_instr_term; eauto; simplify. *)
+ (* eexists; split. *)
+ (* eapply abstr_fold_falsy; eauto. *)
+ (* rewrite H6 in H1. eauto. auto. *)
+ (* Qed. *)
+
+ (* Lemma sem_regset_empty : *)
+ (* forall A ctx, @sem_regset A ctx empty (ctx_rs ctx). *)
+ (* Proof. *)
+ (* intros; constructor; intros. *)
+ (* constructor; auto. constructor. *)
+ (* constructor. *)
+ (* Qed. *)
+
+ (* Lemma sem_predset_empty : *)
+ (* forall A ctx, @sem_predset A ctx empty (ctx_ps ctx). *)
+ (* Proof. *)
+ (* intros; constructor; intros. *)
+ (* constructor; auto. constructor. *)
+ (* constructor. *)
+ (* Qed. *)
+
+ (* Lemma sem_empty : *)
+ (* forall A ctx, @sem A ctx empty (ctx_is ctx, None). *)
+ (* Proof. *)
+ (* intros. destruct ctx. destruct ctx_is. *)
+ (* constructor; try solve [constructor; constructor; crush]. *)
+ (* eapply sem_regset_empty. *)
+ (* eapply sem_predset_empty. *)
+ (* Qed. *)
Lemma abstr_sequence_correct :
forall sp x i i'' cf x',
@@ -1402,9 +1402,10 @@ Proof. induction 2; try rewrite H; eauto with barg. Qed.
unfold abstract_sequence. intros. unfold Option.map in H0.
destruct_match; try easy.
destruct p; simplify.
- eapply abstr_fold_correct; eauto.
- simplify. eapply sem_empty.
- Qed.
+ (* eapply abstr_fold_correct; eauto. *)
+ (* simplify. eapply sem_empty. *)
+ (* Qed. *)
+ Admitted.
Lemma abstr_check_correct :
forall sp i i' a b cf ti,
diff --git a/src/hls/PrintAbstr.ml b/src/hls/PrintAbstr.ml
index c4a772e..e1341b1 100644
--- a/src/hls/PrintAbstr.ml
+++ b/src/hls/PrintAbstr.ml
@@ -13,8 +13,6 @@ let rec expr_to_list = function
let res pp = function
| Reg r -> fprintf pp "x%d" (P.to_int r)
- | Pred r -> fprintf pp "p%d" (P.to_int r)
- | Exit -> fprintf pp "EXIT"
| Mem -> fprintf pp "M"
let rec print_expression pp = function
@@ -29,18 +27,23 @@ let rec print_expression pp = function
(name_of_chunk chunk) print_expression m
(PrintOp.print_addressing print_expression) (addr, expr_to_list el)
print_expression e
- | Esetpred (c, el) ->
+
+let print_pred_expression pp = function
+ | PEbase p -> fprintf pp "%a'" PrintGible.pred p
+ | PEsetpred (c, el) ->
fprintf pp "(%a)" (PrintOp.print_condition print_expression) (c, expr_to_list el)
- | Eexit cf ->
+
+let print_exit_expression pp = function
+ | EEbase -> fprintf pp "EXIT'"
+ | EEexit cf ->
fprintf pp "[%a]" PrintGible.print_bblock_exit cf
let rec rev_index = function
| BinNums.Coq_xH -> Mem
- | BinNums.Coq_xO BinNums.Coq_xH -> Exit
- | BinNums.Coq_xI (BinNums.Coq_xI r) -> Pred r
- | BinNums.Coq_xO (BinNums.Coq_xO r) -> Reg r
+ | BinNums.Coq_xO r -> Reg r
-let print_pred_expr = PrintGible.print_pred_op_gen print_expression
+let print_pred_expr = PrintGible.print_pred_op_gen PrintGible.pred
+let print_pred_pexpr = PrintGible.print_pred_op_gen print_pred_expression
let rec print_predicated pp = function
| NE.Coq_singleton (p, e) ->
@@ -49,11 +52,38 @@ let rec print_predicated pp = function
fprintf pp "%a %a\n%a" print_pred_expr p print_expression e
print_predicated pr
-let print_forest pp f =
- fprintf pp "########################################\n";
+let rec print_predicated_exit pp = function
+ | NE.Coq_singleton (p, e) ->
+ fprintf pp "%a %a" print_pred_expr p print_exit_expression e
+ | NE.Coq_cons ((p, e), pr) ->
+ fprintf pp "%a %a\n%a" print_pred_expr p print_exit_expression e
+ print_predicated_exit pr
+
+let print_forest_regs pp f =
+ fprintf pp "-------------------- Reg --------------------\n";
List.iter
(function (i, y) -> fprintf pp "-- %a --\n%a\n"
res (rev_index i)
print_predicated y)
(PTree.elements f);
flush stdout
+
+let print_forest_preds pp f =
+ fprintf pp "------------------- Preds -------------------\n";
+ List.iter
+ (function (i, y) -> fprintf pp "-- %a --\n%a\n"
+ PrintGible.pred i
+ print_pred_pexpr y)
+ (PTree.elements f);
+ flush stdout
+
+let print_forest_exit pp f =
+ fprintf pp "------------------- Exit -------------------\n";
+ print_predicated_exit pp f
+
+let print_forest pp f =
+ fprintf pp "#############################################\n";
+ fprintf pp "%a\n%a\n%a\n"
+ print_forest_regs f.forest_regs
+ print_forest_preds f.forest_preds
+ print_forest_exit f.forest_exit