Copyright | (c) 2017 2018 N Steenbergen |
---|---|
License | GPL-3 |
Maintainer | ns@slak.ws |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
This module makes it possible to obtain variable assignments by comparing
Formula
s, and to apply substitutions based on them.
The idea is similar to, but not the same as unification. When we pattern x
to y
, the former is schematic and the latter is literal. Even though their
variables can be structurally identical, they are really different, in that,
for example, Var "x"
may well pattern with Implication (Var "x") (Var "x")
,
resulting in the substitution [("x", Implication "x" "x")]
.
Nevertheless, see subsumes
from Control.Unification
. They are not related
by code, but the purpose is similar.
Documentation
type Substitution ext = Map String (Term ext) Source #
A substitution maps identifiers to terms of a logic.
class Substitutable ext term where Source #
The Substitutable
class represents a relation between terms based on an
extension ext
(that is, formulas or extensions of formulas) and subterms
that may be substituted for variables inside those ext
-terms.
substitute, patternM
substitute :: Monad m => Substitution ext -> term -> m term Source #
Apply a substitution to a term.
Note that at the time of writing, there is no fundamental distinction between variables and schematic variables.
:: Monad m | |
=> term | The |
-> term | The formula to fill in the pattern. |
-> m (Substitution ext) |
a
tries to find a substitution such that pattern
ba
matches
b
. The a
formula is taken as a schematic formula, where variables
represent gaps to be filled in, and b
is a "normal" formula, in which
variables represent literals.
For simplicity, this function assumes that the formulas have been
simplify
ed. The intention is to make this explicit via a newtype
at
some point.
patternContinue :: Monad m => Substitution ext -> term -> term -> m (Substitution ext) Source #
Same as pattern
, but starts patterning from a given starting state.
Substitutable Justification Justification Source # | |
(Eq ext, Substitutable ext ext) => Substitutable ext (Formula ext) Source # | |
(Eq ext, Substitutable ext ext) => Substitutable ext (Term ext) Source # | |
(Eq ext, Substitutable ext a) => Substitutable ext (Marked a) Source # | |