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.
unfold addfraction_fun in |- *; simpl in |- *.
unfold eqfraction in |- *; simpl in |- *.
intros x x' y H'; try assumption.
apply
Trans
with
(ring_mult
(ring_mult
(sgroup_law R (ring_mult (num x) (den y))
(ring_mult (num y) (den x))) (den x'))
(den y)).
auto with algebra.
apply
Trans
with
(ring_mult
(ring_mult
(sgroup_law R (ring_mult (num x') (den y))
(ring_mult (num y) (den x'))) (den x))
(den y)).
apply RING_comp.
apply
Trans
with
(sgroup_law R (ring_mult (ring_mult (num x) (den y)) (den x'))
(ring_mult (ring_mult (num y) (den x)) (den x'))).
auto with algebra.
apply
Trans
with
(sgroup_law R (ring_mult (ring_mult (num x') (den y)) (den x))
(ring_mult (ring_mult (num y) (den x')) (den x))).
apply SGROUP_comp.
apply Trans with (ring_mult (ring_mult (den y) (num x)) (den x')).
auto with algebra.
apply Trans with (ring_mult (ring_mult (den y) (num x')) (den x)).
apply Trans with (ring_mult (den y) (ring_mult (num x) (den x'))).
auto with algebra.
apply Trans with (ring_mult (den y) (ring_mult (num x') (den x))).
auto with algebra.
auto with algebra.
auto with algebra.
apply Trans with (ring_mult (num y) (ring_mult (den x) (den x'))).
auto with algebra.
apply Trans with (ring_mult (num y) (ring_mult (den x') (den x))).
auto with algebra.
auto with algebra.
auto with algebra.
auto with algebra.
auto with algebra.
Qed.
unfold addfraction_fun in |- *; simpl in |- *.
unfold eqfraction in |- *; simpl in |- *.
intros x y; try assumption.
apply RING_comp; auto with algebra.
Qed.
intros x y y' H'; try assumption.
apply Trans with (addfraction_fun y x).
apply addfraction_fun_com.
apply Trans with (addfraction_fun y' x).
apply addfraction_law_l; auto with algebra.
apply addfraction_fun_com.
Qed.
red in |- *.
intros x x' y y' H' H'0; try assumption.
apply Trans with (addfraction_fun x' y).
apply addfraction_law_l; auto with algebra.
apply addfraction_law_r; auto with algebra.
Qed.
simpl in |- *.
unfold multfraction_fun, eqfraction in |- *; simpl in |- *.
intros x y z; try assumption.
apply
Trans
with
(ring_mult
(ring_mult (num x)
(sgroup_law R (ring_mult (num y) (den z))
(ring_mult (num z) (den y))))
(ring_mult (den x) (ring_mult (den y) (ring_mult (den x) (den z))))).
auto with algebra.
apply
Trans
with
(ring_mult
(ring_mult
(ring_mult (num x)
(sgroup_law R (ring_mult (num y) (den z))
(ring_mult (num z) (den y)))) (den x))
(ring_mult (den y) (ring_mult (den x) (den z)))).
auto with algebra.
apply RING_comp.
apply
Trans
with
(ring_mult
(sgroup_law R (ring_mult (num x) (ring_mult (num y) (den z)))
(ring_mult (num x) (ring_mult (num z) (den y))))
(den x)).
auto with algebra.
apply
Trans
with
(sgroup_law R
(ring_mult (ring_mult (num x) (ring_mult (num y) (den z))) (den x))
(ring_mult (ring_mult (num x) (ring_mult (num z) (den y))) (den x))).
auto with algebra.
apply SGROUP_comp.
apply
Trans
with (ring_mult (ring_mult (ring_mult (num x) (num y)) (den z)) (den x)).
auto with algebra.
apply
Trans
with (ring_mult (ring_mult (num x) (num y)) (ring_mult (den z) (den x)));
auto with algebra.
apply
Trans
with (ring_mult (ring_mult (ring_mult (num x) (num z)) (den y)) (den x)).
auto with algebra.
apply
Trans
with (ring_mult (ring_mult (num x) (num z)) (ring_mult (den y) (den x)));
auto with algebra.
auto with algebra.
Qed.

Lemma multfraction_com :
forall x y : fraction_set,
Equal (multfraction_fun x y) (multfraction_fun y x).