Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : hash of regions in snapshot stored instead of all the data
[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_fifo_t visited_pairs;
9 xbt_fifo_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_fifo_size(visited_pairs) == 0){
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     int i=0;
216     xbt_fifo_item_t item = xbt_fifo_get_first_item(visited_pairs);
217     mc_pair_visited_t pair_test = NULL;
218
219     while(i < xbt_fifo_size(visited_pairs) && item != NULL){
220
221       pair_test = (mc_pair_visited_t) xbt_fifo_get_item_content(item);
222       
223       if(pair_test != NULL){
224         if(pair_test->search_cycle == sc) {
225           if(automaton_state_compare(pair_test->automaton_state, st) == 0){
226             if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
227               if(snapshot_compare(pair_test->system_state, sn) == 0){
228             
229                 MC_free_snapshot(sn);
230                 xbt_dynar_reset(prop_ato);
231                 xbt_free(prop_ato);
232                 MC_UNSET_RAW_MEM;
233                 
234                 return 1;
235                   
236                 
237               }
238             }
239           }
240         }
241       }
242
243       item = xbt_fifo_get_next_item(item);
244       
245       i++;
246
247     }
248
249
250     MC_free_snapshot(sn);
251     xbt_dynar_reset(prop_ato);
252     xbt_free(prop_ato);
253     MC_UNSET_RAW_MEM;
254     return 0;
255     
256   }
257 }
258
259
260 int visited_hash(xbt_state_t st, int sc){
261
262
263   if(xbt_fifo_size(visited_pairs_hash) == 0){
264
265     return 0;
266
267   }else{
268
269     MC_SET_RAW_MEM;
270
271     mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
272     MC_take_snapshot_liveness(sn);
273    
274     int i, j;
275     
276     xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
277
278     /* Get values of propositional symbols */
279     unsigned int cursor = 0;
280     xbt_propositional_symbol_t ps = NULL;
281     int res;
282     int (*f)();
283
284     xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
285       f = ps->function;
286       res = (*f)();
287       xbt_dynar_push_as(prop_ato, int, res);
288     }
289
290     xbt_fifo_item_t item = xbt_fifo_get_first_item(visited_pairs_hash);
291     mc_pair_visited_hash_t pair_test = NULL;
292
293     while(i < xbt_fifo_size(visited_pairs_hash) && item != NULL){
294
295       pair_test = (mc_pair_visited_hash_t) xbt_fifo_get_item_content(item);
296       
297       if(pair_test != NULL){
298         if(pair_test->search_cycle == sc) {
299           if(automaton_state_compare(pair_test->automaton_state, st) == 0){
300             if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
301               for(j=0 ; j< sn->num_reg ; j++){
302                 if(xbt_dict_get_or_null_ext(pair_test->hash_regions, sn->regions[j]->data, sn->regions[j]->size) == NULL){
303                   return 0;
304                 }
305               }
306               MC_free_snapshot(sn);
307               xbt_dynar_reset(prop_ato);
308               xbt_free(prop_ato);
309               MC_UNSET_RAW_MEM;
310               return 1;
311             }
312           }
313         }
314       }
315
316       item = xbt_fifo_get_next_item(item);
317       
318       i++;
319
320     }
321
322
323     MC_free_snapshot(sn);
324     xbt_dynar_reset(prop_ato);
325     xbt_free(prop_ato);
326     MC_UNSET_RAW_MEM;
327     return 0;
328     
329   }
330 }
331
332 void set_pair_visited_hash(xbt_state_t st, int sc){
333
334  
335   MC_SET_RAW_MEM;
336
337   mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
338   MC_take_snapshot_liveness(sn);
339  
340   mc_pair_visited_hash_t pair = NULL;
341   pair = xbt_new0(s_mc_pair_visited_hash_t, 1);
342   pair->automaton_state = st;
343   pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
344   pair->search_cycle = sc;
345   pair->hash_regions = xbt_dict_new();
346   
347   int i = 0;
348
349   for(i=0 ; i< sn->num_reg ; i++){
350     switch(sn->regions[i]->type){
351     case 0:
352       xbt_dict_set_ext(pair->hash_regions, sn->regions[i]->data, sn->regions[i]->size, "heap", NULL);
353       break;
354     case 1:
355       xbt_dict_set_ext(pair->hash_regions, sn->regions[i]->data, sn->regions[i]->size, "libsimgrid", NULL);
356       break;
357     case 2:
358       xbt_dict_set_ext(pair->hash_regions, sn->regions[i]->data, sn->regions[i]->size, "prog", NULL);
359       break;
360     }
361   }
362   
363   /* Get values of propositional symbols */
364   unsigned int cursor = 0;
365   xbt_propositional_symbol_t ps = NULL;
366   int res;
367   int (*f)();
368
369   xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
370     f = ps->function;
371     res = (*f)();
372     xbt_dynar_push_as(pair->prop_ato, int, res);
373   }
374   
375   xbt_fifo_unshift(visited_pairs_hash, pair);
376
377   MC_free_snapshot(sn);
378   
379   MC_UNSET_RAW_MEM;
380   
381   
382 }
383
384 void set_pair_visited(xbt_state_t st, int sc){
385
386  
387   MC_SET_RAW_MEM;
388  
389   mc_pair_visited_t pair = NULL;
390   pair = xbt_new0(s_mc_pair_visited_t, 1);
391   pair->automaton_state = st;
392   pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
393   pair->search_cycle = sc;
394   pair->system_state = xbt_new0(s_mc_snapshot_t, 1);
395   MC_take_snapshot_liveness(pair->system_state);
396
397
398   /* Get values of propositional symbols */
399   unsigned int cursor = 0;
400   xbt_propositional_symbol_t ps = NULL;
401   int res;
402   int (*f)();
403
404   xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
405     f = ps->function;
406     res = (*f)();
407     xbt_dynar_push_as(pair->prop_ato, int, res);
408   }
409   
410   xbt_fifo_unshift(visited_pairs, pair);
411   
412   MC_UNSET_RAW_MEM;
413   
414   
415 }
416
417 void MC_pair_delete(mc_pair_t pair){
418   xbt_free(pair->graph_state->proc_status);
419   xbt_free(pair->graph_state);
420   xbt_free(pair);
421 }
422
423
424
425 int MC_automaton_evaluate_label(xbt_exp_label_t l){
426   
427   switch(l->type){
428   case 0 : {
429     int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
430     int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
431     return (left_res || right_res);
432     break;
433   }
434   case 1 : {
435     int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
436     int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
437     return (left_res && right_res);
438     break;
439   }
440   case 2 : {
441     int res = MC_automaton_evaluate_label(l->u.exp_not);
442     return (!res);
443     break;
444   }
445   case 3 : { 
446     unsigned int cursor = 0;
447     xbt_propositional_symbol_t p = NULL;
448     xbt_dynar_foreach(automaton->propositional_symbols, cursor, p){
449       if(strcmp(p->pred, l->u.predicat) == 0){
450         int (*f)() = p->function;
451         return (*f)();
452       }
453     }
454     return -1;
455     break;
456   }
457   case 4 : {
458     return 2;
459     break;
460   }
461   default : 
462     return -1;
463   }
464 }
465
466
467
468
469
470 /********************* Double-DFS stateless *******************/
471
472 void MC_pair_stateless_delete(mc_pair_stateless_t pair){
473   xbt_free(pair->graph_state->proc_status);
474   xbt_free(pair->graph_state);
475   xbt_free(pair);
476 }
477
478 mc_pair_stateless_t new_pair_stateless(mc_state_t sg, xbt_state_t st, int r){
479   mc_pair_stateless_t p = NULL;
480   p = xbt_new0(s_mc_pair_stateless_t, 1);
481   p->automaton_state = st;
482   p->graph_state = sg;
483   p->requests = r;
484   mc_stats_pair->expanded_pairs++;
485   return p;
486 }
487
488 void MC_ddfs_stateless_init(){
489
490   XBT_DEBUG("**************************************************");
491   XBT_DEBUG("Double-DFS stateless init");
492   XBT_DEBUG("**************************************************");
493
494   mc_pair_stateless_t mc_initial_pair = NULL;
495   mc_state_t initial_graph_state = NULL;
496   smx_process_t process; 
497  
498   MC_wait_for_requests();
499
500   MC_SET_RAW_MEM;
501
502   initial_graph_state = MC_state_pair_new();
503   xbt_swag_foreach(process, simix_global->process_list){
504     if(MC_process_is_enabled(process)){
505       MC_state_interleave_process(initial_graph_state, process);
506     }
507   }
508
509   reached_pairs = xbt_fifo_new(); 
510   //visited_pairs = xbt_fifo_new();
511   visited_pairs_hash = xbt_fifo_new();
512   successors = xbt_dynar_new(sizeof(mc_pair_stateless_t), NULL);
513
514   /* Save the initial state */
515   initial_snapshot_liveness = xbt_new0(s_mc_snapshot_t, 1);
516   MC_take_snapshot_to_restore_liveness(initial_snapshot_liveness);
517
518   MC_UNSET_RAW_MEM; 
519
520   unsigned int cursor = 0;
521   xbt_state_t state;
522
523   xbt_dynar_foreach(automaton->states, cursor, state){
524     if(state->type == -1){
525       
526       MC_SET_RAW_MEM;
527       mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
528       xbt_fifo_unshift(mc_stack_liveness_stateless, mc_initial_pair);
529       MC_UNSET_RAW_MEM;
530       
531       if(cursor != 0){
532         MC_restore_snapshot(initial_snapshot_liveness);
533         MC_UNSET_RAW_MEM;
534       }
535
536       MC_ddfs_stateless(0);
537
538     }else{
539       if(state->type == 2){
540       
541         MC_SET_RAW_MEM;
542         mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
543         xbt_fifo_unshift(mc_stack_liveness_stateless, mc_initial_pair);
544         MC_UNSET_RAW_MEM;
545
546         set_pair_reached(state);
547         
548         if(cursor != 0){
549           MC_restore_snapshot(initial_snapshot_liveness);
550           MC_UNSET_RAW_MEM;
551         }
552         
553         MC_ddfs_stateless(1);
554         
555       }
556     }
557   } 
558
559 }
560
561
562 void MC_ddfs_stateless(int search_cycle){
563
564   smx_process_t process;
565   mc_pair_stateless_t current_pair = NULL;
566
567   if(xbt_fifo_size(mc_stack_liveness_stateless) == 0)
568     return;
569
570
571   /* Get current pair */
572   current_pair = (mc_pair_stateless_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness_stateless));
573
574   /* Update current state in buchi automaton */
575   automaton->current_state = current_pair->automaton_state;
576
577  
578   XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d )", xbt_fifo_size(mc_stack_liveness_stateless), search_cycle);
579   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));
580  
581   mc_stats_pair->visited_pairs++;
582
583   //sleep(1);
584
585   int value;
586   mc_state_t next_graph_state = NULL;
587   smx_req_t req = NULL;
588   char *req_str;
589
590   xbt_transition_t transition_succ;
591   unsigned int cursor = 0;
592   int res;
593
594   mc_pair_stateless_t next_pair = NULL;
595   mc_pair_stateless_t pair_succ;
596
597   if(xbt_fifo_size(mc_stack_liveness_stateless) < MAX_DEPTH_LIVENESS){
598
599     //set_pair_visited(current_pair->automaton_state, search_cycle);
600     set_pair_visited_hash(current_pair->automaton_state, search_cycle);
601
602     //XBT_DEBUG("Visited pairs : %d", xbt_fifo_size(visited_pairs));
603     //XBT_DEBUG("Visited pairs : %d", xbt_fifo_size(visited_pairs_hash));
604
605     if(current_pair->requests > 0){
606
607       while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
608    
609         /* Debug information */
610         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
611           req_str = MC_request_to_string(req, value);
612           XBT_DEBUG("Execute: %s", req_str);
613           xbt_free(req_str);
614         }
615
616         MC_state_set_executed_request(current_pair->graph_state, req, value);   
617     
618         /* Answer the request */
619         SIMIX_request_pre(req, value);
620
621         /* Wait for requests (schedules processes) */
622         MC_wait_for_requests();
623
624
625         MC_SET_RAW_MEM;
626
627         /* Create the new expanded graph_state */
628         next_graph_state = MC_state_pair_new();
629
630         /* Get enabled process and insert it in the interleave set of the next graph_state */
631         xbt_swag_foreach(process, simix_global->process_list){
632           if(MC_process_is_enabled(process)){
633             MC_state_interleave_process(next_graph_state, process);
634           }
635         }
636
637         xbt_dynar_reset(successors);
638
639         MC_UNSET_RAW_MEM;
640
641
642         cursor= 0;
643         xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
644
645           res = MC_automaton_evaluate_label(transition_succ->label);
646
647           if(res == 1){ // enabled transition in automaton
648             MC_SET_RAW_MEM;
649             next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
650             xbt_dynar_push(successors, &next_pair);
651             MC_UNSET_RAW_MEM;
652           }
653
654         }
655
656         cursor = 0;
657    
658         xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
659       
660           res = MC_automaton_evaluate_label(transition_succ->label);
661         
662           if(res == 2){ // true transition in automaton
663             MC_SET_RAW_MEM;
664             next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
665             xbt_dynar_push(successors, &next_pair);
666             MC_UNSET_RAW_MEM;
667           }
668
669         }
670
671         cursor = 0; 
672         
673         xbt_dynar_foreach(successors, cursor, pair_succ){
674
675           //if(!visited(pair_succ->automaton_state, search_cycle)){
676           if(!visited_hash(pair_succ->automaton_state, search_cycle)){
677
678             if(search_cycle == 1){
679
680               if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){ 
681                       
682                 if(reached(pair_succ->automaton_state) == 1){
683
684                   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));
685
686                   XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
687                   XBT_INFO("|             ACCEPTANCE CYCLE            |");
688                   XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
689                   XBT_INFO("Counter-example that violates formula :");
690                   MC_show_stack_liveness_stateless(mc_stack_liveness_stateless);
691                   MC_dump_stack_liveness_stateless(mc_stack_liveness_stateless);
692                   MC_print_statistics_pairs(mc_stats_pair);
693                   exit(0);
694
695                 }else{
696
697                   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);
698               
699                   set_pair_reached(pair_succ->automaton_state); 
700
701                   XBT_DEBUG("Reached pairs : %d", xbt_fifo_size(reached_pairs));
702
703                 }
704
705               }
706
707             }else{
708           
709               if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
710
711                 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);
712             
713                 set_pair_reached(pair_succ->automaton_state); 
714               
715                 search_cycle = 1;
716
717                 XBT_DEBUG("Reached pairs : %d", xbt_fifo_size(reached_pairs));
718
719               }
720
721             }
722
723             MC_SET_RAW_MEM;
724             xbt_fifo_unshift(mc_stack_liveness_stateless, pair_succ);
725             MC_UNSET_RAW_MEM;
726
727             MC_ddfs_stateless(search_cycle);
728
729             /* Restore system before checking others successors */
730             if(cursor != (xbt_dynar_length(successors) - 1))
731               MC_replay_liveness(mc_stack_liveness_stateless, 1);
732         
733         }else{
734             
735             XBT_DEBUG("Next pair already visited");
736
737             if(search_cycle == 1){
738
739               if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){ 
740                       
741                 if(reached(pair_succ->automaton_state) == 1){
742
743                   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));
744
745                   XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
746                   XBT_INFO("|             ACCEPTANCE CYCLE            |");
747                   XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
748                   XBT_INFO("Counter-example that violates formula :");
749                   MC_show_stack_liveness_stateless(mc_stack_liveness_stateless);
750                   MC_dump_stack_liveness_stateless(mc_stack_liveness_stateless);
751                   MC_print_statistics_pairs(mc_stats_pair);
752                   exit(0);
753
754                 }
755
756               }
757             }
758             
759         }
760           }
761
762         if(MC_state_interleave_size(current_pair->graph_state) > 0){
763           XBT_DEBUG("Backtracking to depth %u", xbt_fifo_size(mc_stack_liveness_stateless));
764           MC_replay_liveness(mc_stack_liveness_stateless, 0);
765         }
766       }
767
768  
769     }else{  /*No request to execute, search evolution in Büchi automaton */
770
771       MC_SET_RAW_MEM;
772
773       /* Create the new expanded graph_state */
774       next_graph_state = MC_state_pair_new();
775
776       xbt_dynar_reset(successors);
777
778       MC_UNSET_RAW_MEM;
779
780
781       cursor= 0;
782       xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
783
784         res = MC_automaton_evaluate_label(transition_succ->label);
785
786         if(res == 1){ // enabled transition in automaton
787           MC_SET_RAW_MEM;
788           next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
789           xbt_dynar_push(successors, &next_pair);
790           MC_UNSET_RAW_MEM;
791         }
792
793       }
794
795       cursor = 0;
796    
797       xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
798       
799         res = MC_automaton_evaluate_label(transition_succ->label);
800         
801         if(res == 2){ // true transition in automaton
802           MC_SET_RAW_MEM;
803           next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
804           xbt_dynar_push(successors, &next_pair);
805           MC_UNSET_RAW_MEM;
806         }
807
808       }
809
810       cursor = 0; 
811      
812       xbt_dynar_foreach(successors, cursor, pair_succ){
813
814         //if(!visited(pair_succ->automaton_state, search_cycle)){
815         if(!visited_hash(pair_succ->automaton_state, search_cycle)){
816
817           if(search_cycle == 1){
818
819             if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){ 
820
821               if(reached(pair_succ->automaton_state) == 1){
822
823                 XBT_DEBUG("Next pair (depth = %d) already reached !", xbt_fifo_size(mc_stack_liveness_stateless) + 1);
824
825                 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
826                 XBT_INFO("|             ACCEPTANCE CYCLE            |");
827                 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
828                 XBT_INFO("Counter-example that violates formula :");
829                 MC_show_stack_liveness_stateless(mc_stack_liveness_stateless);
830                 MC_dump_stack_liveness_stateless(mc_stack_liveness_stateless);
831                 MC_print_statistics_pairs(mc_stats_pair);
832                 exit(0);
833
834               }else{
835
836                 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);
837               
838                 set_pair_reached(pair_succ->automaton_state); 
839                 
840                 XBT_DEBUG("Reached pairs : %d", xbt_fifo_size(reached_pairs));
841
842               }
843
844             }
845
846           }else{
847           
848             if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
849
850               set_pair_reached(pair_succ->automaton_state); 
851                     
852               search_cycle = 1;
853
854               XBT_DEBUG("Reached pairs : %d", xbt_fifo_size(reached_pairs));
855
856             }
857
858           }
859
860           MC_SET_RAW_MEM;
861           xbt_fifo_unshift(mc_stack_liveness_stateless, pair_succ);
862           MC_UNSET_RAW_MEM;
863
864           MC_ddfs_stateless(search_cycle);
865
866           /* Restore system before checking others successors */
867           if(cursor != xbt_dynar_length(successors) - 1)
868             MC_replay_liveness(mc_stack_liveness_stateless, 1);
869
870           }else{
871             
872           XBT_DEBUG("Next pair already visited");
873
874           if(search_cycle == 1){
875
876             if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){ 
877               
878               if(reached(pair_succ->automaton_state) == 1){
879                 
880                 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));
881                 
882                 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
883                 XBT_INFO("|             ACCEPTANCE CYCLE            |");
884                 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
885                 XBT_INFO("Counter-example that violates formula :");
886                 MC_show_stack_liveness_stateless(mc_stack_liveness_stateless);
887                 MC_dump_stack_liveness_stateless(mc_stack_liveness_stateless);
888                 MC_print_statistics_pairs(mc_stats_pair);
889                 exit(0);
890                   
891               }
892                 
893             }
894               
895           }
896         }
897           
898       }
899            
900     }
901     
902   }else{
903     
904     XBT_DEBUG("Max depth reached");
905
906   }
907
908   if(xbt_fifo_size(mc_stack_liveness_stateless) == MAX_DEPTH_LIVENESS ){
909     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) );
910   }else{
911     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) );
912   }
913
914   
915   MC_SET_RAW_MEM;
916   xbt_fifo_shift(mc_stack_liveness_stateless);
917   if((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2)){
918     xbt_fifo_shift(reached_pairs);
919   }
920   MC_UNSET_RAW_MEM;
921   
922   
923
924 }
925