A delayed proof that a constraint is satisfied at the atoms.
Instances For
Normalize a constraint, by dividing through by the GCD.
Return none
if there is nothing to do, to avoid adding unnecessary steps to the proof term.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Normalize a constraint, by dividing through by the GCD.
Equations
Instances For
Shorthand for the first component of normalize
.
Equations
- Std.Tactic.Omega.normalizeConstraint s x = (Std.Tactic.Omega.normalize (s, x)).fst
Instances For
Shorthand for the second component of normalize
.
Equations
- Std.Tactic.Omega.normalizeCoeffs s x = (Std.Tactic.Omega.normalize (s, x)).snd
Instances For
Multiply by -1
if the leading coefficient is negative, otherwise return none
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Multiply by -1
if the leading coefficient is negative, otherwise do nothing.
Equations
Instances For
Shorthand for the first component of positivize
.
Equations
- Std.Tactic.Omega.positivizeConstraint s x = (Std.Tactic.Omega.positivize (s, x)).fst
Instances For
Shorthand for the second component of positivize
.
Equations
- Std.Tactic.Omega.positivizeCoeffs s x = (Std.Tactic.Omega.positivize (s, x)).snd
Instances For
positivize
and normalize
, returning none
if neither does anything.
Equations
- One or more equations did not get rendered due to their size.
Instances For
positivize
and normalize
Equations
Instances For
Shorthand for the first component of tidy
.
Equations
- Std.Tactic.Omega.tidyConstraint s x = (Std.Tactic.Omega.tidy (s, x)).fst
Instances For
Shorthand for the second component of tidy
.
Equations
- Std.Tactic.Omega.tidyCoeffs s x = (Std.Tactic.Omega.tidy (s, x)).snd
Instances For
The value of the new variable introduced when solving a hard equality.
Equations
Instances For
The coefficients of the new equation generated when solving a hard equality.
Equations
Instances For
Our internal representation of argument "justifying" that a constraint holds on some coefficients. We'll use this to construct the proof term once a contradiction is found.
- assumption: (s : Std.Tactic.Omega.Constraint) → (x : Std.Tactic.Omega.Coeffs) → Nat → Std.Tactic.Omega.Justification s x
Problem.assumptions[i]
generates a proof thats.sat' coeffs atoms
- tidy: {s : Std.Tactic.Omega.Constraint} →
{c : Std.Tactic.Omega.Coeffs} →
Std.Tactic.Omega.Justification s c →
Std.Tactic.Omega.Justification (Std.Tactic.Omega.tidyConstraint s c) (Std.Tactic.Omega.tidyCoeffs s c)
The result of
tidy
on anotherJustification
. - combine: {s t : Std.Tactic.Omega.Constraint} →
{c : Std.Tactic.Omega.Coeffs} →
Std.Tactic.Omega.Justification s c →
Std.Tactic.Omega.Justification t c → Std.Tactic.Omega.Justification (Std.Tactic.Omega.Constraint.combine s t) c
The result of
combine
on twoJustifications
. - combo: {s t : Std.Tactic.Omega.Constraint} →
{x y : Std.Tactic.Omega.Coeffs} →
(a : Int) →
Std.Tactic.Omega.Justification s x →
(b : Int) →
Std.Tactic.Omega.Justification t y →
Std.Tactic.Omega.Justification (Std.Tactic.Omega.Constraint.combo a s b t)
(Std.Tactic.Omega.Coeffs.combo a x b y)
A linear
combo
of twoJustifications
. - bmod: (m : Nat) →
(r : Int) →
(i : Nat) →
{x : Std.Tactic.Omega.Coeffs} →
Std.Tactic.Omega.Justification (Std.Tactic.Omega.Constraint.exact r) x →
Std.Tactic.Omega.Justification (Std.Tactic.Omega.Constraint.exact (Int.bmod r m))
(Std.Tactic.Omega.bmod_coeffs m i x)
The justification for the constraing constructed using "balanced mod" while eliminating an equality.
Instances For
Wrapping for Justification.tidy
when tidy?
is nonempty.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Print a Justification
as an indented tree structure.
Instances For
Equations
- Std.Tactic.Omega.Justification.instToStringJustification = { toString := Std.Tactic.Omega.Justification.toString }
Construct the proof term associated to a tidy
step.
Equations
- Std.Tactic.Omega.Justification.tidyProof s x v prf = Lean.mkApp4 (Lean.Expr.const `Std.Tactic.Omega.tidy_sat []) (Lean.toExpr s) (Lean.toExpr x) v prf
Instances For
Construct the proof term associated to a combine
step.
Equations
- Std.Tactic.Omega.Justification.combineProof s t x v ps pt = Lean.mkApp6 (Lean.Expr.const `Std.Tactic.Omega.Constraint.combine_sat' []) (Lean.toExpr s) (Lean.toExpr t) (Lean.toExpr x) v ps pt
Instances For
Construct the proof term associated to a combo
step.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Construct the proof term associated to a bmod
step.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Constructs a proof that s.sat' c v = true
Equations
- One or more equations did not get rendered due to their size.
- Std.Tactic.Omega.Justification.proof v assumptions (Std.Tactic.Omega.Justification.assumption s c i) = assumptions[i]!
Instances For
A Justification
bundled together with its parameters.
- coeffs : Std.Tactic.Omega.Coeffs
The coefficients of a constraint.
- constraint : Std.Tactic.Omega.Constraint
The constraint.
- justification : Std.Tactic.Omega.Justification self.constraint self.coeffs
The justification of a derived fact.
Instances For
Equations
- Std.Tactic.Omega.Fact.instToStringFact = { toString := fun (f : Std.Tactic.Omega.Fact) => toString f.justification }
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
A omega
problem.
This is a hybrid structure:
it contains both Expr
objects giving proofs of the "ground" assumptions
(or rather continuations which will produce the proofs when needed)
and internal representations of the linear constraints that we manipulate in the algorithm.
While the algorithm is running we do not synthesize any new Expr
proofs: proof extraction happens
only once we've found a contradiction.
- assumptions : Array Std.Tactic.Omega.Proof
The ground assumptions that the algorithm starts from.
- numVars : Nat
The number of variables in the problem.
- constraints : Lean.HashMap Std.Tactic.Omega.Coeffs Std.Tactic.Omega.Fact
The current constraints, indexed by their coefficients.
- equalities : Lean.HashSet Std.Tactic.Omega.Coeffs
The coefficients for which
constraints
contains an exact constraint (i.e. an equality). Equations that have already been used to eliminate variables, along with the variable which was removed, and its coefficient (either
1
or-1
). The earlier elements are more recent, so if these are being reapplied it is essential to useList.foldr
.- possible : Bool
Whether the problem is possible.
- proveFalse? : Option Std.Tactic.Omega.Proof
If the problem is impossible, then
proveFalse?
will contain a proof ofFalse
. - proveFalse?_spec : (self.possible || Option.isSome self.proveFalse?) = true
Invariant between
possible
andproveFalse?
. If we have found a contradiction,
explanation?
will contain a human readable account of the deriviation.
Instances For
Check if a problem has no constraints.
Equations
- Std.Tactic.Omega.Problem.isEmpty p = Lean.HashMap.isEmpty p.constraints
Instances For
Equations
- One or more equations did not get rendered due to their size.
Takes a proof that s.sat' x v
for some s
such that s.isImpossible
,
and constructs a proof of False
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Insert a constraint into the problem, without checking if there is already a constraint for these coefficients.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Add a constraint into the problem, combining it with any existing constraints for the same coefficients.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Walk through the equalities, finding either the first equality with minimal coefficient ±1
,
or otherwise the equality with minimal (r.minNatAbs, r.maxNatAbs)
(ordered lexicographically).
Returns the coefficients of the equality, along with the value of minNatAbs
.
Although we don't need to run a termination proof here, it's nevertheless important that we use this ordering so the algorithm terminates in practice!
Equations
- One or more equations did not get rendered due to their size.
Instances For
If we have already solved some equalities, apply those to some new Fact
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Solve an "easy" equality, i.e. one with a coefficient that is ±1
.
After solving, the variable will have been eliminated from all constraints.
Equations
- One or more equations did not get rendered due to their size.
Instances For
We deal with a hard equality by introducing a new easy equality.
After solving the easy equality,
the minimum lexicographic value of (c.minNatAbs, c.maxNatAbs)
will have been reduced.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Solve an equality, by deciding whether it is easy (has a ±1
coefficient) or hard,
and delegating to the appropriate function.
Equations
- Std.Tactic.Omega.Problem.solveEquality p c m = if m = 1 then pure (Std.Tactic.Omega.Problem.solveEasyEquality p c) else Std.Tactic.Omega.Problem.dealWithHardEquality p c
Instances For
Recursively solve all equalities.
Constructing the proof term for addInequality
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Constructing the proof term for addEquality
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Helper function for adding an inequality of the form const + Coeffs.dot coeffs atoms ≥ 0
to a Problem
.
(This is only used while initializing a Problem
. During elimination we use addConstraint
.)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Helper function for adding an equality of the form const + Coeffs.dot coeffs atoms = 0
to a Problem
.
(This is only used while initializing a Problem
. During elimination we use addConstraint
.)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Folding addInequality
over a list.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Folding addEquality
over a list.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Representation of the data required to run Fourier-Motzkin elimination on a variable.
- var : Nat
Which variable is being eliminated.
- irrelevant : List Std.Tactic.Omega.Fact
The "irrelevant" facts which do not involve the target variable.
- lowerBounds : List (Std.Tactic.Omega.Fact × Int)
The facts which give a lower bound on the target variable, and the coefficient of the target variable in each.
- upperBounds : List (Std.Tactic.Omega.Fact × Int)
The facts which give an upper bound on the target variable, and the coefficient of the target variable in each.
- lowerExact : Bool
Whether the elimination would be exact, because all of the lower bound coefficients are
±1
. - upperExact : Bool
Whether the elimination would be exact, because all of the upper bound coefficients are
±1
.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Is a Fourier-Motzkin elimination empty (i.e. there are no relevant constraints).
Equations
- Std.Tactic.Omega.Problem.FourierMotzkinData.isEmpty d = (List.isEmpty d.lowerBounds && List.isEmpty d.upperBounds)
Instances For
The number of new constraints that would be introduced by Fourier-Motzkin elimination.
Equations
- Std.Tactic.Omega.Problem.FourierMotzkinData.size d = List.length d.lowerBounds * List.length d.upperBounds
Instances For
Is the Fourier-Motzkin elimination known to be exact?
Equations
- Std.Tactic.Omega.Problem.FourierMotzkinData.exact d = (d.lowerExact || d.upperExact)
Instances For
Prepare the Fourier-Motzkin elimination data for each variable.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Decides which variable to run Fourier-Motzkin elimination on, and returns the associated data.
We prefer eliminations which introduce no new inequalities, or otherwise exact eliminations, and break ties by the number of new inequalities introduced.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run Fourier-Motzkin elimination on one variable.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run the omega
algorithm (for now without dark and grey shadows!) on a problem.
As for runOmega
, but assuming the first round of solving equalities has already happened.