Selecting and Encoding the Constructed Graphs
Lax920634.GraphEncoding · concepts/Lax920634/GraphEncoding.lean · lax-920634
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
Given a requested order in unary, start at the smallest tower member and advance while its regular-graph order is below . At most advances suffice. After path replacement this selects a graph of order between and a fixed constant times .
The output lists the paired-port destination of every vertex, in numerical order. A destination is recorded as its base vertex and its port, both in unary. The two possible path neighbors follow directly from the row number. This table determines the entire simple graph, including the removal of loops and duplicate edges.
Concept map
Lean source view on GitHub
| 1 | import Lax920634.ZigZagConstruction |
| 2 | import Mathlib.Data.List.Basic |
| 3 | |
| 4 | /-! |
| 5 | --- |
| 6 | title: Selecting and Encoding the Constructed Graphs |
| 7 | type: definition |
| 8 | --- |
| 9 | Given a requested order in unary, start at the smallest tower member and |
| 10 | advance while its regular-graph order is below . At most advances |
| 11 | suffice. After path replacement this selects a graph of order between |
| 12 | and a fixed constant times . |
| 13 | |
| 14 | The output lists the paired-port destination of every vertex, in numerical |
| 15 | order. A destination is recorded as its base vertex and its port, both in |
| 16 | unary. The two possible path neighbors follow directly from the row number. |
| 17 | This table determines the entire simple graph, including the removal of loops |
| 18 | and duplicate edges. |
| 19 | |
| 20 | # Formalization notes |
| 21 | |
| 22 | The binary serialization uses balanced brackets: `false` opens a list and |
| 23 | `true` closes one. A Boolean is an empty list for `false` and a list containing |
| 24 | one empty list for `true`. Records are pairs of unary Boolean words. The |
| 25 | whole table is a list of these records. The format is unambiguous; its unary |
| 26 | coordinates increase output size only polynomially. |
| 27 | -/ |
| 28 | |
| 29 | namespace Lax920634.GraphEncoding |
| 30 | |
| 31 | open SeedSearch ZigZagConstruction |
| 32 | |
| 33 | /-- The bounded level-selection loop, carrying the level and current regular order. -/ |
| 34 | def levelAfter (b n : ℕ) : ℕ → ℕ × ℕ → ℕ × ℕ |
| 35 | | 0, p => p |
| 36 | | j + 1, p => |
| 37 | let q := levelAfter b n j p |
| 38 | if q.2 < 2 * n then (q.1 + 1, q.2 * b) else q |
| 39 | |
| 40 | /-- The level selected for a requested order, after at most `2*n` advances. -/ |
| 41 | def selectedLevel (n : ℕ) : ℕ := |
| 42 | (levelAfter (seedDegree ^ 4) n (2 * n) (0, seedDegree ^ 4)).1 |
| 43 | |
| 44 | /-- A Boolean serialized as an empty or singleton-empty bracketed list. -/ |
| 45 | def encodeBit (b : Bool) : List Bool := |
| 46 | if b then [false, false, true, true] else [false, true] |
| 47 | |
| 48 | /-- Serialize a Boolean word as a bracketed list of encoded Booleans. -/ |
| 49 | def encodeWord (w : List Bool) : List Bool := false :: (w.flatMap encodeBit ++ [true]) |
| 50 | |
| 51 | /-- Serialize a pair of natural coordinates, each represented in unary. -/ |
| 52 | def encodeRecord (p : ℕ × ℕ) : List Bool := |
| 53 | false :: (encodeWord (List.replicate p.1 true) ++ |
| 54 | encodeWord (List.replicate p.2 true) ++ [true]) |
| 55 | |
| 56 | /-- The paired-port destination of each vertex, in canonical row order. -/ |
| 57 | def records (k : ℕ) : List (ℕ × ℕ) := |
| 58 | (List.range (order k)).map fun j => |
| 59 | rotation k (j / degree, j % degree) |
| 60 | |
| 61 | /-- The binary table encoding of the entire subcubic graph at a specified level. -/ |
| 62 | def encoding (k : ℕ) : List Bool := false :: ((records k).flatMap encodeRecord ++ [true]) |
| 63 | |
| 64 | /-- The specified deterministic graph construction on a unary size request. -/ |
| 65 | def construct (input : List Bool) : List Bool := encoding (selectedLevel input.length) |
| 66 | |
| 67 | end Lax920634.GraphEncoding |
| 68 |
Formalization notes
The binary serialization uses balanced brackets: opens a list and closes one. A Boolean is an empty list for and a list containing one empty list for . Records are pairs of unary Boolean words. The whole table is a list of these records. The format is unambiguous; its unary coordinates increase output size only polynomially.
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments