ndefinition union ≝ λA.λU,V:Ω \sup A.{ x | x ∈ U ∨ x ∈ V }.
interpretation "union" 'union U V = (union ? U V).
+ndefinition big_union ≝ λA,B.λT:Ω \sup A.λf:A → Ω \sup B.{ x | ∃i. i ∈ T ∧ x ∈ f i }.
+
+ndefinition big_intersection ≝ λA,B.λT:Ω \sup A.λf:A → Ω \sup B.{ x | ∀i. i ∈ T → x ∈ f i }.
+
+ndefinition full_set: ∀A. Ω \sup A ≝ λA.{ x | True }.
+(* bug dichiarazione coercion qui *)
+(* ncoercion full_set : ∀A:Type[0]. Ω \sup A ≝ full_set on _A: Type[0] to (Ω \sup ?). *)
+
nlemma subseteq_refl: ∀A.∀S: Ω \sup A. S ⊆ S.
#A; #S; #x; #H; nassumption.
nqed.
#A; napply mk_setoid1
[ napply (Ω \sup A)
| napply seteq ]
-nqed.
+nqed.
+
+unification hint 0 (∀A. (λx,y.True) (carr1 (powerclass_setoid A)) (Ω \sup A)).
(************ SETS OVER SETOIDS ********************)
mem_ok': ∀x,x':A. x=x' → (x ∈ pc) = (x' ∈ pc)
}.
+ndefinition Full_set: ∀A. qpowerclass A.
+ #A; napply mk_qpowerclass
+ [ napply (full_set A)
+ | #x; #x'; #H; nnormalize in ⊢ (?%?%%); (* bug universi qui napply refl1;*)
+ napply mk_iff; #K; nassumption ]
+nqed.
+
ndefinition qseteq: ∀A. equivalence_relation1 (qpowerclass A).
#A; napply mk_equivalence_relation1
[ napply (λS,S':qpowerclass A. eq_rel1 ? (eq1 (powerclass_setoid A)) S S')
ndefinition counter_image: ∀A,B. (A → B) → Ω \sup B → Ω \sup A ≝
λA,B,f,Sb. {x | ∃y. y ∈ Sb ∧ f x = y}.
*)
+
+(******************* compatible equivalence relations **********************)
+
+nrecord compatible_equivalence_relation (A: setoid) : Type[1] ≝
+ { rel:> equivalence_relation A;
+ compatibility: ∀x,x':A. x=x' → eq_rel ? rel x x' (* coercion qui non va *)
+ }.
+
+ndefinition quotient: ∀A. compatible_equivalence_relation A → setoid.
+ #A; #R; napply mk_setoid
+ [ napply A
+ | napply R]
+nqed.
+
+(******************* first omomorphism theorem for sets **********************)
+
+ndefinition eqrel_of_morphism:
+ ∀A,B. unary_morphism A B → compatible_equivalence_relation A.
+ #A; #B; #f; napply mk_compatible_equivalence_relation
+ [ napply mk_equivalence_relation
+ [ napply (λx,y. f x = f y)
+ | #x; napply refl | #x; #y; napply sym | #x; #y; #z; napply trans]
+##| #x; #x'; #H; nwhd; napply (.= (†H)); napply refl ]
+nqed.
+
+ndefinition canonical_proj: ∀A,R. unary_morphism A (quotient A R).
+ #A; #R; napply mk_unary_morphism
+ [ napply (λx.x) | #a; #a'; #H; napply (compatibility ? R … H) ]
+nqed.
+
+ndefinition quotiented_mor:
+ ∀A,B.∀f:unary_morphism A B.
+ unary_morphism (quotient ? (eqrel_of_morphism ?? f)) B.
+ #A; #B; #f; napply mk_unary_morphism
+ [ napply f | #a; #a'; #H; nassumption]
+nqed.
+
+nlemma first_omomorphism_theorem_functions1:
+ ∀A,B.∀f: unary_morphism A B.
+ ∀x. f x = quotiented_mor ??? (canonical_proj ? (eqrel_of_morphism ?? f) x).
+ #A; #B; #f; #x; napply refl;
+nqed.
+
+ndefinition surjective ≝
+ λA,B.λS: qpowerclass A.λT: qpowerclass B.λf:unary_morphism A B.
+ ∀y. y ∈ T → ∃x. x ∈ S ∧ f x = y.
+
+ndefinition injective ≝
+ λA,B.λS: qpowerclass A.λf:unary_morphism A B.
+ ∀x,x'. x ∈ S → x' ∈ S → f x = f x' → x = x'.
+
+nlemma first_omomorphism_theorem_functions2:
+ ∀A,B.∀f: unary_morphism A B. surjective ?? (Full_set ?) (Full_set ?) (canonical_proj ? (eqrel_of_morphism ?? f)).
+ #A; #B; #f; nwhd; #y; #Hy; napply (ex_intro … y); napply conj
+ [ napply I | napply refl]
+nqed.
+
+nlemma first_omomorphism_theorem_functions3:
+ ∀A,B.∀f: unary_morphism A B. injective ?? (Full_set ?) (quotiented_mor ?? f).
+ #A; #B; #f; nwhd; #x; #x'; #Hx; #Hx'; #K; nassumption.
+nqed.
+
+nrecord isomorphism (A) (B) (S: qpowerclass A) (T: qpowerclass B) : CProp[0] ≝
+ { iso_f:> unary_morphism A B;
+ f_sur: surjective ?? S T iso_f;
+ f_inj: injective ?? S iso_f
+ }.