Commit db08223a authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Define shorthand EqDecision A := (∀ x y : A, Decision (x = y)).

parent 52cdec56
......@@ -26,8 +26,7 @@ Inductive Pmap_raw (A : Type) : Type :=
Arguments PLeaf {_}.
Arguments PNode {_} _ _ _.
Instance Pmap_raw_eq_dec `{ x y : A, Decision (x = y)} (x y : Pmap_raw A) :
Decision (x = y).
Instance Pmap_raw_eq_dec `{EqDecision A} : EqDecision (Pmap_raw A).
Proof. solve_decision. Defined.
Fixpoint Pmap_wf {A} (t : Pmap_raw A) : bool :=
......@@ -266,8 +265,7 @@ Proof.
split; [by intros ->|intros]; destruct m1 as [t1 ?], m2 as [t2 ?].
simplify_eq/=; f_equal; apply proof_irrel.
Qed.
Instance Pmap_eq_dec `{ x y : A, Decision (x = y)}
(m1 m2 : Pmap A) : Decision (m1 = m2) :=
Instance Pmap_eq_dec `{EqDecision A} : EqDecision (Pmap A) := λ m1 m2,
match Pmap_raw_eq_dec (pmap_car m1) (pmap_car m2) with
| left H => left (proj2 (Pmap_eq m1 m2) H)
| right H => right (H proj1 (Pmap_eq m1 m2))
......
......@@ -16,10 +16,10 @@ Infix "+:+" := String.append (at level 60, right associativity) : C_scope.
Arguments String.append _ _ : simpl never.
(** * Decision of equality *)
Instance assci_eq_dec : a1 a2, Decision (a1 = a2) := ascii_dec.
Instance string_eq_dec (s1 s2 : string) : Decision (s1 = s2).
Instance assci_eq_dec : EqDecision ascii := ascii_dec.
Instance string_eq_dec : EqDecision string.
Proof. solve_decision. Defined.
Instance: Inj (=) (=) (String.append s1).
Instance string_app_inj : Inj (=) (=) (String.append s1).
Proof. intros s1 ???. induction s1; simplify_eq/=; f_equal/=; auto. Qed.
(* Reverse *)
......
......@@ -35,7 +35,7 @@ Coercion fin_to_nat : fin >-> nat.
Notation fin_of_nat := Fin.of_nat_lt.
Notation fin_rect2 := Fin.rect2.
Instance fin_dec {n} : i j : fin n, Decision (i = j).
Instance fin_dec {n} : EqDecision (fin n).
Proof.
refine (fin_rect2
(λ n (i j : fin n), { i = j } + { i j })
......@@ -163,8 +163,7 @@ Proof.
- apply IH. intros i. apply (Hi (FS i)).
Qed.
Instance vec_dec {A} {dec : x y : A, Decision (x = y)} {n} :
v w : vec A n, Decision (v = w).
Instance vec_dec {A} {dec : EqDecision A} {n} : EqDecision (vec A n).
Proof.
refine (vec_rect2
(λ n (v w : vec A n), { v = w } + { v w })
......
......@@ -13,14 +13,13 @@ Arguments Zmap_pos {_} _.
Arguments Zmap_neg {_} _.
Arguments ZMap {_} _ _ _.
Instance Zmap_eq_dec `{ x y : A, Decision (x = y)} (t1 t2 : Zmap A) :
Decision (t1 = t2).
Instance Zmap_eq_dec `{EqDecision A} : EqDecision (Zmap A).
Proof.
refine
refine (λ t1 t2,
match t1, t2 with
| ZMap x t1 t1', ZMap y t2 t2' =>
cast_if_and3 (decide (x = y)) (decide (t1 = t2)) (decide (t1' = t2'))
end; abstract congruence.
end); abstract congruence.
Defined.
Instance Zempty {A} : Empty (Zmap A) := ZMap None .
Instance Zlookup {A} : Lookup Z A (Zmap A) := λ i t,
......
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