Skip to content

Commit 70b331f

Browse files
authored
Merge pull request #1 from UniMath/discrete
Discrete
2 parents ccdce1e + bdafd5a commit 70b331f

File tree

4 files changed

+134
-5
lines changed

4 files changed

+134
-5
lines changed

code/Decidability/DiscreteTypes.v

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
Require Export UniMath.Foundations.All.
1+
Require Import init.imports.
2+
Require Import UniMath.Combinatorics.Lists.
3+
Require Import UniMath.Combinatorics.MoreLists.
4+
Require Import Inductive.Option.
25

36
Section EqualityDeciders.
47

@@ -98,6 +101,97 @@ Section EqualityDeciders.
98101
Qed.
99102
End EqualityDeciders.
100103

104+
Section ClosureProperties.
105+
106+
Lemma isdeceqdirprod (X : UU) (Y : UU) : (isdeceq X) → (isdeceq Y) → (isdeceq (X × Y)).
107+
Proof.
108+
intros isdx isdy [x1 x2] [y1 y2].
109+
induction (isdx x1 y1), (isdy x2 y2).
110+
- left.
111+
exact (pathsdirprod a p).
112+
- right; intros b.
113+
apply n.
114+
exact (maponpaths dirprod_pr2 b).
115+
- right; intros n.
116+
apply b.
117+
exact (maponpaths dirprod_pr1 n).
118+
- right; intros c.
119+
apply b.
120+
exact (maponpaths dirprod_pr1 c).
121+
Qed.
122+
123+
Lemma isdeceqcoprod (X : UU) (Y : UU) : (isdeceq X) → (isdeceq Y) → (isdeceq (X ⨿ Y)).
124+
Proof.
125+
intros isdx isdy [x | x] [y | y].
126+
- induction (isdx x y).
127+
+ left.
128+
exact (maponpaths inl a).
129+
+ right. intros inl.
130+
apply b.
131+
use ii1_injectivity.
132+
* exact Y.
133+
* exact inl.
134+
- exact (ii2 (@negpathsii1ii2 X Y x y)).
135+
- exact (ii2 (@negpathsii2ii1 X Y y x)).
136+
- induction (isdy x y).
137+
+ exact (ii1 (maponpaths inr a)).
138+
+ right; intros inr; apply b.
139+
use ii2_injectivity.
140+
* exact X.
141+
* exact inr.
142+
Qed.
143+
144+
Definition nopathsnilcons {X : UU} (a : X) (l : list X) : ¬ (nil = (cons a l)).
145+
Proof.
146+
intros eq.
147+
set (P := (@list_ind X (λ _, UU) unit (λ _ _ _, empty))).
148+
exact (@transportf (list X) P nil (cons a l) eq tt).
149+
Qed.
150+
151+
Definition nopathsconsnil {X : UU} (a : X) (l : list X) : ¬ ((cons a l) = nil).
152+
Proof.
153+
intros eq.
154+
set (P := (@list_ind X (λ _, UU) empty (λ _ _ _, unit))).
155+
exact (@transportf (list X) P (cons a l) nil eq tt).
156+
Qed.
157+
158+
Lemma isdeceqlist (X : UU) : (isdeceq X) → (isdeceq (list X)).
159+
Proof.
160+
intros isdx.
161+
use list_ind; cbv beta.
162+
- use list_ind; cbv beta.
163+
+ left; apply idpath.
164+
+ intros. right.
165+
apply nopathsnilcons.
166+
- intros x xs Ih.
167+
use list_ind; cbv beta.
168+
+ right. apply nopathsconsnil.
169+
+ intros x0 xs0 deceq.
170+
induction (Ih xs0), (isdx x x0).
171+
* induction a, p.
172+
left. apply idpath.
173+
* right. intros eq.
174+
exact (n (cons_inj1 x x0 xs xs0 eq)).
175+
* right. intros eq.
176+
exact (b (cons_inj2 x x0 xs xs0 eq)).
177+
* right. intros eq.
178+
exact (b (cons_inj2 x x0 xs xs0 eq)).
179+
Qed.
180+
181+
Lemma isdeceqoption (X : UU) : (isdeceq X) → (isdeceq (@option X)).
182+
Proof.
183+
intros isdx.
184+
intros o1 o2.
185+
induction o1, o2.
186+
- induction (isdx a x).
187+
+ induction a0. left. apply idpath.
188+
+ right. intros eq. apply b, some_injectivity. exact eq.
189+
- right. induction u. apply nopathssomenone.
190+
- right; induction b. apply nopathsnonesome.
191+
- left; induction u, b. apply idpath.
192+
Qed.
193+
End ClosureProperties.
194+
101195
Section ChoiceFunction.
102196

103197
End ChoiceFunction.

code/Inductive/Option.v

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Require Import init.imports.
2+
3+
Section Option.
4+
5+
Definition option {X : UU} : UU := X ⨿ unit.
6+
7+
Definition some {X : UU} (x : X) : option := (ii1 x).
8+
Definition none {X : UU} : @option X := (ii2 tt).
9+
10+
End Option.
11+
12+
Section PathProperties.
13+
14+
Lemma nopathssomenone {X : UU} (x : X) : ¬ ((some x) = none).
15+
Proof.
16+
apply negpathsii1ii2.
17+
Qed.
18+
19+
Lemma nopathsnonesome {X : UU} (x : X) : ¬ (none = (some x)).
20+
Proof.
21+
apply negpathsii2ii1.
22+
Qed.
23+
24+
Lemma some_injectivity {X : UU} (x y : X) : (some x = some y) → x = y.
25+
Proof.
26+
apply ii1_injectivity.
27+
Qed.
28+
29+
30+
End PathProperties.
31+

code/_CoqProject

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ COQC = coqc
22
COQDEP = coqdep
33
-R . "sem"
44

5-
-arg "-w -notation-overridden -type-in-type"
5+
-o -arg "-w -notation-overridden -type-in-type"
66

77
init/imports.v
8+
init/all.v
89

9-
Decidability/DecidablePredicates.v
10-
Decidability/DiscreteTypes.v
11-
10+
Inductive/Option.v
1211

12+
Decidability/DecidablePredicates.v
13+
Decidability/DiscreteTypes.v

code/init/all.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
3+
Require Export init.imports.

0 commit comments

Comments
 (0)