Skip to content

Commit 49c9a33

Browse files
authored
Merge pull request #1006 from diffblue/smv-named-properties
SMV: named properties
2 parents bcf000d + 88a05db commit 49c9a33

File tree

7 files changed

+81
-25
lines changed

7 files changed

+81
-25
lines changed

regression/smv/LTL/smv_ltlspec4.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ smv_ltlspec4.smv
33
--bound 10 --numbered-trace
44
^EXIT=10$
55
^SIGNAL=0$
6-
^\[spec1\] F x = 0: REFUTED$
6+
^\[p1\] F x = 0: REFUTED$
77
^Counterexample with 3 states:$
88
^x@0 = 1$
99
^x@1 = 2$
1010
^x@2 = 2$
11-
^\[spec2\] F x = 2: PROVED up to bound 10$
11+
^\[p2\] F x = 2: PROVED up to bound 10$
1212
--
1313
^warning: ignoring
1414
--

regression/smv/LTL/smv_ltlspec4.smv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ ASSIGN
66
init(x) := 1;
77
next(x) := 2;
88

9-
LTLSPEC F x=0 -- fails
10-
LTLSPEC F x=2 -- holds
9+
LTLSPEC NAME p1 := F x=0 -- fails
10+
LTLSPEC NAME p2 := F x=2 -- holds

regression/smv/range-type/range_type1.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ range_type1.smv
33
--bound 10
44
^EXIT=0$
55
^SIGNAL=0$
6-
^\[spec1\] AG x != 4: PROVED up to bound 10$
6+
^\[p1\] AG x != 4: PROVED up to bound 10$
77
--
88
^warning: ignoring

regression/smv/range-type/range_type1.smv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ ASSIGN
1919
TRUE: 4;
2020
esac;
2121

22-
SPEC AG x!=4
22+
SPEC NAME p1 := AG x!=4

src/smvlang/parser.y

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,49 @@ fairness_constraint:
372372
;
373373

374374
ctl_specification:
375-
SPEC_Token formula semi_opt { PARSER.module->add_ctlspec(stack_expr($2), stack_expr($1).source_location()); }
375+
SPEC_Token formula semi_opt
376+
{
377+
PARSER.module->add_ctlspec(
378+
stack_expr($2),
379+
stack_expr($1).source_location());
380+
}
376381
| SPEC_Token
382+
| CTLSPEC_Token formula semi_opt
383+
{
384+
PARSER.module->add_ctlspec(
385+
stack_expr($2),
386+
stack_expr($1).source_location());
387+
}
388+
| CTLSPEC_Token
389+
| SPEC_Token NAME_Token identifier BECOMES_Token formula semi_opt
390+
{
391+
PARSER.module->add_ctlspec(
392+
stack_expr($3).id(),
393+
stack_expr($5),
394+
stack_expr($1).source_location());
395+
}
396+
| CTLSPEC_Token NAME_Token identifier BECOMES_Token formula semi_opt
397+
{
398+
PARSER.module->add_ctlspec(
399+
stack_expr($3).id(),
400+
stack_expr($5),
401+
stack_expr($1).source_location());
402+
}
377403
;
378404

379405
ltl_specification:
380-
LTLSPEC_Token formula semi_opt { PARSER.module->add_ltlspec(stack_expr($2), stack_expr($1).source_location()); }
381-
| LTLSPEC_Token
406+
LTLSPEC_Token formula semi_opt
407+
{
408+
PARSER.module->add_ltlspec(stack_expr($2), stack_expr($1).source_location());
409+
}
410+
| LTLSPEC_Token
411+
| LTLSPEC_Token NAME_Token identifier BECOMES_Token formula semi_opt
412+
{
413+
PARSER.module->add_ltlspec(
414+
stack_expr($3).id(),
415+
stack_expr($5),
416+
stack_expr($1).source_location());
417+
}
382418
;
383419

384420
extern_var : variable_name EQUAL_Token QUOTE_Token
@@ -669,9 +705,13 @@ term : variable_name
669705
| term NOTIN_Token term { binary($$, $1, ID_smv_setnotin, $3); }
670706
;
671707

672-
formula_list: formula { init($$); mto($$, $1); }
673-
| formula_list ',' formula { $$=$1; mto($$, $3); }
674-
;
708+
formula_list:
709+
formula { init($$); mto($$, $1); }
710+
| formula_list ',' formula { $$=$1; mto($$, $3); }
711+
;
712+
713+
identifier : STRING_Token
714+
;
675715

676716
variable_name: qstring_list
677717
{

src/smvlang/smv_parse_tree.h

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,22 @@ class smv_parse_treet
6161
{
6262
}
6363

64+
itemt(
65+
item_typet __item_type,
66+
irep_idt __name,
67+
exprt __expr,
68+
source_locationt __location)
69+
: item_type(__item_type),
70+
name(__name),
71+
expr(std::move(__expr)),
72+
location(std::move(__location))
73+
{
74+
}
75+
6476
friend std::string to_string(item_typet i);
6577

6678
item_typet item_type;
79+
std::optional<irep_idt> name;
6780
exprt expr;
6881
source_locationt location;
6982

@@ -163,18 +176,6 @@ class smv_parse_treet
163176
itemt::INVAR, std::move(expr), source_locationt::nil());
164177
}
165178

166-
void add_ctlspec(exprt expr)
167-
{
168-
items.emplace_back(
169-
itemt::CTLSPEC, std::move(expr), source_locationt::nil());
170-
}
171-
172-
void add_ltlspec(exprt expr)
173-
{
174-
items.emplace_back(
175-
itemt::LTLSPEC, std::move(expr), source_locationt::nil());
176-
}
177-
178179
void add_define(exprt lhs, exprt rhs)
179180
{
180181
items.emplace_back(
@@ -210,11 +211,22 @@ class smv_parse_treet
210211
items.emplace_back(itemt::CTLSPEC, std::move(expr), std::move(location));
211212
}
212213

214+
void add_ctlspec(irep_idt name, exprt expr, source_locationt location)
215+
{
216+
items.emplace_back(
217+
itemt::CTLSPEC, name, std::move(expr), std::move(location));
218+
}
219+
213220
void add_ltlspec(exprt expr, source_locationt location)
214221
{
215222
items.emplace_back(itemt::LTLSPEC, std::move(expr), location);
216223
}
217224

225+
void add_ltlspec(irep_idt name, exprt expr, source_locationt location)
226+
{
227+
items.emplace_back(itemt::LTLSPEC, name, std::move(expr), location);
228+
}
229+
218230
void add_define(exprt expr, source_locationt location)
219231
{
220232
items.emplace_back(itemt::DEFINE, std::move(expr), std::move(location));

src/smvlang/smv_typecheck.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,11 @@ void smv_typecheckt::convert(smv_parse_treet::modulet &smv_module)
15901590
{
15911591
symbolt spec_symbol;
15921592

1593-
spec_symbol.base_name = "spec" + std::to_string(nr++);
1593+
if(it->name.has_value())
1594+
spec_symbol.base_name = it->name.value();
1595+
else
1596+
spec_symbol.base_name = "spec" + std::to_string(nr++);
1597+
15941598
spec_symbol.name =
15951599
id2string(smv_module.name) + "::" + id2string(spec_symbol.base_name);
15961600
spec_symbol.module = smv_module.name;

0 commit comments

Comments
 (0)