Ejemplo n.º 1
0
 def test_no_bdd_encoding_after_parsing(self):
     glob.load_from_file("tests/pynusmv/models/counters.smv")
     with self.assertRaises(NuSMVNeedFlatHierarchyError):
         glob.bdd_encoding()
Ejemplo n.º 2
0
 def test_bdd_encoding(self):
     glob.load_from_file("tests/pynusmv/models/counters.smv")
     glob.flatten_hierarchy()
     be = glob.bdd_encoding()
     self.assertIsNotNone(be)
Ejemplo n.º 3
0
 def test_bdd_encoding(self):
     glob.load_from_file("tests/pynusmv/models/counters.smv")
     glob.flatten_hierarchy()
     be = glob.bdd_encoding()
     self.assertIsNotNone(be)
Ejemplo n.º 4
0
 def test_no_bdd_encoding(self):
     with self.assertRaises(NuSMVNeedFlatHierarchyError):
         glob.bdd_encoding()
Ejemplo n.º 5
0
 def test_no_bdd_encoding_after_parsing(self):
     glob.load_from_file("tests/pynusmv/models/counters.smv")
     with self.assertRaises(NuSMVNeedFlatHierarchyError):
         glob.bdd_encoding()
Ejemplo n.º 6
0
 def test_no_bdd_encoding(self):
     with self.assertRaises(NuSMVNeedFlatHierarchyError):
         glob.bdd_encoding()
Ejemplo n.º 7
0
def bmc_setup(force=False):
    """
    Initializes the bmc sub-system, and builds the model in a Boolean Expression 
    format. This function must be called before the use of any other bmc-related
    functionalities. Only one call per session is required.
    
    If you don't intend to do anything special, you might consider using `go_bmc`
    which is a shortcut for the whole bmc initialization process.
    
    .. note::
        This function is subject to the following requirements:
            
            - a model must be loaded (:see:`glob.load`)
            - hierarchy must already be flattened (:see:`glob.flatten_hierarchy)
            - encoding must be already built (:see:`glob.encode_variables`)
            - boolean model must be already built (:see:`glob.build_boolean_model`)
               except if cone of influence is enabled and force is false
    
    :param force: a flag telling whether or not the boolean model must exist
       despite the cone of influence being enabled
    
    :raises NuSMVNeedBooleanModelError: if the boolean model wasn't created
    """
    # enforce preconditions
    if not _compile.cmp_struct_get_build_bool_model(glob.global_compile_cmps()):
        if not force and glob.is_cone_of_influence_enabled():
            pass
        else:
            raise NuSMVNeedBooleanModelError("boolean model must be created")
    
    if _compile.cmp_struct_get_bmc_setup(glob.global_compile_cmps()):
        raise NuSMVBmcAlreadyInitializedError("Bmc sub system already set up")
    
    # Build the vars manager, initializes the package and all sub packages, 
    # but only if not previously called.
    _bmc.Bmc_Init()
    
    build_master_be_fsm()
    
    be_fsm  = BeFsm.global_master_instance()
    be_enc  = be_fsm.encoding
    bdd_enc = glob.bdd_encoding()
    
    complete = _trc_exec.SATCompleteTraceExecutor_create(
                                be_fsm._ptr, be_enc._ptr, bdd_enc._ptr)
    _trace.TraceManager_register_complete_trace_executor(
        _trace.TracePkg_get_global_trace_manager(), 
        "sat", "SAT complete trace execution",
        _trc_exec.SATCompleteTraceExecutor2completeTraceExecutor(complete))
    
    partial_norestart = _trc_exec.SATPartialTraceExecutor_create(
                                be_fsm._ptr, be_enc._ptr, bdd_enc._ptr,False)
    _trace.TraceManager_register_partial_trace_executor(
        _trace.TracePkg_get_global_trace_manager(), 
        "sat", "SAT partial trace execution (no restart)",
        _trc_exec.SATPartialTraceExecutor2partialTraceExecutor(partial_norestart))
    
    partial_restarting= _trc_exec.SATPartialTraceExecutor_create(
                                be_fsm._ptr, be_enc._ptr, bdd_enc._ptr,True)
    _trace.TraceManager_register_partial_trace_executor(
        _trace.TracePkg_get_global_trace_manager(), 
        "sat_r", "SAT partial trace execution (restart)",
        _trc_exec.SATPartialTraceExecutor2partialTraceExecutor(partial_restarting))
    
    _compile.cmp_struct_set_bmc_setup(glob.global_compile_cmps())
Ejemplo n.º 8
0
def bmc_setup(force=False):
    """
    Initializes the bmc sub-system, and builds the model in a Boolean Expression 
    format. This function must be called before the use of any other bmc-related
    functionalities. Only one call per session is required.
    
    If you don't intend to do anything special, you might consider using `go_bmc`
    which is a shortcut for the whole bmc initialization process.
    
    .. note::
        This function is subject to the following requirements:
            
            - a model must be loaded (:func:`pynusmv.glob.load`)
            - hierarchy must already be flattened (:func:`pynusmv.glob.flatten_hierarchy`)
            - encoding must be already built (:func:`pynusmv.glob.encode_variables`)
            - boolean model must be already built (:func:`pynusmv.glob.build_boolean_model`)
               except if cone of influence is enabled and force is false
    
    :param force: a flag telling whether or not the boolean model must exist
       despite the cone of influence being enabled
    
    :raises NuSMVNeedBooleanModelError: if the boolean model wasn't created
    """
    # enforce preconditions
    if not _compile.cmp_struct_get_build_bool_model(glob.global_compile_cmps()):
        if not force and glob.is_cone_of_influence_enabled():
            pass
        else:
            raise NuSMVNeedBooleanModelError("boolean model must be created")
    
    if _compile.cmp_struct_get_bmc_setup(glob.global_compile_cmps()):
        raise NuSMVBmcAlreadyInitializedError("Bmc sub system already set up")
    
    # Build the vars manager, initializes the package and all sub packages, 
    # but only if not previously called.
    _bmc.Bmc_Init()
    
    build_master_be_fsm()
    
    be_fsm  = BeFsm.global_master_instance()
    be_enc  = be_fsm.encoding
    bdd_enc = glob.bdd_encoding()
    
    complete = _trc_exec.SATCompleteTraceExecutor_create(
                                be_fsm._ptr, be_enc._ptr, bdd_enc._ptr)
    _trace.TraceManager_register_complete_trace_executor(
        _trace.TracePkg_get_global_trace_manager(), 
        "sat", "SAT complete trace execution",
        _trc_exec.SATCompleteTraceExecutor2completeTraceExecutor(complete))
    
    partial_norestart = _trc_exec.SATPartialTraceExecutor_create(
                                be_fsm._ptr, be_enc._ptr, bdd_enc._ptr,False)
    _trace.TraceManager_register_partial_trace_executor(
        _trace.TracePkg_get_global_trace_manager(), 
        "sat", "SAT partial trace execution (no restart)",
        _trc_exec.SATPartialTraceExecutor2partialTraceExecutor(partial_norestart))
    
    partial_restarting= _trc_exec.SATPartialTraceExecutor_create(
                                be_fsm._ptr, be_enc._ptr, bdd_enc._ptr,True)
    _trace.TraceManager_register_partial_trace_executor(
        _trace.TracePkg_get_global_trace_manager(), 
        "sat_r", "SAT partial trace execution (restart)",
        _trc_exec.SATPartialTraceExecutor2partialTraceExecutor(partial_restarting))
    
    _compile.cmp_struct_set_bmc_setup(glob.global_compile_cmps())
Ejemplo n.º 9
0
 def test_to_boolean_wff(self):
     x   = self.enc.by_name["x"]
     x_  = Wff.decorate(x.name).to_boolean_wff(glob.bdd_encoding())
     # TODO: find something better to validate this
     self.assertIsNotNone(x_)