+ ∀A. ∀P:partition A. ∀n,s.
+ ∀f:isomorphism ?? (Nat_ n) (indexes ? P).
+ (∀i. isomorphism ?? (Nat_ (s i)) (class ? P (iso_f ???? f i))) →
+ (isomorphism ?? (Nat_ (big_plus n (λi.λ_.s i))) (Full_set A)).
+#A; #P; #Sn; ncases Sn
+ [ #s; #f; #fi;
+ nlapply (covers ? P); *; #_; #H;
+ (*
+ nlapply
+ (big_union_preserves_iso ??? (indexes A P) (Nat_ O) (λx.class ? P x) f);
+ *; #K; #_; nwhd in K: (? → ? → %);*)
+ nelim daemon (* impossibile *)
+ | #n; #s; #f; #fi; @
+ [ @
+ [ napply (λm.let p ≝ (iso_nat_nat_union s m n) in iso_f ???? (fi (fst … p)) (snd … p))
+ | #a; #a'; #H; nrewrite < H; napply refl ]
+##| #x; #Hx; nwhd; napply I
+##| #y; #_;
+ nlapply (covers ? P); *; #_; #Hc;
+ nlapply (Hc y I); *; #index; *; #Hi1; #Hi2;
+ nlapply (f_sur ???? f ? Hi1); *; #nindex; *; #Hni1; #Hni2;
+ nlapply (f_sur ???? (fi nindex) y ?)
+ [ alias symbol "refl" (instance 3) = "refl".
+alias symbol "prop2" (instance 2) = "prop21".
+alias symbol "prop1" (instance 4) = "prop11".
+napply (. #‡(†?));##[##2: napply Hni2 |##1: ##skip | nassumption]##]
+ *; #nindex2; *; #Hni21; #Hni22;
+ nletin xxx ≝ (plus (big_plus (minus n nindex) (λi.λ_.s (S (plus i nindex)))) nindex2);
+ @ xxx; @
+ [ napply iso_nat_nat_union_pre [ napply le_S_S_to_le; nassumption | nassumption ]
+ ##| nwhd in ⊢ (???%%); napply (.= ?) [##3: nassumption|##skip]
+ nlapply (iso_nat_nat_union_char n s xxx ?)
+ [napply iso_nat_nat_union_pre [ napply le_S_S_to_le; nassumption | nassumption]##]
+ *; *; #K1; #K2; #K3;
+ nlapply
+ (iso_nat_nat_union_uniq n s nindex (fst … (iso_nat_nat_union s xxx n))
+ nindex2 (snd … (iso_nat_nat_union s xxx n)) ?????); /2/
+ [##2: *; #E1; #E2; nrewrite > E1; nrewrite > E2; //
+ | nassumption ]##]
+##| #x; #x'; nnormalize in ⊢ (? → ? → %); #Hx; #Hx'; #E;
+ ncut(∀i1,i2,i1',i2'. i1 ∈ Nat_ (S n) → i1' ∈ Nat_ (S n) → i2 ∈ Nat_ (s i1) → i2' ∈ Nat_ (s i1') → eq_rel (carr A) (eq0 A) (fi i1 i2) (fi i1' i2') → i1=i1' ∧ i2=i2');
+ ##[ #i1; #i2; #i1'; #i2'; #Hi1; #Hi1'; #Hi2; #Hi2'; #E;
+ nlapply(disjoint … P (f i1) (f i1') ???)
+ [##2,3: napply f_closed; //
+ |##1: @ (fi i1 i2); @;
+ ##[ napply f_closed; // ##| alias symbol "refl" = "refl1".
+napply (. E‡#);
+ nwhd; napply f_closed; //]##]
+ #E'; ncut(i1 = i1'); ##[ napply (f_inj … E'); // ##]
+ #E''; nrewrite < E''; @; //;
+ nrewrite < E'' in E; #E'''; napply (f_inj … E'''); //;
+ nrewrite > E''; // ]##]
+ ##] #K;
+ nelim (iso_nat_nat_union_char n s x Hx); *; #i1x; #i2x; #i3x;
+ nelim (iso_nat_nat_union_char n s x' Hx'); *; #i1x'; #i2x'; #i3x';
+ nlapply (K … E)
+ [##1,2: nassumption;
+ ##|##3,4:napply le_to_le_S_S; nassumption; ##]
+ *; #K1; #K2;
+ napply (eq_rect_CProp0_r ?? (λX.λ_.? = X) ?? i1x');
+ napply (eq_rect_CProp0_r ?? (λX.λ_.X = ?) ?? i1x);
+ nrewrite > K1; nrewrite > K2; napply refl.
+nqed.
+
+(************** equivalence relations vs partitions **********************)
+
+ndefinition partition_of_compatible_equivalence_relation:
+ ∀A:setoid. compatible_equivalence_relation A → partition A.
+ #A; #R; napply mk_partition
+ [ napply (quotient ? R)
+ | napply Full_set
+ | napply mk_unary_morphism1
+ [ #a; napply mk_ext_powerclass
+ [ napply {x | rel ? R x a}
+ | #x; #x'; #H; nnormalize; napply mk_iff; #K; nelim daemon]
+ ##| #a; #a'; #H; napply conj; #x; nnormalize; #K [ nelim daemon | nelim daemon]##]
+##| #x; #_; nnormalize; /3/
+ | #x; #x'; #_; #_; nnormalize; *; #x''; *; /3/
+ | nnormalize; napply conj; /4/ ]