|
23 | 23 | Require Import UniMath.Foundations.Propositions. |
24 | 24 | Require Import UniMath.MoreFoundations.PartA. |
25 | 25 | Require Import UniMath.MoreFoundations.Notations. |
| 26 | +Require Import UniMath.MoreFoundations.DecidablePropositions. |
26 | 27 | Require Import UniMath.Combinatorics.FiniteSets. |
27 | 28 | Require Import UniMath.Combinatorics.StandardFiniteSets. |
28 | 29 |
|
@@ -241,3 +242,90 @@ Section kfinite_definition. |
241 | 242 | := hinhfun kfinstruct_finstruct. |
242 | 243 |
|
243 | 244 | End kfinite_definition. |
| 245 | + |
| 246 | +Section iskfinite_isdeceq_isfinite. |
| 247 | +(** |
| 248 | + This section provides the necessary construction to prove that |
| 249 | + every K-Finite type with decidable equality is Bishop-finite. |
| 250 | + |
| 251 | + Proof outline: |
| 252 | + Let X be a K-Finite type. Then there exists n : nat with a surjection |
| 253 | + from stn n to X. |
| 254 | +
|
| 255 | + The proof goes by induction on n, with the type X being generalized. |
| 256 | + In the base case, we have a surjection from an uninhabited type to X. |
| 257 | + Thus, X must also have no elements and therefore, X is equivalent with |
| 258 | + stn 0. |
| 259 | +
|
| 260 | + In the inductive step, we assume that for any type X for which there |
| 261 | + exists a surjection from stn n to X and has decidable equality is |
| 262 | + Bishop finite. We have to show that if there exists a surjection f |
| 263 | + from stn (S n) to X and X has decidable equality, then X is Bishop |
| 264 | + finite. |
| 265 | + Let g : stn n -> X such that g (x) := f x. If X has decidable equality, |
| 266 | + then it is decidable whether f (n) is included in the image of g. |
| 267 | +
|
| 268 | + We will thus proceed by case analysis on whether f n is included in the image of g. |
| 269 | + If f n is included in the image of g, then g must be a surjection as well. By the inductive |
| 270 | + hypothesis X is Bishop finite. If f n is not included in the image of g, we will denote |
| 271 | + y := f n. We now consider the type X / y (pair X (\x -> x != y)) which is inhabited by |
| 272 | + terms different than y. First, we note that X / y has decidable equality. Secondly, we note |
| 273 | + that X / y + unit is equivalent to X. Lastly, we note that by restricting the codomain of g |
| 274 | + to X / y, we obtain a surjection g1 : stn n -> X / y. By the inductive hypothesis, the type |
| 275 | + X / y is Bishop finite, and thus equivalent to stn m for some m : nat. |
| 276 | + To conclude, we have the following chain of equivalences |
| 277 | + X ≃ X / y + 1 ≃ stn m + 1 ≃ stn (S m). Thus, X is Bishop finite. |
| 278 | +
|
| 279 | + *) |
| 280 | + |
| 281 | + Lemma issurjective_stnfun_singleton_complement {X : UU} {n : nat} (f : stn (S n) → X) |
| 282 | + (nfib : ¬ hfiber (fun_stnsn_to_stnn f) (f lastelement)) : issurjective f → |
| 283 | + issurjective (stnfun_singleton_complement f nfib). |
| 284 | + Proof. |
| 285 | + intros surjf y. |
| 286 | + destruct y as [x neq]. |
| 287 | + use squash_to_prop. |
| 288 | + - exact (hfiber f x). |
| 289 | + - exact (surjf x). |
| 290 | + - apply propproperty. |
| 291 | + - intros [[m lth] q]; clear surjf. apply hinhpr. |
| 292 | + induction (natlehchoice _ _ (natlthsntoleh _ _ lth)). |
| 293 | + + apply (tpair _ (m ,, a)). |
| 294 | + unfold stnfun_singleton_complement, fun_stnsn_to_stnn, make_stn. |
| 295 | + apply subtypePath_prop; cbn. |
| 296 | + induction q. apply maponpaths, stn_eq, idpath. |
| 297 | + + assert (H : (m ,, lth = lastelement)) by apply stn_eq, b. |
| 298 | + apply fromempty. induction neq. induction H. apply pathsinv0, q. |
| 299 | + Qed. |
| 300 | + |
| 301 | + Lemma kfinstruct_dec_finstruct {X : UU} : isdeceq X → kfinstruct X → finstruct X. |
| 302 | + Proof. |
| 303 | + intros deceqX [n [f surj]]. |
| 304 | + generalize dependent X. |
| 305 | + induction n; intros. |
| 306 | + - apply tpair with (pr1 := 0). |
| 307 | + apply surj_from_stn0_to_neg with (f := f). assumption. |
| 308 | + - set (g := fun_stnsn_to_stnn f). |
| 309 | + set (y := f lastelement). |
| 310 | + induction (isdeceq_isdecsurj g y deceqX). |
| 311 | + + apply IHn with (f := g); try apply surj_fun_stnsn_to_stnn; assumption. |
| 312 | + + set (g' := stnfun_singleton_complement f b). |
| 313 | + set (surjg' := (issurjective_stnfun_singleton_complement f b surj)). |
| 314 | + specialize IHn with (f := g'). |
| 315 | + apply IHn in surjg'; |
| 316 | + [ | apply isdeceq_subtype; try assumption; intros x; apply isapropneg ]. |
| 317 | + destruct surjg' as [s1 s2]. |
| 318 | + apply tpair with (pr1 := (S s1)); unfold nelstruct. |
| 319 | + eapply weqcomp. |
| 320 | + * apply invweq, weqdnicoprod, lastelement. |
| 321 | + * eapply weqcomp. |
| 322 | + { eapply weqcoprodf1, s2. } |
| 323 | + apply weq_singleton_complement_unit; assumption. |
| 324 | + Qed. |
| 325 | + |
| 326 | + Lemma iskfinite_dec_to_isfinite {X : UU} : isdeceq X → iskfinite X → isfinite X. |
| 327 | + Proof. |
| 328 | + intros deceqX. apply hinhfun, kfinstruct_dec_finstruct, deceqX. |
| 329 | + Qed. |
| 330 | + |
| 331 | +End iskfinite_isdeceq_isfinite. |
0 commit comments