Section ring.
Variable S : Set.
Variable A : S -> Prop.
Variable Add Mult : S -> S -> S.
Variable O I : S.
Variable Opp : S -> S.
Variable v : S -> nat.
(*****************************************************************************)
(****************)
Definition is_ring :=
commutativity S Add /\
is_group S A Add O Opp /\
intern S A Mult /\ associativity S Mult /\ distributivity S Add Mult.
intros.
elim H; intros; elim H2; intros; elim H3; intros; elim H4; intros.
elim H6; intros; elim H8; intros; elim H10; intros; elim H13; intros.
clear H2 H4 H5 H6 H8 H9 H10 H11 H13 H14.
(* H3: is_group, H7: intern Mult, H0: (A x), H15: (A O), H16: rest of neutral, H12: distributivity *)
split.
(* x*0 = 0 *)
apply
(regular_l S A Add O Opp H3 (Mult x O) O (H7 x O H0 H15) H15
(Mult x O) (H7 x O H0 H15)).
elim (H16 (Mult x O) (H7 x O H0 H15)); intros; rewrite H2.
elim (H12 x O O); intros; elim H6.
elim (H16 O H15); intros; rewrite H8; reflexivity.
(* 0*x = 0 *)
apply
(regular_l S A Add O Opp H3 (Mult O x) O (H7 O x H15 H0) H15
(Mult O x) (H7 O x H15 H0)).
elim (H16 (Mult O x) (H7 O x H15 H0)); intros; rewrite H2.
elim (H12 O O x); intros; elim H5.
elim (H16 O H15); intros; rewrite H8; reflexivity.
Qed.
intros.
elim H; intros; elim H3; intros; elim H4; intros; elim H5; intros.
elim H7; intros; elim H9; intros; elim H11; intros; elim (H15 y H1); intros.
elim H17; intros; elim H19; intros.
clear H2 H3 H5 H6 H7 H9 H10 H11 H12 H14 H15 H16 H17 H19.
apply (opp_unicity S A Add O Opp H4 (Mult x y) (Mult x (Opp y))).
unfold is_opposite in |- *; split.
exact (H8 x y H0 H1).
split.
exact (H8 x (Opp y) H0 H18).
elim (mult_O H x H0); intros; elim H2; clear H H0 H1 H2 H3 H4 H8 H18.
pattern O at 1 in |- *; elim H20; elim H21; clear H20 H21.
elim (H13 x y (Opp y)); intros; rewrite H0; clear H H0.
elim (H13 x (Opp y) y); intros; rewrite H0; auto.
Qed.
intros.
elim H; intros; elim H3; intros; elim H4; intros; elim H5; intros.
elim H7; intros; elim H9; intros; elim H11; intros; elim (H15 x H0); intros.
elim H17; intros; elim H19; intros.
clear H2 H3 H5 H6 H7 H9 H10 H11 H12 H14 H15 H16 H17 H19.
apply (opp_unicity S A Add O Opp H4 (Mult x y) (Mult (Opp x) y)).
unfold is_opposite in |- *; split.
exact (H8 x y H0 H1).
split.
exact (H8 (Opp x) y H18 H1).
elim (mult_O H y H1); intros; elim H3; clear H H0 H1 H2 H3 H4 H8 H18.
pattern O at 1 in |- *; elim H20; elim H21; clear H20 H21.
elim (H13 x (Opp x) y); intros; rewrite H; clear H H0.
elim (H13 (Opp x) x y); intros; rewrite H; auto.
Qed.
intros.
elim H; intros; elim H3; intros; elim H4; intros; elim H5; intros.
elim H7; intros; elim H9; intros; elim H11; intros; elim (H15 x H0); intros.
elim H17; intros; clear H2 H3 H5 H6 H7 H9 H10 H11 H12 H13 H14 H15 H16 H17 H19.
rewrite (mult_opp_r H (Opp x) y H18 H1).
rewrite (mult_opp_l H x y H0 H1).
symmetry  in |- *.
exact (opp_opp S A Add O Opp H4 (Mult x y) (H8 x y H0 H1)).
Qed.
(******************)
Definition integrity := forall a b : S, Mult a b = O -> {a = O} + {b = O}.
(************************************)
Definition is_unitary_commutative_ring :=
is_ring /\ commutativity S Mult /\ neutral S A Mult I.
(* Division *)
(***************)
Definition divide (a b : S) :=
A a /\ A b /\ (b = O \/ a <> O /\ (exists q : S, A q /\ b = Mult a q)).

(**************)
Theorem div_O_O : is_ring -> divide O O.