Safe Haskell | Safe-Inferred |
---|
Various properties and transformations of Boogie program elements
- type TypeBinding = Map Id Type
- typeSubst :: TypeBinding -> Type -> Type
- isFreeIn :: Id -> Type -> Bool
- unifier :: [Id] -> [Type] -> [Type] -> Maybe TypeBinding
- oneSidedUnifier :: [Id] -> [Type] -> [Id] -> [Type] -> Maybe TypeBinding
- boundUnifier :: [Id] -> [Id] -> [Type] -> [Id] -> [Type] -> Maybe TypeBinding
- (<==>) :: Type -> Type -> Bool
- freeVarsTwoState :: Expression -> ([Id], [Id])
- freeVars :: Expression -> [Id]
- freeOldVars :: Expression -> [Id]
- type VarBinding = Map Id BareExpression
- exprSubst :: VarBinding -> Expression -> Expression
- paramSubst :: PSig -> PDef -> Expression -> Expression
- preconditions :: [Contract] -> [SpecClause]
- postconditions :: [Contract] -> [SpecClause]
- modifies :: [Contract] -> [Id]
- assumePreconditions :: PSig -> PSig
- data FSig = FSig {
- fsigName :: Id
- fsigTypeVars :: [Id]
- fsigArgTypes :: [Type]
- fsigRetType :: Type
- data FDef = FDef {
- fdefArgs :: [Id]
- fdefGuard :: Expression
- fdefBody :: Expression
- data PSig = PSig {
- psigName :: Id
- psigTypeVars :: [Id]
- psigArgs :: [IdTypeWhere]
- psigRets :: [IdTypeWhere]
- psigContracts :: [Contract]
- psigParams :: PSig -> [IdTypeWhere]
- psigArgTypes :: PSig -> [Type]
- psigRetTypes :: PSig -> [Type]
- psigModifies :: PSig -> [Id]
- psigRequires :: PSig -> [SpecClause]
- psigEnsures :: PSig -> [SpecClause]
- data PDef = PDef {}
- num :: Integer -> Pos BareExpression
- eneg :: Pos BareExpression -> Pos BareExpression
- enot :: Pos BareExpression -> Pos BareExpression
- (|+|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|-|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|*|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|/|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|%|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|=|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|!=|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|<|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|<=|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|>|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|>=|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|&|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|||) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|=>|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- (|<=>|) :: Pos BareExpression -> Pos BareExpression -> Pos BareExpression
- assume :: Pos BareExpression -> Pos BareStatement
- interval :: Enum t => (t, t) -> [t]
- fromRight :: Either a b -> b
- mapFst :: (t -> t1) -> (t, t2) -> (t1, t2)
- mapSnd :: (t -> t2) -> (t1, t) -> (t1, t2)
- mapBoth :: (t -> t1) -> (t, t) -> (t1, t1)
- changeState :: (s -> t) -> (t -> s -> s) -> State t a -> State s a
- withLocalState :: (s -> t) -> State t a -> State s a
Types
type TypeBinding = Map Id TypeSource
Mapping from type variables to types
typeSubst :: TypeBinding -> Type -> TypeSource
typeSubst
binding t
:
Substitute all free type variables in t
according to binding;
all variables in the domain of bindings
are considered free if not explicitly bound
isFreeIn :: Id -> Type -> BoolSource
x
isFreeIn
t
: does x
occur as a free type variable in t
?
x
must not be a name of a type constructor
unifier :: [Id] -> [Type] -> [Type] -> Maybe TypeBindingSource
unifier
fv xs ys
: most general unifier of xs
and ys
with shared free type variables fv
oneSidedUnifier :: [Id] -> [Type] -> [Id] -> [Type] -> Maybe TypeBindingSource
oneSidedUnifier
fv xs tv ys
:
Most general unifier of xs
and ys
,
where only xs
contain free variables (fv
),
while ys
contain rigid type variables tv
, which might clash with fv
boundUnifier :: [Id] -> [Id] -> [Type] -> [Id] -> [Type] -> Maybe TypeBindingSource
boundUnifier
fv bv1 xs bv2 ys
:
Most general unifier of xs
and ys
,
where bv1
are bound type variables in xs
and bv2
are bound type variables in ys
,
and fv
are free type variables of the enclosing context
(<==>) :: Type -> Type -> BoolSource
Semantic equivalence on types (equality up to renaming of bound type variables)
Expressions
freeVarsTwoState :: Expression -> ([Id], [Id])Source
Free variables in an expression, referred to in current state and old state
freeVars :: Expression -> [Id]Source
Free variables in an expression, in current state
freeOldVars :: Expression -> [Id]Source
Free variables in an expression, in old state
type VarBinding = Map Id BareExpressionSource
Mapping from variables to expressions
exprSubst :: VarBinding -> Expression -> ExpressionSource
exprSubst
binding e
: substitute all free variables in e
according to binding
;
all variables in the domain of bindings
are considered free if not explicitly bound
paramSubst :: PSig -> PDef -> Expression -> ExpressionSource
paramSubst
sig def
:
Substitute parameter names from sig
in an expression with their equivalents from def
Specs
preconditions :: [Contract] -> [SpecClause]Source
preconditions
specs
: all precondition clauses in specs
postconditions :: [Contract] -> [SpecClause]Source
postconditions
specs
: all postcondition clauses in specs
assumePreconditions :: PSig -> PSigSource
Make all preconditions in contracts free
Funstions and procedures
Function signature
FSig | |
|
Function definition
FDef | |
|
Procedure signature
PSig | |
|
psigParams :: PSig -> [IdTypeWhere]Source
All parameters of a procedure signature
psigArgTypes :: PSig -> [Type]Source
Types of in-parameters of a procedure signature
psigRetTypes :: PSig -> [Type]Source
Types of out-parameters of a procedure signature
psigModifies :: PSig -> [Id]Source
Modifies clauses of a procedure signature
psigRequires :: PSig -> [SpecClause]Source
Preconditions of a procedure signature
psigEnsures :: PSig -> [SpecClause]Source
Postconditions of a procedure signature
Procedure definition; a single procedure might have multiple definitions (one per body)
PDef | |
|
Code generation
num :: Integer -> Pos BareExpressionSource
Misc
changeState :: (s -> t) -> (t -> s -> s) -> State t a -> State s aSource
Execute a computation with state of type t
inside a computation with state of type s
withLocalState :: (s -> t) -> State t a -> State s aSource
withLocalState
localState e
:
Execute e
in current state modified by localState
, and then restore current state