1414from cfpq_model .cnf_grammar_template import CnfGrammarTemplate
1515from cfpq_model .label_decomposed_graph import LabelDecomposedGraph
1616from cfpq_add_context .add_contexts import add_context , normalize
17+ from cfpq_add_context .utils import verify
1718
1819
1920def run_all_pairs_cflr (
@@ -24,13 +25,13 @@ def run_all_pairs_cflr(
2425 out_path : Optional [str ],
2526 settings : List [AlgoSetting ],
2627 add_contexts : bool = False ,
28+ expected_path : str = "" ,
2729):
2830 algo = get_all_pairs_cfl_reachability_algo (algo_name )
2931 if add_contexts :
3032 graph ,initial_graph_nvertices = add_context (graph_path )
3133 else :
3234 graph = LabelDecomposedGraph .read_from_pocr_graph_file (graph_path )
33- print ("graph = " , graph )
3435 grammar = CnfGrammarTemplate .read_from_pocr_cnf_file (grammar_path )
3536 graph , grammar = preprocess_graph_and_grammar (graph , grammar , settings )
3637 try :
@@ -39,6 +40,8 @@ def run_all_pairs_cflr(
3940 res = algo .solve (graph = graph , grammar = grammar , settings = settings )
4041 if add_contexts :
4142 res = normalize (res , initial_graph_nvertices )
43+ if not ((len (expected_path ) > 0 ) and (verify (res , expected_path ))):
44+ print ("Incorrect result !!!" )
4245 finish = time ()
4346 print ("result: " , res )
4447 print (f"AnalysisTime\t { finish - start } " )
@@ -90,6 +93,9 @@ def main(raw_args: List[str]):
9093 parser .add_argument ('--add_contexts' , dest = 'add_contexts' , default = False ,
9194 help = 'Specifies whether approximation of context sensitivity should be added.'
9295 )
96+ parser .add_argument ('--expected_path' , dest = 'expected_path' , default = "" ,
97+ help = 'If specified, it will be checked wether solver\' s result is overapproximation of represented in the file.'
98+ )
9399 settings_manager = AlgoSettingsManager ()
94100 settings_manager .add_args (parser )
95101 args = parser .parse_args (raw_args )
@@ -98,6 +104,7 @@ def main(raw_args: List[str]):
98104 graph_path = args .graph ,
99105 grammar_path = args .grammar ,
100106 add_contexts = args .add_contexts ,
107+ expected_path = args .expected_path ,
101108 time_limit_sec = args .time_limit ,
102109 out_path = args .out ,
103110 settings = settings_manager .read_args (args )
0 commit comments