On this page
Verada.Lemmas.Floating_Point
What rounding to nearest preserves, for Float and Long_Float: order under addition, subtraction and multiplication by a value of known sign, and exact conversion of whole numbers in the significand's range.
Read the family guide for how floating-point proof works. 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. The error model already knows that rounding is monotone and that whole numbers in the significand's range convert exactly, so most proofs need no call; a call states the fact by name where a proof wants it as a step.
Import and instantiate
with Verada.Lemmas.Floating_Point;import Verada.Lemmas.Floating_Point;
API 001
Lemma_Add_Is_Monotonic (declaration) — Adding the same value to both sides of an order keeps it: Val1 + Val3 <= Val2 + Val3 from Val1 <= Val2, operands bounded so nothing overflows.
Declared interface:
procedure Lemma_Add_Is_Monotonic (Val1, Val2, Val3 : Float)
with Ghost, Global => null,
Pre => Val1 <= Val2 and abs Val1 <= Float'Last / 2.0 and abs Val2 <= Float'Last / 2.0
and abs Val3 <= Float'Last / 2.0,
Post => Val1 + Val3 <= Val2 + Val3;API 002
Lemma_Sub_Is_Monotonic (declaration) — Subtracting the same value from both sides of an order keeps it.
Declared interface:
procedure Lemma_Sub_Is_Monotonic (Val1, Val2, Val3 : Float)
with Ghost, Global => null,
Pre => Val1 <= Val2 and abs Val1 <= Float'Last / 2.0 and abs Val2 <= Float'Last / 2.0
and abs Val3 <= Float'Last / 2.0,
Post => Val1 - Val3 <= Val2 - Val3;API 003
Lemma_Mul_Is_Monotonic (declaration) — Multiplying both sides of an order by a non-negative value keeps it.
Declared interface:
procedure Lemma_Mul_Is_Monotonic (Val1, Val2, Val3 : Float)
with Ghost, Global => null,
Pre => Val1 <= Val2 and Val3 >= 0.0 and abs Val1 <= 1.0E15 and abs Val2 <= 1.0E15
and Val3 <= 1.0E15,
Post => Val1 * Val3 <= Val2 * Val3;API 004
Lemma_Mul_Is_Antimonotonic (declaration) — Multiplying both sides of an order by a non-positive value reverses it.
Declared interface:
procedure Lemma_Mul_Is_Antimonotonic (Val1, Val2, Val3 : Float)
with Ghost, Global => null,
Pre => Val1 <= Val2 and Val3 <= 0.0 and abs Val1 <= 1.0E15 and abs Val2 <= 1.0E15
and Val3 >= -1.0E15,
Post => Val1 * Val3 >= Val2 * Val3;API 005
Lemma_Integer_To_Float_Exact (declaration) — A whole number within the significand's range (224 for Float, 253 for Long_Float) converts to the float type and back unchanged.
Declared interface:
procedure Lemma_Integer_To_Float_Exact (N : Integer)
with Ghost, Global => null,
Pre => N in -2 ** 24 .. 2 ** 24,
Post => Integer (Float (N)) = N;API 006
Lemma_Add_Is_Monotonic (declaration) — Adding the same value to both sides of an order keeps it: Val1 + Val3 <= Val2 + Val3 from Val1 <= Val2, operands bounded so nothing overflows.
Declared interface:
procedure Lemma_Add_Is_Monotonic (Val1, Val2, Val3 : Long_Float)
with Ghost, Global => null,
Pre => Val1 <= Val2 and abs Val1 <= Long_Float'Last / 2.0 and abs Val2 <= Long_Float'Last / 2.0
and abs Val3 <= Long_Float'Last / 2.0,
Post => Val1 + Val3 <= Val2 + Val3;API 007
Lemma_Sub_Is_Monotonic (declaration) — Subtracting the same value from both sides of an order keeps it.
Declared interface:
procedure Lemma_Sub_Is_Monotonic (Val1, Val2, Val3 : Long_Float)
with Ghost, Global => null,
Pre => Val1 <= Val2 and abs Val1 <= Long_Float'Last / 2.0 and abs Val2 <= Long_Float'Last / 2.0
and abs Val3 <= Long_Float'Last / 2.0,
Post => Val1 - Val3 <= Val2 - Val3;API 008
Lemma_Mul_Is_Monotonic (declaration) — Multiplying both sides of an order by a non-negative value keeps it.
Declared interface:
procedure Lemma_Mul_Is_Monotonic (Val1, Val2, Val3 : Long_Float)
with Ghost, Global => null,
Pre => Val1 <= Val2 and Val3 >= 0.0 and abs Val1 <= 1.0E150 and abs Val2 <= 1.0E150
and Val3 <= 1.0E150,
Post => Val1 * Val3 <= Val2 * Val3;API 009
Lemma_Mul_Is_Antimonotonic (declaration) — Multiplying both sides of an order by a non-positive value reverses it.
Declared interface:
procedure Lemma_Mul_Is_Antimonotonic (Val1, Val2, Val3 : Long_Float)
with Ghost, Global => null,
Pre => Val1 <= Val2 and Val3 <= 0.0 and abs Val1 <= 1.0E150 and abs Val2 <= 1.0E150
and Val3 >= -1.0E150,
Post => Val1 * Val3 >= Val2 * Val3;API 010
Lemma_Integer_To_Float_Exact (declaration) — A whole number within the significand's range (224 for Float, 253 for Long_Float) converts to the float type and back unchanged.
Declared interface:
procedure Lemma_Integer_To_Float_Exact (N : Long_Long_Integer)
with Ghost, Global => null,
Pre => N in -2 ** 53 .. 2 ** 53,
Post => Long_Long_Integer (Long_Float (N)) = N;