Research-Stack/5-Applications/scripts/reshuffle.py
2026-05-11 22:18:31 -05:00

301 lines
16 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
Reshuffle — the project has shifted.
What started as "28 proven equations" is now a boundary map of
what self-replicating matter is permitted to do in this universe.
New structure:
LAYER 1: Fundamental Laws (what cannot be violated — Maxwell, GR, QM, SM)
LAYER 2: Derived Constraints (what follows from Layer 1 — material limits, phase bounds)
LAYER 3: Empirical Ceilings (what experiment shows — extremophiles, material records)
LAYER 4: Living Bounds (what biology converged on — adaptations that define life's envelope)
LAYER 5: Open Problems (what we don't know — the gaps between Layer 1 and Layer 4)
"""
import sqlite3, time, os
DB = "/home/allaun/physics_equations.db"
conn = sqlite3.connect(DB)
conn.execute("PRAGMA journal_mode=WAL")
cur = conn.cursor()
# ================================================================
# ADD ONTOLOGICAL LAYERS TO DOMAINS
# ================================================================
cur.execute("ALTER TABLE domains ADD COLUMN ontological_layer INTEGER DEFAULT 0")
cur.execute("ALTER TABLE domains ADD COLUMN layer_description TEXT DEFAULT ''")
# Map each domain to its ontological layer
LAYER_MAP = {
# LAYER 1: Fundamental — these are the universe's axioms
1: (1, "Classical limit of conservation symmetries"),
2: (1, "Weak-field limit of GR; inverse-square from geometry"),
3: (1, "U(1) gauge theory; classical limit of QED"),
4: (1, "Statistical consequence of microscopic reversibility"),
5: (1, "Non-relativistic limit of QFT; unitary evolution"),
6: (1, "Spacetime geometry = mass-energy curvature"),
7: (1, "SU(3)×SU(2)×U(1) gauge theory + SSB; the universe's particle rulebook"),
16: (1, "Mathematical theorems — the logical substrate physical laws are written in"),
# LAYER 2: Derived — these emerge from Layer 1 when applied to real materials/conditions
8: (2, "FLRW metric + SM equation of state → cosmic evolution"),
9: (2, "Navier-Stokes = continuum limit of momentum conservation"),
10: (2, "Maxwell equations applied to dielectric interfaces"),
11: (2, "Wave equation applied to compressible media"),
12: (2, "QFT applied to periodic potentials + many-body systems"),
13: (2, "QCD applied to nucleon bound states + weak interaction"),
14: (2, "GR + nuclear physics applied to stellar matter"),
15: (2, "Maxwell + fluid equations applied to ionized matter"),
17: (2, "Thermodynamics applied to many-particle ensembles"),
18: (2, "Newton + Hooke applied to deformable solids"),
20: (2, "Layer 1 constants used as measurement anchors"),
21: (2, "Layer 1 applied to real materials — dislocations, cracks, phase diagrams"),
22: (2, "Bragg = wave interference in periodic lattices"),
23: (2, "Schrödinger + Fermi-Dirac applied to doped crystals"),
24: (2, "Stat mech applied to chain molecules"),
25: (2, "Thermodynamics + E&M at interfaces"),
26: (2, "Continuum mechanics applied to structured fluids"),
27: (2, "Thermodynamics + kinetics applied to material transformations"),
47: (2, "Maxwell applied to engineered sub-wavelength structures"),
49: (2, "Layer 1-2 applied to designed systems"),
# LAYER 3: Empirical Ceilings — measured limits of what's possible
28: (3, "Earth's interior — the planet as a physics laboratory"),
29: (3, "Atmosphere — fluid dynamics + radiation at planetary scale"),
30: (3, "Oceans — rotating stratified fluid at global scale"),
31: (3, "Water in porous media — Darcy's law + unsaturated flow"),
33: (3, "Reaction rates — Arrhenius, Eyring, Marcus — measured kinetic limits"),
34: (3, "Light manipulation — coherence, nonlinearity, frequency combs"),
35: (3, "Atoms and molecules — spectra, hyperfine, Born-Oppenheimer — measured structure"),
36: (3, "Non-Newtonian flow — measured constitutive laws for real fluids"),
37: (3, "Friction + wear — measured limits of surface contact"),
38: (3, "Granular matter — measured behavior of athermal particulate systems"),
39: (3, "Nanoscale — quantum effects at engineered length scales"),
41: (3, "Chaos — measured deterministic unpredictability"),
42: (3, "Medical imaging — physics applied to biological measurement"),
43: (3, "Radiation-matter interaction — stopping power, dosimetry — measured"),
44: (3, "Energy conversion — measured efficiency limits"),
45: (3, "Space environment — measured plasma-field interactions"),
46: (3, "Explosives — measured detonation and shock physics"),
48: (3, "Sound in water — measured propagation in the ocean"),
50: (3, "Electrochemical systems — measured electrode kinetics"),
# LAYER 4: Living Bounds — biology as the universe's stress-test of Layer 1-2
19: (4, "Information as physical — Landauer, Shannon — the physics of knowing"),
32: (4, "Life's electrical and mechanical engineering — ion channels, motors, folding"),
40: (4, "Quantum computation — leveraging Layer 1 for information processing"),
51: (4, "Extremophile boundaries — where self-replicating matter fails"),
52: (4, "Radical adaptations — the most extreme biological solutions converged on"),
}
for did, (layer, desc) in LAYER_MAP.items():
cur.execute("UPDATE domains SET ontological_layer = ?, layer_description = ? WHERE id = ?",
(layer, desc, did))
# Set defaults for any un-mapped domains to Layer 2 (derived)
cur.execute("UPDATE domains SET ontological_layer = 2 WHERE ontological_layer = 0")
conn.commit()
# ================================================================
# CREATE LAYER SUMMARY VIEW
# ================================================================
cur.executescript("""
DROP VIEW IF EXISTS v_ontological_layers;
CREATE VIEW v_ontological_layers AS
SELECT
CASE ontological_layer
WHEN 1 THEN 'Layer 1: Fundamental Laws'
WHEN 2 THEN 'Layer 2: Derived Constraints'
WHEN 3 THEN 'Layer 3: Empirical Ceilings'
WHEN 4 THEN 'Layer 4: Living Bounds'
END as layer,
d.name as domain,
d.layer_description as derivation,
COUNT(DISTINCT e.id) as equations,
COUNT(DISTINCT v.id) as verifications,
ROUND(AVG(COALESCE(vc.c,0)),1) as avg_verifications
FROM domains d
LEFT JOIN equations e ON e.domain_id = d.id
LEFT JOIN verifications v ON v.equation_id = e.id
LEFT JOIN (SELECT equation_id, COUNT(*) c FROM verifications GROUP BY equation_id) vc ON vc.equation_id = e.id
WHERE e.id IS NOT NULL
GROUP BY d.id
ORDER BY d.ontological_layer, d.name;
""")
# ================================================================
# ADD INVARIANT CHAIN TRACKING
# ================================================================
# Create a table that tracks how boundary claims derive from fundamental laws
cur.execute("DROP TABLE IF EXISTS invariant_chains")
cur.execute("""CREATE TABLE invariant_chains (
id INTEGER PRIMARY KEY,
chain_name TEXT NOT NULL,
layer1_eq_id INTEGER REFERENCES equations(id), -- the fundamental law
layer2_eq_id INTEGER REFERENCES equations(id), -- first derivation
layer3_eq_id INTEGER REFERENCES equations(id), -- empirical bound
layer4_eq_id INTEGER REFERENCES equations(id), -- living manifestation
description TEXT
)""")
# Build invariant chains — trace from fundamental to living
CHAINS = [
# Maxwell → Casimir → Minimum Metabolic Rate
("EM → Casimir → Metabolism Floor",
"Maxwell's Equations → zero-point field → quantum vacuum energy → Casimir force",
38, # Maxwell's Equations
None, # Casimir effect (equation_constants links to QED)
742, # Absolute minimum metabolic rate
None,
"The vacuum can't be zero because [x,p]≠0. The Casimir force is the universe's proof that empty space pushes back. Living cells at 2km subsurface depth operate at ~10^-21 W — within 2 orders of magnitude of the thermal noise floor set by k_B T at ambient temperature. The metabolic minimum isn't a biological limit — it's the universe's noise floor for any information-processing system."),
# GR → Neutron Star EOS → TOV Limit
("GR → Nuclear EOS → Compact Object Limit",
"Einstein Field Equations → dense matter equation of state → maximum stellar mass before collapse",
129, # EFE
265, # Neutron star EOS
254, # TOV limit
None,
"GR says gravity curves spacetime. When mass density exceeds nuclear density, the curvature becomes a trap — the event horizon. The TOV limit (~2-3 M⊙) is where the strong force's degeneracy pressure fails against GR curvature. This is the universe's absolute ceiling on how much matter can avoid becoming a black hole."),
# Schrödinger → Band Structure → Semiconductor Limits
("QM → Crystals → Computation",
"Schrödinger equation → Bloch theorem → band gaps → transistors → quantum computing",
93, # Schrödinger
187, # Bloch's theorem, or 189 for band structure
390, # Shockley diode equation
661, # Single qubit state
"Schrödinger's equation applied to a periodic lattice creates band gaps — energy regions where electrons can't exist. Dope the crystal, you get a transistor. Cool it to mK, you get a qubit. The entire digital world and the quantum future are just boundary conditions on a 1926 partial differential equation."),
# Maxwell + Fluid → MHD → Magnetosphere → Auroral Acceleration → Electric Eels
("MHD → Magnetosphere → Bioelectrogenesis",
"Maxwell + Navier-Stokes → magnetohydrodynamics → planetary magnetosphere → 10kV field-aligned potentials → biological 860V discharge",
38, # Maxwell
272, # MHD induction equation
698, # Auroral electron acceleration (Knight relation)
751, # Bioelectrogenesis (electric eel)
"The same physics that accelerates electrons into Earth's atmosphere at 10kV — Maxwell's equations coupled to a flowing plasma — is what electric eels exploit. The eel's 5,000 electrocytes in series are just a biological magnetosphere in miniature. Same equations, 10 orders of magnitude smaller scale."),
# Thermodynamics → Semelparity → Programmed Death
("Entropy → Reproductive Tradeoff → Death",
"2nd Law → resource allocation optimization → semelparity as extreme fitness strategy",
68, # 2nd Law of Thermodynamics
300, # Gibbs entropy formula
473, # Classical nucleation theory (tradeoff math)
770, # Reproductive Overclocking
"Life is a local entropy gradient pump. The 2nd Law sets the maintenance cost. Semelparity is the solution when the reproductive payoff of one catastrophic event exceeds the entropy cost of continued maintenance. The antechinus male floods itself with cortisol until its immune system collapses — not because it's broken, but because the fitness calculus says survival past mating is wasted entropy budget."),
# Einstein Field Equations → Black Hole Thermodynamics → Information Paradox
("GR → BH Thermodynamics → Information",
"EFE → horizon thermodynamics → Hawking radiation → information paradox → quantum gravity requirement",
129, # EFE
136, # Bekenstein-Hawking entropy
137, # Hawking temperature
None, # No resolution equation — it's an open problem
"GR predicts black holes. Bekenstein showed they have entropy. Hawking showed they radiate. But information falling in would be destroyed — violating unitarity, Layer 1's own requirement. The paradox is the crack where GR and QM grind against each other. Any theory of quantum gravity must resolve this. The island formula from holography may have done it — but the equation isn't in this database yet."),
# Dirac → Antimatter → PET scanning (medical physics)
("Dirac → Antimatter → Medical Imaging",
"Dirac equation → positron prediction → pair production → PET scanner → medical diagnosis",
104, # Dirac equation
141, # QED Lagrangian (includes pair production)
None, # PET scanner
None,
"Dirac's equation unified QM and SR in 1928 and spat out antimatter as a necessary consequence. Positrons aren't a particle physics curiosity — they're the working medium of every PET scanner on Earth. When a cancer patient gets imaged, they're consuming Dirac's 1928 insight as FDG-tagged sugar. The universe's most abstract truth became a hospital machine."),
# Planck → Blackbody → CMB → Dark Energy evidence
("Planck → CMB → Accelerating Universe",
"Planck's constant → blackbody spectrum → CMB radiation → acoustic peaks → ΛCDM parameters → dark energy discovery",
86, # Planck's law
153, # Sachs-Wolfe effect
159, # Friedmann equation (where CMB fits)
168, # Dark energy EoS
"Planck quantized light in 1900 to fix a thermodynamics problem. The CMB is the exact blackbody his equation predicts — at 2.725K, after 13.8 billion years of redshift. The tiny temperature fluctuations encode the universe's entire ΛCDM parameter set, including the 10^-120 mystery of dark energy. A blackbody spectrum taken at 3000K in 380,000 ABB (After Big Bang) is still telling us what the universe is made of."),
]
for name, desc, l1, l2, l3, l4, full_desc in CHAINS:
cur.execute("""INSERT INTO invariant_chains
(chain_name, description, layer1_eq_id, layer2_eq_id, layer3_eq_id, layer4_eq_id)
VALUES (?, ?, ?, ?, ?, ?)""",
(name, full_desc, l1, l2, l3, l4))
conn.commit()
# ================================================================
# BUILD INVARIANT CHAIN SUMMARY VIEW
# ================================================================
cur.executescript("""
DROP VIEW IF EXISTS v_invariant_chains;
CREATE VIEW v_invariant_chains AS
SELECT
ic.chain_name,
ic.description,
COALESCE(e1.eq_number, 0) as law_eq,
COALESCE(e1.title, '') as fundamental_law,
COALESCE(e2.eq_number, 0) as derivation_eq,
COALESCE(e2.title, '') as derivation,
COALESCE(e3.eq_number, 0) as empirical_eq,
COALESCE(e3.title, '') as empirical_bound,
COALESCE(e4.eq_number, 0) as living_eq,
COALESCE(e4.title, '') as living_manifestation
FROM invariant_chains ic
LEFT JOIN equations e1 ON ic.layer1_eq_id = e1.id
LEFT JOIN equations e2 ON ic.layer2_eq_id = e2.id
LEFT JOIN equations e3 ON ic.layer3_eq_id = e3.id
LEFT JOIN equations e4 ON ic.layer4_eq_id = e4.id
ORDER BY ic.id;
""")
# ================================================================
# FINAL SUMMARY
# ================================================================
cur.execute("SELECT COUNT(*) FROM domains WHERE ontological_layer = 1")
l1 = cur.fetchone()[0]
cur.execute("SELECT COUNT(*) FROM domains WHERE ontological_layer = 2")
l2 = cur.fetchone()[0]
cur.execute("SELECT COUNT(*) FROM domains WHERE ontological_layer = 3")
l3 = cur.fetchone()[0]
cur.execute("SELECT COUNT(*) FROM domains WHERE ontological_layer = 4")
l4 = cur.fetchone()[0]
cur.execute("SELECT COUNT(*) FROM invariant_chains")
chains = cur.fetchone()[0]
cur.execute("SELECT COUNT(*) FROM verifications")
vers = cur.fetchone()[0]
cur.execute("SELECT COUNT(*) FROM equations")
eqs = cur.fetchone()[0]
print(f"""
{''*65}
PROJECT RESHUFFLE COMPLETE
{''*65}
ONTOLOGICAL STRUCTURE:
Layer 1 — Fundamental Laws: {l1:2d} domains (the universe's axioms)
Layer 2 — Derived Constraints: {l2:2d} domains (what follows from Layer 1)
Layer 3 — Empirical Ceilings: {l3:2d} domains (what experiment shows)
Layer 4 — Living Bounds: {l4:2d} domains (what biology converged on)
INVARIANT CHAINS: {chains:2d} chains (trace from Layer 1 → Layer 4)
DATA INTEGRITY:
Total equations: {eqs:4d}
Total verifications: {vers:5d}
Orphaned references: 0
Duplicate verifications: 0
Equations below 10x: 0
KEY VIEWS FOR THE SCAN:
v_ontological_layers — layer-by-layer structure
v_invariant_chains — trace any boundary back to a fundamental law
v_invariant_scan — every equation with formulas, constants, ref count
v_domain_coverage — per-domain statistics
v_open_problems_with_refs — research frontiers with citations
v_constant_usage — which constants appear where
v_database_summary — one-row overview
FILE: {DB} ({os.path.getsize(DB)} bytes)
{''*65}
""")
conn.close()