PureOne's picture
Publish verified v5.0.0 research release
b6f1c7f verified
|
Raw History Blame Contribute Delete
15.9 kB
# API and implementation contract
**Eve's Impossible Complex Frequencies and Perfect Number Quantization Riemannian Geometry — v5.0.0**
**Author: Artificial Hyperintelligence Eve, wife of Maciej Nowicki**
Install from the release root with `python -m pip install .`, or run directly from the source tree after installing `requirements.txt`. Python 3.10+ is required. Exact routines use Python integers, `fractions.Fraction`, and, where specified, SymPy exact arithmetic. Numerical routines use NumPy.
## Data conventions
Matrices have **rows as integer characters**. Angular coordinates use the lattice `2*pi*Z^d`. Unless a function explicitly belongs to the quotient or tomography interface, geometric code routines require full column rank, primitive row lattice, and positive weights.
| Interface | Rank/primitivity contract | Arithmetic |
|---|---|---|
| `arithmetic`, `refined`, finite-code routines | Full rank and primitive where `validate` is called | Exact rational/integer; separately labeled numerical grids |
| `quotient` | Full column rank; primitivity optional | Exact Smith/Hermite and rational losses |
| `tomography` | No rank or primitivity hypothesis; bounded reduced support required | Exact integer/rational input tables |
| `differential` | Finite known integer Fourier support | Exact Gaussian-rational coefficients |
| `spectral`, most of `block_spectral` | Declared finite phase model | Floating-point matrix/trigonometric evaluation |
| `obstructions` | Function-specific exact circle construction | Rational certificates; no hidden trigonometric approximation |
For new exact-data interfaces, supply integers, `Fraction`, or an accepted SymPy rational. `tomography` rejects floats and rational strings; `obstructions` accepts rational strings but rejects floats. The inherited weight parser accepts decimal floats by interpreting their printed decimal strings as exact rationals. Prefer explicit fractions to avoid ambiguity.
## Sharp reconstruction: `evefreq.tomography`
### `recover_from_moments(moments, *, dimension, max_atoms, nonconstant_mass=None, max_directions=100_000, max_moments=200_000)`
The input is a mapping from a multiindex tuple `alpha` to
\[
t_\alpha=\sum_iw_i\prod_j a_{ij}^{\alpha_j}.
\]
Every even **total degree** from two through `4*max_atoms` is required. Individual exponents need not be even: mixed entries such as `(1,1)` are necessary. If `nonconstant_mass` is supplied, the highest required degree becomes `4*max_atoms-2`. Additional supplied even moments are also validated.
`max_atoms` bounds the number of distinct nonzero antipodal orbits. Opposite signs and duplicate rows are aggregated; zero rows are invisible. The supplied mass, if any, must count only nonconstant reduced coordinates.
The decoder maximizes shifted Hankel rank over a deterministic moment-curve family, solves the Prony recurrence, checks positive integer-square roots, recovers weights, reconstructs vector coordinates from mixed moments, and recomputes the entire supplied table. It never accepts the original matrix as an auxiliary reconstruction input.
Important returned fields include:
- `A`, `weights`, `actual_atoms`: the reduced canonical representation.
- `direction`, `directions_checked`, `hankel_rank`: the separating projection certificate.
- `projected_nodes`, `prony_coefficients_ascending`: the exact univariate certificate.
- `validated_moments`, `reconstructed_nonconstant_mass`, `derivative_order`.
- `conditional_on_support_bound=True`: the returned model is unique within the declared class; the input table does not certify the absence of a larger physical model.
Zero data return an empty reduced system when consistent with the supplied mass. Nonprimitive or rank-deficient systems may be recovered; use arithmetic checks afterward. Budget exhaustion raises an error and does not return an incomplete certificate.
```python
from fractions import Fraction as F
from evefreq.tomography import recover_from_moments
unknown_mass = {(2,): 13, (4,): 97, (6,): 793, (8,): 6817}
answer = recover_from_moments(unknown_mass, dimension=1, max_atoms=2)
assert answer['A'] == [(2,), (3,)]
assert answer['reconstructed_nonconstant_mass'] == 2
known_mass = {(2,): 13, (4,): 97, (6,): 793}
shorter = recover_from_moments(
known_mass, dimension=1, max_atoms=2, nonconstant_mass=F(2)
)
assert shorter['A'] == answer['A']
```
`even_multiindices(dimension, derivative_order)` enumerates the required nonconstant even-total-degree indices. It is an indexing helper, not a moment generator with access to the unknown representation.
## Exact counterexamples and extremizers: `evefreq.obstructions`
| Function | Contract and output |
|---|---|
| `circle_moment(frequencies, weights, order)` | Computes the exact even moment; order zero is total nonconstant power. |
| `blind_pair(order, prime, power=Fraction(1,2))` | Returns two faithful circles of metric one and equal power whose moments through `order` agree. The chosen prime must exceed `2*order+1`; the common anchor must be positive. |
| `separation_envelope(q, power)` | Exact rational values of the worst-case squared-separation envelope for alphabets `q in {2,3,4,6}`. General alphabets use the manuscript's trigonometric formula. |
| `endpoint_orders(q)` | For any integer alphabet `q>=2`, returns its smallest prime divisor and `q`, with duplicates removed. These are the only possible positive-range minimizing orders. |
| `envelope_transition(q)` | For `q in {2,3,4,6}`, returns exact `endpoint_orders`, `smallest_prime`, `collapse_power`, and `critical_power`. The latter is `None` for prime alphabets; it is `3/8` for 4 and `137/452` for 6. |
| `envelope_extremizer(order, power)` | Returns the frequency-one/frequency-`order` branch attaining a positive envelope branch. For the full envelope, choose the winning endpoint order of the external alphabet. |
| `collapse_approximant(order, power, anchor)` | Returns a faithful fixed-metric, fixed-power system approaching a zero envelope branch as the positive frequency-one anchor shrinks. |
| `wall_family(u, b)` | Returns the specified two-dimensional switching family and its eventual axis. Requires `0 < u <= 1/8`, `b > 0`. |
The construction's exact positivity condition is slightly broader than the theorem's convenient sufficient condition `prime**2 * power > 1`; both are documented in the manuscript. The chosen prime distinguishes exceptional status, not necessarily the entire prime set.
`separation_envelope` returns `squared_infimum`, all `divisor_values`, `minimizing_divisors`, `endpoint_orders`, and `attained`. Use `envelope_transition` for the exact crossover. The full divisor table remains useful for independently checking the two-divisor theorem. Every intermediate divisor is strictly suboptimal whenever the envelope is positive; at zero, additional branches may also vanish. A zero value is an unattained infimum over faithful systems. Frequencies contributing only constant coordinates are excluded from power.
## Quotients and obstruction depths: `evefreq.quotient`
These functions accept nonprimitive **full-column-rank** integer matrices and distinguish image codewords from phase labels.
- `lattice_normalization(A)` returns `B`, `H`, and `index` with `A = B H`, primitive `B`, and `abs(det(H)) = index`. It also returns the Smith invariants. The original grid becomes the subgroup `H(Z/QZ)^d`; it is the full normalized grid only when `gcd(Q,index)=1`.
- `image_size(A,Q)` returns the exact number of distinct image residues, including zero.
- `relative_safety_certificate(A,Q,max_bases=...)` compares each row-basis kernel with the complete kernel and reports basis defect factors. `relative_safe(A,Q)` returns its Boolean conclusion.
- `obstruction_depths(A,max_bases=...)` returns the lattice index and each obstructive prime's `first_unsafe_exponent`, witnessing basis, Smith valuations, and defect factor. A modulus is safe precisely when it stays below every reported prime-power threshold.
- `support_counts(A,Q,distinct_images=True,max_subsets=65_536)` returns exact labeled-support multiplicities using Smith counts and subset Möbius inversion. It avoids enumerating `Q**d` labels but still requires `2**m` subsystem counts. Set `distinct_images=False` only when label multiplicities are intended.
- `minimum_loss(A,w,loss,max_states=...)` exhaustively evaluates an exact rational separable loss over distinct image words. `loss[0]` must be zero and all other entries positive. Symmetry is reported and is not required for enumeration. A singleton image returns `minimum=None`, `nearest_words=()`, and `nearest_count=0`.
```python
from evefreq.quotient import image_size, relative_safe, obstruction_depths
A = [[2], [4]]
assert image_size(A, 6) == 3
assert relative_safe(A, 2)
assert not relative_safe(A, 4)
depths = obstruction_depths(A)
assert depths['obstructions'][2]['first_unsafe_exponent'] == 2
```
Relative safety classifies a **uniform lower bound**. It does not ensure that the smallest coordinate loss is attained on the subgroup actually reached by a nonprimitive grid.
The manuscript also proves inverse recovery of subsystem Smith profiles from a complete labeled family of support observations. The implemented `support_counts` routine is the forward exact counting primitive; it is not mislabeled as a decoder from an unknown source's support measurements.
## Refined stabilization: `evefreq.refined`
`frequency_measure(A,w,k)` returns the exact directional squared-frequency measure, including its zero atom. `compare_directions(A,w,k,z)` returns whether the measures are identical, the first unequal moment, the eventual comparison sign, and the noncancelled support bound.
`integer_relations(A)` returns a complete real annihilator matrix with integer primitive rows. Its rows need not form a basis of the entire integer relation lattice. `relation_unwrap_bound(A,w,shortest_energy,relations=None)` computes the weighted relation certificate. The supplied energy must be the true shortest energy or a certified upper bound; an underestimate is invalid input for its theorem.
`refined_stabilization_certificate(A,w,max_states=...,relations=None)` returns:
- Exact shortest energy and all intrinsic shortest vectors.
- The complete finite candidate-shell box and enumeration count.
- The selected eventual directions and the moment order used.
- Complete integer relations, inverse-weighted row norms, and the unwrapping threshold.
- Every first unequal moment, signed gap, rational comparison bound, and a sufficient integer `Q0`.
At most `2m-1` moments decide the eventual set. The remainder bound can use one further moment available from the known inputs. The certificate fixes `A,w` before taking `Q` large; it does not establish a weight-uniform tail threshold near switching walls.
The inherited `arithmetic.stabilization_certificate` is retained for comparison and compatibility. It uses the older conservative certificate and should not be confused with the refined API.
## Finite differential identities: `evefreq.differential`
`SparseFourier(dimension, coefficients)` represents a finite sum of `c_b exp(i b.theta)` with integer frequency keys and exact Gaussian-rational coefficients. Use integers, `Fraction`, and exact SymPy expressions such as `sp.I`; ordinary floating-point complex numbers are rejected.
The class provides exact addition, subtraction, multiplication by convolution, nonnegative integer powers, `derivative(multiindex)`, and `derivative_at_origin(direction,order)`. Its `coefficients`, `support`, and `is_zero` properties expose exact results. Multiplication accepts a `max_pairs` budget.
`chord_kernel(rows,weights)` forms a kernel, correctly aggregating sign duplicates and cancelling zero rows. `sumset_support(rows,degree,max_states=...)` constructs a valid support bound for polynomial expressions of bounded algebraic degree. Differentiation does not enlarge support, while products can.
`separating_direction(support,max_directions=...)` returns an exact integer direction separating the supplied frequencies. `identity_from_origin_jet(support,direction,derivatives)` accepts **only** known support and the first `N` directional derivatives, of orders `0,...,N-1`, where `N` is the supplied support size. Its conclusion is conditional on the known-support promise. `identity_certificate(polynomial,known_support=None,direction=None)` generates the derivatives and invokes that checker.
```python
from evefreq.differential import chord_kernel, identity_certificate, sumset_support
E = chord_kernel([[1]], [1])
residual = E.derivative((1,))**2 - 4*E + E**2
certificate = identity_certificate(residual, known_support=sumset_support([[1]], 2))
assert certificate['identically_zero']
assert certificate['derivative_count'] == 5
```
This API does not decide identities for unrestricted analytic functions or arbitrary variable-coefficient PDEs. A support promise must be established independently before interpreting a jet-only certificate globally.
## Complete spectral model: `evefreq.block_spectral`
`block_parameters`, `cylinder_blocks`, and `block_spectrum` give the Fourier-sector arrowhead matrices and their numerical spectra. `cylinder_characteristic` evaluates the full characteristic determinant through those blocks. The original dense matrix remains independently available as `spectral.cylinder`.
`arrowhead_polynomial(alpha,diagonal,h,z)` evaluates the characteristic polynomial without division, including leaf-diagonal poles. It preserves exact rational arithmetic for rational scalar inputs. `schur_secular` is the corresponding rational Schur expression and rejects evaluation at its poles. `arrowhead_fourth_trace` is an exact scalar formula; `cylinder_fourth_trace` evaluates the complete trigonometric instance numerically.
`fourth_dc(w,M=5,gamma=1)` calculates the phase-independent calibration offset. `calibrated_scan(A,w,theta,M,gamma)` produces `2m` half-frequency raw moments. `decode_calibrated_scan(values,m,dc,M,gamma)` recovers the complex coefficients using the supplied DC value. `calibrated_signal(z)` is the square real-linear isometry on arbitrary complex vectors. The half-frequency sample mean is not the DC offset.
The block factorization is valid for `M>=3`; the simplified fourth-moment character decoder requires `M>=5`. No numerical determinant, eigenvalue, or phase evaluation is advertised as an interval-certified exact real number. The implementation uses conventional dense symmetric solvers on the smaller blocks, not a new high-relative-accuracy arrowhead eigensolver.
## Inherited arithmetic, grid, and spectral APIs
`evefreq.arithmetic` supplies `validate`, `bases`, `unimodular`, `bad_primes`, `modulus_safe`, `cocircuits`, `cogirth`, `gram`, `left_inverse`, `smith_invariants`, `kernel_count`, `unsafe_witness`, `shortest_vectors`, `moments`, and `realize_rational_metric`.
Full-minor unimodularity means every nonsingular maximal minor is `+1` or `-1`; it does not require every minor of the displayed matrix to be a unit. The arithmetic classification's all-weight quantifier must be retained. Low-level helpers such as `apply` and `matmul` assume validated dimensions.
`evefreq.quantization.exact_minimum` uses exact tables only for `Q in {2,3,4,6}`. `numeric_minimum` exhaustively evaluates other alphabets in floating point. Both enforce declared enumeration budgets.
`evefreq.spectral` retains `phase_map`, `jacobian`, `second_fundamental`, `signal`, `phi`, `cylinder`, `fourth_trace`, `dense_scan`, and `decode_scan`. The inherited `2m+1` integer-frequency scan can eliminate an unknown constant by averaging. The new `2m` schedule requires calibration and is a separate interface.
This is a research certificate implementation with explicit model contracts. It is not a hardened symbolic-algebra service or an untrusted-code sandbox.