proofside 0.1.0__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.
- proofside-0.1.0/LICENSE +202 -0
- proofside-0.1.0/PKG-INFO +373 -0
- proofside-0.1.0/README.md +361 -0
- proofside-0.1.0/proofside/__init__.py +3 -0
- proofside-0.1.0/proofside/__main__.py +6 -0
- proofside-0.1.0/proofside/acceptance.py +77 -0
- proofside-0.1.0/proofside/artifacts.py +9 -0
- proofside-0.1.0/proofside/batch.py +309 -0
- proofside-0.1.0/proofside/cli.py +423 -0
- proofside-0.1.0/proofside/contracts.py +372 -0
- proofside-0.1.0/proofside/proposal.py +290 -0
- proofside-0.1.0/proofside/specification.py +129 -0
- proofside-0.1.0/proofside.egg-info/PKG-INFO +373 -0
- proofside-0.1.0/proofside.egg-info/SOURCES.txt +27 -0
- proofside-0.1.0/proofside.egg-info/dependency_links.txt +1 -0
- proofside-0.1.0/proofside.egg-info/entry_points.txt +2 -0
- proofside-0.1.0/proofside.egg-info/requires.txt +1 -0
- proofside-0.1.0/proofside.egg-info/top_level.txt +1 -0
- proofside-0.1.0/pyproject.toml +24 -0
- proofside-0.1.0/setup.cfg +4 -0
- proofside-0.1.0/tests/test_acceptance.py +174 -0
- proofside-0.1.0/tests/test_artifacts.py +22 -0
- proofside-0.1.0/tests/test_batch.py +240 -0
- proofside-0.1.0/tests/test_batch_proposal.py +317 -0
- proofside-0.1.0/tests/test_cli.py +125 -0
- proofside-0.1.0/tests/test_contracts.py +384 -0
- proofside-0.1.0/tests/test_integration.py +177 -0
- proofside-0.1.0/tests/test_proposal.py +862 -0
- proofside-0.1.0/tests/test_specification.py +306 -0
proofside-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
proofside-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: proofside
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A small formal-verification sidecar for typed mathematical Python
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Repository, https://github.com/kli0n2323/proofside
|
|
7
|
+
Requires-Python: <3.15,>=3.12
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: nagini==1.3.1
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# Proofside
|
|
14
|
+
|
|
15
|
+
**State the math. Review the contract. Verify the code.**
|
|
16
|
+
|
|
17
|
+
Proofside is a small formal-verification sidecar for typed mathematical Python.
|
|
18
|
+
Declare the math a function is supposed to implement, review an explicit
|
|
19
|
+
contract, then ask Nagini/Viper whether the implementation satisfies it.
|
|
20
|
+
|
|
21
|
+
Proofside annotations keep equations and plain-language intent beside the code
|
|
22
|
+
but separate from the implementation body. An optional model can translate that
|
|
23
|
+
declared specification into an untrusted candidate contract without seeing the
|
|
24
|
+
body by default. No model is required: contracts may also be authored manually,
|
|
25
|
+
and a model never determines whether a proof succeeds.
|
|
26
|
+
|
|
27
|
+
## Quick start
|
|
28
|
+
|
|
29
|
+
Proofside supports 64-bit Python 3.12–3.14 and requires a 64-bit Java 11+
|
|
30
|
+
runtime. From a checkout:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
python -m venv .venv
|
|
34
|
+
# Linux/macOS: source .venv/bin/activate
|
|
35
|
+
# Windows PowerShell: .venv\Scripts\Activate.ps1
|
|
36
|
+
python -m pip install .
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Start with a reproducible model-free verification:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
proofside check examples/sidecar/shot_budget_plain.py::allocate_remaining \
|
|
43
|
+
--contract examples/sidecar/shot_budget_contract.json
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The contract assumes nonnegative counts with `first_bucket <= total_shots` and
|
|
47
|
+
guarantees a nonnegative result that conserves the declared budget. The command
|
|
48
|
+
prints the contract, `VERIFIED`, and an explicit proof boundary.
|
|
49
|
+
|
|
50
|
+
Now check the nearly identical broken implementation:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
proofside check examples/sidecar/shot_budget_plain_bad.py::allocate_remaining \
|
|
54
|
+
--contract examples/sidecar/shot_budget_contract.json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Nagini reports `FAILED` because the extra `+ 1` prevents budget conservation.
|
|
58
|
+
Prefixing commands with `python -m proofside` is also supported.
|
|
59
|
+
|
|
60
|
+
## Examples
|
|
61
|
+
|
|
62
|
+
| Path | Purpose |
|
|
63
|
+
| --- | --- |
|
|
64
|
+
| `examples/sidecar/` | Model-free Proofside JSON contract workflow: good and bad implementations share one explicit contract. |
|
|
65
|
+
| `examples/nagini/` | Direct handwritten Nagini contracts. Proofside supports this path but does not parse Nagini annotations back into its IR. |
|
|
66
|
+
| `examples/annotated/shot_budget_annotated.py` | Smallest annotation-first specification and proposal example. |
|
|
67
|
+
| `examples/annotated/model_workflow_stress.py` | Eight-function model-assisted stress fixture with both matching and intentionally mismatched implementations. Its annotations are normative; bodies are withheld by default. |
|
|
68
|
+
| `examples/research/` | Research-derived bookkeeping example with careful, limited provenance. |
|
|
69
|
+
| `examples/unsupported/` | A source boundary that Proofside explicitly reports as unsupported. |
|
|
70
|
+
|
|
71
|
+
## Declare the intended math
|
|
72
|
+
|
|
73
|
+
Proofside recognizes two case-sensitive comments in the contiguous comment
|
|
74
|
+
block immediately above a supported function:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
# proofside equation: result = total_shots - first_bucket
|
|
78
|
+
# proofside intent: Return the unallocated portion of the declared budget.
|
|
79
|
+
def allocate_remaining(total_shots: int, first_bucket: int) -> int:
|
|
80
|
+
return total_shots - first_bucket
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Equation and intent text is opaque, user-authored specification material.
|
|
84
|
+
Proofside preserves it rather than interpreting, normalizing, or checking the
|
|
85
|
+
mathematics at annotation-extraction time. Multiple equation or intent lines
|
|
86
|
+
are allowed.
|
|
87
|
+
|
|
88
|
+
The specification says what the function is supposed to mean; the implementation
|
|
89
|
+
is the object later checked against the accepted contract. They have different
|
|
90
|
+
roles.
|
|
91
|
+
|
|
92
|
+
## From specification to proof
|
|
93
|
+
|
|
94
|
+
```text
|
|
95
|
+
user-declared specification
|
|
96
|
+
equation / intent / selected sources
|
|
97
|
+
↓
|
|
98
|
+
optional model translation
|
|
99
|
+
↓
|
|
100
|
+
candidate contract
|
|
101
|
+
NOT VERIFIED
|
|
102
|
+
↓
|
|
103
|
+
human review/edit
|
|
104
|
+
↓
|
|
105
|
+
accepted contract ─────────┐
|
|
106
|
+
NOT VERIFIED │
|
|
107
|
+
├→ selected explicit contract
|
|
108
|
+
manually authored JSON contract ─────────┘
|
|
109
|
+
NOT VERIFIED
|
|
110
|
+
+
|
|
111
|
+
implementation under test
|
|
112
|
+
↓
|
|
113
|
+
deterministic Proofside lowering
|
|
114
|
+
↓
|
|
115
|
+
Nagini / Viper / Z3
|
|
116
|
+
↓
|
|
117
|
+
VERIFIED / FAILED / UNSUPPORTED / ERROR
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Handwritten Nagini contracts provide a lower-level route directly to Nagini.
|
|
121
|
+
In every route, Nagini/Viper—not a model—decides whether proof obligations are
|
|
122
|
+
discharged.
|
|
123
|
+
|
|
124
|
+
To ask an explicitly selected model for a candidate:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
proofside propose examples/annotated/shot_budget_annotated.py::allocate_remaining \
|
|
128
|
+
--model-source api \
|
|
129
|
+
--model MODEL_NAME
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Without `--out`, this writes:
|
|
133
|
+
|
|
134
|
+
```text
|
|
135
|
+
examples/annotated/.proofside/shot_budget_annotated.allocate_remaining.candidate.json
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The response must be exact JSON. Proofside strictly parses and structurally
|
|
139
|
+
validates it, but labels it `PROPOSED — NOT VERIFIED`. Review or edit that file,
|
|
140
|
+
then record the explicit choice to submit it for verification:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
proofside accept examples/annotated/shot_budget_annotated.py::allocate_remaining
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
This retains the candidate and creates:
|
|
147
|
+
|
|
148
|
+
```text
|
|
149
|
+
examples/annotated/.proofside/shot_budget_annotated.allocate_remaining.contract.json
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Acceptance means only “accepted for verification.” It neither asserts that the
|
|
153
|
+
contract is correct nor runs the verifier. Verification remains a separate
|
|
154
|
+
action:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
proofside check examples/annotated/shot_budget_annotated.py::allocate_remaining \
|
|
158
|
+
--contract examples/annotated/.proofside/shot_budget_annotated.allocate_remaining.contract.json
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
An explicit `--out custom.json` remains available for proposal, and
|
|
162
|
+
`accept --candidate custom.json` validates a reviewed custom candidate into the
|
|
163
|
+
deterministic accepted path. `accept --replace` is required to replace an
|
|
164
|
+
existing accepted contract, and validation completes before replacement.
|
|
165
|
+
|
|
166
|
+
No model is needed for either contract route. A manually authored JSON contract
|
|
167
|
+
may be checked directly with `check --contract`; it does not have to pass through
|
|
168
|
+
`accept`. Advanced users may instead keep handwritten Nagini annotations in the
|
|
169
|
+
function:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
proofside check examples/nagini/shot_budget_good.py::allocate_remaining
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Proofside does not parse handwritten Nagini annotations into its contract IR.
|
|
176
|
+
|
|
177
|
+
## Specification sources
|
|
178
|
+
|
|
179
|
+
`propose` and `propose-all` accept repeatable `--source` choices:
|
|
180
|
+
|
|
181
|
+
- `equation` — the function's `proofside equation` lines;
|
|
182
|
+
- `intent` — the function's `proofside intent` lines;
|
|
183
|
+
- `implementation` — the selected function body, only when explicitly chosen.
|
|
184
|
+
|
|
185
|
+
With no `--source`, Proofside uses every available annotation type in the fixed
|
|
186
|
+
order `equation`, then `intent`. It never silently falls back to the
|
|
187
|
+
implementation. An unannotated function therefore requires explicit
|
|
188
|
+
`--source implementation`; sources may also be combined.
|
|
189
|
+
|
|
190
|
+
The function name, parameter names and types, and return annotation remain
|
|
191
|
+
structural context. Unless `implementation` is selected, the model does not
|
|
192
|
+
receive the body, return expression, neighboring functions, imports, tests, or
|
|
193
|
+
other repository content.
|
|
194
|
+
|
|
195
|
+
## Candidate and accepted artifacts
|
|
196
|
+
|
|
197
|
+
For `path/module.py::function`, the source-adjacent convention is:
|
|
198
|
+
|
|
199
|
+
```text
|
|
200
|
+
path/.proofside/module.function.candidate.json
|
|
201
|
+
proposed or supplied for review; unaccepted; NOT VERIFIED
|
|
202
|
+
|
|
203
|
+
path/.proofside/module.function.contract.json
|
|
204
|
+
explicitly accepted for verification; still NOT VERIFIED
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Both files contain ordinary Proofside contract JSON without approval metadata.
|
|
208
|
+
Proposal never overwrites an existing candidate, accepts it, or verifies it.
|
|
209
|
+
Acceptance validates before writing, never calls a model or verifier, and leaves
|
|
210
|
+
the candidate in place.
|
|
211
|
+
|
|
212
|
+
## Batch workflow
|
|
213
|
+
|
|
214
|
+
Batch commands are deterministic orchestration over independent single-function
|
|
215
|
+
operations. Only marked top-level functions participate; there is no batch
|
|
216
|
+
contract or multi-function proof.
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
proofside propose-all examples/annotated/ --model-source api --model MODEL_NAME
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
`propose-all` may make one sequential model request per marked function needing
|
|
223
|
+
a candidate. It uses each function's equation/intent annotations by default and
|
|
224
|
+
withholds each body unless `--source implementation` is selected. Candidates
|
|
225
|
+
are written independently; none is accepted or verified.
|
|
226
|
+
|
|
227
|
+
Review the candidate files and accept each chosen contract explicitly:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
proofside accept research/budget.py::remaining
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Then verify all marked functions with accepted source-adjacent contracts:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
proofside check-all research/
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
One file or function failure does not stop later independent operations. Both
|
|
240
|
+
batch commands recursively inspect only the supplied files/directories, prune
|
|
241
|
+
hidden directories, deduplicate paths, and use deterministic ordering.
|
|
242
|
+
|
|
243
|
+
The conspicuous bypass below lets `check-all` fall back to a candidate only when
|
|
244
|
+
no accepted contract exists:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
proofside check-all research/ --allow-unreviewed
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Candidate-backed results are labeled `UNREVIEWED CONTRACT`, and the overall
|
|
251
|
+
exit remains nonzero even if every underlying proof verifies. An accepted
|
|
252
|
+
contract always wins over a candidate.
|
|
253
|
+
|
|
254
|
+
## What a result means
|
|
255
|
+
|
|
256
|
+
- `VERIFIED`: Nagini/Viper discharged the displayed proof obligations.
|
|
257
|
+
- `FAILED`: one or more obligations were not proved. This does not by itself
|
|
258
|
+
mean that a concrete counterexample was produced.
|
|
259
|
+
- `UNSUPPORTED`: Proofside recognized input outside its deliberately narrow
|
|
260
|
+
source or contract boundary.
|
|
261
|
+
- `ERROR`: malformed input, missing tooling, or another setup/runtime problem
|
|
262
|
+
prevented meaningful verification.
|
|
263
|
+
|
|
264
|
+
`UNSUPPORTED` and `ERROR` do not imply that verification occurred.
|
|
265
|
+
|
|
266
|
+
A successful run establishes that the selected implementation satisfies the
|
|
267
|
+
displayed guarantees under the displayed assumptions, within the supported
|
|
268
|
+
Nagini/Viper semantics. Preconditions remain obligations on callers.
|
|
269
|
+
|
|
270
|
+
Formal verification does not establish that the contract captures the intended
|
|
271
|
+
mathematics, that a scientific model corresponds to reality, that an algorithm
|
|
272
|
+
is useful or optimal, or that an experiment is empirically valid. The researcher
|
|
273
|
+
remains responsible for the specification and its scientific meaning.
|
|
274
|
+
|
|
275
|
+
## Supported boundary
|
|
276
|
+
|
|
277
|
+
The closed contract language supports:
|
|
278
|
+
|
|
279
|
+
- arithmetic values: parameters, integer literals, the result in
|
|
280
|
+
postconditions, addition, subtraction, negation, and multiplication by an
|
|
281
|
+
integer constant;
|
|
282
|
+
- logical formulas: `==`, `!=`, `<`, `<=`, `>`, `>=`, `and`, `or`, `not`, and
|
|
283
|
+
implication;
|
|
284
|
+
- lists of preconditions (`requires`) and postconditions (`ensures`).
|
|
285
|
+
|
|
286
|
+
This is intentionally close to quantifier-free propositional linear integer
|
|
287
|
+
arithmetic. It excludes arbitrary variable-by-variable multiplication,
|
|
288
|
+
division, powers, quantifiers, arrays, floating point, and arbitrary Python
|
|
289
|
+
expressions.
|
|
290
|
+
|
|
291
|
+
For example, piecewise intent can be preserved directly:
|
|
292
|
+
|
|
293
|
+
```text
|
|
294
|
+
value >= 0 -> result == value
|
|
295
|
+
value < 0 -> result == 0
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
That says more than weakening the function to global bounds such as
|
|
299
|
+
`result >= 0`.
|
|
300
|
+
|
|
301
|
+
It contains no raw Python or Nagini snippets.
|
|
302
|
+
|
|
303
|
+
Proofside currently selects top-level synchronous functions with complete
|
|
304
|
+
parameter and return annotations. Decorated, async, nested, ambiguous, or
|
|
305
|
+
untyped targets are rejected. Sidecar mode also rejects function docstrings and
|
|
306
|
+
one-line bodies.
|
|
307
|
+
|
|
308
|
+
The selected function must be self-contained. Sidecar source generation does
|
|
309
|
+
not preserve arbitrary imports, helpers, closures, comments, or module state.
|
|
310
|
+
Proofside does not provide verification semantics for arbitrary Python, NumPy,
|
|
311
|
+
SciPy, or research frameworks.
|
|
312
|
+
|
|
313
|
+
## Trust and model transport
|
|
314
|
+
|
|
315
|
+
Proofside strictly parses one closed contract representation, validates names
|
|
316
|
+
against the selected function, and lowers accepted JSON deterministically to a
|
|
317
|
+
temporary Nagini source. Nagini, Viper/Silicon, and Z3 perform formal
|
|
318
|
+
verification. Temporary verifier sources are removed after each run.
|
|
319
|
+
|
|
320
|
+
Model output and annotation payloads are untrusted input. A model receives only
|
|
321
|
+
the selected specification sources plus structural signature context:
|
|
322
|
+
|
|
323
|
+
- API mode sends that context remotely. The default OpenAI endpoint alone reads
|
|
324
|
+
`OPENAI_API_KEY` implicitly.
|
|
325
|
+
- A custom API endpoint must use HTTPS and explicitly name its credential with
|
|
326
|
+
`--api-key-env`; Proofside does not forward `OPENAI_API_KEY` automatically.
|
|
327
|
+
- Local mode defaults to `http://localhost:11434/v1` and is unauthenticated.
|
|
328
|
+
- Authenticated requests refuse every HTTP redirect so credentials cannot be
|
|
329
|
+
forwarded to a redirect target.
|
|
330
|
+
|
|
331
|
+
Proofside makes one non-streaming request with a finite timeout and no automatic
|
|
332
|
+
retry, repair, or verifier-feedback loop.
|
|
333
|
+
|
|
334
|
+
## Research example
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
proofside check examples/research/research_shot_budget.py::remaining_feature_shots \
|
|
338
|
+
--contract examples/research/research_shot_budget_contract.json
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
This synthetic bookkeeping kernel is inspired by two motifs in the author's
|
|
342
|
+
research workflow: finite-shot Pauli feature acquisition and train/test
|
|
343
|
+
separation. It is not copied from that implementation and does not represent a
|
|
344
|
+
canonical allocation policy. The private research repository is not needed to
|
|
345
|
+
understand or run this self-contained example.
|
|
346
|
+
|
|
347
|
+
The contract proves a nonnegative remainder and conservation of the declared
|
|
348
|
+
counts under its assumptions. It does not prove that the split is optimal, that
|
|
349
|
+
the acquisition choices are scientifically appropriate, that the method
|
|
350
|
+
improves a downstream task, or that a policy transfers to hardware.
|
|
351
|
+
|
|
352
|
+
## Development
|
|
353
|
+
|
|
354
|
+
See [`CONTRIBUTING.md`](CONTRIBUTING.md) for setup, tests, the code map, and
|
|
355
|
+
design constraints. If Nagini cannot find Java—especially on Windows—set
|
|
356
|
+
`JAVA_HOME` to the Java installation root.
|
|
357
|
+
|
|
358
|
+
See [`ROADMAP.md`](ROADMAP.md) for suggested contribution directions.
|
|
359
|
+
|
|
360
|
+
## Third-party software and license status
|
|
361
|
+
|
|
362
|
+
| Software | Version | License | Use here |
|
|
363
|
+
| --- | --- | --- | --- |
|
|
364
|
+
| [Nagini](https://github.com/marcoeilers/nagini) | 1.3.1 | MPL-2.0 | Direct pinned verification dependency |
|
|
365
|
+
| [Viper/Silicon](https://github.com/viperproject/silicon) | Bundled by Nagini 1.3.1 | MPL-2.0 | Verification backend used through Nagini |
|
|
366
|
+
| [Z3](https://github.com/Z3Prover/z3) | 4.8.7.0 on common x64 platforms | MIT | Solver installed transitively by Nagini |
|
|
367
|
+
|
|
368
|
+
Proofside depends on these projects but contains no copied or adapted
|
|
369
|
+
third-party source. Python and Java are execution prerequisites distributed
|
|
370
|
+
under their respective licenses.
|
|
371
|
+
|
|
372
|
+
Proofside is licensed under the Apache License 2.0. See [`LICENSE`](LICENSE).
|
|
373
|
+
|