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) *)
(************************************************************************)
Contributed by Cédric Auger
Require Import Qabs Qcanon.x:QQred (Qabs x) = Qabs (Qred x)destruct x as [[|a|a] d]; simpl; auto; destruct (Pos.ggcd a d) as [x [y z]]; simpl; auto. Qed.x:QQred (Qabs x) = Qabs (Qred x)x:QQred x = x -> Qred (Qabs x) = Qabs xintros H; now rewrite (Qred_abs x), H. Qed. Definition Qcabs (x:Qc) : Qc := {| canon := Qcabs_canon x (canon x) |}. Notation "[ q ]" := (Qcabs q) : Qc_scope. Ltac Qc_unfolds := unfold Qcabs, Qcminus, Qcopp, Qcplus, Qcmult, Qcle, Q2Qc, this.x:QQred x = x -> Qred (Qabs x) = Qabs xx:QcP:Qc -> Type(0 <= x -> P x) -> (x <= 0 -> P (- x)) -> P [x]x:QcP:Qc -> Type(0 <= x -> P x) -> (x <= 0 -> P (- x)) -> P [x]x:QcP:Qc -> TypeA:0 <= x -> P xB:x <= 0 -> P (- x)P [x]x:QcP:Qc -> TypeA:0 <= x -> P xB:x <= 0 -> P (- x)(0 <= x)%Q -> forall Hx : Qred x = x, P {| this := x; canon := Hx |}x:QcP:Qc -> TypeA:0 <= x -> P xB:x <= 0 -> P (- x)(x <= 0)%Q -> forall Hx : Qred (- x) = (- x)%Q, P {| this := - x; canon := Hx |}intros; case (Qc_decomp (-x) {|canon:=Hx|}); auto. Qed.x:QcP:Qc -> TypeA:0 <= x -> P xB:x <= 0 -> P (- x)(x <= 0)%Q -> forall Hx : Qred (- x) = (- x)%Q, P {| this := - x; canon := Hx |}x:Qc0 <= x -> [x] = xx:Qc0 <= x -> [x] = xx:QcHx:0 <= xQabs x = xx:QcHx:0 <= xQred (Qabs x) = xnow apply Qabs_pos. Qed.x:QcHx:0 <= xQabs x == xx:Qcx <= 0 -> [x] = - xx:Qcx <= 0 -> [x] = - xx:QcHx:x <= 0Qabs x = Qred (- x)now apply Qred_complete; apply Qabs_neg. Qed.x:QcHx:x <= 0Qred (Qabs x) = Qred (- x)x:Qc0 <= [x]intros; apply Qabs_nonneg. Qed.x:Qc0 <= [x]x:Qc[- x] = [x]x:Qc[- x] = [x]x:QcQabs (Qred (- x)) = Qabs xcase Qred_abs; apply Qred_complete; apply Qabs_opp. Qed.x:QcQabs (Qred (- x)) = Qred (Qabs x)x, y:Qc[x + y] <= [x] + [y]Qc_unfolds; case Qred_abs; rewrite !Qred_le; apply Qabs_triangle. Qed.x, y:Qc[x + y] <= [x] + [y]x, y:Qc[x * y] = [x] * [y]x, y:Qc[x * y] = [x] * [y]apply Qred_complete; apply Qabs_Qmult. Qed.x, y:QcQred (Qabs (x * y)) = Qred (Qabs x * Qabs y)x, y:Qc[x - y] = [y - x]x, y:Qc[x - y] = [y - x]x, y:QcQabs (Qred (x + Qred (- y))) = Qabs (Qred (y + Qred (- x)))x, y:QcQabs (Qred (Qred x + Qred (- y))) = Qabs (Qred (y + Qred (- x)))x, y:QcQabs (Qred (Qred x + Qred (- y))) = Qabs (Qred (Qred y + Qred (- x)))repeat case Qred_abs; f_equal; apply Qabs_Qminus. Qed.x, y:QcQabs (Qred (Qred x - Qred y)) = Qabs (Qred (Qred y - Qred x))x:Qcx <= [x]apply Qle_Qabs. Qed.x:Qcx <= [x]x, y:Qc[x] - [y] <= [x - y]x, y:Qc[x] - [y] <= [x - y]x, y:Qc(Qred (Qabs x + Qred (- Qabs y)) <= Qabs (Qred (x + Qred (- y))))%Qapply Qabs_triangle_reverse. Qed.x, y:Qc(Qabs x + - Qabs (Qred y) <= Qabs (x + - Qred y))%Qx, y:Qc[x] <= y <-> - y <= x <= yx, y:Qc[x] <= y <-> - y <= x <= yx, y:Qc(Qabs x <= y)%Q <-> (Qred (- y) <= x <= y)%Qx, y:QcA:(Qabs x <= y)%Q -> (- y <= x <= y)%QB:(- y <= x <= y)%Q -> (Qabs x <= y)%Q(Qabs x <= y)%Q <-> (Qred (- y) <= x <= y)%Qx, y:QcA:(Qabs x <= y)%Q -> (- y <= x <= y)%QB:(- y <= x <= y)%Q -> (Qabs x <= y)%QH:(Qabs x <= y)%Q(Qred (- y) <= x <= y)%Qx, y:QcA:(Qabs x <= y)%Q -> (- y <= x <= y)%QB:(- y <= x <= y)%Q -> (Qabs x <= y)%QH:(Qred (- y) <= x <= y)%Q(Qabs x <= y)%Qx, y:QcA:(Qabs x <= y)%Q -> (- y <= x <= y)%QB:(- y <= x <= y)%Q -> (Qabs x <= y)%QH:(Qabs x <= y)%Q(Qred (- y) <= x <= y)%Qnow case (canon x); apply Qred_le.x, y:QcA:(Qabs x <= y)%Q -> (- y <= x <= y)%QB:(- y <= x <= y)%Q -> (Qabs x <= y)%QH:(Qabs x <= y)%QX:(- y <= x)%QY:(x <= y)%Q(Qred (- y) <= x)%Qx, y:QcA:(Qabs x <= y)%Q -> (- y <= x <= y)%QB:(- y <= x <= y)%Q -> (Qabs x <= y)%QH:(Qred (- y) <= x <= y)%Q(Qabs x <= y)%Qnow case (canon y); case Qred_opp. Qed.x, y:QcA:(Qabs x <= y)%Q -> (- y <= x <= y)%QB:(- y <= x <= y)%Q -> (Qabs x <= y)%QX:(Qred (- y) <= x)%QY:(x <= y)%Q(- y <= x)%Qx, y, r:Qc[x - y] <= r <-> x - r <= y <= x + rx, y, r:Qc[x - y] <= r <-> x - r <= y <= x + rx, y, r:Qc(Qabs (Qred (x + Qred (- y))) <= r)%Q <-> (Qred (x + Qred (- r)) <= y <= Qred (x + r))%Qx, y, r:Qc(Qred (Qabs (x + - Qred y)) <= r)%Q <-> (Qred (x + - Qred r) <= y <= Qred (x + r))%Qx, y, r:Qc(Qred (Qabs (x + - Qred y)) <= r)%Q <-> (Qred (x + - Qred r) <= Qred y <= Qred (x + r))%Qx, y, r:Qc(Qred (Qabs (x + - Qred y)) <= Qred r)%Q <-> (Qred (x + - Qred r) <= Qred y <= Qred (x + Qred r))%Qx, y, r:Qc(Qred (Qabs (x + - Qred y)) <= Qred (Qred r))%Q <-> (Qred (x + - Qred r) <= Qred y <= Qred (x + Qred r))%Qx, y, r:Qc(Qred (Qabs (x + - Qred y)) <= Qred (Qred r))%Q <-> (Qred (x + - Qred r) <= Qred (Qred y) <= Qred (x + Qred r))%Qx, y, r:Qc(Qred (Qabs (x - Qred y)) <= Qred (Qred r))%Q <-> (Qred (x - Qred r) <= Qred (Qred y) <= Qred (x + Qred r))%Qx, y, r:QcA:(Qabs (x - Qred y) <= Qred r)%Q -> (x - Qred r <= Qred y <= x + Qred r)%QB:(x - Qred r <= Qred y <= x + Qred r)%Q -> (Qabs (x - Qred y) <= Qred r)%Q(Qred (Qabs (x - Qred y)) <= Qred (Qred r))%Q <-> (Qred (x - Qred r) <= Qred (Qred y) <= Qred (x + Qred r))%Qx, y, r:QcA:(Qabs (x - Qred y) <= Qred r)%Q -> (x - Qred r <= Qred y <= x + Qred r)%QB:(x - Qred r <= Qred y <= x + Qred r)%Q -> (Qabs (x - Qred y) <= Qred r)%Q(Qred (Qabs (x - Qred y)) <= Qred (Qred r))%Q -> (Qred (x - Qred r) <= Qred (Qred y) <= Qred (x + Qred r))%Qx, y, r:QcA:(Qabs (x - Qred y) <= Qred r)%Q -> (x - Qred r <= Qred y <= x + Qred r)%QB:(x - Qred r <= Qred y <= x + Qred r)%Q -> (Qabs (x - Qred y) <= Qred r)%Q(Qred (x - Qred r) <= Qred (Qred y) <= Qred (x + Qred r))%Q -> (Qred (Qabs (x - Qred y)) <= Qred (Qred r))%Qx, y, r:QcA:(Qabs (x - Qred y) <= Qred r)%Q -> (x - Qred r <= Qred y <= x + Qred r)%QB:(x - Qred r <= Qred y <= x + Qred r)%Q -> (Qabs (x - Qred y) <= Qred r)%Q(Qred (Qabs (x - Qred y)) <= Qred (Qred r))%Q -> (Qred (x - Qred r) <= Qred (Qred y) <= Qred (x + Qred r))%Qauto.x, y, r:QcA:(Qabs (x - Qred y) <= Qred r)%Q -> (x - Qred r <= Qred y <= x + Qred r)%Q(Qabs (x - Qred y) <= Qred r)%Q -> (x - Qred r <= Qred y <= x + Qred r)%Qx, y, r:QcA:(Qabs (x - Qred y) <= Qred r)%Q -> (x - Qred r <= Qred y <= x + Qred r)%QB:(x - Qred r <= Qred y <= x + Qred r)%Q -> (Qabs (x - Qred y) <= Qred r)%Q(Qred (x - Qred r) <= Qred (Qred y) <= Qred (x + Qred r))%Q -> (Qred (Qabs (x - Qred y)) <= Qred (Qred r))%Qauto. Qed.x, y, r:QcB:(x - Qred r <= Qred y <= x + Qred r)%Q -> (Qabs (x - Qred y) <= Qred r)%Q(x - Qred r <= Qred y <= x + Qred r)%Q -> (Qabs (x - Qred y) <= Qred r)%Qx:Qc[x] = 0 -> x = 0x:Qc[x] = 0 -> x = 0x:QcH:[x] = 0x = 0x:QcH:[x] = 0[x] <= 0x:QcH:[x] = 0A:- 0 <= xB:x <= 0x = 0rewrite H; apply Qcle_refl.x:QcH:[x] = 0[x] <= 0apply Qcle_antisym; auto. Qed.x:QcH:[x] = 0A:- 0 <= xB:x <= 0x = 0