Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
6094ec9
feat(exactTriangle): relate lopsided queries and matrix products
edemaine Oct 28, 2026
dec963a
feat(exactTriangle): prove modular counts and the selected-prime bound
edemaine Oct 28, 2026
0d8da3e
doc(threeSum): cite the lopsided triangle paper and clarify adaptatio…
edemaine Oct 28, 2026
8d80ecc
doc(bibliography): sort the new paper entry
edemaine Oct 28, 2026
fd69be7
fix(exactTriangle): repair the prime-window header and hashing docume…
edemaine Oct 28, 2026
ce646c7
feat(exactTriangle): split modular queries and recover witnesses
edemaine Oct 28, 2026
2cae26c
doc(threeSum): record finite splitting and recovery milestone
edemaine Oct 28, 2026
dc4206a
refactor(exactTriangle): reuse the natural residue bound and clarify …
edemaine Oct 28, 2026
2434f47
feat(matrix): prove the tensor recursion and pruned evaluation core
edemaine Oct 28, 2026
62dc601
doc(matrix): clarify the overlapping contributing leaf
edemaine Oct 28, 2026
4f3226c
doc(matrix): make tensor and pruning explanations standalone
edemaine Oct 28, 2026
19ee942
feat(wordram): count Chan–He collisions with native histograms
edemaine Oct 28, 2026
a712205
fix(wordram): preserve collision-counting parameters explicitly
edemaine Oct 28, 2026
844522a
feat(matrix): prove finite thin-product correctness and sparse bounds
edemaine Oct 28, 2026
5cbb93d
feat(wordram): compute Chan–He parameters from native input
edemaine Oct 28, 2026
b4936ce
doc(matrix): explain finite thin-product guarantees in the Lean API
edemaine Oct 28, 2026
0505439
fix(wordram): repair parameter proof hygiene and ceiling-log docs
edemaine Oct 28, 2026
ad3e097
feat(wordram): implement shared tensor encodings
edemaine Oct 28, 2026
3b9234d
test(wordram): connect encoder witnesses to charged runs
edemaine Oct 28, 2026
ff8f89d
Merge commit 'a7122053713cab3e45b505306b5d03bcd01cc737' into work/thr…
edemaine Oct 28, 2026
b2dc4e4
Merge commit '0505439ad73e746828ba9e5ade7ec8bb4577456e' into work/thr…
edemaine Oct 28, 2026
68bbe40
refactor(schonhage): reuse binomial bounds and sharpen signed tests
edemaine Oct 28, 2026
e3f5919
feat(wordram): checkpoint native ET preparation kernels
edemaine Oct 28, 2026
dc7c5b9
doc(wordram): record native ET source attribution
edemaine Oct 28, 2026
99b8a1b
doc(matrix): replace copied source prose with API descriptions
edemaine Oct 28, 2026
48a0fa3
chore(exactTriangle): merge current main for sibling integration
codex Oct 29, 2026
3fb98bd
chore(exactTriangle): join reviewed query splitting and counting layers
codex Oct 29, 2026
d1bc583
chore(exactTriangle): reconcile modular-hashing integration documenta…
SamuelSchlesinger Oct 29, 2026
c0b0511
chore(exactTriangle): carry hashing integration through query splitting
SamuelSchlesinger Oct 29, 2026
a76a7d3
chore(exactTriangle): carry documentation integration through native …
SamuelSchlesinger Oct 29, 2026
4f6de79
fix(imports): deduplicate aggregate after counting integration
SamuelSchlesinger Oct 29, 2026
02f1b49
fix(imports): deduplicate aggregate after query-splitting integration
SamuelSchlesinger Oct 29, 2026
60dfe9a
Merge commit '02f1b495322d8cfee81969186795670e3574defa' into coordina…
SamuelSchlesinger Oct 29, 2026
6f48d5c
Merge remote-tracking branch 'origin/main' into coordinator/integrate…
SamuelSchlesinger Oct 29, 2026
b17ece3
Merge commit '4f6de797203eb5dac02b2cadd9e8fa33e7427d57' into coordina…
SamuelSchlesinger Oct 29, 2026
e031b72
Merge remote-tracking branch 'origin/main' into coordinator/integrate…
SamuelSchlesinger Oct 29, 2026
b79ae8e
fix(imports): regenerate aggregate after Chan-He parameter integration
SamuelSchlesinger Oct 29, 2026
249f960
Merge commit '6f48d5c0efdfea1984c4accf368de9eaa9716b95' into coordina…
SamuelSchlesinger Oct 29, 2026
08a0415
Merge remote-tracking branch 'origin/main' into coordinator/integrate…
SamuelSchlesinger Oct 29, 2026
b0fa45b
Merge commit '08a0415413677534785113b7cf643b1ba9a6ee78' into coordina…
SamuelSchlesinger Oct 29, 2026
bd9bd2b
fix(imports): regenerate aggregate after shared-encoder integration
SamuelSchlesinger Oct 29, 2026
ab3e96c
chore(integration): reconcile splitting layer with landed hashing parent
SamuelSchlesinger Oct 29, 2026
9c8b9fc
perf(wordram): reduce native parameter proof heartbeat budget
SamuelSchlesinger Oct 29, 2026
0c9b346
Merge remote-tracking branch 'github/main' into coordinator-heartbeat…
SamuelSchlesinger Oct 29, 2026
da6a301
chore(integration): adopt splitting layer after its parent landed
SamuelSchlesinger Oct 29, 2026
452924e
chore(wordram): scope measured parameter proof budget to reduction task
SamuelSchlesinger Oct 29, 2026
6aaf569
Merge commit 'da6a301aca1e0c03e6953b3329474b2236f0fac8' into coordina…
SamuelSchlesinger Oct 29, 2026
5f6aad5
chore(integration): refresh tensor recursion supplier after hashing l…
SamuelSchlesinger Oct 29, 2026
d91296f
perf(schonhage): focus cell arithmetic and use the default heartbeat …
SamuelSchlesinger Oct 29, 2026
d8f4162
fix(doc): restore unrelated upstream coordination records
SamuelSchlesinger Oct 29, 2026
a63864f
chore(three-sum): merge corrected supplier preserving scope and sourc…
SamuelSchlesinger Oct 29, 2026
781297c
chore(three-sum): merge refreshed thin-product supplier preserving en…
SamuelSchlesinger Oct 29, 2026
a677276
Merge remote-tracking branch 'origin/main' into coordinator/refresh-1…
SamuelSchlesinger Oct 29, 2026
8a81617
Merge remote-tracking branch 'github/main' into coordinator-refresh-1…
SamuelSchlesinger Oct 29, 2026
9e9cb10
Merge commit 'a67727699b41ff9fa7d7227964d67c26699ab7f6' into coordina…
SamuelSchlesinger Oct 29, 2026
c3e1bcd
doc(order-glue): restore paper citation and finite scope
SamuelSchlesinger Oct 29, 2026
606fd61
Merge commit 'c3e1bcd3c8d9bb1dc4819d1b0a994bf52119731b' into coordina…
SamuelSchlesinger Oct 29, 2026
4b2d75c
Merge remote-tracking branch 'github/main' into coordinator-queue-146…
SamuelSchlesinger Oct 29, 2026
31d8eaa
Merge commit '606fd614454016f738d69d2cd768cb4d9a9ad795' into work/thr…
edemaine Oct 29, 2026
ea38fc5
Merge remote-tracking branch 'origin/main' into coordinator/refresh-1…
SamuelSchlesinger Oct 29, 2026
6a86e25
fix(imports): regenerate thin-product aggregate after main integration
SamuelSchlesinger Oct 29, 2026
6dbd0cc
Merge commit '6a86e258db83b7724f5bd93c43c0cbc4221a992f' into coordina…
SamuelSchlesinger Oct 29, 2026
c94a52f
Merge commit '4b2d75ce50dbca1101868ed3726170770d0a3e77' into coordina…
SamuelSchlesinger Oct 29, 2026
d072322
Merge remote-tracking branch 'origin/main' into coordinator/repair-15…
SamuelSchlesinger Oct 29, 2026
61e7fe7
doc(wordram): separate shared-encoder integration records
SamuelSchlesinger Oct 29, 2026
a0c5e5f
Merge commit '6dbd0cc45f8cfba188c1a8211b8b8f15d78c59f6' into work/thr…
edemaine Oct 29, 2026
d2e8386
Merge commit '38f32f97e76ad36666b99d1f0d39a64fc0ef3306' into coordina…
SamuelSchlesinger Oct 29, 2026
291ea1f
feat(wordram): prepare ExactTriangle instances from initialized input
edemaine Oct 29, 2026
af9a2ec
Merge reviewed encoder parent and validate complete native ET prepara…
edemaine Oct 29, 2026
d094632
doc(wordram): address native ET preparation review nits
edemaine Oct 29, 2026
fc7d99e
feat(ExactTriangle): connect prepared matrices to finite adjacency
edemaine Oct 29, 2026
be6754d
doc(ExactTriangle): link prepared adjacency consumer
edemaine Oct 29, 2026
8527c1f
Merge commit 'cf63e382d02ba396b4f8d460958d70b15735f23e' into coordina…
SamuelSchlesinger Oct 29, 2026
b0485ce
Merge commit '8527c1f4d25246fee901303e7c0f1310d30306c0' into coordina…
SamuelSchlesinger Oct 29, 2026
d354569
Merge commit 'b0485ceee4d9b53db41ad9af567b33a10fc89139' into coordina…
SamuelSchlesinger Oct 29, 2026
a43c989
doc(wordram): fix prepared-adjacency documentation link
SamuelSchlesinger Oct 29, 2026
1814b97
chore(ExactTriangle): integrate landed main into adjacency follow-up
SamuelSchlesinger Oct 29, 2026
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
1 change: 1 addition & 0 deletions Complexity.lean
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public import Complexity.Algorithms.WordRAM.ExactTriangle.InstancePair
public import Complexity.Algorithms.WordRAM.ExactTriangle.Instances
public import Complexity.Algorithms.WordRAM.ExactTriangle.MatrixSpec
public import Complexity.Algorithms.WordRAM.ExactTriangle.Parameters
public import Complexity.Algorithms.WordRAM.ExactTriangle.PreparationAdjacency
public import Complexity.Algorithms.WordRAM.ExactTriangle.PreparationBounds
public import Complexity.Algorithms.WordRAM.ExactTriangle.PreparationInput
public import Complexity.Algorithms.WordRAM.ExactTriangle.PreparationSpec
Expand Down
171 changes: 171 additions & 0 deletions Complexity/Algorithms/WordRAM/ExactTriangle/PreparationAdjacency.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/-
Copyright (c) 2026 Erik Demaine. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Erik Demaine
-/

module
-- upstream: candidate

public import Complexity.Algorithms.WordRAM.ExactTriangle.PreparationSpec

/-!
# Adjacency in prepared native ExactTriangle matrices

These consumer lemmas connect actual prepared memory to the existing finite lopsided graph.
The source prime window supplies the padding bound, and piece membership supplies each local
coordinate. Neither is an additional layout certificate for the program.

## Main results

* `PreparationSpec.instance_adjacency`: actual stored cells give the finite adjacency relations
and zero padding, with piece coordinates and middle-width admissibility derived.

## References

The adjacency relations are those of the pinned
[Theorem 17 matrix construction](https://github.com/anthropics/formal-math/blob/16a5ce41304fcdaea4e0be7c132e1c361dc26da5/3sum-apsp/ThreeSumApsp/Programs/Sec3/Theorem17/Instances/WriteMatrices.lean).
The composition with native memory readback is original.
-/

public section

namespace Cslib.Algorithms.WordRAM.ExactTriangle.PreparationSpec

open Cslib.WordRAM Cslib.Algorithms.ExactTriangle Cslib.Matrix

private theorem prepared_middle_fits {D g p n k : ℕ} (hg : 1 ≤ g)
(hp : p ∈ Nat.sqrtPrimeWindow D) :
min (pieceSize D g) (n - k * pieceSize D g) * p ≤ D := by
have hpS : p ≤ sOf D := Nat.le_sqrt'.mpr (Nat.mem_sqrtPrimeWindow_iff_sq.mp hp).2.2.le
have hlen : min (pieceSize D g) (n - k * pieceSize D g) ≤ sOf D :=
(min_le_left _ _).trans (pieceSize_le_sOf hg)
exact (Nat.mul_le_mul hlen hpS).trans (Nat.sqrt_le D)

private theorem piece_coordinate {n D g k : ℕ} (hD : 16 ≤ D) (hg : 1 ≤ g)
(c : Fin n) (hc : c ∈ piece n D g k) :
k * pieceSize D g + c.val % pieceSize D g = c.val ∧
c.val % pieceSize D g < min (pieceSize D g) (n - k * pieceSize D g) := by
have hB := pieceSize_pos hD hg
have hdiv := (mem_piece c).mp hc
have hsplit := Nat.div_add_mod c.val (pieceSize D g)
rw [hdiv, Nat.mul_comm] at hsplit
have hmod := Nat.mod_lt c.val hB
exact ⟨hsplit, lt_min hmod (by have := c.isLt; omega)⟩

/-- The actual prepared matrix cells express the existing finite graph's adjacency, and the
unused middle positions are zero. The prime-window and piece hypotheses discharge every
padding and local-coordinate premise of the matrix-entry API. -/
theorem instance_adjacency {n D g p : ℕ} (values : ℕ → ℤ)
(wAB wBC wAC : Fin n → Fin n → ℤ)
(hD : 16 ≤ D) (hDn : D ≤ n) (hg : 1 ≤ g) (hp : p ∈ Nat.sqrtPrimeWindow D)
(hAB : ∀ a b, values (pairIndex (a, b)) = wAB a b)
(hBC : ∀ b c, values (n * n + pairIndex (b, c)) = wBC b c)
(hAC : ∀ a c, values (2 * (n * n) + pairIndex (a, c)) = wAC a c)
{initial y : Data 64} (h : Instances.Output n D g p values initial y)
(idx : InstanceIndex p) (hidx : idx ∈ instanceIndices wAB D g p) :
let N := n * n
let C := fun rho => Nat.count (fun q => (values q % (p : ℤ)).toNat = rho) N
let H := numPieces n D g
let B := pieceSize D g
let ord := ChunkCatalogue.before C (queryCap n D) idx.1.val + idx.2.1
let base := y.regs Instances.output +
(ord * H + idx.2.2) * (6 + 2 * (n * D))
let G := lopInstance wAB wBC wAC D g p idx
(∀ (a b c : Fin n) (hc : c ∈ piece n D g idx.2.2) (label : Fin p),
let middle := c.val % B * p + label.val
(y.mem (base + 6 + (a.val * D + middle)) = 1 ↔
G.adjA a (⟨c, hc⟩, label)) ∧
(y.mem (base + 6 + n * D + (middle * n + b.val)) = 1 ↔
G.adjB (⟨c, hc⟩, label) b)) ∧
(∀ (a b : Fin n) (middle : Fin D),
min B (n - idx.2.2 * B) ≤ middle.val / p →
y.mem (base + 6 + (a.val * D + middle.val)) = 0 ∧
y.mem (base + 6 + n * D + (middle.val * n + b.val)) = 0) := by
let N := n * n
let R := fun q => (values q % (p : ℤ)).toNat
let C := fun rho => Nat.count (fun q => R q = rho) N
let H := numPieces n D g
let B := pieceSize D g
let K := ChunkCatalogue.before C (queryCap n D) p
let ord := ChunkCatalogue.before C (queryCap n D) idx.1.val + idx.2.1
let base := 5 + 6 * N + p + 2 * N * p + 3 * K +
(ord * H + idx.2.2) * (6 + 2 * (n * D))
let A : WriteMatrices.Args :=
⟨5 + 5 * N, base + 6, n, D, p, idx.2.2 * B, min B (n - idx.2.2 * B), idx.1.val⟩
let A' := { A with src := 5 + 4 * N, dst := base + 6 + n * D }
have hp0 : p ≠ 0 := (Nat.mem_sqrtPrimeWindow_iff_sq.mp hp).1.ne_zero
obtain ⟨-, hL, hR⟩ := instance_readback values wAB hp0 hAB hD hDn hg h idx hidx
change (Block.mk A.dst (n * D)).Realizes y.mem
(fun j => WriteMatrices.entry false A (fun q => R (2 * N + q)) j) at hL
change (Block.mk A'.dst (n * D)).Realizes y.mem
(fun j => WriteMatrices.entry true A' (fun q => R (N + q)) j) at hR
have hpad : A.length * A.p ≤ A.D := prepared_middle_fits hg hp
change min B (n - idx.2.2 * B) * p ≤ D at hpad
have hloadL (a c : Fin n) :
R (2 * N + (a.val * n + c.val)) = (wAC a c).natMod p := by
change (values (2 * (n * n) + pairIndex (a, c)) % (p : ℤ)).toNat = _
rw [hAC]
rfl
have hloadR (b c : Fin n) :
R (N + (b.val * n + c.val)) = (wBC b c).natMod p := by
change (values (n * n + pairIndex (b, c)) % (p : ℤ)).toNat = _
rw [hBC]
rfl
have hout : y.regs Instances.output = 5 + 6 * N + p + 2 * N * p + 3 * K := h.2.2.2.1
dsimp only
rw [hout]
constructor
· intro a b c hc label
obtain ⟨hvertex, hv⟩ := piece_coordinate hD hg c hc
let v : Fin A.length := ⟨c.val % B, hv⟩
have hm : v.val * p + label.val < D := by
have hstep := Nat.mul_le_mul_right p v.isLt
have hl := label.isLt
change (v.val + 1) * p ≤ min B (n - idx.2.2 * B) * p at hstep
rw [Nat.add_mul, Nat.one_mul] at hstep
omega
have hli : a.val * D + (v.val * p + label.val) < n * D := by
have hi := Nat.mul_le_mul_right D a.isLt
rw [Nat.succ_mul] at hi
omega
have hri : (v.val * p + label.val) * n + b.val < n * D := by
have hi := Nat.mul_le_mul_right n (Nat.succ_le_of_lt hm)
rw [Nat.succ_mul] at hi
have hb := b.isLt
rw [Nat.mul_comm n D]
omega
have hleft := hL ⟨a.val * D + (v.val * p + label.val), hli⟩
have hright := hR ⟨(v.val * p + label.val) * n + b.val, hri⟩
change y.mem (A.dst + (a.val * D + (v.val * p + label.val))) = _ at hleft
change y.mem (A'.dst + ((v.val * p + label.val) * n + b.val)) = _ at hright
constructor
· rw [hleft]
exact MatrixSpec.left_lopInstance A (fun q => R (2 * N + q)) wAB wBC wAC
g idx.2.1 idx.2.2 idx.1 rfl a c v label hc hvertex hpad hloadL
· rw [hright]
exact MatrixSpec.right_lopInstance A' (fun q => R (N + q)) wAB wBC wAC
g idx.2.1 idx.2.2 idx.1 b c v label hc hvertex hloadR
· intro a b middle hmiddle
have hli : a.val * D + middle.val < n * D := by
have hi := Nat.mul_le_mul_right D a.isLt
rw [Nat.succ_mul] at hi
have hm := middle.isLt
omega
have hri : middle.val * n + b.val < n * D := by
have hi := Nat.mul_le_mul_right n (Nat.succ_le_of_lt middle.isLt)
rw [Nat.succ_mul] at hi
have hb := b.isLt
rw [Nat.mul_comm n D]
omega
have hleft := hL ⟨a.val * D + middle.val, hli⟩
have hright := hR ⟨middle.val * n + b.val, hri⟩
change y.mem (A.dst + (a.val * D + middle.val)) = _ at hleft
change y.mem (A'.dst + (middle.val * n + b.val)) = _ at hright
constructor
· rw [hleft]
exact MatrixSpec.left_padding A (fun q => R (2 * N + q)) a middle hmiddle
· rw [hright]
exact MatrixSpec.right_padding A' (fun q => R (N + q)) b middle hmiddle

end Cslib.Algorithms.WordRAM.ExactTriangle.PreparationSpec
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ The native catalogue enumerates the existing residue classes, chunks and pieces.
identify its actual output count and per-instance records with that finite construction. Matrix
meaning and padding reuse `MatrixSpec` and its existing writer-entry formulas.

The [consumer extension](Complexity/Algorithms/WordRAM/ExactTriangle/PreparationAdjacency.html)
connects these cells to finite adjacency, deriving piece coordinates and the padding bound.

## Main results

* `PreparationSpec.count_eq_card`: the actual output counter is the finite instance cardinality.
Expand Down
121 changes: 121 additions & 0 deletions ComplexityTests/WordRAMExactTriangleAdjacency.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/-
Copyright (c) 2026 Erik Demaine. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Erik Demaine
-/

import Complexity.Algorithms.WordRAM.ExactTriangle.PreparationAdjacency
import Complexity.Algorithms.WordRAM.ExactTriangle.PreparationBounds
import Complexity.Foundations.Data.List.Lookup

/-! # Native prepared adjacency with signed asymmetric input -/

namespace ComplexityTests.WordRAMExactTriangleAdjacency

open Cslib.WordRAM Cslib.Matrix Cslib.Algorithms.ExactTriangle
open Cslib.Algorithms.WordRAM.ExactTriangle

private def weightAt (i : Fin 768) : ℤ :=
if i.val = 273 then 1 else if i.val = 513 then -1 else 0

private def values : List ℤ := List.ofFn weightAt

private def wAB (a b : Fin 16) : ℤ := values.getD (pairIndex (a, b)) 0
private def wBC (b c : Fin 16) : ℤ := values.getD (256 + pairIndex (b, c)) 0
private def wAC (a c : Fin 16) : ℤ := values.getD (512 + pairIndex (a, c)) 0

private theorem values_bound : ∀ z ∈ values, z.natAbs ≤ 1 := by
intro z hz
obtain ⟨i, rfl⟩ := List.mem_ofFn.mp hz
dsimp only [weightAt]
split_ifs <;> decide

private theorem values_get_zero {i : ℕ} (hi : i < 256) : values.getD i 0 = 0 := by
rw [values, List.getD_ofFn_of_lt weightAt (by omega)]
simp only [weightAt, show i ≠ 273 by omega, show i ≠ 513 by omega, ↓reduceIte]

private theorem wAB_zero (a b : Fin 16) : wAB a b = 0 := by
apply values_get_zero
change a.val * 16 + b.val < 256
have ha := a.isLt
have hb := b.isLt
omega

private theorem piece_size : pieceSize 16 1 = 4 := by
have hs : sOf 16 = 4 := by
change Nat.sqrt 16 = 4
have hl : 4 ≤ Nat.sqrt 16 := Nat.le_sqrt.mpr (by decide)
have hu : Nat.sqrt 16 < 5 := Nat.sqrt_lt.mpr (by decide)
omega
simp only [pieceSize, hs, ceilDiv_one]

private theorem query_capacity : queryCap 16 16 = 64 := by
have hl : 64 ≤ Nat.sqrt 4096 := Nat.le_sqrt.mpr (by decide)
have hu : Nat.sqrt 4096 < 65 := Nat.sqrt_lt.mpr (by decide)
have hs : Nat.sqrt 4096 = 64 := by omega
simpa only [queryCap, Nat.reducePow, Nat.reduceDiv] using hs

private theorem first_index : (0, 0, 0) ∈ instanceIndices wAB 16 1 3 := by
rw [mem_instanceIndices]
have hclass : (residueClass wAB 3 0).card = 256 := by
have hset : residueClass wAB 3 0 = Finset.univ := by
ext q
simp only [residueClass, Finset.mem_filter, Finset.mem_univ, true_and, wAB_zero]
decide
rw [hset]
simp only [Finset.card_univ, Fintype.card_prod, Fintype.card_fin, Nat.reduceMul]
constructor
· simp only [numChunks, hclass, query_capacity]
norm_num [Nat.ceilDiv_eq_add_pred_div]
· norm_num [numPieces, piece_size, Nat.ceilDiv_eq_add_pred_div]

set_option maxRecDepth 4096 in
-- The actual initialized 768-weight memory witness exceeds the default expression depth.
/-- Signed asymmetric input gives two actual adjacent cells and two padded zeros in the
same initialized run. The client supplies neither a run nor a padding/coordinate premise. -/
example : ∃ y t, t ≤ 2826240 ∧
Runs (PreparationInput.width 16 16 1 3 1) PreparationInput.flatProgram
(State.init (PreparationInput.input 16 16 1 3 values))
⟨Instances.program.size, y⟩ (t - 1) ∧
Executes (PreparationInput.width 16 16 1 3 1) PreparationInput.flatProgram
(State.init (PreparationInput.input 16 16 1 3 values))
(y.regs Instances.output) t ∧
y.mem (y.regs Instances.output + 11) = 1 ∧
y.mem (y.regs Instances.output + 343) = 1 ∧
y.mem (y.regs Instances.output + 18) = 0 ∧
y.mem (y.regs Instances.output + 455) = 0 := by
have hp : 3 ∈ Nat.sqrtPrimeWindow 16 :=
Nat.mem_sqrtPrimeWindow_iff_sq.mpr ⟨by decide, by decide, by decide⟩
obtain ⟨y, t, ht, hr, he, hout, -, -⟩ := PreparationBounds.runs_input
(n := 16) (D := 16) (g := 1) (p := 3) (A := 1) values
(by simp only [values, List.length_ofFn])
(by decide) (by decide) (by decide) hp values_bound le_rfl
obtain ⟨hactive, hzero⟩ := PreparationSpec.instance_adjacency
(fun q => values.getD q 0) wAB wBC wAC
(by decide) (by decide) (by decide) hp
(by intro a b; rfl) (by intro b c; rfl) (by intro a c; rfl)
hout (0, 0, 0) first_index
have hc : (1 : Fin 16) ∈ piece 16 16 1 0 := by
rw [mem_piece, piece_size]
decide
have hAC : wAC 0 1 = -1 := by
change values.getD 513 0 = -1
rw [values, List.getD_ofFn_of_lt weightAt (by decide)]
rfl
have hBC : wBC 1 1 = 1 := by
change values.getD 273 0 = 1
rw [values, List.getD_ofFn_of_lt weightAt (by decide)]
rfl
have ha := hactive 0 1 1 hc 2
norm_num [ChunkCatalogue.before, piece_size] at ha
have hz := hzero 0 1 12 (by rw [piece_size]; decide)
norm_num [ChunkCatalogue.before] at hz
refine ⟨y, t, ht, hr, he, ha.1.mpr ?_, ha.2.mpr ?_, hz.1, hz.2⟩
· change (2 : ℤ) ≡ wAC 0 1 + 0 [ZMOD (3 : ℤ)]
rw [hAC]
decide
· change (2 : ℤ) ≡ -wBC 1 1 [ZMOD (3 : ℤ)]
rw [hBC]
decide

end ComplexityTests.WordRAMExactTriangleAdjacency
Loading