|
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. |
2 | 5 |
|
3 | 6 | Section EqualityDeciders.
|
4 | 7 |
|
@@ -98,6 +101,97 @@ Section EqualityDeciders.
|
98 | 101 | Qed.
|
99 | 102 | End EqualityDeciders.
|
100 | 103 |
|
| 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 | + |
101 | 195 | Section ChoiceFunction.
|
102 | 196 |
|
103 | 197 | End ChoiceFunction.
|
0 commit comments