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.
intros.
apply cardinal_comp_l with (union A (diff B A)); auto with *.
Qed.
Hint Resolve cardinal_union: algebra.
intros A; try assumption.
apply in_eq_part.
intro.
intros H'; try assumption.
apply diff_in_l with A; auto with *.
intros x H'; try assumption.
absurd (in_part x (empty E)); auto with *.
Qed.
Hint Resolve empty_diff: algebra.
intros A; try assumption.
apply in_eq_part.
intros x H'; try assumption.
apply in_part_inter_l with A; auto with *.
intros x H'; try assumption.
absurd (in_part x (empty E)); auto with *.
Qed.
Hint Resolve empty_inter: algebra.
intros A; case A; simpl in |- *.
intros a pa.
intros x y H' H'0; try assumption.
apply pa with x; auto with *.
Qed.
intros A B0 B x H' H'0 H'1; try assumption.
apply in_eq_part.
intros x0 H'2; try assumption.
apply in_diff.
apply in_part_comp_r with (add_part B0 x).
cut (in_part x0 B0).
unfold add_part in |- *.
auto with *.
apply diff_in_l with B; auto with *.
auto with *.
apply diff_in_r with B0; auto with *.
intros x0 H'2; try assumption.
elim (classic (Equal x0 x)).
intros H'3; try assumption.
absurd (in_part x B); auto with *.
cut (in_part x (diff A B)).
intros H'4; try assumption.
apply diff_in_r with A; auto with *.
apply in_part_trans_eq with x0; auto with *.
intros H'3; try assumption.
apply in_diff.
apply add_part_in_el_diff with x; auto with *.
apply in_part_comp_r with A; auto with *.
apply diff_in_l with B; auto with *.
apply diff_in_r with A; auto with *.
Qed.
unfold not in |- *; intros.
apply H.
apply diff_in_l with B; auto with *.
Qed.
Hint Resolve diff_not_in: algebra.
unfold not in |- *; intros.
apply H.
apply in_part_inter_l with B; auto with *.
Qed.
Hint Resolve inter_not_in: algebra.
(* OK *)
unfold add_part in |- *.
intros A B0 B x H' H'0 H'1; try assumption.
apply Trans with (inter (union B0 (single x)) B).
auto with *.
apply Trans with (union (inter B0 B) (inter (single x) B)).
auto with *.
apply union_comp; auto with *.
apply in_eq_part.
intros x0 H'2; try assumption.
apply in_part_inter_l with B; auto with *.
intros x0 H'2; try assumption.
apply in_part_inter; auto with *.
apply in_part_trans_eq with x; auto with *.
Qed.
Hint Resolve inter_add_part: algebra.
intros A B0 B x H' H'0 H'1; try assumption.
apply in_eq_part.
intros x0 H'2; try assumption.
elim (classic (Equal x0 x)).
intros H'3; try assumption.
apply in_part_trans_eq with x; auto with *.
intros H'3; try assumption.
unfold add_part in |- *.
apply in_part_union_or.
left.
apply in_diff.
apply add_part_in_el_diff with x; auto with *.
apply in_part_comp_r with A; auto with *.
apply diff_in_l with B; auto with *.
apply diff_in_r with A; auto with *.
intros x0 H'2; try assumption.
apply in_diff.
apply in_part_comp_r with (add_part B0 x); auto with *.
elim (classic (Equal x0 x)).
intros H'3; try assumption.
apply in_part_trans_eq with x; auto with *.
intros H'3; try assumption.
unfold add_part in |- *.
apply in_part_union_or.
left.
unfold add_part in H'2.
elim (in_part_union H'2).
intros H'4; try assumption.
apply diff_in_l with B; auto with *.
intros H'4; try assumption.
absurd (in_part x0 (single x)); auto with *.
elim (classic (Equal x0 x)).
intros H'3; try assumption.
unfold not in |- *; intros.
unfold not in H'1.
apply H'1.
apply in_part_trans_eq with x0; auto with *.
intros H'3; try assumption.
apply diff_in_r with B0; auto with *.
apply add_part_in_el_diff with x; auto with *.
Qed.
Hint Resolve diff_add_part_not_in: algebra.
unfold add_part in |- *.
intros A B0 B x H' H'0 H'1; try assumption.
apply Trans with (inter (union B0 (single x)) B).
auto with *.
apply Trans with (union (inter B0 B) (inter (single x) B)).
apply Trans with (union (inter B0 B) (empty E)).
auto with *.
apply union_comp; auto with *.
apply Sym.
apply in_eq_part.
intros x0 H'2; try assumption.
cut (Equal x x0).
intros H'3; try assumption.
absurd (in_part x0 B).
unfold not in |- *; intro.
unfold not in H'1.
apply H'1.
apply in_part_trans_eq with x0; auto with *.
apply in_part_inter_r with (single x).
auto with *.
cut (in_part x0 (single x)).
auto with *.
apply in_part_inter_l with B.
auto with *.
intros x0 H'2; try assumption.
absurd (in_part x0 (empty E)); auto with *.
auto with *.
auto with *.
Qed.
simple induction a; intros.
exists 0; intros.
exists 0; intros.
simpl in |- *.
split.
apply cardinal_empty.
apply Trans with (diff (empty E) B); auto with *.
split.
apply cardinal_empty.
apply Trans with (inter (empty E) B); auto with *.
auto with *.
inversion H0.
elim (H B0 B); intros.
case H6; clear H6; intros.
case H6; clear H6; intros.
case H7; clear H7; intros.
case (classic (in_part x B)); intros.
exists x0.
exists (S x1).
split.
apply cardinal_comp_l with (diff B0 B); auto with *.
apply diff_add_part with x; auto with *.
split.
apply cardinal_add with (inter B0 B) x; auto with *.
rewrite H8.
auto with *.
exists (S x0).
exists x1.
split.
apply cardinal_add with (diff B0 B) x; auto with *.
split.
apply cardinal_comp_l with (inter B0 B); auto with *.
apply inter_add_part_not_in with x; auto with *.
rewrite H8; auto with *.
auto with *.
Qed.

Lemma cardinal_union_inter :
forall (A B : part_set E) (a b c : nat),
cardinal A a ->
cardinal B b -> cardinal (inter A B) c -> cardinal (union A B) (a + b - c).