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 nrecord partition (A: setoid) : Type[1] ≝
25 indexes: qpowerclass support;
26 class: support → qpowerclass A;
27 inhabited: ∀i. i ∈ indexes → class i ≬ class i;
28 disjoint: ∀i,j. i ∈ indexes → j ∈ indexes → class i ≬ class j → i=j;
29 covers: big_union support ? ? (λx.class x) = full_set A
30 }. napply indexes; nqed.
34 nlet rec partition_splits_card_map
35 A (P:partition A) n s (f:isomorphism ?? (Nat_ n) (indexes ? P))
36 (fi: ∀i. isomorphism ?? (Nat_ (s i)) (class ? P (iso_f ???? f i))) m index
38 match ltb m (s index) with
39 [ or_introl _ ⇒ iso_f ???? (fi index) m
42 [ O ⇒ (* dummy value: it could be an elim False: *) iso_f ???? (fi O) O
44 partition_splits_card_map A P n s f fi (minus m (s index)) index']].
46 nlemma partition_splits_card:
47 ∀A. ∀P:partition A. ∀n,s.
48 ∀f:isomorphism ?? (Nat_ n) (indexes ? P).
49 (∀i. isomorphism ?? (Nat_ (s i)) (class ? P (iso_f ???? f i))) →
50 (isomorphism ?? (Nat_ (big_plus n (λi.λ_.s i))) (Full_set A)).
51 #A; #P; #n; #s; #f; #fi; napply mk_isomorphism
52 [ napply mk_unary_morphism
53 [ napply (λm.partition_splits_card_map A P n s f fi m n)
54 | #a; #a'; #H; nrewrite < H; napply refl ]
56 ngeneralize in match (covers ? P) in ⊢ ?; *; #_; #Hc;
57 ngeneralize in match (Hc y I) in ⊢ ?; *; #index; *; #Hi1; #Hi2;
59 | #x; #x'; nnormalize in ⊢ (? → ? → %);
64 (************** equivalence relations vs partitions **********************)
66 ndefinition partition_of_compatible_equivalence_relation:
67 ∀A:setoid. compatible_equivalence_relation A → partition A.
68 #A; #R; napply mk_partition
69 [ napply (quotient ? R)
71 | #a; napply mk_qpowerclass
73 | #x; #x'; #H; nnormalize; napply mk_iff; #K; nelim daemon]
74 ##| #x; #_; nnormalize; napply (ex_intro … x); napply conj; napply refl
75 | #x; #x'; #_; #_; nnormalize; *; #x''; *; #H1; #H2; napply (trans ?????? H2);
76 napply sym; nassumption
77 | nnormalize; napply conj
78 [ #a; #_; napply I | #a; #_; napply (ex_intro … a); napply conj [ napply I | napply refl]##]