Documentation

LeanCert.Discovery.Commands

Discovery Mode: Elaboration Commands #

This module provides interactive commands for exploring mathematical functions:

Usage Examples #

-- Find minimum of x² + sin(x) on [-2, 2]
#find_min (fun x => x^2 + Real.sin x) on [-2, 2]

-- Find maximum with higher precision
#find_max (fun x => Real.exp x - x^2) on [0, 1] precision 20

-- Find bounds for a 2D function
#bounds (fun x y => x*y + x^2) on [-1, 1] × [-1, 1]

Note: #minimize and #maximize are aliases for backward compatibility.

Implementation #

The commands work by:

  1. Elaborating the user's expression
  2. Reifying it to a LeanCert.Core.Expr AST
  3. Running the optimization algorithm
  4. Pretty-printing the result

Interval Parsing Helpers #

Parse a rational number from a Lean expression using native evaluation

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[implemented_by LeanCert.Discovery.Commands.parseRatUnsafe]

    Safe wrapper for parseRatUnsafe

    Parse an integer from a reduced Lean expression

    Parse an integer directly from term syntax

    Parse an interval from syntax like [a, b]

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

      Result Formatting #

      def LeanCert.Discovery.Commands.formatRat (q : ) (_precision : := 6) :

      Format a rational for display as a decimal string

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

        Format an interval for display

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

          #find_min Command #

          Syntax for #find_min command

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

            Elaborator for #find_min

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

              Backward-compatible alias for #find_min

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

                #find_max Command #

                Syntax for #find_max command

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

                  Elaborator for #find_max

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

                    Backward-compatible alias for #find_max

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

                      #bounds Command #

                      Syntax for #bounds command

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

                        Elaborator for #bounds

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

                          #eval_interval Command #

                          Syntax for quick interval evaluation

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

                            Elaborator for #eval_interval

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