Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(************************************************************************)
(* * The Coq Proof Assistant / The Coq Development Team *)
(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)
(* <O___,, * (see CREDITS file for the list of authors) *)
(* \VV/ **************************************************************)
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
(* * (see LICENSE file for the text of the license) *)
(************************************************************************)
Normalisation functions for rational numbers.
Require Export QArith_base. Require Import Znumtheory. Notation Z2P := Z.to_pos (only parsing). Notation Z2P_correct := Z2Pos.id (only parsing).
Simplification of fractions using Z.gcd.
This version can compute within Coq.
Definition Qred (q:Q) := let (q1,q2) := q in let (r1,r2) := snd (Z.ggcd q1 (Zpos q2)) in r1#(Z.to_pos r2).forall q : Q, Qred q == qforall q : Q, Qred q == qn:Zd:positiveQnum (let (r1, r2) := snd (Z.ggcd n (Z.pos d)) in r1 # Z.to_pos r2) * Z.pos d = n * QDen (let (r1, r2) := snd (Z.ggcd n (Z.pos d)) in r1 # Z.to_pos r2)n:Zd:positivefst (Z.ggcd n (Z.pos d)) = Z.gcd n (Z.pos d) -> 0 <= Z.gcd n (Z.pos d) -> (let '(g, (aa, bb)) := Z.ggcd n (Z.pos d) in n = g * aa /\ Z.pos d = g * bb) -> Qnum (let (r1, r2) := snd (Z.ggcd n (Z.pos d)) in r1 # Z.to_pos r2) * Z.pos d = n * QDen (let (r1, r2) := snd (Z.ggcd n (Z.pos d)) in r1 # Z.to_pos r2)n:Zd:positiveg, nn, dd:Zg = Z.gcd n (Z.pos d) -> 0 <= Z.gcd n (Z.pos d) -> n = g * nn /\ Z.pos d = g * dd -> nn * Z.pos d = n * Z.pos (Z.to_pos dd)n:Zd:positiveg, nn, dd:Zg = Z.gcd n (Z.pos d) -> 0 <= Z.gcd n (Z.pos d) -> n = g * nn /\ Z.pos d = g * dd -> nn * Z.pos d = n * Z.pos (Z.to_pos dd)n:Zd:positiveg, nn, dd:ZHg:g = Z.gcd n (Z.pos d)LE:0 <= Z.gcd n (Z.pos d)Hn:n = g * nnHd:Z.pos d = g * ddnn * Z.pos d = n * Z.pos (Z.to_pos dd)n:Zd:positiveg, nn, dd:ZHg:g = Z.gcd n (Z.pos d)LE:0 <= Z.gcd n (Z.pos d)Hn:n = g * nnHd:Z.pos d = g * ddnn * (g * dd) = g * nn * Z.pos (Z.to_pos dd)n:Zd:positiveg, nn, dd:ZLE:0 <= gHn:n = g * nnHd:Z.pos d = g * ddnn * (g * dd) = g * nn * Z.pos (Z.to_pos dd)n:Zd:positiveg, nn, dd:ZLE:0 <= gHn:n = g * nnHd:Z.pos d = g * ddH:0 <> gnn * (g * dd) = g * nn * Z.pos (Z.to_pos dd)n:Zd:positiveg, nn, dd:ZLE:0 <= gHn:n = g * nnHd:Z.pos d = g * ddH:0 <> gnn * (g * dd) = g * nn * ddn:Zd:positiveg, nn, dd:ZLE:0 <= gHn:n = g * nnHd:Z.pos d = g * ddH:0 <> g0 < ddrewrite <- (Z.mul_pos_cancel_l g); [now rewrite <- Hd | omega]. Close Scope Z_scope. Qed.n:Zd:positiveg, nn, dd:ZLE:0 <= gHn:n = g * nnHd:Z.pos d = g * ddH:0 <> g0 < ddforall p q : Q, p == q -> Qred p = Qred qforall p q : Q, p == q -> Qred p = Qred qa:Zb:positivec:Zd:positivea # b == c # d -> Qred (a # b) = Qred (c # d)a:Zb:positivec:Zd:positive(a * Z.pos d)%Z = (c * Z.pos b)%Z -> (let (r1, r2) := snd (Z.ggcd a (Z.pos b)) in r1 # Z.to_pos r2) = (let (r1, r2) := snd (Z.ggcd c (Z.pos d)) in r1 # Z.to_pos r2)a:Zb:positivec:Zd:positivea * Z.pos d = c * Z.pos b -> (let (r1, r2) := snd (Z.ggcd a (Z.pos b)) in r1 # Z.to_pos r2) = (let (r1, r2) := snd (Z.ggcd c (Z.pos d)) in r1 # Z.to_pos r2)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos b(let (r1, r2) := snd (Z.ggcd a (Z.pos b)) in r1 # Z.to_pos r2) = (let (r1, r2) := snd (Z.ggcd c (Z.pos d)) in r1 # Z.to_pos r2)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bfst (Z.ggcd a (Z.pos b)) = Z.gcd a (Z.pos b) -> Zis_gcd a (Z.pos b) (Z.gcd a (Z.pos b)) -> 0 <= Z.gcd a (Z.pos b) -> (let '(g, (aa, bb)) := Z.ggcd a (Z.pos b) in a = g * aa /\ Z.pos b = g * bb) -> (let (r1, r2) := snd (Z.ggcd a (Z.pos b)) in r1 # Z.to_pos r2) = (let (r1, r2) := snd (Z.ggcd c (Z.pos d)) in r1 # Z.to_pos r2)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:Zfst (g, (aa, bb)) = Z.gcd a (Z.pos b) -> Zis_gcd a (Z.pos b) (Z.gcd a (Z.pos b)) -> 0 <= Z.gcd a (Z.pos b) -> a = g * aa /\ Z.pos b = g * bb -> (let (r1, r2) := snd (g, (aa, bb)) in r1 # Z.to_pos r2) = (let (r1, r2) := snd (Z.ggcd c (Z.pos d)) in r1 # Z.to_pos r2)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:Zg = Z.gcd a (Z.pos b) -> Zis_gcd a (Z.pos b) (Z.gcd a (Z.pos b)) -> 0 <= Z.gcd a (Z.pos b) -> a = g * aa /\ Z.pos b = g * bb -> aa # Z.to_pos bb = (let (r1, r2) := snd (Z.ggcd c (Z.pos d)) in r1 # Z.to_pos r2)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbaa # Z.to_pos bb = (let (r1, r2) := snd (Z.ggcd c (Z.pos d)) in r1 # Z.to_pos r2)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0aa # Z.to_pos bb = (let (r1, r2) := snd (Z.ggcd c (Z.pos d)) in r1 # Z.to_pos r2)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0fst (Z.ggcd c (Z.pos d)) = Z.gcd c (Z.pos d) -> Zis_gcd c (Z.pos d) (Z.gcd c (Z.pos d)) -> 0 <= Z.gcd c (Z.pos d) -> (let '(g0, (aa0, bb0)) := Z.ggcd c (Z.pos d) in c = g0 * aa0 /\ Z.pos d = g0 * bb0) -> aa # Z.to_pos bb = (let (r1, r2) := snd (Z.ggcd c (Z.pos d)) in r1 # Z.to_pos r2)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:Zfst (g', (cc, dd)) = Z.gcd c (Z.pos d) -> Zis_gcd c (Z.pos d) (Z.gcd c (Z.pos d)) -> 0 <= Z.gcd c (Z.pos d) -> c = g' * cc /\ Z.pos d = g' * dd -> aa # Z.to_pos bb = (let (r1, r2) := snd (g', (cc, dd)) in r1 # Z.to_pos r2)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:Zg' = Z.gcd c (Z.pos d) -> Zis_gcd c (Z.pos d) (Z.gcd c (Z.pos d)) -> 0 <= Z.gcd c (Z.pos d) -> c = g' * cc /\ Z.pos d = g' * dd -> aa # Z.to_pos bb = cc # Z.to_pos dda:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddaa # Z.to_pos bb = cc # Z.to_pos dda:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0aa # Z.to_pos bb = cc # Z.to_pos dda:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0aa = cc -> bb = dd -> aa # Z.to_pos bb = cc # Z.to_pos dda:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0rel_prime aa bba:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0rel_prime cc dda:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0bb > 0a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0dd > 0a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0aa * dd = bb * cccongruence.a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0aa = cc -> bb = dd -> aa # Z.to_pos bb = cc # Z.to_pos dda:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0rel_prime aa bba:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0(1 | aa)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0(1 | bb)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0forall x : Z, (x | aa) -> (x | bb) -> (x | 1)exists aa; auto with zarith.a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0(1 | aa)exists bb; auto with zarith.a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0(1 | bb)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0forall x : Z, (x | aa) -> (x | bb) -> (x | 1)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)(x | 1)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg11:(g | a)Hg12:(g | Z.pos b)Hg13:forall x0 : Z, (x0 | a) -> (x0 | Z.pos b) -> (x0 | g)Hg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)(x | 1)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg11:(g | a)Hg12:(g | Z.pos b)Hg13:forall x0 : Z, (x0 | a) -> (x0 | Z.pos b) -> (x0 | g)Hg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)(g * x | a)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg11:(g | a)Hg12:(g | Z.pos b)Hg13:forall x0 : Z, (x0 | a) -> (x0 | Z.pos b) -> (x0 | g)Hg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)(g * x | Z.pos b)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg11:(g | a)Hg12:(g | Z.pos b)Hg13:forall x0 : Z, (x0 | a) -> (x0 | Z.pos b) -> (x0 | g)Hg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)x':ZHx:g = x' * (g * x)(x | 1)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg11:(g | a)Hg12:(g | Z.pos b)Hg13:forall x0 : Z, (x0 | a) -> (x0 | Z.pos b) -> (x0 | g)Hg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)(g * x | a)destruct Ha as (xa,Hxa); exists xa; rewrite Hxa; ring.a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg11:(g | a)Hg12:(g | Z.pos b)Hg13:forall x0 : Z, (x0 | a) -> (x0 | Z.pos b) -> (x0 | g)Hg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)(g * x | g * aa)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg11:(g | a)Hg12:(g | Z.pos b)Hg13:forall x0 : Z, (x0 | a) -> (x0 | Z.pos b) -> (x0 | g)Hg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)(g * x | Z.pos b)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg11:(g | a)Hg12:(g | Z.pos b)Hg13:forall x0 : Z, (x0 | a) -> (x0 | Z.pos b) -> (x0 | g)Hg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)x':ZHx:g = x' * (g * x)(x | 1)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg11:(g | a)Hg12:(g | Z.pos b)Hg13:forall x0 : Z, (x0 | a) -> (x0 | Z.pos b) -> (x0 | g)Hg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)(g * x | Z.pos b)destruct Hb as (xb,Hxb); exists xb; rewrite Hxb; ring.a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg11:(g | a)Hg12:(g | Z.pos b)Hg13:forall x0 : Z, (x0 | a) -> (x0 | Z.pos b) -> (x0 | g)Hg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)(g * x | g * bb)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg11:(g | a)Hg12:(g | Z.pos b)Hg13:forall x0 : Z, (x0 | a) -> (x0 | Z.pos b) -> (x0 | g)Hg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)x':ZHx:g = x' * (g * x)(x | 1)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg11:(g | a)Hg12:(g | Z.pos b)Hg13:forall x0 : Z, (x0 | a) -> (x0 | Z.pos b) -> (x0 | g)Hg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)x':ZHx:g = x' * (g * x)1 = x' * xrewrite Hx at 1; ring.a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg11:(g | a)Hg12:(g | Z.pos b)Hg13:forall x0 : Z, (x0 | a) -> (x0 | Z.pos b) -> (x0 | g)Hg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHa:(x | aa)Hb:(x | bb)x':ZHx:g = x' * (g * x)g * 1 = g * (x' * x)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0rel_prime cc dda:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0(1 | cc)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0(1 | dd)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0forall x : Z, (x | cc) -> (x | dd) -> (x | 1)exists cc; auto with zarith.a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0(1 | cc)exists dd; auto with zarith.a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0(1 | dd)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0forall x : Z, (x | cc) -> (x | dd) -> (x | 1)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)(x | 1)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)Hg'11:(g' | c)Hg'12:(g' | Z.pos d)Hg'13:forall x0 : Z, (x0 | c) -> (x0 | Z.pos d) -> (x0 | g')(x | 1)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)Hg'11:(g' | c)Hg'12:(g' | Z.pos d)Hg'13:forall x0 : Z, (x0 | c) -> (x0 | Z.pos d) -> (x0 | g')(g' * x | c)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)Hg'11:(g' | c)Hg'12:(g' | Z.pos d)Hg'13:forall x0 : Z, (x0 | c) -> (x0 | Z.pos d) -> (x0 | g')(g' * x | Z.pos d)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)Hg'11:(g' | c)Hg'12:(g' | Z.pos d)Hg'13:forall x0 : Z, (x0 | c) -> (x0 | Z.pos d) -> (x0 | g')x':ZHx:g' = x' * (g' * x)(x | 1)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)Hg'11:(g' | c)Hg'12:(g' | Z.pos d)Hg'13:forall x0 : Z, (x0 | c) -> (x0 | Z.pos d) -> (x0 | g')(g' * x | c)destruct Hc as (xc,Hxc); exists xc; rewrite Hxc; ring.a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)Hg'11:(g' | c)Hg'12:(g' | Z.pos d)Hg'13:forall x0 : Z, (x0 | c) -> (x0 | Z.pos d) -> (x0 | g')(g' * x | g' * cc)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)Hg'11:(g' | c)Hg'12:(g' | Z.pos d)Hg'13:forall x0 : Z, (x0 | c) -> (x0 | Z.pos d) -> (x0 | g')(g' * x | Z.pos d)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)Hg'11:(g' | c)Hg'12:(g' | Z.pos d)Hg'13:forall x0 : Z, (x0 | c) -> (x0 | Z.pos d) -> (x0 | g')x':ZHx:g' = x' * (g' * x)(x | 1)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)Hg'11:(g' | c)Hg'12:(g' | Z.pos d)Hg'13:forall x0 : Z, (x0 | c) -> (x0 | Z.pos d) -> (x0 | g')(g' * x | Z.pos d)destruct Hd as (xd,Hxd); exists xd; rewrite Hxd; ring.a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)Hg'11:(g' | c)Hg'12:(g' | Z.pos d)Hg'13:forall x0 : Z, (x0 | c) -> (x0 | Z.pos d) -> (x0 | g')(g' * x | g' * dd)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)Hg'11:(g' | c)Hg'12:(g' | Z.pos d)Hg'13:forall x0 : Z, (x0 | c) -> (x0 | Z.pos d) -> (x0 | g')x':ZHx:g' = x' * (g' * x)(x | 1)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)Hg'11:(g' | c)Hg'12:(g' | Z.pos d)Hg'13:forall x0 : Z, (x0 | c) -> (x0 | Z.pos d) -> (x0 | g')x':ZHx:g' = x' * (g' * x)1 = x' * xrewrite Hx at 1; ring.a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0x:ZHc:(x | cc)Hd:(x | dd)Hg'11:(g' | c)Hg'12:(g' | Z.pos d)Hg'13:forall x0 : Z, (x0 | c) -> (x0 | Z.pos d) -> (x0 | g')x':ZHx:g' = x' * (g' * x)g' * 1 = g' * (x' * x)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0bb > 0rewrite <- (Z.mul_pos_cancel_l g); [now rewrite <- Hg4 | omega].a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 00 < bba:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0dd > 0rewrite <- (Z.mul_pos_cancel_l g'); [now rewrite <- Hg'4 | omega].a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 00 < dda:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0aa * dd = bb * cca:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0g * g' <> 0a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0g * g' * (aa * dd) = g * g' * (bb * cc)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0g * g' <> 0now destruct 1.a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0~ (g = 0 \/ g' = 0)a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0g * g' * (aa * dd) = g * g' * (bb * cc)now rewrite Z.mul_shuffle1, <- Hg'3, <- Hg4, H, Z.mul_comm. Close Scope Z_scope. Qed.a:Zb:positivec:Zd:positiveH:a * Z.pos d = c * Z.pos bg, aa, bb:ZHg1:Zis_gcd a (Z.pos b) gHg2:0 <= gHg3:a = g * aaHg4:Z.pos b = g * bbHg0:g <> 0g', cc, dd:ZHg'1:Zis_gcd c (Z.pos d) g'Hg'2:0 <= g'Hg'3:c = g' * ccHg'4:Z.pos d = g' * ddHg'0:g' <> 0a * Z.pos d = g * g' * (bb * cc)q, q':QQred q = Qred q' <-> q == q'q, q':QQred q = Qred q' <-> q == q'q, q':QQred q = Qred q' -> q == q'q, q':Qq == q' -> Qred q = Qred q'q, q':QQred q = Qred q' -> q == q'q, q':QE:Qred q = Qred q'q == q'now rewrite E.q, q':QE:Qred q = Qred q'Qred q == Qred q'apply Qred_complete. Qed.q, q':Qq == q' -> Qred q = Qred q'forall x y : Q, x == y -> Qred x == Qred yforall x y : Q, x == y -> Qred x == Qred ynow rewrite !Qred_correct. Qed. Definition Qplus' (p q : Q) := Qred (Qplus p q). Definition Qmult' (p q : Q) := Qred (Qmult p q). Definition Qminus' x y := Qred (Qminus x y).x, y:QH:x == yQred x == Qred yforall p q : Q, Qplus' p q == p + qintros; unfold Qplus'; apply Qred_correct; auto. Qed.forall p q : Q, Qplus' p q == p + qforall p q : Q, Qmult' p q == p * qintros; unfold Qmult'; apply Qred_correct; auto. Qed.forall p q : Q, Qmult' p q == p * qforall p q : Q, Qminus' p q == p - qintros; unfold Qminus'; apply Qred_correct; auto. Qed.forall p q : Q, Qminus' p q == p - qforall x y : Q, x == y -> forall x0 y0 : Q, x0 == y0 -> Qplus' x x0 == Qplus' y y0forall x y : Q, x == y -> forall x0 y0 : Q, x0 == y0 -> Qplus' x x0 == Qplus' y y0rewrite H, H0; auto with qarith. Qed.x, y:QH:x == yx0, y0:QH0:x0 == y0Qred (x + x0) == Qred (y + y0)forall x y : Q, x == y -> forall x0 y0 : Q, x0 == y0 -> Qmult' x x0 == Qmult' y y0forall x y : Q, x == y -> forall x0 y0 : Q, x0 == y0 -> Qmult' x x0 == Qmult' y y0rewrite H, H0; auto with qarith. Qed.x, y:QH:x == yx0, y0:QH0:x0 == y0Qred (x * x0) == Qred (y * y0)forall x y : Q, x == y -> forall x0 y0 : Q, x0 == y0 -> Qminus' x x0 == Qminus' y y0forall x y : Q, x == y -> forall x0 y0 : Q, x0 == y0 -> Qminus' x x0 == Qminus' y y0rewrite H, H0; auto with qarith. Qed.x, y:QH:x == yx0, y0:QH0:x0 == y0Qred (x - x0) == Qred (y - y0)forall q : Q, Qred (- q) = - Qred qforall q : Q, Qred (- q) = - Qred qx:Zy:positive(let (r1, r2) := snd (Z.ggcd (- x) (Z.pos y)) in r1 # Z.to_pos r2) = - (let (r1, r2) := snd (Z.ggcd x (Z.pos y)) in r1 # Z.to_pos r2)unfold Qopp; auto. Qed.x:Zy:positivep1, p2, p3:Z- p2 # Z.to_pos p3 = - (p2 # Z.to_pos p3)forall x y : Q, (x ?= y) = (Qred x ?= Qred y)intros x y; apply Qcompare_comp; apply Qeq_sym; apply Qred_correct. Qed.forall x y : Q, (x ?= y) = (Qred x ?= Qred y)q, q':QQred q <= Qred q' <-> q <= q'now rewrite !Qle_alt, <- Qred_compare. Qed.q, q':QQred q <= Qred q' <-> q <= q'q, q':QQred q < Qred q' <-> q < q'now rewrite !Qlt_alt, <- Qred_compare. Qed.q, q':QQred q < Qred q' <-> q < q'