Moduleghc-typelits-natnormalise-0.7.10Haskell2010
GHC.TypeLits.Normalise.Unify
- 5 types
- 16 values
- Packageghc-typelits-natnormalise-0.7.10
- Exports21
- LanguageHaskell2010
- LicenceBSD-2-Clause
- SourceUnify.hs
Applies normaliseNat and simplifySOP to type or predicates to reduce
any occurrences of sub-terms of kind Nat. If the result is
the same as input, returns Nothing.
Substitution on SOP terms
4 declarationsInstances2Eq, Outputable
(Eq v, Eq c) => Eq (UnifyItem v c)Defined in ghc-typelits-natnormalise-0.7.10 · GHC.TypeLits.Normalise.Unify(Outputable v, Outputable c) => Outputable (UnifyItem v c)Defined in ghc-typelits-natnormalise-0.7.10 · GHC.TypeLits.Normalise.Unify
Apply a substitution to a single normalised SOP term
Apply a substitution to a substitution
Find unifiers
3 declarationsResult of comparing two SOP terms, returning a potential substitution list under which the two terms are equal.
Instances1Outputable
Outputable UnifyResultDefined in ghc-typelits-natnormalise-0.7.10 · GHC.TypeLits.Normalise.Unify
Find unifiers for two SOP terms
Can find the following unifiers:
t ~ a + b ==> [t := a + b]
a + b ~ t ==> [t := a + b]
(a + c) ~ (b + c) ==> a := b
(2*a) ~ (2*b) ==> [a := b]
(2 + a) ~ 5 ==> [a := 3]
(i * a) ~ j ==> [a := div j i], when (mod j i == 0)
However, given a wanted:
[W] t ~ a + b
this function returns [], or otherwise we "solve" the constraint by
finding a unifier equal to the constraint.
However, given a wanted:
[W] (a + c) ~ (b + c)
we do return the unifier:
[a := b]
Free variables in SOP terms
1 declarationInequalities
6 declarationsSubtract an inequality, in order to either:
See if the smallest solution is a natural number
Cancel sums, i.e. monotonicity of addition
subtractIneq (2*y <=? 3*x ~ True) = (-2*y + 3*x)
subtractIneq (2*y <=? 3*x ~ False) = (-3*x + (-1) + 2*y)
solveIneq :: WordSolving depth
-> IneqInequality we want to solve
-> IneqGiven/proven inequality
-> WriterT (Set CType) Maybe BoolSolver result
Nothing: exhausted solver steps
Just True: inequality is solved
Just False: solver is unable to solve inequality, note that this does not mean the wanted inequality does not hold.
Try to solve inequalities
Give the smallest solution for an inequality
instantSolveIneq Try to instantly solve an inequality by using the inequality solver using
1 <=? 1 ~ True as the given constraint.