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) *) (************************************************************************) Require Import Sumbool. Require Import BinInt. Require Import Zorder. Require Import Zcompare. Local Open Scope Z_scope. (* begin hide *) (* Trivial, to deprecate? *)forall r : comparison, {r = Eq} + {r = Lt} + {r = Gt}induction r; auto. Defined. (* end hide *)forall r : comparison, {r = Eq} + {r = Lt} + {r = Gt}P:Typen, m:Z((n ?= m) = Eq -> P) -> ((n ?= m) = Lt -> P) -> ((n ?= m) = Gt -> P) -> PP:Typen, m:Z((n ?= m) = Eq -> P) -> ((n ?= m) = Lt -> P) -> ((n ?= m) = Gt -> P) -> Pdestruct (n ?= m); auto. Defined.P:Typen, m:ZH1:(n ?= m) = Eq -> PH2:(n ?= m) = Lt -> PH3:(n ?= m) = Gt -> PPP:Setn, m:Z((n ?= m) = Eq -> P) -> ((n ?= m) = Lt -> P) -> ((n ?= m) = Gt -> P) -> Papply Zcompare_rect. Defined. Section decidability. Variables x y : Z.P:Setn, m:Z((n ?= m) = Eq -> P) -> ((n ?= m) = Lt -> P) -> ((n ?= m) = Gt -> P) -> P
x, y:Z{x < y} + {~ x < y}unfold Z.lt; case Z.compare; (now left) || (now right). Defined.x, y:Z{x < y} + {~ x < y}x, y:Z{x <= y} + {~ x <= y}unfold Z.le; case Z.compare; (now left) || (right; tauto). Defined.x, y:Z{x <= y} + {~ x <= y}x, y:Z{x > y} + {~ x > y}unfold Z.gt; case Z.compare; (now left) || (now right). Defined.x, y:Z{x > y} + {~ x > y}x, y:Z{x >= y} + {~ x >= y}unfold Z.ge; case Z.compare; (now left) || (right; tauto). Defined.x, y:Z{x >= y} + {~ x >= y}x, y:Z{x < y} + {x >= y}exact Z_lt_dec. Defined.x, y:Z{x < y} + {x >= y}x, y:Z{x < y} + {y <= x}x, y:Z{x < y} + {y <= x}x, y:Zx < y -> {x < y} + {y <= x}x, y:Zx >= y -> {x < y} + {y <= x}now left.x, y:Zx < y -> {x < y} + {y <= x}right; now apply Z.ge_le. Defined.x, y:Zx >= y -> {x < y} + {y <= x}x, y:Z{x <= y} + {x > y}x, y:Z{x <= y} + {x > y}x, y:Z~ x <= y -> {x <= y} + {x > y}x, y:Zb:~ x <= y{x <= y} + {x > y}x, y:Zb:~ x <= yx > ynow apply Z.nle_gt. Defined.x, y:Zb:~ x <= yy < xx, y:Z{x > y} + {x <= y}exact Z_gt_dec. Defined.x, y:Z{x > y} + {x <= y}x, y:Z{x >= y} + {x < y}x, y:Z{x >= y} + {x < y}x, y:Z~ x >= y -> {x >= y} + {x < y}x, y:Zb:~ x >= y{x >= y} + {x < y}x, y:Zb:~ x >= yx < ynow apply Z.lt_nge. Defined.x, y:Zb:~ y <= xx < yx, y:Zx <= y -> {x < y} + {x = y}x, y:Zx <= y -> {x < y} + {x = y}x, y:ZH:x <= y{x < y} + {x = y}x, y:ZH:x <= y(x ?= y) = Eq -> {x < y} + {x = y}x, y:ZH:x <= y(x ?= y) = Lt -> {x < y} + {x = y}x, y:ZH:x <= y(x ?= y) = Gt -> {x < y} + {x = y}x, y:ZH:x <= yH0:(x ?= y) = Eq{x < y} + {x = y}x, y:ZH:x <= y(x ?= y) = Lt -> {x < y} + {x = y}x, y:ZH:x <= y(x ?= y) = Gt -> {x < y} + {x = y}x, y:ZH:x <= yH0:(x ?= y) = Eqx = yx, y:ZH:x <= y(x ?= y) = Lt -> {x < y} + {x = y}x, y:ZH:x <= y(x ?= y) = Gt -> {x < y} + {x = y}x, y:ZH:x <= y(x ?= y) = Lt -> {x < y} + {x = y}x, y:ZH:x <= y(x ?= y) = Gt -> {x < y} + {x = y}x, y:ZH:x <= yH0:(x ?= y) = Lt{x < y} + {x = y}x, y:ZH:x <= y(x ?= y) = Gt -> {x < y} + {x = y}x, y:ZH:x <= yH0:(x ?= y) = Ltx < yx, y:ZH:x <= y(x ?= y) = Gt -> {x < y} + {x = y}x, y:ZH:x <= y(x ?= y) = Gt -> {x < y} + {x = y}absurd (x > y); auto with arith. Defined. End decidability.x, y:ZH:x <= yH1:(x ?= y) = Gt{x < y} + {x = y}
forall n m : Z, n < m -> forall p : Z, {n < p} + {p < m}forall n m : Z, n < m -> forall p : Z, {n < p} + {p < m}x, y:ZH:x < yz:Z{x < z} + {z < y}x, y:ZH:x < yz:Zx < z -> {x < z} + {z < y}x, y:ZH:x < yz:Zx >= z -> {x < z} + {z < y}x, y:ZH:x < yz:Zl:x < z{x < z} + {z < y}x, y:ZH:x < yz:Zx >= z -> {x < z} + {z < y}x, y:ZH:x < yz:Zl:x < zx < zx, y:ZH:x < yz:Zx >= z -> {x < z} + {z < y}x, y:ZH:x < yz:Zx >= z -> {x < z} + {z < y}x, y:ZH:x < yz:Zg:x >= z{x < z} + {z < y}x, y:ZH:x < yz:Zg:x >= zz < yx, y:ZH:x < yz:Zg:x >= zz <= xx, y:ZH:x < yz:Zg:x >= zx < yx, y:ZH:x < yz:Zg:x >= zx >= zx, y:ZH:x < yz:Zg:x >= zx < yassumption. Defined.x, y:ZH:x < yz:Zg:x >= zx < yforall n m : Z, 0 < n + m -> {0 < n} + {0 < m}forall n m : Z, 0 < n + m -> {0 < n} + {0 < m}x, y:ZH:0 < x + y{0 < x} + {0 < y}x, y:ZH:0 < x + y0 < x -> {0 < x} + {0 < y}x, y:ZH:0 < x + yx < x + y -> {0 < x} + {0 < y}now left.x, y:ZH:0 < x + y0 < x -> {0 < x} + {0 < y}x, y:ZH:0 < x + yx < x + y -> {0 < x} + {0 < y}x, y:ZH:0 < x + yl:x < x + y0 < ynow rewrite Z.add_0_r. Defined.x, y:ZH:0 < x + yl:x < x + yx + 0 < x + yforall n m : Z, n + m < 0 -> {n < 0} + {m < 0}intros x y H; case (Zlt_cotrans (x + y) 0 H x); intro Hxy; [ right; apply Z.add_lt_mono_l with (p := x); rewrite Z.add_0_r | left ]; assumption. Defined.forall n m : Z, n + m < 0 -> {n < 0} + {m < 0}forall n m : Z, n <> m -> {n < m} + {m < n}forall n m : Z, n <> m -> {n < m} + {m < n}x, y:ZH:x <> y{x < y} + {y < x}x, y:ZH:x <> yx < y -> {x < y} + {y < x}x, y:ZH:x <> yx >= y -> {x < y} + {y < x}x, y:ZH:x <> yl:x < y{x < y} + {y < x}x, y:ZH:x <> yx >= y -> {x < y} + {y < x}x, y:ZH:x <> yl:x < yx < yx, y:ZH:x <> yx >= y -> {x < y} + {y < x}x, y:ZH:x <> yx >= y -> {x < y} + {y < x}x, y:ZH:x <> yH0:x >= y{x < y} + {y < x}x, y:ZH:x <> yH0:x >= yy <= x -> {x < y} + {y < x}x, y:ZH:x <> yH0:x >= yH1:y <= x{x < y} + {y < x}x, y:ZH:x <> yH0:x >= yH1:y <= xy < x -> {x < y} + {y < x}x, y:ZH:x <> yH0:x >= yH1:y <= xy = x -> {x < y} + {y < x}x, y:ZH:x <> yH0:x >= yH1:y <= xl:y < x{x < y} + {y < x}x, y:ZH:x <> yH0:x >= yH1:y <= xy = x -> {x < y} + {y < x}x, y:ZH:x <> yH0:x >= yH1:y <= xl:y < xy < xx, y:ZH:x <> yH0:x >= yH1:y <= xy = x -> {x < y} + {y < x}x, y:ZH:x <> yH0:x >= yH1:y <= xy = x -> {x < y} + {y < x}x, y:ZH:x <> yH0:x >= yH1:y <= xe:y = x{x < y} + {y < x}x, y:ZH:x <> yH0:x >= yH1:y <= xe:y = xFalsex, y:ZH:x <> yH0:x >= yH1:y <= xe:y = xx = yassumption. Defined.x, y:ZH:x <> yH0:x >= yH1:y <= xe:y = xy = xforall n m : Z, {n < m} + {n > m} + {n = m}forall n m : Z, {n < m} + {n > m} + {n = m}x, y:Z{x < y} + {x > y} + {x = y}x, y:Zx < y -> {x < y} + {x > y} + {x = y}x, y:Zx >= y -> {x < y} + {x > y} + {x = y}x, y:ZH:x < y{x < y} + {x > y} + {x = y}x, y:Zx >= y -> {x < y} + {x > y} + {x = y}x, y:ZH:x < y{x < y} + {x > y}x, y:Zx >= y -> {x < y} + {x > y} + {x = y}x, y:ZH:x < yx < yx, y:Zx >= y -> {x < y} + {x > y} + {x = y}x, y:Zx >= y -> {x < y} + {x > y} + {x = y}x, y:ZH:x >= y{x < y} + {x > y} + {x = y}x, y:ZH:x >= yy <= x -> {x < y} + {x > y} + {x = y}x, y:ZH:x >= yH0:y <= x{x < y} + {x > y} + {x = y}x, y:ZH:x >= yH0:y <= xy < x -> {x < y} + {x > y} + {x = y}x, y:ZH:x >= yH0:y <= xy = x -> {x < y} + {x > y} + {x = y}x, y:ZH:x >= yH0:y <= xH1:y < x{x < y} + {x > y} + {x = y}x, y:ZH:x >= yH0:y <= xy = x -> {x < y} + {x > y} + {x = y}x, y:ZH:x >= yH0:y <= xH1:y < x{x < y} + {x > y}x, y:ZH:x >= yH0:y <= xy = x -> {x < y} + {x > y} + {x = y}x, y:ZH:x >= yH0:y <= xH1:y < xx > yx, y:ZH:x >= yH0:y <= xy = x -> {x < y} + {x > y} + {x = y}x, y:ZH:x >= yH0:y <= xH1:y < xy < xx, y:ZH:x >= yH0:y <= xy = x -> {x < y} + {x > y} + {x = y}x, y:ZH:x >= yH0:y <= xy = x -> {x < y} + {x > y} + {x = y}x, y:ZH:x >= yH0:y <= xe:y = x{x < y} + {x > y} + {x = y}x, y:ZH:x >= yH0:y <= xe:y = xx = yassumption. Defined.x, y:ZH:x >= yH0:y <= xe:y = xy = xforall n m : Z, {n < m} + {m < n} + {n = m}forall n m : Z, {n < m} + {m < n} + {n = m}case (Z.eq_dec x y); intro H; [ right; assumption | left; apply (not_Zeq_inf _ _ H) ]. Defined. (* begin hide *) (* To deprecate ? *)x, y:Z{x < y} + {y < x} + {x = y}forall x : Z, {x = 0} + {x <> 0}exact (fun x:Z => Z.eq_dec x 0). Defined.forall x : Z, {x = 0} + {x <> 0}Proof (fun x => sumbool_not _ _ (Z_zerop x)).forall x : Z, {x <> 0} + {x = 0}Proof (fun x y => sumbool_not _ _ (Z.eq_dec x y)). (* end hide *)forall x y : Z, {x <> y} + {x = y}