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 == n

forall n : t, 0 <= n -> abs n == n
n:t
H:0 <= n

abs n == n
n:t
H:0 <= n

max n (- n) == n
n:t
H:0 <= n

- n <= n
n:t
H:0 <= n

- n <= 0
rewrite opp_nonpos_nonneg; auto. Qed.

forall n : t, n <= 0 -> abs n == - n

forall n : t, n <= 0 -> abs n == - n
n:t
H:n <= 0

abs n == - n
n:t
H:n <= 0

max n (- n) == - n
n:t
H:n <= 0

n <= - n
n:t
H:n <= 0

0 <= - n
rewrite opp_nonneg_nonpos; auto. Qed. End GenericAbs.
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 == 0

forall n : t, n == 0 -> sgn n == 0
n:t
H:n == 0

match compare 0 n with | Eq => 0 | Lt => 1 | Gt => -1 end == 0
destruct (compare_spec 0 n); order. Qed.

forall n : t, 0 < n -> sgn n == 1

forall n : t, 0 < n -> sgn n == 1
n:t
H:0 < n

match compare 0 n with | Eq => 0 | Lt => 1 | Gt => -1 end == 1
destruct (compare_spec 0 n); order. Qed.

forall n : t, n < 0 -> sgn n == -1

forall n : t, n < 0 -> sgn n == -1
n:t
H:n < 0

match compare 0 n with | Eq => 0 | Lt => 1 | Gt => -1 end == -1
destruct (compare_spec 0 n); order. Qed. End GenericSgn.
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) abs

Proper (eq ==> eq) abs
x, y:t
EQ:x == y

abs x == abs y
x, y:t
EQ:x == y
H:0 <= x

x == abs y
x, y:t
EQ:x == y
H:x <= 0
- x == abs y
x, y:t
EQ:x == y
H:0 <= x

0 <= y
x, y:t
EQ:x == y
H:x <= 0
- x == abs y
x, y:t
EQ:x == y
H:x <= 0

- x == abs y
x, y:t
EQ:x == y
H:x <= 0

- x == - y
now rewrite opp_inj_wd. Qed.

forall n : t, abs n == max n (- n)

forall n : t, abs n == max n (- n)
n:t

abs n == max n (- n)
n:t
H:0 <= n

n == max n (- n)
n:t
H:n <= 0
- n == max n (- n)
n:t
H:0 <= n

- n <= n
n:t
H:n <= 0
- n == max n (- n)
n:t
H:0 <= n

- n <= 0
n:t
H:n <= 0
- n == max n (- n)
n:t
H:n <= 0

- n == max n (- n)
n:t
H:n <= 0

n <= - n
n:t
H:n <= 0

0 <= - n
rewrite opp_nonneg_nonpos; auto. Qed.

forall n : t, 0 <= - n -> abs n == - n

forall n : t, 0 <= - n -> abs n == - n
n:t
H:0 <= - n

abs n == - n
n:t
H:0 <= - n

n <= 0
now rewrite <- opp_nonneg_nonpos. Qed.

forall n : t, 0 <= abs n

forall n : t, 0 <= abs n
n:t

0 <= abs n
n:t
H:n <= 0

0 <= - n
now rewrite opp_nonneg_nonpos. Qed.

forall n : t, abs n == n <-> 0 <= n

forall n : t, abs n == n <-> 0 <= n
n:t

abs n == n -> 0 <= n
n:t
EQ:abs n == n

0 <= n
n:t
EQ:abs n == n

0 <= abs n
apply abs_nonneg. Qed.

forall n : t, abs n == - n <-> n <= 0

forall n : t, abs n == - n <-> n <= 0
n:t

abs n == - n -> n <= 0
n:t
EQ:abs n == - n

n <= 0
n:t
EQ:abs n == - n

0 <= abs n
apply abs_nonneg. Qed.

forall n : t, abs (- n) == abs n

forall n : t, abs (- n) == abs n
n:t

abs (- n) == abs n
n:t
H:0 <= n

abs (- n) == n
n:t
H:n <= 0
abs (- n) == - n
n:t
H:0 <= n

n == n
n:t
H:0 <= n
- n <= 0
n:t
H:n <= 0
abs (- n) == - n
n:t
H:0 <= n

- n <= 0
n:t
H:n <= 0
abs (- n) == - n
n:t
H:n <= 0

abs (- n) == - n
n:t
H:n <= 0

- n == - n
n:t
H:n <= 0
0 <= - n
n:t
H:n <= 0

0 <= - n
now rewrite opp_nonneg_nonpos. Qed.

abs 0 == 0

abs 0 == 0

0 <= 0
apply le_refl. Qed.

forall n : t, abs n == 0 <-> n == 0

forall n : t, abs n == 0 <-> n == 0
n:t

abs n == 0 -> n == 0
n:t
n == 0 -> abs n == 0
n:t
H:n <= 0

- n == 0 -> n == 0
n:t
n == 0 -> abs n == 0
n:t

n == 0 -> abs n == 0
n:t
EQ:n == 0

abs 0 == 0
rewrite abs_eq; auto using eq_refl, le_refl. Qed.

forall n : t, 0 < abs n <-> n ~= 0

forall n : t, 0 < abs n <-> n ~= 0
n:t

0 < abs n <-> n ~= 0
n:t

0 < abs n <-> abs n ~= 0
n:t
LT:0 < abs n

abs n ~= 0
n:t
NEQ:abs n ~= 0
0 < abs n
n:t
LT:0 < abs n
EQ:abs n == 0

False
n:t
NEQ:abs n ~= 0
0 < abs n
n:t
LT:0 < 0
EQ:abs n == 0

False
n:t
NEQ:abs n ~= 0
0 < abs n
n:t
NEQ:abs n ~= 0

0 < abs n
n:t
NEQ:abs n ~= 0
LE:0 <= abs n

0 < abs n
n:t
NEQ:abs n ~= 0
H:0 == abs n

0 < abs n
elim NEQ; auto with relations. Qed.

forall n : t, abs n == n \/ abs n == - n

forall n : t, abs n == n \/ abs n == - n
n:t

abs n == n \/ abs n == - n
destruct_max n; auto with relations. Qed.

forall n : t, n == abs n \/ n == - abs n

forall n : t, n == abs n \/ n == - abs n
n:t

n == abs n \/ n == - abs n
destruct_max n; rewrite ? opp_involutive; auto with relations. Qed.

forall n : t, abs (abs n) == abs n

forall n : t, abs (abs n) == abs n
n:t

abs (abs n) == abs n
n:t

0 <= abs n
apply abs_nonneg. Qed.

forall n : t, 0 <= n /\ abs n == n \/ n < 0 /\ abs n == - n

forall n : t, 0 <= n /\ abs n == n \/ n < 0 /\ abs n == - n
n:t

0 <= n /\ abs n == n \/ n < 0 /\ abs n == - n
n:t
H:0 <= n

0 <= n /\ abs n == n \/ n < 0 /\ abs n == - n
n:t
H:n < 0
0 <= n /\ abs n == n \/ n < 0 /\ abs n == - n
n:t
H:0 <= n

abs n == n
n:t
H:n < 0
0 <= n /\ abs n == n \/ n < 0 /\ abs n == - n
n:t
H:n < 0

0 <= n /\ abs n == n \/ n < 0 /\ abs n == - n
n:t
H:n < 0

abs n == - n
n:t
H:n < 0

n <= 0
now apply lt_le_incl. Qed.

forall (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)
P:t -> Prop
n:t
H:Proper (eq ==> iff) P
H0:0 <= n -> P n
H1:n <= 0 -> P (- n)

P (abs n)
destruct_max n; auto. Qed.

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)
P:t -> Prop
n:t
H:Proper (eq ==> iff) P
H0:P n
H1:P (- n)

P (abs n)
now apply abs_case_strong. Qed.

forall n m : t, abs n == abs m -> n == m \/ n == - m

forall n m : t, abs n == abs m -> n == m \/ n == - m
n, m:t
EQ:abs n == abs m

n == m \/ n == - m
n, m:t
EQ:abs n == abs m
EQn:n == abs n

n == m \/ n == - m
n, m:t
EQ:abs n == abs m
EQn:n == - abs n
n == m \/ n == - m
n, m:t
EQ:abs n == abs m
EQn:n == abs n

abs m == m \/ abs m == - m
n, m:t
EQ:abs n == abs m
EQn:n == - abs n
n == m \/ n == - m
n, m:t
EQ:abs n == abs m
EQn:n == - abs n

n == m \/ n == - m
n, m:t
EQ:abs n == abs m
EQn:n == - abs n

abs m == m \/ abs m == - m
apply abs_eq_or_opp. Qed.

forall a b : t, abs a < b <-> - b < a < b

forall a b : t, abs a < b <-> - b < a < b
a, b:t

abs a < b <-> - b < a < b
a, b:t
LE:0 <= a

a < b <-> - b < a < b
a, b:t
LT:a < 0
- a < b <-> - b < a < b
a, b:t
LE:0 <= a
H:a < b

- b < a
a, b:t
LT:a < 0
- a < b <-> - b < a < b
a, b:t
LE:0 <= a
H:a < b

- b < 0
a, b:t
LT:a < 0
- a < b <-> - b < a < b
a, b:t
LT:a < 0

- a < b <-> - b < a < b
a, b:t
LT:a < 0

- b < a <-> - b < a < b
a, b:t
LT:a < 0
H:- b < a

a < b
a, b:t
LT:a < 0
H:- b < a

0 <= b
apply opp_nonpos_nonneg; order. Qed.

forall a b : t, abs a <= b <-> - b <= a <= b

forall a b : t, abs a <= b <-> - b <= a <= b
a, b:t

abs a <= b <-> - b <= a <= b
a, b:t
LE:0 <= a

a <= b <-> - b <= a <= b
a, b:t
LT:a < 0
- a <= b <-> - b <= a <= b
a, b:t
LE:0 <= a
H:a <= b

- b <= a
a, b:t
LT:a < 0
- a <= b <-> - b <= a <= b
a, b:t
LE:0 <= a
H:a <= b

- b <= 0
a, b:t
LT:a < 0
- a <= b <-> - b <= a <= b
a, b:t
LT:a < 0

- a <= b <-> - b <= a <= b
a, b:t
LT:a < 0

- b <= a <-> - b <= a <= b
a, b:t
LT:a < 0
H:- b <= a

a <= b
a, b:t
LT:a < 0
H:- b <= a

a <= 0
a, b:t
LT:a < 0
H:- b <= a
0 <= b
a, b:t
LT:a < 0
H:- b <= a

0 <= b
apply opp_nonpos_nonneg; order. Qed.
Triangular inequality

forall n m : t, abs (n + m) <= abs n + abs m

forall n m : t, abs (n + m) <= abs n + abs m
n, m:t

abs (n + m) <= abs n + abs m
n, m:t
H:0 <= n
H0:0 <= m

abs (n + m) <= n + m
n, m:t
H:0 <= n
H0:m <= 0
abs (n + m) <= n + - m
n, m:t
H:n <= 0
H0:0 <= m
abs (n + m) <= - n + m
n, m:t
H:n <= 0
H0:m <= 0
abs (n + m) <= - n + - m
n, m:t
H:0 <= n
H0:0 <= m

n + m <= n + m
n, m:t
H:0 <= n
H0:0 <= m
0 <= n + m
n, m:t
H:0 <= n
H0:m <= 0
abs (n + m) <= n + - m
n, m:t
H:n <= 0
H0:0 <= m
abs (n + m) <= - n + m
n, m:t
H:n <= 0
H0:m <= 0
abs (n + m) <= - n + - m
n, m:t
H:0 <= n
H0:0 <= m

0 <= n + m
n, m:t
H:0 <= n
H0:m <= 0
abs (n + m) <= n + - m
n, m:t
H:n <= 0
H0:0 <= m
abs (n + m) <= - n + m
n, m:t
H:n <= 0
H0:m <= 0
abs (n + m) <= - n + - m
n, m:t
H:0 <= n
H0:m <= 0

abs (n + m) <= n + - m
n, m:t
H:n <= 0
H0:0 <= m
abs (n + m) <= - n + m
n, m:t
H:n <= 0
H0:m <= 0
abs (n + m) <= - n + - m
n, m:t
H:0 <= n
H0:m <= 0
H1:0 <= n + m

m <= - m
n, m:t
H:0 <= n
H0:m <= 0
H1:n + m <= 0
- n <= n
n, m:t
H:n <= 0
H0:0 <= m
abs (n + m) <= - n + m
n, m:t
H:n <= 0
H0:m <= 0
abs (n + m) <= - n + - m
n, m:t
H:0 <= n
H0:m <= 0
H1:0 <= n + m

0 <= - m
n, m:t
H:0 <= n
H0:m <= 0
H1:n + m <= 0
- n <= n
n, m:t
H:n <= 0
H0:0 <= m
abs (n + m) <= - n + m
n, m:t
H:n <= 0
H0:m <= 0
abs (n + m) <= - n + - m
n, m:t
H:0 <= n
H0:m <= 0
H1:n + m <= 0

- n <= n
n, m:t
H:n <= 0
H0:0 <= m
abs (n + m) <= - n + m
n, m:t
H:n <= 0
H0:m <= 0
abs (n + m) <= - n + - m
n, m:t
H:0 <= n
H0:m <= 0
H1:n + m <= 0

- n <= 0
n, m:t
H:n <= 0
H0:0 <= m
abs (n + m) <= - n + m
n, m:t
H:n <= 0
H0:m <= 0
abs (n + m) <= - n + - m
n, m:t
H:n <= 0
H0:0 <= m

abs (n + m) <= - n + m
n, m:t
H:n <= 0
H0:m <= 0
abs (n + m) <= - n + - m
n, m:t
H:n <= 0
H0:0 <= m
H1:0 <= n + m

n <= - n
n, m:t
H:n <= 0
H0:0 <= m
H1:n + m <= 0
- m <= m
n, m:t
H:n <= 0
H0:m <= 0
abs (n + m) <= - n + - m
n, m:t
H:n <= 0
H0:0 <= m
H1:0 <= n + m

0 <= - n
n, m:t
H:n <= 0
H0:0 <= m
H1:n + m <= 0
- m <= m
n, m:t
H:n <= 0
H0:m <= 0
abs (n + m) <= - n + - m
n, m:t
H:n <= 0
H0:0 <= m
H1:n + m <= 0

- m <= m
n, m:t
H:n <= 0
H0:m <= 0
abs (n + m) <= - n + - m
n, m:t
H:n <= 0
H0:0 <= m
H1:n + m <= 0

- m <= 0
n, m:t
H:n <= 0
H0:m <= 0
abs (n + m) <= - n + - m
n, m:t
H:n <= 0
H0:m <= 0

abs (n + m) <= - n + - m
n, m:t
H:n <= 0
H0:m <= 0

- n + - m <= - n + - m
n, m:t
H:n <= 0
H0:m <= 0
n + m <= 0
n, m:t
H:n <= 0
H0:m <= 0

n + m <= 0
now apply add_nonpos_nonpos. Qed.

forall n m : t, abs n - abs m <= abs (n - m)

forall n m : t, abs n - abs m <= abs (n - m)
n, m:t

abs n - abs m <= abs (n - m)
n, m:t

abs n <= abs (n - m) + abs m
n, m:t

abs (n - m + m) <= abs (n - m) + abs m
apply abs_triangle. Qed.
Absolute value and multiplication

forall n m : t, abs (n * m) == abs n * abs m

forall n m : t, abs (n * m) == abs n * abs m

forall n m : t, 0 <= n -> abs (n * m) == n * abs m
H:forall n m : t, 0 <= n -> abs (n * m) == n * abs m
forall n m : t, abs (n * m) == abs n * abs m
n, m:t
H:0 <= n

abs (n * m) == n * abs m
H:forall n m : t, 0 <= n -> abs (n * m) == n * abs m
forall n m : t, abs (n * m) == abs n * abs m
n, m:t
H:0 <= n
H0:0 <= m

abs (n * m) == n * m
n, m:t
H:0 <= n
H0:m <= 0
abs (n * m) == n * - m
H:forall n m : t, 0 <= n -> abs (n * m) == n * abs m
forall n m : t, abs (n * m) == abs n * abs m
n, m:t
H:0 <= n
H0:0 <= m

n * m == n * m
n, m:t
H:0 <= n
H0:0 <= m
0 <= n * m
n, m:t
H:0 <= n
H0:m <= 0
abs (n * m) == n * - m
H:forall n m : t, 0 <= n -> abs (n * m) == n * abs m
forall n m : t, abs (n * m) == abs n * abs m
n, m:t
H:0 <= n
H0:0 <= m

0 <= n * m
n, m:t
H:0 <= n
H0:m <= 0
abs (n * m) == n * - m
H:forall n m : t, 0 <= n -> abs (n * m) == n * abs m
forall n m : t, abs (n * m) == abs n * abs m
n, m:t
H:0 <= n
H0:m <= 0

abs (n * m) == n * - m
H:forall n m : t, 0 <= n -> abs (n * m) == n * abs m
forall n m : t, abs (n * m) == abs n * abs m
n, m:t
H:0 <= n
H0:m <= 0

- (n * m) == - (n * m)
n, m:t
H:0 <= n
H0:m <= 0
n * m <= 0
H:forall n m : t, 0 <= n -> abs (n * m) == n * abs m
forall n m : t, abs (n * m) == abs n * abs m
n, m:t
H:0 <= n
H0:m <= 0

n * m <= 0
H:forall n m : t, 0 <= n -> abs (n * m) == n * abs m
forall n m : t, abs (n * m) == abs n * abs m
H:forall n m : t, 0 <= n -> abs (n * m) == n * abs m

forall n m : t, abs (n * m) == abs n * abs m
H:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0
n, m:t

abs (n * m) == abs n * abs m
H:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0
n, m:t
H0:0 <= n

abs (n * m) == n * abs m
H:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0
n, m:t
H0:n <= 0
abs (n * m) == - n * abs m
H:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0
n, m:t
H0:n <= 0

abs (n * m) == - n * abs m
H:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0
n, m:t
H0:n <= 0

- n * abs m == - n * abs m
H:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0
n, m:t
H0:n <= 0
0 <= - n
H:forall n0 m0 : t, 0 <= n0 -> abs (n0 * m0) == n0 * abs m0
n, m:t
H0:n <= 0

0 <= - n
now apply opp_nonneg_nonpos. Qed.

forall n : t, abs n * abs n == n * n

forall n : t, abs n * abs n == n * n
n:t

abs n * abs n == n * n
n:t

abs (n * n) == n * n
n:t

0 <= n * n
apply le_0_square. Qed.
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) sgn

Proper (eq ==> eq) sgn
x, y:t
Hxy:x == y

sgn x == sgn y
x, y:t
Hxy:x == y
LT:0 < x

1 == sgn y
x, y:t
Hxy:x == y
EQ:0 == x
0 == sgn y
x, y:t
Hxy:x == y
GT:x < 0
-1 == sgn y
x, y:t
Hxy:x == y
LT:0 < x

0 < y
x, y:t
Hxy:x == y
EQ:0 == x
0 == sgn y
x, y:t
Hxy:x == y
GT:x < 0
-1 == sgn y
x, y:t
Hxy:x == y
EQ:0 == x

0 == sgn y
x, y:t
Hxy:x == y
GT:x < 0
-1 == sgn y
x, y:t
Hxy:x == y
EQ:0 == x

y == 0
x, y:t
Hxy:x == y
GT:x < 0
-1 == sgn y
x, y:t
Hxy:x == y
GT:x < 0

-1 == sgn y
x, y:t
Hxy:x == y
GT:x < 0

y < 0
rewrite <- Hxy; auto. Qed.

forall n : t, 0 < n /\ sgn n == 1 \/ 0 == n /\ sgn n == 0 \/ n < 0 /\ sgn n == -1

forall n : t, 0 < n /\ sgn n == 1 \/ 0 == n /\ sgn n == 0 \/ n < 0 /\ sgn n == -1
n:t

0 < n /\ sgn n == 1 \/ 0 == n /\ sgn n == 0 \/ n < 0 /\ sgn n == -1
destruct_sgn n; [left|right;left|right;right]; auto with relations. Qed.

sgn 0 == 0

sgn 0 == 0
now apply sgn_null. Qed.

forall n : t, sgn n == 1 <-> 0 < n

forall n : t, sgn n == 1 <-> 0 < n
n:t

sgn n == 1 -> 0 < n
n:t
EQ:0 == n

0 == 1 -> 0 < n
n:t
GT:n < 0
-1 == 1 -> 0 < n
n:t
EQ:0 == n
H:0 == 1

0 < n
n:t
GT:n < 0
-1 == 1 -> 0 < n
n:t
EQ:0 == n
H:0 == 1

0 < 1
n:t
GT:n < 0
-1 == 1 -> 0 < n
n:t
GT:n < 0

-1 == 1 -> 0 < n
n:t
GT:n < 0
H:-1 == 1

0 < n
n:t
GT:n < 0
H:-1 == 1

-1 < 1
n:t
GT:n < 0
H:-1 == 1

-1 < 0
n:t
GT:n < 0
H:-1 == 1
0 < 1
n:t
GT:n < 0
H:-1 == 1

0 < 1
n:t
GT:n < 0
H:-1 == 1
0 < 1
n:t
GT:n < 0
H:-1 == 1

0 < 1
apply lt_0_1. Qed.

forall n : t, sgn n == 0 <-> n == 0

forall n : t, sgn n == 0 <-> n == 0
n:t

sgn n == 0 -> n == 0
n:t
LT:0 < n

1 == 0 -> n == 0
n:t
GT:n < 0
-1 == 0 -> n == 0
n:t
LT:0 < n
H:1 == 0

n == 0
n:t
GT:n < 0
-1 == 0 -> n == 0
n:t
LT:0 < n
H:1 == 0

0 < 1
n:t
GT:n < 0
-1 == 0 -> n == 0
n:t
GT:n < 0

-1 == 0 -> n == 0
n:t
GT:n < 0
H:-1 == 0

n == 0
n:t
GT:n < 0
H:-1 == 0

-1 < 0
n:t
GT:n < 0
H:-1 == 0

0 < 1
apply lt_0_1. Qed.

forall n : t, sgn n == -1 <-> n < 0

forall n : t, sgn n == -1 <-> n < 0
n:t

sgn n == -1 -> n < 0
n:t
LT:0 < n

1 == -1 -> n < 0
n:t
EQ:0 == n
0 == -1 -> n < 0
n:t
LT:0 < n
H:1 == -1

n < 0
n:t
EQ:0 == n
0 == -1 -> n < 0
n:t
LT:0 < n
H:1 == -1

-1 < 1
n:t
EQ:0 == n
0 == -1 -> n < 0
n:t
LT:0 < n
H:1 == -1

-1 < 0
n:t
LT:0 < n
H:1 == -1
0 < 1
n:t
EQ:0 == n
0 == -1 -> n < 0
n:t
LT:0 < n
H:1 == -1

0 < 1
n:t
LT:0 < n
H:1 == -1
0 < 1
n:t
EQ:0 == n
0 == -1 -> n < 0
n:t
LT:0 < n
H:1 == -1

0 < 1
n:t
EQ:0 == n
0 == -1 -> n < 0
n:t
EQ:0 == n

0 == -1 -> n < 0
n:t
EQ:0 == n
H:0 == -1

n < 0
n:t
EQ:0 == n
H:0 == -1

-1 < 0
n:t
EQ:0 == n
H:0 == -1

0 < 1
apply lt_0_1. Qed.

forall n : t, sgn (- n) == - sgn n

forall n : t, sgn (- n) == - sgn n
n:t

sgn (- n) == - sgn n
n:t
LT:0 < n

sgn (- n) == -1
n:t
EQ:0 == n
sgn (- n) == - 0
n:t
GT:n < 0
sgn (- n) == - -1
n:t
LT:0 < n

- n < 0
n:t
EQ:0 == n
sgn (- n) == - 0
n:t
GT:n < 0
sgn (- n) == - -1
n:t
EQ:0 == n

sgn (- n) == - 0
n:t
GT:n < 0
sgn (- n) == - -1
n:t
EQ:0 == n

sgn (- 0) == - 0
n:t
GT:n < 0
sgn (- n) == - -1
n:t
EQ:0 == n

sgn 0 == 0
n:t
GT:n < 0
sgn (- n) == - -1
n:t
GT:n < 0

sgn (- n) == - -1
n:t
GT:n < 0

sgn (- n) == 1
n:t
GT:n < 0

0 < - n
now rewrite opp_pos_neg. Qed.

forall n : t, 0 <= sgn n <-> 0 <= n

forall n : t, 0 <= sgn n <-> 0 <= n
n:t

0 <= sgn n -> 0 <= n
n:t
0 <= n -> 0 <= sgn n
n:t
LT:0 < n
H:0 <= 1

0 <= n
n:t
EQ:0 == n
H:0 <= 0
0 <= n
n:t
GT:n < 0
H:0 <= -1
0 <= n
n:t
0 <= n -> 0 <= sgn n
n:t
EQ:0 == n
H:0 <= 0

0 <= n
n:t
GT:n < 0
H:0 <= -1
0 <= n
n:t
0 <= n -> 0 <= sgn n
n:t
GT:n < 0
H:0 <= -1

0 <= n
n:t
0 <= n -> 0 <= sgn n
n:t
GT:n < 0
H:0 <= -1

0 < 0
n:t
0 <= n -> 0 <= sgn n
n:t
GT:n < 0
H:0 <= -1

1 <= 0
n:t
0 <= n -> 0 <= sgn n
n:t

0 <= n -> 0 <= sgn n
n:t
H:0 < n

0 <= sgn n
n:t
H:0 == n
0 <= sgn n
n:t
H:0 < n

0 <= 1
n:t
H:0 == n
0 <= sgn n
n:t
H:0 == n

0 <= sgn n
n:t
H:0 == n

0 <= 0
apply le_refl. Qed.

forall n : t, sgn n <= 0 <-> n <= 0

forall n : t, sgn n <= 0 <-> n <= 0
n:t

sgn n <= 0 <-> n <= 0
n:t

0 <= sgn (- n) <-> 0 <= - n
apply sgn_nonneg. Qed.

forall n m : t, sgn (n * m) == sgn n * sgn m

forall n m : t, sgn (n * m) == sgn n * sgn m
n, m:t

sgn (n * m) == sgn n * sgn m
n, m:t
LT:0 < n

sgn (n * m) == sgn m
n, m:t
EQ:0 == n
sgn (n * m) == 0
n, m:t
GT:n < 0
sgn (n * m) == -1 * sgn m
n, m:t
LT:0 < n
LT0:0 < m

sgn (n * m) == 1
n, m:t
LT:0 < n
EQ:0 == m
sgn (n * m) == 0
n, m:t
LT:0 < n
GT:m < 0
sgn (n * m) == -1
n, m:t
EQ:0 == n
sgn (n * m) == 0
n, m:t
GT:n < 0
sgn (n * m) == -1 * sgn m
n, m:t
LT:0 < n
LT0:0 < m

0 < n * m
n, m:t
LT:0 < n
EQ:0 == m
sgn (n * m) == 0
n, m:t
LT:0 < n
GT:m < 0
sgn (n * m) == -1
n, m:t
EQ:0 == n
sgn (n * m) == 0
n, m:t
GT:n < 0
sgn (n * m) == -1 * sgn m
n, m:t
LT:0 < n
EQ:0 == m

sgn (n * m) == 0
n, m:t
LT:0 < n
GT:m < 0
sgn (n * m) == -1
n, m:t
EQ:0 == n
sgn (n * m) == 0
n, m:t
GT:n < 0
sgn (n * m) == -1 * sgn m
n, m:t
LT:0 < n
EQ:0 == m

n * m == 0
n, m:t
LT:0 < n
GT:m < 0
sgn (n * m) == -1
n, m:t
EQ:0 == n
sgn (n * m) == 0
n, m:t
GT:n < 0
sgn (n * m) == -1 * sgn m
n, m:t
LT:0 < n
GT:m < 0

sgn (n * m) == -1
n, m:t
EQ:0 == n
sgn (n * m) == 0
n, m:t
GT:n < 0
sgn (n * m) == -1 * sgn m
n, m:t
LT:0 < n
GT:m < 0

n * m < 0
n, m:t
EQ:0 == n
sgn (n * m) == 0
n, m:t
GT:n < 0
sgn (n * m) == -1 * sgn m
n, m:t
EQ:0 == n

sgn (n * m) == 0
n, m:t
GT:n < 0
sgn (n * m) == -1 * sgn m
n, m:t
EQ:0 == n

n * m == 0
n, m:t
GT:n < 0
sgn (n * m) == -1 * sgn m
n, m:t
GT:n < 0

sgn (n * m) == -1 * sgn m
n, m:t
GT:n < 0
LT:0 < m

sgn (n * m) == -1
n, m:t
GT:n < 0
EQ:0 == m
sgn (n * m) == 0
n, m:t
GT:n < 0
GT0:m < 0
sgn (n * m) == 1
n, m:t
GT:n < 0
LT:0 < m

n * m < 0
n, m:t
GT:n < 0
EQ:0 == m
sgn (n * m) == 0
n, m:t
GT:n < 0
GT0:m < 0
sgn (n * m) == 1
n, m:t
GT:n < 0
EQ:0 == m

sgn (n * m) == 0
n, m:t
GT:n < 0
GT0:m < 0
sgn (n * m) == 1
n, m:t
GT:n < 0
EQ:0 == m

n * m == 0
n, m:t
GT:n < 0
GT0:m < 0
sgn (n * m) == 1
n, m:t
GT:n < 0
GT0:m < 0

sgn (n * m) == 1
n, m:t
GT:n < 0
GT0:m < 0

0 < n * m
now apply mul_neg_neg. Qed.

forall n : t, n * sgn n == abs n

forall n : t, n * sgn n == abs n
n:t

n * sgn n == abs n
n:t

abs n == n * sgn n
n:t
LT:0 < n

abs n == n
n:t
EQ:0 == n
abs n == 0
n:t
GT:n < 0
abs n == - n
n:t
LT:0 < n

0 <= n
n:t
EQ:0 == n
abs n == 0
n:t
GT:n < 0
abs n == - n
n:t
EQ:0 == n

abs n == 0
n:t
GT:n < 0
abs n == - n
n:t
GT:n < 0

abs n == - n
n:t
GT:n < 0

n <= 0
now apply lt_le_incl. Qed.

forall n : t, abs n * sgn n == n

forall n : t, abs n * sgn n == n
n:t

abs n * sgn n == n
n:t
LT:0 < n

abs n == n
n:t
GT:n < 0
- abs n == n
n:t
LT:0 < n

0 <= n
n:t
GT:n < 0
- abs n == n
n:t
GT:n < 0

- abs n == n
n:t
GT:n < 0

abs n == - n
n:t
GT:n < 0

n <= 0
now apply lt_le_incl. Qed.

forall x : t, sgn (sgn x) == sgn x

forall x : t, sgn (sgn x) == sgn x
x:t

sgn (sgn x) == sgn x
x:t
LT:0 < x
EQ:sgn x == 1

sgn 1 == 1
x:t
EQ':0 == x
EQ:sgn x == 0
sgn 0 == 0
x:t
LT:x < 0
EQ:sgn x == -1
sgn (-1) == -1
x:t
EQ':0 == x
EQ:sgn x == 0

sgn 0 == 0
x:t
LT:x < 0
EQ:sgn x == -1
sgn (-1) == -1
x:t
LT:x < 0
EQ:sgn x == -1

sgn (-1) == -1
x:t
LT:x < 0
EQ:sgn x == -1

-1 < 0
x:t
LT:x < 0
EQ:sgn x == -1

0 < 1
apply lt_0_1. Qed. End ZSgnAbsProp.