Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add binding for GameFormula #181

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/logic/formulae.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,7 @@ void define_formulae(py::module& m) {
py::class_<storm::logic::MultiObjectiveFormula, std::shared_ptr<storm::logic::MultiObjectiveFormula>>(m, "MultiObjectiveFormula", "Multi objective formula", formula)
.def_property_readonly("subformulas", &storm::logic::MultiObjectiveFormula::getSubformulas, "Get vector of subformulas")
.def_property_readonly("nr_subformulas", &storm::logic::MultiObjectiveFormula::getNumberOfSubformulas, "Get number of subformulas");

py::class_<storm::logic::GameFormula, std::shared_ptr<storm::logic::GameFormula>>(m, "GameFormula", "Game formula", unaryStateFormula)
.def_property_readonly("is_game_formula", &storm::logic::GameFormula::isGameFormula, "is it a game formula");
}
11 changes: 11 additions & 0 deletions tests/logic/test_formulas.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,14 @@ def test_subformula(self):
assert type(labelform) == stormpy.logic.AtomicLabelFormula
prop = stormpy.core.Property("label-formula", labelform)
assert prop.raw_formula == labelform

def test_game_formula(self):
formula_str = "<<0>> Pmax=? [F \"goal\"]"
properties = stormpy.parse_properties(formula_str)
formula = properties[0].raw_formula
assert type(formula) == stormpy.logic.GameFormula
assert str(formula) == formula_str
assert len(properties) == 1
formula = formula.subformula
assert type(formula) == stormpy.logic.ProbabilityOperator
assert str(formula) == "Pmax=? [F \"goal\"]"
Loading