-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathid_and_loc.v
90 lines (82 loc) · 1.49 KB
/
id_and_loc.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
Require Import Arith decision tactics.
Require Import Coq.Classes.RelationClasses.
Inductive id :=
Id: nat -> id.
Inductive loc :=
| Loc: nat -> loc.
Instance eq_id_dec:
forall id1 id2 : id,
Decision (id1 = id2).
Proof.
intros [n1] [n2].
destruct (decide (n1 = n2)).
- subst.
left.
reflexivity.
- right.
intro.
injects.
eauto.
Defined.
Instance eq_loc_dec:
forall l1 l2 : loc, Decision (l1 = l2).
Proof.
intros [n1] [n2].
destruct (decide (n1 = n2)).
- subst.
left.
reflexivity.
- right.
intro.
injects.
eauto.
Defined.
(* TODO: Do we really need seperate lemmas for both id and
loc with Robert's type class? *)
Theorem eq_id:
forall (T:Type)
(x : id)
(p q: T),
(if decide (x = x) then p else q) = p.
Proof.
intros.
destruct (decide (x = x)).
- reflexivity.
- exfalso; eauto.
Qed.
(* TODO: Same as above *)
Theorem neq_id:
forall (T: Type)
(x y : id)
(p q: T),
x <> y ->
(if decide (x = y) then p else q) = q.
Proof.
intros.
destruct (decide (x = y)).
- contradiction.
- reflexivity.
Qed.
Theorem eq_loc:
forall (T: Type)
(x : loc)
(p q: T),
(if decide (x = x) then p else q) = p.
Proof.
intros.
destruct (decide (x = x)).
- reflexivity.
- exfalso; eauto.
Qed.
Theorem neq_loc:
forall (T: Type)
(x y: loc)
(p q: T),
x <> y ->
(if decide (x = y) then p else q) = q.
Proof.
intros.
destruct (decide (x = y)).
- contradiction.
- reflexivity.
Qed.