cleanup
This commit is contained in:
@@ -28,6 +28,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
|
|
||||||
self.initialise()
|
self.initialise()
|
||||||
|
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
"""Initialises all the variables used by the checker"""
|
"""Initialises all the variables used by the checker"""
|
||||||
|
|
||||||
@@ -48,11 +49,13 @@ class SmtCheckerRSCParam(object):
|
|||||||
|
|
||||||
self.verification_time = None
|
self.verification_time = None
|
||||||
|
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
"""Reinitialises the state of the checker"""
|
"""Reinitialises the state of the checker"""
|
||||||
|
|
||||||
self.initialise()
|
self.initialise()
|
||||||
|
|
||||||
|
|
||||||
def prepare_all_variables(self):
|
def prepare_all_variables(self):
|
||||||
"""Prepares all the variables"""
|
"""Prepares all the variables"""
|
||||||
|
|
||||||
@@ -61,6 +64,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
self.prepare_intermediate_product_variables()
|
self.prepare_intermediate_product_variables()
|
||||||
self.next_level_to_encode += 1
|
self.next_level_to_encode += 1
|
||||||
|
|
||||||
|
|
||||||
def prepare_context_variables(self):
|
def prepare_context_variables(self):
|
||||||
"""Prepares all the context variables"""
|
"""Prepares all the context variables"""
|
||||||
|
|
||||||
@@ -72,6 +76,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
|
|
||||||
self.v_ctx.append(variables)
|
self.v_ctx.append(variables)
|
||||||
|
|
||||||
|
|
||||||
def prepare_state_variables(self):
|
def prepare_state_variables(self):
|
||||||
"""Prepares all the state variables"""
|
"""Prepares all the state variables"""
|
||||||
|
|
||||||
@@ -84,6 +89,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
|
|
||||||
self.ca_state.append(Int("CA"+str(level)+"_state"))
|
self.ca_state.append(Int("CA"+str(level)+"_state"))
|
||||||
|
|
||||||
|
|
||||||
def prepare_intermediate_product_variables(self):
|
def prepare_intermediate_product_variables(self):
|
||||||
"""
|
"""
|
||||||
Prepares the intermediate product variables
|
Prepares the intermediate product variables
|
||||||
@@ -136,6 +142,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
|
|
||||||
return enc_nz
|
return enc_nz
|
||||||
|
|
||||||
|
|
||||||
def enc_init_state(self, level):
|
def enc_init_state(self, level):
|
||||||
"""Encodes the initial state at the given level"""
|
"""Encodes the initial state at the given level"""
|
||||||
|
|
||||||
@@ -150,6 +157,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
|
|
||||||
return init_state_enc
|
return init_state_enc
|
||||||
|
|
||||||
|
|
||||||
def enc_produced_concentration(self, level, prod_entity):
|
def enc_produced_concentration(self, level, prod_entity):
|
||||||
"""Encodes the produced concentrations for the given level and entity"""
|
"""Encodes the produced concentrations for the given level and entity"""
|
||||||
|
|
||||||
@@ -290,6 +298,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
def enc_transition_relation(self, level):
|
def enc_transition_relation(self, level):
|
||||||
return simplify(And(self.enc_rs_trans(level), self.enc_automaton_trans(level)))
|
return simplify(And(self.enc_rs_trans(level), self.enc_automaton_trans(level)))
|
||||||
|
|
||||||
|
|
||||||
def enc_rs_trans(self, level):
|
def enc_rs_trans(self, level):
|
||||||
"""Encodes the transition relation"""
|
"""Encodes the transition relation"""
|
||||||
|
|
||||||
@@ -309,6 +318,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
|
|
||||||
return enc_trans
|
return enc_trans
|
||||||
|
|
||||||
|
|
||||||
def enc_automaton_trans(self, level):
|
def enc_automaton_trans(self, level):
|
||||||
"""Encodes the transition relation for the context automaton"""
|
"""Encodes the transition relation for the context automaton"""
|
||||||
|
|
||||||
@@ -336,6 +346,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
|
|
||||||
return enc_trans
|
return enc_trans
|
||||||
|
|
||||||
|
|
||||||
def enc_exact_state(self, level, state):
|
def enc_exact_state(self, level, state):
|
||||||
"""Encodes the state at the given level with the exact concentration values"""
|
"""Encodes the state at the given level with the exact concentration values"""
|
||||||
|
|
||||||
@@ -356,6 +367,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
#
|
#
|
||||||
# return simplify(enc)
|
# return simplify(enc)
|
||||||
|
|
||||||
|
|
||||||
def enc_min_state(self, level, state):
|
def enc_min_state(self, level, state):
|
||||||
"""Encodes the state at the given level with the minimal required concentration levels"""
|
"""Encodes the state at the given level with the minimal required concentration levels"""
|
||||||
|
|
||||||
@@ -371,6 +383,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
|
|
||||||
return simplify(enc)
|
return simplify(enc)
|
||||||
|
|
||||||
|
|
||||||
def enc_state_with_blocking(self, level, prop):
|
def enc_state_with_blocking(self, level, prop):
|
||||||
"""Encodes the state at the given level with blocking certain concentrations"""
|
"""Encodes the state at the given level with blocking certain concentrations"""
|
||||||
|
|
||||||
@@ -387,6 +400,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
|
|
||||||
return simplify(enc)
|
return simplify(enc)
|
||||||
|
|
||||||
|
|
||||||
def decode_witness(self, max_level, print_model=False):
|
def decode_witness(self, max_level, print_model=False):
|
||||||
|
|
||||||
m = self.solver.model()
|
m = self.solver.model()
|
||||||
@@ -419,6 +433,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
print(" " + self.rs.get_entity_name(var_id) + "=" + var_rep, end="")
|
print(" " + self.rs.get_entity_name(var_id) + "=" + var_rep, end="")
|
||||||
print(" }")
|
print(" }")
|
||||||
|
|
||||||
|
|
||||||
def check_rsltl(self, formula, print_witness=True, print_time=True, print_mem=True, max_level=None):
|
def check_rsltl(self, formula, print_witness=True, print_time=True, print_mem=True, max_level=None):
|
||||||
"""Bounded Model Checking for rsLTL properties"""
|
"""Bounded Model Checking for rsLTL properties"""
|
||||||
|
|
||||||
@@ -495,6 +510,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
if print_mem:
|
if print_mem:
|
||||||
print("[i] {: >60}".format(" Memory: " + repr(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/(1024*1024)) + " MB"))
|
print("[i] {: >60}".format(" Memory: " + repr(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/(1024*1024)) + " MB"))
|
||||||
|
|
||||||
|
|
||||||
def dummy_unroll(self, levels):
|
def dummy_unroll(self, levels):
|
||||||
"""Unrolls the variables for testing purposes"""
|
"""Unrolls the variables for testing purposes"""
|
||||||
|
|
||||||
@@ -505,6 +521,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
|
|
||||||
print(C_MARK_INFO + " Dummy Unrolling done.")
|
print(C_MARK_INFO + " Dummy Unrolling done.")
|
||||||
|
|
||||||
|
|
||||||
def state_equality(self, level_A, level_B):
|
def state_equality(self, level_A, level_B):
|
||||||
"""Encodes equality of two states at two different levels"""
|
"""Encodes equality of two states at two different levels"""
|
||||||
|
|
||||||
@@ -519,6 +536,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
|
|
||||||
return eq_enc
|
return eq_enc
|
||||||
|
|
||||||
|
|
||||||
def get_loop_encodings(self):
|
def get_loop_encodings(self):
|
||||||
|
|
||||||
k = self.current_level
|
k = self.current_level
|
||||||
@@ -537,6 +555,7 @@ class SmtCheckerRSCParam(object):
|
|||||||
|
|
||||||
return loop_enc
|
return loop_enc
|
||||||
|
|
||||||
|
|
||||||
def check_reachability(self, state, print_witness=True,
|
def check_reachability(self, state, print_witness=True,
|
||||||
print_time=True, print_mem=True, max_level=1000):
|
print_time=True, print_mem=True, max_level=1000):
|
||||||
"""Main testing function"""
|
"""Main testing function"""
|
||||||
@@ -598,9 +617,11 @@ class SmtCheckerRSCParam(object):
|
|||||||
if print_mem:
|
if print_mem:
|
||||||
print("[i] {: >60}".format(" Memory: " + repr(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/(1024*1024)) + " MB"))
|
print("[i] {: >60}".format(" Memory: " + repr(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/(1024*1024)) + " MB"))
|
||||||
|
|
||||||
|
|
||||||
def get_verification_time(self):
|
def get_verification_time(self):
|
||||||
return self.verification_time
|
return self.verification_time
|
||||||
|
|
||||||
|
|
||||||
def show_encoding(self, state, print_witness=True,
|
def show_encoding(self, state, print_witness=True,
|
||||||
print_time=False, print_mem=False, max_level=100):
|
print_time=False, print_mem=False, max_level=100):
|
||||||
"""Encoding debug function"""
|
"""Encoding debug function"""
|
||||||
@@ -656,3 +677,5 @@ class SmtCheckerRSCParam(object):
|
|||||||
if not (x == "y" or x == "yes"):
|
if not (x == "y" or x == "yes"):
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
# EOF
|
||||||
Reference in New Issue
Block a user