Z
The theory fast_integer provides an efficient formalization of
integers in COQ.
Many useful theorems are given in zarith.
The tactic Omega is a partial
decision procedure for goals of Presburger arithmetic expressed in this theory.
Syntax
IntegerGram provides some rudimentary tools for parsing
and pretty printing integers.
A primitive parser for integers is provided. To enter integer n, just
type it between parenthesis. For example:
(0) (143) (-45)
Unfortunately, Coq does not provide hooks for primitive pretty printers and
numbers are printed in their binary representation:
(##0) (##10001111) (##-101101)
If the representation of the number is incomplete, the rest of the number is
printed between brackets followed by a B and the binary representation of the
low order bits.
(POS(xI(xO(xI x)))) --> (##[x]B101)
Types
Inductive Z : Set :=
ZERO : Z | POS : positive -> Z | NEG : positive -> Z.
Inductive relation : Set :=
EGAL :relation | INFERIEUR : relation | SUPERIEUR : relation.
Inductive positive : Set :=
xI : positive -> positive
| xO : positive -> positive
| xH : positive.
Operators
- Zplus :
- Z -> Z -> Z.
- Zinv :
- Z -> Z.
- Zmult :
- Z -> Z -> Z.
- Zcompare :
- Z -> Z -> relation.
Theorems
Inverse
- Zinv_Zinv:
- (x:Z) (Zinv (Zinv x)) = x.
- Zinv_intro :
- (x,y:Z) (Zinv x) = (Zinv y) -> x = y.
- Zinv_NEG :
- (x:positive) (Zinv (NEG x)) = (POS x).
Addition
- Zero_left:
- (x:Z) (Zplus ZERO x) = x.
- Zero_right:
- (x:Z) (Zplus x ZERO) = x.
- Zplus_inverse_r:
- (x:Z) (Zplus x (Zinv x)) = ZERO.
- Zplus_inverse_l:
- (x:Z) (Zplus (Zinv x) x) = ZERO.
- Zplus_sym:
- (x,y:Z) (Zplus x y) = (Zplus y x).
- Zinv_Zplus:
- (x,y:Z) (Zinv (Zplus x y)) = (Zplus (Zinv x) (Zinv y)).
- Zplus_assoc :
-
(x,y,z:Z) (Zplus x (Zplus y z))= (Zplus (Zplus x y) z).
Multiplication
- Zmult_sym :
- (x,y:Z) (Zmult x y) = (Zmult y x).
- Zmult_assoc :
- (x,y,z:Z) (Zmult x (Zmult y z))= (Zmult (Zmult x y) z).
- Zmult_one:
- (x:Z) (Zmult (POS xH) x) = x.
- Zero_mult_left:
- (x:Z) (Zmult ZERO x) = ZERO.
- Zero_mult_right:
- (x:Z) (Zmult x ZERO) = ZERO.
- Zinv_Zmult:
- (x,y:Z) (Zmult (Zinv x) y) = (Zinv (Zmult x y)).
- Zmult_Zplus_distr:
-
(x,y,z:Z) (Zmult x (Zplus y z)) = (Zplus (Zmult x y) (Zmult x z)).
Comparison
- Zcompare_EGAL :
- (x,y:Z) (Zcompare x y) = EGAL <-> x = y.
- Zcompare_ANTISYM :
-
(x,y:Z) (Zcompare x y) = SUPERIEUR <-> (Zcompare y x) = INFERIEUR.
- Zcompare_Zinv :
-
(x,y:Z) (Zcompare x y) = (Zcompare (Zinv y) (Zinv x)).
- Zcompare_Zplus_compatible :
-
(x,y,z:Z) (Zcompare (Zplus z x) (Zplus z y)) = (Zcompare x y).
- Zcompare_trans_SUPERIEUR :
-
(x,y,z:Z) (Zcompare x y) = SUPERIEUR ->
(Zcompare y z) = SUPERIEUR ->
(Zcompare x z) = SUPERIEUR.
- SUPERIEUR_POS :
-
(x,y:Z) (Zcompare x y) = SUPERIEUR ->
(Ex [h:positive](Zplus x (Zinv y)) = (POS h)).