Tactic

cega

Proves numerical bounds: inequalities on a box of real variables, closed constants and interval integrals.

cega
proves a numerical bound: an inequality on real variables that the hypotheses bound by rationals, a bound on a closed constant, or a bound on an interval integral.
cega (prec := n) (depth := n) (panels := n)
the same with the precision, the depth of subdivision and the number of integration panels set by hand.
cega [fast]
tries finite certificates first, checked by compiled code when cega.nativeCertificates is on, and is bare cega otherwise.
cega [use_floats]
rounds enclosure endpoints outward into binary64. cega [use_floats] (arith := F) chooses the IEEE format F, and cega [use_floats := false] selects exact rational endpoints.
cega [batch := n]
proves a goal ∀ i : Fin m, p i by checking n indices at a time in the kernel.
cega [fast, batch := n]
the same, with the batches checked by compiled code when cega.nativeCertificates is on.

cega is the tactic I use for numbers. A bound like sinx≤0.85 for x∈[0,1] is true, obvious from a plot and tedious to prove by hand. cega encloses the expression on the box that your hypotheses describe, compares the enclosure with the bound by exact rational arithmetic, and hands the kernel a certificate for the whole argument.

The name is short for certified enclosures, guarantees and approximations.

Details and Options

  • The goal is a bound: f≤c, f<c, c≤f, |f|≤c, a two-sided bound, f ∈ Set.Icc a b (also Ioo, Ico, Ioc), f≤g, or a conjunction of these.
  • Every real variable needs rational bounds among the hypotheses: a ≤ x and x ≤ b, x ∈ Set.Icc a b, or |x| ≤ r. A goal without variables needs none.
  • When the first enclosure is too weak, the box is cut in halves, by default to depth 2. (depth := n) sets that depth.
  • A bound on one interval integral with rational limits, such as ∫abf≤c or |∫abf−c|≤ε, uses Simpson panels when the first four derivatives of f are certified on [a,b], and range panels, which need only continuity, otherwise. The number of panels doubles up to cega.maxIntegrationPanels, by default 256, and (panels := n) fixes it.
  • A real inequality that the box route does not prove goes to FloatLib’s interval, which reads the bounds in the hypotheses itself and is not limited by cega.maxDimension. It also proves bounds on finite sums, and it bounds a trigonometric polynomial in one variable by its coefficients, with no bounds on the variable. With floats on, it is not run, since it computes with exact rationals.
  • A closed goal that these routes refuse is tried with the tactic dyadic_interval at 32 bits, or at the bits of (prec := n).
  • The certificate propositions EnclosedOn, BoundOn and ApproxOn of SymLean are goals too.
  • The functions are those of N, written as Mathlib terms such as Real.sin x and Real.sqrt x. The box route takes at most 8 variables (cega.maxDimension).
  • set_option cega.nativeCertificates true lets the fast forms check finite certificates with compiled code. That also trusts Lean’s compiler, so it is off by default and every check stays in the kernel.
  • [use_floats] rounds each lower endpoint toward −∞ and each upper endpoint toward +∞ into binary64, and the kernel evaluates every operation. (arith := F) selects another IEEE binary format of FloatLib, such as binary32, binary128, FloatFormat.ieee 15 112 or "binary(p := 113, emax := 16383)", and turns floats on by itself. The flag shares its bracket group with fast, as in cega [fast, use_floats].
  • set_option cega.arithmetic "binary64" sets the default arithmetic. A call can override it: cega [use_floats := false] and the explicit query with (arith := "exact") both use exact endpoints. Certificates shows how to set the default in Lake.
  • When the goal states its bound with numerals, bare cega first tries FloatLib’s check, a refutation of the negation of the bound that bisects the box where it needs to, within cega.maxRefinementWork evaluations, and then the box query. With floats on, the query is the plain interval evaluation, on a uniform subdivision of depth (depth := n). In a float format neither has the monotonicity argument of the exact planner, so a sharp bound needs some room or a larger depth. A bound on an integral is computed with exact rationals and is not run. A float call that does not prove its goal fails with the format and the reason, and never computes with rationals in its place.
  • cega [batch := n] and cega [fast, batch := n] need import CAS.Numerics.Tactic.
  • A false bound, or a true one that the enclosures do not reach, is refused, and the message proposes the next call to try.

Examples (27)#

Basic Examples (3)

A bound on a box, from the hypotheses on x:

In[1]:=
example (x : ℝ) (h₀ : 0 ≤ x) (h₁ : x ≤ 1) : Real.sin x ≤ 0.85 := by
  cega
Out[1]=

Lean accepts the proof.


A bound on a constant:

In[2]:=
example : Real.exp 1 ≤ 2.72 := by
  cega
Out[2]=

Lean accepts the proof.


A bound on an integral with no elementary antiderivative:

In[3]:=
example : (∫ x in (0 : ℝ)..1, Real.exp (-x ^ 2)) ≤ 3 / 4 := by
  cega
Out[3]=

Lean accepts the proof.

Scope (5)

A strict two-sided bound, and membership in an open interval:

In[4]:=
example (x : ℝ) (h0 : 0 ≤ x) (h1 : x ≤ 1) : 0 < x * (1 - x) + 1 ∧ x * (1 - x) + 1 < 2 := by
  cega
Out[4]=

Lean accepts the proof.

In[5]:=
example (x : ℝ) (h0 : 0 ≤ x) (h1 : x ≤ 1) : x * (1 - x) ∈ Set.Ioo (-1 : ℝ) 1 := by
  cega
Out[5]=

Lean accepts the proof.


Several bounds at once. The three expressions differ, so each bound is proved on its own:

In[6]:=
example (x : ℝ) (h0 : 0 ≤ x) (h1 : x ≤ 1) :
    0 ≤ x / (1 + x) ∧ Real.exp x ≤ 3 ∧ |Real.sin x| < 1 := by
  cega
Out[6]=

Lean accepts the proof.


A hypothesis |x| ≤ r gives the box [−r,r]. Here it also keeps the denominator away from zero:

In[7]:=
example (x : ℝ) (hx : |x| ≤ 1 / 2) : 1 / (1 - x) ≤ 2 := by
  cega
Out[7]=

Lean accepts the proof.


A trigonometric polynomial needs no bounds on its variable. FloatLib’s interval bounds sinx+12cos2x by its coefficients, 1+12:

In[8]:=
example (x : ℝ) : Real.sin x + Real.cos (2 * x) / 2 ≤ 3 / 2 := by
  cega
Out[8]=

Lean accepts the proof.


Integrals with the limits reversed, and with an integrand that has a corner:

In[9]:=
example : (∫ x in (1 : ℝ)..0, Real.exp x) < -1 := by
  cega
Out[9]=

Lean accepts the proof.

In[10]:=
example : 1 / 2 < ∫ x in (-1 : ℝ)..1, |x| := by
  cega
Out[10]=

Lean accepts the proof.

Options (6)

(panels := 2) fixes the number of Simpson panels instead of doubling them:

In[11]:=
example : |(∫ x in (0 : ℝ)..1, Real.exp x) - 17182818 / 10000000| ≤ 1 / 10000 := by
  cega (panels := 2)
Out[11]=

Lean accepts the proof.


(depth := 3) allows the box to be cut in halves to depth 3:

In[12]:=
example (x : ℝ) (h0 : 0 ≤ x) (h1 : x ≤ 1) : x * (1 - x) ≤ 1 / 4 := by
  cega (depth := 3)
Out[12]=

Lean accepts the proof.


cega [fast] with the default settings is bare cega, checked in the kernel:

In[13]:=
example (x : ℝ) (h0 : 0 ≤ x) (h1 : x ≤ 1) : x * x ≤ 1 := by
  cega [fast]
Out[13]=

Lean accepts the proof.


[use_floats] computes the same bound with binary64 floats, and (arith := binary128) with binary128:

In[14]:=
example (x : ℝ) (h₀ : 0 ≤ x) (h₁ : x ≤ 1) : Real.exp x ≤ 2.72 := by
  cega [use_floats]
Out[14]=

Lean accepts the proof.

In[15]:=
example (x : ℝ) (h₀ : 0 ≤ x) (h₁ : x ≤ 1) : Real.exp x ≤ 2.72 := by
  cega (arith := binary128)
Out[15]=

Lean accepts the proof.


With floats, (depth := 5) evaluates the sine on 32 pieces of [0,1]:

In[16]:=
example (x : ℝ) (h₀ : 0 ≤ x) (h₁ : x ≤ 1) : Real.sin x ≤ 0.85 := by
  cega [use_floats] (depth := 5)
Out[16]=

Lean accepts the proof.


A finite statement, checked three indices at a time, and then four at a time with the fast form:

In[17]:=
example : ∀ i : Fin 10, i.val * i.val < 100 := by
  cega [batch := 3]
Out[17]=

Lean accepts the proof.

In[18]:=
example : ∀ i : Fin 10, i.val * i.val < 100 := by
  cega [fast, batch := 4]
Out[18]=

Lean accepts the proof.

Applications (2)

cega proves the numerical fact and linarith finishes. Only the three standard axioms are used:

In[19]:=
theorem cega_sin_lt_one (x : ℝ) (h₀ : 0 ≤ x) (h₁ : x ≤ 1) : Real.sin x < 1 := by
  have h : Real.sin x ≤ 17 / 20 := by cega
  linarith

#print axioms cega_sin_lt_one
Out[19]=

cega_sin_lt_one depends on the axioms propext, Classical.choice, Quot.sound.


The digits that N prints, as a bound:

In[20]:=
example : Real.sqrt 2 ≤ 1.415 := by
  cega
Out[20]=

Lean accepts the proof.

Properties and Relations (3)

cega? proves the goal and tells you the explicit query that did it:

In[21]:=
example (x : ℝ) (h₀ : 0 ≤ x) (h₁ : x ≤ 1) : Real.sin x ≤ 0.85 := by
  cega?
Out[21]=

Try this

cega

Lean checked the suggested replacement against the original goal. Selected route: CEGA route: checked box enclosure of an ordinary inequality, arithmetic: exact rationals.

That query is the one enclose runs, and it prints the interval behind the proof:

In[22]:=
#cas [enclose x in [0, 1]] (sin x)
Out[22]=

certified interval in ℝ

[0, 0.841471]
[0, 0.841471]
Domain
x ∈ [0, 1] ⊆ ℝ
Upper bound
0.841471
Absolute bound
0.841471
Center and radius
≈0.420735 ± 0.420736

Checked by Lean’s kernel: Enclosure of the input

∀ x ∈ Set.Icc 0 1, 0 ≤ Real.sin x ∧ Real.sin x ≤ 0.841471

from CAS.Tactic.BoxInequality.mem_of_enclosedOn_box

The certificate: 8 checked steps
  1. Enclosure of the input

    ∀ x ∈ Set.Icc 0 1, 0 ≤ Real.sin x ∧ Real.sin x ≤ 0.841471

    Checked by Lean’s kernel · CAS.Tactic.BoxInequality.mem_of_enclosedOn_box

  2. Upper bound of the input

    ∀ x ∈ Set.Icc 0 1, Real.sin x ≤ 0.841471

    Checked by Lean’s kernel · CAS.Tactic.BoxInequality.le_of_boundOn_box

  3. Absolute bound of the input

    ∀ x ∈ Set.Icc 0 1, |Real.sin x| ≤ 0.841471

    Checked by Lean’s kernel · CAS.Tactic.BoxInequality.abs_le_of_boundOn_abs_box

  4. Center and radius of the input

    ∀ x ∈ Set.Icc 0 1, |Real.sin x - 0.420735| ≤ 0.420736

    Checked by Lean’s kernel · CAS.Tactic.BoxInequality.abs_sub_le_of_approxOn_box

  5. Certified enclosure

    CAS.Certificate.EnclosedOn (CAS.Exact.exprFn 𝕏[0].sin)
      (CAS.Continuum.RationalInterval.boxDomain fun coordinate ↦
        [CAS.Continuum.RationalInterval.ofBounds 0 1 ⋯].get coordinate)
      (↑0 / ↑1) (↑286337738405724074564845076175058320435 / ↑340282366920938463463374607431768211456)

    Checked by Lean’s kernel · CAS.Continuum.RationalInterval.EnclosureAttempt.enclosedOn_of_interval_eq

  6. Certified upper bound

    CAS.Certificate.BoundOn (CAS.Exact.exprFn 𝕏[0].sin)
      (CAS.Continuum.RationalInterval.boxDomain fun coordinate ↦
        [CAS.Continuum.RationalInterval.ofBounds 0 1 ⋯].get coordinate)
      (↑286337738405724074564845076175058320435 / ↑340282366920938463463374607431768211456)

    Checked by Lean’s kernel · CAS.Continuum.RationalInterval.EnclosureAttempt.boundOn_of_interval_eq

  7. Certified absolute bound

    CAS.Certificate.BoundOn (fun x ↦ |CAS.Exact.exprFn 𝕏[0].sin x|)
      (CAS.Continuum.RationalInterval.boxDomain fun coordinate ↦
        [CAS.Continuum.RationalInterval.ofBounds 0 1 ⋯].get coordinate)
      (↑286337738405724074564845076175058320435 / ↑340282366920938463463374607431768211456)

    Checked by Lean’s kernel · CAS.Continuum.RationalInterval.EnclosureAttempt.boundOn_abs_of_interval_eq

  8. Certified center and radius

    CAS.Certificate.ApproxOn (CAS.Exact.exprFn 𝕏[0].sin)
      (fun x ↦ ↑286337738405724074564845076175058320435 / ↑680564733841876926926749214863536422912)
      (CAS.Continuum.RationalInterval.boxDomain fun coordinate ↦
        [CAS.Continuum.RationalInterval.ofBounds 0 1 ⋯].get coordinate)
      (↑286337738405724074564845076175058320435 / ↑680564733841876926926749214863536422912)

    Checked by Lean’s kernel · CAS.Continuum.RationalInterval.EnclosureAttempt.approxOn_center_of_interval_eq

The computation
  • Coordinates: x
    Certified domain: x ∈ [0, 1] ⊆ ℝ
  • Certified numerical guarantee

    Guarantee: the input lies in the output interval throughout the box
    Decimal preview: outward-rounded to 6 places where it is a bound
    Exact certified output: [0, 286337738405724074564845076175058320435/340282366920938463463374607431768211456]

cas tries the same box route on ordinary inequalities:

In[23]:=
example (x : ℝ) (h₀ : 0 ≤ x) (h₁ : x ≤ 1) : Real.sin x ≤ 0.85 := by
  cas
Out[23]=

Lean accepts the proof.

Possible Issues (6)

A false bound is refused. Here sin1>0.84:

In[24]:=
example (x : ℝ) (h₀ : 0 ≤ x) (h₁ : x ≤ 1) : Real.sin x ≤ 0.8 := by
  cega
Out[24]=

Error

cega box route: comparison with the stated bound: the certified value does not give the stated bound.
  ↑286337738405724074564845076175058320435 / ↑340282366920938463463374607431768211456 ≤ 0.8
Exact rational arithmetic did not close this comparison.
The query run was `cega [enclose x in [0, 1]]
    (Real.sin
      x)`; its certified upper bound 286337738405724074564845076175058320435/340282366920938463463374607431768211456 may be too weak for the stated bound. If the bound is true, a deeper subdivision or a higher precision may prove it, as in `cega (depth := 4)` or `cega (prec := 24)`. FloatLib's check, which `cega` tries first, evaluates at most 4096 pieces of the box and cuts a branch at most 32 times.
The rest of the message
Subdivision to depth 2 (`cega (depth := 2) [enclose x in [0, 1]] (Real.sin x)`) did not prove it either:
  cega box route: comparison with the stated bound: the certified value does not give the stated bound.
    ↑286337738405724074564845076175058320435 / ↑340282366920938463463374607431768211456 ≤ 0.8
  Exact rational arithmetic did not close this comparison.
Other routes:
  carrier search:
    cega found no registered checked carrier or direct certificate matching the target
  interval route:
    interval could not certify: on the original box, the expression is enclosed by [-3784231770697581387/4611686018427387904, 1654908495459613035/9223372036854775808]; its upper endpoint does not establish ≤ 0.
    Box: x in [0, 1]. Verification used subdivision depth 8. Try tighter input bounds, more subdivision, or higher approximation settings.
    The coefficient route did not prove it either: interval: the coefficients alone give the range [-1, 1] for the polynomial, which does not prove the goal; a sharp bound takes a sum-of-squares certificate `(upper := h)`, which `scripts/coeff_cert.py` finds
Bare `cega` proves an ordinary real inequality (`f x ≤ c`, `f x < c`, `c ≤ f x`, `c < f x` (also with `≥` and `>`), `|f x| ≤ c`, `|f x| < c`, `a ≤ f x ∧ f x ≤ b` (also with `<`), `f x ∈ Set.Icc a b` (also `Set.Ioo`, `Set.Ico`, `Set.Ioc`), `f x ≤ g x`, `f x < g x`, and conjunctions of these, with `c`, `a`, `b` closed and every real variable bounded by hypotheses `a ≤ x` and `x ≤ b`, `x ∈ Set.Icc a b`, or `|x| ≤ r` with rational literal endpoints), a bound on an interval integral `∫ x in a..b, f x` with rational limits, a certificate goal (`EnclosedOn f s lo hi`, `BoundOn f s c`, `ApproxOn f g s ε`, `ResidualBound r s ε`) on a coordinate box or from a checked carrier in the local context or the goal, a closed decidable statement about floats, which `float_decide` decides, a real inequality that FloatLib's `interval` proves, on finite sums and norms too, and a closed goal that interval evaluation proves.

No hypothesis bounds x here, so there is no box. The bound holds for every real x, since x(1−x)=14−(x−12)2, and nlinarith [sq_nonneg (x - 1 / 2)] proves it:

In[25]:=
example (x : ℝ) : x * (1 - x) ≤ 1 / 4 := by
  cega
Out[25]=

Error

cega box route: no rational bounds on `x` in the hypotheses; the route needs hypotheses `a ≤ x` and `x ≤ b`, `x ∈ Set.Icc a b`, or `|x| ≤ r` with rational literal endpoints
Other routes:
  carrier search:
    cega found no registered checked carrier or direct certificate matching the target
  interval route:
    interval needs a rational lower bound for x
Bare `cega` proves an ordinary real inequality (`f x ≤ c`, `f x < c`, `c ≤ f x`, `c < f x` (also with `≥` and `>`), `|f x| ≤ c`, `|f x| < c`, `a ≤ f x ∧ f x ≤ b` (also with `<`), `f x ∈ Set.Icc a b` (also `Set.Ioo`, `Set.Ico`, `Set.Ioc`), `f x ≤ g x`, `f x < g x`, and conjunctions of these, with `c`, `a`, `b` closed and every real variable bounded by hypotheses `a ≤ x` and `x ≤ b`, `x ∈ Set.Icc a b`, or `|x| ≤ r` with rational literal endpoints), a bound on an interval integral `∫ x in a..b, f x` with rational limits, a certificate goal (`EnclosedOn f s lo hi`, `BoundOn f s c`, `ApproxOn f g s ε`, `ResidualBound r s ε`) on a coordinate box or from a checked carrier in the local context or the goal, a closed decidable statement about floats, which `float_decide` decides, a real inequality that FloatLib's `interval` proves, on finite sums and norms too, and a closed goal that interval evaluation proves.

Too few panels. The message gives the interval that the search proposes and the call to try next:

In[26]:=
example : |(∫ x in (0 : ℝ)..1, Real.exp x) - 17182818 / 10000000| ≤ 1 / 10000 := by
  cega (panels := 1)
Out[26]=

Error

cega: with 1 Simpson panel the search proposes [1.717917, 1.719805] for the integral, an interval of width less than 1.9e-3 that does not prove the stated bound. Each doubling of the panels divides the Simpson remainder by 16; try `cega (panels := 2)`.
The rest of the message
Other routes:
  carrier search:
    cega found no registered checked carrier or direct certificate matching the target
  box route:
    cega box route: unsupported closed subterm
      ∫ (x : ℝ) in 0..1, Real.exp x
    The checked elementary expression language cannot evaluate this subterm, and no rational enclosure of it was supplied by hypotheses.
  interval route:
    interval needs a rational lower bound for ∫ (x : ℝ) in 0..1, Real.exp x
  dyadic_interval route:
    The proposition was not proven true or false.
Bare `cega` proves an ordinary real inequality (`f x ≤ c`, `f x < c`, `c ≤ f x`, `c < f x` (also with `≥` and `>`), `|f x| ≤ c`, `|f x| < c`, `a ≤ f x ∧ f x ≤ b` (also with `<`), `f x ∈ Set.Icc a b` (also `Set.Ioo`, `Set.Ico`, `Set.Ioc`), `f x ≤ g x`, `f x < g x`, and conjunctions of these, with `c`, `a`, `b` closed and every real variable bounded by hypotheses `a ≤ x` and `x ≤ b`, `x ∈ Set.Icc a b`, or `|x| ≤ r` with rational literal endpoints), a bound on an interval integral `∫ x in a..b, f x` with rational limits, a certificate goal (`EnclosedOn f s lo hi`, `BoundOn f s c`, `ApproxOn f g s ε`, `ResidualBound r s ε`) on a coordinate box or from a checked carrier in the local context or the goal, a closed decidable statement about floats, which `float_decide` decides, a real inequality that FloatLib's `interval` proves, on finite sums and norms too, and a closed goal that interval evaluation proves.
CEGA finite certificate could not certify a checked computation: the kernel did not reduce the decision procedure of
  |(∫ (x : ℝ) in 0..1, Real.exp x) - 17182818 / 10000000| ≤ 1 / 10000
to `true`. Its decision procedure mentions `Real.decidableLE`, which is classical and never reduces in the kernel. Whether or not that is what stopped this check, the failure says nothing about the truth of the statement.

An overflow. 10200 fits within binary64’s finite range but its square does not, so the call fails and names the format. cega (arith := binary128) and plain cega prove this bound:

In[27]:=
example : (10 : ℝ) ^ 200 * 10 ^ 200 ≤ 10 ^ 401 := by
  cega [use_floats]
Out[27]=

Error

cega box route: the query `cega (arith := binary64) [enclose]
    (10 ^ 200 *
      10 ^
        200)` found no certificate: the binary64 evaluation found no enclosure: the enclosure of a product has an end beyond the largest finite binary64 number (overflow). A wider format, as in `(arith := binary128)`, or exact arithmetic, `cega [use_floats := false]`, may prove it.
The rest of the message
Other routes:
  carrier search:
    cega found no registered checked carrier or direct certificate matching the target
  interval route:
    cega interval route: FloatLib's `interval` computes with exact rationals, so it is not run in binary64 arithmetic. `cega [use_floats := false]` runs it.
  dyadic_interval route:
    `dyadic_interval` computes with exact dyadic rationals, so it is not run in binary64 arithmetic. `cega [use_floats := false]` runs it.
Bare `cega` proves an ordinary real inequality (`f x ≤ c`, `f x < c`, `c ≤ f x`, `c < f x` (also with `≥` and `>`), `|f x| ≤ c`, `|f x| < c`, `a ≤ f x ∧ f x ≤ b` (also with `<`), `f x ∈ Set.Icc a b` (also `Set.Ioo`, `Set.Ico`, `Set.Ioc`), `f x ≤ g x`, `f x < g x`, and conjunctions of these, with `c`, `a`, `b` closed and every real variable bounded by hypotheses `a ≤ x` and `x ≤ b`, `x ∈ Set.Icc a b`, or `|x| ≤ r` with rational literal endpoints), a bound on an interval integral `∫ x in a..b, f x` with rational limits, a certificate goal (`EnclosedOn f s lo hi`, `BoundOn f s c`, `ApproxOn f g s ε`, `ResidualBound r s ε`) on a coordinate box or from a checked carrier in the local context or the goal, a closed decidable statement about floats, which `float_decide` decides, a real inequality that FloatLib's `interval` proves, on finite sums and norms too, and a closed goal that interval evaluation proves.

Thirty digits of 2 are more than binary64 has. cega (arith := binary128) proves this one:

In[28]:=
example : Real.sqrt 2 ≤ 1.41421356237309504880168872421 := by
  cega [use_floats]
Out[28]=

Error

cega box route: comparison with the stated bound: the certified value does not give the stated bound.
  ↑6369051672525773 / ↑4503599627370496 ≤ 1.41421356237309504880168872421
Exact rational arithmetic did not close this comparison.
The query run was `cega (arith := binary64) [enclose]
    (√2)`; its certified upper bound 6369051672525773/4503599627370496 may be too weak for the stated bound. The goal has no variables, so subdivision does not apply, and the arithmetic is binary64. A wider format, as in `(arith := binary128)`, or exact arithmetic, `cega [use_floats := false]`, may prove it.
The rest of the message
Other routes:
  carrier search:
    cega found no registered checked carrier or direct certificate matching the target
  interval route:
    cega interval route: FloatLib's `interval` computes with exact rationals, so it is not run in binary64 arithmetic. `cega [use_floats := false]` runs it.
  dyadic_interval route:
    `dyadic_interval` computes with exact dyadic rationals, so it is not run in binary64 arithmetic. `cega [use_floats := false]` runs it.
Bare `cega` proves an ordinary real inequality (`f x ≤ c`, `f x < c`, `c ≤ f x`, `c < f x` (also with `≥` and `>`), `|f x| ≤ c`, `|f x| < c`, `a ≤ f x ∧ f x ≤ b` (also with `<`), `f x ∈ Set.Icc a b` (also `Set.Ioo`, `Set.Ico`, `Set.Ioc`), `f x ≤ g x`, `f x < g x`, and conjunctions of these, with `c`, `a`, `b` closed and every real variable bounded by hypotheses `a ≤ x` and `x ≤ b`, `x ∈ Set.Icc a b`, or `|x| ≤ r` with rational literal endpoints), a bound on an interval integral `∫ x in a..b, f x` with rational limits, a certificate goal (`EnclosedOn f s lo hi`, `BoundOn f s c`, `ApproxOn f g s ε`, `ResidualBound r s ε`) on a coordinate box or from a checked carrier in the local context or the goal, a closed decidable statement about floats, which `float_decide` decides, a real inequality that FloatLib's `interval` proves, on finite sums and norms too, and a closed goal that interval evaluation proves.

A batch that fails names its indices. A failed batch is not a counterexample. Either the check did not reduce to true, as here, or the kernel reached its recursion limit, and then the message proposes a larger maxRecDepth or smaller batches:

In[29]:=
example : ∀ i : Fin 2, i.val = 0 := by
  cega [batch := 1]
Out[29]=

Error

cega [batch := 1] could not certify batch 2 of 2, the indices i with 1 ≤ i < 2, of
  ∀ (i : Fin 2), ↑i = 0
The kernel did not reduce the check of this batch to `true`: the statement may be false for an index in this range, or its decision procedure may not reduce in the kernel.

Neat Examples (2)

The examples from here on run after open CAS.Certificate.

The exact range of x/(1+x2) on [−2,2], stated as a certificate proposition on a box in ℝ1. The first query falls short, and bare cega then bisects to depth 2, which cuts [−2,2] at 0 and at the turning points ±1:

In[30]:=
example :
    EnclosedOn (fun p : ℝ^1 ↦ p 0 / (1 + p 0 ^ 2)) {p | -2 ≤ p 0 ∧ p 0 ≤ 2}
      (-1 / 2 : ℝ) (1 / 2 : ℝ) := by
  cega
Out[30]=

Lean accepts the proof.


The cosine on a short interval near 100:

In[31]:=
example (x : ℝ) (h0 : 100 ≤ x) (h1 : x ≤ 100001 / 1000) : 0.86 ≤ Real.cos x := by
  cega
Out[31]=

Lean accepts the proof.

See Also

cega? · cega using · enclose · nintegrate · N · cas · Options