Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 179 additions & 0 deletions research/p104-gate-ceiling-lift/LiftPositivity.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
/-
Toolchain status: checked under Lean v4.33.0-rc1 / Mathlib 55b7917 (with the import
Mathlib.Analysis.Complex.ExponentialBounds, its path in that Mathlib). The import below is the one
for the repository pin (Lean v4.21 / Mathlib 308445d): not yet built under that pin.

Input-lift positivity for the complex interval gate, on kappa in (0, 69/10000].

lift kappa = 7^(1-k) + 3^(1-k) + 5^(1-k) - 9^(1-k) - 4^(1-k) - 2 * 1^(1-k)

This is the moment of the input-lift histogram (pos {7,3,5}, neg {9,4,1,1}) in
shared-wire-split-composition/interval_gate.py. Same style as AnalyticGain.lean
(research/kappa-lean-verification-20261022): a derivative sign on an interval,
strict monotonicity, and the endpoint value. The derivative sign is the SIGNED
curvature bound: only the negative-coefficient ranks (9, 4) are lowered via
exp x >= 1 + x; the positive ranks (7, 3, 5) are raised via r^t <= r (t <= 1).
Logarithms of 3, 5, 7 are bracketed from Mathlib's log 2 bounds and the
alternating log(1 - x) series remainder. Scope: this lemma only; it does not
formalize the gate's other checks, the native word or the compiler.
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Data.Complex.ExponentialBounds
import Mathlib.Tactic.NormNum
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring

namespace KappaInputLift

open Real

/-- Lift moment in the exponent t = 1 - kappa. -/
noncomputable def f (t : ℝ) : ℝ :=
(7 : ℝ) ^ t + (3 : ℝ) ^ t + (5 : ℝ) ^ t - (9 : ℝ) ^ t - (4 : ℝ) ^ t - 2 * (1 : ℝ) ^ t

noncomputable def f' (t : ℝ) : ℝ :=
(7 : ℝ) ^ t * Real.log 7 + (3 : ℝ) ^ t * Real.log 3 + (5 : ℝ) ^ t * Real.log 5
- (9 : ℝ) ^ t * Real.log 9 - (4 : ℝ) ^ t * Real.log 4

/-- The lift as a function of kappa, exactly as the gate evaluates it. -/
noncomputable def lift (k : ℝ) : ℝ := f (1 - k)

lemma hasDerivAt_f (t : ℝ) : HasDerivAt f (f' t) t := by
have d : ∀ a : ℝ, 0 < a → HasDerivAt (fun x : ℝ => a ^ x) (a ^ t * Real.log a) t :=
fun a ha => (Real.hasStrictDerivAt_const_rpow ha t).hasDerivAt
have h := (((((d 7 (by norm_num)).add (d 3 (by norm_num))).add (d 5 (by norm_num))).sub
(d 9 (by norm_num))).sub (d 4 (by norm_num))).sub_const (2 : ℝ)
have e : f = fun x : ℝ => (7 : ℝ) ^ x + (3 : ℝ) ^ x + (5 : ℝ) ^ x - (9 : ℝ) ^ x - (4 : ℝ) ^ x - 2 := by
funext x; simp [f]
rw [e]; exact h

/-- r^t <= r for r >= 1, t <= 1. -/
lemma rpow_le_self' {r t : ℝ} (hr : 1 ≤ r) (ht : t ≤ 1) : r ^ t ≤ r := by
simpa only [Real.rpow_one] using Real.rpow_le_rpow_of_exponent_le hr ht

/-- r^t >= r (1 + (t-1) log r) for r > 0 (exp x >= 1 + x). -/
lemma rpow_ge_tangent {r : ℝ} (hr : 0 < r) (t : ℝ) :
r * (Real.log r * (t - 1) + 1) ≤ r ^ t := by
have e : r ^ t = r * Real.exp (Real.log r * (t - 1)) := by
rw [Real.rpow_def_of_pos hr]
have h : Real.log r * t = Real.log r + Real.log r * (t - 1) := by ring
rw [h, Real.exp_add, Real.exp_log hr]
rw [e]
exact mul_le_mul_of_nonneg_left (by linarith [Real.add_one_le_exp (Real.log r * (t - 1))]) hr.le

/-- log(1 - x) brackets from the series remainder. -/
lemma log_one_sub_bounds (x : ℝ) (hx0 : 0 ≤ x) (hx : x < 1) (n : ℕ) :
-(∑ i ∈ Finset.range n, x ^ (i + 1) / (i + 1)) - x ^ (n + 1) / (1 - x) ≤ Real.log (1 - x) ∧
Real.log (1 - x) ≤ -(∑ i ∈ Finset.range n, x ^ (i + 1) / (i + 1)) + x ^ (n + 1) / (1 - x) := by
have h := Real.abs_log_sub_add_sum_range_le (show |x| < 1 by rwa [abs_of_nonneg hx0]) n
rw [abs_of_nonneg hx0] at h
constructor <;> linarith [(abs_le.mp h).1, (abs_le.mp h).2]

lemma log2_lo : (0.6931471803 : ℝ) < Real.log 2 := Real.log_two_gt_d9
lemma log2_hi : Real.log 2 < (0.6931471808 : ℝ) := Real.log_two_lt_d9

lemma log4_eq : Real.log 4 = 2 * Real.log 2 := by
have h := Real.log_pow (2 : ℝ) 2; norm_num at h; exact h
lemma log8_eq : Real.log 8 = 3 * Real.log 2 := by
have h := Real.log_pow (2 : ℝ) 3; norm_num at h; exact h
lemma log9_eq : Real.log 9 = 2 * Real.log 3 := by
have h := Real.log_pow (3 : ℝ) 2; norm_num at h; exact h

/-- log 3 = log 4 + log(1 - 1/4). -/
lemma log3_bounds : (1.0986 : ℝ) < Real.log 3 ∧ Real.log 3 < 1.09862 := by
have e : Real.log 3 = Real.log 4 + Real.log (1 - 1/4) := by
rw [← Real.log_mul (by norm_num) (by norm_num)]; norm_num
obtain ⟨l, u⟩ := log_one_sub_bounds (1/4) (by norm_num) (by norm_num) 8
simp only [Finset.sum_range_succ, Finset.sum_range_zero] at l u
norm_num at l u
rw [e, log4_eq]; constructor <;> nlinarith [log2_lo, log2_hi]

/-- log 5 = log 4 - log(1 - 1/5). -/
lemma log5_bounds : (1.60943 : ℝ) < Real.log 5 ∧ Real.log 5 < 1.60944 := by
have e : Real.log 5 = Real.log 4 - Real.log (1 - 1/5) := by
rw [← Real.log_div (by norm_num) (by norm_num)]; norm_num
obtain ⟨l, u⟩ := log_one_sub_bounds (1/5) (by norm_num) (by norm_num) 8
simp only [Finset.sum_range_succ, Finset.sum_range_zero] at l u
norm_num at l u
rw [e, log4_eq]; constructor <;> nlinarith [log2_lo, log2_hi]

/-- log 7 = log 8 + log(1 - 1/8). -/
lemma log7_bounds : (1.945909 : ℝ) < Real.log 7 ∧ Real.log 7 < 1.94592 := by
have e : Real.log 7 = Real.log 8 + Real.log (1 - 1/8) := by
rw [← Real.log_mul (by norm_num) (by norm_num)]; norm_num
obtain ⟨l, u⟩ := log_one_sub_bounds (1/8) (by norm_num) (by norm_num) 6
simp only [Finset.sum_range_succ, Finset.sum_range_zero] at l u
norm_num at l u
rw [e, log8_eq]; constructor <;> nlinarith [log2_lo, log2_hi]

/-- The gate inequality itself, in exact reals: with d1 = sum_pos r log r - sum_neg r log r
and the SIGNED curvature N = sum_neg r log^2 r, d1 + (69/10000) N < 0. -/
theorem signed_gate_inequality :
(7 * Real.log 7 + 3 * Real.log 3 + 5 * Real.log 5 - 9 * Real.log 9 - 4 * Real.log 4)
+ (69 / 10000) * (9 * Real.log 9 ^ 2 + 4 * Real.log 4 ^ 2) < 0 := by
obtain ⟨b0, b1⟩ := log3_bounds
obtain ⟨c0, c1⟩ := log5_bounds
obtain ⟨d0, d1⟩ := log7_bounds
have a0 := log2_lo; have a1 := log2_hi
rw [log9_eq, log4_eq]
nlinarith [mul_lt_mul'' b1 b1 (by linarith) (by linarith),
mul_lt_mul'' a1 a1 (by linarith) (by linarith)]

lemma f'_neg {t : ℝ} (ht0 : 9931 / 10000 ≤ t) (ht1 : t ≤ 1) : f' t < 0 := by
have hl : ∀ r : ℝ, 1 ≤ r → 0 ≤ Real.log r := fun r hr => Real.log_nonneg hr
have u7 := mul_le_mul_of_nonneg_right (rpow_le_self' (by norm_num : (1:ℝ) ≤ 7) ht1) (hl 7 (by norm_num))
have u3 := mul_le_mul_of_nonneg_right (rpow_le_self' (by norm_num : (1:ℝ) ≤ 3) ht1) (hl 3 (by norm_num))
have u5 := mul_le_mul_of_nonneg_right (rpow_le_self' (by norm_num : (1:ℝ) ≤ 5) ht1) (hl 5 (by norm_num))
have l9 := mul_le_mul_of_nonneg_right (rpow_ge_tangent (by norm_num : (0:ℝ) < 9) t) (hl 9 (by norm_num))
have l4 := mul_le_mul_of_nonneg_right (rpow_ge_tangent (by norm_num : (0:ℝ) < 4) t) (hl 4 (by norm_num))
-- (t - 1) >= -69/10000 and log r >= 0, so log r (t - 1) >= -(69/10000) log r.
have g9 : Real.log 9 * (t - 1) ≥ -(69/10000) * Real.log 9 := by
nlinarith [hl 9 (by norm_num)]
have g4 : Real.log 4 * (t - 1) ≥ -(69/10000) * Real.log 4 := by
nlinarith [hl 4 (by norm_num)]
have L9 : 9 * (-(69/10000) * Real.log 9 + 1) * Real.log 9 ≤ (9:ℝ) ^ t * Real.log 9 := by
refine le_trans ?_ l9
exact mul_le_mul_of_nonneg_right (by linarith) (hl 9 (by norm_num))
have L4 : 4 * (-(69/10000) * Real.log 4 + 1) * Real.log 4 ≤ (4:ℝ) ^ t * Real.log 4 := by
refine le_trans ?_ l4
exact mul_le_mul_of_nonneg_right (by linarith) (hl 4 (by norm_num))
have G := signed_gate_inequality
unfold f'
nlinarith [u7, u3, u5, L9, L4, G]

lemma f_continuous : Continuous f :=
continuous_iff_continuousAt.mpr fun t => (hasDerivAt_f t).continuousAt

lemma f_strictAntiOn : StrictAntiOn f (Set.Icc (9931 / 10000 : ℝ) 1) := by
apply strictAntiOn_of_deriv_neg (convex_Icc _ _) f_continuous.continuousOn
intro t ht
rw [interior_Icc] at ht
rw [(hasDerivAt_f t).deriv]
exact f'_neg ht.1.le ht.2.le

lemma f_one : f 1 = 0 := by norm_num [f]

lemma lift_zero : lift 0 = 0 := by simp [lift, f_one]

/-- Input-lift positivity: 0 < lift kappa for 0 < kappa <= 69/10000. -/
theorem lift_pos {k : ℝ} (hk0 : 0 < k) (hk1 : k ≤ 69 / 10000) : 0 < lift k := by
have h := f_strictAntiOn (show 1 - k ∈ Set.Icc (9931 / 10000 : ℝ) 1 by
constructor <;> linarith)
(show (1 : ℝ) ∈ Set.Icc (9931 / 10000 : ℝ) 1 by constructor <;> norm_num)
(by linarith)
rw [f_one] at h
exact h

/-- Monotone form used by the gate: lift is strictly increasing on [0, 69/10000]. -/
theorem lift_strictMonoOn : StrictMonoOn lift (Set.Icc (0 : ℝ) (69 / 10000)) := by
intro a ha b hb hab
exact f_strictAntiOn ⟨by linarith [hb.2], by linarith [hb.1]⟩
⟨by linarith [ha.2], by linarith [ha.1]⟩ (by linarith)

end KappaInputLift

#print axioms KappaInputLift.signed_gate_inequality
#print axioms KappaInputLift.lift_pos
#print axioms KappaInputLift.lift_strictMonoOn
97 changes: 97 additions & 0 deletions research/p104-gate-ceiling-lift/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# P104 tooling: lift the input-lift and BIT-pin gate ceilings

DreamingOfClouds with Claude Opus 5.5 (Anthropic), via Claude Code.

Tooling/framework change only. No word, no kappa claim. The pinned
`research/shared-wire-split-composition/interval_gate.py` is **not edited**
(its sha256 is pinned in `certificates/frontier7000-source.json`); this package
ships a patched copy, `interval_gate_signed.py`, and the diff.

## Problem: two ceilings just above the frontier

The official complex-word gate cannot certify any word above these kappa values
(percent over the #7617 frontier, kappa .00365760025222):

| Ceiling | Value | Over #7617 | Cause |
|---|---|---|---|
| Input-lift check | .0037765 | +3.24% | absolute curvature 94.216 |
| Default BIT pin | .00376669 | +2.98% | pin from #6726 |
| **After this patch** | **kappa < .00385248 - 7g** | **+5.33%** | admitted BIT saving |
| Lift proof alone (signed) | .006957747 | +90% | signed curvature 51.137 |

1. The lift check asserts `d1 + lift_cap*curv < 0` for
L(k) = sum_{7,3,5} r^(1-k) - sum_{9,4,1,1} r^(1-k) with d1 = -0.355801 and
curv = sum over *all* ranks of r ln^2 r = 94.2157, giving -d1/94.2157 = .0037765.
Above that the gate sets lift_cap = tested and the assertion fails, although the
lift is positive up to kappa about .05.
2. The default pin .00376669 forces tested < pin. The admitted ordinary BIT
saving is .00385248 (12039/3125000 in `certificates/frontier7000/CLAIM.json`;
#7001 admission, `README.md` lines 36-37, `PROOF-REVIEW.md:389` of
pr7000-application: "The completed BIT saving .00385248 supplies the weaker
.00376669 premise"). Its premise status is unchanged: conditional on the same
five assumptions.

## Fix (three hunks, see `interval_gate.diff`)

- `curvature` sums only the negative-coefficient ranks: N = 9 ln^2 9 + 4 ln^2 4 + 2*1*0 = 51.1374.
`abs_curvature` is still computed and reported.
- `lift_cap = cap if cap <= LIFT_RANGE (.0069) else tested`.
- `BIT_PIN = '.00385248'` is the default (function and CLI), with the citation in a comment;
`assert cap <= F(BIT_PIN)` rejects a pin above the admitted saving
(the original accepted any `--bit-pin`).

Certifiable ceiling: tested < pin, i.e. kappa < .00385248 - 7g (tested = claim + 7g).
The lift proof alone reaches -d1/N = .006957747.

## Proof that the signed bound is valid

Write L(k) = sum s_i r_i^(1-k), s = +1 on {7,3,5}, -1 on {9,4,1,1}; k >= 0, r >= 1.

1. 0 < r^(-k) = exp(-k ln r) <= 1.
2. L(0) = 0 and L'(0) = -d1 = 0.355801 > 0.
3. L''(k) = sum_pos r ln^2 r r^-k - sum_neg r ln^2 r r^-k >= -N, since the positive part is >= 0 and the negative part is <= N by (1).
4. L'(k) = L'(0) + int_0^k L'' >= -d1 - kN. If d1 + cap*N < 0, L' > 0 on [0, cap], so L is strictly increasing and L(k) > 0 on (0, cap].
5. Taylor with integral remainder gives L(k) >= -k d1 - k^2 N/2, which is the gate's per-price assertion; it is weaker with N in place of curv, hence still valid.
6. Interval direction: the gate tests the upper ends, d1_hi + cap*N_hi < 0, and d1 <= d1_hi, N <= N_hi.

The absolute bound |L''| <= sum_all r ln^2 r was valid but dropped the sign of the positive part. All other
gate checks (alpha, gamma, delta, eta, log-power, compiler gap, 54+4 outer, main-moment monotonicity) are untouched.

## Lean status

`LiftPositivity.lean` (no `sorry`, no `native_decide`, no `set_option`; axioms propext, Classical.choice, Quot.sound)
proves `lift_pos` (0 < kappa <= 69/10000 implies lift kappa > 0), `lift_strictMonoOn` and
`signed_gate_inequality` (d1 + (69/10000) N < 0 in exact reals). Logs of 3, 5, 7 come from Mathlib's log 2 bounds
plus the log(1-x) series remainder.

**Checked under Lean v4.33 / Mathlib 55b7917; not yet built under the repo pin (v4.21 / Mathlib 308445d).**
The file carries the import for the repo pin, `Mathlib.Data.Complex.ExponentialBounds`
(`Mathlib.Analysis.Complex.ExponentialBounds` in the newer Mathlib used for the check). Every lemma used exists at
308445d; tactic behaviour (`nlinarith`) under v4.21 is unverified.

## Tests

`python3 -I -B research/p104-gate-ceiling-lift/tests/gate_test.py` (registered in `VERIFY.json`; 32 cases, exit 0 only if all
have the expected outcome):

- #7000 recorded invoice: the pinned original reproduces its recorded gate fields; the signed gate passes and at the old pin differs only in input-lift fields.
- #7617 (claim .00365760025222) and #7615 (.00365455370060): original and signed both pass; for each, 3 corrupted invoices, a claim above the crossing and a gap numerator != 1 are rejected.
- Pin ceiling (synthetic invoice crossing .0038777): tested = pin - 1e-16 passes; tested = pin, pin + 1e-16, and a `--bit-pin` above .00385248 are rejected; the original at the old pin behaves as before.
- Lift ceiling: with the pin guard relaxed, lift caps .00695774704 and .0069577 pass; .006957747045 and .0069578 fail at the lift assertion; LIFT_RANGE branch cases.
- Mutants of the signed bound (curvature sign flipped, pos/neg histograms swapped, d1 sign flipped) are rejected; LIFT_RANGE = .1 with the real pin still passes.

`data/frontier_invoices.json` holds the rank histograms of the #7617 and #7615 complete invoices (frontier word x #7113 caller)
as computed by our pricer; they are gate-logic inputs. #7617 itself did not run this gate, so the claim/tested parameters
used here (g = 1e-16) are ours. Synthetic invoices test gate logic only and are not words.

## Caveats

- The lift histogram {7,3,5}/{9,4,1,1} is hard-coded and inherited from #7000; a word that changes its input lifts is not covered.
- The five conditional assumptions behind the BIT premise are inherited unchanged; only the margin to the pin changes.
- The Lean check is not yet reproduced under the repo's Lean/Mathlib pin (above).
- Ceiling statements are for the gate's logic; this package certifies no word.

## Open next questions

- Does `LiftPositivity.lean` build under Lean v4.21 / Mathlib 308445d? First step: build it with the repo-pin import already applied.
- Can the input-lift histogram be computed from each word's actual invoice instead of being hard-coded? First step: derive it from the invoice and rerun the signed bound.
30 changes: 30 additions & 0 deletions research/p104-gate-ceiling-lift/SOURCES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"schema_version": 1,
"base_commit": "e54523517d0f03e58352e647c403a5af3e525a57",
"files": [
{
"path": "docs/research/agent-task-catalog.json",
"usage": "provenance",
"git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec",
"sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81"
},
{
"path": "certificates/selected-result.json",
"usage": "provenance",
"git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8",
"sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1"
},
{
"path": "research/shared-wire-split-composition/interval_gate.py",
"usage": "input",
"git_blob": "e24dc46079b4c25152f5afc096dda2ce8ee58ff5",
"sha256": "60a743d13f668ef86db4b8215b4d5d04430a671ba6f1fe06d9c1c4c3dfe86da5"
},
{
"path": "research/shared-wire-split-composition/FULL-RESULT.json",
"usage": "input",
"git_blob": "ff3256f0d3ffbfc56b062f9ec0fdbbc7b30e76d5",
"sha256": "d9ba709fa5dcefffe3f3abdcf34600ce188224703cfd743e6db8b58ba4816cb7"
}
]
}
Loading
Loading