1#ifndef STORM_STORAGE_PRISM_PROGRAM_H_
2#define STORM_STORAGE_PRISM_PROGRAM_H_
4#include <boost/optional.hpp>
63 Program(std::shared_ptr<storm::expressions::ExpressionManager> manager,
ModelType modelType, std::vector<Constant>
const& constants,
64 std::vector<BooleanVariable>
const& globalBooleanVariables, std::vector<IntegerVariable>
const& globalIntegerVariables,
65 std::vector<Formula>
const& formulas, std::vector<Player>
const& players, std::vector<Module>
const& modules,
66 std::map<std::string, uint_fast64_t>
const& actionToIndexMap, std::vector<RewardModel>
const& rewardModels, std::vector<Label>
const& labels,
67 std::vector<ObservationLabel>
const& observationLabels, boost::optional<InitialConstruct>
const& initialConstruct,
68 boost::optional<SystemCompositionConstruct>
const&
compositionConstruct,
bool prismCompatibility, std::string
const& filename =
"",
179 Module const& renamedModule, std::map<storm::expressions::Variable, storm::expressions::Expression>
const&
substitution)
const;
321 bool hasModule(std::string
const& moduleName)
const;
336 std::vector<Module>
const&
getModules()
const;
343 std::vector<Player>
const&
getPlayers()
const;
435 std::set<std::string>
const&
getActions()
const;
465 bool hasAction(std::string
const& actionName)
const;
576 std::vector<Label>
const&
getLabels()
const;
708 bool observable =
true)
const;
728 Program flattenModules(std::shared_ptr<storm::utility::solver::SmtSolverFactory>
const& smtSolverFactory =
765 std::pair<storm::jani::Model, std::vector<storm::jani::Property>>
toJani(std::vector<storm::jani::Property>
const& properties,
766 bool allVariablesGlobal =
true, std::string suffix =
"")
const;
787 boost::optional<InitialConstruct>
const& getOptionalInitialConstruct()
const;
800 std::vector<std::reference_wrapper<Command const>>
const& commands)
const;
805 void createMissingInitialValues();
808 std::shared_ptr<storm::expressions::ExpressionManager> manager;
811 void createMappings();
813 uint64_t getHighestCommandIndex()
const;
819 std::vector<Constant> constants;
822 std::map<std::string, uint_fast64_t> constantToIndexMap;
825 std::vector<BooleanVariable> globalBooleanVariables;
828 std::map<std::string, uint_fast64_t> globalBooleanVariableToIndexMap;
831 std::vector<IntegerVariable> globalIntegerVariables;
834 std::map<std::string, uint_fast64_t> globalIntegerVariableToIndexMap;
837 std::vector<Formula> formulas;
840 std::map<std::string, uint_fast64_t> formulaToIndexMap;
843 std::vector<Player> players;
846 std::map<std::string, storm::storage::PlayerIndex> playerToIndexMap;
849 std::vector<Module> modules;
852 std::map<std::string, uint_fast64_t> moduleToIndexMap;
855 std::vector<RewardModel> rewardModels;
858 std::map<std::string, uint_fast64_t> rewardModelToIndexMap;
861 boost::optional<InitialConstruct> initialConstruct;
864 boost::optional<SystemCompositionConstruct> systemCompositionConstruct;
867 std::vector<Label> labels;
870 std::map<std::string, uint_fast64_t> labelToIndexMap;
873 std::vector<ObservationLabel> observationLabels;
876 std::map<std::string, uint_fast64_t> actionToIndexMap;
879 std::map<uint_fast64_t, std::string> indexToActionMap;
882 std::set<std::string> actions;
885 std::set<uint_fast64_t> synchronizingActionIndices;
888 std::map<uint_fast64_t, std::set<uint_fast64_t>> actionIndicesToModuleIndexMap;
891 std::map<std::string, uint_fast64_t> variableToModuleIndexMap;
895 bool prismCompatibility;
This class is responsible for managing a set of typed variables and all expressions using these varia...
Program replaceConstantByVariable(Constant const &c, expressions::Expression const &lowerBound, expressions::Expression const &upperBound, bool observable=true) const
Substitutes the given constant by a fresh global variable that is bound between lowerBound and upperB...
std::set< uint_fast64_t > const & getSynchronizingActionIndices() const
Retrieves the set of synchronizing action indices present in the program.
Program & operator=(Program &&other)=default
void checkValidity(Program::ValidityCheckLevel lvl=Program::ValidityCheckLevel::READYFORPROCESSING) const
Checks the validity of the program.
std::map< std::string, std::string > getFinalRenamingOfModule(Module const &renamedModule) const
Gets the renaming of a module after flattening all renamings.
ModelType getModelType() const
Retrieves the model type of the model.
Program defineUndefinedConstants(std::map< storm::expressions::Variable, storm::expressions::Expression > const &constantDefinitions) const
Defines the undefined constants according to the given map and returns the resulting program.
std::vector< storm::expressions::Expression > getAllRangeExpressions() const
Retrieves a list of expressions that characterize the legal ranges of all variables.
std::vector< RewardModel > const & getRewardModels() const
Retrieves the reward models of the program.
std::vector< Player > const & getPlayers() const
Retrieves the players of the program.
RewardModel const & getRewardModel(std::string const &rewardModelName) const
Retrieves the reward model with the given name.
std::vector< BooleanVariable > const & getGlobalBooleanVariables() const
Retrieves the global boolean variables of the program.
ModelType
An enum for the different model types.
std::set< std::string > const & getActions() const
Retrieves the set of actions present in the program.
std::set< uint_fast64_t > const & getModuleIndicesByAction(std::string const &action) const
Retrieves the indices of all modules within this program that contain commands that are labelled with...
std::vector< std::reference_wrapper< Constant const > > getUndefinedConstants() const
Retrieves the undefined constants in the program.
storm::storage::PlayerIndex const & getIndexOfPlayer(std::string const &playerName) const
Retrieves the index of the player in the program.
bool isPartiallyObservable() const
Retrieves whether the model has restricted observability.
std::pair< uint_fast64_t, uint_fast64_t > getModuleCommandIndexByGlobalCommandIndex(uint_fast64_t globalCommandIndex) const
Retrieves the index of the module and the (local) index of the command with the given global command ...
bool hasAction(std::string const &actionName) const
Retrieves whether the program has an action with the given name.
std::size_t getNumberOfLabels() const
Retrieves the number of labels in the program.
boost::optional< SystemCompositionConstruct > getOptionalSystemCompositionConstruct() const
Retrieves the system composition construct (if any) and none otherwise.
std::map< storm::expressions::Variable, storm::expressions::Expression > getConstantsSubstitution() const
Retrieves a mapping of all defined constants to their defining expressions.
std::string const & getActionName(uint_fast64_t actionIndex) const
Retrieves the action name of the given action index.
std::vector< Module > const & getModules() const
Retrieves all modules of the program.
bool isDiscreteTimeModel() const
Retrieves whether the model is a discrete-time model, i.e.
storm::expressions::Expression const & getLabelExpression(std::string const &label) const
Retrieves the expression associated with the given label, if it exists.
std::unordered_map< uint_fast64_t, std::string > buildCommandIndexToActionNameMap() const
Program substituteNonStandardPredicates() const
Substitutes all nonstandard predicates in expressions of the program by their defining expressions.
Program & operator=(Program const &other)=default
std::vector< ObservationLabel > const & getObservationLabels() const
Retrieves all observation labels that are defined by this program.
Module const & getModule(uint_fast64_t index) const
Retrieves the module with the given index.
uint_fast64_t getActionIndex(std::string const &actionName) const
Retrieves the index of the action with the given name.
IntegerVariable const & getGlobalIntegerVariable(std::string const &variableName) const
Retrieves a the global integer variable with the given name.
std::set< uint_fast64_t > const & getModuleIndicesByActionIndex(uint_fast64_t actionIndex) const
Retrieves the indices of all modules within this program that contain commands that are labelled with...
std::map< uint_fast64_t, storm::storage::PlayerIndex > buildActionIndexToPlayerIndexMap() const
Retrieves a vector whose i'th entry corresponds to the player controlling action with index i.
bool isDeterministicModel() const
Retrieves whether the model is one without nondeterministic choices, i.e.
std::map< storm::expressions::Variable, storm::expressions::Expression > getConstantsFormulasSubstitution(bool getConstantsSubstitution=true, bool getFormulasSubstitution=true) const
Retrieves a mapping of all defined constants and formula variables to their defining expressions.
std::vector< storm::expressions::Expression > getAllGuards(bool negated=false) const
Retrieves all guards appearing in the program.
void removeLabel(std::string const &name)
Removes the label with the given name from the program.
bool undefinedConstantsAreGraphPreserving() const
Checks that undefined constants (parameters) of the model preserve the graph of the underlying model.
std::size_t getNumberOfRewardModels() const
Retrieves the number of reward models in the program.
std::size_t getNumberOfPlayers() const
Retrieves the number of players in the program.
void updateInitialStatesExpression(expressions::Expression const &newExpression)
Sets a new initial states expression.
Constant const & getConstant(std::string const &constantName) const
Retrieves the constant with the given name if it exists.
std::map< std::string, uint_fast64_t > const & getActionNameToIndexMapping() const
Retrieves the mapping of action names to their indices.
size_t getNumberOfCommands() const
The total number of commands in the prism file.
Program labelUnlabelledCommands(std::map< uint64_t, std::string > const &nameSuggestions={}) const
Give commands that do not have an action name an action, which can be helpful for debugging and under...
Program(Program const &other)=default
SystemCompositionConstruct const & getSystemCompositionConstruct() const
If the program specifies a system composition construct, this method retrieves it.
Program substituteConstants() const
Substitutes all constants appearing in the expressions of the program by their defining expressions.
Program substituteFormulas() const
Substitutes all formulas appearing in the expressions of the program by their defining expressions.
std::size_t getNumberOfObservationLabels() const
Retrieves the number of observation labels in the program.
std::map< std::string, storm::storage::PlayerIndex > const & getPlayerNameToIndexMapping() const
std::size_t getNumberOfConstants() const
Retrieves the number of all constants defined in the program.
std::set< storm::expressions::Variable > getAllExpressionVariables(bool includeConstants=true) const
Retrieves all expression variables used by this program.
Program(Program &&other)=default
bool globalIntegerVariableExists(std::string const &variableName) const
Retrieves whether a global Integer variable with the given name exists.
std::unordered_map< uint_fast64_t, std::string > buildActionIndexToActionNameMap() const
BooleanVariable const & getGlobalBooleanVariable(std::string const &variableName) const
Retrieves a the global boolean variable with the given name.
void filterLabels(std::set< std::string > const &labelSet)
Removes all labels that are not contained in the given set from the program.
bool hasModule(std::string const &moduleName) const
Retrieves whether the program has a module with the given name.
Program substituteConstantsFormulas(bool substituteConstants=true, bool substituteFormulas=true) const
Substitutes all constants and/or formulas appearing in the expressions of the program by their defini...
bool globalBooleanVariableExists(std::string const &variableName) const
Retrieves whether a global Boolean variable with the given name exists.
std::unordered_map< uint_fast64_t, uint_fast64_t > buildCommandIndexToActionIndex() const
std::vector< Constant > const & getConstants() const
Retrieves all constants defined in the program.
std::map< storm::expressions::Variable, storm::expressions::Expression > getFormulasSubstitution() const
Retrieves a mapping of all formula variables to their defining expressions.
friend std::ostream & operator<<(std::ostream &stream, Program const &program)
bool hasUnboundedVariables() const
storm::expressions::ExpressionManager & getManager() const
Retrieves the manager responsible for the expressions of this program.
Program replaceVariableInitializationByInitExpression() const
Replace the initialization in variables by an init-expression.
std::vector< Constant > usedConstants() const
Retrieves the constants that are actually used in the program.
bool hasLabel(std::string const &labelName) const
Checks whether the program has a label with the given name.
void removeRewardModels()
std::vector< storm::storage::PlayerIndex > buildModuleIndexToPlayerIndexMap() const
Retrieves a vector whose i'th entry corresponds to the player controlling module i.
std::vector< IntegerVariable > const & getGlobalIntegerVariables() const
Retrieves the global integer variables of the program.
std::size_t getNumberOfGlobalIntegerVariables() const
Retrieves the number of global integer variables of the program.
std::string getUndefinedConstantsAsString() const
Retrieves the undefined constants in the program as a comma-separated string.
std::size_t getNumberOfFormulas() const
Retrieves the number of formulas in the program.
bool hasConstant(std::string const &constantName) const
Retrieves whether the given constant exists in the program.
storm::expressions::Expression getInitialStatesExpression() const
Retrieves an expression characterizing the initial states.
void addLabel(std::string const &name, storm::expressions::Expression const &statePredicateExpression)
Adds a label with the given name and defining expression to the program.
std::size_t getNumberOfModules() const
Retrieves the number of modules in the program.
bool hasInitialConstruct() const
Retrieves whether the program specifies an initial construct.
Program restrictCommands(storm::storage::FlatSet< uint_fast64_t > const &indexSet) const
Creates a new program that drops all commands whose indices are not in the given set.
Program flattenModules(std::shared_ptr< storm::utility::solver::SmtSolverFactory > const &smtSolverFactory=std::shared_ptr< storm::utility::solver::SmtSolverFactory >(new storm::utility::solver::SmtSolverFactory())) const
Creates an equivalent program that contains exactly one module.
bool hasUndefinedConstants() const
Retrieves whether there are undefined constants of any type in the program.
bool specifiesSystemComposition() const
Retrieves whether the program specifies a system composition in terms of process algebra operations o...
std::shared_ptr< Composition > getDefaultSystemComposition() const
Retrieves the default system composition for this program.
std::vector< Label > const & getLabels() const
Retrieves all labels that are defined by the probabilitic program.
uint64_t getNumberOfUnlabeledCommands() const
storm::storage::BitVector const & getPossiblySynchronizingCommands() const
Compute the (labelled) commands in the program that may be synchronizing.
uint_fast64_t getModuleIndexByVariable(std::string const &variableName) const
Retrieves the index of the module in which the given variable name was declared.
bool hasRewardModel() const
Retrieves whether the program has reward models.
std::map< std::string, storm::expressions::Expression > getLabelToExpressionMapping() const
Retrieves a mapping from all labels in the program to their defining expressions.
Program simplify()
Entry point for static analysis for simplify.
std::map< storm::expressions::Variable, storm::expressions::Expression > getSubstitutionForRenamedModule(Module const &renamedModule, std::map< storm::expressions::Variable, storm::expressions::Expression > const &substitution) const
Applies the renaming of a renamed module to the given substitution.
std::size_t getNumberOfGlobalBooleanVariables() const
Retrieves the number of global boolean variables of the program.
storm::jani::Model toJani(bool allVariablesGlobal=true, std::string suffix="") const
Converts the PRISM model into an equivalent JANI model.
std::vector< Formula > const & getFormulas() const
Retrieves the formulas defined in the program.
A bit vector that is internally represented as a vector of 64-bit values.
std::ostream & operator<<(std::ostream &stream, Assignment const &assignment)
boost::container::flat_set< Key, std::less< Key >, boost::container::new_allocator< Key > > FlatSet
Redefinition of flat_set was needed, because from Boost 1.70 on the default allocator is set to void.