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){
653 /********************* Double-DFS stateless *******************/
655 void MC_pair_stateless_delete(mc_pair_stateless_t pair){
656 xbt_free(pair->graph_state->proc_status);
657 xbt_free(pair->graph_state);
661 mc_pair_stateless_t new_pair_stateless(mc_state_t sg, xbt_state_t st, int r){
662 mc_pair_stateless_t p = NULL;
663 p = xbt_new0(s_mc_pair_stateless_t, 1);
664 p->automaton_state = st;
667 mc_stats_pair->expanded_pairs++;
671 void MC_ddfs_init(void){
673 XBT_DEBUG("**************************************************");
674 XBT_DEBUG("Double-DFS init");
675 XBT_DEBUG("**************************************************");
677 mc_pair_stateless_t mc_initial_pair = NULL;
678 mc_state_t initial_graph_state = NULL;
679 smx_process_t process;
681 MC_wait_for_requests();
685 initial_graph_state = MC_state_pair_new();
686 xbt_swag_foreach(process, simix_global->process_list){
687 if(MC_process_is_enabled(process)){
688 MC_state_interleave_process(initial_graph_state, process);
692 reached_pairs = xbt_dynar_new(sizeof(mc_pair_reached_t), NULL);
693 //reached_pairs_hash = xbt_dynar_new(sizeof(mc_pair_reached_hash_t), NULL);
694 //visited_pairs = xbt_dynar_new(sizeof(mc_pair_visited_t), NULL);
695 visited_pairs_hash = xbt_dynar_new(sizeof(mc_pair_visited_hash_t), NULL);
696 successors = xbt_dynar_new(sizeof(mc_pair_stateless_t), NULL);
698 /* Save the initial state */
699 initial_snapshot_liveness = xbt_new0(s_mc_snapshot_t, 1);
700 MC_take_snapshot_to_restore_liveness(initial_snapshot_liveness);
704 unsigned int cursor = 0;
707 xbt_dynar_foreach(automaton->states, cursor, state){
708 if(state->type == -1){
711 mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
712 xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
716 MC_restore_snapshot(initial_snapshot_liveness);
723 if(state->type == 2){
726 mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
727 xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
730 set_pair_reached(state);
731 //set_pair_reached_hash(state);
734 MC_restore_snapshot(initial_snapshot_liveness);
747 void MC_ddfs(int search_cycle){
749 smx_process_t process;
750 mc_pair_stateless_t current_pair = NULL;
752 if(xbt_fifo_size(mc_stack_liveness) == 0)
756 /* Get current pair */
757 current_pair = (mc_pair_stateless_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness));
759 /* Update current state in buchi automaton */
760 automaton->current_state = current_pair->automaton_state;
763 XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d )", xbt_fifo_size(mc_stack_liveness), search_cycle);
764 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));
766 mc_stats_pair->visited_pairs++;
771 mc_state_t next_graph_state = NULL;
772 smx_req_t req = NULL;
775 xbt_transition_t transition_succ;
776 unsigned int cursor = 0;
779 mc_pair_stateless_t next_pair = NULL;
780 mc_pair_stateless_t pair_succ;
782 if(xbt_fifo_size(mc_stack_liveness) < MAX_DEPTH_LIVENESS){
784 //set_pair_visited(current_pair->automaton_state, search_cycle);
785 set_pair_visited_hash(current_pair->automaton_state, search_cycle);
787 //XBT_DEBUG("Visited pairs : %lu", xbt_dynar_length(visited_pairs));
788 XBT_DEBUG("Visited pairs : %lu", xbt_dynar_length(visited_pairs_hash));
790 if(current_pair->requests > 0){
792 while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
794 /* Debug information */
795 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
796 req_str = MC_request_to_string(req, value);
797 XBT_DEBUG("Execute: %s", req_str);
801 MC_state_set_executed_request(current_pair->graph_state, req, value);
803 /* Answer the request */
804 SIMIX_request_pre(req, value);
806 /* Wait for requests (schedules processes) */
807 MC_wait_for_requests();
812 /* Create the new expanded graph_state */
813 next_graph_state = MC_state_pair_new();
815 /* Get enabled process and insert it in the interleave set of the next graph_state */
816 xbt_swag_foreach(process, simix_global->process_list){
817 if(MC_process_is_enabled(process)){
818 MC_state_interleave_process(next_graph_state, process);
822 xbt_dynar_reset(successors);
828 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
830 res = MC_automaton_evaluate_label(transition_succ->label);
832 if(res == 1){ // enabled transition in automaton
834 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
835 xbt_dynar_push(successors, &next_pair);
843 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
845 res = MC_automaton_evaluate_label(transition_succ->label);
847 if(res == 2){ // true transition in automaton
849 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
850 xbt_dynar_push(successors, &next_pair);
858 xbt_dynar_foreach(successors, cursor, pair_succ){
860 if(search_cycle == 1){
862 if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){
864 if(reached(pair_succ->automaton_state)){
865 //if(reached_hash(pair_succ->automaton_state)){
867 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));
869 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
870 XBT_INFO("| ACCEPTANCE CYCLE |");
871 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
872 XBT_INFO("Counter-example that violates formula :");
873 MC_show_stack_liveness(mc_stack_liveness);
874 MC_dump_stack_liveness(mc_stack_liveness);
875 MC_print_statistics_pairs(mc_stats_pair);
880 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);
882 set_pair_reached(pair_succ->automaton_state);
883 //set_pair_reached_hash(pair_succ->automaton_state);
885 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
886 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
889 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
892 MC_ddfs(search_cycle);
898 if(!visited_hash(pair_succ->automaton_state, search_cycle)){
899 //if(!visited(pair_succ->automaton_state, search_cycle)){
902 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
905 MC_ddfs(search_cycle);
909 XBT_DEBUG("Next pair already visited ! ");
917 if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
919 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);
921 set_pair_reached(pair_succ->automaton_state);
922 //set_pair_reached_hash(pair_succ->automaton_state);
926 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
927 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
931 if(!visited_hash(pair_succ->automaton_state, search_cycle)){
932 //if(!visited(pair_succ->automaton_state, search_cycle)){
935 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
938 MC_ddfs(search_cycle);
942 XBT_DEBUG("Next pair already visited ! ");
949 /* Restore system before checking others successors */
950 if(cursor != (xbt_dynar_length(successors) - 1))
951 MC_replay_liveness(mc_stack_liveness, 1);
956 if(MC_state_interleave_size(current_pair->graph_state) > 0){
957 XBT_DEBUG("Backtracking to depth %u", xbt_fifo_size(mc_stack_liveness));
958 MC_replay_liveness(mc_stack_liveness, 0);
963 }else{ /*No request to execute, search evolution in Büchi automaton */
967 /* Create the new expanded graph_state */
968 next_graph_state = MC_state_pair_new();
970 xbt_dynar_reset(successors);
976 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
978 res = MC_automaton_evaluate_label(transition_succ->label);
980 if(res == 1){ // enabled transition in automaton
982 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
983 xbt_dynar_push(successors, &next_pair);
991 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
993 res = MC_automaton_evaluate_label(transition_succ->label);
995 if(res == 2){ // true transition in automaton
997 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
998 xbt_dynar_push(successors, &next_pair);
1006 xbt_dynar_foreach(successors, cursor, pair_succ){
1008 if(search_cycle == 1){
1010 if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){
1012 if(reached(pair_succ->automaton_state)){
1013 //if(reached_hash(pair_succ->automaton_state)){
1015 XBT_DEBUG("Next pair (depth = %d) already reached !", xbt_fifo_size(mc_stack_liveness) + 1);
1017 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1018 XBT_INFO("| ACCEPTANCE CYCLE |");
1019 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1020 XBT_INFO("Counter-example that violates formula :");
1021 MC_show_stack_liveness(mc_stack_liveness);
1022 MC_dump_stack_liveness(mc_stack_liveness);
1023 MC_print_statistics_pairs(mc_stats_pair);
1028 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);
1030 set_pair_reached(pair_succ->automaton_state);
1031 //set_pair_reached_hash(pair_succ->automaton_state);
1033 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1034 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1037 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1040 MC_ddfs(search_cycle);
1046 if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1047 //if(!visited(pair_succ->automaton_state, search_cycle)){
1050 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1053 MC_ddfs(search_cycle);
1057 XBT_DEBUG("Next pair already visited ! ");
1065 if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
1067 set_pair_reached(pair_succ->automaton_state);
1068 //set_pair_reached_hash(pair_succ->automaton_state);
1072 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1073 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1077 if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1078 //if(!visited(pair_succ->automaton_state, search_cycle)){
1081 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1084 MC_ddfs(search_cycle);
1088 XBT_DEBUG("Next pair already visited ! ");
1094 /* Restore system before checking others successors */
1095 if(cursor != xbt_dynar_length(successors) - 1)
1096 MC_replay_liveness(mc_stack_liveness, 1);
1105 XBT_DEBUG("Max depth reached");
1109 if(xbt_fifo_size(mc_stack_liveness) == MAX_DEPTH_LIVENESS ){
1110 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) );
1112 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) );
1117 xbt_fifo_shift(mc_stack_liveness);
1118 if((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2)){
1119 xbt_dynar_pop(reached_pairs, NULL);
1120 //xbt_dynar_pop(reached_pairs_hash, NULL);