Commit 0cc8a44b authored by Heiko Becker's avatar Heiko Becker

Simplify transitivity proof of transitivity of equality

parent cb7a06d9
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Formalization of the base expression language for the daisy framework Formalization of the base expression language for the daisy framework
**) **)
Require Import Coq.Reals.Reals Coq.micromega.Psatz Coq.QArith.QArith Coq.QArith.Qreals. Require Import Coq.Reals.Reals Coq.micromega.Psatz Coq.QArith.QArith Coq.QArith.Qreals.
Require Import Daisy.Infra.RealRationalProps Daisy.Infra.RationalSimps. Require Import Daisy.Infra.RealRationalProps Daisy.Infra.RationalSimps Daisy.Infra.Ltacs.
Require Export Daisy.Infra.Abbrevs Daisy.Infra.RealSimps Daisy.Infra.NatSet Daisy.IntervalArithQ Daisy.IntervalArith Daisy.Infra.MachineType. Require Export Daisy.Infra.Abbrevs Daisy.Infra.RealSimps Daisy.Infra.NatSet Daisy.IntervalArithQ Daisy.IntervalArith Daisy.Infra.MachineType.
(** (**
...@@ -38,6 +38,12 @@ Proof. ...@@ -38,6 +38,12 @@ Proof.
case b; auto. case b; auto.
Qed. Qed.
Lemma binopEqBool_prop b1 b2:
binopEqBool b1 b2 = true <-> b1 = b2.
Proof.
split; case b1; case b2; intros; simpl in *; try congruence; auto.
Qed.
(** (**
Expressions will use unary operators. Expressions will use unary operators.
Define them first Define them first
...@@ -57,6 +63,12 @@ Proof. ...@@ -57,6 +63,12 @@ Proof.
case b; auto. case b; auto.
Qed. Qed.
Lemma unopEqBool_prop b1 b2:
unopEqBool b1 b2 = true <-> b1 = b2.
Proof.
split; case b1; case b2; intros; simpl in *; try congruence; auto.
Qed.
(** (**
Define evaluation for unary operators on reals. Define evaluation for unary operators on reals.
Errors are added in the expression evaluation level later. Errors are added in the expression evaluation level later.
...@@ -132,40 +144,30 @@ Lemma expEqBool_trans e f g: ...@@ -132,40 +144,30 @@ Lemma expEqBool_trans e f g:
expEqBool e g = true. expEqBool e g = true.
Proof. Proof.
revert e f g; induction e; revert e f g; induction e;
destruct f; intros; destruct f; intros g eq1 eq2;
simpl in H; inversion H; rewrite H; clear H; destruct g; simpl in *; try congruence;
destruct g; simpl in H0; inversion H0; rewrite H0; clear H0; try rewrite Nat.eqb_eq in *;
try (apply andb_true_iff in H1; destruct H1; apply andb_true_iff in H2; destruct H2; simpl). subst; try auto.
- apply beq_nat_true in H2. - andb_to_prop eq1;
apply beq_nat_true in H1. andb_to_prop eq2.
subst. apply EquivEqBoolEq in L.
unfold expEqBool. apply EquivEqBoolEq in L0; subst.
rewrite <- beq_nat_refl.
auto.
- apply EquivEqBoolEq in H1.
apply EquivEqBoolEq in H.
subst.
rewrite mTypeEqBool_refl; simpl. rewrite mTypeEqBool_refl; simpl.
apply Qeq_bool_iff in H2. rewrite Qeq_bool_iff in *; lra.
apply Qeq_bool_iff in H0. - andb_to_prop eq1;
apply Qeq_bool_iff. andb_to_prop eq2.
lra. rewrite unopEqBool_prop in *; subst.
- assert (u = u0) by (destruct u; destruct u0; inversion H1; auto). rewrite unopEqBool_refl; simpl.
assert (u0 = u1) by (destruct u0; destruct u1; inversion H; auto).
subst.
assert (unopEqBool u1 u1 = true) by (destruct u1; auto).
apply andb_true_iff; split; try auto.
eapply IHe; eauto. eapply IHe; eauto.
- apply andb_true_iff; split. - andb_to_prop eq1;
+ destruct b; destruct b0; destruct b1; auto. andb_to_prop eq2.
+ apply andb_true_iff in H2; destruct H2. rewrite binopEqBool_prop in *; subst.
apply andb_true_iff in H0; destruct H0. rewrite binopEqBool_refl; simpl.
apply andb_true_iff; split. apply andb_true_iff.
eapply IHe1; eauto. split; [eapply IHe1; eauto | eapply IHe2; eauto].
eapply IHe2; eauto. - andb_to_prop eq1;
- apply EquivEqBoolEq in H1. andb_to_prop eq2.
apply EquivEqBoolEq in H. rewrite EquivEqBoolEq in *; subst.
subst.
rewrite mTypeEqBool_refl; simpl. rewrite mTypeEqBool_refl; simpl.
eapply IHe; eauto. eapply IHe; eauto.
Qed. Qed.
......
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