Substitutions on FlatCurry expressions.
Author: Björn Peemöller
Version: April 2015
ppSubst
:: Subst -> Doc
Pretty printing of a substitution |
emptySubst
:: Subst
empty substitution |
singleSubst
:: Int -> Expr -> Subst
substitute a variable by an expression |
mkSubst
:: [Int] -> [Expr] -> Subst
create a substitution from a list of variables and a list of expressions |
toSubst
:: [(Int,Expr)] -> Subst
create a substitution from a list of variable/expression pairs. |
dom
:: Subst -> [Int]
extract domain of a given substitution |
rng
:: Subst -> [Expr]
extract range of a given substitution |
restrict
:: [Int] -> Subst -> Subst
Restrict a substititution to a given domain. |
without
:: [Int] -> Subst -> Subst
Remove a given part of the domain from a substititution. |
compose
:: Subst -> Subst -> Subst
compose s1 s2
composes the substitutions s1 and s2.
|
combine
:: Subst -> Subst -> Maybe Subst
Try to combine two substitutions $\sigma$ and $\theta$. |
lookupSubst
:: Int -> Subst -> Expr
Lookup a substititution for a variable. |
findSubstWithDefault
:: Expr -> Int -> Subst -> Expr
Find a substititution for a variable with a given default value. |
fmapSubst
:: (Expr -> Expr) -> Subst -> Subst
fmap f sigma
applies f
on all expressions in the range of sigma.
|
substSingle
:: Int -> Expr -> Expr -> Expr
substSingle v s e
substitutes v
by s
in e
|
varSubst
:: [Int] -> [Int] -> Expr -> Expr
Replace a list of variables by another list of variables in the given expression. |
isVariableRenaming
:: Subst -> Bool
Is the substititution sigma
a variable renaming, i.e., are the expressions
in rng(sigma)
all variables?
|
isDetSubst
:: Expr -> Subst -> Bool
Is the substititution sigma
a deterministic substitution w.r.t e , i.e.,
are the expressions in rng(sigma)
all either constructor terms or does
the variable occur at most once in e?
|
subst
:: Subst -> Expr -> Expr
subst sigma e = sigma(e)
substitutes all occurrences of variables
by corresponding expressions.
|
Data type for substitutions
Constructors:
empty substitution
|
substitute a variable by an expression
|
create a substitution from a list of variables and a list of expressions |
create a substitution from a list of variable/expression pairs.
|
|
Try to combine two substitutions $\sigma$ and $\theta$.
This operation returns |
Lookup a substititution for a variable. If there is no substitution given, the variable is substituted by itself. |
Find a substititution for a variable with a given default value. |
|
|
Replace a list of variables by another list of variables in the given expression. |
Is the substititution |
Is the substititution |
Note: The substititution must not replace variables introduced in the expression itself, either as a free variable, a let binding or a pattern variable. This is guaranteed and checked as an assertion. If the assertion is violated, an error is thrown. |