1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "sets/sets.ma".
16 include "nat/plus.ma".
17 include "nat/compare.ma".
18 include "nat/minus.ma".
20 alias symbol "eq" = "setoid eq".
21 alias symbol "eq" = "setoid1 eq".
22 alias symbol "eq" = "setoid eq".
23 alias symbol "eq" = "setoid1 eq".
24 nrecord partition (A: setoid) : Type[1] ≝
26 indexes: qpowerclass support;
27 class: unary_morphism1 (setoid1_of_setoid support) (qpowerclass_setoid A);
28 inhabited: ∀i. i ∈ indexes → class i ≬ class i;
29 disjoint: ∀i,j. i ∈ indexes → j ∈ indexes → class i ≬ class j → i=j;
30 covers: big_union support ? ? (λx.class x) = full_set A
31 }. napply indexes; nqed.
35 nlet rec partition_splits_card_map
36 A (P:partition A) n s (f:isomorphism ?? (Nat_ n) (indexes ? P))
37 (fi: ∀i. isomorphism ?? (Nat_ (s i)) (class ? P (iso_f ???? f i))) m index
39 match ltb m (s index) with
40 [ or_introl _ ⇒ iso_f ???? (fi index) m
43 [ O ⇒ (* dummy value: it could be an elim False: *) iso_f ???? (fi O) O
45 partition_splits_card_map A P n s f fi (minus m (s index)) index']].
47 naxiom big_union_preserves_iso:
49 ∀g: isomorphism A' A T' T.
50 big_union A B T f = big_union A' B T' (λx.f (iso_f ???? g x)).
52 nlemma partition_splits_card:
53 ∀A. ∀P:partition A. ∀n,s.
54 ∀f:isomorphism ?? (Nat_ n) (indexes ? P).
55 (∀i. isomorphism ?? (Nat_ (s i)) (class ? P (iso_f ???? f i))) →
56 (isomorphism ?? (Nat_ (big_plus n (λi.λ_.s i))) (Full_set A)).
57 #A; #P; #Sn; ncases Sn
59 ngeneralize in match (covers ? P) in ⊢ ?; *; #_; #H;
61 (big_union_preserves_iso ??? (indexes A P) (Nat_ O) (λx.class ? P x) f) in ⊢ ?;
62 *; #K; #_; nwhd in K: (? → ? → %);
63 nelim daemon (* impossibile *)
64 | #n; #s; #f; #fi; napply mk_isomorphism
65 [ napply mk_unary_morphism
66 [ napply (λm.partition_splits_card_map A P (S n) s f fi m n)
67 | #a; #a'; #H; nrewrite < H; napply refl ]
69 ngeneralize in match (covers ? P) in ⊢ ?; *; #_; #Hc;
70 ngeneralize in match (Hc y I) in ⊢ ?; *; #index; *; #Hi1; #Hi2;
71 ngeneralize in match (f_sur ???? f ? Hi1) in ⊢ ?; *; #nindex; *; #Hni1; #Hni2;
72 ngeneralize in match (f_sur ???? (fi nindex) y ?) in ⊢ ?
73 [##2: napply (. #‡(†?));##[##3: napply Hni2 |##2: ##skip | nassumption]##]
74 *; #nindex2; *; #Hni21; #Hni22;
75 nletin xxx ≝ (plus match nindex return λ_.nat with [ O ⇒ O | S nn ⇒ big_plus nn (λi.λ_.s i)] nindex2);
76 napply (ex_intro … xxx); napply conj
77 [ nwhd in Hni1; nelim daemon
79 (* BEL POSTO DOVE FARE UN LEMMA *)
80 (* invariante: Hni1; altre premesse: Hni1, Hni22 *)
81 nchange in Hni1 with (nindex < S n); ngeneralize in match Hni1 in ⊢ ?;
82 nelim n in ⊢ (% → ??? (????????%) ?)
84 | #index'; #Hrec; #K; nwhd in ⊢ (???%?);
85 nelim (ltb xxx (s (S index')));
86 #K1; nwhd in ⊢ (???%?)
90 +^{nindex} (s i) w < s (S index')
97 | #x; #x'; nnormalize in ⊢ (? → ? → %);
102 (************** equivalence relations vs partitions **********************)
104 ndefinition partition_of_compatible_equivalence_relation:
105 ∀A:setoid. compatible_equivalence_relation A → partition A.
106 #A; #R; napply mk_partition
107 [ napply (quotient ? R)
109 | #a; napply mk_qpowerclass
111 | #x; #x'; #H; nnormalize; napply mk_iff; #K; nelim daemon]
112 ##| #x; #_; nnormalize; napply (ex_intro … x); napply conj; napply refl
113 | #x; #x'; #_; #_; nnormalize; *; #x''; *; #H1; #H2; napply (trans ?????? H2);
114 napply sym; nassumption
115 | nnormalize; napply conj
116 [ #a; #_; napply I | #a; #_; napply (ex_intro … a); napply conj [ napply I | napply refl]##]