Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
293334c096e48a794329a0c6ecb101b71b9547fb
[simgrid.git] / src / mc / mc_liveness.c
1 #include "private.h"
2 #include "unistd.h"
3
4 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
5                                 "Logging specific to algorithms for liveness properties verification");
6
7 xbt_fifo_t reached_pairs;
8 xbt_dynar_t visited_pairs;
9 xbt_dynar_t visited_pairs_hash;
10 xbt_dynar_t successors;
11
12 int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
13
14   
15   if(s1->num_reg != s2->num_reg){
16     //XBT_DEBUG("Different num_reg (s1 = %d, s2 = %d)", s1->num_reg, s2->num_reg);
17     return 1;
18   }
19
20   int i;
21
22   for(i=0 ; i< s1->num_reg ; i++){
23
24     if(s1->regions[i]->type != s2->regions[i]->type){
25       //XBT_DEBUG("Different type of region");
26       return 1;
27     }
28
29     switch(s1->regions[i]->type){
30     case 0:
31       if(s1->regions[i]->size != s2->regions[i]->size){
32         //XBT_DEBUG("Different size of heap (s1 = %Zu, s2 = %Zu)", s1->regions[i]->size, s2->regions[i]->size);
33         return 1;
34       }
35       if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
36         //XBT_DEBUG("Different start addr of heap (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
37         return 1;
38       }
39       if(mmalloc_compare_heap(s1->regions[i]->data, s2->regions[i]->data)){
40         //XBT_DEBUG("Different heap (mmalloc_compare)");
41         return 1; 
42       }
43       break;
44     case 1 :
45       if(s1->regions[i]->size != s2->regions[i]->size){
46         //XBT_DEBUG("Different size of libsimgrid (s1 = %Zu, s2 = %Zu)", s1->regions[i]->size, s2->regions[i]->size);
47         return 1;
48       }
49       if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
50         //XBT_DEBUG("Different start addr of libsimgrid (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
51         return 1;
52       }
53       if(memcmp(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
54         //XBT_DEBUG("Different memcmp for data in libsimgrid");
55         return 1;
56       }
57       break;
58     case 2:
59       if(s1->regions[i]->size != s2->regions[i]->size){
60         //XBT_DEBUG("Different size of program (s1 = %Zu, s2 = %Zu)", s1->regions[i]->size, s2->regions[i]->size);
61         return 1;
62       }
63       if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
64         //XBT_DEBUG("Different start addr of program (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
65         return 1;
66       }
67       if(memcmp(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
68         //XBT_DEBUG("Different memcmp for data in program");
69         return 1;
70       }
71       break;
72     case 3:
73       if(s1->regions[i]->size != s2->regions[i]->size){
74         //XBT_DEBUG("Different size of stack (s1 = %Zu, s2 = %Zu)", s1->regions[i]->size, s2->regions[i]->size);
75         return 1;
76       }
77       if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
78         //XBT_DEBUG("Different start addr of stack (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
79         return 1;
80       }
81       if(memcmp(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
82         //XBT_DEBUG("Different memcmp for data in stack");
83         return 1;
84       }
85       break;
86     }
87   }
88   
89 }
90
91 int reached(xbt_state_t st){
92
93
94   if(xbt_fifo_size(reached_pairs) == 0){
95
96     return 0;
97
98   }else{
99
100     MC_SET_RAW_MEM;
101
102     mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
103     MC_take_snapshot_liveness(sn);    
104     
105     xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
106     int res;
107     int (*f)();
108
109     /* Get values of propositional symbols */
110     unsigned int cursor = 0;
111     xbt_propositional_symbol_t ps = NULL;
112     xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
113       f = ps->function;
114       res = (*f)();
115       xbt_dynar_push_as(prop_ato, int, res);
116     }
117
118     int i=0;
119     xbt_fifo_item_t item = xbt_fifo_get_first_item(reached_pairs);
120     mc_pair_reached_t pair_test = NULL;
121
122
123     while(i < xbt_fifo_size(reached_pairs) && item != NULL){
124
125       pair_test = (mc_pair_reached_t) xbt_fifo_get_item_content(item);
126       
127       if(pair_test != NULL){
128         if(automaton_state_compare(pair_test->automaton_state, st) == 0){
129           if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
130             if(snapshot_compare(sn, pair_test->system_state) == 0){
131
132               MC_free_snapshot(sn);
133               xbt_dynar_reset(prop_ato);
134               xbt_free(prop_ato);
135               MC_UNSET_RAW_MEM;
136               return 1;
137             }
138           }
139         }
140       }
141
142       item = xbt_fifo_get_next_item(item);
143       
144       i++;
145
146     }
147
148     MC_free_snapshot(sn);
149     xbt_dynar_reset(prop_ato);
150     xbt_free(prop_ato);
151     MC_UNSET_RAW_MEM;
152     return 0;
153     
154   }
155 }
156
157 void set_pair_reached(xbt_state_t st){
158
159  
160   MC_SET_RAW_MEM;
161   
162   mc_pair_reached_t pair = NULL;
163   pair = xbt_new0(s_mc_pair_reached_t, 1);
164   pair->automaton_state = st;
165   pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
166   pair->system_state = xbt_new0(s_mc_snapshot_t, 1);
167   MC_take_snapshot_liveness(pair->system_state);
168
169   /* Get values of propositional symbols */
170   unsigned int cursor = 0;
171   xbt_propositional_symbol_t ps = NULL;
172   int res;
173   int (*f)(); 
174
175   xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
176     f = ps->function;
177     res = (*f)();
178     xbt_dynar_push_as(pair->prop_ato, int, res);
179   }
180   
181   xbt_fifo_unshift(reached_pairs, pair); 
182
183   MC_UNSET_RAW_MEM;
184   
185 }
186
187 int visited(xbt_state_t st, int sc){
188
189
190   if(xbt_dynar_is_empty(visited_pairs)){
191
192     return 0;
193
194   }else{
195
196     MC_SET_RAW_MEM;
197
198     mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
199     MC_take_snapshot_liveness(sn);
200
201     xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
202
203     /* Get values of propositional symbols */
204     unsigned int cursor = 0;
205     xbt_propositional_symbol_t ps = NULL;
206     int res;
207     int (*f)();
208
209     xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
210       f = ps->function;
211       res = (*f)();
212       xbt_dynar_push_as(prop_ato, int, res);
213     }
214
215     cursor = 0;
216     mc_pair_visited_t pair_test = NULL;
217
218     xbt_dynar_foreach(visited_pairs_hash, cursor, pair_test){
219       if(pair_test->search_cycle == sc) {
220         if(automaton_state_compare(pair_test->automaton_state, st) == 0){
221           if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
222             if(snapshot_compare(pair_test->system_state, sn) == 0){
223             
224               MC_free_snapshot(sn);
225               xbt_dynar_reset(prop_ato);
226               xbt_free(prop_ato);
227               MC_UNSET_RAW_MEM;
228                 
229               return 1;
230                   
231                 
232             }
233           }
234         }
235       }
236    
237     }
238
239
240     MC_free_snapshot(sn);
241     xbt_dynar_reset(prop_ato);
242     xbt_free(prop_ato);
243     MC_UNSET_RAW_MEM;
244     return 0;
245     
246   }
247 }
248
249
250 int visited_hash(xbt_state_t st, int sc){
251
252
253   if(xbt_dynar_is_empty(visited_pairs_hash)){
254
255     return 0;
256
257   }else{
258
259     MC_SET_RAW_MEM;
260
261     mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
262     MC_take_snapshot_liveness(sn);
263    
264     int i, j;
265     
266     xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
267
268     /* Get values of propositional symbols */
269     unsigned int cursor = 0;
270     xbt_propositional_symbol_t ps = NULL;
271     int res;
272     int (*f)();
273
274     xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
275       f = ps->function;
276       res = (*f)();
277       xbt_dynar_push_as(prop_ato, int, res);
278     }
279
280     mc_pair_visited_hash_t pair_test = NULL;
281
282     int region_diff = 0;
283     cursor = 0;
284
285     xbt_dynar_foreach(visited_pairs_hash, cursor, pair_test){
286       if(pair_test->search_cycle == sc) {
287         if(automaton_state_compare(pair_test->automaton_state, st) == 0){
288           if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
289             for(j=0 ; j< sn->num_reg ; j++){
290               if(xbt_dict_get_or_null_ext(pair_test->hash_regions, sn->regions[j]->data, sn->regions[j]->size) == NULL){
291                 region_diff++;
292               }
293             }
294             if(region_diff == 0){
295               MC_free_snapshot(sn);
296               xbt_dynar_reset(prop_ato);
297               xbt_free(prop_ato);
298               MC_UNSET_RAW_MEM;
299               return 1;
300             }
301           }
302         }
303       }
304       region_diff = 0;
305     }
306     
307     MC_free_snapshot(sn);
308     xbt_dynar_reset(prop_ato);
309     xbt_free(prop_ato);
310     MC_UNSET_RAW_MEM;
311     return 0;
312     
313   }
314 }
315
316 void set_pair_visited_hash(xbt_state_t st, int sc){
317
318   //if(!visited_hash(st, sc)){
319  
320     MC_SET_RAW_MEM;
321
322     mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
323     MC_take_snapshot_liveness(sn);
324  
325     mc_pair_visited_hash_t pair = NULL;
326     pair = xbt_new0(s_mc_pair_visited_hash_t, 1);
327     pair->automaton_state = st;
328     pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
329     pair->search_cycle = sc;
330     pair->hash_regions = xbt_dict_new();
331   
332     int i = 0;
333
334     for(i=0 ; i< sn->num_reg ; i++){
335       switch(sn->regions[i]->type){
336       case 0:
337         xbt_dict_set_ext(pair->hash_regions, sn->regions[i]->data, sn->regions[i]->size, "heap", NULL);
338         break;
339       case 1:
340         xbt_dict_set_ext(pair->hash_regions, sn->regions[i]->data, sn->regions[i]->size, "libsimgrid", NULL);
341         break;
342       case 2:
343         xbt_dict_set_ext(pair->hash_regions, sn->regions[i]->data, sn->regions[i]->size, "prog", NULL);
344         break;
345       }
346     }
347   
348     /* Get values of propositional symbols */
349     unsigned int cursor = 0;
350     xbt_propositional_symbol_t ps = NULL;
351     int res;
352     int (*f)();
353
354     xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
355       f = ps->function;
356       res = (*f)();
357       xbt_dynar_push_as(pair->prop_ato, int, res);
358     }
359   
360     xbt_dynar_push(visited_pairs_hash, &pair);
361
362     MC_free_snapshot(sn);
363   
364     MC_UNSET_RAW_MEM;
365   
366     //}
367   
368   
369 }
370
371 void set_pair_visited(xbt_state_t st, int sc){
372
373  
374   MC_SET_RAW_MEM;
375  
376   mc_pair_visited_t pair = NULL;
377   pair = xbt_new0(s_mc_pair_visited_t, 1);
378   pair->automaton_state = st;
379   pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
380   pair->search_cycle = sc;
381   pair->system_state = xbt_new0(s_mc_snapshot_t, 1);
382   MC_take_snapshot_liveness(pair->system_state);
383
384
385   /* Get values of propositional symbols */
386   unsigned int cursor = 0;
387   xbt_propositional_symbol_t ps = NULL;
388   int res;
389   int (*f)();
390
391   xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
392     f = ps->function;
393     res = (*f)();
394     xbt_dynar_push_as(pair->prop_ato, int, res);
395   }
396   
397   xbt_dynar_push(visited_pairs_hash, &pair);
398   
399   MC_UNSET_RAW_MEM;
400   
401   
402 }
403
404 void MC_pair_delete(mc_pair_t pair){
405   xbt_free(pair->graph_state->proc_status);
406   xbt_free(pair->graph_state);
407   xbt_free(pair);
408 }
409
410
411
412 int MC_automaton_evaluate_label(xbt_exp_label_t l){
413   
414   switch(l->type){
415   case 0 : {
416     int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
417     int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
418     return (left_res || right_res);
419     break;
420   }
421   case 1 : {
422     int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
423     int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
424     return (left_res && right_res);
425     break;
426   }
427   case 2 : {
428     int res = MC_automaton_evaluate_label(l->u.exp_not);
429     return (!res);
430     break;
431   }
432   case 3 : { 
433     unsigned int cursor = 0;
434     xbt_propositional_symbol_t p = NULL;
435     int (*f)();
436     xbt_dynar_foreach(automaton->propositional_symbols, cursor, p){
437       if(strcmp(p->pred, l->u.predicat) == 0){
438         f = p->function;
439         return (*f)();
440       }
441     }
442     return -1;
443     break;
444   }
445   case 4 : {
446     return 2;
447     break;
448   }
449   default : 
450     return -1;
451   }
452 }
453
454
455
456
457
458 /********************* Double-DFS stateless *******************/
459
460 void MC_pair_stateless_delete(mc_pair_stateless_t pair){
461   xbt_free(pair->graph_state->proc_status);
462   xbt_free(pair->graph_state);
463   xbt_free(pair);
464 }
465
466 mc_pair_stateless_t new_pair_stateless(mc_state_t sg, xbt_state_t st, int r){
467   mc_pair_stateless_t p = NULL;
468   p = xbt_new0(s_mc_pair_stateless_t, 1);
469   p->automaton_state = st;
470   p->graph_state = sg;
471   p->requests = r;
472   mc_stats_pair->expanded_pairs++;
473   return p;
474 }
475
476 void MC_ddfs_stateless_init(){
477
478   XBT_DEBUG("**************************************************");
479   XBT_DEBUG("Double-DFS stateless init");
480   XBT_DEBUG("**************************************************");
481
482   mc_pair_stateless_t mc_initial_pair = NULL;
483   mc_state_t initial_graph_state = NULL;
484   smx_process_t process; 
485  
486   MC_wait_for_requests();
487
488   MC_SET_RAW_MEM;
489
490   initial_graph_state = MC_state_pair_new();
491   xbt_swag_foreach(process, simix_global->process_list){
492     if(MC_process_is_enabled(process)){
493       MC_state_interleave_process(initial_graph_state, process);
494     }
495   }
496
497   reached_pairs = xbt_fifo_new(); 
498   //visited_pairs = xbt_dynar_new(sizeof(mc_pair_visited_t), NULL);
499   visited_pairs_hash = xbt_dynar_new(sizeof(mc_pair_visited_hash_t), NULL);
500   successors = xbt_dynar_new(sizeof(mc_pair_stateless_t), NULL);
501
502   /* Save the initial state */
503   initial_snapshot_liveness = xbt_new0(s_mc_snapshot_t, 1);
504   MC_take_snapshot_to_restore_liveness(initial_snapshot_liveness);
505
506   MC_UNSET_RAW_MEM; 
507
508   unsigned int cursor = 0;
509   xbt_state_t state;
510
511   xbt_dynar_foreach(automaton->states, cursor, state){
512     if(state->type == -1){
513       
514       MC_SET_RAW_MEM;
515       mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
516       xbt_fifo_unshift(mc_stack_liveness_stateless, mc_initial_pair);
517       MC_UNSET_RAW_MEM;
518       
519       if(cursor != 0){
520         MC_restore_snapshot(initial_snapshot_liveness);
521         MC_UNSET_RAW_MEM;
522       }
523
524       MC_ddfs_stateless(0);
525
526     }else{
527       if(state->type == 2){
528       
529         MC_SET_RAW_MEM;
530         mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
531         xbt_fifo_unshift(mc_stack_liveness_stateless, mc_initial_pair);
532         MC_UNSET_RAW_MEM;
533
534         set_pair_reached(state);
535         
536         if(cursor != 0){
537           MC_restore_snapshot(initial_snapshot_liveness);
538           MC_UNSET_RAW_MEM;
539         }
540         
541         MC_ddfs_stateless(1);
542         
543       }
544     }
545   } 
546
547 }
548
549
550 void MC_ddfs_stateless(int search_cycle){
551
552   smx_process_t process;
553   mc_pair_stateless_t current_pair = NULL;
554
555   if(xbt_fifo_size(mc_stack_liveness_stateless) == 0)
556     return;
557
558
559   /* Get current pair */
560   current_pair = (mc_pair_stateless_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness_stateless));
561
562   /* Update current state in buchi automaton */
563   automaton->current_state = current_pair->automaton_state;
564
565  
566   XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d )", xbt_fifo_size(mc_stack_liveness_stateless), search_cycle);
567   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));
568  
569   mc_stats_pair->visited_pairs++;
570
571   //sleep(1);
572
573   int value;
574   mc_state_t next_graph_state = NULL;
575   smx_req_t req = NULL;
576   char *req_str;
577
578   xbt_transition_t transition_succ;
579   unsigned int cursor = 0;
580   int res;
581
582   mc_pair_stateless_t next_pair = NULL;
583   mc_pair_stateless_t pair_succ;
584
585   if(xbt_fifo_size(mc_stack_liveness_stateless) < MAX_DEPTH_LIVENESS){
586
587     //set_pair_visited(current_pair->automaton_state, search_cycle);
588     set_pair_visited_hash(current_pair->automaton_state, search_cycle);
589
590     //XBT_DEBUG("Visited pairs : %d", xbt_fifo_size(visited_pairs));
591     XBT_DEBUG("Visited pairs : %lu", xbt_dynar_length(visited_pairs_hash));
592
593     if(current_pair->requests > 0){
594
595       while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
596    
597         /* Debug information */
598         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
599           req_str = MC_request_to_string(req, value);
600           XBT_DEBUG("Execute: %s", req_str);
601           xbt_free(req_str);
602         }
603
604         MC_state_set_executed_request(current_pair->graph_state, req, value);   
605     
606         /* Answer the request */
607         SIMIX_request_pre(req, value);
608
609         /* Wait for requests (schedules processes) */
610         MC_wait_for_requests();
611
612
613         MC_SET_RAW_MEM;
614
615         /* Create the new expanded graph_state */
616         next_graph_state = MC_state_pair_new();
617
618         /* Get enabled process and insert it in the interleave set of the next graph_state */
619         xbt_swag_foreach(process, simix_global->process_list){
620           if(MC_process_is_enabled(process)){
621             MC_state_interleave_process(next_graph_state, process);
622           }
623         }
624
625         xbt_dynar_reset(successors);
626
627         MC_UNSET_RAW_MEM;
628
629
630         cursor= 0;
631         xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
632
633           res = MC_automaton_evaluate_label(transition_succ->label);
634
635           if(res == 1){ // enabled transition in automaton
636             MC_SET_RAW_MEM;
637             next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
638             xbt_dynar_push(successors, &next_pair);
639             MC_UNSET_RAW_MEM;
640           }
641
642         }
643
644         cursor = 0;
645    
646         xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
647       
648           res = MC_automaton_evaluate_label(transition_succ->label);
649         
650           if(res == 2){ // true transition in automaton
651             MC_SET_RAW_MEM;
652             next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
653             xbt_dynar_push(successors, &next_pair);
654             MC_UNSET_RAW_MEM;
655           }
656
657         }
658
659         cursor = 0; 
660         
661         xbt_dynar_foreach(successors, cursor, pair_succ){
662
663           //if(!visited(pair_succ->automaton_state, search_cycle)){
664           if(!visited_hash(pair_succ->automaton_state, search_cycle)){
665
666             if(search_cycle == 1){
667
668               if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){ 
669                       
670                 if(reached(pair_succ->automaton_state) == 1){
671
672                   XBT_DEBUG("Next pair (depth = %d, %d interleave) already reached !", xbt_fifo_size(mc_stack_liveness_stateless) + 1, MC_state_interleave_size(pair_succ->graph_state));
673
674                   XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
675                   XBT_INFO("|             ACCEPTANCE CYCLE            |");
676                   XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
677                   XBT_INFO("Counter-example that violates formula :");
678                   MC_show_stack_liveness_stateless(mc_stack_liveness_stateless);
679                   MC_dump_stack_liveness_stateless(mc_stack_liveness_stateless);
680                   MC_print_statistics_pairs(mc_stats_pair);
681                   exit(0);
682
683                 }else{
684
685                   XBT_DEBUG("Next pair (depth =%d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness_stateless) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
686               
687                   set_pair_reached(pair_succ->automaton_state); 
688
689                   XBT_DEBUG("Reached pairs : %d", xbt_fifo_size(reached_pairs));
690
691                 }
692
693               }
694
695             }else{
696           
697               if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
698
699                 XBT_DEBUG("Next pair (depth =%d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness_stateless) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
700             
701                 set_pair_reached(pair_succ->automaton_state); 
702               
703                 search_cycle = 1;
704
705                 XBT_DEBUG("Reached pairs : %d", xbt_fifo_size(reached_pairs));
706
707               }
708
709             }
710
711             MC_SET_RAW_MEM;
712             xbt_fifo_unshift(mc_stack_liveness_stateless, pair_succ);
713             MC_UNSET_RAW_MEM;
714
715             MC_ddfs_stateless(search_cycle);
716
717             /* Restore system before checking others successors */
718             if(cursor != (xbt_dynar_length(successors) - 1))
719               MC_replay_liveness(mc_stack_liveness_stateless, 1);
720         
721         }else{
722             
723             XBT_DEBUG("Next pair already visited");
724
725             if(search_cycle == 1){
726
727               if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){ 
728                       
729                 if(reached(pair_succ->automaton_state) == 1){
730
731                   XBT_DEBUG("Next pair (depth = %d, %d interleave) already reached !", xbt_fifo_size(mc_stack_liveness_stateless) + 1, MC_state_interleave_size(pair_succ->graph_state));
732
733                   XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
734                   XBT_INFO("|             ACCEPTANCE CYCLE            |");
735                   XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
736                   XBT_INFO("Counter-example that violates formula :");
737                   MC_show_stack_liveness_stateless(mc_stack_liveness_stateless);
738                   MC_dump_stack_liveness_stateless(mc_stack_liveness_stateless);
739                   MC_print_statistics_pairs(mc_stats_pair);
740                   exit(0);
741
742                 }
743
744               }
745             }
746             
747         }
748           }
749
750         if(MC_state_interleave_size(current_pair->graph_state) > 0){
751           XBT_DEBUG("Backtracking to depth %u", xbt_fifo_size(mc_stack_liveness_stateless));
752           MC_replay_liveness(mc_stack_liveness_stateless, 0);
753         }
754       }
755
756  
757     }else{  /*No request to execute, search evolution in Büchi automaton */
758
759       MC_SET_RAW_MEM;
760
761       /* Create the new expanded graph_state */
762       next_graph_state = MC_state_pair_new();
763
764       xbt_dynar_reset(successors);
765
766       MC_UNSET_RAW_MEM;
767
768
769       cursor= 0;
770       xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
771
772         res = MC_automaton_evaluate_label(transition_succ->label);
773
774         if(res == 1){ // enabled transition in automaton
775           MC_SET_RAW_MEM;
776           next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
777           xbt_dynar_push(successors, &next_pair);
778           MC_UNSET_RAW_MEM;
779         }
780
781       }
782
783       cursor = 0;
784    
785       xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
786       
787         res = MC_automaton_evaluate_label(transition_succ->label);
788         
789         if(res == 2){ // true transition in automaton
790           MC_SET_RAW_MEM;
791           next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
792           xbt_dynar_push(successors, &next_pair);
793           MC_UNSET_RAW_MEM;
794         }
795
796       }
797
798       cursor = 0; 
799      
800       xbt_dynar_foreach(successors, cursor, pair_succ){
801
802         //if(!visited(pair_succ->automaton_state, search_cycle)){
803         if(!visited_hash(pair_succ->automaton_state, search_cycle)){
804
805           if(search_cycle == 1){
806
807             if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){ 
808
809               if(reached(pair_succ->automaton_state) == 1){
810
811                 XBT_DEBUG("Next pair (depth = %d) already reached !", xbt_fifo_size(mc_stack_liveness_stateless) + 1);
812
813                 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
814                 XBT_INFO("|             ACCEPTANCE CYCLE            |");
815                 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
816                 XBT_INFO("Counter-example that violates formula :");
817                 MC_show_stack_liveness_stateless(mc_stack_liveness_stateless);
818                 MC_dump_stack_liveness_stateless(mc_stack_liveness_stateless);
819                 MC_print_statistics_pairs(mc_stats_pair);
820                 exit(0);
821
822               }else{
823
824                 XBT_DEBUG("Next pair (depth =%d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness_stateless) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
825               
826                 set_pair_reached(pair_succ->automaton_state); 
827                 
828                 XBT_DEBUG("Reached pairs : %d", xbt_fifo_size(reached_pairs));
829
830               }
831
832             }
833
834           }else{
835           
836             if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
837
838               set_pair_reached(pair_succ->automaton_state); 
839                     
840               search_cycle = 1;
841
842               XBT_DEBUG("Reached pairs : %d", xbt_fifo_size(reached_pairs));
843
844             }
845
846           }
847
848           MC_SET_RAW_MEM;
849           xbt_fifo_unshift(mc_stack_liveness_stateless, pair_succ);
850           MC_UNSET_RAW_MEM;
851
852           MC_ddfs_stateless(search_cycle);
853
854           /* Restore system before checking others successors */
855           if(cursor != xbt_dynar_length(successors) - 1)
856             MC_replay_liveness(mc_stack_liveness_stateless, 1);
857
858           }else{
859             
860           XBT_DEBUG("Next pair already visited");
861
862           if(search_cycle == 1){
863
864             if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){ 
865               
866               if(reached(pair_succ->automaton_state) == 1){
867                 
868                 XBT_DEBUG("Next pair (depth = %d, %d interleave) already reached !", xbt_fifo_size(mc_stack_liveness_stateless) + 1, MC_state_interleave_size(pair_succ->graph_state));
869                 
870                 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
871                 XBT_INFO("|             ACCEPTANCE CYCLE            |");
872                 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
873                 XBT_INFO("Counter-example that violates formula :");
874                 MC_show_stack_liveness_stateless(mc_stack_liveness_stateless);
875                 MC_dump_stack_liveness_stateless(mc_stack_liveness_stateless);
876                 MC_print_statistics_pairs(mc_stats_pair);
877                 exit(0);
878                   
879               }
880                 
881             }
882               
883           }
884         }
885           
886       }
887            
888     }
889     
890   }else{
891     
892     XBT_DEBUG("Max depth reached");
893
894   }
895
896   if(xbt_fifo_size(mc_stack_liveness_stateless) == MAX_DEPTH_LIVENESS ){
897     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_stateless) );
898   }else{
899     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_stateless) );
900   }
901
902   
903   MC_SET_RAW_MEM;
904   xbt_fifo_shift(mc_stack_liveness_stateless);
905   if((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2)){
906     xbt_fifo_shift(reached_pairs);
907   }
908   MC_UNSET_RAW_MEM;
909   
910   
911
912 }
913