Discovery Mode: Elaboration Commands #
This module provides interactive commands for exploring mathematical functions:
#find_min- Find the global minimum of an expression on a domain#find_max- Find the global maximum of an expression on a domain#bounds- Find both min and max bounds#eval_interval- Quick interval evaluation
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:
- Elaborating the user's expression
- Reifying it to a
LeanCert.Core.ExprAST - Running the optimization algorithm
- Pretty-printing the result
Instances For
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
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
Parse a box (product of intervals)
Result Formatting #
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.