| Copyright | (c) Masahiro Sakai 2011-2013 |
|---|---|
| License | BSD-style |
| Maintainer | masahiro.sakai@gmail.com |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
ToySolver.Arith.FourierMotzkin
Description
Naïve implementation of Fourier-Motzkin Variable Elimination
Reference:
- data Constr
- project :: Var -> [Atom Rational] -> [([Atom Rational], Model Rational -> Model Rational)]
- projectN :: VarSet -> [Atom Rational] -> [([Atom Rational], Model Rational -> Model Rational)]
- eliminateQuantifiers :: Formula (Atom Rational) -> Maybe (Formula (Atom Rational))
- solveFormula :: VarSet -> Formula (Atom Rational) -> SatResult Rational
- solve :: VarSet -> [Atom Rational] -> Maybe (Model Rational)
Primitive constraints
Atomic constraint
Projection
project :: Var -> [Atom Rational] -> [([Atom Rational], Model Rational -> Model Rational)] Source #
returns project x φ[(ψ_1, lift_1), …, (ψ_m, lift_m)] such that:
⊢_LRA ∀y1, …, yn. (∃x. φ) ↔ (ψ_1 ∨ … ∨ φ_m)where{y1, …, yn} = FV(φ) \ {x}, and- if
M ⊧_LRA ψ_ithenlift_i M ⊧_LRA φ.
projectN :: VarSet -> [Atom Rational] -> [([Atom Rational], Model Rational -> Model Rational)] Source #
returns projectN {x1,…,xm} φ[(ψ_1, lift_1), …, (ψ_n, lift_n)] such that:
⊢_LRA ∀y1, …, yp. (∃x. φ) ↔ (ψ_1 ∨ … ∨ φ_n)where{y1, …, yp} = FV(φ) \ {x1,…,xm}, and- if
M ⊧_LRA ψ_ithenlift_i M ⊧_LRA φ.
Quantifier elimination
eliminateQuantifiers :: Formula (Atom Rational) -> Maybe (Formula (Atom Rational)) Source #
Eliminate quantifiers and returns equivalent quantifier-free formula.
returns eliminateQuantifiers φ(ψ, lift) such that:
- ψ is a quantifier-free formula and
LRA ⊢ ∀y1, …, yn. φ ↔ ψwhere{y1, …, yn} = FV(φ) ⊇ FV(ψ), and - if
M ⊧_LRA ψthenlift M ⊧_LRA φ.
φ may or may not be a closed formula.
Constraint solving
solveFormula :: VarSet -> Formula (Atom Rational) -> SatResult Rational Source #
returnssolveFormula{x1,…,xm} φsuch thatSatMM ⊧_LRA φwhen suchMexists,- returns
when suchUnsatMdoes not exists, and - returns
whenUnknownφis beyond LRA.