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) *)
(************************************************************************)
Properties of abs and sgn
Require Import ZMulOrder.
Since we already have max, we could have defined abs.
Module GenericAbs (Import Z : ZAxiomsMiniSig') (Import ZP : ZMulOrderProp Z) <: HasAbs Z. Definition abs n := max n (-n).forall n : t, 0 <= n -> abs n == nforall n : t, 0 <= n -> abs n == nn:tH:0 <= nabs n == nn:tH:0 <= nmax n (- n) == nn:tH:0 <= n- n <= nrewrite opp_nonpos_nonneg; auto. Qed.n:tH:0 <= n- n <= 0forall n : t, n <= 0 -> abs n == - nforall n : t, n <= 0 -> abs n == - nn:tH:n <= 0abs n == - nn:tH:n <= 0max n (- n) == - nn:tH:n <= 0n <= - nrewrite opp_nonneg_nonpos; auto. Qed. End GenericAbs.n:tH:n <= 00 <= - n
We can deduce a sgn function from a compare function
Module Type ZDecAxiomsSig := ZAxiomsMiniSig <+ HasCompare. Module Type ZDecAxiomsSig' := ZAxiomsMiniSig' <+ HasCompare. Module Type GenericSgn (Import Z : ZDecAxiomsSig') (Import ZP : ZMulOrderProp Z) <: HasSgn Z. Definition sgn n := match compare 0 n with Eq => 0 | Lt => 1 | Gt => -1 end.forall n : t, n == 0 -> sgn n == 0forall n : t, n == 0 -> sgn n == 0destruct (compare_spec 0 n); order. Qed.n:tH:n == 0match compare 0 n with | Eq => 0 | Lt => 1 | Gt => -1 end == 0forall n : t, 0 < n -> sgn n == 1forall n : t, 0 < n -> sgn n == 1destruct (compare_spec 0 n); order. Qed.n:tH:0 < nmatch compare 0 n with | Eq => 0 | Lt => 1 | Gt => -1 end == 1forall n : t, n < 0 -> sgn n == -1forall n : t, n < 0 -> sgn n == -1destruct (compare_spec 0 n); order. Qed. End GenericSgn.n:tH:n < 0match compare 0 n with | Eq => 0 | Lt => 1 | Gt => -1 end == -1
Derived properties of abs and sgn
Module Type ZSgnAbsProp (Import Z : ZAxiomsSig') (Import ZP : ZMulOrderProp Z). Ltac destruct_max n := destruct (le_ge_cases 0 n); [rewrite (abs_eq n) by auto | rewrite (abs_neq n) by auto].Proper (eq ==> eq) absProper (eq ==> eq) absx, y:tEQ:x == yabs x == abs yx, y:tEQ:x == yH:0 <= xx == abs yx, y:tEQ:x == yH:x <= 0- x == abs yx, y:tEQ:x == yH:0 <= x0 <= yx, y:tEQ:x == yH:x <= 0- x == abs yx, y:tEQ:x == yH:x <= 0- x == abs ynow rewrite opp_inj_wd. Qed.x, y:tEQ:x == yH:x <= 0- x == - yforall n : t, abs n == max n (- n)forall n : t, abs n == max n (- n)n:tabs n == max n (- n)n:tH:0 <= nn == max n (- n)n:tH:n <= 0- n == max n (- n)n:tH:0 <= n- n <= nn:tH:n <= 0- n == max n (- n)n:tH:0 <= n- n <= 0n:tH:n <= 0- n == max n (- n)n:tH:n <= 0- n == max n (- n)n:tH:n <= 0n <= - nrewrite opp_nonneg_nonpos; auto. Qed.n:tH:n <= 00 <= - nforall n : t, 0 <= - n -> abs n == - nforall n : t, 0 <= - n -> abs n == - nn:tH:0 <= - nabs n == - nnow rewrite <- opp_nonneg_nonpos. Qed.n:tH:0 <= - nn <= 0forall n : t, 0 <= abs nforall n : t, 0 <= abs nn:t0 <= abs nnow rewrite opp_nonneg_nonpos. Qed.n:tH:n <= 00 <= - nforall n : t, abs n == n <-> 0 <= nforall n : t, abs n == n <-> 0 <= nn:tabs n == n -> 0 <= nn:tEQ:abs n == n0 <= napply abs_nonneg. Qed.n:tEQ:abs n == n0 <= abs nforall n : t, abs n == - n <-> n <= 0forall n : t, abs n == - n <-> n <= 0n:tabs n == - n -> n <= 0n:tEQ:abs n == - nn <= 0apply abs_nonneg. Qed.n:tEQ:abs n == - n0 <= abs nforall n : t, abs (- n) == abs nforall n : t, abs (- n) == abs nn:tabs (- n) == abs nn:tH:0 <= nabs (- n) == nn:tH:n <= 0abs (- n) == - nn:tH:0 <= nn == nn:tH:0 <= n- n <= 0n:tH:n <= 0abs (- n) == - nn:tH:0 <= n- n <= 0n:tH:n <= 0abs (- n) == - nn:tH:n <= 0abs (- n) == - nn:tH:n <= 0- n == - nn:tH:n <= 00 <= - nnow rewrite opp_nonneg_nonpos. Qed.n:tH:n <= 00 <= - nabs 0 == 0abs 0 == 0apply le_refl. Qed.0 <= 0forall n : t, abs n == 0 <-> n == 0forall n : t, abs n == 0 <-> n == 0n:tabs n == 0 -> n == 0n:tn == 0 -> abs n == 0n:tH:n <= 0- n == 0 -> n == 0n:tn == 0 -> abs n == 0n:tn == 0 -> abs n == 0rewrite abs_eq; auto using eq_refl, le_refl. Qed.n:tEQ:n == 0abs 0 == 0forall n : t, 0 < abs n <-> n ~= 0forall n : t, 0 < abs n <-> n ~= 0n:t0 < abs n <-> n ~= 0n:t0 < abs n <-> abs n ~= 0n:tLT:0 < abs nabs n ~= 0n:tNEQ:abs n ~= 00 < abs nn:tLT:0 < abs nEQ:abs n == 0Falsen:tNEQ:abs n ~= 00 < abs nn:tLT:0 < 0EQ:abs n == 0Falsen:tNEQ:abs n ~= 00 < abs nn:tNEQ:abs n ~= 00 < abs nn:tNEQ:abs n ~= 0LE:0 <= abs n0 < abs nelim NEQ; auto with relations. Qed.n:tNEQ:abs n ~= 0H:0 == abs n0 < abs nforall n : t, abs n == n \/ abs n == - nforall n : t, abs n == n \/ abs n == - ndestruct_max n; auto with relations. Qed.n:tabs n == n \/ abs n == - nforall n : t, n == abs n \/ n == - abs nforall n : t, n == abs n \/ n == - abs ndestruct_max n; rewrite ? opp_involutive; auto with relations. Qed.n:tn == abs n \/ n == - abs nforall n : t, abs (abs n) == abs nforall n : t, abs (abs n) == abs nn:tabs (abs n) == abs napply abs_nonneg. Qed.n:t0 <= abs nforall n : t, 0 <= n /\ abs n == n \/ n < 0 /\ abs n == - nforall n : t, 0 <= n /\ abs n == n \/ n < 0 /\ abs n == - nn:t0 <= n /\ abs n == n \/ n < 0 /\ abs n == - nn:tH:0 <= n0 <= n /\ abs n == n \/ n < 0 /\ abs n == - nn:tH:n < 00 <= n /\ abs n == n \/ n < 0 /\ abs n == - nn:tH:0 <= nabs n == nn:tH:n < 00 <= n /\ abs n == n \/ n < 0 /\ abs n == - nn:tH:n < 00 <= n /\ abs n == n \/ n < 0 /\ abs n == - nn:tH:n < 0abs n == - nnow apply lt_le_incl. Qed.n:tH:n < 0n <= 0forall (P : t -> Prop) (n : t), Proper (eq ==> iff) P -> (0 <= n -> P n) -> (n <= 0 -> P (- n)) -> P (abs n)forall (P : t -> Prop) (n : t), Proper (eq ==> iff) P -> (0 <= n -> P n) -> (n <= 0 -> P (- n)) -> P (abs n)destruct_max n; auto. Qed.P:t -> Propn:tH:Proper (eq ==> iff) PH0:0 <= n -> P nH1:n <= 0 -> P (- n)P (abs n)forall (P : t -> Prop) (n : t), Proper (eq ==> iff) P -> P n -> P (- n) -> P (abs n)forall (P : t -> Prop) (n : t), Proper (eq ==> iff) P -> P n -> P (- n) -> P (abs n)now apply abs_case_strong. Qed.P:t -> Propn:tH:Proper (eq ==> iff) PH0:P nH1:P (- n)P (abs n)forall n m : t, abs n == abs m -> n == m \/ n == - mforall n m : t, abs n == abs m -> n == m \/ n == - mn, m:tEQ:abs n == abs mn == m \/ n == - mn, m:tEQ:abs n == abs mEQn:n == abs nn == m \/ n == - mn, m:tEQ:abs n == abs mEQn:n == - abs nn == m \/ n == - mn, m:tEQ:abs n == abs mEQn:n == abs nabs m == m \/ abs m == - mn, m:tEQ:abs n == abs mEQn:n == - abs nn == m \/ n == - mn, m:tEQ:abs n == abs mEQn:n == - abs nn == m \/ n == - mapply abs_eq_or_opp. Qed.n, m:tEQ:abs n == abs mEQn:n == - abs nabs m == m \/ abs m == - mforall a b : t, abs a < b <-> - b < a < bforall a b : t, abs a < b <-> - b < a < ba, b:tabs a < b <-> - b < a < ba, b:tLE:0 <= aa < b <-> - b < a < ba, b:tLT:a < 0- a < b <-> - b < a < ba, b:tLE:0 <= aH:a < b- b < aa, b:tLT:a < 0- a < b <-> - b < a < ba, b:tLE:0 <= aH:a < b- b < 0a, b:tLT:a < 0- a < b <-> - b < a < ba, b:tLT:a < 0- a < b <-> - b < a < ba, b:tLT:a < 0- b < a <-> - b < a < ba, b:tLT:a < 0H:- b < aa < bapply opp_nonpos_nonneg; order. Qed.a, b:tLT:a < 0H:- b < a0 <= bforall a b : t, abs a <= b <-> - b <= a <= bforall a b : t, abs a <= b <-> - b <= a <= ba, b:tabs a <= b <-> - b <= a <= ba, b:tLE:0 <= aa <= b <-> - b <= a <= ba, b:tLT:a < 0- a <= b <-> - b <= a <= ba, b:tLE:0 <= aH:a <= b- b <= aa, b:tLT:a < 0- a <= b <-> - b <= a <= ba, b:tLE:0 <= aH:a <= b- b <= 0a, b:tLT:a < 0- a <= b <-> - b <= a <= ba, b:tLT:a < 0- a <= b <-> - b <= a <= ba, b:tLT:a < 0- b <= a <-> - b <= a <= ba, b:tLT:a < 0H:- b <= aa <= ba, b:tLT:a < 0H:- b <= aa <= 0a, b:tLT:a < 0H:- b <= a0 <= bapply opp_nonpos_nonneg; order. Qed.a, b:tLT:a < 0H:- b <= a0 <= b
Triangular inequality
forall n m : t, abs (n + m) <= abs n + abs mforall n m : t, abs (n + m) <= abs n + abs mn, m:tabs (n + m) <= abs n + abs mn, m:tH:0 <= nH0:0 <= mabs (n + m) <= n + mn, m:tH:0 <= nH0:m <= 0abs (n + m) <= n + - mn, m:tH:n <= 0H0:0 <= mabs (n + m) <= - n + mn, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:0 <= nH0:0 <= mn + m <= n + mn, m:tH:0 <= nH0:0 <= m0 <= n + mn, m:tH:0 <= nH0:m <= 0abs (n + m) <= n + - mn, m:tH:n <= 0H0:0 <= mabs (n + m) <= - n + mn, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:0 <= nH0:0 <= m0 <= n + mn, m:tH:0 <= nH0:m <= 0abs (n + m) <= n + - mn, m:tH:n <= 0H0:0 <= mabs (n + m) <= - n + mn, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:0 <= nH0:m <= 0abs (n + m) <= n + - mn, m:tH:n <= 0H0:0 <= mabs (n + m) <= - n + mn, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:0 <= nH0:m <= 0H1:0 <= n + mm <= - mn, m:tH:0 <= nH0:m <= 0H1:n + m <= 0- n <= nn, m:tH:n <= 0H0:0 <= mabs (n + m) <= - n + mn, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:0 <= nH0:m <= 0H1:0 <= n + m0 <= - mn, m:tH:0 <= nH0:m <= 0H1:n + m <= 0- n <= nn, m:tH:n <= 0H0:0 <= mabs (n + m) <= - n + mn, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:0 <= nH0:m <= 0H1:n + m <= 0- n <= nn, m:tH:n <= 0H0:0 <= mabs (n + m) <= - n + mn, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:0 <= nH0:m <= 0H1:n + m <= 0- n <= 0n, m:tH:n <= 0H0:0 <= mabs (n + m) <= - n + mn, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:n <= 0H0:0 <= mabs (n + m) <= - n + mn, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:n <= 0H0:0 <= mH1:0 <= n + mn <= - nn, m:tH:n <= 0H0:0 <= mH1:n + m <= 0- m <= mn, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:n <= 0H0:0 <= mH1:0 <= n + m0 <= - nn, m:tH:n <= 0H0:0 <= mH1:n + m <= 0- m <= mn, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:n <= 0H0:0 <= mH1:n + m <= 0- m <= mn, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:n <= 0H0:0 <= mH1:n + m <= 0- m <= 0n, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:n <= 0H0:m <= 0abs (n + m) <= - n + - mn, m:tH:n <= 0H0:m <= 0- n + - m <= - n + - mn, m:tH:n <= 0H0:m <= 0n + m <= 0now apply add_nonpos_nonpos. Qed.n, m:tH:n <= 0H0:m <= 0n + m <= 0forall n m : t, abs n - abs m <= abs (n - m)forall n m : t, abs n - abs m <= abs (n - m)n, m:tabs n - abs m <= abs (n - m)n, m:tabs n <= abs (n - m) + abs mapply abs_triangle. Qed.n, m:tabs (n - m + m) <= abs (n - m) + abs m
Absolute value and multiplication
forall n m : t, abs (n * m) == abs n * abs mforall n m : t, abs (n * m) == abs n * abs mforall n m : t, 0 <= n -> abs (n * m) == n * abs mH:forall n m : t, 0 <= n -> abs (n * m) == n * abs mforall n m : t, abs (n * m) == abs n * abs mn, m:tH:0 <= nabs (n * m) == n * abs mH:forall n m : t, 0 <= n -> abs (n * m) == n * abs mforall n m : t, abs (n * m) == abs n * abs mn, m:tH:0 <= nH0:0 <= mabs (n * m) == n * mn, m:tH:0 <= nH0:m <= 0abs (n * m) == n * - mH:forall n m : t, 0 <= n -> abs (n * m) == n * abs mforall n m : t, abs (n * m) == abs n * abs mn, m:tH:0 <= nH0:0 <= mn * m == n * mn, m:tH:0 <= nH0:0 <= m0 <= n * mn, m:tH:0 <= nH0:m <= 0abs (n * m) == n * - mH:forall n m : t, 0 <= n -> abs (n * m) == n * abs mforall n m : t, abs (n * m) == abs n * abs mn, m:tH:0 <= nH0:0 <= m0 <= n * mn, m:tH:0 <= nH0:m <= 0abs (n * m) == n * - mH:forall n m : t, 0 <= n -> abs (n * m) == n * abs mforall n m : t, abs (n * m) == abs n * abs mn, m:tH:0 <= nH0:m <= 0abs (n * m) == n * - mH:forall n m : t, 0 <= n -> abs (n * m) == n * abs mforall n m : t, abs (n * m) == abs n * abs mn, m:tH:0 <= nH0:m <= 0- (n * m) == - (n * m)n, m:tH:0 <= nH0:m <= 0n * m <= 0H:forall n m : t, 0 <= n -> abs (n * m) == n * abs mforall n m : t, abs (n * m) == abs n * abs mn, m:tH:0 <= nH0:m <= 0n * m <= 0H:forall n m : t, 0 <= n -> abs (n * m) == n * abs mforall n m : t, abs (n * m) == abs n * abs mH:forall n m : t, 0 <= n -> abs (n * m) == n * abs mforall n m : t, abs (n * m) == abs n * abs mH:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0n, m:tabs (n * m) == abs n * abs mH:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0n, m:tH0:0 <= nabs (n * m) == n * abs mH:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0n, m:tH0:n <= 0abs (n * m) == - n * abs mH:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0n, m:tH0:n <= 0abs (n * m) == - n * abs mH:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0n, m:tH0:n <= 0- n * abs m == - n * abs mH:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0n, m:tH0:n <= 00 <= - nnow apply opp_nonneg_nonpos. Qed.H:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0n, m:tH0:n <= 00 <= - nforall n : t, abs n * abs n == n * nforall n : t, abs n * abs n == n * nn:tabs n * abs n == n * nn:tabs (n * n) == n * napply le_0_square. Qed.n:t0 <= n * n
Some results about the sign function.
Ltac destruct_sgn n := let LT := fresh "LT" in let EQ := fresh "EQ" in let GT := fresh "GT" in destruct (lt_trichotomy 0 n) as [LT|[EQ|GT]]; [rewrite (sgn_pos n) by auto| rewrite (sgn_null n) by auto with relations| rewrite (sgn_neg n) by auto].Proper (eq ==> eq) sgnProper (eq ==> eq) sgnx, y:tHxy:x == ysgn x == sgn yx, y:tHxy:x == yLT:0 < x1 == sgn yx, y:tHxy:x == yEQ:0 == x0 == sgn yx, y:tHxy:x == yGT:x < 0-1 == sgn yx, y:tHxy:x == yLT:0 < x0 < yx, y:tHxy:x == yEQ:0 == x0 == sgn yx, y:tHxy:x == yGT:x < 0-1 == sgn yx, y:tHxy:x == yEQ:0 == x0 == sgn yx, y:tHxy:x == yGT:x < 0-1 == sgn yx, y:tHxy:x == yEQ:0 == xy == 0x, y:tHxy:x == yGT:x < 0-1 == sgn yx, y:tHxy:x == yGT:x < 0-1 == sgn yrewrite <- Hxy; auto. Qed.x, y:tHxy:x == yGT:x < 0y < 0forall n : t, 0 < n /\ sgn n == 1 \/ 0 == n /\ sgn n == 0 \/ n < 0 /\ sgn n == -1forall n : t, 0 < n /\ sgn n == 1 \/ 0 == n /\ sgn n == 0 \/ n < 0 /\ sgn n == -1destruct_sgn n; [left|right;left|right;right]; auto with relations. Qed.n:t0 < n /\ sgn n == 1 \/ 0 == n /\ sgn n == 0 \/ n < 0 /\ sgn n == -1sgn 0 == 0now apply sgn_null. Qed.sgn 0 == 0forall n : t, sgn n == 1 <-> 0 < nforall n : t, sgn n == 1 <-> 0 < nn:tsgn n == 1 -> 0 < nn:tEQ:0 == n0 == 1 -> 0 < nn:tGT:n < 0-1 == 1 -> 0 < nn:tEQ:0 == nH:0 == 10 < nn:tGT:n < 0-1 == 1 -> 0 < nn:tEQ:0 == nH:0 == 10 < 1n:tGT:n < 0-1 == 1 -> 0 < nn:tGT:n < 0-1 == 1 -> 0 < nn:tGT:n < 0H:-1 == 10 < nn:tGT:n < 0H:-1 == 1-1 < 1n:tGT:n < 0H:-1 == 1-1 < 0n:tGT:n < 0H:-1 == 10 < 1n:tGT:n < 0H:-1 == 10 < 1n:tGT:n < 0H:-1 == 10 < 1apply lt_0_1. Qed.n:tGT:n < 0H:-1 == 10 < 1forall n : t, sgn n == 0 <-> n == 0forall n : t, sgn n == 0 <-> n == 0n:tsgn n == 0 -> n == 0n:tLT:0 < n1 == 0 -> n == 0n:tGT:n < 0-1 == 0 -> n == 0n:tLT:0 < nH:1 == 0n == 0n:tGT:n < 0-1 == 0 -> n == 0n:tLT:0 < nH:1 == 00 < 1n:tGT:n < 0-1 == 0 -> n == 0n:tGT:n < 0-1 == 0 -> n == 0n:tGT:n < 0H:-1 == 0n == 0n:tGT:n < 0H:-1 == 0-1 < 0apply lt_0_1. Qed.n:tGT:n < 0H:-1 == 00 < 1forall n : t, sgn n == -1 <-> n < 0forall n : t, sgn n == -1 <-> n < 0n:tsgn n == -1 -> n < 0n:tLT:0 < n1 == -1 -> n < 0n:tEQ:0 == n0 == -1 -> n < 0n:tLT:0 < nH:1 == -1n < 0n:tEQ:0 == n0 == -1 -> n < 0n:tLT:0 < nH:1 == -1-1 < 1n:tEQ:0 == n0 == -1 -> n < 0n:tLT:0 < nH:1 == -1-1 < 0n:tLT:0 < nH:1 == -10 < 1n:tEQ:0 == n0 == -1 -> n < 0n:tLT:0 < nH:1 == -10 < 1n:tLT:0 < nH:1 == -10 < 1n:tEQ:0 == n0 == -1 -> n < 0n:tLT:0 < nH:1 == -10 < 1n:tEQ:0 == n0 == -1 -> n < 0n:tEQ:0 == n0 == -1 -> n < 0n:tEQ:0 == nH:0 == -1n < 0n:tEQ:0 == nH:0 == -1-1 < 0apply lt_0_1. Qed.n:tEQ:0 == nH:0 == -10 < 1forall n : t, sgn (- n) == - sgn nforall n : t, sgn (- n) == - sgn nn:tsgn (- n) == - sgn nn:tLT:0 < nsgn (- n) == -1n:tEQ:0 == nsgn (- n) == - 0n:tGT:n < 0sgn (- n) == - -1n:tLT:0 < n- n < 0n:tEQ:0 == nsgn (- n) == - 0n:tGT:n < 0sgn (- n) == - -1n:tEQ:0 == nsgn (- n) == - 0n:tGT:n < 0sgn (- n) == - -1n:tEQ:0 == nsgn (- 0) == - 0n:tGT:n < 0sgn (- n) == - -1n:tEQ:0 == nsgn 0 == 0n:tGT:n < 0sgn (- n) == - -1n:tGT:n < 0sgn (- n) == - -1n:tGT:n < 0sgn (- n) == 1now rewrite opp_pos_neg. Qed.n:tGT:n < 00 < - nforall n : t, 0 <= sgn n <-> 0 <= nforall n : t, 0 <= sgn n <-> 0 <= nn:t0 <= sgn n -> 0 <= nn:t0 <= n -> 0 <= sgn nn:tLT:0 < nH:0 <= 10 <= nn:tEQ:0 == nH:0 <= 00 <= nn:tGT:n < 0H:0 <= -10 <= nn:t0 <= n -> 0 <= sgn nn:tEQ:0 == nH:0 <= 00 <= nn:tGT:n < 0H:0 <= -10 <= nn:t0 <= n -> 0 <= sgn nn:tGT:n < 0H:0 <= -10 <= nn:t0 <= n -> 0 <= sgn nn:tGT:n < 0H:0 <= -10 < 0n:t0 <= n -> 0 <= sgn nn:tGT:n < 0H:0 <= -11 <= 0n:t0 <= n -> 0 <= sgn nn:t0 <= n -> 0 <= sgn nn:tH:0 < n0 <= sgn nn:tH:0 == n0 <= sgn nn:tH:0 < n0 <= 1n:tH:0 == n0 <= sgn nn:tH:0 == n0 <= sgn napply le_refl. Qed.n:tH:0 == n0 <= 0forall n : t, sgn n <= 0 <-> n <= 0forall n : t, sgn n <= 0 <-> n <= 0n:tsgn n <= 0 <-> n <= 0apply sgn_nonneg. Qed.n:t0 <= sgn (- n) <-> 0 <= - nforall n m : t, sgn (n * m) == sgn n * sgn mforall n m : t, sgn (n * m) == sgn n * sgn mn, m:tsgn (n * m) == sgn n * sgn mn, m:tLT:0 < nsgn (n * m) == sgn mn, m:tEQ:0 == nsgn (n * m) == 0n, m:tGT:n < 0sgn (n * m) == -1 * sgn mn, m:tLT:0 < nLT0:0 < msgn (n * m) == 1n, m:tLT:0 < nEQ:0 == msgn (n * m) == 0n, m:tLT:0 < nGT:m < 0sgn (n * m) == -1n, m:tEQ:0 == nsgn (n * m) == 0n, m:tGT:n < 0sgn (n * m) == -1 * sgn mn, m:tLT:0 < nLT0:0 < m0 < n * mn, m:tLT:0 < nEQ:0 == msgn (n * m) == 0n, m:tLT:0 < nGT:m < 0sgn (n * m) == -1n, m:tEQ:0 == nsgn (n * m) == 0n, m:tGT:n < 0sgn (n * m) == -1 * sgn mn, m:tLT:0 < nEQ:0 == msgn (n * m) == 0n, m:tLT:0 < nGT:m < 0sgn (n * m) == -1n, m:tEQ:0 == nsgn (n * m) == 0n, m:tGT:n < 0sgn (n * m) == -1 * sgn mn, m:tLT:0 < nEQ:0 == mn * m == 0n, m:tLT:0 < nGT:m < 0sgn (n * m) == -1n, m:tEQ:0 == nsgn (n * m) == 0n, m:tGT:n < 0sgn (n * m) == -1 * sgn mn, m:tLT:0 < nGT:m < 0sgn (n * m) == -1n, m:tEQ:0 == nsgn (n * m) == 0n, m:tGT:n < 0sgn (n * m) == -1 * sgn mn, m:tLT:0 < nGT:m < 0n * m < 0n, m:tEQ:0 == nsgn (n * m) == 0n, m:tGT:n < 0sgn (n * m) == -1 * sgn mn, m:tEQ:0 == nsgn (n * m) == 0n, m:tGT:n < 0sgn (n * m) == -1 * sgn mn, m:tEQ:0 == nn * m == 0n, m:tGT:n < 0sgn (n * m) == -1 * sgn mn, m:tGT:n < 0sgn (n * m) == -1 * sgn mn, m:tGT:n < 0LT:0 < msgn (n * m) == -1n, m:tGT:n < 0EQ:0 == msgn (n * m) == 0n, m:tGT:n < 0GT0:m < 0sgn (n * m) == 1n, m:tGT:n < 0LT:0 < mn * m < 0n, m:tGT:n < 0EQ:0 == msgn (n * m) == 0n, m:tGT:n < 0GT0:m < 0sgn (n * m) == 1n, m:tGT:n < 0EQ:0 == msgn (n * m) == 0n, m:tGT:n < 0GT0:m < 0sgn (n * m) == 1n, m:tGT:n < 0EQ:0 == mn * m == 0n, m:tGT:n < 0GT0:m < 0sgn (n * m) == 1n, m:tGT:n < 0GT0:m < 0sgn (n * m) == 1now apply mul_neg_neg. Qed.n, m:tGT:n < 0GT0:m < 00 < n * mforall n : t, n * sgn n == abs nforall n : t, n * sgn n == abs nn:tn * sgn n == abs nn:tabs n == n * sgn nn:tLT:0 < nabs n == nn:tEQ:0 == nabs n == 0n:tGT:n < 0abs n == - nn:tLT:0 < n0 <= nn:tEQ:0 == nabs n == 0n:tGT:n < 0abs n == - nn:tEQ:0 == nabs n == 0n:tGT:n < 0abs n == - nn:tGT:n < 0abs n == - nnow apply lt_le_incl. Qed.n:tGT:n < 0n <= 0forall n : t, abs n * sgn n == nforall n : t, abs n * sgn n == nn:tabs n * sgn n == nn:tLT:0 < nabs n == nn:tGT:n < 0- abs n == nn:tLT:0 < n0 <= nn:tGT:n < 0- abs n == nn:tGT:n < 0- abs n == nn:tGT:n < 0abs n == - nnow apply lt_le_incl. Qed.n:tGT:n < 0n <= 0forall x : t, sgn (sgn x) == sgn xforall x : t, sgn (sgn x) == sgn xx:tsgn (sgn x) == sgn xx:tLT:0 < xEQ:sgn x == 1sgn 1 == 1x:tEQ':0 == xEQ:sgn x == 0sgn 0 == 0x:tLT:x < 0EQ:sgn x == -1sgn (-1) == -1x:tEQ':0 == xEQ:sgn x == 0sgn 0 == 0x:tLT:x < 0EQ:sgn x == -1sgn (-1) == -1x:tLT:x < 0EQ:sgn x == -1sgn (-1) == -1x:tLT:x < 0EQ:sgn x == -1-1 < 0apply lt_0_1. Qed. End ZSgnAbsProp.x:tLT:x < 0EQ:sgn x == -10 < 1