File size: 4,693 Bytes
92416a2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | import Mathlib
import OAI.Computability.VertexCover.PCP.AlphabetTableTable
import OAI.Computability.VertexCover.PCP.FinalBooleanVerifier
namespace OAI
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
namespace UniqueGames.Foundations.Complexity.FinalCNFPattern
open PCP
open scoped BigOperators
abbrev Label := FinalBooleanVerifier.Label
abbrev labelEquiv : Label ≃ Fin 64 := AlphabetTable.Enumeration.labelEquiv
theorem labelEquiv_val (label : Label) :
(labelEquiv label).val =
∑ i : Fin 6, AlphabetTable.Enumeration.bitValue (label i) * 2 ^ i.val :=
AlphabetTable.Enumeration.labelEquiv_val label
def labelIndex (label : Label) : Fin 64 := labelEquiv label
def labelBits (index : Fin 64) : Label := labelEquiv.symm index
@[simp] theorem labelBits_labelIndex (label : Label) :
labelBits (labelIndex label) = label := labelEquiv.symm_apply_apply label
@[simp] theorem labelIndex_labelBits (index : Fin 64) :
labelIndex (labelBits index) = index := labelEquiv.apply_symm_apply index
def leftHalf (bits : VerifierToCNF.Pattern 12) : Label :=
fun j => bits (Fin.castAdd 6 j)
def rightHalf (bits : VerifierToCNF.Pattern 12) : Label :=
fun j => bits (Fin.natAdd 6 j)
def relationAddress (bits : VerifierToCNF.Pattern 12) : Fin 4096 :=
GraphTables.relationIndex (labelIndex (leftHalf bits), labelIndex (rightHalf bits))
theorem relationAddress_val (bits : VerifierToCNF.Pattern 12) :
(relationAddress bits).val =
64 * (labelIndex (leftHalf bits)).val + (labelIndex (rightHalf bits)).val := by
rw [relationAddress, GraphTables.relationIndex_val, Nat.add_comm]
def patternRelationIndex (p : VerifierToCNF.PatternIndex 12) : Fin 4096 :=
relationAddress (VerifierToCNF.patternAt 12 p)
@[simp] theorem patternRelationIndex_eq (p : VerifierToCNF.PatternIndex 12) :
patternRelationIndex p = relationAddress (VerifierToCNF.patternAt 12 p) := rfl
def tableGraph (table : GraphTables.Table) :
ConstraintGraph (Fin table.vertices) (Fin table.darts) Label :=
(GraphTables.semantics table).reindex (Equiv.refl _) (Equiv.refl _) labelEquiv.symm
@[simp] theorem tableGraph_tail (table : GraphTables.Table) (e : Fin table.darts) :
(tableGraph table).tail e = table.rows[e].tail := rfl
@[simp] theorem tableGraph_reverse (table : GraphTables.Table) (e : Fin table.darts) :
(tableGraph table).reverse e = table.rows[e].reverseIndex := rfl
@[simp] theorem tableGraph_accepts (table : GraphTables.Table) (e : Fin table.darts)
(a b : Label) :
(tableGraph table).accepts e a b =
GraphTables.relationAt table.rows[e].relation (labelIndex a) (labelIndex b) := rfl
abbrev tableVerifier (table : GraphTables.Table) : VerifierToCNF.FiniteVerifier 12 :=
FinalBooleanVerifier.verifier (tableGraph table) (Equiv.refl _) (Equiv.refl _)
theorem relation_lookup_eq_verifier_accepts (table : GraphTables.Table)
(e : Fin table.darts) (bits : VerifierToCNF.Pattern 12) :
table.rows[e].relation[relationAddress bits] =
(tableVerifier table).accepts e bits := rfl
theorem pattern_lookup_eq_verifier_accepts (table : GraphTables.Table)
(e : Fin table.darts) (p : VerifierToCNF.PatternIndex 12) :
table.rows[e].relation[patternRelationIndex p] =
(tableVerifier table).accepts e (VerifierToCNF.patternAt 12 p) := rfl
theorem verifier_accepts_eq_lookup (table : GraphTables.Table)
(e : Fin table.darts) (bits : VerifierToCNF.Pattern 12) :
(tableVerifier table).accepts e bits =
table.rows[e].relation[relationAddress bits] := rfl
theorem buffer_lookup_eq_verifier_accepts (table : GraphTables.Table)
(e : Fin table.darts) (buffer : Fin 4096 → Bool)
(read_correct : ∀ i, buffer i = table.rows[e].relation[i])
(bits : VerifierToCNF.Pattern 12) :
buffer (relationAddress bits) = (tableVerifier table).accepts e bits :=
(read_correct _).trans (relation_lookup_eq_verifier_accepts table e bits)
theorem pattern_buffer_lookup_eq_verifier_accepts (table : GraphTables.Table)
(e : Fin table.darts) (buffer : Fin 4096 → Bool)
(read_correct : ∀ i, buffer i = table.rows[e].relation[i])
(p : VerifierToCNF.PatternIndex 12) :
buffer (patternRelationIndex p) =
(tableVerifier table).accepts e (VerifierToCNF.patternAt 12 p) :=
buffer_lookup_eq_verifier_accepts table e buffer read_correct _
end UniqueGames.Foundations.Complexity.FinalCNFPattern
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end OAI
|