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 nlemma partition_splits_card:
48 ∀A. ∀P:partition A. ∀n,s.
49 ∀f:isomorphism ?? (Nat_ n) (indexes ? P).
50 (∀i. isomorphism ?? (Nat_ (s i)) (class ? P (iso_f ???? f i))) →
51 (isomorphism ?? (Nat_ (big_plus n (λi.λ_.s i))) (Full_set A)).
52 #A; #P; #n; #s; #f; #fi; napply mk_isomorphism
53 [ napply mk_unary_morphism
54 [ napply (λm.partition_splits_card_map A P n s f fi m n)
55 | #a; #a'; #H; nrewrite < H; napply refl ]
57 ngeneralize in match (covers ? P) in ⊢ ?; *; #_; #Hc;
58 ngeneralize in match (Hc y I) in ⊢ ?; *; #index; *; #Hi1; #Hi2;
59 ngeneralize in match (f_sur ???? f ? Hi1) in ⊢ ?; *; #nindex; *; #Hni1; #Hni2;
60 ngeneralize in match (f_sur ???? (fi nindex) y ?) in ⊢ ?
61 [##2: napply (. #‡(†?));##[##3: napply Hni2 |##2: ##skip | nassumption]##]
62 *; #nindex2; *; #Hni21; #Hni22;
63 napply (ex_intro … (plus (big_plus nindex (λi.λ_.s i)) nindex2)); napply conj
64 [ nwhd in Hni1; nelim daemon
66 (* BEL POSTO DOVE FARE UN LEMMA *)
67 (* invariante: Hni1; altre premesse: Hni1, Hni22 *)
68 nchange in Hni1 with (nindex < n); ngeneralize in match Hni1 in ⊢ ?;
74 | #x; #x'; nnormalize in ⊢ (? → ? → %);
79 (************** equivalence relations vs partitions **********************)
81 ndefinition partition_of_compatible_equivalence_relation:
82 ∀A:setoid. compatible_equivalence_relation A → partition A.
83 #A; #R; napply mk_partition
84 [ napply (quotient ? R)
86 | #a; napply mk_qpowerclass
88 | #x; #x'; #H; nnormalize; napply mk_iff; #K; nelim daemon]
89 ##| #x; #_; nnormalize; napply (ex_intro … x); napply conj; napply refl
90 | #x; #x'; #_; #_; nnormalize; *; #x''; *; #H1; #H2; napply (trans ?????? H2);
91 napply sym; nassumption
92 | nnormalize; napply conj
93 [ #a; #_; napply I | #a; #_; napply (ex_intro … a); napply conj [ napply I | napply refl]##]