se-interpretive-kernel 0.1.0__py3-none-any.whl
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.
- se_interpretive_kernel/__init__.py +7 -0
- se_interpretive_kernel/_version.py +24 -0
- se_interpretive_kernel/artifact.py +76 -0
- se_interpretive_kernel/cases.py +120 -0
- se_interpretive_kernel/check.py +293 -0
- se_interpretive_kernel/cli.py +5 -0
- se_interpretive_kernel/demand.py +66 -0
- se_interpretive_kernel/differences.py +69 -0
- se_interpretive_kernel/explain.py +224 -0
- se_interpretive_kernel/generated.py +100 -0
- se_interpretive_kernel/kernel.py +52 -0
- se_interpretive_kernel/lifting.py +374 -0
- se_interpretive_kernel/literal.py +87 -0
- se_interpretive_kernel/loader.py +238 -0
- se_interpretive_kernel/partition.py +363 -0
- se_interpretive_kernel/probes.py +124 -0
- se_interpretive_kernel/sampling.py +36 -0
- se_interpretive_kernel/witness.py +69 -0
- se_interpretive_kernel-0.1.0.dist-info/METADATA +261 -0
- se_interpretive_kernel-0.1.0.dist-info/RECORD +23 -0
- se_interpretive_kernel-0.1.0.dist-info/WHEEL +4 -0
- se_interpretive_kernel-0.1.0.dist-info/entry_points.txt +2 -0
- se_interpretive_kernel-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: se-interpretive-kernel
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Executable contract for the Structural Explainability interpretive kernel: finite kernel, generated occurrence regime, thresholds, witnesses, and comparison-lifting laws
|
|
5
|
+
Project-URL: Changelog, https://github.com/structural-explainability/se-interpretive-kernel/blob/main/CHANGELOG.md
|
|
6
|
+
Project-URL: Documentation, https://structural-explainability.github.io/se-interpretive-kernel/
|
|
7
|
+
Project-URL: Homepage, https://github.com/structural-explainability/se-interpretive-kernel
|
|
8
|
+
Project-URL: Issues, https://github.com/structural-explainability/se-interpretive-kernel/issues
|
|
9
|
+
Project-URL: Repository, https://github.com/structural-explainability/se-interpretive-kernel
|
|
10
|
+
Author: Denise M. Case
|
|
11
|
+
Maintainer: Denise M. Case
|
|
12
|
+
License-Expression: MIT
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: equivalence-relations,galois-connection,identity,interpretive-kernel,partitions,refinement,research-software,structural-explainability,verification
|
|
15
|
+
Classifier: Development Status :: 3 - Alpha
|
|
16
|
+
Classifier: Environment :: Console
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Intended Audience :: Science/Research
|
|
19
|
+
Classifier: Natural Language :: English
|
|
20
|
+
Classifier: Operating System :: OS Independent
|
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
|
22
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
27
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
28
|
+
Classifier: Topic :: Scientific/Engineering
|
|
29
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
30
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
31
|
+
Classifier: Typing :: Typed
|
|
32
|
+
Requires-Python: >=3.12
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# se-interpretive-kernel
|
|
36
|
+
|
|
37
|
+
[](https://pypi.org/project/se-interpretive-kernel/)
|
|
38
|
+
[](https://structural-explainability.github.io/se-interpretive-kernel/)
|
|
39
|
+
[](https://github.com/structural-explainability/se-interpretive-kernel)
|
|
40
|
+
[](https://pypi.org/project/se-interpretive-kernel/)
|
|
41
|
+
[](https://github.com/structural-explainability/se-interpretive-kernel/blob/main/LICENSE)
|
|
42
|
+
|
|
43
|
+
[](https://github.com/structural-explainability/se-interpretive-kernel/actions/workflows/ci-python-zensical.yml)
|
|
44
|
+
[](https://github.com/structural-explainability/se-interpretive-kernel/actions/workflows/deploy-zensical.yml)
|
|
45
|
+
[](https://github.com/structural-explainability/se-interpretive-kernel/actions/workflows/pre-release.yml)
|
|
46
|
+
[](https://github.com/structural-explainability/se-interpretive-kernel/actions/workflows/release-pypi.yml)
|
|
47
|
+
[](https://github.com/structural-explainability/se-interpretive-kernel/actions/workflows/links.yml)
|
|
48
|
+
[](https://github.com/structural-explainability/se-interpretive-kernel/security)
|
|
49
|
+
|
|
50
|
+
> An executable contract for the Structural Explainability (SE) **interpretive kernel**:
|
|
51
|
+
> when a declared identity regime over frames induces well-defined judgments about the
|
|
52
|
+
> objects an interpretation produces, and what it costs when it does not.
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install se-interpretive-kernel
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Python 3.12 or newer. No runtime dependencies. The package is typed.
|
|
61
|
+
|
|
62
|
+
## Quick start
|
|
63
|
+
|
|
64
|
+
Two probes read two frames. The declared regime says frames `a` and `b` are the
|
|
65
|
+
same, and outputs are compared by equality.
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from se_interpretive_kernel.artifact import Artifact
|
|
69
|
+
from se_interpretive_kernel.explain import explain, format_steps
|
|
70
|
+
from se_interpretive_kernel.generated import generated
|
|
71
|
+
from se_interpretive_kernel.kernel import coherent
|
|
72
|
+
from se_interpretive_kernel.partition import Partition
|
|
73
|
+
from se_interpretive_kernel.witness import find_witness
|
|
74
|
+
|
|
75
|
+
artifact = Artifact(
|
|
76
|
+
frames=("a", "b"),
|
|
77
|
+
outputs=("x", "y", "z"),
|
|
78
|
+
probes=("p", "q"),
|
|
79
|
+
table={("p", "a"): "x", ("p", "b"): "y", ("q", "a"): "y", ("q", "b"): "z"},
|
|
80
|
+
)
|
|
81
|
+
same = Partition.from_blocks(artifact.frames, [("a", "b")])
|
|
82
|
+
equal = Partition.discrete(artifact.outputs)
|
|
83
|
+
|
|
84
|
+
print(coherent(artifact, artifact.probes, same, equal))
|
|
85
|
+
# False
|
|
86
|
+
|
|
87
|
+
print(find_witness(artifact, artifact.probes, same, equal))
|
|
88
|
+
# Witness(frame_1='a', frame_2='b', probe='p', output_1='x', output_2='y')
|
|
89
|
+
|
|
90
|
+
print(generated(artifact, artifact.probes, same).blocks())
|
|
91
|
+
# (('x', 'y', 'z'),)
|
|
92
|
+
|
|
93
|
+
print(format_steps(explain(artifact, artifact.probes, same, "x", "z")))
|
|
94
|
+
# 1. probe 'p' reads frame 'a' as 'x' and frame 'b' as 'y'; the frame regime relates those two frames
|
|
95
|
+
# 2. probe 'q' reads frame 'a' as 'y' and frame 'b' as 'z'; the frame regime relates those two frames
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The regime is coherent only if `x`, `y`, and `z` are called the same, and the
|
|
99
|
+
derivation shows why.
|
|
100
|
+
|
|
101
|
+
## Purpose
|
|
102
|
+
|
|
103
|
+
An interpretation `I` maps a probe and a frame to structured output.
|
|
104
|
+
Fix a finite probe domain `P` and an equivalence `rho` on outputs.
|
|
105
|
+
The **interpretive kernel** relates two frames when no probe can tell
|
|
106
|
+
them apart:
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
F ~ker F' iff for every p in P, I(p, F) is rho-indistinguishable from I(p, F')
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
A declared identity regime over frames induces well-defined
|
|
113
|
+
object-level judgments exactly when it refines the kernel, and every failure
|
|
114
|
+
comes with a finite witness: the probe and the pair of frames on which
|
|
115
|
+
the regime identifies what interpretation separates.
|
|
116
|
+
|
|
117
|
+
The stronger result is the **threshold**.
|
|
118
|
+
For a declared regime `phi`, the least output equivalence under which `phi` is
|
|
119
|
+
coherent is generated directly by the pairs `phi` forces together:
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
L(phi) = equivalence closure of { (I(p, F), I(p, F')) : p in P, F phi F' }
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`L` is left adjoint to the kernel, so no search over the lattice is required.
|
|
126
|
+
The result is a computed commitment rather than a pass or fail verdict:
|
|
127
|
+
not
|
|
128
|
+
"this regime is inadmissible" but
|
|
129
|
+
"this regime is coherent only if you are willing to call these outputs the same".
|
|
130
|
+
|
|
131
|
+
The construction is domain-agnostic.
|
|
132
|
+
Interpretation is supplied by the consuming domain and not imported.
|
|
133
|
+
|
|
134
|
+
The package reports commitments and differences.
|
|
135
|
+
It reports whether a declared identity regime is consistent
|
|
136
|
+
with a declared interpretation,
|
|
137
|
+
what the regime obliges the outputs to be, and
|
|
138
|
+
where two regimes disagree.
|
|
139
|
+
It does not certify ground truth:
|
|
140
|
+
when two regimes disagree,
|
|
141
|
+
it shows where and why, and does not say which is correct.
|
|
142
|
+
|
|
143
|
+
## Comparison Liftings Have Laws
|
|
144
|
+
|
|
145
|
+
Comparing structured outputs requires carrying an output equivalence up to
|
|
146
|
+
the structures:
|
|
147
|
+
|
|
148
|
+
```text
|
|
149
|
+
C : Eq(O) -> Eq(X)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The kernel construction needs `C` to preserve arbitrary meets.
|
|
153
|
+
Complete meet homomorphisms of this shape are exactly the `Eq(O)`-valued
|
|
154
|
+
generalized ultrametrics on `X`, so every one of them is given by a cost
|
|
155
|
+
`delta(x, y)`: the least output identification that would make two objects
|
|
156
|
+
the same.
|
|
157
|
+
The cost must satisfy three laws, and `check_lifting_laws` is the finite test
|
|
158
|
+
that decides whether a supplied comparison has them.
|
|
159
|
+
|
|
160
|
+
Two comparisons in this package are present because they fail, and both
|
|
161
|
+
failures are regressions that must keep failing.
|
|
162
|
+
|
|
163
|
+
- **Indexed pointwise**: monotone, meet-preserving, and a lifting.
|
|
164
|
+
- **Quotient-image equality**: monotone, but not meet-preserving, so not a
|
|
165
|
+
lifting.
|
|
166
|
+
- **Optimal matching over bijections**: not a lifting, because the triangle
|
|
167
|
+
law fails.
|
|
168
|
+
|
|
169
|
+
Quotient-image equality on unordered outputs is the natural way to compare
|
|
170
|
+
occurrence sets and does not preserve meets, so no cost represents it.
|
|
171
|
+
Optimal matching is the natural repair and violates the triangle law, because
|
|
172
|
+
moving the meet over alternative bijections through the join needs a
|
|
173
|
+
distributivity the partition lattice does not have.
|
|
174
|
+
|
|
175
|
+
The surviving repair is a declared canonicalization, which fixes the index
|
|
176
|
+
before the output regime is known.
|
|
177
|
+
It restores every law, and it costs something: the identification it demands
|
|
178
|
+
is no finer than the best matching would have required.
|
|
179
|
+
That price is measured in the test suite rather than asserted.
|
|
180
|
+
|
|
181
|
+
A canonicalization is therefore a declared artifact, not an implementation
|
|
182
|
+
detail.
|
|
183
|
+
One that is not injective identifies distinct objects at zero cost, which
|
|
184
|
+
declares an identity without ever appearing as a declared identity regime.
|
|
185
|
+
|
|
186
|
+
## Run
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
uv sync
|
|
190
|
+
|
|
191
|
+
uv run pytest
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Developer
|
|
195
|
+
|
|
196
|
+
### Clone and copy
|
|
197
|
+
|
|
198
|
+
Open a machine terminal where you want the project:
|
|
199
|
+
|
|
200
|
+
```shell
|
|
201
|
+
git clone https://github.com/structural-explainability/se-interpretive-kernel
|
|
202
|
+
|
|
203
|
+
cd se-interpretive-kernel
|
|
204
|
+
code .
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Open in VS Code and Run
|
|
208
|
+
|
|
209
|
+
In a VS Code terminal
|
|
210
|
+
|
|
211
|
+
```pwsh
|
|
212
|
+
.\sit
|
|
213
|
+
|
|
214
|
+
uv run se-interpretive-kernel --random 2000 --seed 0
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
```shell
|
|
218
|
+
# save progress
|
|
219
|
+
git add -A
|
|
220
|
+
git commit -m "update"
|
|
221
|
+
git push -u origin main
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Planned
|
|
225
|
+
|
|
226
|
+
The boundary of the current slice is explicit.
|
|
227
|
+
|
|
228
|
+
- `outcome.py`: the tagged output domain carrying end, undefined, and error,
|
|
229
|
+
which makes length mismatch a declared comparison result rather than an
|
|
230
|
+
exception.
|
|
231
|
+
- `signature.py`: declared roles for each variable. A variable in the probe
|
|
232
|
+
domain is a test condition, in the frame domain it is a thing whose
|
|
233
|
+
sameness is at issue, and in the output domain it is observable. The same
|
|
234
|
+
variable in three positions asks three different questions, so position is
|
|
235
|
+
a declaration and must be validated.
|
|
236
|
+
|
|
237
|
+
## Related Repositories
|
|
238
|
+
|
|
239
|
+
- [se-theory-interpretive-kernel](https://github.com/structural-explainability/se-theory-interpretive-kernel):
|
|
240
|
+
the Lean formalization of the same results. The two are independent
|
|
241
|
+
realizations of one contract, and disagreement between them means one of
|
|
242
|
+
the definitions is wrong.
|
|
243
|
+
- [se-verification-operational-identity](https://github.com/structural-explainability/se-verification-operational-identity):
|
|
244
|
+
SE-210, whose refinement and four-way sibling positioning this construction
|
|
245
|
+
builds on.
|
|
246
|
+
|
|
247
|
+
## Citation
|
|
248
|
+
|
|
249
|
+
[CITATION.cff](https://github.com/structural-explainability/se-interpretive-kernel/blob/main/CITATION.cff)
|
|
250
|
+
|
|
251
|
+
## Software Metadata
|
|
252
|
+
|
|
253
|
+
[CodeMeta (`codemeta.json`)](https://github.com/structural-explainability/se-interpretive-kernel/blob/main/codemeta.json)
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
[MIT](https://github.com/structural-explainability/se-interpretive-kernel/blob/main/LICENSE)
|
|
258
|
+
|
|
259
|
+
## Repository Manifest
|
|
260
|
+
|
|
261
|
+
[SE_MANIFEST.toml](https://github.com/structural-explainability/se-interpretive-kernel/blob/main/SE_MANIFEST.toml)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
se_interpretive_kernel/__init__.py,sha256=HJftBV3Hwbd-fnUUJc18kmjefqwPvJ8GjraD04RwH8Y,283
|
|
2
|
+
se_interpretive_kernel/_version.py,sha256=n_5vdJsPNu7wZ57LGuRL585uvll-hiuvZUBWzdG0RQU,520
|
|
3
|
+
se_interpretive_kernel/artifact.py,sha256=o3FVtewRSE-BtiZIT6m3tyxbPJgkOvUYlYD9EE-f3kw,2941
|
|
4
|
+
se_interpretive_kernel/cases.py,sha256=BhB87lmRZN8Kuy8GjdyCR5UHP4CWLfl6bBhkH7DnA0I,3686
|
|
5
|
+
se_interpretive_kernel/check.py,sha256=XkUdUniZ0seybEkAs_-i9639CDkzUrA5soo0xQGJRoA,12296
|
|
6
|
+
se_interpretive_kernel/cli.py,sha256=1omCSSiRkqyGTOWkOSf9jpKnW3pLI-T8Fz2eh-34jaU,97
|
|
7
|
+
se_interpretive_kernel/demand.py,sha256=E-PCts6n35XmPhxG-eFpKoDG-jHmrQHa-UU55Lu0X3Q,2701
|
|
8
|
+
se_interpretive_kernel/differences.py,sha256=AC_GgVZmERUwy_OiRaZWyPeMQbKslosWxyRmRrf23AE,2469
|
|
9
|
+
se_interpretive_kernel/explain.py,sha256=WkqIy4MZ1n6PAKdERNT5ukTa20Tm_YJ-kXryoV7n5mg,7476
|
|
10
|
+
se_interpretive_kernel/generated.py,sha256=0HJadzqqVK4TT1XOJIBLOxcMusFsC2ZR9NzcHZ-2OGI,3536
|
|
11
|
+
se_interpretive_kernel/kernel.py,sha256=2zPqVFuSt6hHGbiKD8SWDIvEOx9AwSUK-Tahc8takzg,1982
|
|
12
|
+
se_interpretive_kernel/lifting.py,sha256=cQ3n7KLkdyBSr01CJ0ICWo3qNTPPLRWK-kwbbefF8zY,13868
|
|
13
|
+
se_interpretive_kernel/literal.py,sha256=ypIrQRnvcK16RtFO-4M9A7P9UgDIv5mjLGXTQWBaKrc,2732
|
|
14
|
+
se_interpretive_kernel/loader.py,sha256=I4xhMl-gN9CPrC1AATt-NfWMiTetvMZ4JvUtvLPWtUE,8227
|
|
15
|
+
se_interpretive_kernel/partition.py,sha256=bCkTALEAnUG-I7Z29cO5zktZ_nXToM7GjZ5v91rxgK8,13224
|
|
16
|
+
se_interpretive_kernel/probes.py,sha256=D3JQDbbwk-Mss0mmtc9pVO4GLzHbybQdWjM5M1Pp8fE,4459
|
|
17
|
+
se_interpretive_kernel/sampling.py,sha256=menI3G9GBzv6C36G_57QHJjMZSfJUE0ANXteA0h_j1c,1194
|
|
18
|
+
se_interpretive_kernel/witness.py,sha256=dulJ3bDFbDMgS2Gg5ahPpoG-9CdBHRU6uxGNE3KiJIM,2292
|
|
19
|
+
se_interpretive_kernel-0.1.0.dist-info/METADATA,sha256=jblefopF2clR0i0opVsPkY-6hmfM_e54tDJrYrYuJxc,11299
|
|
20
|
+
se_interpretive_kernel-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
21
|
+
se_interpretive_kernel-0.1.0.dist-info/entry_points.txt,sha256=ELjA9hgrT2Oau--Jf4vZc47DyGIAYww9EyZV0YA0ohE,75
|
|
22
|
+
se_interpretive_kernel-0.1.0.dist-info/licenses/LICENSE,sha256=Xs6IcjtQ_6V_-e6sSH0xOsGwgZ1zwlqOz12Tx4VMXvU,1068
|
|
23
|
+
se_interpretive_kernel-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Denise Case
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|