Term.LTerm

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

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

Term.LTerm

Contents

- Names
  - Queries
  - Construction
- LVar
  - Destructors
  - Manging Free LVars
- BVar
- Pretty-Printing
- Convenience exports

Description

Terms with logical variables and names.

Synopsis

- data Name = Name {
  - nTag :: NameTag
  - nId :: NameId
  }
- data NameTag
  - = FreshName
  - | PubName
  - | NodeName
- newtype NameId = NameId {
  - getNameId :: String
  }
- type NTerm v = VTerm Name v
- sortOfName :: Name -> LSort
- freshTerm :: String -> NTerm v
- pubTerm :: String -> NTerm v
- data LSort
  - = LSortPub
  - | LSortFresh
  - | LSortMsg
  - | LSortNode
- data LVar = LVar {
  - lvarName :: String
  - lvarSort :: !LSort
  - lvarIdx :: !Integer
  }
- type NodeId = LVar
- type LTerm c = VTerm c LVar
- type LNTerm = VTerm Name LVar
- freshLVar :: MonadFresh m => String -> LSort -> m LVar
- sortPrefix :: LSort -> String
- sortSuffix :: LSort -> String
- sortCompare :: LSort -> LSort -> Maybe Ordering
- sortOfLTerm :: Show c => (c -> LSort) -> LTerm c -> LSort
- sortOfLNTerm :: LNTerm -> LSort
- sortOfLit :: Lit Name LVar -> LSort
- isMsgVar :: LNTerm -> Bool
- isFreshVar :: LNTerm -> Bool
- isSimpleTerm :: LNTerm -> Bool
- getVar :: LNTerm -> Maybe [LVar]
- getMsgVar :: LNTerm -> Maybe [LVar]
- niFactors :: LNTerm -> [LNTerm]
- containsPrivate :: Term t -> Bool
- containsNoPrivateExcept :: [ByteString] -> Term t -> Bool
- neverContainsFreshPriv :: LNTerm -> Bool
- ltermVar :: LSort -> LTerm c -> Maybe LVar
- ltermVar' :: Show c => LSort -> LTerm c -> LVar
- ltermNodeId :: LTerm c -> Maybe LVar
- ltermNodeId' :: Show c => LTerm c -> LVar
- bltermNodeId :: BLTerm -> Maybe LVar
- bltermNodeId' :: BLTerm -> LVar
- class HasFrees t where
- data MonotoneFunction f
  - = Monotone (LVar -> f LVar)
  - | Arbitrary (LVar -> f LVar)
- occurs :: HasFrees t => LVar -> t -> Bool
- freesList :: HasFrees t => t -> [LVar]
- frees :: HasFrees t => t -> [LVar]
- someInst :: (MonadFresh m, MonadBind LVar LVar m, HasFrees t) => t -> m t
- rename :: (MonadFresh m, HasFrees a) => a -> m a
- renameIgnoring :: (MonadFresh m, HasFrees a) => [LVar] -> a -> m a
- eqModuloFreshnessNoAC :: (HasFrees a, Eq a) => a -> a -> Bool
- avoid :: HasFrees t => t -> FreshState
- evalFreshAvoiding :: HasFrees t => Fresh a -> t -> a
- evalFreshTAvoiding :: (Monad m, HasFrees t) => FreshT m a -> t -> m a
- renameAvoiding :: (HasFrees s, HasFrees t) => s -> t -> s
- renameAvoidingIgnoring :: (HasFrees s, HasFrees t) => s -> t -> [LVar] -> s
- avoidPrecise :: HasFrees t => t -> FreshState
- renamePrecise :: (MonadFresh m, HasFrees a) => a -> m a
- renameDropNamehint :: (MonadFresh m, MonadBind LVar LVar m, HasFrees a) => a -> m a
- varOccurences :: HasFrees a => a -> [(LVar, Set Occurence)]
- data BVar v
  - = Bound Integer
  - | Free v
- type BLVar = BVar LVar
- type BLTerm = NTerm BLVar
- foldBVar :: (Integer -> a) -> (v -> a) -> BVar v -> a
- fromFree :: BVar v -> v
- prettyLVar :: Document d => LVar -> d
- prettyNodeId :: Document d => NodeId -> d
- prettyNTerm :: (Show v, Document d) => NTerm v -> d
- prettyLNTerm :: Document d => LNTerm -> d
- showLitName :: Lit Name LVar -> String
- module Term.VTerm

# Names

data Name #

Names.

Constructors

Name |
Fields nTag :: NameTag nId :: NameId

Instances

Eq Name # |
Methods (==) :: Name -> Name -> Bool # (/=) :: Name -> Name -> Bool #
Data Name # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Name -> c Name # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Name # toConstr :: Name -> Constr # dataTypeOf :: Name -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Name) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name) # gmapT :: (forall b. Data b => b -> b) -> Name -> Name # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r # gmapQ :: (forall d. Data d => d -> u) -> Name -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Name -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Name -> m Name # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Name -> m Name # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Name -> m Name #
Ord Name # |
Methods compare :: Name -> Name -> Ordering # (<) :: Name -> Name -> Bool # (<=) :: Name -> Name -> Bool # (>) :: Name -> Name -> Bool # (>=) :: Name -> Name -> Bool # max :: Name -> Name -> Name # min :: Name -> Name -> Name #
Show Name # |
Methods showsPrec :: Int -> Name -> ShowS # show :: Name -> String # showList :: [Name] -> ShowS #
Generic Name # |
Associated Types type Rep Name :: * -> * # Methods from :: Name -> Rep Name x # to :: Rep Name x -> Name #
Binary Name # |
Methods put :: Name -> Put # get :: Get Name # putList :: [Name] -> Put #
NFData Name # |
Methods rnf :: Name -> () #
IsConst Name # |
Apply BLTerm # |
Methods apply :: LNSubst -> BLTerm -> BLTerm #
Apply LNTerm # |
Methods apply :: LNSubst -> LNTerm -> LNTerm #
type Rep Name # |
type Rep Name = D1 (MetaData "Name" "Term.LTerm" "tamarin-prover-term-1.2.2-AAX5pCkSPqj7TesI35mR1r" False) (C1 (MetaCons "Name" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "nTag") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NameTag)) (S1 (MetaSel (Just Symbol "nId") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 NameId))))

data NameTag #

Tags for names.

Constructors

FreshName |
PubName |
NodeName |

Instances

Eq NameTag # |
Methods (==) :: NameTag -> NameTag -> Bool # (/=) :: NameTag -> NameTag -> Bool #
Data NameTag # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NameTag -> c NameTag # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NameTag # toConstr :: NameTag -> Constr # dataTypeOf :: NameTag -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c NameTag) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NameTag) # gmapT :: (forall b. Data b => b -> b) -> NameTag -> NameTag # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NameTag -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NameTag -> r # gmapQ :: (forall d. Data d => d -> u) -> NameTag -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> NameTag -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> NameTag -> m NameTag # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NameTag -> m NameTag # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NameTag -> m NameTag #
Ord NameTag # |
Methods compare :: NameTag -> NameTag -> Ordering # (<) :: NameTag -> NameTag -> Bool # (<=) :: NameTag -> NameTag -> Bool # (>) :: NameTag -> NameTag -> Bool # (>=) :: NameTag -> NameTag -> Bool # max :: NameTag -> NameTag -> NameTag # min :: NameTag -> NameTag -> NameTag #
Show NameTag # |
Methods showsPrec :: Int -> NameTag -> ShowS # show :: NameTag -> String # showList :: [NameTag] -> ShowS #
Generic NameTag # |
Associated Types type Rep NameTag :: * -> * # Methods from :: NameTag -> Rep NameTag x # to :: Rep NameTag x -> NameTag #
Binary NameTag # |
Methods put :: NameTag -> Put # get :: Get NameTag # putList :: [NameTag] -> Put #
NFData NameTag # |
Methods rnf :: NameTag -> () #
type Rep NameTag # |
type Rep NameTag = D1 (MetaData "NameTag" "Term.LTerm" "tamarin-prover-term-1.2.2-AAX5pCkSPqj7TesI35mR1r" False) ((:+:) (C1 (MetaCons "FreshName" PrefixI False) U1) ((:+:) (C1 (MetaCons "PubName" PrefixI False) U1) (C1 (MetaCons "NodeName" PrefixI False) U1)))

newtype NameId #

Type safety for names.

Constructors

NameId |
Fields getNameId :: String

Instances

Eq NameId # |
Methods (==) :: NameId -> NameId -> Bool # (/=) :: NameId -> NameId -> Bool #
Data NameId # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NameId -> c NameId # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NameId # toConstr :: NameId -> Constr # dataTypeOf :: NameId -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c NameId) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NameId) # gmapT :: (forall b. Data b => b -> b) -> NameId -> NameId # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NameId -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NameId -> r # gmapQ :: (forall d. Data d => d -> u) -> NameId -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> NameId -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> NameId -> m NameId # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NameId -> m NameId # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NameId -> m NameId #
Ord NameId # |
Methods compare :: NameId -> NameId -> Ordering # (<) :: NameId -> NameId -> Bool # (<=) :: NameId -> NameId -> Bool # (>) :: NameId -> NameId -> Bool # (>=) :: NameId -> NameId -> Bool # max :: NameId -> NameId -> NameId # min :: NameId -> NameId -> NameId #
Show NameId # |
Methods showsPrec :: Int -> NameId -> ShowS # show :: NameId -> String # showList :: [NameId] -> ShowS #
Generic NameId # |
Associated Types type Rep NameId :: * -> * # Methods from :: NameId -> Rep NameId x # to :: Rep NameId x -> NameId #
Binary NameId # |
Methods put :: NameId -> Put # get :: Get NameId # putList :: [NameId] -> Put #
NFData NameId # |
Methods rnf :: NameId -> () #
type Rep NameId # |
type Rep NameId = D1 (MetaData "NameId" "Term.LTerm" "tamarin-prover-term-1.2.2-AAX5pCkSPqj7TesI35mR1r" True) (C1 (MetaCons "NameId" PrefixI True) (S1 (MetaSel (Just Symbol "getNameId") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)))

type NTerm v = VTerm Name v #

Terms with literals containing names and arbitrary variables.

## Queries

sortOfName :: Name -> LSort #

Return `LSort` for given `Name`.

## Construction

freshTerm :: String -> NTerm v #

`freshTerm f` represents the fresh name `f`.

pubTerm :: String -> NTerm v #

`pubTerm f` represents the pub name `f`.

# LVar

data LSort #

Sorts for logical variables. They satisfy the following sub-sort relation:

     LSortFresh < LSortMsg
     LSortPub   < LSortMsg

Constructors

LSortPub | Arbitrary public names.
LSortFresh | Arbitrary fresh names.
LSortMsg | Arbitrary messages.
LSortNode | Sort for variables denoting nodes of derivation graphs.

Instances

Bounded LSort # |
Methods minBound :: LSort # maxBound :: LSort #
Enum LSort # |
Methods succ :: LSort -> LSort # pred :: LSort -> LSort # toEnum :: Int -> LSort # fromEnum :: LSort -> Int # enumFrom :: LSort -> [LSort] # enumFromThen :: LSort -> LSort -> [LSort] # enumFromTo :: LSort -> LSort -> [LSort] # enumFromThenTo :: LSort -> LSort -> LSort -> [LSort] #
Eq LSort # |
Methods (==) :: LSort -> LSort -> Bool # (/=) :: LSort -> LSort -> Bool #
Data LSort # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LSort -> c LSort # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c LSort # toConstr :: LSort -> Constr # dataTypeOf :: LSort -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c LSort) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LSort) # gmapT :: (forall b. Data b => b -> b) -> LSort -> LSort # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LSort -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LSort -> r # gmapQ :: (forall d. Data d => d -> u) -> LSort -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> LSort -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LSort -> m LSort # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LSort -> m LSort # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LSort -> m LSort #
Ord LSort # |
Methods compare :: LSort -> LSort -> Ordering # (<) :: LSort -> LSort -> Bool # (<=) :: LSort -> LSort -> Bool # (>) :: LSort -> LSort -> Bool # (>=) :: LSort -> LSort -> Bool # max :: LSort -> LSort -> LSort # min :: LSort -> LSort -> LSort #
Show LSort # |
Methods showsPrec :: Int -> LSort -> ShowS # show :: LSort -> String # showList :: [LSort] -> ShowS #
Generic LSort # |
Associated Types type Rep LSort :: * -> * # Methods from :: LSort -> Rep LSort x # to :: Rep LSort x -> LSort #
Binary LSort # |
Methods put :: LSort -> Put # get :: Get LSort # putList :: [LSort] -> Put #
NFData LSort # |
Methods rnf :: LSort -> () #
type Rep LSort # |
type Rep LSort = D1 (MetaData "LSort" "Term.LTerm" "tamarin-prover-term-1.2.2-AAX5pCkSPqj7TesI35mR1r" False) ((:+:) ((:+:) (C1 (MetaCons "LSortPub" PrefixI False) U1) (C1 (MetaCons "LSortFresh" PrefixI False) U1)) ((:+:) (C1 (MetaCons "LSortMsg" PrefixI False) U1) (C1 (MetaCons "LSortNode" PrefixI False) U1)))

data LVar #

Logical variables. Variables with the same name and index but different sorts are regarded as different variables.

Constructors

LVar |
Fields lvarName :: String lvarSort :: !LSort lvarIdx :: !Integer

Instances

Eq LVar # |
Methods (==) :: LVar -> LVar -> Bool # (/=) :: LVar -> LVar -> Bool #
Data LVar # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LVar -> c LVar # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c LVar # toConstr :: LVar -> Constr # dataTypeOf :: LVar -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c LVar) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LVar) # gmapT :: (forall b. Data b => b -> b) -> LVar -> LVar # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LVar -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LVar -> r # gmapQ :: (forall d. Data d => d -> u) -> LVar -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> LVar -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> LVar -> m LVar # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LVar -> m LVar # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LVar -> m LVar #
Ord LVar # |
Methods compare :: LVar -> LVar -> Ordering # (<) :: LVar -> LVar -> Bool # (<=) :: LVar -> LVar -> Bool # (>) :: LVar -> LVar -> Bool # (>=) :: LVar -> LVar -> Bool # max :: LVar -> LVar -> LVar # min :: LVar -> LVar -> LVar #
Show LVar # |
Methods showsPrec :: Int -> LVar -> ShowS # show :: LVar -> String # showList :: [LVar] -> ShowS #
Generic LVar # |
Associated Types type Rep LVar :: * -> * # Methods from :: LVar -> Rep LVar x # to :: Rep LVar x -> LVar #
Binary LVar # |
Methods put :: LVar -> Put # get :: Get LVar # putList :: [LVar] -> Put #
NFData LVar # |
Methods rnf :: LVar -> () #
IsVar LVar # |
HasFrees LVar # |
Methods foldFrees :: Monoid m => (LVar -> m) -> LVar -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> LVar -> m # mapFrees :: Applicative f => MonotoneFunction f -> LVar -> f LVar #
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 #
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) #
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) #
type Rep LVar # |
type Rep LVar = D1 (MetaData "LVar" "Term.LTerm" "tamarin-prover-term-1.2.2-AAX5pCkSPqj7TesI35mR1r" False) (C1 (MetaCons "LVar" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "lvarName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) ((:*:) (S1 (MetaSel (Just Symbol "lvarSort") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 LSort)) (S1 (MetaSel (Just Symbol "lvarIdx") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Integer)))))

type NodeId = LVar #

An alternative name for logical variables, which are intented to be variables of sort `LSortNode`.

type LTerm c = VTerm c LVar #

Terms used for proving; i.e., variables fixed to logical variables.

type LNTerm = VTerm Name LVar #

Terms used for proving; i.e., variables fixed to logical variables and constants to Names.

freshLVar :: MonadFresh m => String -> LSort -> m LVar #

`freshLVar v` represents a fresh logical variable with name `v`.

sortPrefix :: LSort -> String #

`sortPrefix s` is the prefix we use for annotating variables of sort `s`.

sortSuffix :: LSort -> String #

`sortSuffix s` is the suffix we use for annotating variables of sort `s`.

sortCompare :: LSort -> LSort -> Maybe Ordering #

`sortCompare s1 s2` compares `s1` and `s2` with respect to the partial order on sorts. Partial order: Node Msg / -- Pub Fresh

sortOfLTerm :: Show c => (c -> LSort) -> LTerm c -> LSort #

Returns the most precise sort of an `LTerm`.

sortOfLNTerm :: LNTerm -> LSort #

Returns the most precise sort of an `LNTerm`.

sortOfLit :: Lit Name LVar -> LSort #

Returns the most precise sort of a `Lit`.

isMsgVar :: LNTerm -> Bool #

Is a term a message variable?

isFreshVar :: LNTerm -> Bool #

Is a term a fresh variable?

isSimpleTerm :: LNTerm -> Bool #

A term is *simple* iff there is an instance of this term that can be constructed from public names only. i.e., the term does not contain any fresh names, fresh variables, or private function symbols.

getVar :: LNTerm -> Maybe [LVar] #

If the term is a variable, return it, nothing otherwise.

getMsgVar :: LNTerm -> Maybe [LVar] #

If the term is a message variable, return it, nothing otherwise.

niFactors :: LNTerm -> [LNTerm] #

The non-inverse factors of a term.

containsPrivate :: Term t -> Bool #

`containsPrivate t` returns `True` if `t` contains private function symbols.

containsNoPrivateExcept :: [ByteString] -> Term t -> Bool #

containsNoPrivateExcept t t2`returns` True`if` t2`contains private function symbols other than` t@.

neverContainsFreshPriv :: LNTerm -> Bool #

`True` iff no instance of this term contains fresh names or private function symbols.

## Destructors

ltermVar :: LSort -> LTerm c -> Maybe LVar #

Extract a variable of the given sort from a term that may be such a variable. Use `termVar`, if you do not want to restrict the sort.

ltermVar' :: Show c => LSort -> LTerm c -> LVar #

Extract a variable of the given sort from a term that must be such a variable. Fails with an error, if that is not possible.

ltermNodeId :: LTerm c -> Maybe LVar #

Extract a node-id variable from a term that may be a node-id variable.

ltermNodeId' :: Show c => LTerm c -> LVar #

Extract a node-id variable from a term that must be a node-id variable.

bltermNodeId :: BLTerm -> Maybe LVar #

Extract a node-id variable from a term that may be a node-id variable.

bltermNodeId' :: BLTerm -> LVar #

Extract a node-id variable from a term that must be a node-id variable.

## Manging Free LVars

class HasFrees t where #

`HasFree t` denotes that the type `t` has free `LVar` variables. They can be collected using `foldFrees` and `foldFreesOcc` and mapped in the context of an applicative functor using `mapFrees`.

When defining instances of this class, you have to ensure that only the free LVars are collected and mapped and no others. The instances for standard Haskell types assume that all variables free in all type arguments are free. The `foldFreesOcc` is only used to define the function `varOccurences`. See below for required properties of the instance methods.

Once we need it, we can use type synonym instances to parametrize over the variable type.

Minimal complete definition

foldFrees, foldFreesOcc, mapFrees

Methods

foldFrees :: Monoid m => (LVar -> m) -> t -> m #

foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> t -> m #

mapFrees :: Applicative f => MonotoneFunction f -> t -> f t #

Instances

HasFrees Bool # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Bool -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Bool -> m # mapFrees :: Applicative f => MonotoneFunction f -> Bool -> f Bool #
HasFrees Char # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Char -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Char -> m # mapFrees :: Applicative f => MonotoneFunction f -> Char -> f Char #
HasFrees Int # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Int -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Int -> m # mapFrees :: Applicative f => MonotoneFunction f -> Int -> f Int #
HasFrees Integer # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Integer -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Integer -> m # mapFrees :: Applicative f => MonotoneFunction f -> Integer -> f Integer #
HasFrees () # |
Methods foldFrees :: Monoid m => (LVar -> m) -> () -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> () -> m # mapFrees :: Applicative f => MonotoneFunction f -> () -> f () #
HasFrees LVar # |
Methods foldFrees :: Monoid m => (LVar -> m) -> LVar -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> LVar -> m # mapFrees :: Applicative f => MonotoneFunction f -> LVar -> f LVar #
HasFrees a => HasFrees [a] # |
Methods foldFrees :: Monoid m => (LVar -> m) -> [a] -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> [a] -> m # mapFrees :: Applicative f => MonotoneFunction f -> [a] -> f [a] #
HasFrees a => HasFrees (Maybe a) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Maybe a -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Maybe a -> m # mapFrees :: Applicative f => MonotoneFunction f -> Maybe a -> f (Maybe a) #
(Ord a, HasFrees a) => HasFrees (Set a) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Set a -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Set a -> m # mapFrees :: Applicative f => MonotoneFunction f -> Set a -> f (Set a) #
HasFrees a => HasFrees (Conj a) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Conj a -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Conj a -> m # mapFrees :: Applicative f => MonotoneFunction f -> Conj a -> f (Conj a) #
HasFrees a => HasFrees (Disj a) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Disj a -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Disj a -> m # mapFrees :: Applicative f => MonotoneFunction f -> Disj a -> f (Disj a) #
(HasFrees l, Ord l) => HasFrees (Term l) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Term l -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Term l -> m # mapFrees :: Applicative f => MonotoneFunction f -> Term l -> f (Term l) #
HasFrees a => HasFrees (RRule a) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> RRule a -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> RRule a -> m # mapFrees :: Applicative f => MonotoneFunction f -> RRule a -> f (RRule a) #
HasFrees a => HasFrees (Match a) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Match a -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Match a -> m # mapFrees :: Applicative f => MonotoneFunction f -> Match a -> f (Match a) #
HasFrees a => HasFrees (Equal a) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Equal a -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Equal a -> m # mapFrees :: Applicative f => MonotoneFunction f -> Equal a -> f (Equal a) #
HasFrees v => HasFrees (BVar v) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> BVar v -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> BVar v -> m # mapFrees :: Applicative f => MonotoneFunction f -> BVar v -> f (BVar v) #
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) #
(HasFrees a, HasFrees b) => HasFrees (Either a b) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Either a b -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Either a b -> m # mapFrees :: Applicative f => MonotoneFunction f -> Either a b -> f (Either a b) #
(HasFrees a, HasFrees b) => HasFrees (a, b) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> (a, b) -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> (a, b) -> m # mapFrees :: Applicative f => MonotoneFunction f -> (a, b) -> f (a, b) #
(Ord k, HasFrees k, HasFrees v) => HasFrees (Map k v) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Map k v -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Map k v -> m # mapFrees :: Applicative f => MonotoneFunction f -> Map k v -> f (Map k v) #
HasFrees v => HasFrees (Lit c v) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> Lit c v -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> Lit c v -> m # mapFrees :: Applicative f => MonotoneFunction f -> Lit c v -> f (Lit c v) #
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) #
(HasFrees a, HasFrees b, HasFrees c) => HasFrees (a, b, c) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> (a, b, c) -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> (a, b, c) -> m # mapFrees :: Applicative f => MonotoneFunction f -> (a, b, c) -> f (a, b, c) #

data MonotoneFunction f #

For performance reasons, we distinguish between monotone functions on `LVar`s and arbitrary functions. For a monotone f, if `x <= y`, then `f x <= f y`. This ensures that the AC-normal form does not have to be recomputed. If you are unsure about what to use, then use the `Arbitrary` function.

Constructors

Monotone (LVar -> f LVar) |
Arbitrary (LVar -> f LVar) |

occurs :: HasFrees t => LVar -> t -> Bool #

`v `occurs` t` iff variable `v` occurs as a free variable in `t`.

freesList :: HasFrees t => t -> [LVar] #

`freesList t` is the list of all free variables of `t`.

frees :: HasFrees t => t -> [LVar] #

`frees t` is the sorted and duplicate-free list of all free variables in `t`.

someInst :: (MonadFresh m, MonadBind LVar LVar m, HasFrees t) => t -> m t #

`someInst t` returns an instance of `t` where all free variables whose binding is not yet determined by the caller are replaced with fresh variables.

rename :: (MonadFresh m, HasFrees a) => a -> m a #

`rename t` replaces all variables in `t` with fresh variables. Note that the result is not guaranteed to be equal for terms that are equal modulo changing the indices of variables.

renameIgnoring :: (MonadFresh m, HasFrees a) => [LVar] -> a -> m a #

`renameIgnoring t vars` replaces all variables in `t` with fresh variables, excpet for the variables in `vars`. Note that the result is not guaranteed to be equal for terms that are equal modulo changing the indices of variables.

eqModuloFreshnessNoAC :: (HasFrees a, Eq a) => a -> a -> Bool #

`eqModuloFreshness t1 t2` checks whether `t1` is equal to `t2` modulo renaming of indices of free variables. Note that the normal form is not unique with respect to AC symbols.

avoid :: HasFrees t => t -> FreshState #

`avoid t` computes a `FreshState` that avoids generating variables occurring in `t`.

evalFreshAvoiding :: HasFrees t => Fresh a -> t -> a #

`m `evalFreshAvoiding` t` evaluates the monadic action `m` with a fresh-variable supply that avoids generating variables occurring in `t`.

evalFreshTAvoiding :: (Monad m, HasFrees t) => FreshT m a -> t -> m a #

`m `evalFreshTAvoiding` t` evaluates the monadic action `m` in the underlying monad with a fresh-variable supply that avoids generating variables occurring in `t`.

renameAvoiding :: (HasFrees s, HasFrees t) => s -> t -> s #

`s `renameAvoiding` t` replaces all free variables in `s` by fresh variables avoiding variables in `t`.

renameAvoidingIgnoring :: (HasFrees s, HasFrees t) => s -> t -> [LVar] -> s #

`s `renameAvoiding` t` replaces all free variables in `s` by fresh variables avoiding variables in `t`.

avoidPrecise :: HasFrees t => t -> FreshState #

`avoidPrecise t` computes a `FreshState` that avoids generating variables occurring in `t`.

renamePrecise :: (MonadFresh m, HasFrees a) => a -> m a #

`renamePrecise t` replaces all variables in `t` with fresh variables. If `PreciseFresh` is used with non-AC terms and identical fresh state, the same result is returned for two terms that only differ in the indices of variables.

renameDropNamehint :: (MonadFresh m, MonadBind LVar LVar m, HasFrees a) => a -> m a #

varOccurences :: HasFrees a => a -> [(LVar, Set Occurence)] #

Returns the variables occuring in `t` together with the contexts they appear in. Note that certain contexts (and variables only occuring in such contexts) are ignored by this function. The function is used to "guess" renamings of variables, i.e., if t is a renaming of s, then variables that occur in equal contexts in t and s are probably renamings of each other.

# BVar

data BVar v #

Bound and free variables.

Constructors

Bound Integer | A bound variable in De-Brujin notation.
Free v | A free variable.

Instances

Monad BVar # |
Methods (>>=) :: BVar a -> (a -> BVar b) -> BVar b # (>>) :: BVar a -> BVar b -> BVar b # return :: a -> BVar a # fail :: String -> BVar a #
Functor BVar # |
Methods fmap :: (a -> b) -> BVar a -> BVar b # (<$) :: a -> BVar b -> BVar a #
Applicative BVar # |
Methods pure :: a -> BVar a # (<*>) :: BVar (a -> b) -> BVar a -> BVar b # (*>) :: BVar a -> BVar b -> BVar b # (<*) :: BVar a -> BVar b -> BVar a #
Foldable BVar # |
Methods fold :: Monoid m => BVar m -> m # foldMap :: Monoid m => (a -> m) -> BVar a -> m # foldr :: (a -> b -> b) -> b -> BVar a -> b # foldr' :: (a -> b -> b) -> b -> BVar a -> b # foldl :: (b -> a -> b) -> b -> BVar a -> b # foldl' :: (b -> a -> b) -> b -> BVar a -> b # foldr1 :: (a -> a -> a) -> BVar a -> a # foldl1 :: (a -> a -> a) -> BVar a -> a # toList :: BVar a -> [a] # null :: BVar a -> Bool # length :: BVar a -> Int # elem :: Eq a => a -> BVar a -> Bool # maximum :: Ord a => BVar a -> a # minimum :: Ord a => BVar a -> a # sum :: Num a => BVar a -> a # product :: Num a => BVar a -> a #
Traversable BVar # |
Methods traverse :: Applicative f => (a -> f b) -> BVar a -> f (BVar b) # sequenceA :: Applicative f => BVar (f a) -> f (BVar a) # mapM :: Monad m => (a -> m b) -> BVar a -> m (BVar b) # sequence :: Monad m => BVar (m a) -> m (BVar a) #
Apply BLTerm # |
Methods apply :: LNSubst -> BLTerm -> BLTerm #
Apply BLVar # |
Methods apply :: LNSubst -> BLVar -> BLVar #
Eq v => Eq (BVar v) # |
Methods (==) :: BVar v -> BVar v -> Bool # (/=) :: BVar v -> BVar v -> Bool #
Data v => Data (BVar v) # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BVar v -> c (BVar v) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (BVar v) # toConstr :: BVar v -> Constr # dataTypeOf :: BVar v -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (BVar v)) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (BVar v)) # gmapT :: (forall b. Data b => b -> b) -> BVar v -> BVar v # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BVar v -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BVar v -> r # gmapQ :: (forall d. Data d => d -> u) -> BVar v -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> BVar v -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> BVar v -> m (BVar v) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BVar v -> m (BVar v) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BVar v -> m (BVar v) #
Ord v => Ord (BVar v) # |
Methods compare :: BVar v -> BVar v -> Ordering # (<) :: BVar v -> BVar v -> Bool # (<=) :: BVar v -> BVar v -> Bool # (>) :: BVar v -> BVar v -> Bool # (>=) :: BVar v -> BVar v -> Bool # max :: BVar v -> BVar v -> BVar v # min :: BVar v -> BVar v -> BVar v #
Show v => Show (BVar v) # |
Methods showsPrec :: Int -> BVar v -> ShowS # show :: BVar v -> String # showList :: [BVar v] -> ShowS #
Generic (BVar v) # |
Associated Types type Rep (BVar v) :: * -> * # Methods from :: BVar v -> Rep (BVar v) x # to :: Rep (BVar v) x -> BVar v #
Binary v => Binary (BVar v) # |
Methods put :: BVar v -> Put # get :: Get (BVar v) # putList :: [BVar v] -> Put #
NFData v => NFData (BVar v) # |
Methods rnf :: BVar v -> () #
HasFrees v => HasFrees (BVar v) # |
Methods foldFrees :: Monoid m => (LVar -> m) -> BVar v -> m # foldFreesOcc :: Monoid m => (Occurence -> LVar -> m) -> Occurence -> BVar v -> m # mapFrees :: Applicative f => MonotoneFunction f -> BVar v -> f (BVar v) #
type Rep (BVar v) # |
type Rep (BVar v) = D1 (MetaData "BVar" "Term.LTerm" "tamarin-prover-term-1.2.2-AAX5pCkSPqj7TesI35mR1r" False) ((:+:) (C1 (MetaCons "Bound" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Integer))) (C1 (MetaCons "Free" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 v))))

type BLVar = BVar LVar #

`LVar`s combined with quantified variables. They occur only in `LFormula`s.

type BLTerm = NTerm BLVar #

Terms built over names and `LVar`s combined with quantified variables.

foldBVar :: (Integer -> a) -> (v -> a) -> BVar v -> a #

Fold a possibly bound variable.

fromFree :: BVar v -> v #

Extract the name of free variable under the assumption the variable is guaranteed to be of the form `Free a`.

# Pretty-Printing

prettyLVar :: Document d => LVar -> d #

Pretty print a `LVar`.

prettyNodeId :: Document d => NodeId -> d #

Pretty print a `NodeId`.

prettyNTerm :: (Show v, Document d) => NTerm v -> d #

Pretty print an `NTerm`.

prettyLNTerm :: Document d => LNTerm -> d #

Pretty print an `LTerm`.

showLitName :: Lit Name LVar -> String #

Pretty print a literal for case generation.

# Convenience exports

module Term.VTerm