Download lean/OAI/Computability/VertexCover/Fourier/SourceOccurrences.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 22.2 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Computability/VertexCover/Fourier/SourceOccurrences.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Computability/VertexCover/Fourier/SourceOccurrences.lean
-
curl -L -o SourceOccurrences.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Computability/VertexCover/Fourier/SourceOccurrences.lean
22.2 kB
Lean 4 · 74
declarations statementsfull
structure Encoding (α : Type) where body · 2 lines
size : ℕ
code : α ≃ Fin sizedef fin (n : ℕ) : Encoding (Fin n) := ⟨n, Equiv.refl _⟩ def bool : Encoding Bool := ⟨2, finTwoEquiv.symm⟩ def unit : Encoding Unit := ⟨1, finOneEquiv.symm⟩ def prod {α β : Type} (a : Encoding α) (b : Encoding β) : Encoding (α × β) := body · 1 line
⟨a.size * b.size, (Equiv.prodCongr a.code b.code).trans finProdFinEquiv⟩def sum {α β : Type} (a : Encoding α) (b : Encoding β) : Encoding (α ⊕ β) := body · 1 line
⟨a.size + b.size, (Equiv.sumCongr a.code b.code).trans finSumFinEquiv⟩def function {α β : Type} (a : Encoding α) (b : Encoding β) : Encoding (α → β) where body · 6 lines
size := b.size ^ a.size
code := (show (α → β) ≃ (Fin a.size → Fin b.size) from
{ toFun := fun f i => b.code (f (a.code.symm i))
invFun := fun f x => b.code.symm (f (a.code x))
left_inv := by intro f; funext x; simp
right_inv := by intro f; funext i; simp }).trans finFunctionFinEquivdef enumerate {α : Type} (a : Encoding α) : List α := List.ofFn a.code.symm @[simp] theorem length_enumerate {α : Type} (a : Encoding α) :
a.enumerate.length = a.size := by simp [enumerate] theorem mem_enumerate {α : Type} (a : Encoding α) (x : α) : x ∈ a.enumerate := by proof · 2 lines
rw [enumerate, List.mem_ofFn']
exact ⟨a.code x, a.code.symm_apply_apply x⟩theorem nodup_enumerate {α : Type} (a : Encoding α) : a.enumerate.Nodup := proof · 1 line
List.nodup_ofFn_ofInjective a.code.symm.injectivetheorem card_eq_size {α : Type} [Fintype α] (a : Encoding α) :
Fintype.card α = a.size := by proof · 1 line
simpa only [Fintype.card_fin] using Fintype.card_congr a.codeabbrev GlobalKey (V C I J : Type) := (V × Cube I) ⊕ ((C × Cube J) ⊕ Unit) def globalEncoding {V C I J : Type}
(v : Encoding V) («c» : Encoding C) (i : Encoding I) (j : Encoding J) :
Encoding (GlobalKey V C I J) := body · 2 lines
(v.prod (i.function Encoding.bool)).sum
((«c».prod (j.function Encoding.bool)).sum Encoding.unit)@[simp] theorem globalEncoding_size {V C I J : Type}
(v : Encoding V) («c» : Encoding C) (i : Encoding I) (j : Encoding J) :
(globalEncoding v «c» i j).size =
v.size * 2 ^ i.size + («c».size * 2 ^ j.size + 1) := rfl def extendRestricted {J : Type} (valid : J → Bool)
(f : Cube {j : J // valid j = true}) : Cube J := body · 1 line
fun j => if h : valid j = true then f ⟨j, h⟩ else false@[simp] theorem extendRestricted_valid {J : Type} (valid : J → Bool)
(f : Cube {j : J // valid j = true}) (j : {j : J // valid j = true}) :
extendRestricted valid f j.val = f j := by simp [extendRestricted, j.property] theorem extendRestricted_injective {J : Type} (valid : J → Bool) :
Function.Injective (extendRestricted valid) := by proof · 4 lines
intro f g h
funext j
have := congrFun h j.val
simpa only [extendRestricted_valid] using this@[simp] theorem restrictQuery_extendRestricted {J : Type} (valid : J → Bool)
(f : Cube {j : J // valid j = true}) :
restrictQuery valid (extendRestricted valid f) = f := by proof · 2 lines
funext j exact extendRestricted_valid valid f j
@[simp] theorem canonicalInput_half {I : Type} [Fintype I] [DecidableEq I]
(i₀ : I) (f : HalfCube i₀) :
canonicalInput i₀ f.val = f := by proof · 2 lines
apply Subtype.ext
simp [canonicalInput, representative, f.property]def assignmentOfKey {V C I J : Type}
(v : Encoding V) («c» : Encoding C) (i : Encoding I) (j : Encoding J)
(bits : GlobalKey V C I J → Bool) : Fin (globalEncoding v «c» i j).size → Bool := body · 1 line
fun q => bits ((globalEncoding v «c» i j).code.symm q)@[simp] theorem assignmentOfKey_code {V C I J : Type}
(v : Encoding V) («c» : Encoding C) (i : Encoding I) (j : Encoding J)
(bits : GlobalKey V C I J → Bool) (key : GlobalKey V C I J) :
assignmentOfKey v «c» i j bits ((globalEncoding v «c» i j).code key) = bits key := by proof · 1 line
exact congrArg bits ((globalEncoding v «c» i j).code.symm_apply_apply key)theorem assignmentOfKey_surjective {V C I J : Type}
(v : Encoding V) («c» : Encoding C) (i : Encoding I) (j : Encoding J) :
Function.Surjective (assignmentOfKey v «c» i j) := by proof · 4 lines
intro bits
refine ⟨fun key => bits ((globalEncoding v «c» i j).code key), ?_⟩
funext q
exact congrArg bits ((globalEncoding v «c» i j).code.apply_symm_apply q)def localAddress (vE : Encoding V) (cE : Encoding C) (iE : Encoding I) (jE : Encoding J)
(v : V) («c» : C) (valid : J → Bool) (i₀ : I) (j₀ : {j : J // valid j = true}) :
FoldedEquation.Address i₀ j₀ → Fin (globalEncoding vE cE iE jE).size body · 2 lines
| .inl f => (globalEncoding vE cE iE jE).code (.inl (v, f.val))
| .inr g => (globalEncoding vE cE iE jE).code (.inr (.inl («c», extendRestricted valid g.val)))theorem localAddress_injective
(vE : Encoding V) (cE : Encoding C) (iE : Encoding I) (jE : Encoding J)
(v : V) («c» : C) (valid : J → Bool) (i₀ : I) (j₀ : {j : J // valid j = true}) :
Function.Injective (localAddress vE cE iE jE v «c» valid i₀ j₀) := by proof · 20 lines
intro a b h
cases a with
| inl a =>
cases b with
| inl b =>
have h' := (globalEncoding vE cE iE jE).code.injective h
have hval : a.val = b.val := congrArg Prod.snd (Sum.inl.inj h')
exact congrArg Sum.inl (Subtype.ext hval)
| inr b =>
have h' := (globalEncoding vE cE iE jE).code.injective h
cases h'
| inr a =>
cases b with
| inl b =>
have h' := (globalEncoding vE cE iE jE).code.injective h
cases h'
| inr b =>
have h' := (globalEncoding vE cE iE jE).code.injective h
have hext := congrArg Prod.snd (Sum.inl.inj (Sum.inr.inj h'))
exact congrArg Sum.inr (Subtype.ext (extendRestricted_injective valid hext))def conditionedOccurrence
(vE : Encoding V) (cE : Encoding C) (iE : Encoding I) (jE : Encoding J)
(v : V) («c» : C) (valid : J → Bool) (π : J → I)
(i₀ : I) (j₀ : {j : J // valid j = true}) (f : Cube I) (g μ : Cube J) :
Equation (Fin (globalEncoding vE cE iE jE).size) := body · 2 lines
mapEquation (localAddress vE cE iE jE v «c» valid i₀ j₀)
(FoldedEquation.conditionedEquation valid π i₀ j₀ f g μ)theorem conditionedOccurrence_satisfied
(vE : Encoding V) (cE : Encoding C) (iE : Encoding I) (jE : Encoding J)
(v : V) («c» : C) (valid : J → Bool) (π : J → I)
(i₀ : I) (j₀ : {j : J // valid j = true})
(bits : Fin (globalEncoding vE cE iE jE).size → Bool)
(f : Cube I) (g μ : Cube J) :
satisfied (conditionedOccurrence vE cE iE jE v «c» valid π i₀ j₀ f g μ) bits =
!(foldedAnswer i₀ (fun h => bits ((globalEncoding vE cE iE jE).code (.inl (v, h.val)))) f ^^
conditionedFoldedAnswer valid j₀
(fun h => bits ((globalEncoding vE cE iE jE).code
(.inr (.inl («c», extendRestricted valid h.val))))) g ^^
conditionedFoldedAnswer valid j₀
(fun h => bits ((globalEncoding vE cE iE jE).code
(.inr (.inl («c», extendRestricted valid h.val))))) (thirdQuery π f g μ)) := by proof · 12 lines
rw [conditionedOccurrence, satisfied_mapEquation]
let tableA : HalfCube i₀ → Bool :=
fun h => bits ((globalEncoding vE cE iE jE).code (.inl (v, h.val)))
let tableB : HalfCube j₀ → Bool :=
fun h => bits ((globalEncoding vE cE iE jE).code
(.inr (.inl («c», extendRestricted valid h.val))))
have hbits : bits ∘ localAddress vE cE iE jE v «c» valid i₀ j₀ =
FoldedEquation.storedAssignment tableA tableB := by
funext a
cases a <;> rfl
rw [hbits]
exact FoldedEquation.conditionedEquation_satisfied valid π i₀ j₀ tableA tableB f g μdef findValid {J : Type} (valid : J → Bool) : List J → Option {j : J // valid j = true} body · 2 lines
| [] => none
| j :: rest => if h : valid j = true then some ⟨j, h⟩ else findValid valid resttheorem findValid_none_iff {J : Type} (valid : J → Bool) (xs : List J) :
findValid valid xs = none ↔ ∀ j ∈ xs, valid j = false := by proof · 6 lines
induction xs with
| nil => simp [findValid]
| cons j xs ih =>
by_cases hj : valid j = true
· simp [findValid, hj]
· simp [findValid, hj, ih]def firstValid {J : Type} (e : Encoding J) (valid : J → Bool) :
Option {j : J // valid j = true} := findValid valid e.enumerate theorem firstValid_none_iff {J : Type} (e : Encoding J) (valid : J → Bool) :
firstValid e valid = none ↔ ∀ j, valid j = false := by proof · 2 lines
rw [firstValid, findValid_none_iff]
exact ⟨fun h j => h j (e.mem_enumerate j), fun h j _ => h j⟩def occurrenceList {Tape Name : Type} (tape : Encoding Tape)
(emit : Tape → Equation Name) : List (Equation Name) := tape.enumerate.map emit @[simp] theorem occurrenceList_length {Tape Name : Type} (tape : Encoding Tape)
(emit : Tape → Equation Name) : (occurrenceList tape emit).length = tape.size := by proof · 1 line
simp [occurrenceList]
private theorem countP_cast_eq_sum {α : Type} (xs : List α) (p : α → Bool) :
(xs.countP p : ℝ) = (xs.map (fun x => if p x then (1 : ℝ) else 0)).sum := by proof · 3 lines
induction xs with
| nil => simp
| cons x xs ih => cases hp : p x <;> simp [hp, ih, add_comm]theorem countP_enumerate {Tape : Type} [Fintype Tape]
(tape : Encoding Tape) (p : Tape → Bool) :
(tape.enumerate.countP p : ℝ) = ∑ x, if p x then (1 : ℝ) else 0 := by proof · 3 lines
rw [countP_cast_eq_sum]
simp only [Encoding.enumerate, List.map_ofFn, List.sum_ofFn]
exact Fintype.sum_equiv tape.code.symm _ _ (fun _ => rfl)theorem occurrenceList_acceptance {Tape Name : Type} [Fintype Tape]
(tape : Encoding Tape) (emit : Tape → Equation Name) (bits : Name → Bool) :
((occurrenceList tape emit).countP (fun e => satisfied e bits) : ℝ) /
(occurrenceList tape emit).length =
𝔼 x, if satisfied (emit x) bits then (1 : ℝ) else 0 := by proof · 4 lines
rw [occurrenceList_length, Fintype.expect_eq_sum_div_card, tape.card_eq_size]
congr 1
simpa only [occurrenceList, List.countP_map, Function.comp_def] using
countP_enumerate tape (fun x => satisfied (emit x) bits)def clauseAnswerEncoding : Encoding PCP.ClauseAnswer := ⟨8, clauseAnswerFinEquiv⟩ def slotEncoding : Encoding PCP.Slot where body · 6 lines
size := 3
code :=
{ toFun := fun s => match s with | .first => 0 | .second => 1 | .third => 2
invFun := fun i => if i.val = 0 then .first else if i.val = 1 then .second else .third
left_inv := by intro s; cases s <;> rfl
right_inv := by decide }def iEncoding (u : ℕ) : Encoding (I u) := (Encoding.fin u).function Encoding.bool def jEncoding (u : ℕ) : Encoding (J u) := (Encoding.fin u).function clauseAnswerEncoding def variableEncoding (F : Target.Formula) (u : ℕ) : Encoding (VariableContext F u) := body · 1 line
(Encoding.fin u).function (Encoding.fin F.«variables»)def clauseEncoding (F : Target.Formula) (u : ℕ) : Encoding (ClauseContext F u) := body · 1 line
(Encoding.fin u).function (Encoding.fin F.clauses.length)def slotContextEncoding (u : ℕ) : Encoding (SlotContext u) := body · 1 line
(Encoding.fin u).function slotEncodingdef proofEncoding (F : Target.Formula) (u : ℕ) :
Encoding (GlobalKey (VariableContext F u) (ClauseContext F u) (I u) (J u)) := body · 1 line
globalEncoding (variableEncoding F u) (clauseEncoding F u) (iEncoding u) (jEncoding u)def nBits (F : Target.Formula) (u : ℕ) : ℕ := (proofEncoding F u).size @[simp] theorem nBits_eq (F : Target.Formula) (u : ℕ) :
nBits F u = F.«variables» ^ u * 2 ^ (2 ^ u) +
(F.clauses.length ^ u * 2 ^ (8 ^ u) + 1) := rfl def dummyIndex (F : Target.Formula) (u : ℕ) : Fin (nBits F u) := body · 1 line
(proofEncoding F u).code (.inr (.inr ()))def leftAnchor (u : ℕ) : I u := fun _ => false def rightAnchor (F : Target.Formula) {u : ℕ} («c» : ClauseContext F u) :
Option {j : J u // validJ F «c» j = true} := firstValid (jEncoding u) (validJ F «c») theorem rightAnchor_none_iff (F : Target.Formula) {u : ℕ} («c» : ClauseContext F u) :
rightAnchor F «c» = none ↔ ∀ j : J u, validJ F «c» j = false := proof · 1 line
firstValid_none_iff _ _
def halfTableKeyAssignment (F : Target.Formula) (u : ℕ)
(a : VariableContext F u → HalfCube (leftAnchor u) → Bool)
(b : ∀ «c» : ClauseContext F u, ∀ j₀ : {j : J u // validJ F «c» j = true},
HalfCube j₀ → Bool) :
GlobalKey (VariableContext F u) (ClauseContext F u) (I u) (J u) → Bool body · 6 lines
| .inl (v, f) => a v (canonicalInput (leftAnchor u) f)
| .inr (.inl («c», g)) =>
match rightAnchor F «c» with
| none => false
| some j₀ => b «c» j₀ (canonicalInput j₀ (restrictQuery (validJ F «c») g))
| .inr (.inr _) => falsedef extendHalfTables (F : Target.Formula) (u : ℕ)
(a : VariableContext F u → HalfCube (leftAnchor u) → Bool)
(b : ∀ «c» : ClauseContext F u, ∀ j₀ : {j : J u // validJ F «c» j = true},
HalfCube j₀ → Bool) : Fin (nBits F u) → Bool := body · 2 lines
assignmentOfKey (variableEncoding F u) (clauseEncoding F u) (iEncoding u) (jEncoding u)
(halfTableKeyAssignment F u a b)@[simp] theorem extendHalfTables_left (F : Target.Formula) (u : ℕ)
(a : VariableContext F u → HalfCube (leftAnchor u) → Bool)
(b : ∀ «c» : ClauseContext F u, ∀ j₀ : {j : J u // validJ F «c» j = true},
HalfCube j₀ → Bool) (v : VariableContext F u) (h : HalfCube (leftAnchor u)) :
extendHalfTables F u a b ((proofEncoding F u).code (.inl (v, h.val))) = a v h := by proof · 5 lines
calc
_ = halfTableKeyAssignment F u a b (.inl (v, h.val)) :=
assignmentOfKey_code (variableEncoding F u) (clauseEncoding F u) (iEncoding u)
(jEncoding u) (halfTableKeyAssignment F u a b) (.inl (v, h.val))
_ = a v h := congrArg (a v) (canonicalInput_half (leftAnchor u) h)theorem extendHalfTables_right (F : Target.Formula) (u : ℕ)
(a : VariableContext F u → HalfCube (leftAnchor u) → Bool)
(b : ∀ «c» : ClauseContext F u, ∀ j₀ : {j : J u // validJ F «c» j = true},
HalfCube j₀ → Bool) («c» : ClauseContext F u)
(j₀ : {j : J u // validJ F «c» j = true}) (hanchor : rightAnchor F «c» = some j₀)
(h : HalfCube j₀) :
extendHalfTables F u a b ((proofEncoding F u).code
(.inr (.inl («c», extendRestricted (validJ F «c») h.val)))) = b «c» j₀ h := by proof · 8 lines
calc
_ = halfTableKeyAssignment F u a b
(.inr (.inl («c», extendRestricted (validJ F «c») h.val))) :=
assignmentOfKey_code (variableEncoding F u) (clauseEncoding F u) (iEncoding u)
(jEncoding u) (halfTableKeyAssignment F u a b) _
_ = b «c» j₀ h := by
simp only [halfTableKeyAssignment, hanchor]
rw [restrictQuery_extendRestricted, canonicalInput_half]def emptyAddress (F : Target.Formula) (u : ℕ) (v : VariableContext F u) :
EmptyContext.Address (leftAnchor u) → Fin (nBits F u) body · 2 lines
| .inl h => (proofEncoding F u).code (.inl (v, h.val))
| .inr _ => dummyIndex F udef contextEquation (F : Target.Formula) (u D : ℕ)
(«c» : ClauseContext F u) (v : VariableContext F u)
(t : SourceTape.TestTape (I u) (J u) D) : Equation (Fin (nBits F u)) := body · 5 lines
match rightAnchor F «c» with
| none => mapEquation (emptyAddress F u v) (EmptyContext.equation (leftAnchor u) t.1)
| some j₀ => conditionedOccurrence (variableEncoding F u) (clauseEncoding F u)
(iEncoding u) (jEncoding u) v «c» (validJ F «c») (pi F «c» v) (leftAnchor u) j₀
t.1 t.2.2 (realizedNoise t.2.1)def leftResponse (F : Target.Formula) (u : ℕ) (bits : Fin (nBits F u) → Bool)
(v : VariableContext F u) : Cube (I u) → Bool := body · 1 line
foldedAnswer (leftAnchor u) (fun h => bits ((proofEncoding F u).code (.inl (v, h.val))))def rightResponse (F : Target.Formula) (u : ℕ) (bits : Fin (nBits F u) → Bool)
(«c» : ClauseContext F u) : Cube (J u) → Bool := body · 4 lines
match rightAnchor F «c» with
| none => fun _ => false
| some j₀ => conditionedFoldedAnswer (validJ F «c») j₀
(fun h => bits ((proofEncoding F u).code (.inr (.inl («c», extendRestricted (validJ F «c») h.val)))))theorem contextEquation_satisfied (F : Target.Formula) (u D : ℕ)
(«c» : ClauseContext F u) (v : VariableContext F u)
(t : SourceTape.TestTape (I u) (J u) D) (bits : Fin (nBits F u) → Bool) :
satisfied (contextEquation F u D «c» v t) bits =
!(leftResponse F u bits v t.1 ^^ rightResponse F u bits «c» t.2.2 ^^
rightResponse F u bits «c» (thirdQuery (pi F «c» v) t.1 t.2.2 (realizedNoise t.2.1))) := by proof · 10 lines
cases ha : rightAnchor F «c» with
| none =>
simp only [contextEquation, ha, satisfied_mapEquation, EmptyContext.equation_satisfied,
rightResponse, Bool.xor_false]
rfl
| some j₀ =>
simp only [contextEquation, ha, rightResponse]
exact conditionedOccurrence_satisfied (variableEncoding F u) (clauseEncoding F u)
(iEncoding u) (jEncoding u) v «c» (validJ F «c») (pi F «c» v) (leftAnchor u) j₀
bits t.1 t.2.2 (realizedNoise t.2.1)def testTapeEncoding (u D : ℕ) : Encoding (SourceTape.TestTape (I u) (J u) D) := body · 2 lines
((iEncoding u).function Encoding.bool).prod
(((jEncoding u).function (Encoding.fin D)).prod ((jEncoding u).function Encoding.bool))abbrev SourceIndex (F : Target.Formula) (u D : ℕ) := body · 1 line
(ClauseContext F u × SlotContext u) × SourceTape.TestTape (I u) (J u) Ddef sourceIndexEncoding (F : Target.Formula) (u D : ℕ) : Encoding (SourceIndex F u D) := body · 1 line
((clauseEncoding F u).prod (slotContextEncoding u)).prod (testTapeEncoding u D)def sourceEquation (F : Target.Formula) (u D : ℕ) (p : SourceIndex F u D) :
Equation (Fin (nBits F u)) := body · 1 line
contextEquation F u D p.1.1 (sampledVariables F p.1.1 p.1.2) p.2def rawSourceList (F : Target.Formula) (u D : ℕ) : List (Equation (Fin (nBits F u))) := body · 1 line
occurrenceList (sourceIndexEncoding F u D) (sourceEquation F u D)@[simp] theorem rawSourceList_length (F : Target.Formula) (u D : ℕ) :
(rawSourceList F u D).length =
(F.clauses.length ^ u * 3 ^ u) *
(2 ^ (2 ^ u) * (D ^ (8 ^ u) * 2 ^ (8 ^ u))) := by proof · 2 lines
rw [rawSourceList, occurrenceList_length] rfl
theorem rawSourceList_acceptance (F : Target.Formula) (u D : ℕ)
(hD : 0 < D) (bits : Fin (nBits F u) → Bool) :
((rawSourceList F u D).countP (fun e => satisfied e bits) : ℝ) /
(rawSourceList F u D).length =
𝔼 «c» : ClauseContext F u, 𝔼 s : SlotContext u,
testAcceptance ((D : ℝ)⁻¹) (pi F «c» (sampledVariables F «c» s))
(leftResponse F u bits (sampledVariables F «c» s)) (rightResponse F u bits «c») := by proof · 15 lines
rw [rawSourceList, occurrenceList_acceptance, SourceTape.expect_prod]
rw [SourceTape.expect_prod]
apply Finset.expect_congr rfl
intro «c» _
apply Finset.expect_congr rfl
intro s _
rw [← SourceTape.tapeAcceptance_eq_testAcceptance hD]
unfold SourceTape.tapeAcceptance
apply Finset.expect_congr rfl
intro t _
rw [sourceEquation, contextEquation_satisfied]
cases h : leftResponse F u bits (sampledVariables F «c» s) t.1 ^^
rightResponse F u bits «c» t.2.2 ^^
rightResponse F u bits «c»
(thirdQuery (pi F «c» (sampledVariables F «c» s)) t.1 t.2.2 (realizedNoise t.2.1)) <;> rfldef emptyFormulaEquation (F : Target.Formula) (u : ℕ) : Equation (Fin (nBits F u)) := body · 1 line
⟨dummyIndex F u, dummyIndex F u, dummyIndex F u, false⟩def sourceList (F : Target.Formula) (u D : ℕ) : List (Equation (Fin (nBits F u))) := body · 1 line
if F.clauses.isEmpty then [emptyFormulaEquation F u] else rawSourceList F u Dtheorem sourceList_empty (F : Target.Formula) (u D : ℕ) (h : F.clauses = []) :
sourceList F u D = [emptyFormulaEquation F u] := by simp [sourceList, h] theorem sourceList_nonempty (F : Target.Formula) (u D : ℕ) (h : F.clauses ≠ []) :
sourceList F u D = rawSourceList F u D := by proof · 3 lines
unfold sourceList
rw [List.isEmpty_eq_false_iff.mpr h]
rfltheorem sourceList_length_le_raw_add_one (F : Target.Formula) (u D : ℕ) :
(sourceList F u D).length ≤ (rawSourceList F u D).length + 1 := by proof · 6 lines
by_cases h : F.clauses = []
· rw [sourceList_empty F u D h]
rw [List.length_singleton]
omega
· rw [sourceList_nonempty F u D h]
omegatheorem sourceList_ne_nil (F : Target.Formula) (u D : ℕ) (hD : 0 < D) :
sourceList F u D ≠ [] := by proof · 8 lines
by_cases h : F.clauses = []
· rw [sourceList_empty F u D h]
simp
· rw [sourceList_nonempty F u D h]
apply List.length_pos_iff.mp
rw [rawSourceList_length]
have hc : 0 < F.clauses.length := List.length_pos_iff.mpr h
positivitydef sourceInput (F : Target.Formula) (u D : ℕ) (hD : 0 < D) :
UniqueGames.Reduction.SourceEncoding.Input := body · 1 line
⟨nBits F u, sourceList F u D, sourceList_ne_nil F u D hD⟩theorem emptyFormulaEquation_satisfied (F : Target.Formula) (u : ℕ)
(bits : Fin (nBits F u) → Bool) :
satisfied (emptyFormulaEquation F u) bits = !(bits (dummyIndex F u)) := by proof · 1 line
cases h : bits (dummyIndex F u) <;> simp [emptyFormulaEquation, satisfied, h]Outline
- structure
Encoding46 - def
fin52 - def
bool53 - def
unit54 - def
prod56 - def
sum59 - def
function62 - def
enumerate70 - theorem
length_enumerate72 - theorem
mem_enumerate75 - theorem
nodup_enumerate79 - theorem
card_eq_size82 - abbrev
GlobalKey88 - def
globalEncoding90 - theorem
globalEncoding_size96 - def
extendRestricted101 - theorem
extendRestricted_valid105 - theorem
extendRestricted_injective109 - theorem
restrictQuery_extendRestricted116 - theorem
canonicalInput_half122 - def
assignmentOfKey128 - theorem
assignmentOfKey_code133 - theorem
assignmentOfKey_surjective139 - def
localAddress151 - theorem
localAddress_injective158 - def
conditionedOccurrence183 - theorem
conditionedOccurrence_satisfied192 - def
findValid221 - theorem
findValid_none_iff225 - def
firstValid234 - theorem
firstValid_none_iff237 - def
occurrenceList242 - theorem
occurrenceList_length245 - theorem
countP_cast_eq_sum249 - theorem
countP_enumerate255 - theorem
occurrenceList_acceptance262 - def
clauseAnswerEncoding277 - def
slotEncoding279 - def
iEncoding287 - def
jEncoding288 - def
variableEncoding289 - def
clauseEncoding291 - def
slotContextEncoding293 - def
proofEncoding296 - def
nBits300 - theorem
nBits_eq302 - def
dummyIndex306 - def
leftAnchor309 - def
rightAnchor311 - theorem
rightAnchor_none_iff314 - def
halfTableKeyAssignment318 - def
extendHalfTables330 - theorem
extendHalfTables_left337 - theorem
extendHalfTables_right348 - def
emptyAddress365 - def
contextEquation370 - def
leftResponse379 - def
rightResponse383 - theorem
contextEquation_satisfied390 - def
testTapeEncoding407 - abbrev
SourceIndex411 - def
sourceIndexEncoding414 - def
sourceEquation417 - def
rawSourceList421 - theorem
rawSourceList_length424 - theorem
rawSourceList_acceptance431 - def
emptyFormulaEquation454 - def
sourceList457 - theorem
sourceList_empty460 - theorem
sourceList_nonempty463 - theorem
sourceList_length_le_raw_add_one469 - theorem
sourceList_ne_nil478 - def
sourceInput489 - theorem
emptyFormulaEquation_satisfied493