cfahlgren1's picture
download
raw
6.28 kB
import Mathlib
import OAI.Combinatorics.IndependentSets.Fourier.EmptyContext
import OAI.Combinatorics.IndependentSets.Encoding.Occurrences
namespace OAI
namespace IndependentSetsGames.Foundations.Hastad.SourceOccurrences
open IndependentSetsGames.Reduction.CloneGap
open scoped BigOperators
section LocalEquations
variable {V C I J : Type} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J]
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
| .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)))
omit [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] in
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
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) :=
mapEquation (localAddress vE cE iE jE v c valid i₀ j₀)
(FoldedEquation.conditionedEquation valid π i₀ j₀ f g μ)
omit [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] in
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
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 μ
end LocalEquations
def findValid {J : Type} (valid : J → Bool) : List J → Option {j : J // valid j = true}
| [] => none
| j :: rest => if h : valid j = true then some ⟨j, h⟩ else findValid valid rest
theorem findValid_none_iff {J : Type} (valid : J → Bool) (xs : List J) :
findValid valid xs = none ↔ ∀ j ∈ xs, valid j = false := by
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
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
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
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
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
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)
end IndependentSetsGames.Foundations.Hastad.SourceOccurrences
end OAI

Xet Storage Details

Size:
6.28 kB
·
Xet hash:
a6e29f1a1dc66478514034ec49da25a2b9addac722c8fd0eb7f0bd0016f8b1ed

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.