Documentation

LeanCert.Engine.Search.CounterExample

Counter-Example Search #

This file provides machinery for finding counter-examples to bound claims. Finding a counter-example is just global optimization: to disprove f(x) ≤ C, we maximize f(x) and check if the result exceeds C.

Main definitions #

Counter-Example Types #

Usage #

-- Check if x² ≤ 3 on [-2, 2]
let result := findViolation (Expr.mul (Expr.var 0) (Expr.var 0)) [⟨-2, 2, by norm_num⟩] 3
-- Returns some { status := .Verified, ... } because max(x²) = 4 > 3

Counter-example types #

Status of a counter-example

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

      A counter-example to a bound claim

      • point : List

        The input point (midpoint of the best box)

      • valueLo :

        The computed output interval at/near the point

      • valueHi :
      • Whether the counter-example is verified or just a candidate

      • The box containing the counter-example

      • iterations :

        Number of iterations used

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

          Upper bound violation (f(x) ≤ limit) #

          Search for a counter-example to the claim ∀ x ∈ domain, f(x) ≤ limit.

          Returns some CounterExample if the bound cannot be verified. Returns none if the theorem appears to be true (no violation found).

          Algorithm: Maximize f(x) over the domain. If max(f).lo > limit, the bound is definitely false. If max(f).hi > limit but lo ≤ limit, there might be a violation.

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

            Variant of findViolation with division support.

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

              Lower bound violation (limit ≤ f(x)) #

              Search for a counter-example to the claim ∀ x ∈ domain, limit ≤ f(x).

              Returns some CounterExample if the bound cannot be verified.

              Algorithm: Minimize f(x) over the domain. If min(f).hi < limit, the bound is definitely false.

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

                Variant with division support.

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

                  Strict bound violations #

                  Search for a counter-example to ∀ x ∈ domain, f(x) < limit. A violation means f(x) ≥ limit for some x.

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

                    Search for a counter-example to ∀ x ∈ domain, limit < f(x). A violation means f(x) ≤ limit for some x.

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

                      Pretty printing #

                      Format a counter-example for display

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