fact
stringlengths 8
1.54k
| type
stringclasses 19
values | library
stringclasses 8
values | imports
listlengths 1
10
| filename
stringclasses 98
values | symbolic_name
stringlengths 1
42
| docstring
stringclasses 1
value |
|---|---|---|---|---|---|---|
qpolyC_is_zmod_morphism: zmod_morphism (qpolyC h).
Proof. by move=> x y; rewrite qpolyCD qpolyCN. Qed.
#[deprecated(since="mathcomp 2.5.0",
note="use `qpolyC_is_zmod_morphism` instead")]
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg",
"From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix",
"From mathcomp Require Import mxalgebra mxpoly vector countalg"
] |
algebra/qpoly.v
|
qpolyC_is_zmod_morphism
| |
qpolyC_is_additive:= qpolyC_is_zmod_morphism.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg",
"From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix",
"From mathcomp Require Import mxalgebra mxpoly vector countalg"
] |
algebra/qpoly.v
|
qpolyC_is_additive
| |
qpolyC_is_monoid_morphism: monoid_morphism (qpolyC h).
Proof. by split=> // x y; rewrite qpolyCM. Qed.
#[deprecated(since="mathcomp 2.5.0",
note="use `qpolyC_is_monoid_morphism` instead")]
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg",
"From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix",
"From mathcomp Require Import mxalgebra mxpoly vector countalg"
] |
algebra/qpoly.v
|
qpolyC_is_monoid_morphism
| |
qpolyC_is_multiplicative:=
(fun g => (g.2,g.1)) qpolyC_is_monoid_morphism.
HB.instance Definition _ := GRing.isZmodMorphism.Build A {poly %/ h} (qpolyC h)
qpolyC_is_zmod_morphism.
HB.instance Definition _ :=
GRing.isMonoidMorphism.Build A {poly %/ h} (qpolyC h)
qpolyC_is_monoid_morphism.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg",
"From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix",
"From mathcomp Require Import mxalgebra mxpoly vector countalg"
] |
algebra/qpoly.v
|
qpolyC_is_multiplicative
| |
qpoly_scalek (p : {poly %/ h}) : {poly %/ h} := (k *: p)%R.
Fact qpoly_scaleA a b p :
qpoly_scale a (qpoly_scale b p) = qpoly_scale (a * b) p.
Proof. by apply/val_eqP; rewrite /= scalerA. Qed.
Fact qpoly_scale1l : left_id 1%R qpoly_scale.
Proof. by move=> p; apply/val_eqP; rewrite /= scale1r. Qed.
Fact qpoly_scaleDr a : {morph qpoly_scale a : p q / (p + q)%R}.
Proof. by move=> p q; apply/val_eqP; rewrite /= scalerDr. Qed.
Fact qpoly_scaleDl p : {morph qpoly_scale^~ p : a b / a + b}%R.
Proof. by move=> a b; apply/val_eqP; rewrite /= scalerDl. Qed.
Fact qpoly_scaleAl a p q : qpoly_scale a (p * q) = (qpoly_scale a p * q).
Proof. by apply/val_eqP; rewrite /= -scalerAl rmodpZ // monic_mk_monic. Qed.
Fact qpoly_scaleAr a p q : qpoly_scale a (p * q) = p * (qpoly_scale a q).
Proof. by apply/val_eqP; rewrite /= -scalerAr rmodpZ // monic_mk_monic. Qed.
HB.instance Definition _ := GRing.Lmodule_isLalgebra.Build A {poly__ A}
qpoly_scaleAl.
HB.instance Definition _ := GRing.Lalgebra.on {poly %/ h}.
HB.instance Definition _ := GRing.Lalgebra_isAlgebra.Build A {poly__ A}
qpoly_scaleAr.
HB.instance Definition _ := GRing.Algebra.on {poly %/ h}.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg",
"From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix",
"From mathcomp Require Import mxalgebra mxpoly vector countalg"
] |
algebra/qpoly.v
|
qpoly_scale
| |
poly_of_qpolyZ(p : {poly %/ h}) a :
a *: p = a *: (p : {poly A}) :> {poly A}.
Proof. by []. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg",
"From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix",
"From mathcomp Require Import mxalgebra mxpoly vector countalg"
] |
algebra/qpoly.v
|
poly_of_qpolyZ
| |
char_qpoly:= (pchar_qpoly) (only parsing).
|
Notation
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg",
"From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix",
"From mathcomp Require Import mxalgebra mxpoly vector countalg"
] |
algebra/qpoly.v
|
char_qpoly
| |
qpoly_inv(p : {poly %/ h}) :=
if coprimep hQ p then let v : {poly %/ h} := in_qpoly h (egcdp hQ p).2 in
((lead_coef (v * p)) ^-1 *: v) else p.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg",
"From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix",
"From mathcomp Require Import mxalgebra mxpoly vector countalg"
] |
algebra/qpoly.v
|
qpoly_inv
| |
qpoly_mulVz(p : {poly %/ h}) : coprimep hQ p -> (qpoly_inv p * p = 1)%R.
Proof.
have hQM := monic_mk_monic h.
move=> hCp; apply: val_inj; rewrite /qpoly_inv /in_qpoly hCp /=.
have p_neq0 : p != 0%R.
apply/eqP=> pZ; move: hCp; rewrite pZ.
rewrite coprimep0 -size_poly_eq1.
by case: size (size_mk_monic_gt1 h) => [|[]].
have F : (egcdp hQ p).1 * hQ + (egcdp hQ p).2 * p %= 1.
apply: eqp_trans _ (_ : gcdp hQ p %= _).
rewrite eqp_sym.
by case: (egcdpP (mk_monic_neq0 h) p_neq0).
by rewrite -size_poly_eq1.
rewrite rmodp_mulml // -scalerAl rmodpZ // rmodp_mulml //.
rewrite -[rmodp]/rmodp -!Pdiv.IdomainMonic.modpE //.
have := eqp_modpl hQ F.
rewrite modpD // modp_mull add0r // .
rewrite [(1 %% _)%R]modp_small => // [egcdE|]; last first.
by rewrite size_polyC oner_eq0 size_mk_monic_gt1.
rewrite {2}(eqpfP egcdE) lead_coefC divr1 alg_polyC scale_polyC mulVf //.
rewrite lead_coef_eq0.
apply/eqP => egcdZ.
by move: egcdE; rewrite -size_poly_eq1 egcdZ size_polyC eq_sym eqxx.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg",
"From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix",
"From mathcomp Require Import mxalgebra mxpoly vector countalg"
] |
algebra/qpoly.v
|
qpoly_mulVz
| |
qpoly_mulzV(p : {poly %/ h}) :
coprimep hQ p -> (p * (qpoly_inv p) = 1)%R.
Proof. by move=> hCp; rewrite /= mulrC qpoly_mulVz. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg",
"From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix",
"From mathcomp Require Import mxalgebra mxpoly vector countalg"
] |
algebra/qpoly.v
|
qpoly_mulzV
| |
qpoly_intro_unit(p q : {poly %/ h}) : (q * p = 1)%R -> coprimep hQ p.
Proof.
have hQM := monic_mk_monic h.
case; rewrite -[rmodp]/rmodp -!Pdiv.IdomainMonic.modpE // => qp1.
have:= coprimep1 hQ.
rewrite -coprimep_modr -[1%R]qp1 !coprimep_modr coprimepMr; by case/andP.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg",
"From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix",
"From mathcomp Require Import mxalgebra mxpoly vector countalg"
] |
algebra/qpoly.v
|
qpoly_intro_unit
| |
qpoly_inv_out(p : {poly %/ h}) : ~~ coprimep hQ p -> qpoly_inv p = p.
Proof. by rewrite /qpoly_inv => /negPf->. Qed.
HB.instance Definition _ := GRing.ComNzRing_hasMulInverse.Build {poly__ _}
qpoly_mulVz qpoly_intro_unit qpoly_inv_out.
HB.instance Definition _ := GRing.ComUnitAlgebra.on {poly %/ h}.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg",
"From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix",
"From mathcomp Require Import mxalgebra mxpoly vector countalg"
] |
algebra/qpoly.v
|
qpoly_inv_out
| |
irreducible_poly_coprime(A : idomainType) (p q : {poly A}) :
irreducible_poly p -> coprimep p q = ~~(p %| q)%R.
Proof.
case => H1 H2; apply/coprimepP/negP.
move=> sPq H.
by have := sPq p (dvdpp _) H; rewrite -size_poly_eq1; case: size H1 => [|[]].
move=> pNDq d dDp dPq.
rewrite -size_poly_eq1; case: eqP => // /eqP /(H2 _) => /(_ dDp) dEp.
by case: pNDq; rewrite -(eqp_dvdl _ dEp).
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg",
"From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix",
"From mathcomp Require Import mxalgebra mxpoly vector countalg"
] |
algebra/qpoly.v
|
irreducible_poly_coprime
| |
rat: Set := Rat {
valq : (int * int);
_ : (0 < valq.2) && coprime `|valq.1| `|valq.2|
}.
Bind Scope ring_scope with rat.
Delimit Scope rat_scope with Q.
|
Record
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
rat
| |
ratz(n : int) := @Rat (n, 1) (coprimen1 _).
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
ratz
| |
rat_isSub:= Eval hnf in [isSub for valq].
HB.instance Definition _ := rat_isSub.
#[hnf] HB.instance Definition _ := [Equality of rat by <:].
HB.instance Definition _ := [Countable of rat by <:].
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
rat_isSub
| |
numqx := (valq x).1.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
numq
| |
denqx := (valq x).2.
Arguments numq : simpl never.
Arguments denq : simpl never.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
denq
| |
denq_gt0x : 0 < denq x.
Proof. by rewrite /denq; case: x=> [[a b] /= /andP []]. Qed.
#[global] Hint Resolve denq_gt0 : core.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
denq_gt0
| |
denq_ge0x := ltW (denq_gt0 x).
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
denq_ge0
| |
denq_lt0x : (denq x < 0) = false. Proof. by rewrite lt_gtF. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
denq_lt0
| |
denq_neq0x : denq x != 0.
Proof. by rewrite /denq gt_eqF ?denq_gt0. Qed.
#[global] Hint Resolve denq_neq0 : core.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
denq_neq0
| |
denq_eq0x : (denq x == 0) = false.
Proof. exact: negPf (denq_neq0 _). Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
denq_eq0
| |
coprime_num_denx : coprime `|numq x| `|denq x|.
Proof. by rewrite /numq /denq; case: x=> [[a b] /= /andP []]. Qed.
Fact RatK x P : @Rat (numq x, denq x) P = x.
Proof. by move: x P => [[a b] P'] P; apply: val_inj. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
coprime_num_den
| |
fracq_subdefx :=
if x.2 != 0 then let g := gcdn `|x.1| `|x.2| in
((-1) ^ ((x.2 < 0) (+) (x.1 < 0)) * (`|x.1| %/ g)%:Z, (`|x.2| %/ g)%:Z)
else (0, 1).
Arguments fracq_subdef /.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
fracq_subdef
| |
fracq_opt_subdef(x : int * int) :=
if (0 < x.2) && coprime `|x.1| `|x.2| then x else fracq_subdef x.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
fracq_opt_subdef
| |
fracq_opt_subdefEx : fracq_opt_subdef x = fracq_subdef x.
Proof.
rewrite /fracq_opt_subdef; case: ifP => //; case: x => n d /= /andP[d_gt0 cnd].
rewrite /fracq_subdef gt_eqF//= lt_gtF//= (eqP cnd) !divn1 abszEsg gtz0_abs//.
rewrite mulrA sgz_def mulrnAr -signr_addb addbb expr0.
by have [->|] := eqVneq n 0; rewrite (mulr0, mul1r).
Qed.
Fact fracq_subproof x (y := fracq_opt_subdef x) :
(0 < y.2) && (coprime `|y.1| `|y.2|).
Proof.
rewrite {}/y fracq_opt_subdefE /=; have [] //= := eqVneq x.2 0.
case: x => [/= n d]; rewrite -absz_gt0 => dN0.
have ggt0 : (0 < gcdn `|n| `|d|)%N by rewrite gcdn_gt0 dN0 orbT.
rewrite ltz_nat divn_gt0// dvdn_leq ?dvdn_gcdr//=.
rewrite abszM abszX abszN1 exp1n mul1n absz_nat.
rewrite /coprime -(@eqn_pmul2r (gcdn `|n| `|d|))// mul1n.
by rewrite muln_gcdl !divnK ?(dvdn_gcdl, dvdn_gcdr).
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
fracq_opt_subdefE
| |
fracq_opt_subdef_idx :
fracq_opt_subdef (fracq_opt_subdef x) = fracq_subdef x.
Proof.
rewrite [fracq_opt_subdef (_ x)]/fracq_opt_subdef.
by rewrite fracq_subproof fracq_opt_subdefE.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
fracq_opt_subdef_id
| |
fracq'((n', d')) : rat :=
match d', n' with
| Posz 0 as d, _ as n => Rat (fracq_subproof (1, 0))
| _ as d, Posz _ as n | _ as d, _ as n =>
Rat (fracq_subproof (fracq_opt_subdef (n, d)))
end.
Arguments fracq : simpl never.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
fracq
| |
Irat_prf:= Ifracq_subproof : (int * int) -> Irat_prf.
|
Variant
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
Irat_prf
| |
Irat:= IRat : (int * int) -> Irat_prf -> Irat.
|
Variant
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
Irat
| |
parse(x : Number.number) : option Irat :=
let parse_pos i f :=
let nf := Decimal.nb_digits f in
let d := (10 ^ nf)%nat in
let n := (Nat.of_uint i * d + Nat.of_uint f)%nat in
valq (fracq (Posz n, Posz d)) in
let parse i f :=
match i with
| Decimal.Pos i => parse_pos i f
| Decimal.Neg i => let (n, d) := parse_pos i f in ((- n)%R, d)
end in
match x with
| Number.Decimal (Decimal.Decimal i f) =>
let nd := parse i f in
Some (IRat nd (Ifracq_subproof nd))
| Number.Decimal (Decimal.DecimalExp _ _ _) => None
| Number.Hexadecimal _ => None
end.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
parse
| |
print(r : Irat) : option Number.number :=
let print_pos n d :=
if d == 1%nat then Some (Nat.to_uint n, Decimal.Nil) else
let d2d5 :=
match prime_decomp d with
| [:: (2, d2); (5, d5)] => Some (d2, d5)
| [:: (2, d2)] => Some (d2, O)
| [:: (5, d5)] => Some (O, d5)
| _ => None
end in
match d2d5 with
| Some (d2, d5) =>
let f := (2 ^ (d5 - d2) * 5 ^ (d2 - d5))%nat in
let (i, f) := edivn (n * f) (d * f) in
Some (Nat.to_uint i, Nat.to_uint f)
| None => None
end in
let print_IRat nd :=
match nd with
| (Posz n, Posz d) =>
match print_pos n d with
| Some (i, f) => Some (Decimal.Pos i, f)
| None => None
end
| (Negz n, Posz d) =>
match print_pos n.+1 d with
| Some (i, f) => Some (Decimal.Neg i, f)
| None => None
end
| (_, Negz _) => None
end in
match r with
| IRat nd _ =>
match print_IRat nd with
| Some (i, f) => Some (Number.Decimal (Decimal.Decimal i f))
| None => None
end
end.
Number Notation rat parse print (via Irat
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
print
| |
val_fracqx : val (fracq x) = fracq_subdef x.
Proof. by case: x => [[n|n] [[|[|d]]|d]]//=; rewrite !fracq_opt_subdef_id. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
val_fracq
| |
num_fracqx : numq (fracq x) = if x.2 != 0 then
(-1) ^ ((x.2 < 0) (+) (x.1 < 0)) * (`|x.1| %/ gcdn `|x.1| `|x.2|)%:Z else 0.
Proof. by rewrite /numq val_fracq/=; case: ifP. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
num_fracq
| |
den_fracqx : denq (fracq x) =
if x.2 != 0 then (`|x.2| %/ gcdn `|x.1| `|x.2|)%:Z else 1.
Proof. by rewrite /denq val_fracq/=; case: ifP. Qed.
Fact ratz_frac n : ratz n = fracq (n, 1).
Proof.
by apply: val_inj; rewrite val_fracq/= gcdn1 !divn1 abszE mulr_sign_norm.
Qed.
Fact valqK x : fracq (valq x) = x.
Proof.
move: x => [[n d] /= Pnd]; apply: val_inj; rewrite ?val_fracq/=.
move: Pnd; rewrite /coprime /fracq /= => /andP[] hd -/eqP hnd.
by rewrite lt_gtF ?gt_eqF //= hnd !divn1 mulz_sign_abs abszE gtr0_norm.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
den_fracq
| |
scalq'(n, d) := sgr d * (gcdn `|n| `|d|)%:Z.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
scalq
| |
scalq_defx : scalq x = sgr x.2 * (gcdn `|x.1| `|x.2|)%:Z.
Proof. by case: x. Qed.
Fact scalq_eq0 x : (scalq x == 0) = (x.2 == 0).
Proof.
case: x => n d; rewrite scalq_def /= mulf_eq0 sgr_eq0 /= eqz_nat.
rewrite -[gcdn _ _ == 0]negbK -lt0n gcdn_gt0 ?absz_gt0 [X in ~~ X]orbC.
by case: sgrP.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
scalq_def
| |
sgr_scalqx : sgr (scalq x) = sgr x.2.
Proof.
rewrite scalq_def sgrM sgr_id -[(gcdn _ _)%:Z]intz sgr_nat.
by rewrite -lt0n gcdn_gt0 ?absz_gt0 orbC; case: sgrP; rewrite // mul0r.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
sgr_scalq
| |
signr_scalqx : (scalq x < 0) = (x.2 < 0).
Proof. by rewrite -!sgr_cp0 sgr_scalq. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
signr_scalq
| |
scalqEx :
x.2 != 0 -> scalq x = (-1) ^+ (x.2 < 0)%R * (gcdn `|x.1| `|x.2|)%:Z.
Proof. by rewrite scalq_def; case: sgrP. Qed.
Fact valq_frac x :
x.2 != 0 -> x = (scalq x * numq (fracq x), scalq x * denq (fracq x)).
Proof.
move=> x2_neq0; rewrite scalqE//; move: x2_neq0.
case: x => [n d] /= d_neq0; rewrite num_fracq den_fracq/= ?d_neq0.
rewrite mulr_signM -mulrA -!PoszM addKb.
do 2!rewrite muln_divCA ?(dvdn_gcdl, dvdn_gcdr) // divnn.
by rewrite gcdn_gt0 !absz_gt0 d_neq0 orbT !muln1 !mulz_sign_abs.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
scalqE
| |
zeroq:= 0%Q.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
zeroq
| |
oneq:= 1%Q.
Fact frac0q x : fracq (0, x) = zeroq.
Proof.
apply: val_inj; rewrite //= val_fracq/= div0n !gcd0n !mulr0 !divnn.
by have [//|x_neq0] := eqVneq; rewrite absz_gt0 x_neq0.
Qed.
Fact fracq0 x : fracq (x, 0) = zeroq. Proof. exact/eqP. Qed.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
oneq
| |
fracq_spec(x : int * int) : int * int -> rat -> Type :=
| FracqSpecN of x.2 = 0 : fracq_spec x (x.1, 0) zeroq
| FracqSpecP k fx of k != 0 : fracq_spec x (k * numq fx, k * denq fx) fx.
Fact fracqP x : fracq_spec x x (fracq x).
Proof.
case: x => n d /=; have [d_eq0 | d_neq0] := eqVneq d 0.
by rewrite d_eq0 fracq0; constructor.
by rewrite {2}[(_, _)]valq_frac //; constructor; rewrite scalq_eq0.
Qed.
|
Variant
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
fracq_spec
| |
rat_eqEx y : (x == y) = (numq x == numq y) && (denq x == denq y).
Proof.
rewrite -val_eqE [val x]surjective_pairing [val y]surjective_pairing /=.
by rewrite xpair_eqE.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
rat_eqE
| |
sgr_denqx : sgr (denq x) = 1. Proof. by apply/eqP; rewrite sgr_cp0. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
sgr_denq
| |
normr_denqx : `|denq x| = denq x. Proof. by rewrite gtr0_norm. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
normr_denq
| |
absz_denqx : `|denq x|%N = denq x :> int.
Proof. by rewrite abszE normr_denq. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
absz_denq
| |
rat_eqx y : (x == y) = (numq x * denq y == numq y * denq x).
Proof.
symmetry; rewrite rat_eqE andbC.
have [->|] /= := eqVneq (denq _); first by rewrite (inj_eq (mulIf _)).
apply: contraNF => /eqP hxy; rewrite -absz_denq -[eqbRHS]absz_denq.
rewrite eqz_nat /= eqn_dvd.
rewrite -(@Gauss_dvdr _ `|numq x|) 1?coprime_sym ?coprime_num_den // andbC.
rewrite -(@Gauss_dvdr _ `|numq y|) 1?coprime_sym ?coprime_num_den //.
by rewrite -!abszM hxy -{1}hxy !abszM !dvdn_mull ?dvdnn.
Qed.
Fact fracq_eq x y : x.2 != 0 -> y.2 != 0 ->
(fracq x == fracq y) = (x.1 * y.2 == y.1 * x.2).
Proof.
case: fracqP=> //= u fx u_neq0 _; case: fracqP=> //= v fy v_neq0 _; symmetry.
rewrite [eqbRHS]mulrC mulrACA [eqbRHS]mulrACA.
by rewrite [denq _ * _]mulrC (inj_eq (mulfI _)) ?mulf_neq0 // rat_eq.
Qed.
Fact fracq_eq0 x : (fracq x == zeroq) = (x.1 == 0) || (x.2 == 0).
Proof.
move: x=> [n d] /=; have [->|d0] := eqVneq d 0.
by rewrite fracq0 eqxx orbT.
by rewrite -[zeroq]valqK orbF fracq_eq ?d0 //= mulr1 mul0r.
Qed.
Fact fracqMM x n d : x != 0 -> fracq (x * n, x * d) = fracq (n, d).
Proof.
move=> x_neq0; apply/eqP.
have [->|d_neq0] := eqVneq d 0; first by rewrite mulr0 !fracq0.
by rewrite fracq_eq ?mulf_neq0 //= mulrCA mulrA.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
rat_eq
| |
addq_subdef(x y : int * int) :=
let: (x1, x2) := x in
let: (y1, y2) := y in
match x2, y2 with
| Posz 1, Posz 1 =>
match x1, y1 with
| Posz 0, _ => (y1, 1)
| _, Posz 0 => (x1, 1)
| Posz n, Posz 1 => (Posz n.+1, 1)
| Posz 1, Posz n => (Posz n.+1, 1)
| _, _ => (x1 + y1, 1)
end
| Posz 1, _ => (x1 * y2 + y1, y2)
| _, Posz 1 => (x1 + y1 * x2, x2)
| _, _ => (x1 * y2 + y1 * x2, x2 * y2)
end.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
addq_subdef
| |
addq'(Rat x xP) '(Rat y yP) := fracq (addq_subdef x y).
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
addq
| |
addq_defx y : addq x y = fracq (addq_subdef (valq x) (valq y)).
Proof. by case: x; case: y. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
addq_def
| |
addq_subdefEx y : addq_subdef x y = (x.1 * y.2 + y.1 * x.2, x.2 * y.2).
Proof.
case: x y => [x1 [[|[|x2]]|x2]] [y1 [[|[|y2]]|y2]]/=; rewrite ?Monoid.simpm//.
by case: x1 y1 => [[|[|m]]|m] [[|[|n]]|n]; rewrite ?Monoid.simpm// -PoszD addn1.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
addq_subdefE
| |
oppq_subdef(x : int * int) := (- x.1, x.2).
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
oppq_subdef
| |
oppq'(Rat x xP) := fracq (oppq_subdef x).
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
oppq
| |
oppq_defx : oppq x = fracq (oppq_subdef (valq x)).
Proof. by case: x. Qed.
Fact addq_subdefC : commutative addq_subdef.
Proof. by move=> x y; rewrite !addq_subdefE addrC [x.2 * _]mulrC. Qed.
Fact addq_subdefA : associative addq_subdef.
Proof.
move=> x y z; rewrite !addq_subdefE.
by rewrite !mulrA !mulrDl addrA ![_ * x.2]mulrC !mulrA.
Qed.
Fact addq_frac x y : x.2 != 0 -> y.2 != 0 ->
(addq (fracq x) (fracq y)) = fracq (addq_subdef x y).
Proof.
case: fracqP => // u fx u_neq0 _; case: fracqP => // v fy v_neq0 _.
rewrite addq_def !addq_subdefE /=.
rewrite ![(_ * numq _) * _]mulrACA [(_ * denq _) * _]mulrACA.
by rewrite [v * _]mulrC -mulrDr fracqMM ?mulf_neq0.
Qed.
Fact ratzD : {morph ratz : x y / x + y >-> addq x y}.
Proof. by move=> x y; rewrite !ratz_frac addq_frac// addq_subdefE/= !mulr1. Qed.
Fact oppq_frac x : oppq (fracq x) = fracq (oppq_subdef x).
Proof.
rewrite /oppq_subdef; case: fracqP => /= [|u fx u_neq0].
by rewrite fracq0.
by rewrite oppq_def -mulrN fracqMM.
Qed.
Fact ratzN : {morph ratz : x / - x >-> oppq x}.
Proof. by move=> x /=; rewrite !ratz_frac // /add /= !mulr1. Qed.
Fact addqC : commutative addq.
Proof. by move=> x y; rewrite !addq_def /= addq_subdefC. Qed.
Fact addqA : associative addq.
Proof.
move=> x y z; rewrite -[x]valqK -[y]valqK -[z]valqK.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
oppq_def
| |
mulq_subdef(x y : int * int) :=
let: (x1, x2) := x in
let: (y1, y2) := y in
match x2, y2 with
| Posz 1, Posz 1 => (x1 * y1, 1)
| Posz 1, _ => (x1 * y1, y2)
| _, Posz 1 => (x1 * y1, x2)
| _, _ => (x1 * y1, x2 * y2)
end.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
mulq_subdef
| |
mulq'(Rat x xP) '(Rat y yP) := fracq (mulq_subdef x y).
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
mulq
| |
mulq_defx y : mulq x y = fracq (mulq_subdef (valq x) (valq y)).
Proof. by case: x; case: y. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
mulq_def
| |
mulq_subdefEx y : mulq_subdef x y = (x.1 * y.1, x.2 * y.2).
Proof.
by case: x y => [x1 [[|[|x2]]|x2]] [y1 [[|[|y2]]|y2]]/=; rewrite ?Monoid.simpm.
Qed.
Fact mulq_subdefC : commutative mulq_subdef.
Proof. by move=> x y; rewrite !mulq_subdefE mulrC [_ * x.2]mulrC. Qed.
Fact mul_subdefA : associative mulq_subdef.
Proof. by move=> x y z; rewrite !mulq_subdefE !mulrA. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
mulq_subdefE
| |
invq_subdef(x : int * int) := (x.2, x.1).
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
invq_subdef
| |
invq'(Rat x xP) := fracq (invq_subdef x).
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
invq
| |
invq_defx : invq x = fracq (invq_subdef (valq x)).
Proof. by case: x. Qed.
Fact mulq_frac x y : (mulq (fracq x) (fracq y)) = fracq (mulq_subdef x y).
Proof.
rewrite mulq_def !mulq_subdefE; case: (fracqP x) => /= [|u fx u_neq0].
by rewrite !mul0r !mul1r fracq0 frac0q.
case: (fracqP y) => /= [|v fy v_neq0].
by rewrite !mulr0 !mulr1 fracq0 frac0q.
by rewrite ![_ * (v * _)]mulrACA [RHS]fracqMM ?mulf_neq0.
Qed.
Fact ratzM : {morph ratz : x y / x * y >-> mulq x y}.
Proof. by move=> x y /=; rewrite !ratz_frac //= !mulr1. Qed.
Fact invq_frac x :
x.1 != 0 -> x.2 != 0 -> invq (fracq x) = fracq (invq_subdef x).
Proof. by rewrite invq_def; case: (fracqP x) => // k ? k0; rewrite fracqMM. Qed.
Fact mulqC : commutative mulq.
Proof. by move=> x y; rewrite !mulq_def mulq_subdefC. Qed.
Fact mulqA : associative mulq.
Proof.
by move=> x y z; rewrite -[x]valqK -[y]valqK -[z]valqK !mulq_frac mul_subdefA.
Qed.
Fact mul1q : left_id oneq mulq.
Proof.
move=> x; rewrite -[x]valqK -[oneq]valqK; rewrite mulq_frac !mulq_subdefE.
by rewrite !mul1r -surjective_pairing.
Qed.
Fact mulq_addl : left_distributive mulq addq.
Proof.
move=> x y z; rewrite -[x]valqK -[y]valqK -[z]valqK /=.
rewrite !(mulq_frac, addq_frac, mulq_subdefE, addq_subdefE) ?mulf_neq0 ?denq_neq0 //=.
apply/eqP; rewrite fracq_eq ?mulf_neq0 ?denq_neq0 //= !mulrDl; apply/eqP.
by rewrite !mulrA ![_ * (valq z).1]mulrC !mulrA ![_ * (valq x).2]mulrC !mulrA.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
invq_def
| |
numq_eq0x : (numq x == 0) = (x == 0).
Proof.
rewrite -[x]valqK fracq_eq0; case: fracqP=> /= [|k {}x k0].
by rewrite eqxx orbT.
by rewrite !mulf_eq0 (negPf k0) /= denq_eq0 orbF.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
numq_eq0
| |
subq(x y : rat) : rat := (addq x (oppq y)).
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
subq
| |
divq(x y : rat) : rat := (mulq x (invq y)).
Infix "+" := addq : rat_scope.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
divq
| |
ratzEn : ratz n = n%:Q.
Proof.
elim: n=> [|n ihn|n ihn]; first by rewrite mulr0z ratz_frac.
by rewrite intS mulrzDr ratzD ihn.
by rewrite intS opprD mulrzDr ratzD ihn.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
ratzE
| |
numq_intn : numq n%:Q = n. Proof. by rewrite -ratzE. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
numq_int
| |
denq_intn : denq n%:Q = 1. Proof. by rewrite -ratzE. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
denq_int
| |
rat0: 0%:Q = 0. Proof. by []. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
rat0
| |
rat1: 1%:Q = 1. Proof. by []. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
rat1
| |
numqNx : numq (- x) = - numq x.
Proof.
rewrite [- _]oppq_def/= num_fracq.
case: x => -[a b]; rewrite /numq/= => /andP[b_gt0].
rewrite /coprime => /eqP cab.
by rewrite lt_gtF ?gt_eqF // {2}abszN cab divn1 mulz_sign_abs.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
numqN
| |
denqNx : denq (- x) = denq x.
Proof.
rewrite [- _]oppq_def den_fracq.
case: x => -[a b]; rewrite /denq/= => /andP[b_gt0].
by rewrite /coprime=> /eqP cab; rewrite gt_eqF // abszN cab divn1 gtz0_abs.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
denqN
| |
fracqEx : fracq x = x.1%:Q / x.2%:Q.
Proof.
move: x => [m n] /=; apply/val_inj; rewrite val_fracq/=.
case: eqVneq => //= [->|n_neq0]; first by rewrite rat0 invr0 mulr0.
rewrite -[m%:Q]valqK -[n%:Q]valqK.
rewrite [_^-1]invq_frac ?denq_neq0 ?numq_eq0 ?intq_eq0//=.
rewrite [X in valq X]mulq_frac val_fracq /invq_subdef !mulq_subdefE/=.
by rewrite -!/(numq _) -!/(denq _) !numq_int !denq_int mul1r mulr1 n_neq0.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
fracqE
| |
divq_num_denx : (numq x)%:Q / (denq x)%:Q = x.
Proof. by rewrite -{3}[x]valqK [valq _]surjective_pairing /= fracqE. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
divq_num_den
| |
divq_spec(n d : int) : int -> int -> rat -> Type :=
| DivqSpecN of d = 0 : divq_spec n d n 0 0
| DivqSpecP k x of k != 0 : divq_spec n d (k * numq x) (k * denq x) x.
|
Variant
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
divq_spec
| |
divqPn d : divq_spec n d n d (n%:Q / d%:Q).
Proof.
set x := (n, d); rewrite -[n]/x.1 -[d]/x.2 -fracqE.
by case: fracqP => [_|k fx k_neq0] /=; constructor.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
divqP
| |
rat_spec : rat -> int -> int -> Type :=
Rat_spec (n : int) (d : nat) & coprime `|n| d.+1
: rat_spec (n%:Q / d.+1%:Q) n d.+1.
|
Variant
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
rat_spec
| |
ratPx : rat_spec x (numq x) (denq x).
Proof.
rewrite -{1}[x](divq_num_den); case hd: denq => [p|n].
have: 0 < p%:Z by rewrite -hd denq_gt0.
case: p hd=> //= n hd; constructor; rewrite -?hd ?divq_num_den //.
by rewrite -[n.+1]/`|n.+1|%N -hd coprime_num_den.
by move: (denq_gt0 x); rewrite hd.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
ratP
| |
coprimeq_numn d : coprime `|n| `|d| -> numq (n%:~R / d%:~R) = sgr d * n.
Proof.
move=> cnd /=; have <- := fracqE (n, d).
rewrite num_fracq/= (eqP (cnd : _ == 1)) divn1.
have [|d_gt0|d_lt0] := sgrP d;
by rewrite (mul0r, mul1r, mulN1r) //= ?[_ ^ _]signrN ?mulNr mulz_sign_abs.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
coprimeq_num
| |
coprimeq_denn d :
coprime `|n| `|d| -> denq (n%:~R / d%:~R) = (if d == 0 then 1 else `|d|).
Proof.
move=> cnd; have <- := fracqE (n, d).
by rewrite den_fracq/= (eqP (cnd : _ == 1)) divn1; case: d {cnd}; case.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
coprimeq_den
| |
denqVz(i : int) : i != 0 -> denq (i%:~R^-1) = `|i|.
Proof.
move=> h; rewrite -div1r -[1]/(1%:~R).
by rewrite coprimeq_den /= ?coprime1n // (negPf h).
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
denqVz
| |
numqEx : (numq x)%:~R = x * (denq x)%:~R.
Proof. by rewrite -{2}[x]divq_num_den divfK // intq_eq0 denq_eq0. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
numqE
| |
denqPx : {d | denq x = d.+1}.
Proof. by rewrite /denq; case: x => [[_ [[|d]|]] //= _]; exists d. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
denqP
| |
normq'(Rat x _) : rat := `|x.1|%:~R / (x.2)%:~R.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
normq
| |
le_rat'(Rat x _) '(Rat y _) := x.1 * y.2 <= y.1 * x.2.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
le_rat
| |
lt_rat'(Rat x _) '(Rat y _) := x.1 * y.2 < y.1 * x.2.
|
Definition
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
lt_rat
| |
normqEx : normq x = `|numq x|%:~R / (denq x)%:~R.
Proof. by case: x. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
normqE
| |
le_ratEx y : le_rat x y = (numq x * denq y <= numq y * denq x).
Proof. by case: x; case: y. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
le_ratE
| |
lt_ratEx y : lt_rat x y = (numq x * denq y < numq y * denq x).
Proof. by case: x; case: y. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
lt_ratE
| |
gt_rat0x : lt_rat 0 x = (0 < numq x).
Proof. by rewrite lt_ratE mul0r mulr1. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
gt_rat0
| |
lt_rat0x : lt_rat x 0 = (numq x < 0).
Proof. by rewrite lt_ratE mul0r mulr1. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
lt_rat0
| |
ge_rat0x : le_rat 0 x = (0 <= numq x).
Proof. by rewrite le_ratE mul0r mulr1. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
ge_rat0
| |
le_rat0x : le_rat x 0 = (numq x <= 0).
Proof. by rewrite le_ratE mul0r mulr1. Qed.
Fact le_rat0D x y : le_rat 0 x -> le_rat 0 y -> le_rat 0 (x + y).
Proof.
rewrite !ge_rat0 => hnx hny.
have hxy: (0 <= numq x * denq y + numq y * denq x).
by rewrite addr_ge0 ?mulr_ge0.
rewrite [_ + _]addq_def /numq /= -!/(denq _) ?mulf_eq0 ?denq_eq0.
rewrite val_fracq/=; case: ifP => //=.
by rewrite ?addq_subdefE !mulr_ge0// !le_gtF ?mulr_ge0 ?denq_ge0//=.
Qed.
Fact le_rat0M x y : le_rat 0 x -> le_rat 0 y -> le_rat 0 (x * y).
Proof.
rewrite !ge_rat0 => hnx hny.
have hxy: (0 <= numq x * denq y + numq y * denq x).
by rewrite addr_ge0 ?mulr_ge0.
rewrite [_ * _]mulq_def /numq /= -!/(denq _) ?mulf_eq0 ?denq_eq0.
rewrite val_fracq/=; case: ifP => //=.
by rewrite ?mulq_subdefE !mulr_ge0// !le_gtF ?mulr_ge0 ?denq_ge0//=.
Qed.
Fact le_rat0_anti x : le_rat 0 x -> le_rat x 0 -> x = 0.
Proof.
by move=> hx hy; apply/eqP; rewrite -numq_eq0 eq_le -ge_rat0 -le_rat0 hx hy.
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
le_rat0
| |
sgr_numq_div(n d : int) : sgr (numq (n%:Q / d%:Q)) = sgr n * sgr d.
Proof.
set x := (n, d); rewrite -[n]/x.1 -[d]/x.2 -fracqE.
case: fracqP => [|k fx k_neq0] /=; first by rewrite mulr0.
by rewrite !sgrM mulrACA -expr2 sqr_sg k_neq0 sgr_denq mulr1 mul1r.
Qed.
Fact subq_ge0 x y : le_rat 0 (y - x) = le_rat x y.
Proof.
symmetry; rewrite ge_rat0 !le_ratE -subr_ge0.
case: ratP => nx dx cndx; case: ratP => ny dy cndy.
rewrite -!mulNr addf_div ?intq_eq0 // !mulNr -!rmorphM -rmorphB /=.
symmetry; rewrite !leNgt -sgr_cp0 sgr_numq_div mulrC gtr0_sg //.
by rewrite mul1r sgr_cp0.
Qed.
Fact le_rat_total : total le_rat.
Proof. by move=> x y; rewrite !le_ratE; apply: le_total. Qed.
Fact numq_sign_mul (b : bool) x : numq ((-1) ^+ b * x) = (-1) ^+ b * numq x.
Proof. by case: b; rewrite ?(mul1r, mulN1r) // numqN. Qed.
Fact numq_div_lt0 n d : n != 0 -> d != 0 ->
(numq (n%:~R / d%:~R) < 0)%R = (n < 0)%R (+) (d < 0)%R.
Proof.
move=> n0 d0; rewrite -sgr_cp0 sgr_numq_div !sgr_def n0 d0.
by rewrite !mulr1n -signr_addb; case: (_ (+) _).
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
sgr_numq_div
| |
normr_num_divn d : `|numq (n%:~R / d%:~R)| = numq (`|n|%:~R / `|d|%:~R).
Proof.
rewrite (normrEsg n) (normrEsg d) !rmorphM /= invfM mulrACA !sgr_def.
have [->|n_neq0] := eqVneq; first by rewrite mul0r mulr0.
have [->|d_neq0] := eqVneq; first by rewrite invr0 !mulr0.
rewrite !intr_sign invr_sign -signr_addb numq_sign_mul -numq_div_lt0 //.
by apply: (canRL (signrMK _)); rewrite mulz_sign_abs.
Qed.
Fact norm_ratN x : normq (- x) = normq x.
Proof. by rewrite !normqE numqN denqN normrN. Qed.
Fact ge_rat0_norm x : le_rat 0 x -> normq x = x.
Proof.
rewrite ge_rat0; case: ratP=> [] // n d cnd n_ge0.
by rewrite normqE /= normr_num_div ?ger0_norm // divq_num_den.
Qed.
Fact lt_rat_def x y : (lt_rat x y) = (y != x) && (le_rat x y).
Proof. by rewrite lt_ratE le_ratE lt_def rat_eq. Qed.
HB.instance Definition _ :=
Num.IntegralDomain_isLeReal.Build rat le_rat0D le_rat0M le_rat0_anti
subq_ge0 (@le_rat_total 0) norm_ratN ge_rat0_norm lt_rat_def.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
normr_num_div
| |
numq_ge0x : (0 <= numq x) = (0 <= x).
Proof.
by case: ratP => n d cnd; rewrite ?pmulr_lge0 ?invr_gt0 (ler0z, ltr0z).
Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
numq_ge0
| |
numq_le0x : (numq x <= 0) = (x <= 0).
Proof. by rewrite -oppr_ge0 -numqN numq_ge0 oppr_ge0. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
numq_le0
| |
numq_gt0x : (0 < numq x) = (0 < x).
Proof. by rewrite !ltNge numq_le0. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
numq_gt0
| |
numq_lt0x : (numq x < 0) = (x < 0).
Proof. by rewrite !ltNge numq_ge0. Qed.
|
Lemma
|
algebra
|
[
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice",
"From mathcomp Require Import prime fintype finfun bigop order tuple ssralg",
"From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp",
"From mathcomp Require Import polydiv intdiv matrix mxalgebra vector"
] |
algebra/rat.v
|
numq_lt0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.