4 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
5 "Logging specific to algorithms for liveness properties verification");
7 xbt_dynar_t reached_pairs;
8 xbt_dynar_t reached_pairs_hash;
9 xbt_dynar_t visited_pairs;
10 xbt_dynar_t visited_pairs_hash;
11 xbt_dynar_t successors;
14 /* fast implementation of djb2 algorithm */
15 unsigned int hash_region(char *str, int str_len){
18 register unsigned int hash = 5381;
22 hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
29 int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
32 if(s1->num_reg != s2->num_reg){
33 XBT_DEBUG("Different num_reg (s1 = %d, s2 = %d)", s1->num_reg, s2->num_reg);
40 for(i=0 ; i< s1->num_reg ; i++){
42 if(s1->regions[i]->type != s2->regions[i]->type){
43 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
44 XBT_DEBUG("Different type of region");
51 switch(s1->regions[i]->type){
53 if(s1->regions[i]->size != s2->regions[i]->size){
54 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
55 XBT_DEBUG("Different size of heap (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size);
61 if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
62 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
63 XBT_DEBUG("Different start addr of heap (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
69 if(mmalloc_compare_heap(s1->regions[i]->data, s2->regions[i]->data)){
70 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
71 XBT_DEBUG("Different heap (mmalloc_compare)");
79 if(s1->regions[i]->size != s2->regions[i]->size){
80 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
81 XBT_DEBUG("Different size of libsimgrid (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size);
87 if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
88 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
89 XBT_DEBUG("Different start addr of libsimgrid (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
95 if(memcmp(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
96 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
97 XBT_DEBUG("Different memcmp for data in libsimgrid");
105 if(s1->regions[i]->size != s2->regions[i]->size){
106 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
107 XBT_DEBUG("Different size of program (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size);
113 if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
114 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
115 XBT_DEBUG("Different start addr of program (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
121 if(memcmp(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
122 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
123 XBT_DEBUG("Different memcmp for data in program");
131 if(s1->regions[i]->size != s2->regions[i]->size){
132 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
133 XBT_DEBUG("Different size of stack (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size);
139 if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
140 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
141 XBT_DEBUG("Different start addr of stack (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
147 if(memcmp(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
148 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
149 XBT_DEBUG("Different memcmp for data in stack");
161 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
169 int reached(xbt_state_t st){
172 if(xbt_dynar_is_empty(reached_pairs)){
180 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
181 MC_take_snapshot_liveness(sn);
183 xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
187 /* Get values of propositional symbols */
188 unsigned int cursor = 0;
189 xbt_propositional_symbol_t ps = NULL;
190 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
193 xbt_dynar_push_as(prop_ato, int, res);
197 mc_pair_reached_t pair_test = NULL;
200 xbt_dynar_foreach(reached_pairs, cursor, pair_test){
201 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
202 if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
203 XBT_DEBUG("Pair reached %d", cursor+1);
204 if(snapshot_compare(pair_test->system_state, sn) == 0){
205 MC_free_snapshot(sn);
206 xbt_dynar_reset(prop_ato);
211 XBT_DEBUG("Different snapshot");
214 XBT_DEBUG("Different values of propositional symbols");
217 XBT_DEBUG("Different automaton state");
221 MC_free_snapshot(sn);
222 xbt_dynar_reset(prop_ato);
230 void set_pair_reached(xbt_state_t st){
235 mc_pair_reached_t pair = NULL;
236 pair = xbt_new0(s_mc_pair_reached_t, 1);
237 pair->automaton_state = st;
238 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
239 pair->system_state = xbt_new0(s_mc_snapshot_t, 1);
240 MC_take_snapshot_liveness(pair->system_state);
242 /* Get values of propositional symbols */
243 unsigned int cursor = 0;
244 xbt_propositional_symbol_t ps = NULL;
248 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
251 xbt_dynar_push_as(pair->prop_ato, int, res);
254 xbt_dynar_push(reached_pairs, &pair);
260 int reached_hash(xbt_state_t st){
263 if(xbt_dynar_is_empty(reached_pairs_hash)){
271 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
272 MC_take_snapshot_liveness(sn);
275 unsigned int hash_regions[sn->num_reg];
276 for(j=0; j<sn->num_reg; j++){
277 hash_regions[j] = hash_region(sn->regions[j]->data, sn->regions[j]->size);
281 /* Get values of propositional symbols */
282 xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
283 unsigned int cursor = 0;
284 xbt_propositional_symbol_t ps = NULL;
288 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
291 xbt_dynar_push_as(prop_ato, int, res);
294 mc_pair_reached_hash_t pair_test = NULL;
300 xbt_dynar_foreach(reached_pairs_hash, cursor, pair_test){
302 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
303 if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
304 for(j=0 ; j< sn->num_reg ; j++){
305 if(hash_regions[j] != pair_test->hash_regions[j]){
309 if(region_diff == 0){
310 MC_free_snapshot(sn);
311 xbt_dynar_reset(prop_ato);
316 XBT_DEBUG("Different snapshot");
319 XBT_DEBUG("Different values of propositional symbols");
322 XBT_DEBUG("Different automaton state");
328 MC_free_snapshot(sn);
329 xbt_dynar_reset(prop_ato);
337 void set_pair_reached_hash(xbt_state_t st){
341 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
342 MC_take_snapshot_liveness(sn);
344 mc_pair_reached_hash_t pair = NULL;
345 pair = xbt_new0(s_mc_pair_reached_hash_t, 1);
346 pair->automaton_state = st;
347 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
348 pair->hash_regions = malloc(sizeof(unsigned int) * sn->num_reg);
352 for(i=0 ; i< sn->num_reg ; i++){
353 pair->hash_regions[i] = hash_region(sn->regions[i]->data, sn->regions[i]->size);
356 /* Get values of propositional symbols */
357 unsigned int cursor = 0;
358 xbt_propositional_symbol_t ps = NULL;
362 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
365 xbt_dynar_push_as(pair->prop_ato, int, res);
368 xbt_dynar_push(reached_pairs_hash, &pair);
370 MC_free_snapshot(sn);
377 int visited(xbt_state_t st, int sc){
380 if(xbt_dynar_is_empty(visited_pairs)){
388 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
389 MC_take_snapshot_liveness(sn);
391 xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
393 /* Get values of propositional symbols */
394 unsigned int cursor = 0;
395 xbt_propositional_symbol_t ps = NULL;
399 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
402 xbt_dynar_push_as(prop_ato, int, res);
406 mc_pair_visited_t pair_test = NULL;
408 xbt_dynar_foreach(visited_pairs, cursor, pair_test){
409 if(pair_test->search_cycle == sc) {
410 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
411 if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
412 if(snapshot_compare(pair_test->system_state, sn) == 0){
414 MC_free_snapshot(sn);
415 xbt_dynar_reset(prop_ato);
422 XBT_DEBUG("Different snapshot");
425 XBT_DEBUG("Different values of propositional symbols");
428 XBT_DEBUG("Different automaton state");
431 XBT_DEBUG("Different value of search_cycle");
436 MC_free_snapshot(sn);
437 xbt_dynar_reset(prop_ato);
446 int visited_hash(xbt_state_t st, int sc){
449 if(xbt_dynar_is_empty(visited_pairs_hash)){
457 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
458 MC_take_snapshot_liveness(sn);
461 unsigned int hash_regions[sn->num_reg];
462 for(j=0; j<sn->num_reg; j++){
463 hash_regions[j] = hash_region(sn->regions[j]->data, sn->regions[j]->size);
467 /* Get values of propositional symbols */
468 xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
469 unsigned int cursor = 0;
470 xbt_propositional_symbol_t ps = NULL;
474 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
477 xbt_dynar_push_as(prop_ato, int, res);
480 mc_pair_visited_hash_t pair_test = NULL;
485 xbt_dynar_foreach(visited_pairs_hash, cursor, pair_test){
487 if(pair_test->search_cycle == sc) {
488 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
489 if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
490 for(j=0 ; j< sn->num_reg ; j++){
491 if(hash_regions[j] != pair_test->hash_regions[j]){
495 if(region_diff == 0){
496 MC_free_snapshot(sn);
497 xbt_dynar_reset(prop_ato);
502 XBT_DEBUG("Different snapshot");
505 XBT_DEBUG("Different values of propositional symbols");
508 XBT_DEBUG("Different automaton state");
511 XBT_DEBUG("Different value of search_cycle");
517 MC_free_snapshot(sn);
518 xbt_dynar_reset(prop_ato);
526 void set_pair_visited_hash(xbt_state_t st, int sc){
530 mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
531 MC_take_snapshot_liveness(sn);
533 mc_pair_visited_hash_t pair = NULL;
534 pair = xbt_new0(s_mc_pair_visited_hash_t, 1);
535 pair->automaton_state = st;
536 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
537 pair->search_cycle = sc;
538 pair->hash_regions = malloc(sizeof(unsigned int) * sn->num_reg);
542 for(i=0 ; i< sn->num_reg ; i++){
543 pair->hash_regions[i] = hash_region(sn->regions[i]->data, sn->regions[i]->size);
546 /* Get values of propositional symbols */
547 unsigned int cursor = 0;
548 xbt_propositional_symbol_t ps = NULL;
552 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
555 xbt_dynar_push_as(pair->prop_ato, int, res);
558 xbt_dynar_push(visited_pairs_hash, &pair);
560 MC_free_snapshot(sn);
566 void set_pair_visited(xbt_state_t st, int sc){
571 mc_pair_visited_t pair = NULL;
572 pair = xbt_new0(s_mc_pair_visited_t, 1);
573 pair->automaton_state = st;
574 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
575 pair->search_cycle = sc;
576 pair->system_state = xbt_new0(s_mc_snapshot_t, 1);
577 MC_take_snapshot_liveness(pair->system_state);
580 /* Get values of propositional symbols */
581 unsigned int cursor = 0;
582 xbt_propositional_symbol_t ps = NULL;
586 xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
589 xbt_dynar_push_as(pair->prop_ato, int, res);
592 xbt_dynar_push(visited_pairs, &pair);
599 void MC_pair_delete(mc_pair_t pair){
600 xbt_free(pair->graph_state->proc_status);
601 xbt_free(pair->graph_state);
607 int MC_automaton_evaluate_label(xbt_exp_label_t l){
611 int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
612 int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
613 return (left_res || right_res);
617 int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
618 int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
619 return (left_res && right_res);
623 int res = MC_automaton_evaluate_label(l->u.exp_not);
628 unsigned int cursor = 0;
629 xbt_propositional_symbol_t p = NULL;
631 xbt_dynar_foreach(automaton->propositional_symbols, cursor, p){
632 if(strcmp(p->pred, l->u.predicat) == 0){
654 /********************* Double-DFS stateless *******************/
656 void MC_pair_stateless_delete(mc_pair_stateless_t pair){
657 xbt_free(pair->graph_state->proc_status);
658 xbt_free(pair->graph_state);
662 mc_pair_stateless_t new_pair_stateless(mc_state_t sg, xbt_state_t st, int r){
663 mc_pair_stateless_t p = NULL;
664 p = xbt_new0(s_mc_pair_stateless_t, 1);
665 p->automaton_state = st;
668 mc_stats_pair->expanded_pairs++;
672 void MC_ddfs_init(void){
674 XBT_DEBUG("**************************************************");
675 XBT_DEBUG("Double-DFS init");
676 XBT_DEBUG("**************************************************");
678 mc_pair_stateless_t mc_initial_pair = NULL;
679 mc_state_t initial_graph_state = NULL;
680 smx_process_t process;
682 MC_wait_for_requests();
686 initial_graph_state = MC_state_pair_new();
687 xbt_swag_foreach(process, simix_global->process_list){
688 if(MC_process_is_enabled(process)){
689 MC_state_interleave_process(initial_graph_state, process);
693 reached_pairs = xbt_dynar_new(sizeof(mc_pair_reached_t), NULL);
694 //reached_pairs_hash = xbt_dynar_new(sizeof(mc_pair_reached_hash_t), NULL);
695 //visited_pairs = xbt_dynar_new(sizeof(mc_pair_visited_t), NULL);
696 visited_pairs_hash = xbt_dynar_new(sizeof(mc_pair_visited_hash_t), NULL);
697 successors = xbt_dynar_new(sizeof(mc_pair_stateless_t), NULL);
699 /* Save the initial state */
700 initial_snapshot_liveness = xbt_new0(s_mc_snapshot_t, 1);
701 MC_take_snapshot_to_restore_liveness(initial_snapshot_liveness);
705 unsigned int cursor = 0;
708 xbt_dynar_foreach(automaton->states, cursor, state){
709 if(state->type == -1){
712 mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
713 xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
717 MC_restore_snapshot(initial_snapshot_liveness);
724 if(state->type == 2){
727 mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
728 xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
731 set_pair_reached(state);
732 //set_pair_reached_hash(state);
735 MC_restore_snapshot(initial_snapshot_liveness);
748 void MC_ddfs(int search_cycle){
750 smx_process_t process;
751 mc_pair_stateless_t current_pair = NULL;
753 if(xbt_fifo_size(mc_stack_liveness) == 0)
757 /* Get current pair */
758 current_pair = (mc_pair_stateless_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness));
760 /* Update current state in buchi automaton */
761 automaton->current_state = current_pair->automaton_state;
764 XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d )", xbt_fifo_size(mc_stack_liveness), search_cycle);
765 XBT_DEBUG("Pair : graph=%p, automaton=%p(%s), %u interleave", current_pair->graph_state, current_pair->automaton_state, current_pair->automaton_state->id, MC_state_interleave_size(current_pair->graph_state));
767 mc_stats_pair->visited_pairs++;
772 mc_state_t next_graph_state = NULL;
773 smx_req_t req = NULL;
776 xbt_transition_t transition_succ;
777 unsigned int cursor = 0;
780 mc_pair_stateless_t next_pair = NULL;
781 mc_pair_stateless_t pair_succ;
783 if(xbt_fifo_size(mc_stack_liveness) < MAX_DEPTH_LIVENESS){
785 //set_pair_visited(current_pair->automaton_state, search_cycle);
786 set_pair_visited_hash(current_pair->automaton_state, search_cycle);
788 //XBT_DEBUG("Visited pairs : %lu", xbt_dynar_length(visited_pairs));
789 XBT_DEBUG("Visited pairs : %lu", xbt_dynar_length(visited_pairs_hash));
791 if(current_pair->requests > 0){
793 while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
795 /* Debug information */
796 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
797 req_str = MC_request_to_string(req, value);
798 XBT_DEBUG("Execute: %s", req_str);
802 MC_state_set_executed_request(current_pair->graph_state, req, value);
804 /* Answer the request */
805 SIMIX_request_pre(req, value);
807 /* Wait for requests (schedules processes) */
808 MC_wait_for_requests();
813 /* Create the new expanded graph_state */
814 next_graph_state = MC_state_pair_new();
816 /* Get enabled process and insert it in the interleave set of the next graph_state */
817 xbt_swag_foreach(process, simix_global->process_list){
818 if(MC_process_is_enabled(process)){
819 MC_state_interleave_process(next_graph_state, process);
823 xbt_dynar_reset(successors);
829 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
831 res = MC_automaton_evaluate_label(transition_succ->label);
833 if(res == 1){ // enabled transition in automaton
835 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
836 xbt_dynar_push(successors, &next_pair);
844 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
846 res = MC_automaton_evaluate_label(transition_succ->label);
848 if(res == 2){ // true transition in automaton
850 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
851 xbt_dynar_push(successors, &next_pair);
859 xbt_dynar_foreach(successors, cursor, pair_succ){
861 if(search_cycle == 1){
863 if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){
865 if(reached(pair_succ->automaton_state)){
866 //if(reached_hash(pair_succ->automaton_state)){
868 XBT_DEBUG("Next pair (depth = %d, %d interleave) already reached !", xbt_fifo_size(mc_stack_liveness) + 1, MC_state_interleave_size(pair_succ->graph_state));
870 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
871 XBT_INFO("| ACCEPTANCE CYCLE |");
872 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
873 XBT_INFO("Counter-example that violates formula :");
874 MC_show_stack_liveness(mc_stack_liveness);
875 MC_dump_stack_liveness(mc_stack_liveness);
876 MC_print_statistics_pairs(mc_stats_pair);
881 XBT_DEBUG("Next pair (depth =%d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
883 set_pair_reached(pair_succ->automaton_state);
884 //set_pair_reached_hash(pair_succ->automaton_state);
886 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
887 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
890 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
893 MC_ddfs(search_cycle);
899 if(!visited_hash(pair_succ->automaton_state, search_cycle)){
900 //if(!visited(pair_succ->automaton_state, search_cycle)){
903 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
906 MC_ddfs(search_cycle);
910 XBT_DEBUG("Next pair already visited ! ");
918 if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
920 XBT_DEBUG("Next pair (depth =%d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
922 set_pair_reached(pair_succ->automaton_state);
923 //set_pair_reached_hash(pair_succ->automaton_state);
927 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
928 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
932 if(!visited_hash(pair_succ->automaton_state, search_cycle)){
933 //if(!visited(pair_succ->automaton_state, search_cycle)){
936 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
939 MC_ddfs(search_cycle);
943 XBT_DEBUG("Next pair already visited ! ");
950 /* Restore system before checking others successors */
951 if(cursor != (xbt_dynar_length(successors) - 1))
952 MC_replay_liveness(mc_stack_liveness, 1);
957 if(MC_state_interleave_size(current_pair->graph_state) > 0){
958 XBT_DEBUG("Backtracking to depth %u", xbt_fifo_size(mc_stack_liveness));
959 MC_replay_liveness(mc_stack_liveness, 0);
964 }else{ /*No request to execute, search evolution in Büchi automaton */
968 /* Create the new expanded graph_state */
969 next_graph_state = MC_state_pair_new();
971 xbt_dynar_reset(successors);
977 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
979 res = MC_automaton_evaluate_label(transition_succ->label);
981 if(res == 1){ // enabled transition in automaton
983 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
984 xbt_dynar_push(successors, &next_pair);
992 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
994 res = MC_automaton_evaluate_label(transition_succ->label);
996 if(res == 2){ // true transition in automaton
998 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
999 xbt_dynar_push(successors, &next_pair);
1007 xbt_dynar_foreach(successors, cursor, pair_succ){
1009 if(search_cycle == 1){
1011 if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){
1013 if(reached(pair_succ->automaton_state)){
1014 //if(reached_hash(pair_succ->automaton_state)){
1016 XBT_DEBUG("Next pair (depth = %d) already reached !", xbt_fifo_size(mc_stack_liveness) + 1);
1018 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1019 XBT_INFO("| ACCEPTANCE CYCLE |");
1020 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1021 XBT_INFO("Counter-example that violates formula :");
1022 MC_show_stack_liveness(mc_stack_liveness);
1023 MC_dump_stack_liveness(mc_stack_liveness);
1024 MC_print_statistics_pairs(mc_stats_pair);
1029 XBT_DEBUG("Next pair (depth = %d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
1031 set_pair_reached(pair_succ->automaton_state);
1032 //set_pair_reached_hash(pair_succ->automaton_state);
1034 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1035 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1038 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1041 MC_ddfs(search_cycle);
1047 if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1048 //if(!visited(pair_succ->automaton_state, search_cycle)){
1051 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1054 MC_ddfs(search_cycle);
1058 XBT_DEBUG("Next pair already visited ! ");
1066 if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
1068 set_pair_reached(pair_succ->automaton_state);
1069 //set_pair_reached_hash(pair_succ->automaton_state);
1073 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1074 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1078 if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1079 //if(!visited(pair_succ->automaton_state, search_cycle)){
1082 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1085 MC_ddfs(search_cycle);
1089 XBT_DEBUG("Next pair already visited ! ");
1095 /* Restore system before checking others successors */
1096 if(cursor != xbt_dynar_length(successors) - 1)
1097 MC_replay_liveness(mc_stack_liveness, 1);
1106 XBT_DEBUG("Max depth reached");
1110 if(xbt_fifo_size(mc_stack_liveness) == MAX_DEPTH_LIVENESS ){
1111 XBT_DEBUG("Pair (graph=%p, automaton =%p, search_cycle = %u, depth = %d) shifted in stack, maximum depth reached", current_pair->graph_state, current_pair->automaton_state, search_cycle, xbt_fifo_size(mc_stack_liveness) );
1113 XBT_DEBUG("Pair (graph=%p, automaton =%p, search_cycle = %u, depth = %d) shifted in stack", current_pair->graph_state, current_pair->automaton_state, search_cycle, xbt_fifo_size(mc_stack_liveness) );
1118 xbt_fifo_shift(mc_stack_liveness);
1119 if((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2)){
1120 xbt_dynar_pop(reached_pairs, NULL);
1121 //xbt_dynar_pop(reached_pairs_hash, NULL);