Section fparts2_def.
Variable E : Setoid.
Definition disjoint (A B : part_set E) := Equal (inter A B) (empty E).
unfold disjoint in |- *.
intros A A' B B' H' H'0 H'1; try assumption.
apply Trans with (inter A B).
auto with *.
auto with *.
Qed.
intros A; case A; intros a pa; simpl in |- *.
unfold eq_part, empty in |- *; simpl in |- *.
intuition.
intros.
elim (H x); auto with *.
Qed.
unfold included, disjoint in |- *.
intros A B C H' H'0; try assumption.
apply not_in_empty.
unfold not in |- *; intros.
cut (in_part x (inter B C)).
generalize (empty_not_in (A:=inter B C) H'0).
unfold not in |- *; intros.
apply H0 with (x := x).
auto with *.
auto with *.
apply in_part_inter.
apply H'.
apply in_part_inter_l with C.
auto with *.
apply in_part_inter_r with A.
auto with *.
Qed.
intros A x; red in |- *.
unfold add_part in |- *.
auto with *.
Qed.
Hint Resolve included_add_part: algebra.
unfold not in |- *; intros.
cut (in_part x A \/ in_part x B).
intros H'; try assumption.
intuition.
auto with *.
Qed.
Hint Resolve union_not_in: algebra.
unfold disjoint in |- *.
unfold not in |- *; intros.
cut (in_part x (empty E)).
auto with *.
apply in_part_comp_r with (inter A B).
auto with *.
auto with *.
Qed.
simple induction a.
intros.
apply cardinal_comp_l with (union (empty E) B); auto with *.
apply union_comp; auto with *.
apply Sym.
auto with *.
apply cardinal_comp_l with B; auto with *.
intros.
inversion H0.
simpl in |- *.
apply cardinal_add with (union B0 B) x; auto with *.
apply H; auto with *.
apply disjoint_inclus with (add_part B0 x); auto with *.
apply disjoint_comp with A B; auto with *.
apply union_not_in; auto with *.
apply disjoint_not_in_r with A; auto with *.
apply in_part_comp_r with (add_part B0 x); auto with *.
apply Trans with (union (add_part B0 x) B); auto with *.
unfold add_part in |- *.
apply Trans with (union B0 (union (single x) B)); auto with *.
apply Trans with (union B0 (union B (single x))); auto with *.
Qed.
Hint Resolve cardinal_union_disjoint: algebra.
intros A B.
case A; case B; simpl in |- *.
intros a pa b pb.
unfold eq_part in |- *; simpl in |- *.
intuition.
Qed.
intros A B.
case A; case B; simpl in |- *.
intros a pa b pb.
unfold eq_part in |- *; simpl in |- *.
intuition.
Qed.
intros A B.
case A; case B; simpl in |- *.
intros a pa b pb.
unfold eq_part in |- *; simpl in |- *.
intuition.
Qed.
intros A B.
case A; case B; simpl in |- *.
intros a pa b pb.
unfold eq_part in |- *; simpl in |- *.
intuition.
Qed.
Hint Resolve in_diff: algebra.
intros A B; try assumption.
apply in_eq_part.
intros x H'; try assumption.
elim (in_part_union H').
auto with *.
intros H'0; try assumption.
cut (in_part x B).
auto with *.
exact (diff_in_l H'0).
intros x H'; try assumption.
elim (in_part_union H').
auto with *.
intros H'0; try assumption.
elim (classic (in_part x A)).
auto with *.
intros H'1; try assumption.
cut (in_part x (diff B A)).
auto with *.
auto with *.
Qed.
Hint Resolve union_diff: algebra.
red in |- *.
intros A B; try assumption.
apply not_in_empty.
intros x; red in |- *; intros H'; try exact H'.
absurd (in_part x A).
apply diff_in_r with B.
auto with *.
apply in_part_inter_r with A; auto with *.
apply in_part_inter_l with (diff B A); auto with *.
Qed.
Hint Resolve disjoint_diff: algebra.

Lemma cardinal_union :
forall (a b : nat) (A B : part_set E),
cardinal A a -> cardinal (diff B A) b -> cardinal (union A B) (a + b).