Documentation

LeanCert.Meta.ProveContinuous

Automatic Continuity Proof Generation #

This module provides metaprogramming infrastructure to automatically generate ContinuousOn proof terms for reified LeanCert expressions.

Given a reified AST e : LeanCert.Core.Expr, we construct a proof that ContinuousOn (fun x => Expr.eval (fun _ => x) e) (Set.Icc lo hi).

Main definitions #

Design #

We define ExprContinuousCore as a separate predicate from ExprSupportedCore because:

Operations in ExprContinuousCore:

@[reducible, inline]
abbrev LExpr :
Equations
Instances For

    Continuous Expression Predicate #

    Since inv (1/x) is not continuous at 0, we define a separate predicate for expressions that are continuous everywhere. This excludes inv from ExprSupportedCore.

    Expressions that are continuous everywhere (excludes inv and log). This is a subset of ExprSupportedCore used for continuity proofs. Note: log is excluded because it is not continuous at 0.

    Instances For

      ExprContinuousCore implies ExprSupportedCore

      Base Continuity Theorem #

      This theorem proves that all ExprContinuousCore expressions evaluate to continuous functions. We prove this by induction on the structure of ExprContinuousCore.

      theorem LeanCert.Meta.exprContinuousCore_continuousOn (e : LExpr) (hsupp : ExprContinuousCore e) {s : Set } :
      ContinuousOn (fun (x : ) => Core.Expr.eval (fun (x_1 : ) => x) e) s

      All ExprContinuousCore expressions are continuous on any set.

      This is the foundational theorem that allows automatic continuity proof generation. Since ExprContinuousCore only includes operations that are continuous everywhere (const, var, add, mul, neg, sin, cos, exp, sqrt, sinh, cosh, tanh), the result follows by structural induction.

      NOTE: inv and log are NOT included because they are not continuous at 0.

      theorem LeanCert.Meta.exprContinuousCore_continuousOn_Icc (e : LExpr) (hsupp : ExprContinuousCore e) (lo hi : ) :
      ContinuousOn (fun (x : ) => Core.Expr.eval (fun (x_1 : ) => x) e) (Set.Icc lo hi)

      Specialized version for Icc intervals (common case for interval_roots)

      theorem LeanCert.Meta.exprContinuousCore_continuousOn_interval (e : LExpr) (hsupp : ExprContinuousCore e) (I : Core.IntervalRat) :
      ContinuousOn (fun (x : ) => Core.Expr.eval (fun (x_1 : ) => x) e) (Set.Icc I.lo I.hi)

      Version taking IntervalRat for convenience

      Backward Compatibility: ExprSupportedCore Continuity #

      These theorems are provided for backward compatibility with code that uses ExprSupportedCore. For expressions with log, a domain validity condition is required.

      Domain validity for continuity: ensures log arguments evaluate to positive values. For expressions without log, this is always True.

      Equations
      Instances For

        Domain validity is trivially true for ExprSupported expressions (which exclude log).

        Domain validity is trivially true for ExprContinuousCore expressions (no log).

        theorem LeanCert.Meta.exprSupportedCore_continuousOn (e : LExpr) (hsupp : Core.ExprSupportedCore e) {s : Set } (hdom : exprContinuousDomainValid e s) :
        ContinuousOn (fun (x : ) => Core.Expr.eval (fun (x_1 : ) => x) e) s

        All ExprSupportedCore expressions are continuous on sets where log arguments are positive.

        This theorem exists for backward compatibility with code that uses ExprSupportedCore. For expressions with log, the domain validity condition ensures the argument evaluates to positive values on s.

        Metaprogramming: Continuity Proof Generation #

        Generate proof terms of ContinuousOn (fun x => Expr.eval (fun _ => x) e) (Set.Icc lo hi) by applying exprContinuousCore_continuousOn_Icc with an automatically generated ExprContinuousCore proof.

        Note: We use ExprContinuousCore (not ExprSupportedCore) because inv is not continuous everywhere, and ExprContinuousCore excludes inv.

        Generate a proof of ExprContinuousCore e_ast by matching on the AST structure.

        This is similar to mkSupportedCoreProof but for the ExprContinuousCore predicate which excludes inv (since 1/x is not continuous at 0).

        Supported: const, var, add, mul, neg, sin, cos, exp, sqrt, sinh, cosh, tanh Not supported: inv, log, atan, arsinh, atanh

        Generate a ContinuousOn proof for an expression on an interval.

        Given:

        • e_ast : the AST expression (Lean.Expr representing LeanCert.Core.Expr)
        • interval : the interval expression (Lean.Expr representing IntervalRat)

        Returns a proof of: ContinuousOn (fun x => Expr.eval (fun _ => x) e) (Set.Icc I.lo I.hi)

        This works by:

        1. Generating an ExprContinuousCore proof for the AST
        2. Applying exprContinuousCore_continuousOn_interval

        Note: This will fail for expressions containing inv since 1/x is not continuous at 0.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Alternative: generate ContinuousOn proof with explicit lo/hi bounds

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Testing Infrastructure #

            Debug command to test continuity proof generation

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For