PDEAtlas

10.4. Proof-producing computation🔗

In the opening heat calculation, the useful conclusion is an equality between derivatives of an ordinary real function. Computing a syntax tree for the answer is an intermediate step. A soundness theorem connects that tree to the function and gives us an equality we can use in a proof.

a candidate still needs a proofPlannersearch, ranking, heuristicsCandidatea rewrite, an interval, a jettrust boundaryGoalthe statement we wantedLean's kernelchecks the proofSoundnessproved onceCertificate∀ x ∈ Ω, ‖f(x) − g(x)‖ ≤ εRejectedthe goal is unchangedsoundness connects the computed object to the original goal
Where the trust boundary runs. The planner proposes a rewrite, interval, or jet. A closing tactic uses a soundness theorem and its hypotheses to turn that candidate into a proof of the original goal. Lean's kernel checks the resulting declaration; a failed check leaves the goal unchanged. The certificate shown here is ApproxOn: \(\lVert f(x)-g(x)\rVert\le\varepsilon\) for every \(x\in\Omega\). At \(\varepsilon=0\), this gives pointwise equality on \(\Omega\). Supplied certificates retain their own assumptions and axioms.

An expression, interval, or polynomial becomes usable in a proof only after it is connected to the original function by a soundness theorem. The domain conditions travel with that theorem: a cancellation involving a denominator, for instance, still needs the denominator to be nonzero at the points in question.

10.4.1. From input to theorem🔗

After importing CAS.CAS, calculations are written in ordinary real-scalar notation. The frontend reifies that notation internally, so users do not have to construct a Verified.Expr by hand.

Closed finite certificates have a simpler route. After its semantic routes refuse a goal, bare cega can evaluate a closed decidable proposition in the kernel, such as a bound on every entry of a finite integer table. cega [fast] first tries compiled evaluation of that proposition, then a computable polynomial interval enclosure. It restores the proof state and environment on refusal before falling back to kernel CEGA. Compiled successes additionally trust Lean's compiler and native evaluation; their generated axioms reach downstream results. The kernel build profile disables these native paths without changing the statements. Exponential, logarithmic, and other proof-bearing analytic planner routes stay kernel checked. A closed finite certificate can still contain rational enclosures for these functions: checking that finite data and proving its analytic meaning are separate steps.

The semantic theorem determines how we can use the answer. A derivative identity lets us replace a term in a PDE operator. An enclosure \ell\le f(x)\le h for every x in a box can bound an error on that box; it says nothing about points outside it. An antiderivative identity supplies the derivative step of the fundamental theorem of calculus, whose interval hypotheses must also hold.

The #cas command displays expressions and checked evidence together with any outstanding conditions or diagnostics. The theorem-facing tactics use that evidence in ordinary Lean goals. If a closing tactic cannot justify the requested conclusion, it fails and preserves the goal. The SymLean manual gives the full command and tactic syntax, coordinate-selection rules, side-condition contract, and limitations.

10.4.2. The Expression Representation🔗

To differentiate a formula, the algorithm needs to see how it is assembled: which operation is outermost, which subexpressions it acts on, and where variables occur. We store that structure as a finite expression tree, called Verified.Expr ι, rather than only its value as a real function. Its constructors include integer and rational constants, variables, the four arithmetic operations, negation, natural powers, real powers a ^ b with an arbitrary real exponent (Mathlib's Real.rpow), sin, cos, atan, asin, acos, exp, log, and sqrt, together with pi and e. An environment \rho:\iota\to\mathbb R assigns a real value to every variable, and Expr.eval ρ e interprets the syntax tree as a real number.

This is called a deep embedding. A shallow representation by Lean functions \mathbb R\to\mathbb R is convenient for stating analytic theorems, but an opaque function does not expose its constituent operations to a symbolic algorithm. The expression tree does: differentiation, normalization, and interval evaluation recurse over those operations. We use it because these three computations can then share one representation. The price is a proof that each computation has the intended meaning when the tree is evaluated. The bridge theorems provide that proof and return statements about ordinary real functions, such as the derivatives used in the earlier PDE chapters.

The index type carries arity, not a new scalar type. For example, Verified.Expr (Fin 2) is a scalar expression in two ordered real coordinates. The expression \sin(xy) therefore denotes a map \mathbb R^2\to\mathbb R. A vector-valued expression is represented by a finite family of scalar expressions, one for each output coordinate.

The #cas command and theorem tactics recognize supported ordinary Lean notation and build the tree internally; a real power is recognized whether it is written x ^ (r : ℝ) or Real.rpow x r, while a literal natural exponent keeps the natural-power constructor.

10.4.3. Domains, Types, and Side Conditions🔗

The calculator frontend has fixed real semantics. Writing (x : ℝ) documents that semantics; it does not select a different backend. A complex annotation is rejected.

Inside ordinary theorem goals, coefficients can come from many Lean types as long as the resulting expression is real-valued. Natural, integer, rational, and nonnegative-real casts, structure fields, and arbitrary real-valued parameters may remain opaque coefficients. Differentiated coordinates themselves are real.

Evaluation is total because Lean's real division, logarithm, square root, and real power are total functions. Classical calculus rules are not unconditional. The predicate Expr.ValidAt ρ e records the facts needed at a point: denominators and logarithm arguments are nonzero, square-root arguments and the bases of real powers are strictly positive, and the argument of an inverse sine or cosine differs from \pm1. The analytic logarithm derivative bridge therefore needs x\ne0 (or a stronger hypothesis such as 0<x), and the power rule for x^{3/2} needs 0<x. This is distinct from identities and enclosures about the total value, which need not assume analytic validity.

For example, (x^2-1)/(x-1)=x+1 holds when x\ne1. At x=1, Lean's totalized division makes the left side zero, whereas the right side is two. The side condition protects the equality itself. For an interval calculation, a bound such as |x-1|\geq\delta>0 also controls division quantitatively: the reciprocal has magnitude at most 1/\delta. Domain information therefore affects both the validity of an exact simplification and the width of a numerical certificate.

Every checked frontend, whether it normalizes, differentiates, integrates, or lowers a PDE residual, generates the same small family of obligations: nonvanishing denominators and logarithm arguments, positive square-root arguments and power bases, and finite lists of such facts collected as ValidAt, ValidityRequirements.Holds, or Alg.SideHolds. One tactic, symbolic_assumptions, discharges all of them. It first reduces the requirement container to a conjunction of atomic real facts without rewriting the atoms, so a generated condition keeps the shape a user hint refers to, and then closes each atom by exactly one of assumption, positivity, norm_num, or nlinarith, also in their ≠ 0 forms; a disequality hypothesis a\ne b closes a-b\ne0, and a positive hypothesis 0<e also discharges a nonvanishing condition e\ne0. Evidence given through a using clause is simply added to the local context first. On failure the tactic names the atoms it could not prove and leaves the goal unchanged; no assumption is ever inserted.

These obligations explain why a plausible simplification can stop short of a proof. Cancelling a denominator requires evidence that it is nonzero; if we cannot establish that condition, we still have work to do. The question of how a calculator should expose such conditions also appears in a 2020 Lean Zulip wishlist of computer-algebra features (Effectiveness as a computer algebra system?) and again in 2023 (Is there a field_simp variant that generates hypotheses?). Here the obligations travel with the result. The tactic must prove them from the available context, including any supplied hints, before it can use the calculation to close the goal.