Documentation

LeanCert.Examples.Certificate

Certificate-Driven Verification Examples #

This file demonstrates the certificate-driven verification system. All proofs use native_decide to execute the boolean checkers.

Design #

The golden theorems (verify_upper_bound, etc.) take:

  1. The expression e
  2. A proof hsupp that e is in ExprSupportedCore
  3. The interval I
  4. The bound c
  5. An EvalConfig specifying Taylor depth
  6. A proof h_cert that the checker returns true

The last argument is discharged by native_decide.

Examples #

Basic algebraic bounds #

Transcendental bounds with varying depth #

Demonstrating depth sensitivity #

Setup: Expressions and intervals #

Basic algebraic bounds #

x² ≤ 1 on [0, 1] with default depth 10

0 ≤ x² on [0, 1] with default depth 10

Transcendental bounds #

exp(x) ≤ 3 on [0, 1] with depth 10

9/10 ≤ exp(x) on [0, 1] with depth 10 Note: The Taylor model gives a conservative lower bound slightly below 1, so we use 9/10 as a safe lower bound that the interval arithmetic can verify.

sin(x) ≤ 1 on [0, 1]

cos(x) ≤ 1 on [0, 1]

Tighter bounds with higher depth #

Higher Taylor depth allows tighter bounds to be verified.

theorem LeanCert.Examples.Certificate.exp_le_275_cert (x : ) :
x I01Core.Expr.eval (fun (x_1 : ) => x) exprExp (11 / 4)

exp(x) ≤ 2.75 on [0, 1] requires higher depth for tighter bound

Combined expression: x * exp(x) #

This demonstrates the certificate system on a more complex expression. On [0, 1], we have:

x * exp(x) ≤ 3 on [0, 1]

0 ≤ x * exp(x) on [0, 1]

Strict bounds #

x² < 2 on [0, 1] (strict upper bound)

-1 < x² on [0, 1] (strict lower bound)

Two-sided bounds #

theorem LeanCert.Examples.Certificate.xsq_bounds_cert (x : ) :
x I010 Core.Expr.eval (fun (x_1 : ) => x) exprXSq Core.Expr.eval (fun (x_1 : ) => x) exprXSq 1

0 ≤ x² ≤ 1 on [0, 1]

theorem LeanCert.Examples.Certificate.exp_bounds_cert (x : ) :
x I01(9 / 10) Core.Expr.eval (fun (x_1 : ) => x) exprExp Core.Expr.eval (fun (x_1 : ) => x) exprExp 3

9/10 ≤ exp(x) ≤ 3 on [0, 1]

Example: RPC workflow simulation #

This section demonstrates what Python-generated code would look like. Python determines the required depth, then generates a one-liner proof.

theorem LeanCert.Examples.Certificate.rpc_exp_bound (x : ) :
x I01Core.Expr.eval (fun (x_1 : ) => x) exprExp (14 / 5)

Simulated RPC call: Python found depth 12 sufficient for exp(x) ≤ 2.8 on [0,1]