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
use std::io ;
use std::fmt ;
use errors::* ;
pub trait Sym2Smt<Info> {
fn sym_to_smt2<Writer>(& self, & mut Writer, Info) -> SmtRes<()>
where Writer: io::Write ;
}
pub trait Expr2Smt<Info> {
fn expr_to_smt2<Writer>(& self, & mut Writer, Info) -> SmtRes<()>
where Writer: io::Write ;
}
pub trait Sort2Smt {
fn sort_to_smt2<Writer>(& self, & mut Writer) -> SmtRes<()>
where Writer: io::Write ;
}
#[inline(always)]
pub fn write_str(
w: & mut io::Write, s: & str
) -> SmtRes<()> {
w.write_all( s.as_bytes() ) ? ;
Ok(())
}
impl<'a, T> Sym2Smt<T> for & 'a str {
fn sym_to_smt2<Writer>(
& self, writer: & mut Writer, _: T
) -> SmtRes<()> where Writer: io::Write {
write_str(writer, self)
}
}
impl<'a, T> Expr2Smt<T> for & 'a str {
fn expr_to_smt2<Writer>(
& self, writer: & mut Writer, _: T
) -> SmtRes<()> where Writer: io::Write {
write_str(writer, self)
}
}
impl<'a> Sort2Smt for & 'a str {
fn sort_to_smt2<Writer>(
& self, writer: & mut Writer
) -> SmtRes<()> where Writer: io::Write {
write_str(writer, self)
}
}
impl<T> Sym2Smt<T> for str {
fn sym_to_smt2<Writer>(
& self, writer: & mut Writer, _: T
) -> SmtRes<()> where Writer: io::Write {
write_str(writer, self)
}
}
impl<T> Expr2Smt<T> for str {
fn expr_to_smt2<Writer>(
& self, writer: & mut Writer, _: T
) -> SmtRes<()> where Writer: io::Write {
write_str(writer, self)
}
}
impl Sort2Smt for str {
fn sort_to_smt2<Writer>(
& self, writer: & mut Writer
) -> SmtRes<()> where Writer: io::Write {
write_str(writer, self)
}
}
impl<T> Sym2Smt<T> for String {
fn sym_to_smt2<Writer>(
& self, writer: & mut Writer, _: T
) -> SmtRes<()> where Writer: io::Write {
write_str(writer, self)
}
}
impl<T> Expr2Smt<T> for String {
fn expr_to_smt2<Writer>(
& self, writer: & mut Writer, _: T
) -> SmtRes<()> where Writer: io::Write {
write_str(writer, self)
}
}
impl Sort2Smt for String {
fn sort_to_smt2<Writer>(
& self, writer: & mut Writer
) -> SmtRes<()> where Writer: io::Write {
write_str(writer, self)
}
}
#[allow(non_camel_case_types)]
#[derive(Clone, Copy)]
pub enum Logic {
QF_UF,
QF_LIA,
QF_NIA,
QF_LRA,
QF_AUFLIA,
AUFLIA,
AUFLIRA,
AUFNIRA,
LRA,
}
impl fmt::Display for Logic {
fn fmt(& self, fmt: & mut fmt::Formatter) -> fmt::Result {
use self::Logic::* ;
match * self {
QF_UF => write!(fmt, "QF_UF"),
QF_LIA => write!(fmt, "QF_LIA"),
QF_NIA => write!(fmt, "QF_NIA"),
QF_LRA => write!(fmt, "QF_LRA"),
QF_AUFLIA => write!(fmt, "QF_AUFLIA"),
AUFLIA => write!(fmt, "AUFLIA"),
AUFLIRA => write!(fmt, "AUFLIRA"),
AUFNIRA => write!(fmt, "AUFNIRA"),
LRA => write!(fmt, "LRA"),
}
}
}
impl Logic {
pub fn to_smt2(& self, writer: & mut io::Write, _: ()) -> SmtRes<()> {
write!(writer, "{}", self) ? ;
Ok(())
}
}
#[test]
fn logic() {
use conf::SolverConf ;
use { Logic, Kid, solver, Solver } ;
let conf = SolverConf::z3() ;
let mut kid = Kid::new(conf).expect("kid") ;
let mut solver = solver(& mut kid, ()).expect("solver") ;
solver.set_logic(Logic::QF_UF).expect("QF_UF") ;
solver.reset().expect("reset") ;
solver.set_logic(Logic::QF_LIA).expect("QF_LIA") ;
solver.reset().expect("reset") ;
solver.set_logic(Logic::QF_NIA).expect("QF_NIA") ;
solver.reset().expect("reset") ;
solver.set_logic(Logic::QF_LRA).expect("QF_LRA") ;
solver.reset().expect("reset") ;
solver.set_logic(Logic::QF_AUFLIA).expect("QF_AUFLIA") ;
solver.reset().expect("reset") ;
solver.set_logic(Logic::AUFLIA).expect("AUFLIA") ;
solver.reset().expect("reset") ;
solver.set_logic(Logic::AUFLIRA).expect("AUFLIRA") ;
solver.reset().expect("reset") ;
solver.set_logic(Logic::AUFNIRA).expect("AUFNIRA") ;
solver.reset().expect("reset") ;
solver.set_logic(Logic::LRA).expect("LRA") ;
solver.reset().expect("reset") ;
}