File size: 9,379 Bytes
2f887db | 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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | import OAI.Computability.PerfectCompleteness.Construction.SourceQuestionOrderLemmas
import OAI.Computability.PerfectCompleteness.Machines.KeyMetadataMachine
import OAI.Computability.PerfectCompleteness.Machines.SignedTupleCleanupMachineLemmas
import OAI.Computability.PerfectCompleteness.Machines.SourceOccurrenceProducerLemmas
import OAI.Computability.PerfectCompleteness.Reduction.ExactPreliminaryTarget
namespace OAI
namespace PerfectCompleteness.NormalizedTarget
open UniqueGamesTheorem.Foundations.Complexity
open scoped Classical
noncomputable section
variable {branch : Nat → Nat} {n t : Nat}
def inputBits (input : NormalizedSourceInput.Input) : List Bool :=
NormalizedSourceInput.bits input
@[simp] theorem inputBits_eq (input : NormalizedSourceInput.Input) :
inputBits input = SourceOccurrenceEncoding.bits input.formula := rfl
theorem decode_inputBits (input : NormalizedSourceInput.Input) :
SourceOccurrenceEncoding.decode (inputBits input) = some input.formula :=
NormalizedSourceInput.decode_bits input
theorem inputBits_injective : Function.Injective inputBits :=
NormalizedSourceInput.bits_injective
abbrev SourceTuple (input : NormalizedSourceInput.Input) :=
Fin (TreeCanonical.locationCount branch n t) →
Fin (NormalizedSourceInput.clauseCount input)
def tupleQuestion (input : NormalizedSourceInput.Input)
(indices : SourceTuple (branch := branch) (n := n) (t := t) input) :
PreliminarySampler.Questions branch n t (NormalizedSourceInput.clauseCount input) :=
SourceQuestionOrder.tupleToQuestion indices
@[simp] theorem tupleQuestion_digits (input : NormalizedSourceInput.Input)
(indices : SourceTuple (branch := branch) (n := n) (t := t) input) :
SourceQuestionOrder.questionToTuple (tupleQuestion input indices) = indices :=
SourceQuestionOrder.questionToTuple_tupleToQuestion indices
def sourceShapes (input : NormalizedSourceInput.Input)
(indices : SourceTuple (branch := branch) (n := n) (t := t) input) :
Fin (TreeCanonical.locationCount branch n t) → CanonicalKeyShape.Shape :=
fun position => SourceClauseReaderMachine.clauseShape
(SourceTupleData.selectedClause input.formula indices position)
def parsedVariableIDs (input : NormalizedSourceInput.Input)
(indices : SourceTuple (branch := branch) (n := n) (t := t) input)
(position : Fin (TreeCanonical.locationCount branch n t)) (slot : Fin 3) : Nat :=
(SourceTupleData.selectedClause input.formula indices position)[slot].variableIndex.val
@[simp] theorem parsedVariableIDs_eq (input : NormalizedSourceInput.Input)
(indices : SourceTuple (branch := branch) (n := n) (t := t) input)
(position : Fin (TreeCanonical.locationCount branch n t)) (slot : Fin 3) :
parsedVariableIDs input indices position slot =
((NormalizedSourceInput.clauses input (indices position)).variable slot).val := rfl
theorem sourceSigns_eq (input : NormalizedSourceInput.Input)
(indices : SourceTuple (branch := branch) (n := n) (t := t) input) :
SourceTupleScheduleMachine.sourceSigns input.formula indices =
MetadataFreeSampler.sourceSigns (NormalizedSourceInput.clauses input)
(tupleQuestion input indices) := by
funext leaf coordinate
rfl
theorem signTuple_eq (input : NormalizedSourceInput.Input)
(indices : SourceTuple (branch := branch) (n := n) (t := t) input) :
SourceTupleScheduleMachine.signTuple (sourceShapes input indices) =
MetadataFreeSampler.sourceSigns (NormalizedSourceInput.clauses input)
(tupleQuestion input indices) :=
sourceSigns_eq input indices
theorem numberedSlots_eq (input : NormalizedSourceInput.Input)
(indices : SourceTuple (branch := branch) (n := n) (t := t) input)
(position : Fin (TreeCanonical.locationCount branch n t)) :
TreeCanonical.numberedSlots
(MetadataFreeSampler.sourceSlots (NormalizedSourceInput.clauses input)
(tupleQuestion input indices)) position =
KeyMetadataMachine.actualSlot (sourceShapes input indices position)
(indices position).val (parsedVariableIDs input indices position) := by
change SourceKeys.slot (NormalizedSourceInput.clauses input)
(.clause (SourceQuestionOrder.questionToTuple
(SourceQuestionOrder.tupleToQuestion
(branch := branch) (n := n) (t := t) indices) position)) = _
simp only [SourceQuestionOrder.questionToTuple_tupleToQuestion]; rfl
theorem sourceTable_eq (input : NormalizedSourceInput.Input)
(indices : SourceTuple (branch := branch) (n := n) (t := t) input)
(prepared : Fin (TreeCanonical.locationCount branch n t) → Bool) :
SourceTupleData.stacks input.formula indices prepared .table = inputBits input := rfl
theorem digit_counter (input : NormalizedSourceInput.Input)
(indices : SourceTuple (branch := branch) (n := n) (t := t) input)
(prepared : Fin (TreeCanonical.locationCount branch n t) → Bool)
(position : Fin (TreeCanonical.locationCount branch n t)) :
SourceTupleData.stacks input.formula indices prepared (.digit position) =
List.replicate (indices position).val true := rfl
theorem variable_counter (input : NormalizedSourceInput.Input)
(indices : SourceTuple (branch := branch) (n := n) (t := t) input)
(position : Fin (TreeCanonical.locationCount branch n t)) (slot : Fin 3) :
SourceTupleData.stacks input.formula indices (fun _ => true) (.variableName position slot) =
List.replicate (parsedVariableIDs input indices position slot) true := rfl
variable (rows repeats : Nat → Nat)
(hn : 0 < n) (hbranch : ∀ k < n, 0 < branch k)
(hrows : ∀ k, 0 < rows (k + 1)) (δ : ℚ)
local notation "q" => FinitePreliminaryCompletion.alphabet branch n t δ
def construct (input : NormalizedSourceInput.Input) : Instance q :=
ExactPreliminaryTarget.construct (t := t) (NormalizedSourceInput.clauses input)
rows repeats hn hbranch hrows δ
def outputBits (input : NormalizedSourceInput.Input) : List Bool :=
Encoding.gameBits (construct (t := t) rows repeats hn hbranch hrows δ input)
@[simp] theorem construct_eq (input : NormalizedSourceInput.Input) :
construct (t := t) rows repeats hn hbranch hrows δ input =
ExactPreliminaryTarget.construct (t := t) (NormalizedSourceInput.clauses input)
rows repeats hn hbranch hrows δ := rfl
theorem edge_count (input : NormalizedSourceInput.Input) :
(construct (t := t) rows repeats hn hbranch hrows δ input).edges.length =
SignedMultiplicity.denominator branch n t rows repeats hn hbranch hrows q *
(NormalizedSourceInput.clauseCount input) ^ TreeCanonical.locationCount branch n t :=
ExactPreliminaryTarget.edge_count (t := t) (NormalizedSourceInput.clauses input)
rows repeats hn hbranch hrows δ
local instance leftVertex_fintype (input : NormalizedSourceInput.Input) :
Fintype (CanonicalGame.LeftVertex (FinitePreliminaryCompletion.blockFamily
(NormalizedSourceInput.clauses input) branch n t rows repeats)) := Fintype.ofFinite _
local instance rightVertex_fintype (input : NormalizedSourceInput.Input) :
Fintype (CanonicalGame.RightVertex (FinitePreliminaryCompletion.blockFamily
(NormalizedSourceInput.clauses input) branch n t rows repeats)) := Fintype.ofFinite _
local instance leftLabel_fintype (input : NormalizedSourceInput.Input)
(x : CanonicalGame.LeftVertex (FinitePreliminaryCompletion.blockFamily
(NormalizedSourceInput.clauses input) branch n t rows repeats)) :
Fintype (CanonicalGame.LeftLabel (FinitePreliminaryCompletion.blockFamily
(NormalizedSourceInput.clauses input) branch n t rows repeats) x) := Fintype.ofFinite _
local instance rightLabel_fintype (input : NormalizedSourceInput.Input)
(y : CanonicalGame.RightVertex (FinitePreliminaryCompletion.blockFamily
(NormalizedSourceInput.clauses input) branch n t rows repeats)) :
Fintype (CanonicalGame.RightLabel (FinitePreliminaryCompletion.blockFamily
(NormalizedSourceInput.clauses input) branch n t rows repeats) y) := Fintype.ofFinite _
theorem value_le (input : NormalizedSourceInput.Input) (hδ : 0 < δ) :
(construct (t := t) rows repeats hn hbranch hrows δ input).value ≤
(PreliminarySampler.game (NormalizedSourceInput.clauses input)
branch n t rows repeats hn hbranch hrows).value + (δ : ℝ) / 3 :=
ExactPreliminaryTarget.value_le (t := t) (NormalizedSourceInput.clauses input)
rows repeats hn hbranch hrows δ hδ
theorem perfectlyComplete (input : NormalizedSourceInput.Input)
(satisfiable : input.formula.Satisfiable) :
PerfectlyComplete (construct (t := t) rows repeats hn hbranch hrows δ input) := by
obtain ⟨assignment, satisfies⟩ := satisfiable
apply ExactPreliminaryTarget.perfectlyComplete (t := t)
(NormalizedSourceInput.clauses input) rows repeats hn hbranch hrows δ assignment
intro occurrence
exact satisfies _ (List.getElem_mem occurrence.isLt)
theorem outputBits_length_le (input : NormalizedSourceInput.Input) :
let N := (construct (t := t) rows repeats hn hbranch hrows δ input).edges.length
(outputBits (t := t) rows repeats hn hbranch hrows δ input).length ≤
2 * N + q + N + 4 + N * (2 * N + 2 * q * q + 2 * q + 2) :=
ExactPreliminaryTarget.encoding_length_le (t := t) (NormalizedSourceInput.clauses input)
rows repeats hn hbranch hrows δ
end
end PerfectCompleteness.NormalizedTarget
end OAI
|