forked from Eelis/hybrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vector_setoid.v
74 lines (55 loc) · 1.53 KB
/
vector_setoid.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Require Export VecUtil.
Require Export VecEq.
Require Export CSetoids.
Require Export SetoidClass.
Require Import c_util.
Require Export Coq.Classes.EquivDec.
Set Implicit Arguments.
(** * CSetoid on vectors. *)
Section VectorCSetoid.
Variables A : CSetoid.
Fixpoint vec_ap (n: nat): vector A n -> vector A n -> CProp :=
match n with
| O => fun _ _ => False
| S m => fun v w => (Vhead v [#] Vhead w) or vec_ap (Vtail v) (Vtail w)
end.
Variable n : nat.
Notation vec := (vector A n).
(*
Instance eqA : SetoidClass.Setoid A :=
{ equiv := @st_eq (cs_crr A); setoid_equiv := st_isSetoid A }.
*)
Let vec_eq := @eq_vec A (@cs_eq A) n.
Lemma is_vec_CSetoid : is_CSetoid vec vec_eq (@vec_ap n).
Proof.
constructor.
(* irreflexivive *)
admit.
(* Csymmetric *)
admit.
(* cotransitive *)
admit.
(* tight_apart *)
admit.
Admitted.
Definition vecCSetoid : CSetoid :=
Build_CSetoid _ _ _ is_vec_CSetoid.
End VectorCSetoid.
(* FIXME, this should come from CoLoR.Util.Vector.VecEq.v *)
Add Parametric Morphism A n i (ip : (i < n)%nat) :
(fun v : vecCSetoid A n => Vnth v ip)
with signature (@cs_eq _) ==> (@cs_eq _)
as Vnth_Cmorph.
Proof.
intros. apply Vforall2n_nth with (R := @st_eq _). assumption.
Qed.
(** * Decidable Leibniz equality on vectors *)
Section vector_eqdec.
Variable n : nat.
Variable A : Type.
Variable eqA_dec : EqDec A eq.
Global Program Instance vector_EqDec : EqDec (vector A n) eq.
Next Obligation.
apply eq_vec_dec; auto.
Qed.
End vector_eqdec.