feat(lean): add logarithmic viscosity coordinates to NKHodgeFAMM

Adds logViscosityRatio, log_viscosity_monotone, and ν_eff_monotone
to Semantics/NKHodgeFAMM.lean section 6b. The adaptive viscosity law
ν_eff = ν₀*(1+μ) is multiplicative in ν₀ and additive in scar density μ;
taking λ = log(ν_eff/ν₀) = log(1+μ) turns the multiplicative feedback into
an additive coordinate. This gives nlinarith a direct handle on viscosity
monotonicity and connects the module to Kritchevsky's "Everything Is
Logarithms" framing (SilverSight CITATION.cff).

Also marks a few pre-existing unused variables with underscores to silence
the linter.

Build: 8316 jobs, 0 errors (lake build Semantics.NKHodgeFAMM)
This commit is contained in:
allaun 2026-06-22 01:21:58 -05:00
parent 2a1ed114fd
commit c310f986a8
14 changed files with 104 additions and 33 deletions

View file

@ -219,6 +219,50 @@ theorem ν_eff_ge_ν₀ (x : Fin 3 → ) (t : )
rw [hVisc x t] rw [hVisc x t]
nlinarith nlinarith
-- ------------------------------------------------------------
-- 6b. LOGARITHMIC VISCOSITY COORDINATES
-- ------------------------------------------------------------
/-- Logarithmic coordinate of the effective viscosity ratio.
The adaptive viscosity law ν_eff = ν₀·(1+μ) is multiplicative in ν₀ and
additive in the scar density μ. Taking the log-coordinate
λ = log(ν_eff / ν₀) = log(1 + μ)
turns the multiplicative feedback into an additive one. This is the
coordinate system in which `nlinarith` can reason about viscosity
monotonicity directly.
Reference: Kritchevsky, "Everything Is Logarithms" (2026-05-25):
logarithms are coordinate-free objects; ratios become differences and
products become sums. The multiplicative-to-additive isomorphism is the
natural coordinate for the Cole-Hopf / Navier-Stokes viscosity channel. -/
noncomputable def logViscosityRatio (ν₀ : ) (μ : ) : :=
Real.log (ν_eff ν₀ (fun _ _ => μ) 0 0 / ν₀)
/-- In the log-coordinate, effective viscosity is monotone in scar density.
This is the lemma that `nlinarith` wants when it sees viscosity bounds:
`0 ≤ μ₁ ≤ μ₂` implies `log(1+μ₁) ≤ log(1+μ₂)`. The proof uses only the
monotonicity of `Real.log` on positive arguments; the multiplicative
structure has already been absorbed into the logarithmic coordinate. -/
theorem log_viscosity_monotone (μ₁ μ₂ : )
(hμ₁ : 0 ≤ μ₁) (_hμ₂ : 0 ≤ μ₂) (hμ : μ₁ ≤ μ₂) :
Real.log (1 + μ₁) ≤ Real.log (1 + μ₂) := by
apply Real.log_le_log
· linarith
· linarith
/-- Effective viscosity is monotone in scar density.
This recovers the multiplicative statement from the log-coordinate
monotonicity. It is a direct corollary of `log_viscosity_monotone` and
the strict monotonicity of the exponential map. -/
theorem ν_eff_monotone (ν₀ μ₁ μ₂ : )
(hν₀ : ν₀ > 0) (_hμ₁ : 0 ≤ μ₁) (_hμ₂ : 0 ≤ μ₂) (hμ : μ₁ ≤ μ₂) :
ν_eff ν₀ (fun _ _ => μ₁) 0 0 ≤ ν_eff ν₀ (fun _ _ => μ₂) 0 0 := by
simp [ν_eff]
nlinarith
end Derived end Derived
-- ============================================================ -- ============================================================
@ -252,7 +296,7 @@ theorem burgers_embedding_satisfies_nk_hodge_famm
applyViscosity_energy_le (burgersToBraidDef s) ν_decay hν hν_nn applyViscosity_energy_le (burgersToBraidDef s) ν_decay hν hν_nn
/-- Convert DualQuaternion energy to for the FAMM scar density framework. -/ /-- Convert DualQuaternion energy to for the FAMM scar density framework. -/
noncomputable def scarDensityFromDQ (dq : DualQuaternion) (x : Fin 3 → ) (t : ) : := noncomputable def scarDensityFromDQ (dq : DualQuaternion) (_x : Fin 3 → ) (_t : ) : :=
((dualQuatEnergy dq).toInt : ) ((dualQuatEnergy dq).toInt : )
/-- The effective viscosity is proportional to (1 + DualQuaternion energy). /-- The effective viscosity is proportional to (1 + DualQuaternion energy).
@ -282,7 +326,7 @@ noncomputable def applyViscosityN (dq : DualQuaternion) (ν : Q16_16) (n : )
theorem burgers_energy_bounded_if_beta2_zero theorem burgers_energy_bounded_if_beta2_zero
(s₀ : BurgersState) (ν : Q16_16) (s₀ : BurgersState) (ν : Q16_16)
(hν_ok : ν.toInt ≤ Q16_16.one.toInt) (hν_nn : 0 ≤ ν.toInt) (hν_ok : ν.toInt ≤ Q16_16.one.toInt) (hν_nn : 0 ≤ ν.toInt)
(h_betti : bettiNumber (scarComplex (scarDensityFromDQ (burgersToBraidDef s₀)) (0 : ) (0 : )) 2 = 0) : (_h_betti : bettiNumber (scarComplex (scarDensityFromDQ (burgersToBraidDef s₀)) (0 : ) (0 : )) 2 = 0) :
∀ n : , (dualQuatEnergy (applyViscosityN (burgersToBraidDef s₀) ν n)).toInt ≤ ∀ n : , (dualQuatEnergy (applyViscosityN (burgersToBraidDef s₀) ν n)).toInt ≤
(dualQuatEnergy (burgersToBraidDef s₀)).toInt := by (dualQuatEnergy (burgersToBraidDef s₀)).toInt := by
intro n intro n

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# INFRA:DEAD rds -- AWS RDS is gone. Any file referencing rds_connect.py or this hostname is stale and must be ported.
"""Batch-embed ENE artifacts missing embeddings and emit a JSON receipt.""" """Batch-embed ENE artifacts missing embeddings and emit a JSON receipt."""
from __future__ import annotations from __future__ import annotations

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# INFRA:DEAD rds -- AWS RDS is gone. Any file referencing rds_connect.py or this hostname is stale and must be ported.
""" """
Bulk dataset ingestion Aurora PostgreSQL. Bulk dataset ingestion Aurora PostgreSQL.

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# INFRA:DEAD rds -- AWS RDS is gone. Any file referencing rds_connect.py or this hostname is stale and must be ported.
"""ENE substrate migration + concept tagging (legacy shim). """ENE substrate migration + concept tagging (legacy shim).
NOTE (ontology migration): NOTE (ontology migration):

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# INFRA:DEAD rds -- AWS RDS is gone. Any file referencing rds_connect.py or this hostname is stale and must be ported.
# /// script # /// script
# requires-python = ">=3.10" # requires-python = ">=3.10"
# dependencies = [ # dependencies = [

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# INFRA:DEAD rds -- AWS RDS is gone. Any file referencing rds_connect.py or this hostname is stale and must be ported.
"""Ingest 57 theorem vectors into ene.flexures with full v2 spectral features.""" """Ingest 57 theorem vectors into ene.flexures with full v2 spectral features."""
import hashlib import hashlib

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# INFRA:DEAD rds -- AWS RDS is gone. Any file referencing rds_connect.py or this hostname is stale and must be ported.
"""Ingest Tier 2B trace flexure joints into ene.flexures. """Ingest Tier 2B trace flexure joints into ene.flexures.
For each theorem trace, extracts per-step transitions as flexure joints, For each theorem trace, extracts per-step transitions as flexure joints,

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# INFRA:DEAD rds -- AWS RDS is gone. Any file referencing rds_connect.py or this hostname is stale and must be ported.
"""Joint-based classifier using ene.flexures motifs. """Joint-based classifier using ene.flexures motifs.
Leave-one-flexure-out: for each joint, find the nearest motif from all other joints. Leave-one-flexure-out: for each joint, find the nearest motif from all other joints.

View file

@ -221,6 +221,20 @@ def gccl_compress_file(
"decision": "OVERSIZE", "decision": "OVERSIZE",
} }
if original_size == 0:
return b"", {
"mode": "raw",
"reference": str(reference_path) if reference_path else None,
"original_size": 0,
"compressed_size": 0,
"ratio": 1.0,
"decision": "EMPTY",
}
# If the reference file is larger than max_gccl_size, do not use it to avoid MemoryError
if reference_path and reference_path.stat().st_size > max_gccl_size:
reference_path = None
data = src_path.read_bytes() data = src_path.read_bytes()
reference = reference_path.read_bytes() if reference_path else None reference = reference_path.read_bytes() if reference_path else None
@ -327,40 +341,41 @@ def compress_folder(
"files": [], "files": [],
} }
temp_compressed = archive_path.parent / f"{archive_path.name}.tmp" zstd_proc = subprocess.Popen(
with tarfile.open(temp_compressed, "w") as tar: ["zstd", "-T0", "-19", "-q", "-f", "-o", str(archive_path)],
for f in files: stdin=subprocess.PIPE,
src = Path(f["local_path"]) )
rel = src.relative_to(local_root) try:
ref = refs.get(f["local_path"]) with tarfile.open(fileobj=zstd_proc.stdin, mode="w|") as tar:
for f in files:
src = Path(f["local_path"])
rel = src.relative_to(local_root)
ref = refs.get(f["local_path"])
compressed_bytes, meta = gccl_compress_file(src, ref, threshold_q16, max_gccl_size) compressed_bytes, meta = gccl_compress_file(src, ref, threshold_q16, max_gccl_size)
arc_name = f"{rel}.gccl" if meta["mode"] not in ("raw", "raw-oversize") else str(rel) arc_name = f"{rel}.gccl" if meta["mode"] not in ("raw", "raw-oversize") else str(rel)
if meta["mode"] in ("raw", "raw-oversize"): if meta["mode"] in ("raw", "raw-oversize"):
tar.add(src, arcname=arc_name) tar.add(src, arcname=arc_name)
else: else:
info = tarfile.TarInfo(name=arc_name) info = tarfile.TarInfo(name=arc_name)
info.size = len(compressed_bytes) info.size = len(compressed_bytes)
info.mtime = time.time() info.mtime = time.time()
tar.addfile(info, io.BytesIO(compressed_bytes)) tar.addfile(info, io.BytesIO(compressed_bytes))
manifest["files"].append({ manifest["files"].append({
"path": str(rel), "path": str(rel),
"archive_path": arc_name, "archive_path": arc_name,
"drive_id": f["drive_id"], "drive_id": f["drive_id"],
"sha256": f["sha256"], "sha256": f["sha256"],
**meta, **meta,
}) })
finally:
# Re-pack with zstd if zstd_proc.stdin:
with open(temp_compressed, "rb") as src_f, open(archive_path, "wb") as dst_f: zstd_proc.stdin.close()
subprocess.run( zstd_proc.wait()
["zstd", "-T0", "-19", "-q", "-f", "-o", str(archive_path)], if zstd_proc.returncode != 0:
stdin=src_f, raise RuntimeError(f"zstd exited with code {zstd_proc.returncode}")
check=True,
)
temp_compressed.unlink()
# Write manifest alongside # Write manifest alongside
manifest_path = archive_path.with_suffix(".manifest.json") manifest_path = archive_path.with_suffix(".manifest.json")

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# INFRA:DEAD rds -- AWS RDS is gone. Any file referencing rds_connect.py or this hostname is stale and must be ported.
"""Classify a proof receipt via PIST and insert into RDS. """Classify a proof receipt via PIST and insert into RDS.
Usage: Usage:

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# INFRA:DEAD rds -- AWS RDS is gone. Any file referencing rds_connect.py or this hostname is stale and must be ported.
"""Route-Repair Loop v1 — use the flexure joint library to suggest tactic repairs for failed proofs. """Route-Repair Loop v1 — use the flexure joint library to suggest tactic repairs for failed proofs.
Takes a failed Lean proof trace, classifies it, generates candidate patches Takes a failed Lean proof trace, classifies it, generates candidate patches

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# INFRA:DEAD rds -- AWS RDS is gone. Any file referencing rds_connect.py or this hostname is stale and must be ported.
"""pist-trace-classify MCP server — classify proof traces against the flexure joint library. """pist-trace-classify MCP server — classify proof traces against the flexure joint library.
Calling convention (MCP JSON-RPC on stdio): Calling convention (MCP JSON-RPC on stdio):

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# INFRA:DEAD rds -- AWS RDS is gone. Any file referencing rds_connect.py or this hostname is stale and must be ported.
"""Shared database connection helper — resolves env vars, DATABASE_URL.""" """Shared database connection helper — resolves env vars, DATABASE_URL."""
import os import os

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# INFRA:DEAD rds -- AWS RDS is gone. Any file referencing rds_connect.py or this hostname is stale and must be ported.
""" """
rrc_bosonic_db_buffer.py Asynchronous buffering database ingestion program. rrc_bosonic_db_buffer.py Asynchronous buffering database ingestion program.