The numbers and the search intervals of the program #
The ends of the search intervals of the command line of ratpoints-lean, as
Ratpoints.Model.CliNumbers reads, compares and joins them. strtod never reads a NaN
(Ratpoints.Cli.isNaN_strtod); outward moves a double to the side of the end that its direction
asks, and onto the largest double at most a lower end when it starts close enough to it
(Ratpoints.Cli.outward_spec); so an end that scan_end reads has a double that is not a NaN,
outward of the end (Ratpoints.Cli.inf_mem_and_isNaN_eq_false_and_le_of_run_scanEnd_eq_some). For
a word of fewer than 2 ^ 56 characters, the double of a lower end is the largest double at most
the end (Ratpoints.Cli.run_scanEnd_isMaxBelow): the parts of the word give its exact value
(Ratpoints.Cli.floatParts_bounds_and_isDigit_exponentDigits, Ratpoints.Cli.wordValue), which
lies below the successor of the double that strtod reads (Ratpoints.Cli.lt_nextUp_strtod), and
the exponent that scan_end accumulates, which stops at LONG_MAX / 20, is the exact one for the
doubles that are finite and not zero (Ratpoints.Cli.scanEndValue_eq_wordValue). The ends of a
missing -l and -u lie beyond the height bound
(Ratpoints.Cli.isFinite_heightEnd_and_le_toRat). The comparisons cmp_end and cmp_end_x
compare the values (Ratpoints.Cli.cmpEnd_neg_iff, Ratpoints.Cli.cmpEndX_neg_iff), so that the
binary search of in_region over increasing and disjoint intervals decides the membership of
x / z (Ratpoints.Cli.inRegion_spec); and join_intervals keeps what the intervals hold and,
for intervals that join well, gives intervals that the library accepts
(Ratpoints.Cli.joinIntervals_spec).
Main definitions #
Ratpoints.Cli.ExactEnd.value,Ratpoints.Cli.InExactRegion: the value of an exact end, and the exact search region of the command line.Ratpoints.Cli.scanEndValue,Ratpoints.Cli.wordValue: the end thatscan_endtakes, and the exact value of a floating constant.Ratpoints.Cli.ChainEnds: the ends of increasing and disjoint intervalsl ≤ u.Ratpoints.Cli.InPair,Ratpoints.Cli.NoNaN,Ratpoints.Cli.JoinsWell: intervals of doubles.
Main statements #
Ratpoints.Cli.outward_spec,Ratpoints.Cli.inf_mem_and_isNaN_eq_false_and_le_of_run_scanEnd_eq_some,Ratpoints.Cli.run_scanEnd_isMaxBelow,Ratpoints.Cli.isFinite_heightEnd_and_le_toRat: the doubles of the ends.Ratpoints.Cli.lt_nextUp_strtod: the exact value below the successor of the double ofstrtod.Ratpoints.Cli.inRegion_spec: the binary search.Ratpoints.Cli.joinIntervals_spec: the intervals that the library is given.
Implementation notes #
The contracts of the loops are proved with vcgen, as those of the model's other loops.
The value of an exact end of a search interval of the command line
(Ratpoints.Cli.ExactEnd): ⊥ and ⊤ for the infinite ends, and its rational number
otherwise.
Instances For
The invariant of the loop of Ratpoints.Cli.outward from the double x0 towards v, dir < 0
for a lower end, on the double x: it is not a NaN, an infinite x is that of the direction, at
the exit a finite x is on the side of v that the direction asks, and for a lower end, when v
lies below the successor of x0, every double at most v is at most x.
Equations
- One or more equations did not get rendered due to their size.
Instances For
outward moves the double x to the side of v that the direction asks, below v for a
lower end (dir < 0) and above it otherwise, and for a lower end it lands on the largest double at
most v when it starts from a double whose successor lies above v.
The number q that Ratpoints.Cli.scanEnd takes as the end that the word w denotes, x
being the double that strtod reads from it, copied from Ratpoints.Cli.scanEnd
(Ratpoints.Cli.eq_of_run_scanEnd_eq_some).
Equations
- One or more equations did not get rendered due to their size.
Instances For
An end that scan_end reads: its inf is -1, 0 or 1, its double is not a NaN, and it is
outward of the end, below a lower end and above an upper one.
The largest double below a lower end #
The digits that Ratpoints.Cli.mantissaDigits takes from s: as many after the point at most
as in all, no more than the characters of s, all digits, and the rest of s without the digits
and the points.
The exponent that scan_end accumulates, which stops taking digits once it reaches L, is the
exponent of the digits when that lies below L.
The exact value of the floating constant w that is not an infinity, from the parts of its
word (Ratpoints.Cli.floatParts): ±m 2 ^ (ex - 4 k) for a hexadecimal constant and
±m 10 ^ (ex - k) for a decimal one, for the digits m of its mantissa, the number k of them
after the point and its exponent ex, as strtod takes it.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The exact value of a floating constant lies below the successor of the finite double other
than a zero that strtod reads from it: the upper half of the faithful rounding of
Ratpoints.Double.ofRatio and Ratpoints.Double.ofDyadic
(Ratpoints.Double.lt_nextUp_and_nextDown_lt_ofRatio,
Ratpoints.Double.lt_nextUp_and_nextDown_lt_ofDyadic).
The parts of the word w (Ratpoints.Cli.floatParts): as many digits after the point at most
as in all, no more than the characters of w, all digits of the base, and the decimal digits of the
exponent when w is a floating constant that is not an infinity.
For a floating constant of fewer than 2 ^ 56 characters whose double is finite and not a
zero, the end that scan_end takes is its exact value.
When strtod reads a zero, the end that scan_end takes is 0 or ±2 ^ (-1075), below the
least positive double, the successor of the zero.
The double that scan_end gives for a lower end of fewer than 2 ^ 56 characters is the
largest double at most the end: every double at most the end is at most it.
The search region of the command line #
The rational number x lies in one of the n search intervals of the command line with the
exact ends ends: ends[2 j] ≤ x ≤ ends[2 j + 1] for some j < n.
Equations
Instances For
The values v 0, v 1, …, v (m - 1) of the ends of intervals, in turn a lower and an upper end,
increase, the upper end of each strictly below the lower end of the next, as the checks of error 7
make those of the command line.
Equations
Instances For
The invariant of the binary search of Ratpoints.Cli.inRegion for x among the n intervals
with the ends of the values v, on its state (lo, hi): the upper ends before lo lie below x,
those from hi on not, and lo = hi at the exit.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The binary search of in_region over increasing and disjoint intervals decides whether
a / b lies in one of them.
Joining the intervals #
x lies in the interval p, over the values of its ends.
Equations
- Ratpoints.Cli.InPair p x = (Ratpoints.doubleValue p.1.bits ≤ WithBotTop.coe x ∧ WithBotTop.coe x ≤ Ratpoints.doubleValue p.2.bits)
Instances For
The invariant of the loop of Ratpoints.Cli.joinIntervals over the intervals dom, after the
intervals up to the k-th, on its state (iv, n), the array of the intervals and the index of the
last interval kept.
The array has the length of
dom.The last interval kept has an index at most
k.The intervals up to the
k-th are among those ofdom.The intervals after the
k-th are those ofdom.The intervals kept,
iv[0]toiv[n], have no NaN.The intervals kept hold every interval of
domup to thek-th.- wellJoined : JoinsWell dom → (∀ j ≤ n, doubleValue iv[j]!.1.bits ≤ doubleValue iv[j]!.2.bits) ∧ (∀ j < n, doubleValue iv[j]!.2.bits < doubleValue iv[j + 1]!.1.bits) ∧ (n ≠ 0 → ∀ (i : ℕ), k < i → i < dom.length → doubleValue iv[n]!.1.bits ≤ doubleValue dom[i]!.1.bits)
For intervals that join well, the intervals kept have
l ≤ uand are increasing and strictly apart, and the lower end of the last one, when it is not the first, is at most those of the intervals ofdomafter thek-th.
Instances For
The order of the intervals kept by the loop of Ratpoints.Cli.joinIntervals after the next
interval is joined to the last one kept, p, the least lower and the greatest upper end.
The order of the intervals kept by the loop of Ratpoints.Cli.joinIntervals after the next
interval, which lies above the last one kept, is kept after it.
A step of the loop of Ratpoints.Cli.joinIntervals that joins the next interval to the last
one kept: the slot of that one holds the least lower and the greatest upper end.
join_intervals keeps the search intervals of the command line, without NaN: it gives none
exactly when there are none, the intervals it gives hold the values of the intervals it joins, and
for intervals that join well (with l ≤ u and the lower ends increasing from the second on) the
intervals it gives have l ≤ u and are increasing and strictly apart.