Skip to content

Commit 867bb66

Browse files
authored
Merge pull request #1226 from diffblue/hoa-intt
Hanoi Omega-Automata INT is 32 bits
2 parents f817354 + 4b9a5c5 commit 867bb66

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

src/temporal-logic/hoa.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Author: Daniel Kroening, dkr@amazon.com
99
#include "hoa.h"
1010

1111
#include <util/arith_tools.h>
12+
#include <util/string2int.h>
1213

1314
#include <ebmc/ebmc_error.h>
1415

@@ -167,9 +168,9 @@ hoa_tokenizert::tokent hoa_tokenizert::get_token(std::istream &in)
167168
}
168169
}
169170

170-
mp_integer hoat::max_state_number() const
171+
hoat::intt hoat::max_state_number() const
171172
{
172-
mp_integer max = 0;
173+
intt max = 0;
173174

174175
for(auto &state : body)
175176
max = std::max(max, state.first.number);
@@ -208,6 +209,7 @@ class hoa_parsert
208209
labelt parse_label_expr_and();
209210
labelt parse_label_expr_primary();
210211
acc_sigt parse_acc_sig();
212+
hoat::intt parse_int();
211213
};
212214

213215
hoat hoat::from_string(const std::string &src)
@@ -222,6 +224,15 @@ hoat hoat::from_string(const std::string &src)
222224
return hoat{header, body};
223225
}
224226

227+
hoat::intt hoa_parsert::parse_int()
228+
{
229+
auto text = tokenizer.consume().text;
230+
auto int_opt = string2optional<hoat::intt>(text);
231+
if(!int_opt.has_value())
232+
throw ebmc_errort() << "HOA-parser failed to parse INT";
233+
return int_opt.value();
234+
}
235+
225236
hoat::headert hoa_parsert::parse_header()
226237
{
227238
std::string headername;
@@ -284,8 +295,7 @@ hoat::state_namet hoa_parsert::parse_state_name()
284295
state_name.label = parse_label();
285296

286297
// INT
287-
auto number = tokenizer.consume().text;
288-
state_name.number = string2integer(number);
298+
state_name.number = parse_int();
289299

290300
// STRING?
291301
if(tokenizer.peek().is_string())
@@ -324,11 +334,11 @@ hoat::edget hoa_parsert::parse_edge()
324334
edge.label = parse_label();
325335

326336
// state-conj: INT | state-conj "&" INT
327-
edge.dest_states.push_back(string2integer(tokenizer.consume().text));
337+
edge.dest_states.push_back(parse_int());
328338
while(tokenizer.peek().text == "&")
329339
{
330340
tokenizer.consume();
331-
edge.dest_states.push_back(string2integer(tokenizer.consume().text));
341+
edge.dest_states.push_back(parse_int());
332342
}
333343

334344
// acc-sig?

src/temporal-logic/hoa.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Author: Daniel Kroening, dkr@amazon.com
1010
#define CPROVER_TEMPORAL_LOGIC_HOA_H
1111

1212
#include <util/irep.h>
13-
#include <util/mp_arith.h>
1413

14+
#include <cstdint>
1515
#include <list>
1616
#include <map>
1717
#include <string>
@@ -24,12 +24,15 @@ class hoat
2424
using headert = std::list<std::pair<std::string, std::list<std::string>>>;
2525
headert header;
2626

27+
// A HOA INT is non-negative and less than 2^31
28+
using intt = uint32_t;
29+
2730
// body
2831
using labelt = irept;
2932
using acc_sigt = std::vector<std::string>;
3033
struct state_namet
3134
{
32-
mp_integer number;
35+
intt number;
3336
labelt label; // in-state condition
3437
acc_sigt acc_sig;
3538
bool is_accepting() const
@@ -40,7 +43,7 @@ class hoat
4043
struct edget
4144
{
4245
labelt label; // transition condition
43-
std::vector<mp_integer> dest_states;
46+
std::vector<intt> dest_states;
4447
acc_sigt acc_sig; // acceptance sets
4548
};
4649
using edgest = std::list<edget>;
@@ -61,10 +64,10 @@ class hoat
6164
return out;
6265
}
6366

64-
mp_integer max_state_number() const;
67+
intt max_state_number() const;
6568

6669
// atomic propositions
67-
std::map<mp_integer, std::string> ap_map;
70+
std::map<intt, std::string> ap_map;
6871
};
6972

7073
#endif // CPROVER_TEMPORAL_LOGIC_HOA_H

src/temporal-logic/ltl_to_buechi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ ltl_to_buechi(const exprt &property, message_handlert &message_handler)
178178
// is nonaccepting with an unconditional self-loop.
179179
std::vector<exprt> error_disjuncts;
180180

181-
std::map<mp_integer, std::pair<hoat::state_namet, hoat::edgest>> state_map;
181+
std::map<hoat::intt, std::pair<hoat::state_namet, hoat::edgest>> state_map;
182182
for(auto &state : hoa.body)
183183
state_map[state.first.number] = state;
184184

0 commit comments

Comments
 (0)