Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make typed_store_model and example computable #114

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions monae_lib.v
Original file line number Diff line number Diff line change
Expand Up @@ -211,26 +211,40 @@ Proof. by elim: n st => [|n IH] [|d st'] //= /IH ->. Qed.
End nth_error.
Arguments nth_error_size {T st n a}.

(* Equality *)
Section eqtype.
Variable T : Type.
Variable eq_dec : comparable T.
Definition compareb x y : bool := eq_dec x y.
Definition compareP' x y :=
match eq_dec x y as s return reflect (x = y) s with
| left a => ReflectT (x = y) a
| right b => ReflectF (x = y) b
end.
Definition eqP' (E : eqType) : Equality.axiom (@eq_op E) :=
match E with EqType sort (EqMixin op a) => a end.
End eqtype.

Section coerce.
Variables (X : eqType) (f : X -> Type).

Definition coerce (T1 T2 : X) (v : f T1) : option (f T2) :=
if @eqP _ T1 T2 is ReflectT H then Some (eq_rect _ _ v _ H) else None.
if @eqP' _ T1 T2 is ReflectT H then Some (eq_rect _ _ v _ H) else None.

Lemma coerce_sym (T T' : X) (s : f T) (s' : f T') : coerce T' s -> coerce T s'.
Proof.
by rewrite /coerce; case: eqP => //= h; case: eqP => //; rewrite h; auto.
by rewrite /coerce; case: eqP' => //= h; case: eqP' => //; rewrite h; auto.
Qed.

Lemma coerce_Some (T : X) (s : f T) : coerce T s = Some s.
Proof.
by rewrite /coerce; case: eqP => /= [?|]; [rewrite -eq_rect_eq|auto].
by rewrite /coerce; case: eqP' => /= [?|]; [rewrite -eq_rect_eq|auto].
Qed.

Lemma coerce_eq (T T' : X) (s : f T) : coerce T' s -> T = T'.
Proof. by rewrite /coerce; case: eqP. Qed.
Proof. by rewrite /coerce; case: eqP'. Qed.

Lemma coerce_None (T T' : X) (s : f T) : T != T' -> coerce T' s = None.
Proof. by rewrite /coerce; case: eqP. Qed.
Proof. by rewrite /coerce; case: eqP'. Qed.

End coerce.
Loading