-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbdd_engine.cpp
1089 lines (816 loc) · 24.6 KB
/
bdd_engine.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************\
Module: BDD Engine
Author: Daniel Kroening, [email protected]
\*******************************************************************/
#include "bdd_engine.h"
#include <util/expr_util.h>
#include <util/format_expr.h>
#include <ebmc/liveness_to_safety.h>
#include <ebmc/transition_system.h>
#include <solvers/bdd/miniBDD/miniBDD.h>
#include <solvers/prop/literal_expr.h>
#include <solvers/sat/satcheck.h>
#include <temporal-logic/ctl.h>
#include <temporal-logic/ltl.h>
#include <temporal-logic/temporal_logic.h>
#include <trans-netlist/aig_prop.h>
#include <trans-netlist/instantiate_netlist.h>
#include <trans-netlist/trans_trace_netlist.h>
#include <trans-netlist/unwind_netlist.h>
#include <verilog/sva_expr.h>
#include "netlist.h"
#include <algorithm>
#include <iostream>
/*******************************************************************\
Class: bdd_enginet
Purpose:
\*******************************************************************/
class bdd_enginet
{
public:
bdd_enginet(
const cmdlinet &_cmdline,
transition_systemt &_transition_system,
ebmc_propertiest &_properties,
message_handlert &_message_handler)
: cmdline(_cmdline),
transition_system(_transition_system),
properties(_properties),
message(_message_handler),
ns(transition_system.symbol_table)
{
}
property_checker_resultt operator()();
protected:
using propertiest = ebmc_propertiest;
using propertyt = ebmc_propertiest::propertyt;
const cmdlinet &cmdline;
transition_systemt &transition_system;
propertiest &properties;
messaget message;
const namespacet ns;
netlistt netlist;
static bool property_supported(const exprt &);
// the Manager must appear before any BDDs
// to do the cleanup in the right order
mini_bdd_mgrt mgr;
typedef mini_bddt BDD;
struct atomic_propositiont
{
literalt l;
BDD bdd;
};
typedef std::map<exprt, atomic_propositiont> atomic_propositionst;
atomic_propositionst atomic_propositions;
std::vector<BDD> constraints_BDDs, initial_BDDs,
transition_BDDs;
class vart
{
public:
bool is_input;
BDD current, next;
};
// this is our BDD variable ordering
class ordering
{
public:
bool operator()(const bv_varidt &a, const bv_varidt &b) const
{
if(a.bit_nr==b.bit_nr) return a.id<b.id;
return a.bit_nr<b.bit_nr;
}
};
typedef std::map<bv_varidt, vart, ordering> varst;
varst vars;
void allocate_vars(const var_mapt &);
void build_BDDs();
inline BDD aig2bdd(
literalt l,
const std::vector<BDD> &BDDs) const
{
if(l.is_true()) return mgr.True();
if(l.is_false()) return mgr.False();
assert(l.var_no()<BDDs.size());
BDD result=BDDs[l.var_no()];
assert(result.is_initialized());
if(l.sign()) result=!result;
return result;
}
void get_atomic_propositions(const exprt &);
void check_property(propertyt &);
BDD current_to_next(const BDD &) const;
BDD next_to_current(const BDD &) const;
BDD project_next(const BDD &) const;
BDD project_current(const BDD &) const;
void compute_counterexample(
propertyt &,
unsigned number_of_timeframes);
void check_AGp(propertyt &);
void check_CTL(propertyt &);
BDD CTL(const exprt &);
BDD EX(BDD);
BDD AX(BDD f)
{
return !EX(!f);
}
BDD EF(BDD);
BDD AF(BDD f)
{
return !EG(!f);
}
BDD EG(BDD);
BDD AG(BDD f)
{
return !EF(!f);
}
BDD EU(BDD, BDD);
BDD AU(BDD, BDD);
BDD ER(BDD f1, BDD f2)
{
return !AU(!f1, !f2);
}
BDD AR(BDD f1, BDD f2)
{
return !EU(!f1, !f2);
}
BDD fixedpoint(std::function<BDD(BDD)>, BDD);
};
/*******************************************************************\
Function: bdd_enginet::operator()
Inputs:
Outputs:
Purpose:
\*******************************************************************/
property_checker_resultt bdd_enginet::operator()()
{
try
{
// any properties left?
if(!properties.has_unfinished_property())
return property_checker_resultt{properties};
// possibly apply liveness-to-safety
if(cmdline.isset("liveness-to-safety"))
liveness_to_safety(transition_system, properties);
message.status() << "Building netlist" << messaget::eom;
netlist = make_netlist(
transition_system, properties, message.get_message_handler());
message.statistics() << "Latches: " << netlist.var_map.latches.size()
<< ", nodes: " << netlist.number_of_nodes()
<< messaget::eom;
for(const auto &property : properties.properties)
if(property_supported(property.normalized_expr))
get_atomic_propositions(property.normalized_expr);
message.status() << "Building BDD for netlist" << messaget::eom;
allocate_vars(netlist.var_map);
build_BDDs();
message.statistics() << "BDD nodes: " << mgr.number_of_nodes()
<< messaget::eom;
if(cmdline.isset("show-bdds"))
{
mgr.DumpTable(std::cout);
std::cout << '\n';
std::cout << "Atomic propositions:\n";
for(const auto & a : atomic_propositions)
{
std::cout << '`' << format(a.first) << "' -> "
<< a.second.bdd.node_number() << '\n';
}
std::cout << '\n';
return property_checker_resultt::success();
}
if(properties.properties.empty())
{
message.error() << "no properties" << messaget::eom;
return property_checker_resultt::error();
}
for(propertyt &p : properties.properties)
check_property(p);
return property_checker_resultt{properties};
}
catch(const char *error_msg)
{
message.error() << error_msg << messaget::eom;
return property_checker_resultt::error();
}
catch(int)
{
return property_checker_resultt::error();
}
}
/*******************************************************************\
Function: bdd_enginet::allocate_vars
Inputs:
Outputs:
Purpose:
\*******************************************************************/
void bdd_enginet::allocate_vars(const var_mapt &var_map)
{
// gather variables according to variable ordering
for(auto &it : var_map.map)
{
if(it.second.is_latch() ||
it.second.is_input() ||
it.second.is_nondet())
{
for(std::size_t bit_nr=0;
bit_nr<it.second.bits.size();
bit_nr++)
{
bv_varidt bv_varid(it.first, bit_nr);
vars[bv_varid].is_input=
it.second.is_input() || it.second.is_nondet();
}
}
}
// now allocate BBD variables
for(auto &it : vars)
{
std::string s=it.first.as_string();
it.second.current=mgr.Var(s);
it.second.next=mgr.Var(s+"'");
}
}
/*******************************************************************\
Function: bdd_enginet::current_to_next
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bdd_enginet::BDD bdd_enginet::current_to_next(const BDD &bdd) const
{
BDD tmp=bdd;
for(const auto &v : vars)
tmp=substitute(tmp, v.second.current.var(), v.second.next);
return tmp;
}
/*******************************************************************\
Function: bdd_enginet::next_to_current
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bdd_enginet::BDD bdd_enginet::next_to_current(const BDD &bdd) const
{
BDD tmp=bdd;
for(const auto &v : vars)
tmp=substitute(tmp, v.second.next.var(), v.second.current);
return tmp;
}
/*******************************************************************\
Function: bdd_enginet::project_next
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bdd_enginet::BDD bdd_enginet::project_next(const BDD &bdd) const
{
BDD tmp=bdd;
for(const auto &v : vars)
tmp=exists(tmp, v.second.next.var());
return tmp;
}
/*******************************************************************\
Function: bdd_enginet::project_current
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bdd_enginet::BDD bdd_enginet::project_current(const BDD &bdd) const
{
BDD tmp=bdd;
for(const auto &v : vars)
tmp=exists(tmp, v.second.current.var());
return tmp;
}
/*******************************************************************\
Function: bdd_enginet::compute_counterexample
Inputs:
Outputs:
Purpose:
\*******************************************************************/
void bdd_enginet::compute_counterexample(
propertyt &property,
unsigned number_of_timeframes)
{
// Supported by BMC engine?
if(!netlist_bmc_supports_property(property.normalized_expr))
return;
message.status() << "Computing counterexample with " << number_of_timeframes
<< " timeframe(s)" << messaget::eom;
satcheckt solver{message.get_message_handler()};
const auto bmc_map = bmc_mapt{netlist, number_of_timeframes, solver};
::unwind(netlist, bmc_map, message, solver);
// find the netlist property
auto netlist_property = netlist.properties.find(property.identifier);
CHECK_RETURN(netlist_property != netlist.properties.end());
property.timeframe_literals =
::unwind_property(netlist_property->second.value(), bmc_map);
// we need the propertyt to fail in one of the timeframes
bvt clause=property.timeframe_literals;
for(auto & l : clause) l=!l;
solver.lcnf(clause);
propt::resultt prop_result=
solver.prop_solve();
switch(prop_result)
{
case propt::resultt::P_SATISFIABLE: break; // this is what we want
case propt::resultt::P_UNSATISFIABLE:
throw "SAT solver says UNSAT!";
case propt::resultt::P_ERROR:
default:
throw "unexpected result from SAT solver";
}
property.witness_trace =
compute_trans_trace(property.timeframe_literals, bmc_map, solver, ns);
}
/*******************************************************************\
Function: bdd_enginet::property_supported
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool bdd_enginet::property_supported(const exprt &expr)
{
// Our engine knows all of CTL.
if(is_CTL(expr))
return true;
if(is_LTL(expr))
{
// We can map selected path properties to CTL.
return LTL_to_CTL(expr).has_value();
}
if(is_SVA(expr))
{
if(
expr.id() == ID_sva_always &&
!has_temporal_operator(to_sva_always_expr(expr).op()))
{
// always p
return true;
}
if(
expr.id() == ID_sva_always &&
to_sva_always_expr(expr).op().id() == ID_sva_s_eventually &&
!has_temporal_operator(
to_sva_s_eventually_expr(to_sva_always_expr(expr).op()).op()))
{
// always s_eventually p
return true;
}
}
return false;
}
/*******************************************************************\
Function: bdd_enginet::check_property
Inputs:
Outputs:
Purpose:
\*******************************************************************/
void bdd_enginet::check_property(propertyt &property)
{
if(property.is_disabled())
return;
if(property.is_assumed())
return;
if(!property_supported(property.normalized_expr))
{
property.failure("property not supported by BDD engine");
return;
}
message.status() << "Checking " << property.name << messaget::eom;
property.status=propertyt::statust::UNKNOWN;
if(
property.normalized_expr.id() == ID_sva_always &&
to_sva_always_expr(property.normalized_expr).op().id() ==
ID_sva_s_eventually &&
!has_temporal_operator(to_sva_s_eventually_expr(
to_sva_always_expr(property.normalized_expr).op())
.op()))
{
// always s_eventually p --> AG AF p
auto p = to_sva_s_eventually_expr(
to_sva_always_expr(property.normalized_expr).op())
.op();
property.normalized_expr = AG_exprt{AF_exprt{p}};
}
if(
property.normalized_expr.id() == ID_sva_always &&
!has_temporal_operator(to_sva_always_expr(property.normalized_expr).op()))
{
// always p --> AG p
auto p = to_sva_always_expr(property.normalized_expr).op();
property.normalized_expr = AG_exprt{p};
}
// Our engine knows CTL only.
// We map selected path properties to CTL.
if(
has_temporal_operator(property.normalized_expr) &&
is_LTL(property.normalized_expr))
{
auto CTL_opt = LTL_to_CTL(property.normalized_expr);
CHECK_RETURN(CTL_opt.has_value());
property.normalized_expr = CTL_opt.value();
CHECK_RETURN(is_CTL(property.normalized_expr));
}
if(is_AGp(property.normalized_expr))
{
check_AGp(property);
}
else if(is_CTL(property.normalized_expr))
{
check_CTL(property);
}
else
DATA_INVARIANT(false, "unexpected normalized property");
}
/*******************************************************************\
Function: bdd_enginet::check_AGp
Inputs:
Outputs:
Purpose:
\*******************************************************************/
void bdd_enginet::check_AGp(propertyt &property)
{
const exprt &sub_expr = to_unary_expr(property.normalized_expr).op();
BDD p = CTL(sub_expr);
// Start with !p, and go backwards until saturation or we hit an
// initial state.
BDD states = !p;
unsigned iteration = 0;
for(const auto &c : constraints_BDDs)
states = states & c;
std::size_t peak_bdd_nodes = 0;
while(true)
{
iteration++;
message.statistics() << "Iteration " << iteration << messaget::eom;
// do we have an initial state?
BDD intersection = states;
for(const auto &i : initial_BDDs)
intersection = intersection & i;
peak_bdd_nodes = std::max(peak_bdd_nodes, mgr.number_of_nodes());
if(!intersection.is_false())
{
property.refuted();
message.status() << "Property refuted" << messaget::eom;
compute_counterexample(property, iteration);
break;
}
// make the states be expressed in terms of 'next' variables
BDD states_next = current_to_next(states);
// now conjoin with transition relation
BDD conjunction = states_next;
for(const auto &t : transition_BDDs)
conjunction = conjunction & t;
for(const auto &c : constraints_BDDs)
conjunction = conjunction & c;
// now project away 'next' variables
BDD pre_image = project_next(conjunction);
// compute union
BDD set_union = states | pre_image;
// have we saturated?
if((set_union == states).is_true())
{
property.proved();
message.status() << "Property proved" << messaget::eom;
break;
}
states = set_union;
peak_bdd_nodes = std::max(peak_bdd_nodes, mgr.number_of_nodes());
}
}
/*******************************************************************\
Function: bdd_enginet::check_CTL
Inputs:
Outputs:
Purpose:
\*******************************************************************/
void bdd_enginet::check_CTL(propertyt &property)
{
// For a CTL formula f, calculate the set of states that satisfy
// !f, and then check if that contains any initial state.
BDD not_f = !CTL(property.normalized_expr);
BDD intersection = not_f;
for(const auto &i : initial_BDDs)
intersection = intersection & i;
for(const auto &c : constraints_BDDs)
intersection = intersection & c;
if(intersection.is_false())
{
// intersection empty, proved
property.proved();
message.status() << "Property proved" << messaget::eom;
}
else
{
// refuted
property.refuted();
message.status() << "Property refuted" << messaget::eom;
}
}
/*******************************************************************\
Function: bdd_enginet::CTL
Inputs: a CTL expression
Outputs: a BDD for the set of states that satisfies the expression
Purpose: compute states that satisfy a particular property
\*******************************************************************/
bdd_enginet::BDD bdd_enginet::CTL(const exprt &expr)
{
if(expr.is_true())
return mgr.True();
else if(expr.is_false())
return mgr.False();
else if(expr.id()==ID_not)
{
return !CTL(to_not_expr(expr).op());
}
else if(expr.id() == ID_implies)
{
return (!CTL(to_binary_expr(expr).lhs())) | CTL(to_binary_expr(expr).rhs());
}
else if(expr.id()==ID_and)
{
BDD result=mgr.True();
for(const auto & op : expr.operands())
result = result & CTL(op);
return result;
}
else if(expr.id()==ID_or)
{
BDD result=mgr.False();
for(const auto & op : expr.operands())
result = result | CTL(op);
return result;
}
else if(
expr.id() == ID_equal && to_equal_expr(expr).lhs().type().id() == ID_bool)
{
return (
!(CTL(to_binary_expr(expr).lhs())) ^ CTL(to_binary_expr(expr).rhs()));
}
else if(expr.id() == ID_EX)
{
return EX(CTL(to_EX_expr(expr).op()));
}
else if(expr.id() == ID_EF)
{
return EF(CTL(to_EF_expr(expr).op()));
}
else if(expr.id() == ID_EG)
{
return EG(CTL(to_EG_expr(expr).op()));
}
else if(expr.id() == ID_AX)
{
return AX(CTL(to_AX_expr(expr).op()));
}
else if(expr.id() == ID_AF)
{
return AF(CTL(to_AF_expr(expr).op()));
}
else if(expr.id() == ID_AG)
{
return AG(CTL(to_AG_expr(expr).op()));
}
else if(expr.id() == ID_EU)
{
auto &EU_expr = to_EU_expr(expr);
return EU(CTL(EU_expr.lhs()), CTL(EU_expr.rhs()));
}
else if(expr.id() == ID_AU)
{
auto &AU_expr = to_AU_expr(expr);
return AU(CTL(AU_expr.lhs()), CTL(AU_expr.rhs()));
}
else if(expr.id() == ID_ER)
{
auto &ER_expr = to_ER_expr(expr);
return ER(CTL(ER_expr.lhs()), CTL(ER_expr.rhs()));
}
else if(expr.id() == ID_AR)
{
auto &AR_expr = to_AR_expr(expr);
return AR(CTL(AR_expr.lhs()), CTL(AR_expr.rhs()));
}
else
{
atomic_propositionst::const_iterator it=
atomic_propositions.find(expr);
if(it!=atomic_propositions.end())
return it->second.bdd;
}
message.error() << "unsupported property -- `" << expr.id()
<< "' not implemented" << messaget::eom;
throw 0;
}
/*******************************************************************\
Function: bdd_enginet::EX
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bdd_enginet::BDD bdd_enginet::EX(BDD f)
{
for(const auto &c : constraints_BDDs)
f = f & c;
// make 'f' be expressed in terms of 'next' variables
BDD p_next = current_to_next(f);
// now conjoin with transition relation
BDD conjunction = p_next;
for(const auto &t : transition_BDDs)
conjunction = conjunction & t;
for(const auto &c : constraints_BDDs)
conjunction = conjunction & c;
// now project away 'next' variables
BDD pre_image = project_next(conjunction);
return pre_image;
}
/*******************************************************************\
Function: bdd_enginet::fixedpoint
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bdd_enginet::BDD bdd_enginet::fixedpoint(std::function<BDD(BDD)> tau, BDD x)
{
// Apply tau(x) until saturation.
while(true)
{
BDD image = tau(x);
// fixpoint?
if((image == x).is_true())
return x; // done
x = image;
}
}
/*******************************************************************\
Function: bdd_enginet::EG
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bdd_enginet::BDD bdd_enginet::EG(BDD f)
{
// EG f = f ∧ EX EG f
// Iterate x ∧ EX x until saturation.
auto tau = [this](BDD x) { return x & EX(x); };
return fixedpoint(tau, f);
}
/*******************************************************************\
Function: bdd_enginet::EF
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bdd_enginet::BDD bdd_enginet::EF(BDD f)
{
// EF f ↔ f ∨ EX EF f
// Iterate x ∨ EX x until saturation.
auto tau = [this](BDD x) { return x | EX(x); };
return fixedpoint(tau, f);
}
/*******************************************************************\
Function: bdd_enginet::EU
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bdd_enginet::BDD bdd_enginet::EU(BDD f1, BDD f2)
{
// Iterate x ∨ f2 ∨ (f1 ∧ EX x) until saturation
auto tau = [this, f1, f2](BDD x) { return x | f2 | (f1 & EX(x)); };
return fixedpoint(tau, mgr.False());
}
/*******************************************************************\
Function: bdd_enginet::AU
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bdd_enginet::BDD bdd_enginet::AU(BDD f1, BDD f2)
{
// Iterate x ∨ f2 ∨ (f1 ∧ AX x) until saturation
auto tau = [this, f1, f2](BDD x) { return x | f2 | (f1 & AX(x)); };
return fixedpoint(tau, mgr.False());
}
/*******************************************************************\
Function: bdd_enginet::get_atomic_propositions
Inputs:
Outputs:
Purpose:
\*******************************************************************/
void bdd_enginet::get_atomic_propositions(const exprt &expr)
{
if(
expr.id() == ID_and || expr.id() == ID_or || expr.id() == ID_not ||
expr.id() == ID_implies ||
(expr.id() == ID_equal &&
to_equal_expr(expr).lhs().type().id() == ID_bool) ||
is_temporal_operator(expr))
{
for(const auto & op : expr.operands())
if(op.type().id() == ID_bool)
get_atomic_propositions(op);
}
else
{
// do we have it already?
if(atomic_propositions.find(expr)!=
atomic_propositions.end())
return; // yes
assert(expr.type().id()==ID_bool);
aig_prop_constraintt aig_prop(netlist, message.get_message_handler());
literalt l = instantiate_convert(
aig_prop, netlist.var_map, expr, ns, message.get_message_handler());
atomic_propositiont &a=atomic_propositions[expr];
a.l=l;
a.bdd=mgr.False();
}
}
/*******************************************************************\
Function: bdd_enginet::build_BDDs
Inputs:
Outputs:
Purpose:
\*******************************************************************/
void bdd_enginet::build_BDDs()
{
std::vector<BDD> BDDs;
BDDs.resize(netlist.nodes.size());
for(std::size_t i=0; i<netlist.nodes.size(); i++)
{
const netlistt::nodet &n=netlist.nodes[i];