A Word-Sized Encoding of the Constructed Graphs
Lax920634.WordEncoding · concepts/Lax920634/WordEncoding.lean · lax-920634
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A graph is encoded by its order followed by one matching endpoint per vertex, in numerical vertex order. Consecutive ports in each cloud supply the path edges. Thus the encoding has exactly one more word than the graph has vertices. It determines the entire simple graph, including loop removal and merging of coincident edges.
Concept map
Lean source view on GitHub
| 1 | import Lax920634.GraphEncoding |
| 2 | |
| 3 | /-! |
| 4 | --- |
| 5 | title: A Word-Sized Encoding of the Constructed Graphs |
| 6 | type: definition |
| 7 | --- |
| 8 | A graph is encoded by its order followed by one matching endpoint per vertex, |
| 9 | in numerical vertex order. Consecutive ports in each cloud supply the path |
| 10 | edges. Thus the encoding has exactly one more word than the graph has |
| 11 | vertices. It determines the entire simple graph, including loop removal and |
| 12 | merging of coincident edges. |
| 13 | |
| 14 | # Formalization notes |
| 15 | |
| 16 | The row number determines the base vertex and port by division and remainder |
| 17 | by the fixed degree. This encoding uses machine words for vertex labels, |
| 18 | rather than unary coordinates. The requested order is supplied as one word. |
| 19 | -/ |
| 20 | |
| 21 | namespace Lax920634.WordEncoding |
| 22 | |
| 23 | open ZigZagConstruction GraphEncoding |
| 24 | |
| 25 | /-- The complete matching table, with its graph order as a header. -/ |
| 26 | def table (k : ℕ) : List ℕ := order k :: |
| 27 | (List.range (order k)).map (matchingNeighbor k) |
| 28 | |
| 29 | /-- Construct the word encoding for the same size selector as the binary constructor. -/ |
| 30 | def construct (n : ℕ) : List ℕ := table (selectedLevel n) |
| 31 | |
| 32 | /-- Decode the matching table at its declared graph order. Path edges are determined by row numbers. -/ |
| 33 | def decode (n : ℕ) (tape : List ℕ) : SimpleGraph (Fin n) := |
| 34 | SimpleGraph.fromRel (fun u v => |
| 35 | (u.val / degree = v.val / degree ∧ u.val+1 = v.val) ∨ |
| 36 | v.val = (tape.tail[u.val]?).getD 0) |
| 37 | |
| 38 | end Lax920634.WordEncoding |
| 39 |
Formalization notes
The row number determines the base vertex and port by division and remainder by the fixed degree. This encoding uses machine words for vertex labels, rather than unary coordinates. The requested order is supplied as one word.
Builds on
From Mathlib
none
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments