Library Coq.NArith.BinNat
Binary natural numbers, operations and properties
The type
N and its constructors
N0 and
Npos are now
defined in
BinNums.v
Every definitions and properties about binary natural numbers
are placed in a module
N for qualification purpose.
Local Open Scope N_scope.
Every definitions and early properties about positive numbers
are placed in a module N for qualification purpose.
Definitions of operations, now in a separate file
When including property functors, only inline t eq zero one two
Logical predicates
Decidability of equality.
Discrimination principle
Convenient induction principles
Peano induction on binary natural numbers
Properties of mixed successor and predecessor.
Properties of successor and predecessor
Specification of addition
Specification of subtraction.
Specification of multiplication
Specification of boolean comparisons.
Basic properties of comparison
Some more advanced properties of comparison and orders,
including compare_spec and lt_irrefl and lt_eq_cases.
We regroup here some results used for proving the correctness
of more advanced functions. These results will also be provided
by the generic functor of properties about natural numbers
instantiated at the end of the file.
Specification of lt and le.
Properties of double and succ_double
Specification of minimum and maximum
0 is the least natural number
Specifications of power
Specification of square
Specification of Base-2 logarithm
Specification of parity functions
Specification of the euclidean division
Specification of square root
Specification of gcd
The first component of ggcd is gcd
The other components of ggcd are indeed the correct factors.
We can use this fact to prove a part of the gcd correctness
We now prove directly that gcd is the greatest amongst common divisors
Specification of bitwise functions
Correctness proofs for
testbit.
Correctness proofs for shifts
Semantics of bitwise operations
Specification of constants
Proofs of morphisms, obvious since eq is Leibniz
Generic induction / recursion
Instantiation of generic properties of natural numbers
The Bind Scope prevents N to stay associated with abstract_scope.
(TODO FIX)
In generic statements, the predicates lt and le have been
favored, whereas gt and ge don't even exist in the abstract
layers. The use of gt and ge is hence not recommended. We provide
here the bare minimal results to related them with lt and le.
Auxiliary results about right shift on positive numbers,
used in BinInt
Exportation of notations
Infix "+" :=
N.add :
N_scope.
Infix "-" :=
N.sub :
N_scope.
Infix "*" :=
N.mul :
N_scope.
Infix "^" :=
N.pow :
N_scope.
Infix "?=" :=
N.compare (
at level 70,
no associativity) :
N_scope.
Infix "<=" :=
N.le :
N_scope.
Infix "<" :=
N.lt :
N_scope.
Infix ">=" :=
N.ge :
N_scope.
Infix ">" :=
N.gt :
N_scope.
Notation "x <= y <= z" := (
x <= y /\ y <= z) :
N_scope.
Notation "x <= y < z" := (
x <= y /\ y < z) :
N_scope.
Notation "x < y < z" := (
x < y /\ y < z) :
N_scope.
Notation "x < y <= z" := (
x < y /\ y <= z) :
N_scope.
Infix "=?" :=
N.eqb (
at level 70,
no associativity) :
N_scope.
Infix "<=?" :=
N.leb (
at level 70,
no associativity) :
N_scope.
Infix "<?" :=
N.ltb (
at level 70,
no associativity) :
N_scope.
Infix "/" :=
N.div :
N_scope.
Infix "mod" :=
N.modulo (
at level 40,
no associativity) :
N_scope.
Notation "( p | q )" := (
N.divide p q) (
at level 0) :
N_scope.
Compatibility notations
More complex compatibility facts, expressed as lemmas
(to preserve scopes for instance)
Not kept : Ncompare_n_Sm Nplus_lt_cancel_l