Skip to content

Commit 7d64ebb

Browse files
committed
Merge branch 'atlas-labsparse'
2 parents 048ffc7 + 513d401 commit 7d64ebb

File tree

18 files changed

+321
-375
lines changed

18 files changed

+321
-375
lines changed

HISTORY

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Version 4.0 - 2023-05
2+
3+
C translation: general improvements
4+
LAbS: Added conditional processes (cond => P) (C encoding only)
5+
LAbS: Added multi-dimensional arrays (e.g., arr[x, y, z]) (C encoding only)
6+
SLiVER: Fixed ESBMC backend for SMT-based BMC
7+
SLiVER: Improved performance of CBMC simulation workflow
8+
19
Version 3.0 - 2022-07
210

311
LAbS: Added blocks of actions "{a1; a2; ... ; an}"
@@ -9,7 +17,6 @@ LAbS: Added nondeterministic agent selection "pick"
917
LAbS: Added ternary operator "if cond then expr1 else expr2"
1018
LAbS: Underscores ("_") can now be used within all names (but not at the beginning of a name)
1119
LAbS: Arithmetic expressions can now be used where a Boolean expression is expected ("expr" is desugared into "expr != 0")
12-
1320
SLiVER: CBMC backend now supports simulation
1421
SLiVER: Added a compositional CADP backend "cadp-comp" (experimental)
1522

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ VERSION := $(strip $(shell grep version sliver/app/__about__.py | grep = | sed '
1717
RELEASENAME = sliver-v$(VERSION)_$(strip $(subst -,_, ${platform}))
1818
BUILD_DIR = build/$(platform)
1919
SLIVER_DIR = $(BUILD_DIR)/sliver
20+
BLACKLIST = $(shell git ls-files --others --exclude-standard)
2021

2122
build/%/sliver/labs/LabsTranslate : $(labs_sources) $(labs_templates)
2223
@echo Building LabsTranslate...
@@ -28,6 +29,8 @@ build/%/sliver.py :
2829
@cp ./HISTORY $(@D) ;
2930
@cp ./LICENSE $(@D) ;
3031
@cp ./*.* $(@D) ;
32+
@# Remove untracked files from release directory
33+
@rm $(foreach f, $(BLACKLIST), $(@D)/$(f)) ;
3134

3235
build/%/examples/README.md : $(labs_examples)
3336
@echo Copying examples...

README.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
SLiVER 4.0-230417
3-
18 April 2023
2+
SLiVER 4.0
3+
10 May 2023
44

55
The SLiVER LAbS VERification tool
66

@@ -27,13 +27,19 @@ sliver/ SLiVER code
2727

2828
To install SLiVER, please follow the steps below:
2929

30-
1. install Python 3.10 or higher
30+
1. install Python 3.10 or higher.
31+
We recommend setting up a dedicated Python installation/environment
32+
by using pyenv or similar tools.
3133

3234
2. create a directory, suppose this is called /workspace
3335

3436
3. extract the entire package contents in /workspace
3537

36-
4. set execution permissions (chmod +x) for sliver.py and cbmc-simulator
38+
4. set execution permissions (chmod +x) for the following files:
39+
- sliver.py
40+
- sliver/cbmc/cbmc-simulator
41+
- sliver/cbmc/cbmc-5-74
42+
- sliver/minisat/minisat
3743

3844
5. Install dependencies with (pip install -r requirements.txt)
3945

sliver/analysis/value_analysis.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from itertools import product
88

99
from ..app.cli import Args
10-
from ..labsparse.labs_ast import Expr, QueryResult
11-
from ..labsparse.labs_parser import Attr, NodeType, parse_to_dict
10+
from ..labsparse.labsparse.labs_ast import Expr, QueryResult
11+
from ..labsparse.labsparse.labs_parser import Attr, NodeType, parse_to_dict
1212

1313

1414
def merge(s0, s1, State):
@@ -47,7 +47,7 @@ def make_init(info, local_names, domain):
4747
else:
4848
s0[var.name] = abstract
4949

50-
s0["id"] = domain.abstract(*range(0, info.spawn.num_agents() - 1))
50+
s0["id"] = domain.abstract_range(range(0, info.spawn.num_agents()))
5151
State = namedtuple("State", [*local_names, *s0.keys()])
5252
for x in local_names:
5353
s0[x] = domain.NO
@@ -273,7 +273,7 @@ def value_analysis(cli, info, domain):
273273
blocks.update(n for n in node.walk() if n(NodeType.BLOCK))
274274
guards.update(
275275
(a, n) for n in node.walk()
276-
if n(NodeType.GUARDED))
276+
if n(NodeType.GUARDED) or n(NodeType.CONDITIONAL))
277277
calls = (
278278
n[Attr.NAME] for n in node.walk()
279279
if n(NodeType.CALL)

sliver/app/__about__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
__summary__ = "The SLiVER LAbS VERification tool"
77
__uri__ = "https://github.com/labs-lang/sliver"
88

9-
__version__ = "4.0-230418"
10-
__date__ = "18 April 2023"
9+
__version__ = "4.0"
10+
__date__ = "10 May 2023"

sliver/app/cli.py

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import logging
44
import sys
5+
import time
56
from dataclasses import dataclass
67
from enum import Enum
78

9+
import click
10+
811
from .__about__ import __date__, __summary__, __version__
912

1013
log = logging.getLogger('backend')
@@ -13,22 +16,23 @@
1316
class Args(Enum):
1417
BACKEND = "backend"
1518
BV = "bv"
19+
CONCRETIZATION = "concretization"
1620
CORES = "cores"
21+
CORES_FROM = "from"
22+
CORES_TO = "to"
1723
DEBUG = "debug"
1824
FAIR = "fair"
19-
CORES_FROM = "from"
20-
KEEP_FILES = "keep_files"
2125
INCLUDE = "include"
22-
PROPERTY = "property"
23-
CONCRETIZATION = "concretization"
26+
KEEP_FILES = "keep_files"
2427
NO_PROPERTIES = "no_properties"
28+
PROPERTY = "property"
29+
RND_SEED = "rnd_seed"
2530
SHOW = "show"
2631
SIMULATE = "simulate"
2732
STEPS = "steps"
2833
SYNC = "sync"
2934
TIMEOUT = "timeout"
3035
TRANSLATE_CEX = "translate_cex"
31-
CORES_TO = "to"
3236
VALUES = "values"
3337
VERBOSE = "verbose"
3438

@@ -43,53 +47,37 @@ class Args(Enum):
4347

4448
HELPMSG = {
4549
Args.BACKEND: "Backend to use in verification mode.",
46-
4750
Args.BV: "Enable bitvector optimization where supported.",
48-
4951
Args.CONCRETIZATION: "Type of concretization (only for simulation).",
50-
52+
Args.CORES_FROM: "Parallel analysis: partition start.",
53+
Args.CORES_TO: "Parallel analysis: partition end.",
5154
Args.CORES: "Number of CPU cores for parallel analysis.",
52-
5355
Args.DEBUG: "Enable additional checks in the backend.",
54-
5556
Args.FAIR: "Enforce fair interleaving of components.",
56-
57-
Args.CORES_FROM: "Parallel analysis: partition start.",
58-
59-
Args.KEEP_FILES: "Do not remove intermediate files.",
60-
6157
Args.INCLUDE: (
6258
"Add custom code to generated program "
6359
"(may be specified multiple times)."),
64-
65-
Args.PROPERTY: "Property to consider, others will be ignored.",
66-
60+
Args.KEEP_FILES: "Do not remove intermediate files.",
6761
Args.NO_PROPERTIES: "Ignore all properties.",
68-
62+
Args.PROPERTY: "Property to consider, others will be ignored.",
63+
Args.RND_SEED: (
64+
"Seed for the random number generator."
65+
"If none is given, the current time will be used."),
6966
Args.SHOW: "Print emulation program and exit.",
70-
7167
Args.SIMULATE: (
7268
"Number of simulation traces to generate. "
7369
"If 0, run in verification mode."),
74-
7570
Args.STEPS: (
7671
"Number of system evolutions. "
7772
"If 0, generate an unbounded system."),
78-
7973
Args.SYNC: "Force synchronous stigmergy messages.",
80-
8174
Args.TIMEOUT: (
8275
"Configure time limit (seconds). "
8376
"Set to 0 to disable timeout."),
84-
8577
Args.TRANSLATE_CEX: (
8678
"Translate given counterexample to LAbS and exit."
8779
),
88-
89-
Args.CORES_TO: "Parallel analysis: partition end.",
90-
9180
Args.VALUES: "assign values for parameterised specification (key=value)",
92-
9381
Args.VERBOSE: "Print additional messages from the backend."
9482
}
9583

@@ -100,31 +88,51 @@ class Args(Enum):
10088
Args.CORES: 1,
10189
Args.DEBUG: False,
10290
Args.FAIR: False,
103-
Args.CORES_FROM: None,
10491
Args.INCLUDE: tuple(),
10592
Args.KEEP_FILES: False,
106-
Args.PROPERTY: None,
10793
Args.NO_PROPERTIES: False,
10894
Args.SHOW: False,
10995
Args.SIMULATE: 0,
11096
Args.STEPS: 0,
11197
Args.SYNC: False,
11298
Args.TIMEOUT: 0,
113-
Args.TRANSLATE_CEX: None,
114-
Args.CORES_TO: None,
11599
Args.VALUES: tuple(),
116100
Args.VERBOSE: False
117101
}
118102

119103

104+
__existing = click.Path(exists=True)
105+
__nonnegative = click.IntRange(min=0)
106+
107+
TYPES = {
108+
Args.CONCRETIZATION: click.Choice(("src", "sat", "none")),
109+
Args.CORES_FROM: __nonnegative,
110+
Args.CORES_TO: __nonnegative,
111+
Args.CORES: __nonnegative,
112+
Args.INCLUDE: __existing,
113+
Args.RND_SEED: click.IntRange(min=1),
114+
Args.SIMULATE: __nonnegative,
115+
Args.STEPS: __nonnegative,
116+
Args.TIMEOUT: __nonnegative,
117+
Args.TRANSLATE_CEX: __existing
118+
}
119+
120+
120121
def CLICK(name, **kwargs):
121-
return {
122-
"help": HELPMSG[name],
122+
result = {
123123
"show_default": name in DEFAULTS,
124-
**({} if DEFAULTS[name] is None else {"default": DEFAULTS[name]}),
125124
**kwargs
126125
}
127126

127+
def maybe_add_from(some_dict, kwarg):
128+
if name in some_dict:
129+
result[kwarg] = some_dict[name]
130+
131+
maybe_add_from(HELPMSG, "help")
132+
maybe_add_from(DEFAULTS, "default")
133+
maybe_add_from(TYPES, "type")
134+
return result
135+
128136

129137
class CliArgs(dict):
130138
def __init__(self, file, __dict) -> None:
@@ -136,14 +144,18 @@ def __init__(self, file, __dict) -> None:
136144
self.externs[k] = int(v)
137145

138146
def __getitem__(self, key: Args):
139-
return self.get(key.value, DEFAULTS[key])
147+
return self.get(key.value, DEFAULTS.get(key))
140148

141149
def __setitem__(self, key: Args, value):
142150
if isinstance(key, Args):
143151
self[key.value] = value
144152
else:
145153
super().__setitem__(key, value)
146154

155+
def get_seed(self) -> int:
156+
seed = self[Args.RND_SEED]
157+
return time.time_ns() % (1 << 32) if seed is None else seed
158+
147159

148160
class ExitStatus(Enum):
149161
SUCCESS = 0

sliver/app/main.py

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,35 @@
1414
__file__ = inspect.getfile(inspect.currentframe())
1515

1616
__DIR = Path(__file__).parent.resolve()
17-
__existing = click.Path(exists=True)
17+
backends_type = click.Choice(tuple(ALL_BACKENDS.keys()))
18+
1819
log = logging.getLogger("sliver")
1920

2021

2122
@click.command(help=LONGDESCR)
2223
@click.version_option(__version__, prog_name=__title__.lower())
23-
@click.argument('file', required=True, type=__existing)
24+
@click.argument('file', required=True, type=click.Path(exists=True))
2425
@click.argument('values', nargs=-1)
25-
@click.option('--backend',
26-
type=click.Choice(tuple(ALL_BACKENDS.keys())),
27-
**CLICK(Args.BACKEND))
28-
@click.option('--concretization',
29-
type=click.Choice(("src", "sat", "none")),
30-
**CLICK(Args.CONCRETIZATION))
26+
@click.option('--backend', **CLICK(Args.BACKEND, type=backends_type))
27+
@click.option('--concretization', **CLICK(Args.CONCRETIZATION))
28+
@click.option('--bv/--no-bv', **CLICK(Args.BV))
29+
@click.option('--cores', **CLICK(Args.CORES))
3130
@click.option('--debug', **CLICK(Args.DEBUG, is_flag=True))
3231
@click.option('--fair/--no-fair', **CLICK(Args.FAIR))
33-
@click.option('--bv/--no-bv', **CLICK(Args.BV))
34-
@click.option('--simulate', **CLICK(Args.SIMULATE, type=int))
32+
@click.option('--from', **CLICK(Args.CORES_FROM))
33+
@click.option('--keep-files', **CLICK(Args.KEEP_FILES, is_flag=True))
34+
@click.option('--no-properties', **CLICK(Args.NO_PROPERTIES, is_flag=True))
35+
@click.option('--property', **CLICK(Args.PROPERTY))
36+
@click.option('--rnd-seed', **CLICK(Args.RND_SEED))
3537
@click.option('--show', **CLICK(Args.SHOW, is_flag=True))
36-
@click.option('--steps', **CLICK(Args.STEPS, type=int))
38+
@click.option('--simulate', **CLICK(Args.SIMULATE))
39+
@click.option('--steps', **CLICK(Args.STEPS))
3740
@click.option('--sync/--no-sync', **CLICK(Args.SYNC))
38-
@click.option('--timeout', **CLICK(Args.TIMEOUT, type=int))
39-
@click.option('--cores', **CLICK(Args.CORES, type=int))
40-
@click.option('--from', **CLICK(Args.CORES_FROM, type=int))
41-
@click.option('--to', **CLICK(Args.CORES_TO, type=int))
41+
@click.option('--timeout', **CLICK(Args.TIMEOUT))
42+
@click.option('--to', **CLICK(Args.CORES_TO))
4243
@click.option('--verbose', **CLICK(Args.VERBOSE, is_flag=True))
43-
@click.option('--no-properties', **CLICK(Args.NO_PROPERTIES, is_flag=True))
44-
@click.option('--property', **CLICK(Args.PROPERTY))
45-
@click.option('--keep-files', **CLICK(Args.KEEP_FILES, is_flag=True))
46-
@click.option('--translate-cex',
47-
**CLICK(Args.TRANSLATE_CEX, type=__existing))
48-
@click.option('--include',
49-
multiple=True, type=__existing,
50-
**CLICK(Args.INCLUDE))
44+
@click.option('--translate-cex', **CLICK(Args.TRANSLATE_CEX))
45+
@click.option('--include', multiple=True, **CLICK(Args.INCLUDE))
5146
def main(file, **kwargs):
5247
cli = CliArgs(file, kwargs)
5348
backend_arg, simulate, show = (

0 commit comments

Comments
 (0)