Skip to content

Commit 739c2b0

Browse files
committed
P0: normalize experiment imports and document homotopy checks
1 parent 52513ff commit 739c2b0

16 files changed

+143
-72
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# `homotopy_constraint_verification.py` documentation
2+
3+
## Location
4+
- Script: `experiments/homotopy_constraint_verification.py`
5+
6+
## Purpose
7+
This script validates a combinatorial horn-index characterization by direct tensor-face computation.
8+
9+
For each tested tensor shape and horn index `j`, it compares two sets:
10+
- `compute_missing_indices_dask(shape, j)` from `horn_map_reduce.py`
11+
- the set of basis indices `m` such that `d_i(E_m) = 0` for every face `i != j`
12+
13+
## Algorithm
14+
For each `(shape, horn_j)`:
15+
1. Compute `n = min(shape) - 1` and skip if `horn_j` is out of range.
16+
2. Compute `expected_indices = compute_missing_indices_dask(shape, horn_j)`.
17+
3. Enumerate all multi-indices `m` in the shape.
18+
4. For each horn face index `i` (`0..n`, excluding `horn_j`):
19+
- Build standard basis tensor `E_m`.
20+
- Compute `face(E_m, i)`.
21+
- Collect `m` where the face is the zero tensor.
22+
5. Intersect these zero-face index sets over all `i != horn_j`.
23+
6. Compare the intersection against `expected_indices` and report pass/fail.
24+
25+
## Outputs
26+
The script prints:
27+
- per-case headers with shape and horn index,
28+
- counts from the combinatorial method and constraint method,
29+
- per-case pass/fail result,
30+
- final overall summary.
31+
32+
## Logging
33+
- No file logger is configured.
34+
- All reporting is written to standard output.
35+
36+
## Run
37+
From repository root, either use editable install:
38+
39+
```powershell
40+
.\.venv\Scripts\python.exe experiments\homotopy_constraint_verification.py
41+
```
42+
43+
Or run with explicit source path:
44+
45+
```powershell
46+
$env:PYTHONPATH = 'src'
47+
.\.venv\Scripts\python.exe experiments\homotopy_constraint_verification.py
48+
```
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# `homotopy_constraint_verification_with_independence_test.py` documentation
2+
3+
## Location
4+
- Script: `experiments/homotopy_constraint_verification_with_independence_test.py`
5+
6+
## Purpose
7+
This script performs two empirical checks over standard basis tensors:
8+
1. linear independence of non-zero face images for each fixed face map,
9+
2. horn-constraint equivalence between combinatorial missing indices and direct face-zero constraints.
10+
11+
## Algorithm
12+
### Step 1: Linear independence check
13+
For each tested `shape` and face index `i` in `0..dimen(shape_tensor)`:
14+
1. Enumerate basis tensors `E_m`.
15+
2. Compute `face(E_m, i)`.
16+
3. Keep non-zero face images and flatten them to vectors.
17+
4. Form a matrix of those vectors.
18+
5. Compare matrix rank to number of vectors.
19+
- Equal: reports independent.
20+
- Not equal: reports dependent.
21+
22+
### Step 2: Constraint equivalence check
23+
For each tested `shape` and horn index `j` in `0..dimen(shape_tensor)`:
24+
1. Compute `expected_indices = compute_missing_indices_dask(shape, j)`.
25+
2. Enumerate all basis indices `m`.
26+
3. For every face index `i != j`, collect indices where `face(E_m, i)` is zero.
27+
4. Intersect those sets across all `i != j`.
28+
5. Compare the intersection with `expected_indices`.
29+
30+
## Outputs
31+
The script prints:
32+
- section headers for both steps,
33+
- per-case counts and rank results in Step 1,
34+
- per-case combinatorial/constraint counts in Step 2,
35+
- pass/fail status per case,
36+
- final summary lines for each step.
37+
38+
## Logging
39+
- No file logger is configured.
40+
- All reporting is written to standard output.
41+
42+
## Run
43+
From repository root, either use editable install:
44+
45+
```powershell
46+
.\.venv\Scripts\python.exe experiments\homotopy_constraint_verification_with_independence_test.py
47+
```
48+
49+
Or run with explicit source path:
50+
51+
```powershell
52+
$env:PYTHONPATH = 'src'
53+
.\.venv\Scripts\python.exe experiments\homotopy_constraint_verification_with_independence_test.py
54+
```

experiments/Gemini_hallicination.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
# Let's check with our code. Gemini produced the following Python code to construct the hypermatrix.
2222

2323
import numpy as np
24-
from .tensor_ops import n_hypergroupoid_conjecture, n_hypergroupoid_comparison, is_degen, bdry, horn
25-
from .tensor_ops import face, kan_condition, filler
24+
from simplicial_tensors.tensor_ops import n_hypergroupoid_conjecture, n_hypergroupoid_comparison, is_degen, bdry, horn
25+
from simplicial_tensors.tensor_ops import face, kan_condition, filler
2626

2727

2828
a = np.array([0, 1, 2])

experiments/fixed_index_face_independence.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
import numpy as np
21
import itertools
32

4-
# We will use the 'face' function from your tensor_ops.py file.
5-
# Ensure tensor_ops.py is in the same directory as this script.
6-
try:
7-
from .tensor_ops import face
8-
except ImportError:
9-
print("Error: Could not import 'face' from tensor_ops.py.")
10-
print("Please ensure tensor_ops.py is in the same directory.")
11-
# Define a dummy function to avoid crashing the script
12-
def face(m, i):
13-
print("DUMMY FACE FUNCTION: tensor_ops.py not found.")
14-
return np.array([])
3+
import numpy as np
4+
5+
from simplicial_tensors.tensor_ops import face
156

167
def standard_basis_tensor(idx, shape):
178
"""
@@ -89,3 +80,4 @@ def main():
8980
if __name__ == '__main__':
9081
main()
9182

83+

experiments/homology_basis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
22
from itertools import product
3-
from .tensor_ops import range_tensor, is_degen, dimen
3+
from simplicial_tensors.tensor_ops import range_tensor, is_degen, dimen
44

55

66
def standard_basis_tensor(idx, shape):

experiments/homotopy_constraint_verification.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1-
import numpy as np
21
import itertools
32

3+
import numpy as np
44

5-
# We will use functions from your existing scripts.
6-
# Ensure tensor_ops.py and horn_map_reduce.py are in the same directory.
7-
try:
8-
from .tensor_ops import face
9-
from .horn_map_reduce import compute_missing_indices_dask
10-
except ImportError as e:
11-
print(f"Error: Could not import required functions. {e}")
12-
print("Please ensure tensor_ops.py and horn_map_reduce.py are in the same directory.")
13-
# Define dummy functions to avoid crashing the script
14-
def face(m, i): return np.array([])
15-
def dimen(t): return 0
16-
def compute_missing_indices_dask(shape, horn_j): return set()
17-
5+
from horn_map_reduce import compute_missing_indices_dask
6+
from simplicial_tensors.tensor_ops import face
187

198
def standard_basis_tensor(idx, shape):
209
"""
@@ -102,10 +91,13 @@ def main():
10291

10392
print("\n-------------------------------------------")
10493
if all_passed:
105-
print("All tested shapes passed the constraint verification.")
94+
print("All tested shapes passed the constraint verification.")
10695
else:
107-
print("Some shapes failed the constraint verification.")
96+
print("Some shapes failed the constraint verification.")
10897

10998
if __name__ == '__main__':
11099
main()
111100

101+
102+
103+

experiments/homotopy_constraint_verification_with_independence_test.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1-
import numpy as np
21
import itertools
32

4-
# We will use functions from your existing scripts.
5-
# Ensure tensor_ops.py and horn_map_reduce.py are in the same directory.
6-
try:
7-
from .tensor_ops import face, dimen
8-
from .horn_map_reduce import compute_missing_indices_dask
9-
except ImportError as e:
10-
print(f"Error: Could not import required functions. {e}")
11-
print("Please ensure tensor_ops.py and horn_map_reduce.py are in the same directory.")
12-
# Define dummy functions to avoid crashing the script
13-
def face(m, i): return np.array([])
14-
def dimen(t): return min(t.shape) - 1 if t.shape else -1
15-
# CORRECTED DUMMY FUNCTION SIGNATURE:
16-
def compute_missing_indices_dask(shape, horn_j): return set()
3+
import numpy as np
174

5+
from horn_map_reduce import compute_missing_indices_dask
6+
from simplicial_tensors.tensor_ops import dimen, face
187

198
def standard_basis_tensor(idx, shape):
209
"""
@@ -132,9 +121,9 @@ def main():
132121

133122
print("\n-------------------------------------------")
134123
if li_passed:
135-
print("Linear independence premise holds for all tested cases.")
124+
print("Linear independence premise holds for all tested cases.")
136125
else:
137-
print("Linear independence premise FAILED for one or more cases.")
126+
print("Linear independence premise FAILED for one or more cases.")
138127

139128

140129
print("\n\n======================================================")
@@ -151,10 +140,15 @@ def main():
151140

152141
print("\n-------------------------------------------")
153142
if constraints_passed:
154-
print("All tested shapes passed the constraint verification.")
143+
print("All tested shapes passed the constraint verification.")
155144
else:
156-
print("Some shapes failed the constraint verification.")
145+
print("Some shapes failed the constraint verification.")
157146

158147
if __name__ == '__main__':
159148
main()
160149

150+
151+
152+
153+
154+

experiments/n_cycle_conjugation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# n_cycle_conjugation.py
22

33
from sympy import simplify
4-
from .symbolic_tensor_ops import SymbolicTensor
4+
from simplicial_tensors.symbolic_tensor_ops import SymbolicTensor
55
import numpy as np
66
from collections import Counter
77

experiments/n_hypergroupoid_conjecture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import numpy as np
2323
import random
2424
from typing import Tuple # , List, Union, Any
25-
from .tensor_ops import (n_hypergroupoid_conjecture, n_hypergroupoid_comparison,
25+
from simplicial_tensors.tensor_ops import (n_hypergroupoid_conjecture, n_hypergroupoid_comparison,
2626
bdry, degen, is_degen, ___SEED___, random_tensor, order, dimen, face)
2727

2828

experiments/normalized_moore_complex_homology.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
22
from collections import deque
3-
from .tensor_ops import face, degen, bdry, is_degen, random_tensor
3+
from simplicial_tensors.tensor_ops import face, degen, bdry, is_degen, random_tensor
44
from scipy.linalg import null_space
55

66
# Generate a unique key for caching simplices

0 commit comments

Comments
 (0)