The source code and dockerfile for the GSW2024 AI Lab.
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

46 lines
1.7 KiB

2 months ago
  1. import stormpy
  2. import stormpy.core
  3. import stormpy.examples
  4. import stormpy.examples.files
  5. from stormpy.storage import Expression
  6. def example_analysis_02():
  7. path = stormpy.examples.files.prism_dtmc_die
  8. prism_program = stormpy.parse_prism_program(path)
  9. formula_str = "P=? [F s=7 & d=2]"
  10. properties = stormpy.parse_properties(formula_str, prism_program)
  11. model = stormpy.build_symbolic_model(prism_program, properties)
  12. result = stormpy.model_checking(model, properties[0])
  13. filter = stormpy.create_filter_initial_states_symbolic(model)
  14. result.filter(filter)
  15. assert result.min == result.max
  16. print(result.min)
  17. # Create an auxiliary mapping to build expressions that matches some state.
  18. variables = dict()
  19. for m in prism_program.modules:
  20. for v in m.integer_variables:
  21. variables[v.name] = v.expression_variable.get_expression()
  22. expr_manager = prism_program.expression_manager
  23. expr_for_state_1 = Expression.Conjunction([Expression.Eq(variables["s"],expr_manager.create_integer(1)),
  24. Expression.Eq(variables["d"],expr_manager.create_integer(0))])
  25. expr_for_state_2 = Expression.And(Expression.Eq(variables["s"],expr_manager.create_integer(4)),
  26. Expression.Eq(variables["d"],expr_manager.create_integer(0)))
  27. result = stormpy.model_checking(model, properties[0])
  28. cached_res = result.clone()
  29. cached_res.filter(stormpy.create_filter_symbolic(model,expr_for_state_1))
  30. print(cached_res.min)
  31. result.filter(stormpy.create_filter_symbolic(model,expr_for_state_2))
  32. assert result.min == result.max
  33. print(result.min)
  34. if __name__ == '__main__':
  35. example_analysis_02()