On this page
Verada.Lemmas.Arithmetic
Facts of integer arithmetic that a solver does not find by itself inside a larger proof, the nonlinear ones above all: order under multiplication and division, the sign and size of products, squares, quotients and remainders. Products and quotients are stated in Long_Long_Long_Integer (Big, 128 bits), so that no lemma has an overflow to rule out first.
Read the family guide for how proof treats integer arithmetic. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.
Availability and ownership
Every lemma is a ghost procedure with a null body: calling it costs nothing at run time, and its postcondition is proved, not assumed. Call one where a proof needs its fact as a step; the solver then has the fact at hand rather than having to find it.
Import and instantiate
with Verada.Lemmas.Arithmetic;import Verada.Lemmas.Arithmetic;
API 001
Big (declaration) — Long_Long_Long_Integer (128 bits), the type the lemmas state products and quotients in.
Declared interface:
subtype Big is Long_Long_Long_Integer;API 002
Lemma_Mult_Is_Monotonic (declaration) — Multiplying both sides of an order by a value that is not negative keeps it.
Declared interface:
procedure Lemma_Mult_Is_Monotonic (Val1, Val2, Val3 : Integer)
with Ghost, Global => null,
Pre => Val1 <= Val2 and Val3 >= 0,
Post => Big (Val1) * Big (Val3) <= Big (Val2) * Big (Val3);API 003
Lemma_Mult_Is_Strictly_Monotonic (declaration) — Multiplying both sides of a strict order by a positive value keeps it strict.
Declared interface:
procedure Lemma_Mult_Is_Strictly_Monotonic (Val1, Val2, Val3 : Integer)
with Ghost, Global => null,
Pre => Val1 < Val2 and Val3 > 0,
Post => Big (Val1) * Big (Val3) < Big (Val2) * Big (Val3);API 004
Lemma_Mult_Is_Antimonotonic (declaration) — Multiplying both sides of an order by a value that is not positive reverses it.
Declared interface:
procedure Lemma_Mult_Is_Antimonotonic (Val1, Val2, Val3 : Integer)
with Ghost, Global => null,
Pre => Val1 <= Val2 and Val3 <= 0,
Post => Big (Val1) * Big (Val3) >= Big (Val2) * Big (Val3);API 005
Lemma_Mult_Non_Negative (declaration) — A product of two values of the same sign is not negative.
Declared interface:
procedure Lemma_Mult_Non_Negative (Val1, Val2 : Integer)
with Ghost, Global => null,
Pre => (Val1 >= 0 and Val2 >= 0) or (Val1 <= 0 and Val2 <= 0),
Post => Big (Val1) * Big (Val2) >= 0;API 006
Lemma_Mult_Non_Positive (declaration) — A product of two values of opposite signs is not positive.
Declared interface:
procedure Lemma_Mult_Non_Positive (Val1, Val2 : Integer)
with Ghost, Global => null,
Pre => (Val1 >= 0 and Val2 <= 0) or (Val1 <= 0 and Val2 >= 0),
Post => Big (Val1) * Big (Val2) <= 0;API 007
Lemma_Mult_Abs (declaration) — The size of a product is the product of the sizes.
Declared interface:
procedure Lemma_Mult_Abs (Val1, Val2 : Integer)
with Ghost, Global => null,
Pre => Val1 > Integer'First and Val2 > Integer'First,
Post => abs (Big (Val1) * Big (Val2)) = Big (abs Val1) * Big (abs Val2);API 008
Lemma_Mult_Bounded (declaration) — A product of two values within bounds is within the product of the bounds.
Declared interface:
procedure Lemma_Mult_Bounded (Val1, Val2, Bound1, Bound2 : Integer)
with Ghost, Global => null,
Pre => Val1 in 0 .. Bound1 and Val2 in 0 .. Bound2,
Post => Big (Val1) * Big (Val2) <= Big (Bound1) * Big (Bound2);API 009
Lemma_Square_Is_Monotonic (declaration) — Squaring keeps the order of values that are not negative.
Declared interface:
procedure Lemma_Square_Is_Monotonic (Val1, Val2 : Integer)
with Ghost, Global => null,
Pre => 0 <= Val1 and Val1 <= Val2,
Post => Big (Val1) * Big (Val1) <= Big (Val2) * Big (Val2);API 010
Lemma_Square_Non_Negative (declaration) — A square is not negative.
Declared interface:
procedure Lemma_Square_Non_Negative (Val : Integer)
with Ghost, Global => null,
Post => Big (Val) * Big (Val) >= 0;API 011
Lemma_Div_Is_Monotonic (declaration) — Dividing both sides of an order by a positive value keeps it.
Declared interface:
procedure Lemma_Div_Is_Monotonic (Val1, Val2, Val3 : Integer)
with Ghost, Global => null,
Pre => Val1 <= Val2 and Val3 > 0,
Post => Val1 / Val3 <= Val2 / Val3;API 012
Lemma_Div_Is_Antimonotonic (declaration) — Dividing by a larger positive value gives no more.
Declared interface:
procedure Lemma_Div_Is_Antimonotonic (Val1, Val2, Val3 : Integer)
with Ghost, Global => null,
Pre => Val1 >= 0 and 0 < Val2 and Val2 <= Val3,
Post => Val1 / Val3 <= Val1 / Val2;API 013
Lemma_Div_Then_Mult_Bounds (declaration) — A quotient times the divisor is the dividend less the remainder, which is less than the divisor.
Declared interface:
procedure Lemma_Div_Then_Mult_Bounds (Val1, Val2 : Integer)
with Ghost, Global => null,
Pre => Val1 >= 0 and Val2 > 0,
Post => Big (Val1 / Val2) * Big (Val2) <= Big (Val1)
and Big (Val1) - Big (Val1 / Val2) * Big (Val2) < Big (Val2)
and Big (Val1 / Val2) * Big (Val2) + Big (Val1 rem Val2) = Big (Val1);API 014
Lemma_Mult_Then_Div (declaration) — Multiplying and then dividing by the same value gives the value back.
Declared interface:
procedure Lemma_Mult_Then_Div (Val1, Val2 : Integer)
with Ghost, Global => null,
Pre => Val2 /= 0 and then Big (Val1) * Big (Val2) in Big (Integer'First) .. Big (Integer'Last),
Post => (Val1 * Val2) / Val2 = Val1;API 015
Lemma_Div_Is_Smaller (declaration) — A quotient by a positive value is no larger than the dividend.
Declared interface:
procedure Lemma_Div_Is_Smaller (Val1, Val2 : Integer)
with Ghost, Global => null,
Pre => Val1 >= 0 and Val2 > 0,
Post => Val1 / Val2 <= Val1;API 016
Lemma_Mod_Range (declaration) — A value modulo a positive one is between 0 and that one less 1.
Declared interface:
procedure Lemma_Mod_Range (Val1, Val2 : Integer)
with Ghost, Global => null,
Pre => Val2 > 0,
Post => Val1 mod Val2 in 0 .. Val2 - 1;API 017
Lemma_Mod_Of_Smaller (declaration) — A value already in that range is its own remainder.
Declared interface:
procedure Lemma_Mod_Of_Smaller (Val1, Val2 : Integer)
with Ghost, Global => null,
Pre => Val2 > 0 and then Val1 in 0 .. Val2 - 1,
Post => Val1 mod Val2 = Val1;API 018
Lemma_Mod_Mult (declaration) — A multiple of a positive value has no remainder by it.
Declared interface:
procedure Lemma_Mod_Mult (Val1, Val2 : Integer)
with Ghost, Global => null,
Pre => Val2 > 0 and then Big (Val1) * Big (Val2) in Big (Integer'First) .. Big (Integer'Last),
Post => (Val1 * Val2) mod Val2 = 0;