dratify 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.
dratify-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.
dratify-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,136 @@
1
+ Metadata-Version: 2.4
2
+ Name: dratify
3
+ Version: 0.1.0
4
+ Summary: Check DRAT/DRUP proofs of unsatisfiability inside your Python process. Zero dependencies, optional Rust accelerator.
5
+ Author: Carlo Perassi
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/carlok/dratify
8
+ Project-URL: Source, https://github.com/carlok/dratify
9
+ Keywords: sat,drat,drup,proof,checker,unsatisfiability,rup,rat
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Programming Language :: Rust
20
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
21
+ Classifier: Topic :: Software Development :: Testing
22
+ Classifier: Operating System :: POSIX :: Linux
23
+ Classifier: Operating System :: MacOS
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: license-file
28
+
29
+ # dratify
30
+
31
+ **Check a DRAT/DRUP proof of unsatisfiability, inside your Python process.**
32
+
33
+ A SAT solver that answers "unsatisfiable" is asking to be trusted. A DRAT proof
34
+ is how it stops asking: the solver logs every clause it derives, and a checker
35
+ that shares no code with it replays the log and confirms the empty clause
36
+ really follows.
37
+
38
+ Emitting those proofs is routine. PySAT exposes them from six solver families
39
+ with `with_proof=True` / `get_proof()`. *Checking* them from Python has not
40
+ been practical: `drat-trim` is C you compile and shell out to, and the only
41
+ checker on PyPI installs on Linux x86-64 under Python ≤ 3.10 alone.
42
+
43
+ ```bash
44
+ pip install dratify # pure Python, zero dependencies
45
+ ```
46
+
47
+ A Rust implementation of the same checker is published separately as the
48
+ [`dratify` crate](https://crates.io/crates/dratify). Python bindings for it are
49
+ not packaged yet; `engine="native"` is wired up and will pick them up when they
50
+ are.
51
+
52
+ ## Check a proof from PySAT
53
+
54
+ ```python
55
+ from pysat.formula import CNF as PyCNF
56
+ from pysat.solvers import Glucose42
57
+ from dratify import parse_dimacs, check_proof
58
+
59
+ cnf = PyCNF(from_file="problem.cnf")
60
+ with Glucose42(bootstrap_with=cnf, with_proof=True) as s:
61
+ assert not s.solve()
62
+ proof = s.get_proof()
63
+
64
+ result = check_proof(parse_dimacs(cnf.to_dimacs()), "\n".join(proof))
65
+ print(result.ok) # True -- the refutation is genuine
66
+ ```
67
+
68
+ No subprocess, no compiler, no temporary files.
69
+
70
+ ## Two engines, and that is the point
71
+
72
+ Proof checking is the one domain where two independent implementations agreeing
73
+ *is* the evidence. This ships both:
74
+
75
+ | | |
76
+ |---|---|
77
+ | **Pure Python** | zero dependencies, runs anywhere Python does |
78
+ | **Rust** (crates.io) | ~18x faster; Python bindings not yet packaged |
79
+
80
+ Neither is the "real" one. They have been differentially tested against each
81
+ other on acceptances *and* on rejections, and they agree.
82
+
83
+ ```python
84
+ check_proof(formula, proof, engine="python") # always available
85
+ check_proof(formula, proof, engine="native") # when bindings are installed
86
+ check_proof(formula, proof, engine="auto") # default: native when present
87
+ ```
88
+
89
+ ## What it checks
90
+
91
+ - **RUP** (reverse unit propagation) — the common case.
92
+ - **RAT** (resolution asymmetric tautology) — the "A" in DRAT, checked properly:
93
+ pivot on the first literal, resolvent against every clause containing its
94
+ negation, RUP on each.
95
+ - **Deletion**, applied by default. Deletion is monotone-safe for RUP; RAT is
96
+ not monotone, so RAT steps are checked against exactly the clauses present.
97
+
98
+ Checking is **forward**: every step is verified, rather than working backwards
99
+ from the empty clause as `drat-trim` does. That makes it slower on large proofs
100
+ and means a corrupted step is caught where it occurs.
101
+
102
+ ## Speed
103
+
104
+ Measured against `drat-trim` (which does backward checking by default):
105
+
106
+ | proof | steps | pure Python | Rust | drat-trim |
107
+ |---|---|---|---|---|
108
+ | uuf100-01 | 774 | 0.01s | 0.01s | 0.05s |
109
+ | uuf100-010 | 1,103 | 0.05s | 0.00s | 0.06s |
110
+ | uuf250-01 | 209,367 | 41.47s | 2.27s | 1.30s |
111
+
112
+ Rust wins on small proofs — `drat-trim` pays process startup and cannot be
113
+ called in-process — and loses 1.75x on the large one, while checking forward.
114
+
115
+ On 10 proofs from two solvers, `dratify` and `drat-trim` agreed on every case,
116
+ including four rejections.
117
+
118
+ ## Honest limitations
119
+
120
+ - Forward checking only. Backward checking would close the large-proof gap.
121
+ - No binary DRAT format yet; text proofs only.
122
+ - Not formally verified. It is carefully written, differentially tested against
123
+ a second implementation, and cross-validated against `drat-trim` — which is
124
+ not the same thing as a machine-checked proof of the checker itself. If you
125
+ need that, `cake_lpr` is CakeML-verified and consumes LRAT.
126
+
127
+ ## Related
128
+
129
+ [`cdclkit`](https://github.com/carlok/cdclkit) is a from-scratch CDCL SAT
130
+ solver by the same author that uses this package to check its own refutations.
131
+ You do not need it to use `dratify` — checking a proof should never require
132
+ installing a solver, which is why these are separate packages.
133
+
134
+ ## Licence
135
+
136
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,108 @@
1
+ # dratify
2
+
3
+ **Check a DRAT/DRUP proof of unsatisfiability, inside your Python process.**
4
+
5
+ A SAT solver that answers "unsatisfiable" is asking to be trusted. A DRAT proof
6
+ is how it stops asking: the solver logs every clause it derives, and a checker
7
+ that shares no code with it replays the log and confirms the empty clause
8
+ really follows.
9
+
10
+ Emitting those proofs is routine. PySAT exposes them from six solver families
11
+ with `with_proof=True` / `get_proof()`. *Checking* them from Python has not
12
+ been practical: `drat-trim` is C you compile and shell out to, and the only
13
+ checker on PyPI installs on Linux x86-64 under Python ≤ 3.10 alone.
14
+
15
+ ```bash
16
+ pip install dratify # pure Python, zero dependencies
17
+ ```
18
+
19
+ A Rust implementation of the same checker is published separately as the
20
+ [`dratify` crate](https://crates.io/crates/dratify). Python bindings for it are
21
+ not packaged yet; `engine="native"` is wired up and will pick them up when they
22
+ are.
23
+
24
+ ## Check a proof from PySAT
25
+
26
+ ```python
27
+ from pysat.formula import CNF as PyCNF
28
+ from pysat.solvers import Glucose42
29
+ from dratify import parse_dimacs, check_proof
30
+
31
+ cnf = PyCNF(from_file="problem.cnf")
32
+ with Glucose42(bootstrap_with=cnf, with_proof=True) as s:
33
+ assert not s.solve()
34
+ proof = s.get_proof()
35
+
36
+ result = check_proof(parse_dimacs(cnf.to_dimacs()), "\n".join(proof))
37
+ print(result.ok) # True -- the refutation is genuine
38
+ ```
39
+
40
+ No subprocess, no compiler, no temporary files.
41
+
42
+ ## Two engines, and that is the point
43
+
44
+ Proof checking is the one domain where two independent implementations agreeing
45
+ *is* the evidence. This ships both:
46
+
47
+ | | |
48
+ |---|---|
49
+ | **Pure Python** | zero dependencies, runs anywhere Python does |
50
+ | **Rust** (crates.io) | ~18x faster; Python bindings not yet packaged |
51
+
52
+ Neither is the "real" one. They have been differentially tested against each
53
+ other on acceptances *and* on rejections, and they agree.
54
+
55
+ ```python
56
+ check_proof(formula, proof, engine="python") # always available
57
+ check_proof(formula, proof, engine="native") # when bindings are installed
58
+ check_proof(formula, proof, engine="auto") # default: native when present
59
+ ```
60
+
61
+ ## What it checks
62
+
63
+ - **RUP** (reverse unit propagation) — the common case.
64
+ - **RAT** (resolution asymmetric tautology) — the "A" in DRAT, checked properly:
65
+ pivot on the first literal, resolvent against every clause containing its
66
+ negation, RUP on each.
67
+ - **Deletion**, applied by default. Deletion is monotone-safe for RUP; RAT is
68
+ not monotone, so RAT steps are checked against exactly the clauses present.
69
+
70
+ Checking is **forward**: every step is verified, rather than working backwards
71
+ from the empty clause as `drat-trim` does. That makes it slower on large proofs
72
+ and means a corrupted step is caught where it occurs.
73
+
74
+ ## Speed
75
+
76
+ Measured against `drat-trim` (which does backward checking by default):
77
+
78
+ | proof | steps | pure Python | Rust | drat-trim |
79
+ |---|---|---|---|---|
80
+ | uuf100-01 | 774 | 0.01s | 0.01s | 0.05s |
81
+ | uuf100-010 | 1,103 | 0.05s | 0.00s | 0.06s |
82
+ | uuf250-01 | 209,367 | 41.47s | 2.27s | 1.30s |
83
+
84
+ Rust wins on small proofs — `drat-trim` pays process startup and cannot be
85
+ called in-process — and loses 1.75x on the large one, while checking forward.
86
+
87
+ On 10 proofs from two solvers, `dratify` and `drat-trim` agreed on every case,
88
+ including four rejections.
89
+
90
+ ## Honest limitations
91
+
92
+ - Forward checking only. Backward checking would close the large-proof gap.
93
+ - No binary DRAT format yet; text proofs only.
94
+ - Not formally verified. It is carefully written, differentially tested against
95
+ a second implementation, and cross-validated against `drat-trim` — which is
96
+ not the same thing as a machine-checked proof of the checker itself. If you
97
+ need that, `cake_lpr` is CakeML-verified and consumes LRAT.
98
+
99
+ ## Related
100
+
101
+ [`cdclkit`](https://github.com/carlok/cdclkit) is a from-scratch CDCL SAT
102
+ solver by the same author that uses this package to check its own refutations.
103
+ You do not need it to use `dratify` — checking a proof should never require
104
+ installing a solver, which is why these are separate packages.
105
+
106
+ ## Licence
107
+
108
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "dratify"
7
+ version = "0.1.0"
8
+ description = "Check DRAT/DRUP proofs of unsatisfiability inside your Python process. Zero dependencies, optional Rust accelerator."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Carlo Perassi" }]
14
+ keywords = ["sat", "drat", "drup", "proof", "checker", "unsatisfiability", "rup", "rat"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Science/Research",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
25
+ "Programming Language :: Rust",
26
+ "Topic :: Scientific/Engineering :: Mathematics",
27
+ "Topic :: Software Development :: Testing",
28
+ "Operating System :: POSIX :: Linux",
29
+ "Operating System :: MacOS",
30
+ ]
31
+ dependencies = []
32
+
33
+ [project.urls]
34
+ Homepage = "https://github.com/carlok/dratify"
35
+ Source = "https://github.com/carlok/dratify"
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,68 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Check a DRAT/DRUP proof of unsatisfiability, inside your Python process.
3
+
4
+ A SAT solver that answers "unsatisfiable" is asking to be trusted. A DRAT proof
5
+ is how it stops asking: the solver logs every clause it derives, and a checker
6
+ that shares no code with it replays the log and confirms the empty clause
7
+ really follows.
8
+
9
+ Emitting those proofs is common -- PySAT exposes them from six solver families
10
+ via ``with_proof=True`` / ``get_proof()``. *Checking* them from Python has not
11
+ been possible: ``drat-trim`` is C you have to compile and shell out to, and the
12
+ one checker on PyPI installs only on Linux x86-64 under Python <= 3.10.
13
+
14
+ >>> from dratify import parse_dimacs, check_proof
15
+ >>> formula = parse_dimacs(open("problem.cnf").read())
16
+ >>> result = check_proof(formula, open("proof.drat").read())
17
+ >>> result.ok
18
+ True
19
+
20
+ Two engines, and that is the point
21
+ ----------------------------------
22
+ The pure-Python checker has zero dependencies and runs anywhere Python does.
23
+ The optional Rust accelerator (``pip install dratify[native]``) is roughly 18x
24
+ faster. Neither is the "real" one: proof checking is the one domain where two
25
+ independent implementations agreeing *is* the evidence, and these two have been
26
+ differentially tested against each other, on acceptances and on rejections.
27
+
28
+ Pass ``engine="python"``, ``engine="native"``, or ``engine="auto"`` (the
29
+ default: native when installed).
30
+
31
+ RUP and RAT are both checked. Checking is forward -- every step is verified,
32
+ rather than working backwards from the empty clause.
33
+ """
34
+
35
+ from __future__ import annotations
36
+
37
+ from .cnf import CNF
38
+ from .lits import from_dimacs, to_dimacs
39
+ from .proof import (
40
+ DRATChecker,
41
+ MemoryProof,
42
+ ProofWriter,
43
+ check_proof,
44
+ )
45
+ from .cnf import parse_dimacs, parse_dimacs_file, write_dimacs
46
+ from . import _nativeinfo
47
+
48
+ __version__ = "0.1.0"
49
+
50
+ __all__ = [
51
+ "CNF",
52
+ "DRATChecker",
53
+ "MemoryProof",
54
+ "ProofWriter",
55
+ "check_proof",
56
+ "parse_dimacs",
57
+ "parse_dimacs_file",
58
+ "write_dimacs",
59
+ "from_dimacs",
60
+ "to_dimacs",
61
+ "native_available",
62
+ "__version__",
63
+ ]
64
+
65
+
66
+ def native_available() -> bool:
67
+ """True when the optional Rust checker is installed."""
68
+ return _nativeinfo.available()
@@ -0,0 +1,21 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Availability of the optional Rust checker."""
3
+
4
+ from __future__ import annotations
5
+
6
+ BUILD_HINT = (
7
+ "engine='native' was requested but the Rust checker is not installed. "
8
+ "The Rust accelerator is not yet published as a Python wheel; use "
9
+ "engine='python' or engine='auto' "
10
+ "(the pure-Python checker is complete and is never going away -- it is "
11
+ "the independent implementation that makes agreement meaningful)."
12
+ )
13
+
14
+
15
+ def available() -> bool:
16
+ """True when the Rust checker can be imported."""
17
+ try:
18
+ import sable_native
19
+ except ImportError:
20
+ return False
21
+ return hasattr(sable_native, "check_proof")