Download lean/OAI/Computability/MaxCut/PCP/PoweringRowHeaderSemantics.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 4.21 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Computability/MaxCut/PCP/PoweringRowHeaderSemantics.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Computability/MaxCut/PCP/PoweringRowHeaderSemantics.lean
-
curl -L -o PoweringRowHeaderSemantics.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Computability/MaxCut/PCP/PoweringRowHeaderSemantics.lean
4.21 kB
| import Mathlib | |
| import OAI.Computability.MaxCut.PCP.PoweringOpinionTables | |
| namespace OAI | |
| /-! Exact tail and reverse-index fields of the actual powering-table rows. | |
| The reverse address is affine in the live starting vertex; the coefficient | |
| and offset depend only on the fixed degree, word, and orientation. -/ | |
| namespace MaxCutGames.Foundations.PCP.PoweringRowHeaderSemantics | |
| open PoweringWalks PoweringEnumeration | |
| open MaxCutGames.Foundations.Complexity | |
| variable {vertices d : Nat} | |
| def blockSize (d n : Nat) : Nat := 2 * d ^ (n + 1) | |
| def reverseOffset (d n : Nat) (ports : Fin (n + 1) → Fin d) (direction : Bool) : Nat := | |
| 2 * (wordEquiv d (n + 1) ports).val + (if direction then 0 else 1) | |
| def reverseValue (d n : Nat) (vertex : Fin vertices) | |
| (ports : Fin (n + 1) → Fin d) (direction : Bool) : Nat := | |
| blockSize d n * vertex.val + reverseOffset d n ports direction | |
| def tailVertex (input : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) | |
| (ports : Fin (n + 1) → Fin d) (direction : Bool) : Fin vertices := | |
| if direction then wordEnd (PortTables.portGraph input) (n + 1) vertex ports else vertex | |
| def headerWords (input : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) | |
| (ports : Fin (n + 1) → Fin d) (direction : Bool) : List Nat := | |
| [(tailVertex input n vertex ports direction).val, reverseValue d n vertex ports direction] | |
| /-- The stored tail is the recorded start or endpoint according to direction. -/ | |
| theorem table_tail (input : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) | |
| (ports : Fin (n + 1) → Fin d) (direction : Bool) : | |
| (PoweringTables.table input n).rows[encodeDart vertices d n (direction, vertex, ports)].tail = | |
| tailVertex input n vertex ports direction := by | |
| change (GenericGraphTables.semantics (PoweringTables.table input n)).tail | |
| (encodeDart vertices d n (direction, vertex, ports)) = _ | |
| rw [PoweringTables.semantics_table] | |
| change (PoweringTables.mathematicalGraph input n).tail | |
| ((dartEquiv vertices d n).symm (dartEquiv vertices d n (direction, vertex, ports))) = _ | |
| rw [Equiv.symm_apply_apply] | |
| rfl | |
| /-- The reverse address retains the word and changes only its direction bit. -/ | |
| theorem table_reverseValue (input : PortTables.Table vertices d) (n : Nat) | |
| (vertex : Fin vertices) (ports : Fin (n + 1) → Fin d) (direction : Bool) : | |
| (PoweringTables.table input n).rows[encodeDart vertices d n | |
| (direction, vertex, ports)].reverseIndex.val = reverseValue d n vertex ports direction := by | |
| change (GenericGraphTables.reverseAt (PoweringTables.table input n).rows | |
| (encodeDart vertices d n (direction, vertex, ports))).val = _ | |
| rw [PoweringTables.table_reverse, encodeDart, dartEquiv_val] | |
| cases direction <;> | |
| simp [reverseValue, blockSize, reverseOffset, orientationEquiv, Nat.add_assoc] <;> decide | |
| theorem headerWords_eq (input : PortTables.Table vertices d) (n : Nat) (vertex : Fin vertices) | |
| (ports : Fin (n + 1) → Fin d) (direction : Bool) : | |
| headerWords input n vertex ports direction = | |
| [(PoweringTables.table input n).rows[encodeDart vertices d n | |
| (direction, vertex, ports)].tail.val, | |
| (PoweringTables.table input n).rows[encodeDart vertices d n | |
| (direction, vertex, ports)].reverseIndex.val] := by | |
| rw [table_tail, table_reverseValue] | |
| rfl | |
| /-- Prepending these two fields to the existing relation yields the exact | |
| serialized row, preserving the rest of the output tape. -/ | |
| theorem header_relation_bits (input : PortTables.Table vertices d) (n : Nat) | |
| (vertex : Fin vertices) (ports : Fin (n + 1) → Fin d) (direction : Bool) | |
| (suffix : List Bool) : | |
| encodeWords (headerWords input n vertex ports direction) ++ | |
| (encodeWords (GenericGraphTables.relationWords | |
| (PoweringTables.table input n).rows[encodeDart vertices d n | |
| (direction, vertex, ports)].relation) ++ suffix) = | |
| encodeWords (GenericGraphTables.rowWords | |
| (PoweringTables.table input n).rows[encodeDart vertices d n | |
| (direction, vertex, ports)]) ++ suffix := by | |
| rw [headerWords_eq, ← List.append_assoc, ← encodeWords_append] | |
| rfl | |
| end MaxCutGames.Foundations.PCP.PoweringRowHeaderSemantics | |
| end OAI | |