1 | % (c) 2009-2024 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, | |
2 | % Heinrich Heine Universitaet Duesseldorf | |
3 | % This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) | |
4 | ||
5 | :- module(model_checker,[is_deadlocked/1, node_satisfies_goal/1, | |
6 | open_search/12, | |
7 | expired_static_analysis_time/1, | |
8 | proof_info_model_checking_incomplete/5, model_checking_is_incomplete/6, | |
9 | perform_static_analyses/3, compute_transitions_opt/3, | |
10 | get_model_check_stats/6, | |
11 | find_invariant_error/4]). | |
12 | ||
13 | :- use_module(module_information). | |
14 | :- module_info(group,model_checker). | |
15 | :- module_info(description,'The core model checker (does not treat LTL).'). | |
16 | ||
17 | :- use_module(b_interpreter,[state_violates_assertions/2]). | |
18 | :- use_module(error_manager,[enter_new_error_scope/1, exit_error_scope/3, error_occurred_in_error_scope/0, | |
19 | add_internal_error/2]). | |
20 | ||
21 | :- use_module(specfile,[animation_mode/1,csp_mode/1]). | |
22 | :- use_module(state_space,[visited_expression/2,transition/3, operation_not_yet_covered/1]). | |
23 | ||
24 | :- use_module(probporsrc(static_analysis),[compute_dependendency_relation_of_all_events_in_the_model/3]). | |
25 | :- use_module(probpgesrc(pge_algo), [compute_transitions_pge/2,compute_operation_relations_for_pge_if_necessary/2]). | |
26 | ||
27 | :- use_module(state_space_exploration_modes,[depth_breadth_first_mode/1]). | |
28 | :- use_module(bmachine,[b_machine_has_constants/0]). | |
29 | :- use_module(state_space,[multiple_concrete_constants_exist/0]). | |
30 | ||
31 | :- dynamic mc_found_error/2. | |
32 | ||
33 | /* open_search: search for errors/goals among open nodes (i.e., not yet processed nodes)*/ | |
34 | /* LimitNr: max number of nodes to check, NodesAnalysed: number of nodes checked */ | |
35 | open_search(LimitNr,NodesAnalysed,LimitTime,Res,FindDeadlocks,FindInvViolations, | |
36 | FindGoal,FindAssViolations,FindStateErrors, | |
37 | StopAtFullCoverage,PartialOrderReduction,PartialGuardEvaluation) :- | |
38 | animation_mode(MODE), | |
39 | retractall(mc_found_error(_,_)), | |
40 | initialise_optimisations(MODE,PartialOrderReduction,PartialGuardEvaluation,FindInvViolations,Optimisations), | |
41 | perform_static_analyses(MODE,FindInvViolations,Optimisations), | |
42 | %(error_manager:real_error_occurred -> print(error_after_perform_static_analyses),nl ; true), | |
43 | depth_breadth_first_mode(DFMODE), | |
44 | preferences:temporary_set_preference(do_invariant_checking,true,CHNG), | |
45 | statistics(walltime,[ReferenceTime,_]), | |
46 | get_model_check_stats(States,_Transitions,ProcessedTotal,Percentage,_,_), | |
47 | % MEMO: used to cache expanded concrete_constants values | |
48 | % particularly useful, e.g., for ../prob_examples/public_examples/B/PerformanceTests/LiftLargeWithLargeCst.mch | |
49 | ((\+ b_machine_has_constants ; multiple_concrete_constants_exist) | |
50 | -> MEMO = '$disabled' % it could still be useful to cache one constant setup ?? | |
51 | ; true), | |
52 | enter_new_error_scope(ScopeID), | |
53 | set_context_state(root), | |
54 | open_search10(0,LimitNr,refstatus(ReferenceTime,Percentage,States,ProcessedTotal,ReferenceTime), | |
55 | NodesAnalysed,LimitTime,MCRes,FindDeadlocks,FindInvViolations, | |
56 | FindGoal,FindAssViolations,FindStateErrors, | |
57 | StopAtFullCoverage,Optimisations,MODE,DFMODE,MEMO), | |
58 | %tools_printing:print_term_summary(memo(MEMO)),nl, | |
59 | exit_error_scope(ScopeID,_,open_search), | |
60 | preferences:reset_temporary_preference(do_invariant_checking,CHNG), | |
61 | clear_context_state, | |
62 | (no_error_found_result(MCRes), | |
63 | mc_found_error(Res,ID) % stored error because of mc_continue_after_error | |
64 | -> set_counter_example_last_node(ID) | |
65 | ; Res=MCRes). | |
66 | ||
67 | no_error_found_result(no). | |
68 | no_error_found_result(all). | |
69 | ||
70 | :- use_module(probsrc(tools),[statistics_memory_used/1]). | |
71 | :- use_module(probsrc(debug),[silent_mode/1, formatsilent/3]). | |
72 | :- use_module(library(random)). | |
73 | open_search10(Nr,LimitNr,RefStatus,NodesAnalysed,LimitTime,Res, | |
74 | FindDeadlocks,FindInvViolations,FindGoal,FindAssViolations,FindStateErrors, | |
75 | SFC,Optimisations,MODE,DF,MEMO) :- | |
76 | %print(open_search(Nr,LimitNr,RefStatus)),nl, | |
77 | Nr < LimitNr,!, | |
78 | (\+ number(LimitTime) | |
79 | -> open_search_do_one_node(Nr,LimitNr,RefStatus,NodesAnalysed,LimitTime,Res, | |
80 | FindDeadlocks,FindInvViolations,FindGoal,FindAssViolations,FindStateErrors, | |
81 | SFC,Optimisations,MODE,DF,MEMO) | |
82 | ; statistics(walltime,[NewTime,_]), | |
83 | (Nr mod 25 =:= 24, silent_mode(off) %, Nr\=0 | |
84 | -> RefStatus = refstatus(RefTime,RefPerc,PrevStates,PrevProcessed,StartTime), | |
85 | Delta is NewTime-RefTime, | |
86 | (Delta>20000 % more than 20 seconds since last progress message | |
87 | % ; random(0,20000,X), X=<Delta) | |
88 | -> get_model_check_stats(States,Transitions,ProcessedTotal,Perc,Ignored,ScopePerc), | |
89 | (Ignored>0 | |
90 | -> format('~n* ~w states checked (~1f% of total ~w, ~1f% wo ~w ignored), ~w transitions,', | |
91 | [ProcessedTotal,Perc,States,ScopePerc,Ignored,Transitions]) | |
92 | ; get_current_breadth_first_level(Level) | |
93 | -> format('~n* ~w states checked (~1f% of total ~w), ~w transitions, bf-level ~w, ', | |
94 | [ProcessedTotal,Perc,States,Transitions,Level]) | |
95 | ; format('~n* ~w states checked (~1f% of total ~w), ~w transitions,', | |
96 | [ProcessedTotal,Perc,States,Transitions]) | |
97 | ), | |
98 | findall(Op,operation_not_yet_covered(Op),NotCov), length(NotCov,NrNotCov), | |
99 | (NrNotCov = 1 -> format(' 1 operation not covered,',[]) | |
100 | ; NrNotCov > 0 -> format(' ~w operations not covered,',[NrNotCov]) ; true), | |
101 | statistics_memory_used(M), tools:print_mb(M), | |
102 | DeltaProcessedStates is (ProcessedTotal-PrevProcessed), | |
103 | NodesProcessedPerSec is DeltaProcessedStates*1000 / (NewTime-RefTime), | |
104 | format('~n* currently checking ~2f states/sec',[NodesProcessedPerSec]), | |
105 | DeltaStates is (States-PrevStates), | |
106 | NodesPerSec is DeltaStates*1000 / (NewTime-RefTime), | |
107 | format(', adding ~2f new states/sec~n',[NodesPerSec]), | |
108 | RefStatus1 = refstatus(NewTime,Perc,States,ProcessedTotal,StartTime), | |
109 | FullDeltaTime is NewTime - StartTime, | |
110 | FullDeltaTimeMinutes is FullDeltaTime / 60000.0, | |
111 | (Perc>RefPerc -> format('* walltime ~1f minutes~n',[FullDeltaTimeMinutes]) | |
112 | ; format('* walltime ~1f minutes, percentage of checked states decreasing from ~1f%~n',[FullDeltaTimeMinutes,RefPerc])) | |
113 | ; RefStatus1 = RefStatus | |
114 | ) | |
115 | ; RefStatus1 = RefStatus | |
116 | ), | |
117 | (NewTime>LimitTime, Nr>0 | |
118 | -> Res = [timeout,Nr], NodesAnalysed=Nr | |
119 | ; open_search_do_one_node(Nr,LimitNr,RefStatus1,NodesAnalysed,LimitTime,Res, | |
120 | FindDeadlocks,FindInvViolations,FindGoal,FindAssViolations,FindStateErrors, | |
121 | SFC,Optimisations,MODE,DF,MEMO)) | |
122 | ). | |
123 | open_search10(N,_LimitNr,_RefStatus,N,_,no ,_,_,_,_,_,_,_,_,_,_MEMO). | |
124 | ||
125 | % States: total number of states encounetered | |
126 | % ProcessedTotal: number of states already processed | |
127 | % Percentage: percentate of total processed | |
128 | % Ignored: number of states ignored because not satisfying SCOPE predicate | |
129 | % ScopePercentage: percentage processed taking into account ignored states | |
130 | get_model_check_stats(States,Transitions,ProcessedTotal,Percentage,Ignored,ScopePercentage) :- | |
131 | get_state_space_stats(States,Transitions,ProcessedTotal,Ignored), | |
132 | Percentage is (100*ProcessedTotal / States), | |
133 | InScope is (States-Ignored), | |
134 | (InScope > 0 -> ScopePercentage is (100*ProcessedTotal / InScope) ; ScopePercentage = 100). | |
135 | ||
136 | :- use_module(preferences,[preference/2]). | |
137 | :- use_module(specfile,[prepare_state_for_specfile_trans/4]). | |
138 | open_search_do_one_node(Nr,LimitNr,RefStatus,NodesAnalysed,LimitTime,Res, | |
139 | FindDeadlocks,FindInvViolations, | |
140 | FindGoal,FindAssViolations,FindStateErrors, | |
141 | StopAtFullCoverage,Optimisations,MODE,DFMODE,MEMO) :- | |
142 | get_next_node_to_check(FindInvViolations,ID,MODE,DFMODE),!, | |
143 | update_context_state(ID), %print(treating_node(ID)),nl, | |
144 | ||
145 | (preference(ignore_hash_collisions,true), | |
146 | preference(forget_state_space,true) | |
147 | -> retract_visited_expression(ID,CurState) %, retractall(id_to_marker(ID,_)) not necessary | |
148 | ; visited_expression(ID,CurState)), | |
149 | (FindInvViolations=1 % compute invariant status | |
150 | -> prepare_state_for_specfile_trans(CurState,ID,MEMO,PCurState), | |
151 | tcltk_interface:compute_invariant_if_necessary(ID,PCurState,MODE) | |
152 | ; CurState=PCurState), | |
153 | %print(processed_invariant(ID)), statistics(memory_used,M), tools:print_mb(M),nl, | |
154 | !, | |
155 | compute_transitions_opt(Optimisations,ID,PCurState), | |
156 | %tools:print_message(mc(ID)), | |
157 | %print(computed_all_transitions(ID)), statistics(memory_used,M2), tools:print_mb(M2),nl, | |
158 | % !, | |
159 | (open_search_check_for_error(ID,PCurState,Res, | |
160 | FindDeadlocks,FindInvViolations,FindGoal,FindAssViolations, | |
161 | FindStateErrors,StopAtFullCoverage,MODE) | |
162 | -> print_found_error(Res,ID), | |
163 | NodesAnalysed=Nr, | |
164 | set_counter_example_last_node(ID) | |
165 | ; N1 is Nr + 1, | |
166 | open_search10(N1,LimitNr,RefStatus,NodesAnalysed,LimitTime,Res, | |
167 | FindDeadlocks,FindInvViolations,FindGoal,FindAssViolations,FindStateErrors,StopAtFullCoverage, | |
168 | Optimisations,MODE,DFMODE,MEMO) | |
169 | ). | |
170 | open_search_do_one_node(N,_LimitNr,_RefStatus,N,_,all,_,_,_,_,_,_,_,_,_,_MEMO) :- | |
171 | formatsilent(user_output,'% Model checking finished, all open states visited~n',[]). | |
172 | ||
173 | set_counter_example_last_node(ID) :- | |
174 | tcltk_interface:tcltk_execute_trace_to_node(ID). % TO DO: allow to disable this when -nocounter option given | |
175 | ||
176 | :- use_module(tools_printing,[format_with_colour_nl/4]). | |
177 | print_found_error(goal_found,ID) :- !, | |
178 | format_with_colour_nl(user_output,[green],'Found GOAL in state id ~w',[ID]). | |
179 | print_found_error(full_coverage,ID) :- !, | |
180 | format_with_colour_nl(user_output,[green],'Full coverage achieved in state id ~w',[ID]). | |
181 | print_found_error(state_error(X),ID) :- nonvar(X),functor(X,F,_),!, % only print functor; term can be big | |
182 | format_with_colour_nl(user_error,[red],'Found "~w" in state id ~w',[F,ID]). | |
183 | print_found_error(X,ID) :- | |
184 | format_with_colour_nl(user_error,[red],'Found "~w" error in state id ~w',[X,ID]). | |
185 | ||
186 | ||
187 | %% Optimisation options (see first argument 'Optimisations'): | |
188 | compute_transitions_opt(Optimisations,ID,CurState) :- | |
189 | Optimisations = opt(PORPrefs,PGEPref), | |
190 | compute_transitions(PORPrefs,PGEPref,ID,CurState). | |
191 | ||
192 | compute_transitions(PORPrefs,_PGEPref,ID,CurState) :- | |
193 | PORPrefs = por(POROption,_UseEnableGraph,_Depth,_UsePGE), | |
194 | (POROption==ample_sets;POROption==ample_sets2),!, | |
195 | tcltk_interface: compute_ample_set(ID,CurState,PORPrefs). | |
196 | compute_transitions(_,PGEPref,ID,CurState) :- | |
197 | PGEPref \= off,!, | |
198 | compute_transitions_pge(ID,CurState). % from pge_algo | |
199 | compute_transitions(_,_,ID,CurState) :- | |
200 | tcltk_interface: compute_all_transitions(ID,CurState). | |
201 | ||
202 | :- use_module(preferences,[get_preference/2]). | |
203 | :- use_module(specfile,[b_or_z_mode/1]). | |
204 | :- use_module(state_space_exploration_modes,[get_open_node_to_check/2, get_current_breadth_first_level/1]). | |
205 | %%get_next_node_to_check(1,ID,_) :- state_space:not_invariant_checked(ID). % if there is an existing node whose invariant we have not yet checked: check it now | |
206 | get_next_node_to_check(_,ID,AnimMODE,DFMODE) :- | |
207 | %(nonvar(ID) -> print(nonvar(ID)),nl ; true), | |
208 | get_open_node_to_check(DFMODE,ID), | |
209 | (b_or_z_mode(AnimMODE) -> assertz(not_invariant_checked(ID)) ; true). | |
210 | ||
211 | ||
212 | :- use_module(state_space). | |
213 | open_search_check_for_error(ID,PCurState,Res, | |
214 | FindDeadlocks,FindInvViolations,FindGoal,FindAssViolations, | |
215 | FindStateErrors,StopAtFullCoverage,MODE) :- | |
216 | open_search_found_error(ID,PCurState,Res, | |
217 | FindDeadlocks,FindInvViolations,FindGoal,FindAssViolations, | |
218 | FindStateErrors,StopAtFullCoverage,MODE), | |
219 | (get_preference(mc_continue_after_error,false) | |
220 | -> true | |
221 | ; print_found_error(Res,ID), % just print the error and try find more | |
222 | %ajoin(['Found at state ',ID,':'],Msg), add_error(model_checker,'Found error:'Res), | |
223 | % we could call analyse_invariant_for_state(ID) | |
224 | \+ mc_found_error(_,_), | |
225 | assertz(mc_found_error(Res,ID)), % store error to replay at end | |
226 | fail | |
227 | ). | |
228 | ||
229 | open_search_found_error(ID,CurState,Error, | |
230 | _FindDeadlocks,1,_FindGoal,_FindAssViolations,_FindStateErrors,_StopAtFullCoverage,MODE) :- | |
231 | find_invariant_error(MODE,ID,CurState,Error). | |
232 | open_search_found_error(ID,_CurState,deadlock,1,_,_,_,_,_,_) :- | |
233 | is_deadlocked(ID). %, print(deadlock(ID)),nl. | |
234 | open_search_found_error(ID,CurState,assertion_violation,_,_,_,1,_,_,_MODE) :- | |
235 | state_violates_assertions(ID,CurState). | |
236 | open_search_found_error(ID,_CurState,ERR,_,_,_,_,1,_,_MODE) :- | |
237 | state_space:state_error(ID,_,Error), | |
238 | Error \== invariant_violated, | |
239 | ERR = state_error(Error). | |
240 | open_search_found_error(_ID,_CurState,general_error_occurred,_,_,_,_,1,_,_MODE) :- | |
241 | error_occurred_in_error_scope. % enter_new_error_scope set up in open_search | |
242 | %% we no longer use: error_manager:real_error_occurred ; errors can happen e.g. in POR static analysis | |
243 | open_search_found_error(ID,CurState,goal_found,_,_,1,_,_,_,MODE) :- | |
244 | node_satisfies_goal(ID,CurState,MODE). | |
245 | open_search_found_error(_ID,_CurState,full_coverage,_,_,_,_,_,1,_MODE) :- % StopAtFullCoverage = 1 | |
246 | \+ operation_not_yet_covered(_). | |
247 | ||
248 | find_invariant_error(b,ID,_CurState,invariant_violation) :- !, % here we know that invariant information has been computed | |
249 | (invariant_violated(ID) -> true). | |
250 | %find_invariant_error(b,_ID,CurState,invariant_false) :- !, | |
251 | % preference(double_evaluation_when_analysing,true), % DOUBLE_EVALUATION | |
252 | % CurState \= root, CurState \= concrete_constants(_), | |
253 | % specfile:expand_const_and_vars_to_full_store(CurState,FullState), %print(eval_neg_inv(_ID)),nl, | |
254 | % (b_interpreter:state_satisfies_negation_of_invariant(FullState)->true). | |
255 | find_invariant_error(cspm,ID,_CurState,csp_error) :- !, % we know that only csp_can be possible | |
256 | is_csp_error_state(ID). | |
257 | find_invariant_error(MODE,ID,CurState,invariant_violation) :- | |
258 | tcltk_interface:check_invariantKO(MODE,ID,CurState). | |
259 | find_invariant_error(csp_and_b,ID,_CurState,csp_error) :- !, % xtl mode cannot apply | |
260 | is_csp_error_state(ID). | |
261 | find_invariant_error(MODE,ID,CurState,xtl_error) :- | |
262 | is_xtl_error_state(ID,CurState,MODE). | |
263 | ||
264 | :- use_module(error_manager,[add_warning/3]). | |
265 | is_deadlocked(ID) :- | |
266 | preferences:preference(forget_state_space,true),!, /* transitions not added */ | |
267 | (retract(state_space:transition(ID,_,_,_)) -> fail ; true). | |
268 | is_deadlocked(ID) :- % ID must be ground upon call | |
269 | %% visited_expression_id(ID), | |
270 | deadlocked_state(ID), | |
271 | \+ max_reached_or_timeout_for_node(ID), | |
272 | (get_preference(store_only_one_incoming_transition,true) | |
273 | -> add_warning(model_checker,'Deadlock may not exist and be caused by preference SAFETY_MODEL_CHECK being TRUE: ',ID) | |
274 | ; true). | |
275 | /* \+((transition(ID,_,NID),NID \= ID)). <-- to detect more liberal form of DEADLOCK */ | |
276 | ||
277 | is_csp_error_state(ID) :- | |
278 | transition(ID,io(_,error,_),_). /* <--- THE CSP has raised the error channel */ | |
279 | ||
280 | :- use_module(xtl_interface,[xtl_invariant_violated/1]). | |
281 | is_xtl_error_state(_ID,CurState,xtl) :- | |
282 | xtl_invariant_violated(CurState). /* <--- XTL has found unsafe configuration */ | |
283 | % ; AM=promela -> promela_property(CurState,unsafe) | |
284 | % ; AM=smv -> smv_property(CurState,unsafe) ). | |
285 | ||
286 | ||
287 | :- use_module(specfile,[animation_mode/1, b_or_z_mode/1, csp_mode/1]). | |
288 | ||
289 | node_satisfies_goal(NodeID) :- | |
290 | animation_mode(MODE), | |
291 | (MODE=xtl | |
292 | -> visited_expression(NodeID,State), | |
293 | node_satisfies_goal(NodeID,State,MODE) | |
294 | ; node_satisfies_goal(NodeID,[],MODE) % we do not need the state | |
295 | ). | |
296 | ||
297 | :- use_module(xtl_interface,[xtl_goal_found/1]). | |
298 | :- use_module(bmachine,[b_get_machine_goal/1]). | |
299 | node_satisfies_goal(NodeID,_,MODE) :- b_or_z_mode(MODE), !, | |
300 | b_get_machine_goal(Goal), | |
301 | eclipse_interface:test_boolean_expression_in_node(NodeID,Goal,'model checking GOAL'). % TODO: avoid re-expanding state | |
302 | node_satisfies_goal(NodeID,_,MODE) :- csp_mode(MODE), !, | |
303 | transition(NodeID,io(_,goal,_),_). | |
304 | node_satisfies_goal(_,State,xtl) :- | |
305 | xtl_goal_found(State). | |
306 | % TO DO: allow LTL atomic properties like e(Op1), ... | |
307 | % TO DO: seperate machine GOAL from MC goal; provide intermediate PROB fact and set_mc_goal/1 | |
308 | ||
309 | % --------------------------------------- | |
310 | ||
311 | :- use_module(tools, [ajoin/2]). | |
312 | :- use_module(symsrc(symmetry_marker),[hash_model_checking_imprecise/2]). | |
313 | % Note: we do not need mcFindStateErrors flag | |
314 | %model_checking_is_unsound(FindInvViolations,FindDeadlocks,FindGoal,FindAssViolations,Msg,Term) | |
315 | model_checking_is_incomplete(FindInvViolations,FindDeadlocks,FindGoal,FindAssViolations,Msg,'') :- | |
316 | proof_info_model_checking_incomplete(FindInvViolations,FindDeadlocks,FindGoal,FindAssViolations,Msg). | |
317 | model_checking_is_incomplete(_FindInv,_FindDeadlocks,_FindGoal,_FindAss,Msg,Term) :- | |
318 | (get_preference(symmetry_mode,hash),hash_model_checking_imprecise(ID,BasicType) | |
319 | -> Msg = '*** Possibly not all states computed, symmetry hashing may be imprecise, e.g., for variable ', | |
320 | translate:pretty_type(BasicType,S), | |
321 | ajoin([ID,' : ',S],Term)). | |
322 | model_checking_is_incomplete(1,_FindDeadlocks,_FindGoal,_FindAss,Msg,Term) :- | |
323 | (time_out_for_invariant(ID) | |
324 | -> Msg = '*** Timeout(s) occured during invariant computation, e.g., state with id = ', Term=ID). | |
325 | model_checking_is_incomplete(_FindInv,_FindDeadlocks,_FindGoal,1,Msg,Term) :- | |
326 | (time_out_for_assertions(ID) | |
327 | -> Msg = '*** Timeout(s) occured during evaluation of ASSERTIONS, e.g., state with id = ', Term=ID). | |
328 | model_checking_is_incomplete(_FindInv,_FindDeadlocks,_FindGoal,_FindAss,Msg,Term) :- | |
329 | (max_reached_for_node(ID) | |
330 | -> ((ID=root ; is_concrete_constants_state_id(ID)) | |
331 | -> get_preference(maxNrOfInitialisations,MI), | |
332 | ajoin(['*** Not all transitions were computed as MAX_INITIALISATIONS=',MI,' was too small, e.g., for state with id = '],Msg) | |
333 | ; get_preference(maxNrOfEnablingsPerOperation,MO), | |
334 | ajoin(['*** Not all transitions were computed as MAX_OPERATIONS=',MO,' was too small, e.g., for state with id = '],Msg) | |
335 | ), | |
336 | Term=ID). | |
337 | model_checking_is_incomplete(_FindInv,_FindDeadlocks,_FindGoal,_FindAss,Msg,Term) :- | |
338 | (time_out_for_node(ID,Op,Reason) -> | |
339 | functor(Reason,Func,_), % time_out or virtual_time_out | |
340 | ajoin(['*** Not all transitions were computed due to a ', Func,', e.g., for ',Op, ' and state with id = '],Msg), | |
341 | Term=ID). | |
342 | model_checking_is_incomplete(_FindInv,_FindDeadlocks,_FindGoal,_FindAss,Msg,'') :- | |
343 | get_preference(ignore_hash_collisions,true), | |
344 | Msg = '*** Possibly not all states computed due to IGNORE_HASH_COLLISIONS preference'. | |
345 | ||
346 | :- use_module(bmachine, [b_machine_has_proven_invariants/0, b_machine_has_unproven_assertions/0]). | |
347 | proof_info_model_checking_incomplete(1,_FindDeadlocks,_FindGoal,0,Msg) :- | |
348 | b_machine_has_proven_invariants, | |
349 | preferences:get_preference(use_po,true), | |
350 | b_machine_has_unproven_assertions, | |
351 | Msg = '*** Using proof information (-p PROOF_INFO TRUE) is potentially incomplete when not checking theorems (-noass) !'. | |
352 | ||
353 | ||
354 | % disable POR if not applicable + merge POR/PGE info into one atom for easier lookup in compute_transitions | |
355 | initialise_optimisations(MODE,PartialOrderReduction,PartialGuardEvaluation,FindInvViolations,Optimisations) :- | |
356 | MODE == b, | |
357 | !, | |
358 | ((PartialOrderReduction == ample_sets; PartialOrderReduction == ample_sets2) -> | |
359 | get_preference(enable_graph,UseEnableGraph), | |
360 | get_preference(enable_graph_depth,Depth), | |
361 | PORPrefs = por(PartialOrderReduction,UseEnableGraph,Depth,PartialGuardEvaluation), | |
362 | Optimisations = opt(PORPrefs,PartialGuardEvaluation), | |
363 | (FindInvViolations == 1 -> assertz(ample_sets:check_cycle_proviso);true) | |
364 | ; PartialGuardEvaluation \= off -> | |
365 | Optimisations = opt(off,PartialGuardEvaluation) | |
366 | ; | |
367 | Optimisations = opt(off,off)). | |
368 | initialise_optimisations(_,_,_,_,opt(off,off)). | |
369 | ||
370 | ||
371 | :- dynamic expired_static_analysis_time/1. | |
372 | perform_static_analyses(MODE,FindInvViolations,opt(PORPrefs,PGEPref)) :- | |
373 | MODE == b, | |
374 | !, | |
375 | retractall(expired_static_analysis_time(_)), | |
376 | statistics(runtime,[T1,_]), | |
377 | (perform_static_analyses_aux(PORPrefs,PGEPref,FindInvViolations) -> true | |
378 | ; add_internal_error('POR static analysis failed:',perform_static_analyses_aux(PORPrefs,PGEPref,FindInvViolations)) | |
379 | ), | |
380 | statistics(runtime,[T2,_]), | |
381 | D is T2-T1, | |
382 | assertz(expired_static_analysis_time(D)). | |
383 | perform_static_analyses(_,_,_) :- retractall(expired_static_analysis_time(_)). | |
384 | ||
385 | perform_static_analyses_aux(off,off,_FindInvViolations) :- !. | |
386 | perform_static_analyses_aux(PORPrefs,PGEPref,FindInvViolations) :- | |
387 | PORPrefs = por(POROption,_UseEnableGraph,_Depth,_), | |
388 | (POROption==ample_sets;POROption==ample_sets2),!, | |
389 | compute_dependendency_relation_of_all_events_in_the_model(FindInvViolations,PORPrefs,_EnableGraph), | |
390 | compute_operation_relations_for_pge_if_necessary(PGEPref,FindInvViolations). | |
391 | perform_static_analyses_aux(_,PGEPref,FindInvViolations) :- | |
392 | compute_operation_relations_for_pge_if_necessary(PGEPref,FindInvViolations). | |
393 | perform_static_analyses_aux(_,_,_). |