Term.Substitution

tamarin-prover-term-1.2.2: Term manipulation library for the tamarin prover.

Copyright | (c) 2010-2012 Benedikt Schmidt
License | GPL v3 (see LICENSE)
Maintainer | Benedikt Schmidt <beschmi@gmail.com>
Safe Haskell | None
Language | Haskell98

Term.Substitution

Contents

- Composition of fresh and free substitutions
- Conversion between fresh and free
- Convenience exports
- General Substitutions
- application of substitutions
- smart constructors for substitutions
- Composition of substitutions
- operations
- queries
- views
- Apply class
- Pretty printing
- Substitution of LVars
- General Substitutions
- smart constructors for substitutions
- operations
- queries
- views
- Pretty printing
- operations on fresh substitutions
- Substitution of LVars

Description

Standard and fresh substitutions.

Synopsis

- composeVFresh :: IsConst c => LSubstVFresh c -> LSubst c -> LSubstVFresh c
- freshToFree :: (MonadFresh m, IsConst c) => SubstVFresh c LVar -> m (Subst c LVar)
- freshToFreeAvoiding :: (HasFrees t, IsConst c) => SubstVFresh c LVar -> t -> Subst c LVar
- freshToFreeAvoidingFast :: (HasFrees t, Ord c) => LSubstVFresh c -> t -> LSubst c
- freeToFreshRaw :: Subst c LVar -> SubstVFresh c LVar
- module Term.LTerm
- newtype Subst c v = Subst {
  - sMap :: Map v (VTerm c v)
  }
- applyVTerm :: (IsConst c, IsVar v) => Subst c v -> VTerm c v -> VTerm c v
- applyLit :: IsVar v => Subst c v -> Lit c v -> VTerm c v
- substFromList :: IsVar v => [(v, VTerm c v)] -> Subst c v
- substFromMap :: IsVar v => Map v (VTerm c v) -> Subst c v
- emptySubst :: Subst c v
- compose :: (IsConst c, IsVar v) => Subst c v -> Subst c v -> Subst c v
- applySubst :: (IsConst c, IsVar v) => Subst c v -> Subst c v -> Subst c v
- restrict :: IsVar v => [v] -> Subst c v -> Subst c v
- mapRange :: IsVar v => (VTerm c v -> VTerm c2 v) -> Subst c v -> Subst c2 v
- varsRange :: IsVar v => Subst c v -> [v]
- dom :: Subst c v -> [v]
- range :: Subst c v -> [VTerm c v]
- imageOf :: IsVar v => Subst c v -> v -> Maybe (VTerm c v)
- substToListOn :: IsVar v => [v] -> Subst c v -> [VTerm c v]
- substToList :: Subst c v -> [(v, VTerm c v)]
- class Apply t where
- prettySubst :: (Ord c, Ord v, HighlightDocument d, Show c, Show v) => (v -> d) -> (Lit c v -> d) -> Subst c v -> [d]
- type LSubst c = Subst c LVar
- type LNSubst = Subst Name LVar
- prettyLNSubst :: (Show (Lit c LVar), Ord c, HighlightDocument d, Show c) => LSubst c -> d
- newtype SubstVFresh c v = SubstVFresh {
  - svMap :: Map v (VTerm c v)
  }
- substFromListVFresh :: IsVar v => [(v, VTerm c v)] -> SubstVFresh c v
- emptySubstVFresh :: SubstVFresh c v
- restrictVFresh :: IsVar v => [v] -> SubstVFresh c v -> SubstVFresh c v
- mapRangeVFresh :: (VTerm c v -> VTerm c2 v) -> SubstVFresh c v -> SubstVFresh c2 v
- extendWithRenaming :: Ord c => [LVar] -> SubstVFresh c LVar -> SubstVFresh c LVar
- varsRangeVFresh :: IsVar v => SubstVFresh c v -> [v]
- domVFresh :: SubstVFresh c v -> [v]
- rangeVFresh :: SubstVFresh c v -> [VTerm c v]
- isRenaming :: LSubstVFresh c -> Bool
- imageOfVFresh :: IsVar v => SubstVFresh c v -> v -> Maybe (VTerm c v)
- substToListVFresh :: SubstVFresh c v -> [(v, VTerm c v)]
- prettySubstVFresh :: (Ord c, Ord v, HighlightDocument d, Show c, Show v) => (v -> d) -> (Lit c v -> d) -> SubstVFresh c v -> [d]
- renameFresh :: (Ord c, MonadFresh m) => SubstVFresh c LVar -> m (SubstVFresh c LVar)
- renameFreshAvoiding :: (Ord c, HasFrees t) => LSubstVFresh c -> t -> SubstVFresh c LVar
- removeRenamings :: LSubstVFresh c -> LSubstVFresh c
- type LSubstVFresh c = SubstVFresh c LVar
- type LNSubstVFresh = SubstVFresh Name LVar
- prettyLSubstVFresh :: (Show (Lit c LVar), Ord c, HighlightDocument d, Show c) => LSubstVFresh c -> d
- prettyDisjLNSubstsVFresh :: Document d => Disj LNSubstVFresh -> d

## Composition of fresh and free substitutions

composeVFresh :: IsConst c => LSubstVFresh c -> LSubst c -> LSubstVFresh c #

`composeVFresh s1 s2` composes the fresh substitution s1 and the free substitution s2. The result is the fresh substitution s = s1.s2.

## Conversion between fresh and free

freshToFree :: (MonadFresh m, IsConst c) => SubstVFresh c LVar -> m (Subst c LVar) #

`freshToFree s` converts the bound variables in `s` to free variables using fresh variable names. We try to preserve variables names if possible.

freshToFreeAvoiding :: (HasFrees t, IsConst c) => SubstVFresh c LVar -> t -> Subst c LVar #

`freshToFreeAvoiding s t` converts all fresh variables in the range of `s` to free variables avoiding free variables in `t`. This function tries to reuse variable names from the domain of the substitution if possible.

freshToFreeAvoidingFast :: (HasFrees t, Ord c) => LSubstVFresh c -> t -> LSubst c #

`freshToFreeAvoidingFast s t` converts all fresh variables in the range of `s` to free variables avoiding free variables in `t`. This function does not try to reuse variable names from the domain of the substitution.

freeToFreshRaw :: Subst c LVar -> SubstVFresh c LVar #

`freeToFreshRaw s` considers all variables in the range of `s` as fresh.

## Convenience exports

module Term.LTerm

# General Substitutions

newtype Subst c v #

We use the data type `Subst c v` of substitutions. `c` is the type of constants and `v` the type of variables.

Constructors

Subst |
Fields sMap :: Map v (VTerm c v)

Instances

Ord c => HasFrees (LSubst c) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> LSubst c -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> LSubst c -> m # mapFrees :: Applicative f => MonotoneFunction f -> LSubst c -> f (LSubst c) #
(Eq c, Eq v) => Eq (Subst c v) # |
Methods (==) :: Subst c v -> Subst c v -> Bool # (/=) :: Subst c v -> Subst c v -> Bool #
(Ord c, Ord v) => Ord (Subst c v) # |
Methods compare :: Subst c v -> Subst c v -> Ordering # (<) :: Subst c v -> Subst c v -> Bool # (<=) :: Subst c v -> Subst c v -> Bool # (>) :: Subst c v -> Subst c v -> Bool # (>=) :: Subst c v -> Subst c v -> Bool # max :: Subst c v -> Subst c v -> Subst c v # min :: Subst c v -> Subst c v -> Subst c v #
(Show v, Show c) => Show (Subst c v) # |
Methods showsPrec :: Int -> Subst c v -> ShowS # show :: Subst c v -> String # showList :: [Subst c v] -> ShowS #
(Binary c, Binary v) => Binary (Subst c v) # |
Methods put :: Subst c v -> Put # get :: Get (Subst c v) # putList :: [Subst c v] -> Put #
(NFData c, NFData v) => NFData (Subst c v) # |
Methods rnf :: Subst c v -> () #
Sized (Subst c v) # |
Methods size :: Subst c v -> Int #

# application of substitutions

applyVTerm :: (IsConst c, IsVar v) => Subst c v -> VTerm c v -> VTerm c v #

`applyVTerm subst t` applies the substitution `subst` to the term `t`.

applyLit :: IsVar v => Subst c v -> Lit c v -> VTerm c v #

`applyLit subst l` applies the substitution `subst` to the literal `l`.

# smart constructors for substitutions

substFromList :: IsVar v => [(v, VTerm c v)] -> Subst c v #

Convert a list to a substitution. The `x/x` mappings are removed.

substFromMap :: IsVar v => Map v (VTerm c v) -> Subst c v #

Convert a map to a substitution. The `x/x` mappings are removed. FIXME: implement directly, use substFromMap for substFromList.

emptySubst :: Subst c v #

`emptySubVFree` is the substitution with empty domain.

# Composition of substitutions

compose :: (IsConst c, IsVar v) => Subst c v -> Subst c v -> Subst c v #

`compose s1 s2` composes the substitutions s1 and s2. The result is `s1.s2`, i.e., it has the same effect as `(t s2) s1 = s1(s2(t))` when applied to a term `t`.

applySubst :: (IsConst c, IsVar v) => Subst c v -> Subst c v -> Subst c v #

`applySubst subst subst'` applies the substitution `subst` to the range of the substitution `subst'`.

# operations

restrict :: IsVar v => [v] -> Subst c v -> Subst c v #

`restrict vars subst` restricts the domain of the substitution `subst` to `vars`.

mapRange :: IsVar v => (VTerm c v -> VTerm c2 v) -> Subst c v -> Subst c2 v #

`mapRange f subst` maps the function `f` over the range of the substitution `subst`.

# queries

varsRange :: IsVar v => Subst c v -> [v] #

`varsRange subst` returns all variables in the range of the substitution.

dom :: Subst c v -> [v] #

`dom subst` returns the domain of the substitution `substs`.

range :: Subst c v -> [VTerm c v] #

`range subst` returns the range of the substitution `substs`.

imageOf :: IsVar v => Subst c v -> v -> Maybe (VTerm c v) #

Returns the image of `i` under `subst` if `i` is in the domain of `subst`.

# views

substToListOn :: IsVar v => [v] -> Subst c v -> [VTerm c v] #

`substToPairOn vs sigma` converts the list of variables `[x1,..,xk]` to `[sigma(x1),..,sigma(xk)]`.

substToList :: Subst c v -> [(v, VTerm c v)] #

Convert substitution to list.

# Apply class

class Apply t where #

Types that support the application of `LSubst`s.

Minimal complete definition

apply

Methods

apply :: LNSubst -> t -> t #

Instances

Apply Bool # |
Methods apply :: LNSubst -> Bool -> Bool #
Apply Char # |
Methods apply :: LNSubst -> Char -> Char #
Apply Int # |
Methods apply :: LNSubst -> Int -> Int #
Apply () # |
Methods apply :: LNSubst -> () -> () #
Apply BLTerm # |
Methods apply :: LNSubst -> BLTerm -> BLTerm #
Apply BLVar # |
Methods apply :: LNSubst -> BLVar -> BLVar #
Apply LNTerm # |
Methods apply :: LNSubst -> LNTerm -> LNTerm #
Apply LVar # |
Methods apply :: LNSubst -> LVar -> LVar #
Apply a => Apply [a] # |
Methods apply :: LNSubst -> [a] -> [a] #
Apply a => Apply (Maybe a) # |
Methods apply :: LNSubst -> Maybe a -> Maybe a #
(Ord a, Apply a) => Apply (Set a) # |
Methods apply :: LNSubst -> Set a -> Set a #
Apply a => Apply (Conj a) # |
Methods apply :: LNSubst -> Conj a -> Conj a #
Apply a => Apply (Disj a) # |
Methods apply :: LNSubst -> Disj a -> Disj a #
Apply t => Apply (Equal t) # |
Methods apply :: LNSubst -> Equal t -> Equal t #
(Apply a, Apply b) => Apply (Either a b) # |
Methods apply :: LNSubst -> Either a b -> Either a b #
(Apply a, Apply b) => Apply (a, b) # |
Methods apply :: LNSubst -> (a, b) -> (a, b) #
Apply a => Apply (Map k a) # |
Methods apply :: LNSubst -> Map k a -> Map k a #

# Pretty printing

prettySubst :: (Ord c, Ord v, HighlightDocument d, Show c, Show v) => (v -> d) -> (Lit c v -> d) -> Subst c v -> [d] #

Pretty print a substitution.

# Substitution of LVars

type LSubst c = Subst c LVar #

A substitution for logical variables.

type LNSubst = Subst Name LVar #

A substitution with names and logical variables.

prettyLNSubst :: (Show (Lit c LVar), Ord c, HighlightDocument d, Show c) => LSubst c -> d #

Pretty print a substitution with logical variables.

# General Substitutions

newtype SubstVFresh c v #

We use the data type `SubstVFresh c v` of substitutions. `c` denotes the type of constants and `v` the type of variables. Fresh substitutions cannot be applied directly, they have to be converted to free substitutions in a certain context (MonadFresh).

Constructors

SubstVFresh |
Fields svMap :: Map v (VTerm c v)

Instances

(Eq c, Eq v) => Eq (SubstVFresh c v) # |
Methods (==) :: SubstVFresh c v -> SubstVFresh c v -> Bool # (/=) :: SubstVFresh c v -> SubstVFresh c v -> Bool #
(Ord c, Ord v) => Ord (SubstVFresh c v) # |
Methods compare :: SubstVFresh c v -> SubstVFresh c v -> Ordering # (<) :: SubstVFresh c v -> SubstVFresh c v -> Bool # (<=) :: SubstVFresh c v -> SubstVFresh c v -> Bool # (>) :: SubstVFresh c v -> SubstVFresh c v -> Bool # (>=) :: SubstVFresh c v -> SubstVFresh c v -> Bool # max :: SubstVFresh c v -> SubstVFresh c v -> SubstVFresh c v # min :: SubstVFresh c v -> SubstVFresh c v -> SubstVFresh c v #
(Show c, Show v) => Show (SubstVFresh c v) # |
Methods showsPrec :: Int -> SubstVFresh c v -> ShowS # show :: SubstVFresh c v -> String # showList :: [SubstVFresh c v] -> ShowS #
(Binary c, Binary v) => Binary (SubstVFresh c v) # |
Methods put :: SubstVFresh c v -> Put # get :: Get (SubstVFresh c v) # putList :: [SubstVFresh c v] -> Put #
(NFData c, NFData v) => NFData (SubstVFresh c v) # |
Methods rnf :: SubstVFresh c v -> () #
Sized (SubstVFresh c v) # |
Methods size :: SubstVFresh c v -> Int #
HasFrees (SubstVFresh n LVar) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> SubstVFresh n LVar -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> SubstVFresh n LVar -> m # mapFrees :: Applicative f => MonotoneFunction f -> SubstVFresh n LVar -> f (SubstVFresh n LVar) #

# smart constructors for substitutions

substFromListVFresh :: IsVar v => [(v, VTerm c v)] -> SubstVFresh c v #

Convert a list of mappings to a fresh substitution.

emptySubstVFresh :: SubstVFresh c v #

`emptySubstVFresh` is the fresh substitution with empty domain.

# operations

restrictVFresh :: IsVar v => [v] -> SubstVFresh c v -> SubstVFresh c v #

`restrictVFresh vars subst` restricts the domain of the substitution `subst` to `vars`.

mapRangeVFresh :: (VTerm c v -> VTerm c2 v) -> SubstVFresh c v -> SubstVFresh c2 v #

`mapRangeVFresh f subst` maps the function `f` over the range of the substitution `subst`. Note that all introduced variables are considered fresh.

extendWithRenaming :: Ord c => [LVar] -> SubstVFresh c LVar -> SubstVFresh c LVar #

`extendWithRenaming vs s` extends the substitution `s` with renamings (with fresh variables) for the variables in `vs` that are not already in `dom s`.

# queries

varsRangeVFresh :: IsVar v => SubstVFresh c v -> [v] #

`varsRangeVFresh subst` returns all variables in the range of the substitution

domVFresh :: SubstVFresh c v -> [v] #

`domVFresh subst` returns the domain of the substitution `substs`.

rangeVFresh :: SubstVFresh c v -> [VTerm c v] #

`rangeVFresh subst` returns the range of the substitution `substs`.

isRenaming :: LSubstVFresh c -> Bool #

Returns `True` if the substitution is a renaming.

imageOfVFresh :: IsVar v => SubstVFresh c v -> v -> Maybe (VTerm c v) #

Returns the image of `i` under `subst` if `i` is in the domain of `subst`.

# views

substToListVFresh :: SubstVFresh c v -> [(v, VTerm c v)] #

Convert substitution to list.

# Pretty printing

prettySubstVFresh :: (Ord c, Ord v, HighlightDocument d, Show c, Show v) => (v -> d) -> (Lit c v -> d) -> SubstVFresh c v -> [d] #

Pretty print a substitution.

# operations on fresh substitutions

renameFresh :: (Ord c, MonadFresh m) => SubstVFresh c LVar -> m (SubstVFresh c LVar) #

`renameFresh s` renames the fresh variables in `s` using fresh variables. This function can be used to prevent overshadowing which might make output hard to read.

renameFreshAvoiding :: (Ord c, HasFrees t) => LSubstVFresh c -> t -> SubstVFresh c LVar #

`renameFreshAvoiding s t` renames the fresh variables in the range of `s` away from variables that are free in `t`. This is an internal function.

removeRenamings :: LSubstVFresh c -> LSubstVFresh c #

`removeRenamings s` removes all renamings (see `isRenamedVar`) from `s`.

# Substitution of LVars

type LSubstVFresh c = SubstVFresh c LVar #

Fresh substitution with logical variables

type LNSubstVFresh = SubstVFresh Name LVar #

Fresh substitution with logical variables and names

prettyLSubstVFresh :: (Show (Lit c LVar), Ord c, HighlightDocument d, Show c) => LSubstVFresh c -> d #

Pretty print a substitution with logical variables.

prettyDisjLNSubstsVFresh :: Document d => Disj LNSubstVFresh -> d #

Pretty print a disjunction of substitutions.