Section Def.
Variable R : INTEGRAL_DOMAIN.
Variable diff10 : ~ Equal (ring_unit R) (monoid_unit R).
Set Strict Implicit.
Unset Implicit Arguments.
Record fraction : Type :=
{num : R; den : R; den_prf : ~ Equal den (monoid_unit R)}.
Set Implicit Arguments.
Unset Strict Implicit.
Hint Resolve den_prf: algebra.
Definition eqfraction (x y : fraction) :=
Equal (ring_mult (num x) (den y)) (ring_mult (num y) (den x)).
red in |- *.
intros x; red in |- *.
red in |- *.
auto with algebra.
Qed.
Definition fraction0 := Build_fraction (monoid_unit R) (ring_unit R) diff10.
intros x; try assumption.
case x; unfold eqfraction, fraction0 in |- *; simpl in |- *.
intros numer denom H' H'0; try assumption.
apply Trans with (ring_mult numer (ring_unit R)); auto with algebra.
apply Trans with (ring_mult (monoid_unit R) denom); auto with algebra.
Qed.
intros x; try assumption.
case x; unfold eqfraction, fraction0 in |- *; simpl in |- *.
intros numer denom H' H'0; try assumption.
apply Trans with numer; auto with algebra.
apply Trans with (monoid_unit R); auto with algebra.
Qed.
red in |- *.
unfold app_rel, eqfraction in |- *; auto with algebra.
Qed.
red in |- *.
unfold app_rel, eqfraction in |- *.
intros x y z H' H'0; try assumption.
apply INTEGRAL_DOMAIN_simpl_l with (den y).
auto with algebra.
apply Trans with (ring_mult (ring_mult (den y) (num x)) (den z)).
auto with algebra.
apply Trans with (ring_mult (ring_mult (num x) (den y)) (den z)).
auto with algebra.
apply Trans with (ring_mult (ring_mult (num y) (den x)) (den z)).
auto with algebra.
apply Trans with (ring_mult (ring_mult (den x) (num y)) (den z)).
auto with algebra.
apply Trans with (ring_mult (den x) (ring_mult (num y) (den z))).
auto with algebra.
apply Trans with (ring_mult (den x) (ring_mult (num z) (den y))).
auto with algebra.
apply Trans with (ring_mult (ring_mult (den x) (num z)) (den y)).
auto with algebra.
apply Trans with (ring_mult (ring_mult (num z) (den x)) (den y));
auto with algebra.
Qed.
Definition fraction_set : SET.
apply (Build_Setoid (Carrier:=fraction) (Equal:=eqfraction)).
red in |- *.
split; [ try assumption | idtac ].
exact eqfraction_refl.
red in |- *.
split; [ try assumption | idtac ].
exact eqfraction_trans.
exact eqfraction_sym.
Defined.
Definition addfraction_fun (x y : fraction_set) : fraction_set :=
Build_fraction
(sgroup_law R (ring_mult (num x) (den y)) (ring_mult (num y) (den x)))
(ring_mult (den x) (den y))
(INTEGRAL_DOMAIN_prop_rev (den_prf x) (den_prf y)).
Definition opfraction_fun (x : fraction_set) : fraction_set :=
Build_fraction (group_inverse R (num x)) (den x) (den_prf x).
Definition multfraction_fun (x y : fraction_set) : fraction_set :=
Build_fraction (ring_mult (num x) (num y)) (ring_mult (den x) (den y))
(INTEGRAL_DOMAIN_prop_rev (den_prf x) (den_prf y)).
Definition fraction1 : fraction_set :=
Build_fraction (ring_unit R) (ring_unit R) diff10.

Lemma addfraction_law_l :
forall x x' y : fraction_set,
Equal x x' -> Equal (addfraction_fun x y) (addfraction_fun x' y).