]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/nlibrary/sets/partitions.ma
e588fd2bc2273d91b1e4122697ec7c0d0717da3b
[helm.git] / helm / software / matita / nlibrary / sets / partitions.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "sets/sets.ma".
16 include "nat/plus.ma".
17 include "nat/compare.ma".
18 include "nat/minus.ma".
19
20 alias symbol "eq" = "setoid eq".
21 alias symbol "eq" = "setoid1 eq".
22 nrecord partition (A: setoid) : Type[1] ≝ 
23  { support: setoid;
24    indexes: qpowerclass support;
25    class: support → qpowerclass A;
26    inhabited: ∀i. i ∈ indexes → class i ≬ class i;
27    disjoint: ∀i,j. i ∈ indexes → j ∈ indexes → class i ≬ class j → i=j;
28    covers: big_union support ? ? (λx.class x) = full_set A
29  }. napply indexes; nqed.
30
31 naxiom daemon: False.
32
33 nlet rec partition_splits_card_map
34  A (P:partition A) n s (f:isomorphism ?? (Nat_ n) (indexes ? P))
35  (fi: ∀i. isomorphism ?? (Nat_ (s i)) (class ? P (iso_f ???? f i))) m index
36  on index : A ≝
37  match ltb m (s index) with
38   [ or_introl _ ⇒ iso_f ???? (fi index) m
39   | or_intror _ ⇒
40      match index with
41       [ O ⇒ (* dummy value: it could be an elim False: *) iso_f ???? (fi O) O
42       | S index' ⇒
43          partition_splits_card_map A P n s f fi (minus m (s index)) index']].  
44
45 nlemma partition_splits_card:
46  ∀A. ∀P:partition A. ∀n,s.
47   ∀f:isomorphism ?? (Nat_ n) (indexes ? P).
48    (∀i. isomorphism ?? (Nat_ (s i)) (class ? P (iso_f ???? f i))) →
49     (isomorphism ?? (Nat_ (big_plus n (λi.λ_.s i))) (Full_set A)).
50  #A; #P; #n; #s; #f; #fi; napply mk_isomorphism
51   [ napply mk_unary_morphism
52      [ napply (λm.partition_splits_card_map A P n s f fi m n)
53      | #a; #a'; #H; nrewrite < H; napply refl ]
54 ##| #y; #_;
55     ngeneralize in match (covers ? P) in ⊢ ?; *; #_; #Hc;
56     ngeneralize in match (Hc y I) in ⊢ ?; *; #index; *; #Hi1; #Hi2;
57     nelim daemon
58   | #x; #x'; nnormalize in ⊢ (? → ? → %);
59     nelim daemon
60   ]
61 nqed.