PyNuSMV is a Python framework for experimenting and prototyping BDD-based model checking algorithms based on NuSMV. It gives access to main BDD-related NuSMV functionalities, like model and BDD manipulation, while hiding NuSMV implementation details by providing wrappers to NuSMV functions and data structures. In particular, NuSMV models can be read, parsed and compiled, giving full access to SMV’s rich modeling language and vast collection of existing models.
PyNuSMV is composed of several modules, each one proposing some functionalities:
Warning
Before using any PyNuSMV functionality, make sure to call init_nusmv function to initialize NuSMV; do not forget to also call deinit_nusmv when you do not need PyNuSMV anymore to clean everything needed by NuSMV to run.
The pynusmv.init module provides functions to initialize and quit NuSMV.
The init_nusmv() function can be used as a context manager for the with Python statement:
with init_nusmv():
...
Warning
init_nusmv() should be called before any other call to pynusmv functions; deinit_nusmv() should be called after using pynusmv.
Initialize NuSMV. Must be called only once before calling deinit_nusmv().
Parameters: | collecting – Whether or not collecting pointer wrappers to free them before deiniting nusmv. |
---|
Quit NuSMV. Must be called only once, after calling init_nusmv().
Parameters: | ddinfo – Whether or not display Decision Diagrams statistics. |
---|
Reset NuSMV, i.e. deinit it and init it again. Cannot be called before init_nusmv().
The pynusmv.glob module provide some functions to access global NuSMV functionalities. These functions are used to feed an SMV model to NuSMV and build the different structures representing the model, like flattening the model, building its BDD encoding and getting the BDD-encoded FSM.
Besides the functions, this module provides an access to main globally stored data structures like the flat hierarchy, the BDD encoding, the symbols table and the propositions database.
Load the given model. This model can be of several forms:
Flatten the read model and store it in global data structures.
Raise: | a NuSMVNoReadModelError if no model is read yet |
---|---|
Raise: | a NuSMVCannotFlattenError if an error occurred during flattening |
Raise: | a NuSMVModelAlreadyFlattenedError if the model is already flattened |
Warning
In case of type checking errors, a message is printed at stderr and a NuSMVCannotFlattenError is raised.
Return the main symbols table of the current model.
Return type: | SymbTable |
---|
Encode the BDD variables of the current model and store it in global data structures. If variables_ordering is provided, use this ordering to encode the variables; otherwise, the default ordering method is used.
Parameters: |
|
---|---|
Raise: | a NuSMVNeedFlatHierarchyError if the model is not flattened |
Raise: | a NuSMVModelAlreadyEncodedError if the variables are already encoded |
Encode the BDD variables of the given layers and store them in global data structures.
Parameters: |
|
---|
Return the main bdd encoding of the current model.
Return type: | BddEnc |
---|
Build the Sexp FSM (Simple Expression FSM) of the current model and store it in global data structures.
Raise: | a NuSMVNeedFlatHierarchyError if the model is not flattened |
---|---|
Raise: | a NuSMVFlatModelAlreadyBuiltError if the Sexp FSM is already built |
Build the BDD FSM of the current model and store it in global data structures.
Raise: | a NuSMVNeedFlatModelError if the Sexp FSM of the model is not built yet |
---|---|
Raise: | a NuSMVNeedVariablesEncodedError if the variables of the model are not encoded yet |
Raise: | a NuSMVModelAlreadyBuiltError if the BDD FSM of the model is already built |
Return the global flat hierarchy.
Return type: | FlatHierarchy |
---|
Compute the read model and store its parts in global data structures. This function is a shortcut for calling all the steps of the model building that are not yet performed. If variables_ordering is not None, it is used as a file containing the order of variables used for encoding the model into BDDs.
Parameters: | variables_ordering (path to file) – the file containing a custom ordering |
---|
The pynusmv.model module provides a way to define NuSMV modules in Python. The module is composed of several classes that fall in five sections:
Bases: pynusmv.model.Identifier
The self identifier.
Bases: pynusmv.model.ComplexIdentifier
Access to a part of a module instance.
Bases: pynusmv.model.ComplexIdentifier
Access to an index of an array.
Bases: pynusmv.model.Constant
A range of integers.
Bases: pynusmv.model.Function
Converting an expression into a specific type.
Bases: pynusmv.model.Function
A function applied on a word.
Bases: pynusmv.model.Expression
Array subscript.
Bases: pynusmv.model.Expression
Word bit selection.
Bases: pynusmv.model.Operator
A concatenation (::) of expressions.
Bases: pynusmv.model.Operator
A multiplication (*) of expressions.
Bases: pynusmv.model.Operator
A division (/) of expressions.
Bases: pynusmv.model.Operator
A modulo (%) of expressions.
Bases: pynusmv.model.Operator
An addition (+) of expressions.
Bases: pynusmv.model.Operator
A subtraction (-) of expressions.
Bases: pynusmv.model.Operator
A left shift (<<) of expressions.
Bases: pynusmv.model.Operator
A right shift (>>) of expressions.
Bases: pynusmv.model.Operator
A union (union) of expressions.
Bases: pynusmv.model.Operator
The ? : expression.
Bases: pynusmv.model.Element
An array define expression.
Bases: pynusmv.model.SimpleType
An array type.
Bases: pynusmv.model.Type
A module instantiation.
Bases: pynusmv.model.MappingSection
Declaring variables.
Bases: pynusmv.model.MappingSection
Declaring input variables.
Bases: pynusmv.model.MappingSection
Declaring frozen variables.
Bases: pynusmv.model.MappingSection
Declaring defines.
Bases: pynusmv.model.MappingSection
Declaring assigns.
Bases: pynusmv.model.ListingSection
Declaring constants.
Bases: pynusmv.model.ListingSection
A COMPASSION section.
Bases: pynusmv.model.Declaration
A declared IVAR.
Bases: pynusmv.model.Declaration
A declared FROZENVAR.
Bases: pynusmv.model.Declaration
A declared DEFINE.
Bases: pynusmv.model.Modtype
A generic module.
To create a new module, the user must subclass the Module class and add class attributes with names corresponding to sections of NuSMV module definitions: VAR, IVAR, FROZENVAR, DEFINE, CONSTANTS, ASSIGN, TRANS, INIT, INVAR, FAIRNESS, JUSTICE, COMPASSION.
In addition to these attributes, the ARGS and NAME attributes can be defined. If NAME is defined, it overrides module name for the NuSMV module name. If ARGS is defined, it must be a sequence object where each element’s string representation is an argument of the module.
Treatment of the section depends of the type of the section and the value of the corresponding attribute.
If the value of the section is a string (str), it is parsed as the body of the declaration. If it is a dictionary (dict), keys are parsed as names of variables (or input variables, define, etc.) if they are strings, or used as they are otherwise, and values are parsed as bodies of the declaration (if strings, kept as they are otherwise). Otherwise, the value must be a sequence, and each element is treated separately:
In addition to these sections, the class body can contain instances of pynsumv.model.Declaration. These ones take the name of the corresponding variable, and are added to the corresponding section (VAR, IVAR, FROZENVAR or DEFINE) when creating the class.
For example, the class
class TwoCounter(Module):
NAME = "twoCounter"
ARGS = ["run"]
c1 = Range(0, 2)
VAR = {"c2": "0..2"}
INIT = [c1 == 0 & "c2 = 0"]
TRANS = [Next(c1) == Ite("run", (c1 + 1) % 2, c1),
"next(c2) = run ? c2+1 mod 2 : c2"]
defines the module
MODULE twoCounter(run)
VAR
c1 : 0..2;
c2 : 0..2;
INIT
c1 = 0 & c2 = 0
TRANS
next(c1) = run ? c1+1 mod 2 : c1
TRANS
next(c2) = run ? c2+1 mod 2 : c2
After creation, module sections satisfy the following patterns:
The pynusmv.node module provides classes representing NuSMV internal nodes, as well as a class FlatHierarchy to represent a NuSMV flat hierarchary.
Traverse the hierarchy represented by node and transfer it to the node hash table.
Parameters: | node (a SWIG wrapper for a NuSMV node_ptr) – the node |
---|
Bases: pynusmv.utils.PointerWrapper
A generic NuSMV node.
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
A generic section.
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Node
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Section
Bases: pynusmv.node.Node
A generic type node.
Bases: pynusmv.node.Type
The boolean type.
Bases: pynusmv.node.Type
An unsigned word type.
Bases: pynusmv.node.UnsignedWord
An unsigned word type.
Bases: pynusmv.node.Type
A signed word type.
Bases: pynusmv.node.Type
A range type.
Bases: pynusmv.node.Type
An array type.
Bases: pynusmv.node.Type
The enumeration type.
Bases: pynusmv.node.Type
A module instantiation type.
Bases: pynusmv.node.Type
The process type.
Warning
This type is deprecated.
Bases: pynusmv.node.Type
The integer number type.
Warning
This node type is not supported by NuSMV.
Bases: pynusmv.node.Type
The real number type.
Warning
This node type is not supported by NuSMV.
Bases: pynusmv.node.Type
The word array type.
Warning
This type is not documented in NuSMV documentation.
Bases: pynusmv.node.Node
A generic expression node.
Parse the string representation of the given expression and return the corresponding node.
Parameters: | expression – the string to parse |
---|---|
Return type: | Expression subclass |
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Leaf
A FAILURE node.
Bases: pynusmv.node.Leaf
The FALSE expression.
Bases: pynusmv.node.Leaf
The TRUE expression.
Bases: pynusmv.node.Leaf
The self expression.
Bases: pynusmv.node.Leaf
An ATOM node.
Bases: pynusmv.node.Leaf
A node containing an integer.
Bases: pynusmv.node.Leaf
A node containing an unsigned word value.
Bases: pynusmv.node.Leaf
A node containing a signed word value.
Bases: pynusmv.node.Leaf
A rational number.
Warning
This node type is not supported by NuSMV.
Bases: pynusmv.node.Leaf
A real number.
Warning
This node type is not supported by NuSMV.
Bases: pynusmv.node.Leaf
An exponential-formed number.
Warning
This node type is not supported by NuSMV.
Bases: pynusmv.node.Expression
A CONTEXT node.
Bases: pynusmv.node.Expression
An ARRAY node.
Bases: pynusmv.node.Expression
A range of integers.
Bases: pynusmv.node.Expression
A set of cases.
Bases: pynusmv.node.Expression
The cond ? truebranch : falsebranch expression.
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
A NOT expression.
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
A unitary minus expression.
Bases: pynusmv.node.Expression
A NEXT expression.
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
A Bit selection node.
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
A boolean casting node.
Bases: pynusmv.node.Expression
A word-1 casting node.
Bases: pynusmv.node.Expression
A signed number casting node.
Bases: pynusmv.node.Expression
An unsigned number casting node.
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
A WAWRITE node.
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Expression
A size-of-word node.
Bases: pynusmv.node.Expression
An integer casting node.
Bases: pynusmv.node.Expression
A set expression.
Bases: pynusmv.node.Expression
A generic custom expression.
Bases: pynusmv.node.CustomExpression
A set expression.
Bases: pynusmv.node.CustomExpression
A custom identifier.
Bases: pynusmv.node.Expression
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Property
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Node
Bases: pynusmv.node.Atom
A Declaration behaves like an atom, except that it knows which type it belongs to. Furthermore, it does not know its name for sure, and cannot be printed without giving it a name.
Bases: pynusmv.node.Declaration
A declared VAR.
Bases: pynusmv.node.Declaration
A declared IVAR.
Bases: pynusmv.node.Declaration
A declared FROZENVAR.
Bases: pynusmv.node.Declaration
A declared DEFINE.
Bases: pynusmv.utils.PointerWrapper
Python class for flat hiearchy. The flat hierarchy is a NuSMV model where all the modules instances are reduced to their variables.
A FlatHierarchy is used to store information obtained after flattening module hierarchy. It stores:
Note
There are a few assumptions about the content stored in this class:
The pynusmv.fsm module provides some functionalities about FSMs represented and stored by NuSMV:
Bases: pynusmv.utils.PointerWrapper
Python class for FSM structure, encoded into BDDs.
The BddFsm provides some functionalities on the FSM: getting initial and reachable states as a BDD, getting or replacing the transition relation, getting fairness, state and inputs constraints, getting pre and post images of BDDs, possibly through particular actions, picking and counting states and actions of given BDDs.
Return the pre-image of states in this FSM. If inputs is not None, it is used as constraints to get pre-states that are reachable through these inputs.
Parameters: | |
---|---|
Return type: |
Return the weak pre-image of states in this FSM. This means that it returns a BDD representing the set of states with corresponding inputs <s,i> such that there is a state in state reachable from s through i.
Parameters: | states (BDD) – the states from which getting the weak pre-image |
---|---|
Return type: | BDD |
Return the post-image of states in this FSM. If inputs is not None, it is used as constraints to get post-states that are reachable through these inputs.
Parameters: | |
---|---|
Return type: |
Return a BDD representing a state of bdd.
Return type: | State |
---|---|
Raise: | a NuSMVBddPickingError if bdd is false or an error occurs while picking one state |
Return a BDD representing a state of bdd, picked at random.
Return type: | State |
---|---|
Raise: | a NuSMVBddPickingError if bdd is false or an error occurs while picking one state |
Return a BDD representing an inputs of bdd.
Return type: | Inputs |
---|---|
Raise: | a NuSMVBddPickingError if bdd is false or an error occurs while picking one inputs |
Return a BDD representing an inputs of bdd, picked at random.
Return type: | Inputs |
---|---|
Raise: | a NuSMVBddPickingError if bdd is false or an error occurs while picking one inputs |
Return a BDD representing a state/inputs pair of bdd.
Return type: | StateInputs |
---|---|
Raise: | a NuSMVBddPickingError if bdd is false or an error occurs while picking one pair |
Return a BDD representing a state/inputs pair of bdd, picked at random.
Return type: | StateInputs |
---|---|
Raise: | a NuSMVBddPickingError if bdd is false or an error occurs while picking one pair |
Return the BDD representing the possible inputs between current and next_.
Parameters: | |
---|---|
Return type: |
Return the number of states of the given BDD.
Parameters: | bdd (BDD) – the concerned BDD |
---|
Return the number of inputs of the given BDD
Parameters: | bdd (BDD) – the concerned BDD |
---|
Return the number of state/inputs pairs of the given BDD
Parameters: | bdd (BDD) – the concerned BDD |
---|
Return a tuple of all states belonging to bdd.
Parameters: | bdd (BDD) – the concerned BDD |
---|---|
Return type: | tuple(State) |
Raise: | a NuSMVBddPickingError if something is wrong |
Return a tuple of all inputs belonging to bdd.
Parameters: | bdd (BDD) – the concerned BDD |
---|---|
Return type: | tuple(Inputs) |
Raise: | a NuSMVBddPickingError if something is wrong |
Return a tuple of all states/inputs pairs belonging to bdd.
Parameters: | bdd (BDD) – the concerned BDD |
---|---|
Return type: | tuple(StateInputs) |
Raise: | a NuSMVBddPickingError if something is wrong |
Return the FSM corresponding to the model in filepath.
Parameters: | filepath – the path to the SMV model |
---|
Bases: pynusmv.utils.PointerWrapper
Python class for transition relation encoded with BDDs.
A BddTrans represents a transition relation and provides pre and post operations on BDDs, possibly restricted to given actions.
Compute the pre-image of states, through inputs if not None.
Parameters: | |
---|---|
Return type: |
Compute the post-image of states, through inputs if not None.
Parameters: | |
---|---|
Return type: |
Return a new BddTrans from the given trans.
Parameters: |
|
---|---|
Return type: | |
Raise: | a NuSMVFlatteningError if trans cannot be flattened under context |
Return a new BddTrans from the given strtrans, in given strcontex.
Parameters: |
|
---|---|
Return type: | |
Raise: | a NuSMVTypeCheckingError if strtrans is wrongly typed under context |
Bases: pynusmv.utils.PointerWrapper
Python class for BDD encoding.
A BddEnc provides some basic functionalities like getting the DD manager used to manage BDDs, the symbols table or the state and inputs masks.
The mask for all input and state variables, represented as a BDD.
Return type: | BDD |
---|
Return the cube for the given input variables.
Parameters: | variables – a list of input variable names |
---|---|
Return type: | BDD |
Bases: pynusmv.utils.PointerWrapper
Python class for symbols table.
Create a new layer in this symbol table.
Parameters: |
|
---|
Return the type of the given variable.
Parameters: | variable (Node) – the name of the variable |
---|---|
Return type: | a NuSMV SymbType_ptr |
Warning
The returned pointer must not be altered or freed.
Return whether the given variable name can be declared in layer.
Parameters: |
|
---|---|
Return type: | bool |
Declare a new input variable in this symbol table.
Parameters: | |
---|---|
Raise: | a NuSMVSymbTableError if the variable is already defined in the given layer |
Warning
type_ must be already resolved, that is, the body of type_ must be leaf values.
Declare a new state variable in this symbol table.
Parameters: | |
---|---|
Raise: | a NuSMVSymbTableError if the variable is already defined in the given layer |
Warning
type_ must be already resolved, that is, the body of type_ must be leaf values.
Declare a new frozen variable in this symbol table.
Parameters: | |
---|---|
Raise: | a NuSMVSymbTableError if the variable is already defined in the given layer |
Warning
type_ must be already resolved, that is, the body of type_ must be leaf values.
Declare a new variable in this symbol table.
Parameters: | |
---|---|
Raise: | a NuSMVSymbTableError if the variable is already defined in the given layer |
Warning
type_ must be already resolved, that is, the body of type_ must be leaf values.
Return whether the given var name is a declared input variable.
Parameters: | ivar (Node) – the name of the input variable |
---|---|
Raise: | a NuSMVSymbTableError if the variable is not defined in this symbol table |
Return whether the given var name is a declared state variable.
Parameters: | var (Node) – the name of the state variable |
---|---|
Raise: | a NuSMVSymbTableError if the variable is not defined in this symbol table |
Return whether the given var name is a declared frozen variable.
Parameters: | fvar (Node) – the name of the frozen variable |
---|---|
Raise: | a NuSMVSymbTableError if the variable is not defined in this symbol table |
The pynusmv.prop module contains classes and functions dealing with properties and specifications of models.
The possible types of properties. This gives access to NuSMV internal types without dealing with pynusmv.nusmv modules.
Bases: pynusmv.utils.PointerWrapper
Python class for properties.
Properties are NuSMV data structures containing specifications but also pointers to models (FSM) and other things.
Bases: pynusmv.utils.PointerWrapper
Python class for property database.
A property database is just a list of properties (Prop). Any PropDb can be used as a Python list.
Bases: pynusmv.utils.PointerWrapper
A CTL specification.
The Spec class implements a NuSMV nodes-based specification. No check is made to insure that the node is effectively a specification, i.e. the stored pointer is not checked against spec types.
Return a new specification corresponding to NOT spec.
Return type: | Spec |
---|
Return a new specification corresponding to left AND right.
Return type: | Spec |
---|
Return a new specification corresponding to left OR right.
Return type: | Spec |
---|
Return a new specification corresponding to left IMPLIES right.
Return type: | Spec |
---|
Return a new specification corresponding to left IFF right.
Return type: | Spec |
---|
Return a new specification corresponding to EX spec.
Return type: | Spec |
---|
Return a new specification corresponding to EG spec.
Return type: | Spec |
---|
Return a new specification corresponding to EF spec.
Return type: | Spec |
---|
Return a new specification corresponding to E[left U right].
Return type: | Spec |
---|
Return a new specification corresponding to E[left W right].
Return type: | Spec |
---|
Return a new specification corresponding to AX spec.
Return type: | Spec |
---|
Return a new specification corresponding to AG spec.
Return type: | Spec |
---|
Return a new specification corresponding to AF spec.
Return type: | Spec |
---|
Return a new specification corresponding to A[left U right].
Return type: | Spec |
---|
Return a new specification corresponding to A[left W right].
Return type: | Spec |
---|
Return a new specification corresponding to the given atom. strrep is parsed and type checked on the current model. A model needs to be read and with variables encoded to be able to type check the atomic proposition. If type_checking is False, type checking is not performed and a model is not needed anymore.
Parameters: |
|
---|---|
Return type: |
The pynusmv.dd module provides some BDD-related structures:
It also provides global methods to work on BDD variables reordering: enable_dynamic_reordering(), disable_dynamic_reordering(), dynamic_reordering_enabled(), reorder().
Enable dynamic reordering of BDD variables under control of DDmanager with the given method.
Parameters: |
|
---|---|
Raise: | a MissingManagerError if the manager is missing |
Note
For more information on reordering methods, see NuSMV manual.
Disable dynamic reordering of BDD variables under control of DDmanager.
Parameters: | DDmanager (DDManager) – the conserned DD manager; if None, the global DD manager is used instead. |
---|---|
Raise: | a MissingManagerError if the manager is missing |
Return the dynamic reordering method used if reordering is enabled for BDD under control of DDmanager, None otherwise.
Parameters: | DDmanager (DDManager) – the conserned DD manager; if None, the global DD manager is used instead. |
---|---|
Return type: | None, or a the name of the method used |
Raise: | a MissingManagerError if the manager is missing |
Force a reordering of BDD variables under control of DDmanager.
Parameters: |
|
---|---|
Raise: | a MissingManagerError if the manager is missing |
Note
For more information on reordering methods, see NuSMV manual.
Bases: pynusmv.utils.PointerWrapper
Python class for BDD structure.
The BDD represents a BDD in NuSMV and provides a set of operations on this BDD. Thanks to operator overloading, it is possible to write compact expressions on BDDs. The available operations are:
Any BDD operation raises a MissingManagerError whenever the manager of the BDD is None and a manager is needed to perform the operation.
Determine whether this BDD is equal to other or not.
Parameters: | other (BDD) – the BDD to compare |
---|
Determine whether this BDD is included in other or not.
Parameters: | other (BDD) – the BDD to compare |
---|
Determine whether the intersection between this BDD and other is not empty.
Parameters: | other (BDD) – the BDD to compare |
---|
Determine whether this BDD is less than or equal to other.
Parameters: | other (BDD) – the BDD to compare |
---|
Compute the conjunction of this BDD and other.
Parameters: | other (BDD) – the other BDD |
---|
Compute the conjunction of this BDD and other.
Parameters: | other (BDD) – the other BDD |
---|
Compute the exclusive-OR of this BDD and other.
Parameters: | other (BDD) – the other BDD |
---|
Compute the IFF operation on this BDD and other.
Parameters: | other (BDD) – the other BDD |
---|
Compute the IMPLY operation on this BDD and other.
Parameters: | other (BDD) – the other BDD |
---|
Existentially abstract all the variables in cube from this BDD.
Parameters: | cube (BDD) – the cube |
---|
Universally abstract all the variables in cube from this BDD.
Parameters: | cube (BDD) – the cube |
---|
Restrict this BDD with c, as described in Coudert et al. ICCAD90.
Parameters: | c (BDD) – the BDD used to restrict this BDD |
---|
Note
Always returns a BDD not larger than the this BDD.
Bases: pynusmv.utils.PointerWrapper
A BDD list stored as NuSMV nodes.
The BDDList class implements a NuSMV nodes-based BDD list and can be used as any Python list.
Return a tuple containing all BDDs of self. The returned BDDs are copies of the ones of self.
Create a node-based list from the Python tuple bddtuple.
Parameters: | bddtuple – a Python tuple of BDDs |
---|
Return a BDDList representing the given tuple, using NuSMV nodes. All BDDs are assumed from the same DD manager; the created list contains the DD manager of the first non-None BDD. If all elements of bddtuple are None, the manager of the created BDDList is None.
Bases: pynusmv.dd.BDD
Python class for State structure.
A State is a BDD representing a single state of the model.
Bases: pynusmv.dd.BDD
Python class for inputs structure.
An Inputs is a BDD representing a single valuation of the inputs variables of the model, i.e. an action of the model.
Bases: pynusmv.dd.BDD
Python class for State and Inputs structure.
A StateInputs is a BDD representing a single state/inputs pair of the model.
Bases: pynusmv.dd.BDD
Python class for Cube structure.
A Cube is a BDD representing a BDD cube of the model.
Compute the difference between this cube and other
Parameters: | other (BDD) – the other cube |
---|
The pynusmv.parser module provides functions to parse strings and return corresponding ASTs. This module includes three types of functionalities:
Parse a simple expression.
Parameters: | expression (string) – the expression to parse |
---|---|
Raise: | a NuSMVParsingError if a parsing error occurs |
Warning
Returned value is a SWIG wrapper for the NuSMV node_ptr. It is the responsibility of the caller to manage it.
Parse a “next” expression.
Parameters: | expression (string) – the expression to parse |
---|---|
Raise: | a NuSMVParsingError if a parsing error occurs |
Warning
Returned value is a SWIG wrapper for the NuSMV node_ptr. It is the responsibility of the caller to manage it.
Parse an identifier
Parameters: | expression (string) – the identifier to parse |
---|---|
Raise: | a NuSMVParsingError if a parsing error occurs |
Warning
Returned value is a SWIG wrapper for the NuSMV node_ptr. It is the responsibility of the caller to manage it.
Parse a CTL specification
Parameters: | spec (string) – the specification to parse |
---|---|
Raise: | a NuSMVParsingError if a parsing error occurs |
Warning
Returned value is a SWIG wrapper for the NuSMV node_ptr. It is the responsibility of the caller to manage it.
The pynusmv.mc module provides some functions of NuSMV dealing with model checking, like CTL model checking.
Return whether the given fsm satisfies or not the given spec in context, if specified. That is, return whether all initial states of fsm satisfies spec in context or not.
Parameters: | |
---|---|
Return type: | bool |
Return the set of states of fsm satisfying sexp, as a BDD. sexp is first parsed, then evaluated on fsm.
Parameters: |
|
---|---|
Return type: |
Return the set of states of fsm satisfying spec in context, as a BDD.
Parameters: | |
---|---|
Return type: |
Return the set of states of fsm satisfying EF states, as a BDD.
Parameters: | |
---|---|
Return type: |
Return the set of states of fsm satisfying EG states, as a BDD.
Parameters: | |
---|---|
Return type: |
Return the set of states of fsm satisfying EX states, as a BDD.
Parameters: | |
---|---|
Return type: |
Return the set of states of fsm satisfying E[s1 U s2], as a BDD.
Parameters: | |
---|---|
Return type: |
Return the set of states of fsm satisfying A[s1 U s2], as a BDD.
Parameters: | |
---|---|
Return type: |
Explain why state of fsm satisfies spec in context.
Parameters: |
---|
Return a tuple t composed of states (State) and inputs (Inputs), such that t[0] is state and t represents a path in fsm explaining why state satisfies spec in context. The returned path is looping if the last state of path is equal to a previous state along the path.
Explain why state of fsm satisfies EX phi, where a is the set of states of fsm satisfying phi, represented by a BDD.
Parameters: |
---|
Return (s, i, s’) tuple where s (State) is the given state, s’ (State) is a successor of s belonging to a and i (Inputs) is the inputs to go from s to s’ in fsm.
Explain why state of fsm satisfies E[phi U psi], where a is the set of states of `fsm satisfying phi and b is the set of states of fsm satisfying psi, both represented by BDDs.
Parameters: |
---|
Return a tuple t composed of states (State) and inputs (Inputs), such that t[0] is state, t[-1] belongs to b, and every other state of t belongs to a. The states of t are separated by inputs. Furthermore, t represents a path in fsm.
Explain why state of fsm satisfies EG phi, where a the set of states of fsm satisfying phi, represented by a BDD.
Parameters: |
---|
Return a tuple (t, (i, loop)) where t is a tuple composed of states (State) and inputs (Inputs), such that t[0] is state and every other state of t belongs to a. The states of t are separated by inputs. Furthermore, t represents a path in fsm. loop represents the start of the loop contained in t, i.e. t[-1] can lead to loop through i, and loop is a state of t.
The pynusmv.exception module provides all the exceptions used in PyNuSMV. Every particular exception raised by a PyNuSMV function is a sub-class of the PyNuSMVError class, such that one can catch all PyNuSMV by catching PyNuSMVError exceptions.
Bases: builtins.Exception
A generic PyNuSMV Error, superclass of all PyNuSMV Errors.
Bases: pynusmv.exception.PyNuSMVError
Exception for missing BDD manager.
Bases: pynusmv.exception.PyNuSMVError
Exception for NuSMV lexer error.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when no SMV model has been read yet.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when a model is already read.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when no SMV model has been read yet.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when the model is already flattened.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when the model must be flattened.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when the model is already encoded.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when the flat model is already built.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when the model must be flattened.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when the BDD model is already built.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when the variables of the model must be encoded.
Bases: pynusmv.exception.PyNuSMVError
NuSMV initialisation-related exception.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when an error occured while parsing a string with NuSMV.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when an expression is wrongly typed.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when an error occured while flattening some expression.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when an error occured while picking a state/inputs from a BDD.
Bases: pynusmv.exception.PyNuSMVError
A NuSMVParsingError is a NuSMV parsing exception. Contains several errors accessible through the errors attribute.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when an error occured while creating a module.
Bases: pynusmv.exception.PyNuSMVError
Exception raised when an error occured while working with symbol tables.
The pynusmv.utils module contains some secondary functions and classes used by PyNuSMV internals.
Bases: builtins.object
Superclass wrapper for NuSMV pointers.
Every pointer to a NuSMV structure is wrapped in a PointerWrapper or in a subclass of PointerWrapper. Every subclass instance takes a pointer to a NuSMV structure as constructor parameter.
It is the responsibility of PointerWrapper and its subclasses to free the wrapped pointer. Some pointers have to be freed like bdd_ptr, but other do not have to be freed since NuSMV takes care of this; for example, BddFrm_ptr does not have to be freed. To ensure that a pointer is freed only once, PyNuSMV ensures that any pointer is wrapped by only one PointerWrapper (or subclass of it) if the pointer have to be freed.