vnnlib 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of vnnlib might be problematic. Click here for more details.
- vnnlib-0.0.1/LICENSE.txt +9 -0
- vnnlib-0.0.1/PKG-INFO +102 -0
- vnnlib-0.0.1/README.md +60 -0
- vnnlib-0.0.1/pyproject.toml +66 -0
- vnnlib-0.0.1/setup.cfg +4 -0
- vnnlib-0.0.1/setup.py +16 -0
- vnnlib-0.0.1/tests/test_cli.py +45 -0
- vnnlib-0.0.1/tests/test_compat.py +430 -0
- vnnlib-0.0.1/tests/test_parser.py +124 -0
- vnnlib-0.0.1/tests/test_parser_errors.py +62 -0
- vnnlib-0.0.1/tests/test_tokenizer.py +100 -0
- vnnlib-0.0.1/tests/test_tokenizer_errors.py +62 -0
- vnnlib-0.0.1/vnnlib/__init__.py +4 -0
- vnnlib-0.0.1/vnnlib/__main__.py +3 -0
- vnnlib-0.0.1/vnnlib/__version__.py +1 -0
- vnnlib-0.0.1/vnnlib/cli.py +70 -0
- vnnlib-0.0.1/vnnlib/compat.py +290 -0
- vnnlib-0.0.1/vnnlib/errors.py +13 -0
- vnnlib-0.0.1/vnnlib/parser.py +269 -0
- vnnlib-0.0.1/vnnlib/tokenizer.py +143 -0
- vnnlib-0.0.1/vnnlib/transformer.py +78 -0
- vnnlib-0.0.1/vnnlib.egg-info/PKG-INFO +102 -0
- vnnlib-0.0.1/vnnlib.egg-info/SOURCES.txt +24 -0
- vnnlib-0.0.1/vnnlib.egg-info/dependency_links.txt +1 -0
- vnnlib-0.0.1/vnnlib.egg-info/requires.txt +27 -0
- vnnlib-0.0.1/vnnlib.egg-info/top_level.txt +2 -0
vnnlib-0.0.1/LICENSE.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present David Shriver <davidshriver@outlook.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
vnnlib-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: vnnlib
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Author-email: David Shriver <davidshriver@outlook.com>
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Documentation, https://github.com/dlshriver/vnnlib#readme
|
|
7
|
+
Project-URL: Issues, https://github.com/dlshriver/vnnlib/issues
|
|
8
|
+
Project-URL: Source, https://github.com/dlshriver/vnnlib
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE.txt
|
|
21
|
+
Requires-Dist: numpy>=1.19
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: mypy>=1.5.0; extra == "dev"
|
|
24
|
+
Requires-Dist: black>=23.1.0; extra == "dev"
|
|
25
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
26
|
+
Requires-Dist: coverage>=7.1.0; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest>=7.2.1; extra == "dev"
|
|
28
|
+
Provides-Extra: lint
|
|
29
|
+
Requires-Dist: mypy>=1.8.0; extra == "lint"
|
|
30
|
+
Provides-Extra: style
|
|
31
|
+
Requires-Dist: black>=23.1.0; extra == "style"
|
|
32
|
+
Requires-Dist: isort>=5.12.0; extra == "style"
|
|
33
|
+
Provides-Extra: test
|
|
34
|
+
Requires-Dist: coverage>=7.1.0; extra == "test"
|
|
35
|
+
Requires-Dist: pytest>=7.2.1; extra == "test"
|
|
36
|
+
Provides-Extra: docs
|
|
37
|
+
Requires-Dist: furo>=2022.12.7; extra == "docs"
|
|
38
|
+
Requires-Dist: sphinx>=6.1.3; extra == "docs"
|
|
39
|
+
Provides-Extra: dist
|
|
40
|
+
Requires-Dist: build; extra == "dist"
|
|
41
|
+
Requires-Dist: twine; extra == "dist"
|
|
42
|
+
|
|
43
|
+
# vnnlib
|
|
44
|
+
|
|
45
|
+
[](https://pypi.org/project/vnnlib)
|
|
46
|
+
[](https://pypi.org/project/vnnlib)
|
|
47
|
+
|
|
48
|
+
-----
|
|
49
|
+
|
|
50
|
+
A python package for parsing neural network properties in the [VNN-LIB format](https://www.vnnlib.org/).
|
|
51
|
+
It should currently parse a superset of the VNN-LIB spec that was supported by the [example parser](https://github.com/stanleybak/nnenum/blob/master/src/nnenum/vnnlib.py) written by Stan Bak for [VNN-COMP](https://sites.google.com/view/vnn2023), and will produce compiled specs in the same format.
|
|
52
|
+
Additionally, we allow parsing of gzip, bzip2, and lzma compressed specs.
|
|
53
|
+
|
|
54
|
+
> Our parser is currently slower for some large files than the previous scripts due to the increased specification support.
|
|
55
|
+
> However, we expect significant optimization opportunities are available, and that overhead will decrease over time.
|
|
56
|
+
|
|
57
|
+
> This package is still alpha software and APIs other than the compatibility API may change before the first release.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
For the latest stable version, you can install from PyPI with:
|
|
63
|
+
|
|
64
|
+
```console
|
|
65
|
+
pip install vnnlib
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
For the latest updates of `vnnlib`, you can pip install directly from the GitHub repo with:
|
|
69
|
+
|
|
70
|
+
```console
|
|
71
|
+
pip install git+https://github.com/dlshriver/vnnlib.git@main
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Usage
|
|
75
|
+
|
|
76
|
+
This package can be used as a drop-in replacement for the VNN-COMP utility script by importing
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from vnnlib.compat import read_vnnlib_simple
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
wherever you previously imported `read_vnnlib_simple`.
|
|
83
|
+
|
|
84
|
+
### Standalone
|
|
85
|
+
|
|
86
|
+
The parser can also be used to compile vnnlib ahead of time to reduce future property read times. The result of parsing will be pickled and saved to the location specified.
|
|
87
|
+
|
|
88
|
+
```console
|
|
89
|
+
python -m vnnlib [FILE] --compat -o [OUTPUTFILE]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### API
|
|
93
|
+
|
|
94
|
+
We provide a full VNN-LIB parser which will generate an AST for a given specification.
|
|
95
|
+
To manipulate this AST to generate useful representations that can be dispatched to a verifier, we provide a transformer class which visits the nodes of the AST.
|
|
96
|
+
We implement one version of this to parse and generate outputs in the format used in prior years of VNN-COMP in `vnnlib/compat.py`
|
|
97
|
+
|
|
98
|
+
> Documentation will hopefully be coming soon.
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
`vnnlib` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
|
vnnlib-0.0.1/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# vnnlib
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/vnnlib)
|
|
4
|
+
[](https://pypi.org/project/vnnlib)
|
|
5
|
+
|
|
6
|
+
-----
|
|
7
|
+
|
|
8
|
+
A python package for parsing neural network properties in the [VNN-LIB format](https://www.vnnlib.org/).
|
|
9
|
+
It should currently parse a superset of the VNN-LIB spec that was supported by the [example parser](https://github.com/stanleybak/nnenum/blob/master/src/nnenum/vnnlib.py) written by Stan Bak for [VNN-COMP](https://sites.google.com/view/vnn2023), and will produce compiled specs in the same format.
|
|
10
|
+
Additionally, we allow parsing of gzip, bzip2, and lzma compressed specs.
|
|
11
|
+
|
|
12
|
+
> Our parser is currently slower for some large files than the previous scripts due to the increased specification support.
|
|
13
|
+
> However, we expect significant optimization opportunities are available, and that overhead will decrease over time.
|
|
14
|
+
|
|
15
|
+
> This package is still alpha software and APIs other than the compatibility API may change before the first release.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
For the latest stable version, you can install from PyPI with:
|
|
21
|
+
|
|
22
|
+
```console
|
|
23
|
+
pip install vnnlib
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
For the latest updates of `vnnlib`, you can pip install directly from the GitHub repo with:
|
|
27
|
+
|
|
28
|
+
```console
|
|
29
|
+
pip install git+https://github.com/dlshriver/vnnlib.git@main
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
This package can be used as a drop-in replacement for the VNN-COMP utility script by importing
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from vnnlib.compat import read_vnnlib_simple
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
wherever you previously imported `read_vnnlib_simple`.
|
|
41
|
+
|
|
42
|
+
### Standalone
|
|
43
|
+
|
|
44
|
+
The parser can also be used to compile vnnlib ahead of time to reduce future property read times. The result of parsing will be pickled and saved to the location specified.
|
|
45
|
+
|
|
46
|
+
```console
|
|
47
|
+
python -m vnnlib [FILE] --compat -o [OUTPUTFILE]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### API
|
|
51
|
+
|
|
52
|
+
We provide a full VNN-LIB parser which will generate an AST for a given specification.
|
|
53
|
+
To manipulate this AST to generate useful representations that can be dispatched to a verifier, we provide a transformer class which visits the nodes of the AST.
|
|
54
|
+
We implement one version of this to parse and generate outputs in the format used in prior years of VNN-COMP in `vnnlib/compat.py`
|
|
55
|
+
|
|
56
|
+
> Documentation will hopefully be coming soon.
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
`vnnlib` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools", "mypy[mypyc]"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vnnlib"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = ""
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
authors = [{ name = "David Shriver", email = "davidshriver@outlook.com" }]
|
|
12
|
+
keywords = []
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 4 - Beta",
|
|
15
|
+
"Programming Language :: Python",
|
|
16
|
+
"Programming Language :: Python :: 3.7",
|
|
17
|
+
"Programming Language :: Python :: 3.8",
|
|
18
|
+
"Programming Language :: Python :: 3.9",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
22
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
23
|
+
]
|
|
24
|
+
requires-python = ">=3.8"
|
|
25
|
+
dependencies = ["numpy>=1.19"]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Documentation = "https://github.com/dlshriver/vnnlib#readme"
|
|
29
|
+
Issues = "https://github.com/dlshriver/vnnlib/issues"
|
|
30
|
+
Source = "https://github.com/dlshriver/vnnlib"
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
dev = [
|
|
34
|
+
"mypy>=1.5.0",
|
|
35
|
+
"black>=23.1.0",
|
|
36
|
+
"isort>=5.12.0",
|
|
37
|
+
"coverage>=7.1.0",
|
|
38
|
+
"pytest>=7.2.1",
|
|
39
|
+
]
|
|
40
|
+
lint = ["mypy>=1.8.0"]
|
|
41
|
+
style = ["black>=23.1.0", "isort>=5.12.0"]
|
|
42
|
+
test = ["coverage>=7.1.0", "pytest>=7.2.1"]
|
|
43
|
+
docs = ["furo>=2022.12.7", "sphinx>=6.1.3"]
|
|
44
|
+
dist = ["build", "twine"]
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.dynamic]
|
|
47
|
+
version = { attr = "vnnlib.__version__.__version__" }
|
|
48
|
+
|
|
49
|
+
[tool.setuptools.packages.find]
|
|
50
|
+
include = ["vnnlib"]
|
|
51
|
+
|
|
52
|
+
[tool.coverage.run]
|
|
53
|
+
branch = true
|
|
54
|
+
command_line = "-m pytest"
|
|
55
|
+
parallel = true
|
|
56
|
+
source = ["vnnlib"]
|
|
57
|
+
omit = ["vnnlib/__main__.py"]
|
|
58
|
+
|
|
59
|
+
[tool.isort]
|
|
60
|
+
profile = "black"
|
|
61
|
+
src_paths = ["vnnlib", "test"]
|
|
62
|
+
|
|
63
|
+
[tool.pytest.ini_options]
|
|
64
|
+
minversion = "7.0"
|
|
65
|
+
addopts = "--ff --verbose --import-mode=importlib"
|
|
66
|
+
testpaths = ["tests"]
|
vnnlib-0.0.1/setup.cfg
ADDED
vnnlib-0.0.1/setup.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from setuptools import setup
|
|
3
|
+
from mypyc.build import mypycify
|
|
4
|
+
|
|
5
|
+
setup(
|
|
6
|
+
name="vnnlib",
|
|
7
|
+
packages=["vnnlib"],
|
|
8
|
+
ext_modules=mypycify(
|
|
9
|
+
[
|
|
10
|
+
"vnnlib/tokenizer.py",
|
|
11
|
+
"vnnlib/parser.py",
|
|
12
|
+
]
|
|
13
|
+
)
|
|
14
|
+
if sys.implementation.name == "cpython"
|
|
15
|
+
else [],
|
|
16
|
+
)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
4
|
+
from vnnlib.cli import main
|
|
5
|
+
from vnnlib.errors import VnnLibError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_nano(tmp_path):
|
|
9
|
+
vnnlib_path = tmp_path / "test.vnnlib"
|
|
10
|
+
with open(vnnlib_path, "w+") as f:
|
|
11
|
+
f.write(
|
|
12
|
+
"(declare-const X_0 Real)\n(declare-const Y_0 Real)\n(assert (>= X_0 -1))\n(assert (<= X_0 1))\n(assert (<= Y_0 -1))\n"
|
|
13
|
+
)
|
|
14
|
+
out_path = tmp_path / "out.npy"
|
|
15
|
+
|
|
16
|
+
result = main([str(vnnlib_path), "-o", str(out_path), "--compat"])
|
|
17
|
+
assert result is None
|
|
18
|
+
|
|
19
|
+
output = np.load(out_path, allow_pickle=True)
|
|
20
|
+
assert output == [([[-1, 1]], [(np.array([[1]]), np.array([[-1]]))])]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_unsupported_spec_format(tmp_path):
|
|
24
|
+
vnnlib_path = tmp_path / "test.py"
|
|
25
|
+
with open(vnnlib_path, "w+"):
|
|
26
|
+
pass
|
|
27
|
+
out_path = tmp_path / "out.npy"
|
|
28
|
+
|
|
29
|
+
with pytest.raises(VnnLibError, match="Unsupported file type: .py"):
|
|
30
|
+
_ = main([str(vnnlib_path), "-o", str(out_path), "--compat"])
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_unsupported_output_format(tmp_path):
|
|
34
|
+
vnnlib_path = tmp_path / "test.vnnlib"
|
|
35
|
+
with open(vnnlib_path, "w+") as f:
|
|
36
|
+
f.write(
|
|
37
|
+
"(declare-const X_0 Real)\n(declare-const Y_0 Real)\n(assert (>= X_0 -1))\n(assert (<= X_0 1))\n(assert (<= Y_0 -1))\n"
|
|
38
|
+
)
|
|
39
|
+
out_path = tmp_path / "out.npy"
|
|
40
|
+
|
|
41
|
+
with pytest.raises(
|
|
42
|
+
NotImplementedError,
|
|
43
|
+
match="Currently only the VNN-COMP-1 output format is supported",
|
|
44
|
+
):
|
|
45
|
+
_ = main([str(vnnlib_path), "-o", str(out_path)])
|