forked from lijwen2748/aaltaf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
131 lines (114 loc) · 2.65 KB
/
main.cpp
File metadata and controls
131 lines (114 loc) · 2.65 KB
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
#include "formula/aalta_formula.h"
#include "ltlfchecker.h"
#include "carchecker.h"
#include "solver.h"
#include <stdio.h>
#include <string.h>
#define MAXN 100000
char in[MAXN];
using namespace aalta;
void
print_help ()
{
cout << "usage: ./aalta_f [-e|-v|-blsc|-t|-h] [\"formula\"]" << endl;
cout << "\t -e\t:\t print example when result is SAT" << endl;
cout << "\t -v\t:\t print verbose details" << endl;
cout << "\t -blsc\t:\t use the BLSC checking method; Default is CDLSC" << endl;
cout << "\t -t\t:\t print weak until formula" << endl;
cout << "\t -h\t:\t print help information" << endl;
}
void
ltlf_sat (int argc, char** argv)
{
bool verbose = false;
bool evidence = false;
int input_count = 0;
bool blsc = false;
bool print_weak_until_free = false;
for (int i = argc; i > 1; i --)
{
if (strcmp (argv[i-1], "-v") == 0)
verbose = true;
else if (strcmp (argv[i-1], "-e") == 0)
evidence = true;
else if (strcmp (argv[i-1], "-blsc") == 0)
blsc = true;
else if (strcmp (argv[i-1], "-t") == 0)
print_weak_until_free = true;
else if (strcmp (argv[i-1], "-h") == 0)
{
print_help ();
exit (0);
}
else //for input
{
if (input_count > 1)
{
printf ("Error: read more than one input!\n");
exit (0);
}
strcpy (in, argv[i-1]);
input_count ++;
}
}
if (input_count == 0)
{
puts ("please input the formula:");
if (fgets (in, MAXN, stdin) == NULL)
{
printf ("Error: read input!\n");
exit (0);
}
}
aalta_formula* af;
//set tail id to be 1
af = aalta_formula::TAIL ();
af = aalta_formula(in, true).unique();
if (print_weak_until_free)
{
cout << af->to_string () << endl;
return;
}
af = af->nnf ();
af = af->add_tail ();
af = af->remove_wnext ();
af = af->simplify ();
af = af->split_next ();
//LTLfChecker checker (af, verbose);
// A t (af, verbose);
/*
LTLfChecker *checker;
if (!blsc)
checker = new CARChecker (af, verbose, evidence);
else
checker = new LTLfChecker (af, verbose, evidence);
bool res = checker->check ();
printf ("%s\n", res ? "sat" : "unsat");
if (evidence && res)
checker->print_evidence ();
delete checker;
*/
if (blsc)
{
LTLfChecker checker (af, verbose, evidence);
bool res = checker.check ();
printf ("%s\n", res ? "sat" : "unsat");
if (evidence && res)
checker.print_evidence ();
}
else
{
CARChecker checker (af, verbose, evidence);
bool res = checker.check ();
printf ("%s\n", res ? "sat" : "unsat");
if (evidence && res)
checker.print_evidence ();
}
aalta_formula::destroy();
}
int
main (int argc, char** argv)
{
ltlf_sat (argc, argv);
return 0;
}