Buckets:
| import Mathlib | |
| import OAI.Computability.VertexCover.PCP.GraphTables | |
| import OAI.Computability.VertexCover.PCP.PoweringWalks | |
| namespace OAI | |
| namespace UniqueGames.Foundations.PCP.PortTables | |
| open PoweringWalks | |
| abbrev Label := GraphTables.Label | |
| def rowIndex (vertices ports : Nat) : | |
| Fin vertices × Fin ports ≃ Fin (vertices * ports) := finProdFinEquiv | |
| @[simp] theorem rowIndex_val (n d : Nat) (e : Fin n × Fin d) : | |
| (rowIndex n d e).val = e.2.val + d * e.1.val := rfl | |
| structure Table (vertices ports : Nat) where | |
| reverseIndex : Vector (Fin (vertices * ports)) (vertices * ports) | |
| relations : Vector GraphTables.RelationTable (vertices * ports) | |
| involutive : Function.Involutive | |
| (fun i : Fin (vertices * ports) => reverseIndex[i]) | |
| transpose : ∀ (i : Fin (vertices * ports)) (a b : Label), | |
| GraphTables.relationAt relations[reverseIndex[i]] b a = | |
| GraphTables.relationAt relations[i] a b | |
| variable {n d : Nat} | |
| def rotation (table : Table n d) (e : Fin n × Fin d) : Fin n × Fin d := | |
| (rowIndex n d).symm table.reverseIndex[rowIndex n d e] | |
| def accepts (table : Table n d) (e : Fin n × Fin d) (a b : Label) : Bool := | |
| GraphTables.relationAt table.relations[rowIndex n d e] a b | |
| @[simp] theorem rowIndex_rotation (table : Table n d) (e : Fin n × Fin d) : | |
| rowIndex n d (rotation table e) = table.reverseIndex[rowIndex n d e] := by | |
| exact (rowIndex n d).apply_symm_apply _ | |
| theorem rotation_involutive (table : Table n d) : Function.Involutive (rotation table) := by | |
| intro e | |
| simp only [rotation, Equiv.apply_symm_apply] | |
| exact (congrArg (rowIndex n d).symm (table.involutive (rowIndex n d e))).trans | |
| ((rowIndex n d).symm_apply_apply e) | |
| theorem accepts_rotation (table : Table n d) (e : Fin n × Fin d) (a b : Label) : | |
| accepts table (rotation table e) b a = accepts table e a b := by | |
| simpa only [accepts, rowIndex_rotation] using table.transpose (rowIndex n d e) a b | |
| def portGraph (table : Table n d) : PortGraph (Fin n) (Fin d) where | |
| rot := | |
| { toFun := rotation table | |
| invFun := rotation table | |
| left_inv := rotation_involutive table | |
| right_inv := rotation_involutive table } | |
| rot_involutive := rotation_involutive table | |
| @[simp] theorem portGraph_rot (table : Table n d) (e : Fin n × Fin d) : | |
| (portGraph table).rot e = rotation table e := rfl | |
| def baseGraph (table : Table n d) : ConstraintGraph (Fin n) (Fin n × Fin d) Label where | |
| reverse := (portGraph table).rot | |
| reverse_involutive := rotation_involutive table | |
| tail := Prod.fst | |
| accepts := accepts table | |
| reverse_accepts := accepts_rotation table | |
| @[simp] theorem baseGraph_reverse (table : Table n d) (e : Fin n × Fin d) : | |
| (baseGraph table).reverse e = rotation table e := rfl | |
| @[simp] theorem baseGraph_tail (table : Table n d) (e : Fin n × Fin d) : | |
| (baseGraph table).tail e = e.1 := rfl | |
| @[simp] theorem baseGraph_head (table : Table n d) (e : Fin n × Fin d) : | |
| (baseGraph table).head e = (rotation table e).1 := rfl | |
| @[simp] theorem baseGraph_accepts (table : Table n d) (e : Fin n × Fin d) (a b : Label) : | |
| (baseGraph table).accepts e a b = accepts table e a b := rfl | |
| def ofPortGraph (G : PortGraph (Fin n) (Fin d)) | |
| (predicate : (Fin n × Fin d) → Label → Label → Bool) | |
| (htranspose : ∀ e a b, predicate (G.rot e) b a = predicate e a b) : Table n d where | |
| reverseIndex := Vector.ofFn (fun i => rowIndex n d (G.rot ((rowIndex n d).symm i))) | |
| relations := Vector.ofFn (fun i => GraphTables.relationOf (predicate ((rowIndex n d).symm i))) | |
| involutive := by | |
| intro i | |
| simp only [Fin.getElem_fin, Vector.getElem_ofFn, Fin.eta, | |
| Equiv.symm_apply_apply] | |
| exact (congrArg (rowIndex n d) (G.rot_involutive ((rowIndex n d).symm i))).trans | |
| ((rowIndex n d).apply_symm_apply i) | |
| transpose := by | |
| intro i a b | |
| simp only [Fin.getElem_fin, Vector.getElem_ofFn, Fin.eta, | |
| Equiv.symm_apply_apply, GraphTables.relationAt_relationOf] | |
| exact htranspose ((rowIndex n d).symm i) a b | |
| @[simp] theorem rotation_ofPortGraph (G : PortGraph (Fin n) (Fin d)) | |
| (predicate : (Fin n × Fin d) → Label → Label → Bool) | |
| (htranspose : ∀ e a b, predicate (G.rot e) b a = predicate e a b) | |
| (e : Fin n × Fin d) : rotation (ofPortGraph G predicate htranspose) e = G.rot e := by | |
| simp only [rotation, ofPortGraph, Fin.getElem_fin, Vector.getElem_ofFn, Fin.eta, | |
| Equiv.symm_apply_apply] | |
| @[simp] theorem accepts_ofPortGraph (G : PortGraph (Fin n) (Fin d)) | |
| (predicate : (Fin n × Fin d) → Label → Label → Bool) | |
| (htranspose : ∀ e a b, predicate (G.rot e) b a = predicate e a b) | |
| (e : Fin n × Fin d) (a b : Label) : | |
| accepts (ofPortGraph G predicate htranspose) e a b = predicate e a b := by | |
| simp only [accepts, ofPortGraph, Fin.getElem_fin, Vector.getElem_ofFn, Fin.eta, | |
| Equiv.symm_apply_apply, GraphTables.relationAt_relationOf] | |
| def flatRows (table : Table n d) : GraphTables.Rows n (n * d) := | |
| Vector.ofFn (fun i => | |
| ⟨((rowIndex n d).symm i).1, table.reverseIndex[i], table.relations[i]⟩) | |
| @[simp] theorem reverseAt_flatRows (table : Table n d) (i : Fin (n * d)) : | |
| GraphTables.reverseAt (flatRows table) i = table.reverseIndex[i] := by | |
| simp [GraphTables.reverseAt, flatRows] | |
| @[simp] theorem acceptsAt_flatRows (table : Table n d) (i : Fin (n * d)) (a b : Label) : | |
| GraphTables.acceptsAt (flatRows table) i a b = GraphTables.relationAt table.relations[i] a b := by | |
| simp [GraphTables.acceptsAt, flatRows] | |
| theorem flatRows_valid (table : Table n d) : GraphTables.Valid (flatRows table) := by | |
| constructor | |
| · intro i | |
| simpa only [reverseAt_flatRows] using table.involutive i | |
| · intro i a b | |
| simpa only [reverseAt_flatRows, acceptsAt_flatRows] using table.transpose i a b | |
| def graphTable (table : Table n d) : GraphTables.Table := | |
| ⟨n, n * d, flatRows table, flatRows_valid table⟩ | |
| def tableWords (table : Table n d) : List Nat := GraphTables.tableWords (graphTable table) | |
| def tableBits (table : Table n d) : List Bool := GraphTables.tableBits (graphTable table) | |
| abbrev Input (ports : Nat) := (vertices : Nat) × Table vertices ports | |
| def inputBits {ports : Nat} (input : Input ports) : List Bool := tableBits input.2 | |
| theorem tableWords_eq (table : Table n d) : | |
| tableWords table = [n, n * d] ++ (flatRows table).toList.flatMap GraphTables.rowWords := rfl | |
| theorem tableWords_length (table : Table n d) : | |
| (tableWords table).length = 2 + 4098 * (n * d) := | |
| GraphTables.tableWords_length (graphTable table) | |
| theorem vertices_le_tableBits_length (table : Table n d) : n ≤ (tableBits table).length := | |
| GraphTables.vertices_le_tableBits_length (graphTable table) | |
| end UniqueGames.Foundations.PCP.PortTables | |
| end OAI | |
Xet Storage Details
- Size:
- 6.77 kB
- Xet hash:
- 6a5224a8c13f80543954bf7527b2a7a557f59e076fc7a157e5a49ab677fe69d4
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.