QInterval — Rational Interval Arithmetic with ℝ Containment #
Closed intervals [lo, hi] over ℚ, with proofs that arithmetic operations
preserve ℝ containment. This is the foundation for the rsa_decide tactic:
- Reify an ℝ expression into a tree of
QIntervaloperations - Evaluate the tree to get a concrete
[lo, hi](computable ℚ) - Check separation
b.hi < a.lo(decidable on ℚ) - Conclude
a > bon ℝ viagt_of_separated
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Zero-width interval [q, q].
Equations
- Linglib.Interval.QInterval.exact q = { lo := q, hi := q, valid := ⋯ }
Instances For
Containment for (0 : ℝ). Uses the literal 0 so the proof type mentions
@OfNat.ofNat ℝ 0 _ (= @Zero.zero ℝ _), matching expressions directly.
Containment for (1 : ℝ). Uses the literal 1 so the proof type mentions
@OfNat.ofNat ℝ 1 _ (= @One.one ℝ _), avoiding the Nat.cast 1 = 0 + 1
mismatch that breaks nested proof terms.
Containment for natural number literals ≥ 2 cast via Nat.cast.
For n ≥ 2, @OfNat.ofNat ℝ n _ is definitionally equal to @Nat.cast ℝ _ n
(via Mathlib's instOfNat). For n = 0, 1, use exact_zero_containsReal /
exact_one_containsReal instead (since Nat.cast 1 ≢ OfNat.ofNat 1).
General interval multiplication via 4-corner method.
For intervals [a, b] and [c, d], the product interval is
[min(ac, ad, bc, bd), max(ac, ad, bc, bd)].
Handles arbitrary signs (unlike mulNonneg which requires both nonneg).
Equations
Instances For
Containment for general interval multiplication.
For a.lo ≤ x ≤ a.hi and b.lo ≤ y ≤ b.hi, x·y lies between
min(corners) and max(corners) since extrema of a bilinear function
on a rectangle occur at corners.
Key theorem: interval separation implies ℝ strict ordering.
If a.hi ≤ b.lo, then x ≤ y. Dual of gt_of_separated.
Interval separation implies ≥.
Two exact intervals at the same point imply equality.
If the condition is known false, take the else branch.
If the condition is known true, take the then branch.
Decidable.rec with condition known true → take the isTrue branch.
Handles the case where ite has been unfolded to Decidable.rec by whnf.
Decidable.rec with condition known false → take the isFalse branch.
If an interval has positive lower bound, the contained value is positive.
If an interval has positive lower bound, the contained value is nonzero.
If an interval has nonneg lower bound and nonpos upper bound, the value is zero.
Used by the tactic to prove x = 0 when the interval is [0, 0].
If an interval has lo = 0 and hi = 0, the contained value equals zero.
If x is in a zero interval, x * y is in the zero interval.
If y is in a zero interval, x * y is in the zero interval.
If x is in a zero interval, x / y is in the zero interval.
Transport containment along a real-valued equality.
If y = x and the interval contains x, it contains y.
Containment for x ^ n (nat power) with nonneg base.
Raise an interval to a natural power. No proof obligation — checks nonneg
at runtime and uses rpowNat for sound computation, fallback otherwise.
Equations
- One or more equations did not get rendered due to their size.
Instances For
If a real value is contained in an interval with lo = 0 and hi = 0, the value equals zero.
Maximum bit length for rational numerator/denominator. 64 bits ≈ 19 decimal digits, enough precision for RSA comparisons.
Equations
Instances For
Widen an interval to bounded-precision rationals. Sound: only makes the interval wider, so containment is preserved.
Equations
- I.coarsen bits = { lo := Linglib.Interval.QInterval.truncDown✝ I.lo bits, hi := Linglib.Interval.QInterval.truncUp✝ I.hi bits, valid := ⋯ }