Skip to content
Merged
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
82 changes: 82 additions & 0 deletions .github/workflows/r420-forest-cut-budget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: R420 forest finite and formal coverage

on:
pull_request:
paths:
- 'research/r420-forest-cut-budget/**'
- 'research/e8-bit-r420/**'
- 'research/e8-bit-carrier-skeleton/**'
- 'certificates/checkpoints/k492626.json'
- '.github/workflows/r420-forest-cut-budget.yml'
push:
paths:
- 'research/r420-forest-cut-budget/**'
- 'research/e8-bit-r420/**'
- 'research/e8-bit-carrier-skeleton/**'
- 'certificates/checkpoints/k492626.json'
- '.github/workflows/r420-forest-cut-budget.yml'
workflow_dispatch:

permissions:
contents: read

defaults:
run:
shell: bash

jobs:
finite-and-formal:
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7, repository baseline pin
with:
# Historical source pins must be checked at the submitted head.
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7, repository baseline pin
with:
python-version: '3.13'
- name: Install C++ and Lean dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends g++ libboost-dev
curl --proto '=https' --tlsv1.2 -sSf --connect-timeout 15 --max-time 120 https://raw.githubusercontent.com/leanprover/elan/0e36a07b9bbcc5381fa6250df109f9a4f94d7bac/elan-init.sh -o "$RUNNER_TEMP/elan-init.sh"
sh "$RUNNER_TEMP/elan-init.sh" -y --default-toolchain none
"$HOME/.elan/bin/elan" toolchain install "$(cat research/r420-forest-cut-budget/lean-toolchain)"
echo "$HOME/.elan/bin" >> "$GITHUB_PATH"
- name: Record the checked revision, files and environment
run: |
mkdir -p "$RUNNER_TEMP/r420-forest-cut-budget"
git rev-parse HEAD | tee "$RUNNER_TEMP/r420-forest-cut-budget/HEAD.txt"
git ls-tree -r HEAD -- research/r420-forest-cut-budget > "$RUNNER_TEMP/r420-forest-cut-budget/FILES.txt"
{
python3 --version
g++ --version
elan run "$(cat research/r420-forest-cut-budget/lean-toolchain)" lean --version
} | tee "$RUNNER_TEMP/r420-forest-cut-budget/environment.txt"
- name: Rebuild finite certificates, run controls and check Lean axioms
timeout-minutes: 10
run: |
lean_bin="$(cd research/r420-forest-cut-budget && elan which lean)"
python3 -B research/r420-forest-cut-budget/reproduce.py --lean "$lean_bin" | tee "$RUNNER_TEMP/r420-forest-cut-budget/reproduce.log"
- name: Replay selected circuit and missing-restoration control
timeout-minutes: 20
run: |
python3 -B research/r420-forest-cut-budget/native.py --cxx g++ --boost /usr/include --out "$RUNNER_TEMP/r420-forest-cut-budget/selected"
- name: Require native rejection of the uncut 106-bit calibration
timeout-minutes: 20
run: |
python3 -B research/r420-forest-cut-budget/native.py --cxx g++ --boost /usr/include --out "$RUNNER_TEMP/r420-forest-cut-budget/uncut" --candidate research/r420-forest-cut-budget/data/optimum.json.gz --recipe research/r420-forest-cut-budget/data/optimum-recipe.json --expect-prefix-rejection
- name: Require committed artifacts unchanged
run: git diff --exit-code
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with:
name: r420-forest-finite-and-formal
path: |
${{ runner.temp }}/r420-forest-cut-budget/*.txt
${{ runner.temp }}/r420-forest-cut-budget/*.log
${{ runner.temp }}/r420-forest-cut-budget/*/*.log
${{ runner.temp }}/r420-forest-cut-budget/*/VERIFY.json
${{ runner.temp }}/r420-forest-cut-budget/*/NATIVE-RESULTS.json
60 changes: 60 additions & 0 deletions research/r420-forest-cut-budget/CLAIM.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"track": "bit supplier",
"assignment_seed": 6,
"base_commit": "66849e1475c930fd7732b1a0067ffee7e1e95f60",
"started_utc": "2026-10-13T04:52:39.487231+00:00",
"claimed_utc": "2026-10-13T04:58:55.587591+00:00",
"expected_finish_utc": "2026-10-13T06:25:00+00:00",
"scope": "R420 frame-zero compensation: reversible rooted-forest target basis and exact minimum-spanning-tree certificate for this circuit class",
"method": "All 120 target rows; 7140 undirected pair weights plus 120 root weights; seed 6 deterministically orders equal-cost edges; complete exact basis-column replay and cut/cycle certificate; positive-prefix accounting and meaningful mutants. Reserve final quarter for verification and handoff.",
"expected_deliverable": "One research construction with restricted optimality theorem, standalone replay, exact certificate and focused PR; no new kappa claim.",
"candidate_tasks": [
{
"task": "R420 local block/cleanup resynthesis",
"decision": "Not chosen: overlaps #670/#674/#688/#691/#710."
},
{
"task": "R420 early helper reuse or target-read hoist",
"decision": "Not chosen: monotone frame constraints; early target reads conflict with retained-copy scatter boundary."
},
{
"task": "R420 rooted-forest target compensation",
"decision": "Chosen: expands #713/#716 disjoint-pair class to arbitrary forests with polynomial exact optimum and a separate proof certificate."
}
],
"coordination": "GitHub repository pinnedIssues query returned no pinned issue; open issue list only #650. Claim recorded locally as brief permits.",
"overlap_checked": [
"#450",
"#476",
"#478",
"#686",
"#694",
"#713",
"#716",
"#731",
"#733",
"#742",
"#748",
"#753",
"#759"
],
"status": "complete",
"attribution": "Anthony (@anthonylei), substantial OpenAI Codex multi-agent assistance; predecessor lineage credited in the research note",
"completed_utc": "2026-10-13T05:21:00.572178+00:00",
"result": "Finite target-forest construction:4897 fewer XORs, unchanged104-bit admission; exact14921 unrestricted class optimum (106-bit rejected calibration); exact15025 cut-class optimum via724states; generic Lean proof; no new kappa.",
"result_url": "https://github.com/anthonylei/integer-mult-bounds/tree/research/seed06-bit-supplier/research/r420-forest-cut-budget",
"coverage": {
"complete_graph_vertices": 121,
"complete_graph_edges": 7260,
"non_tree_edges_certified": 7140,
"cut_positions": 116,
"cut_subsets_covered": "83076749736557242056487941267521536",
"cut_dp_states": 724,
"stopping_rule": "Complete fixed seed-6 MST and exact all-cut DP, followed by independent verification. No broader tree or circuit optimization claim.",
"assignment_randomness": "One secrets.randbelow(100) call; draw6, recorded before task selection.",
"seed_diversification": "SHA256(seed:u:v) total order selects one tied MST for the fixed-tree cut theorem."
},
"evidence_driven_pivot": "After the uncut scalar optimum failed native104-bit payload checks, solve the complete cut-subset budget problem rather than reuse its failing invoice.",
"scope_control": "Reparent32 from37 to34 gives15023 D XORs and exact104-bit scalar/frame pass outside the frozen cut family; explicitly documented and tested.",
"late_overlap": "Oscar Fennell PR759 arrived during final validation with same forest class and14921 floor. This independently corroborates its floor and adds exact all-cut budget optimum15025 (113 XORs below its15138 construction) and generic Lean proof. Renamed package to r420-forest-cut-budget to avoid path collision. No priority for the forest mechanism claimed."
}
213 changes: 213 additions & 0 deletions research/r420-forest-cut-budget/Forest.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
import Init

/-!
Generic Boolean semantics for target-forest compensation.

The circuit theorems below quantify over arbitrary register types, arbitrary
initial target/helper values, and arbitrary finite lists of legal XOR gates.
The inverse is the literal reversed gate list. No concrete R420 word, geometry,
cost bound, COPY/ERASE lifecycle, or physical frame transport is asserted here.
Prepared with OpenAI assistance; original project attribution is retained.
-/

namespace TargetForest

set_option Elab.async false

abbrev State (Reg : Type) := Reg → Bool

/-- A reversible target transvection; self-addition is excluded at the boundary. -/
structure Gate (Reg : Type) where
dst : Reg
src : Reg
distinct : dst ≠ src

variable {Reg : Type} [DecidableEq Reg]

def add (x y : State Reg) : State Reg := fun r => x r ^^ y r

def step (g : Gate Reg) (x : State Reg) : State Reg :=
fun r => if r = g.dst then x r ^^ x g.src else x r

/-- Execute from left to right, exactly as a sequential gate word. -/
def run : List (Gate Reg) → State Reg → State Reg
| [], x => x
| g :: gs, x => run gs (step g x)

private theorem xor_shuffle (a b c d : Bool) :
((a ^^ b) ^^ (c ^^ d)) = ((a ^^ c) ^^ (b ^^ d)) := by
cases a <;> cases b <;> cases c <;> cases d <;> rfl

private theorem xor_cancel (a b : Bool) : ((a ^^ b) ^^ b) = a := by
cases a <;> cases b <;> rfl

theorem step_add (g : Gate Reg) (x y : State Reg) :
step g (add x y) = add (step g x) (step g y) := by
funext r
by_cases hr : r = g.dst
· simp only [step, add, if_pos hr]
exact xor_shuffle _ _ _ _
· simp only [step, add, if_neg hr]

theorem step_involutive (g : Gate Reg) (x : State Reg) :
step g (step g x) = x := by
funext r
by_cases hr : r = g.dst
· have hs : g.src ≠ g.dst := Ne.symm g.distinct
simp only [step, if_pos hr, if_neg hs]
exact xor_cancel _ _
· simp only [step, if_neg hr]

theorem run_add (gs : List (Gate Reg)) (x y : State Reg) :
run gs (add x y) = add (run gs x) (run gs y) := by
induction gs generalizing x y with
| nil => rfl
| cons g gs ih =>
simp only [run, step_add, ih]

theorem run_append (as bs : List (Gate Reg)) (x : State Reg) :
run (as ++ bs) x = run bs (run as x) := by
induction as generalizing x with
| nil => rfl
| cons a as ih =>
exact ih (step a x)

/-- Reversing a legal XOR word constructs its inverse, for every initial state. -/
theorem run_reverse (gs : List (Gate Reg)) (x : State Reg) :
run gs.reverse (run gs x) = x := by
induction gs generalizing x with
| nil => rfl
| cons g gs ih =>
simp only [List.reverse_cons, run_append, run]
rw [ih, step_involutive]

/-- Core compensation identity: prepare by A, inject A d, then undo A. -/
theorem compensated_injection (gs : List (Gate Reg)) (x d : State Reg) :
run gs.reverse (add (run gs x) (run gs d)) = add x d := by
rw [← run_add, run_reverse]

/-- Every destination occurs once, and a parent is changed only after its children.
Roots need no gate. The condition also permits parents outside the target list. -/
def ForestOrdered : List (Gate Reg) → Prop
| [] => True
| g :: gs => ForestOrdered gs ∧
∀ h ∈ gs, g.dst ≠ h.dst ∧ g.dst ≠ h.src

/-- The parent edge encoded by a child's unique gate. -/
def parent : List (Gate Reg) → Reg → Option Reg
| [], _ => none
| g :: gs, r => if r = g.dst then some g.src else parent gs r

/-- The sparse forest matrix I + P, expressed without a matrix library. -/
def forestAction (gs : List (Gate Reg)) (x : State Reg) : State Reg :=
fun r => match parent gs r with
| none => x r
| some p => x r ^^ x p

theorem run_untouched (gs : List (Gate Reg)) (x : State Reg) (r : Reg)
(h : ∀ g ∈ gs, r ≠ g.dst) : run gs x r = x r := by
induction gs generalizing x with
| nil => rfl
| cons g gs ih =>
change run gs (step g x) r = x r
rw [ih (step g x) (fun q hq => h q (List.mem_cons_of_mem g hq))]
simp only [step, if_neg (h g List.mem_cons_self)]

private theorem parent_some (gs : List (Gate Reg)) (r p : Reg)
(h : parent gs r = some p) :
∃ g ∈ gs, r = g.dst ∧ p = g.src := by
induction gs with
| nil => simp [parent] at h
| cons g gs ih =>
by_cases hr : r = g.dst
· simp only [parent, if_pos hr, Option.some.injEq] at h
exact ⟨g, List.mem_cons_self, hr, h.symm⟩
· simp only [parent, if_neg hr] at h
obtain ⟨q, hq, hrq, hpq⟩ := ih h
exact ⟨q, List.mem_cons_of_mem g hq, hrq, hpq⟩

private theorem forestAction_step (gs : List (Gate Reg)) (g : Gate Reg)
(h : ∀ q ∈ gs, g.dst ≠ q.src) (x : State Reg) (r : Reg)
(hr : r ≠ g.dst) : forestAction gs (step g x) r = forestAction gs x r := by
unfold forestAction
cases hp : parent gs r with
| none => simp only [step, if_neg hr]
| some p =>
obtain ⟨q, hq, _, hpq⟩ := parent_some gs r p hp
have hpg : p ≠ g.dst := by
rw [hpq]
exact Ne.symm (h q hq)
simp only [step, if_neg hr, if_neg hpg]

/-- Children-before-parent execution really is A = I + P on all initial bits. -/
theorem run_forestAction (gs : List (Gate Reg)) (ordered : ForestOrdered gs)
(x : State Reg) : run gs x = forestAction gs x := by
induction gs generalizing x with
| nil => rfl
| cons g gs ih =>
rcases ordered with ⟨tail, fresh⟩
funext r
by_cases hr : r = g.dst
· subst r
change run gs (step g x) g.dst = _
rw [run_untouched gs (step g x) g.dst (fun q hq => (fresh q hq).1)]
simp [step, forestAction, parent]
· change run gs (step g x) r = _
rw [ih tail (step g x)]
rw [forestAction_step gs g (fun q hq => (fresh q hq).2) x r hr]
simp only [forestAction, parent, if_neg hr]

/-- Forest compensation uses exactly the local increment d(child) XOR d(parent). -/
theorem forest_compensated_injection (gs : List (Gate Reg))
(ordered : ForestOrdered gs) (x d : State Reg) :
run gs.reverse (add (run gs x) (forestAction gs d)) = add x d := by
rw [← run_forestAction gs ordered d]
exact compensated_injection gs x d

/-- A register bank split explicitly into arbitrary helpers and targets. -/
structure Banks (Helper Target : Type) where
helpers : State Helper
targets : State Target

variable {Helper : Type}

/-- The unchanged helpers determine the intended target increment `K h`.
The executed middle injection uses the compensated increment `A (K h)`.
`K` can be any function; linearity is needed only for the target circuit A. -/
def compensatedShear (gs : List (Gate Reg))
(K : State Helper → State Reg) (s : Banks Helper Reg) : Banks Helper Reg :=
{ helpers := s.helpers
targets := run gs.reverse (add (run gs s.targets) (run gs (K s.helpers))) }

/-- Exact dirty-helper/dirty-target semantics of the three-stage construction. -/
theorem compensatedShear_correct (gs : List (Gate Reg))
(K : State Helper → State Reg) (s : Banks Helper Reg) :
compensatedShear gs K s =
{ helpers := s.helpers, targets := add s.targets (K s.helpers) } := by
simp only [compensatedShear, compensated_injection]

/-- The same bank operation, using the explicit one-parent compensation formula. -/
def forestShear (gs : List (Gate Reg))
(K : State Helper → State Reg) (s : Banks Helper Reg) : Banks Helper Reg :=
{ helpers := s.helpers
targets := run gs.reverse
(add (run gs s.targets) (forestAction gs (K s.helpers))) }

/-- Local forest compensation preserves arbitrary helpers and adds K h to
arbitrary initial targets; no clean-register assumption occurs in the theorem. -/
theorem forestShear_correct (gs : List (Gate Reg))
(ordered : ForestOrdered gs) (K : State Helper → State Reg)
(s : Banks Helper Reg) :
forestShear gs K s =
{ helpers := s.helpers, targets := add s.targets (K s.helpers) } := by
simp only [forestShear, forest_compensated_injection gs ordered]

end TargetForest

#print axioms TargetForest.run_add
#print axioms TargetForest.run_reverse
#print axioms TargetForest.compensated_injection
#print axioms TargetForest.run_forestAction
#print axioms TargetForest.forest_compensated_injection
#print axioms TargetForest.compensatedShear_correct
#print axioms TargetForest.forestShear_correct
Loading