You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.8 KiB

  1. import pycarl
  2. import stormpy
  3. import stormpy.logic
  4. class TestFormulas:
  5. def test_probability_formula(self):
  6. prop = "P=? [F \"one\"]"
  7. formulas = stormpy.parse_formulas(prop)
  8. formula = formulas[0]
  9. assert type(formula) == stormpy.logic.ProbabilityOperator
  10. assert len(formulas) == 1
  11. assert str(formula) == prop
  12. def test_reward_formula(self):
  13. prop = "R=? [F \"one\"]"
  14. formulas = stormpy.parse_formulas(prop)
  15. formula = formulas[0]
  16. assert type(formula) == stormpy.logic.RewardOperator
  17. assert len(formulas) == 1
  18. assert str(formula) == "R[exp]=? [F \"one\"]"
  19. def test_formula_list(self):
  20. formulas = []
  21. prop = "=? [F \"one\"]"
  22. forms = stormpy.parse_formulas("P" + prop)
  23. formulas.append(forms[0])
  24. forms = stormpy.parse_formulas("R" + prop)
  25. formulas.append(forms[0])
  26. assert len(formulas) == 2
  27. assert str(formulas[0]) == "P" + prop
  28. assert str(formulas[1]) == "R[exp]" + prop
  29. def test_bounds(self):
  30. prop = "P=? [F \"one\"]"
  31. formula = stormpy.parse_formulas(prop)[0]
  32. assert not formula.has_bound
  33. prop = "P<0.4 [F \"one\"]"
  34. formula = stormpy.parse_formulas(prop)[0]
  35. assert formula.has_bound
  36. assert formula.threshold == pycarl.Rational("0.4")
  37. assert formula.comparison_type == stormpy.logic.ComparisonType.LESS
  38. def test_set_bounds(self):
  39. prop = "P<0.4 [F \"one\"]"
  40. formula = stormpy.parse_formulas(prop)[0]
  41. formula.threshold = pycarl.Rational("0.2")
  42. formula.comparison_type = stormpy.logic.ComparisonType.GEQ
  43. assert formula.threshold == pycarl.Rational("0.2")
  44. assert formula.comparison_type == stormpy.logic.ComparisonType.GEQ
  45. assert str(formula) == "P>=1/5 [F \"one\"]"