This assignment will be closed on May 28, 2025 (23:59:59).
You must be authenticated to submit your files

CSE308 - Tutorial 7 - Bounded Model Checking

Setup

You should already have all the dependencies on your system.

In case, run in the terminal the command pysmt-install --check and check you have a SAT (or SMT solver) installed. Your output will be something like:

Installed Solvers:
  msat      True (5.6.1)
  cvc4      False (None)              Not in Python's path!
  z3        True (4.8.7)
  yices     False (None)              Not in Python's path!
  btor      False (None)              Not in Python's path!
  picosat   False (None)              Not in Python's path!
  bdd       True (2.0.3)

All is ok as long as you have any of the following installed (True value in the column): msat, cvc4, z3,yices,picosat.

Download and extract the files of the tutorial CSE308-TD7-1-handin.zip. You’ll have a folder called CSE308-TD7-1-handin.

Evaluation

You will receive a maximum 20 points, subdivided as follows:

Deadline.

The deadline for submitting the exercise to obtain a full grade is Thursday May 29th at 23:59. You can submit your work after that deadline but you will receive only 50% of the total grade.

Implement the BMC encoding for G p properties

Here and in the rest of the tutorial you will work in the file mc308/td7.py. In the first exercise you will implement the Bounded Model Checking algorithm for checking properties of the form G p, where p is a propositional logic formula.

Your task is to implement the function bmc_Gp:

def bmc_Gp(ts : SymbolicTS, p : BoolFormula, k : int) -> Tuple[bool, Optional[KL_lasso]]

The function takes as input a symbolic transition system (ts), the property p to check (i.e., the p from G p), and the length k of the path to check. The function returns a tuple: the first element is False if the function finds a counterexample, and in that case returns a lasso-shaped path as second argument (**for now, ignore the second argument and always return None). If bmc cannot determine if there is a violation, the function returns (True,None).

Your task is to construct the bounded model checking encoding for finding a counterexample to the formula G p.

Some hints:

Construct the lasso-shaped counter-example

Extend bmc_Gp to construct a lasso-shaped counter-example from the satisfying assignment found by the SAT solver.

We represent a (k-l)-lasso with the following type:

KL_lasso : TypeAlias = Tuple[List[Mapping[BoolFormula, bool]], int]

where:

You may find the function get_py_value of the Model object returned from get_model useful. The function returns the value (e.g., true or false) assigned to a variable in the encoding. Model is defined in pysmt.solvers.solver and useful, or not:

There are no explicit test cases for this function, but you can print your model in the examples in td7_script.py.

BMC for FG p properties

Implement the function bmc_FGp defined in the file bmc.py to find violations to LTL properties of the form FG p:

def bmc_FGp(ts : SymbolicTS, p : BoolFormula, k : int) -> Tuple[bool, Optional[KL_lasso]]

Also here, look for the function `test_fgp in td7_script.py.

BMC for arbitrary LTL properties

Implement the generic BMC encoding for checking a LTL formula already in Negation Normal Form:

def bmc(ts : SymbolicTS, f : LtlFormula, k : int) -> Tuple[bool, Optional[KL_lasso]

Here assume that f is already the negation of the formula you want to check (i.e., the input to \(\Gamma\) in the BMC encoding formula you have on the slides).

Use the test cases for G p and FG p to try your implementation first.

A buggy buffer

Then, take a look at the file buffer.smv.

The SMV model specifies a bounded-size buffer that:

You will have to perform two tasks: 1. Use NuSMV to find the bugs in the buffer and fix the SMV model. 2. Test your BMC implementation on the (still buggy) model (it should return reasonable counterexamples to the LTL properties in the SMV model).

For task 1:

For task 2:

Submit your work

You’ll have to upload the following files

Upload form is only available when connected
Upload form is only available when connected