|
71 | 71 |
|
72 | 72 | #[global] |
73 | 73 | Instance reflect_eq_spec_float : ReflectEq SpecFloat.spec_float := EqDec_ReflectEq _. |
74 | | - |
75 | | -(* #[program] |
76 | | -#[global] |
77 | | -Instance reflect_eq_float64 : ReflectEq float64_model := |
78 | | - { eqb x y := eqb (proj1_sig x) (proj1_sig y) }. |
79 | | -Next Obligation. |
80 | | - cbn -[eqb]. |
81 | | - intros x y. |
82 | | - elim: eqb_spec. constructor. |
83 | | - now apply exist_irrel_eq. |
84 | | - intros neq; constructor => H'; apply neq; now subst x. |
85 | | -Qed. *) |
86 | 74 |
|
87 | | -(** Propositional UIP is needed below *) |
88 | | -Set Equations With UIP. |
89 | | - |
90 | | -#[global] |
91 | | -Instance prim_model_eqdec {term} (*e : EqDec term*) : forall p : prim_tag, EqDec (prim_model term p). |
92 | | -Proof. eqdec_proof. Qed. |
| 75 | +Equations eqb_prim_model {term} {t : prim_tag} (x y : prim_model term t) : bool := |
| 76 | + | primIntModel x, primIntModel y := ReflectEq.eqb x y |
| 77 | + | primFloatModel x, primFloatModel y := ReflectEq.eqb x y. |
| 78 | + |
| 79 | +#[global, program] |
| 80 | +Instance prim_model_reflecteq {term} {p : prim_tag} : ReflectEq (prim_model term p) := |
| 81 | + {| ReflectEq.eqb := eqb_prim_model |}. |
| 82 | +Next Obligation. |
| 83 | + intros. depelim x; depelim y; simp eqb_prim_model. |
| 84 | + case: ReflectEq.eqb_spec; constructor; subst; auto. congruence. |
| 85 | + case: ReflectEq.eqb_spec; constructor; subst; auto. congruence. |
| 86 | +Qed. |
93 | 87 |
|
94 | 88 | #[global] |
95 | | -Instance prim_tag_model_eqdec term : EqDec (prim_val term). |
96 | | -Proof. eqdec_proof. Defined. |
| 89 | +Instance prim_model_eqdec {term} : forall p : prim_tag, EqDec (prim_model term p) := _. |
| 90 | + |
| 91 | +Equations eqb_prim_val {term} (x y : prim_val term) : bool := |
| 92 | + | (primInt; i), (primInt; i') := ReflectEq.eqb i i' |
| 93 | + | (primFloat; f), (primFloat; f') := ReflectEq.eqb f f' |
| 94 | + | x, y := false. |
| 95 | + |
| 96 | +#[global, program] |
| 97 | +Instance prim_val_reflect_eq {term} : ReflectEq (prim_val term) := |
| 98 | + {| ReflectEq.eqb := eqb_prim_val |}. |
| 99 | +Next Obligation. |
| 100 | + intros. funelim (eqb_prim_val x y); simp eqb_prim_val. |
| 101 | + case: ReflectEq.eqb_spec; constructor; subst; auto. intros H; noconf H. cbn in n. auto. |
| 102 | + constructor. intros H; noconf H; auto. |
| 103 | + constructor. intros H; noconf H; auto. |
| 104 | + case: ReflectEq.eqb_spec; constructor; subst; auto. intros H; noconf H; auto. |
| 105 | +Qed. |
97 | 106 |
|
98 | 107 | #[global] |
99 | | -Instance prim_val_reflect_eq term : ReflectEq (prim_val term) := EqDec_ReflectEq _. |
| 108 | +Instance prim_tag_model_eqdec term : EqDec (prim_val term) := _. |
100 | 109 |
|
101 | 110 | (** Printing *) |
102 | 111 |
|
103 | | -Definition string_of_float64_model (f : float64_model) := |
104 | | - "<>". |
105 | | - |
106 | 112 | Definition string_of_prim {term} (soft : term -> string) (p : prim_val term) : string := |
107 | 113 | match p.π2 return string with |
108 | 114 | | primIntModel f => "(int: " ^ string_of_prim_int f ^ ")" |
|
0 commit comments