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 Bool NSub NZParity.
Some additional properties of even, odd.
Module Type NParityProp (Import N : NAxiomsSig')(Import NP : NSubProp N).

Include NZParityProp N N NP.


forall n : t, n ~= 0 -> odd (P n) = even n

forall n : t, n ~= 0 -> odd (P n) = even n
n:t
H:n ~= 0

odd (P n) = even n
n:t
H:n ~= 0

odd (P n) = even (S (P n))
n:t
H:n ~= 0

even (S (P n)) = odd (P n)
apply even_succ. Qed.

forall n : t, n ~= 0 -> even (P n) = odd n

forall n : t, n ~= 0 -> even (P n) = odd n
n:t
H:n ~= 0

even (P n) = odd n
n:t
H:n ~= 0

even (P n) = odd (S (P n))
n:t
H:n ~= 0

odd (S (P n)) = even (P n)
apply odd_succ. Qed.

forall n m : t, m <= n -> even (n - m) = Bool.eqb (even n) (even m)

forall n m : t, m <= n -> even (n - m) = Bool.eqb (even n) (even m)
n, m:t
H:m <= n

even (n - m) = Bool.eqb (even n) (even m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n'

Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n'

n - m == 2 * (n' - m')
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

n - m == 2 * (n' - m' - 1) + 1
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

2 * n' - 2 * m' - 1 == 2 * n' - 2 * m' - 2 + 1
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

2 * n' - 2 * m' - 1 == 2 * n' - 2 * m' - S 1 + 1
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

2 * n' - 2 * m' - 1 == 2 * n' - 2 * m' - (1 + 1) + 1
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

2 * n' - 2 * m' - 1 == 2 * n' - 2 * m' - 1 - 1 + 1
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

2 * n' - 2 * m' - 1 - 1 + 1 == 2 * n' - 2 * m' - 1
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

1 <= 2 * n' - 2 * m' - 1
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

1 + 1 <= 2 * n' - 2 * m'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

2 * 1 <= 2 * n' - 2 * m'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

2 * 1 <= 2 * (n' - m')
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

1 <= n' - m'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

0 < n' - m'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'

m' < n'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'
LE:n' <= m'

m' < n'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n'
LE:n' <= m'

2 * n' < 2 * m' + 1 -> m' < n'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1

Odd (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1

n - m == 2 * (n' - m') + 1
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1

2 * n' + 1 - 2 * m' == 2 * n' - 2 * m' + 1
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1

2 * m' <= 2 * n'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1

m' <= n'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
GT:n' < m'

m' <= n'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m'
n':t
Hn:n == 2 * n' + 1
GT:n' < m'

2 * n' + 1 < 2 * m' -> m' <= n'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1

Even (n - m)
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1

n - m == 2 * (n' - m')
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1

2 * n' + 1 - (2 * m' + 1) == 2 * n' - 2 * m'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1

2 * n' + 1 - 2 * m' - 1 == 2 * n' - 2 * m'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1

2 * n' - 2 * m' + 1 - 1 == 2 * n' - 2 * m'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1
2 * m' <= 2 * n'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1

2 * m' <= 2 * n'
n, m:t
H:m <= n
m':t
Hm:m == 2 * m' + 1
n':t
Hn:n == 2 * n' + 1

S (2 * m') <= S (2 * n')
n, m:t
H:m <= n
m':t
Hm:m == S (2 * m')
n':t
Hn:n == S (2 * n')

S (2 * m') <= S (2 * n')
order. Qed.

forall n m : t, m <= n -> odd (n - m) = xorb (odd n) (odd m)

forall n m : t, m <= n -> odd (n - m) = xorb (odd n) (odd m)
n, m:t
H:m <= n

odd (n - m) = xorb (odd n) (odd m)
n, m:t
H:m <= n

negb (even (n - m)) = xorb (negb (even n)) (negb (even m))
n, m:t
H:m <= n

negb (Bool.eqb (even n) (even m)) = xorb (negb (even n)) (negb (even m))
now destruct (even n), (even m). Qed. End NParityProp.