Buckets:
| import Mathlib | |
| import OAI.Computability.MinUncut.PCP.SpectralCut | |
| namespace OAI | |
| section | |
| namespace MinUncutGames.Foundations.PCP.PreprocessingTableSpectral | |
| open PoweringWalks SpectralReturn | |
| private theorem portGraph_ext {V D : Type*} {G H : PortGraph V D} | |
| (h : ∀ x, G.rot x = H.rot x) : G = H := by | |
| have hr : G.rot = H.rot := Equiv.ext h | |
| cases G | |
| cases H | |
| cases hr | |
| rfl | |
| theorem materialize_portGraph {n d : Nat} {D : Type*} | |
| (G : ConstraintGraph (Fin n) (Fin n × D) PortTables.Label) | |
| (ports : D ≃ Fin d) : | |
| PortTables.portGraph (PreprocessingOverlayTables.materialize G ports) = | |
| GraphTransport.reindex (Overlay.originalPortGraph G) (Equiv.refl _) ports := by | |
| apply portGraph_ext | |
| intro x | |
| rw [PortTables.portGraph_rot, PreprocessingOverlayTables.rotation_materialize] | |
| rfl | |
| theorem overlay_portGraph {n d e : Nat} (G : PortTables.Table n d) | |
| (H : ExpanderTables.Table n e) : | |
| PortTables.portGraph (PreprocessingOverlayTables.overlay G H) = | |
| GraphTransport.reindex | |
| (Overlay.portGraph (PortTables.portGraph G) (ExpanderTables.graph H)) | |
| (Equiv.refl _) (PreprocessingOverlayTables.overlayPorts d e) := by | |
| unfold PreprocessingOverlayTables.overlay | |
| rw [materialize_portGraph] | |
| rfl | |
| theorem overlay_rotation_eq {n d e : Nat} (G : PortTables.Table n d) | |
| (H : ExpanderTables.Table n e) (x : Fin n × Fin (d + e)) : | |
| PortTables.rotation (PreprocessingOverlayTables.overlay G H) x = | |
| (GraphTransport.reindex | |
| (Overlay.portGraph (PortTables.portGraph G) (ExpanderTables.graph H)) | |
| (Equiv.refl _) (PreprocessingOverlayTables.overlayPorts d e)).rot x := by | |
| change (PortTables.portGraph (PreprocessingOverlayTables.overlay G H)).rot x = _ | |
| rw [overlay_portGraph] | |
| theorem lazy_portGraph {n d : Nat} (G : PortTables.Table n d) : | |
| PortTables.portGraph (PreprocessingOverlayTables.lazy G) = | |
| GraphTransport.reindex (lazyGraph (PortTables.portGraph G)) | |
| (Equiv.refl _) (PreprocessingOverlayTables.lazyPorts d) := by | |
| unfold PreprocessingOverlayTables.lazy | |
| rw [materialize_portGraph] | |
| rfl | |
| theorem lazy_rotation_eq {n d : Nat} (G : PortTables.Table n d) | |
| (x : Fin n × Fin (2 * d)) : | |
| PortTables.rotation (PreprocessingOverlayTables.lazy G) x = | |
| (GraphTransport.reindex (lazyGraph (PortTables.portGraph G)) | |
| (Equiv.refl _) (PreprocessingOverlayTables.lazyPorts d)).rot x := by | |
| change (PortTables.portGraph (PreprocessingOverlayTables.lazy G)).rot x = _ | |
| rw [lazy_portGraph] | |
| theorem overlay_certificate_seven_eighths {n d e : Nat} | |
| (G : PortTables.Table n d) (H : ExpanderTables.Table n e) | |
| (hn : 0 < n) (hdegree : d = e + 1) (he : 8 ≤ e) | |
| (hH : SpectralCertificate (ExpanderTables.graph H) (1 / 2 : ℝ)) : | |
| SpectralCertificate (PortTables.portGraph (PreprocessingOverlayTables.overlay G H)) | |
| (7 / 8 : ℝ) := by | |
| let : Nonempty (Fin n) := ⟨⟨0, hn⟩⟩ | |
| rw [overlay_portGraph] | |
| apply GraphTransport.reindex_spectralCertificate | |
| apply Overlay.spectralCertificate_seven_eighths | |
| (PortTables.portGraph G) (ExpanderTables.graph H) | |
| · simpa only [Fintype.card_fin] using hdegree | |
| · simp only [Fintype.card_fin] | |
| omega | |
| · exact hH | |
| theorem lazy_certificate_31_32 {n d : Nat} (G : PortTables.Table n d) | |
| (hd : 0 < d) (hG : SpectralCertificate (PortTables.portGraph G) (7 / 8 : ℝ)) : | |
| SpectralCertificate (PortTables.portGraph (PreprocessingOverlayTables.lazy G)) | |
| (31 / 32 : ℝ) := by | |
| let : Nonempty (Fin d) := ⟨⟨0, hd⟩⟩ | |
| rw [lazy_portGraph] | |
| exact GraphTransport.reindex_spectralCertificate _ _ _ _ | |
| (LazySpectral.lazy_certificate_31_32 (PortTables.portGraph G) hG) | |
| end MinUncutGames.Foundations.PCP.PreprocessingTableSpectral | |
| end | |
| section | |
| noncomputable section | |
| namespace MinUncutGames.Foundations.PCP.PreprocessingGuarantees | |
| open PoweringWalks SpectralReturn PreprocessingTables | |
| open PreprocessingRegularTables (internalDegree regularize) | |
| variable {n d e : Nat} | |
| theorem overlay_rejectionCount (G : PortTables.Table n d) (H : ExpanderTables.Table n e) | |
| (labels : Fin n → GraphTables.Label) : | |
| (PortTables.baseGraph (PreprocessingOverlayTables.overlay G H)).rejectionCount labels = | |
| (PortTables.baseGraph G).rejectionCount labels := by | |
| rw [PreprocessingOverlayTables.overlay_semantics] | |
| calc | |
| _ = (Overlay.constraintGraph (PortTables.baseGraph G) (ExpanderTables.graph H)).rejectionCount labels := by | |
| convert ConstraintGraph.reindex_rejectionCount | |
| (Overlay.constraintGraph (PortTables.baseGraph G) (ExpanderTables.graph H)) | |
| (Equiv.refl _) (Equiv.prodCongr (Equiv.refl _) | |
| (PreprocessingOverlayTables.overlayPorts d e)) (Equiv.refl _) labels using 1 | |
| rfl | |
| _ = _ := Overlay.rejectionCount_eq _ _ rfl labels | |
| theorem lazy_rejectionCount (G : PortTables.Table n d) | |
| (labels : Fin n → GraphTables.Label) : | |
| (PortTables.baseGraph (PreprocessingOverlayTables.lazy G)).rejectionCount labels = | |
| (PortTables.baseGraph G).rejectionCount labels := by | |
| rw [PreprocessingOverlayTables.lazy_semantics] | |
| calc | |
| _ = (LazyConstraint.constraintGraph (PortTables.baseGraph G)).rejectionCount labels := by | |
| convert ConstraintGraph.reindex_rejectionCount | |
| (LazyConstraint.constraintGraph (PortTables.baseGraph G)) | |
| (Equiv.refl _) (Equiv.prodCongr (Equiv.refl _) | |
| (PreprocessingOverlayTables.lazyPorts d)) (Equiv.refl _) labels using 1 | |
| rfl | |
| _ = _ := LazyConstraint.rejectionCount_eq _ rfl labels | |
| theorem overlayFamily_certificate (H : BaseTable) | |
| (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) | |
| (t : GraphTables.Table) : | |
| SpectralCertificate (ExpanderTables.graph (overlayFamily H t)) (1 / 2 : ℝ) := by | |
| let : NeZero Expanders.baseDegree := ⟨PreprocessingRegularSoundness.baseDegree_ne_zero⟩ | |
| apply PreprocessingRegularSoundness.resizeTable_certificate | |
| exact ExpanderTables.family_certificate H certificate _ | |
| theorem overlay_certificate (H : BaseTable) | |
| (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) | |
| (t : GraphTables.Table) : | |
| SpectralCertificate (PortTables.portGraph | |
| (PreprocessingOverlayTables.overlay (padded H t) (overlayFamily H t))) (7 / 8 : ℝ) := | |
| PreprocessingTableSpectral.overlay_certificate_seven_eighths _ _ | |
| (vertices_positive t) rfl PreprocessingRegularSoundness.internalDegree_ge_eight | |
| (overlayFamily_certificate H certificate t) | |
| theorem spectral_certificate (H : BaseTable) | |
| (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) | |
| (t : GraphTables.Table) : | |
| SpectralCertificate (PortTables.portGraph (preprocess H t)) (31 / 32 : ℝ) := by | |
| apply PreprocessingTableSpectral.lazy_certificate_31_32 | |
| · omega | |
| · exact overlay_certificate H certificate t | |
| def restrictedLabel (t : GraphTables.Table) | |
| (labels : Fin (vertices t) → GraphTables.Label) : | |
| Fin (regularVertices t) → GraphTables.Label := | |
| fun v => labels (v.castLE (PreprocessingLevels.le_paddedSize (regularVertices t))) | |
| theorem rejectionCount_eq_regularized (H : BaseTable) (t : GraphTables.Table) | |
| (labels : Fin (vertices t) → GraphTables.Label) : | |
| (PortTables.baseGraph (preprocess H t)).rejectionCount labels = | |
| (PortTables.baseGraph (regularize H t)).rejectionCount (restrictedLabel t labels) := by | |
| unfold preprocess PreprocessingTables.degree | |
| rw [lazy_rejectionCount, overlay_rejectionCount] | |
| exact PreprocessingPaddingTables.pad_rejectionCount _ _ labels | |
| def roundLabels (t : GraphTables.Table) | |
| (labels : Fin (vertices t) → GraphTables.Label) : Fin t.vertices → GraphTables.Label := | |
| PreprocessingRegularSoundness.roundLabels t (restrictedLabel t labels) | |
| theorem soundness (H : BaseTable) | |
| (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) | |
| (t : GraphTables.Table) (labels : Fin (vertices t) → GraphTables.Label) : | |
| (GraphTables.semantics t).rejectionCount (roundLabels t labels) ≤ | |
| (PortTables.baseGraph (preprocess H t)).rejectionCount labels := by | |
| rw [rejectionCount_eq_regularized] | |
| exact PreprocessingRegularSoundness.soundness H certificate t (restrictedLabel t labels) | |
| theorem completeness (H : BaseTable) (t : GraphTables.Table) | |
| (h : (GraphTables.semantics t).Satisfiable) : | |
| (PortTables.baseGraph (preprocess H t)).Satisfiable := by | |
| have hp : (PortTables.baseGraph (padded H t)).Satisfiable := | |
| (PreprocessingPaddingTables.pad_satisfiable_iff _ _).mpr | |
| (PreprocessingRegularSoundness.completeness H t h) | |
| obtain ⟨labels, hlabels⟩ := hp | |
| refine ⟨labels, ?_⟩ | |
| apply (ConstraintGraph.rejectionCount_eq_zero_iff _ labels).mp | |
| unfold preprocess PreprocessingTables.degree | |
| rw [lazy_rejectionCount, overlay_rejectionCount] | |
| exact (ConstraintGraph.rejectionCount_eq_zero_iff _ labels).mpr hlabels | |
| theorem gap_transfer_real (H : BaseTable) | |
| (certificate : SpectralCertificate (ExpanderTables.graph H) (1 / 100 : ℝ)) | |
| (t : GraphTables.Table) (ht : 0 < t.darts) | |
| (epsilon : ℝ) (he : 0 ≤ epsilon) | |
| (lower : ∀ labels : Fin t.vertices → GraphTables.Label, | |
| epsilon * t.darts ≤ ((GraphTables.semantics t).rejectionCount labels : ℝ)) | |
| (labels : Fin (vertices t) → GraphTables.Label) : | |
| (epsilon / Preprocessing.sizeFactor) * | |
| Fintype.card (Fin (vertices t) × Fin PreprocessingTables.degree) ≤ | |
| ((PortTables.baseGraph (preprocess H t)).rejectionCount labels : ℝ) := by | |
| have hs : (0 : ℝ) < Preprocessing.sizeFactor := | |
| Nat.cast_pos.mpr Preprocessing.sizeFactor_positive | |
| have hcount : Fintype.card (Fin (vertices t) × Fin PreprocessingTables.degree) ≤ | |
| Preprocessing.sizeFactor * t.darts := by | |
| simp only [Fintype.card_prod, Fintype.card_fin] | |
| calc | |
| _ ≤ (ExpanderFamily.growth ^ 2 * t.darts) * PreprocessingTables.degree := | |
| Nat.mul_le_mul_right _ (vertices_le_of_positive t ht) | |
| _ = _ := by rw [PreprocessingTables.degree_eq]; unfold Preprocessing.sizeFactor; ring | |
| have hcountR : (Fintype.card (Fin (vertices t) × Fin PreprocessingTables.degree) : ℝ) ≤ | |
| (Preprocessing.sizeFactor : ℝ) * t.darts := by exact_mod_cast hcount | |
| calc | |
| _ ≤ (epsilon / Preprocessing.sizeFactor) * | |
| ((Preprocessing.sizeFactor : ℝ) * t.darts) := | |
| mul_le_mul_of_nonneg_left hcountR (div_nonneg he hs.le) | |
| _ = epsilon * t.darts := by field_simp | |
| _ ≤ ((GraphTables.semantics t).rejectionCount (roundLabels t labels) : ℝ) := lower _ | |
| _ ≤ _ := Nat.cast_le.mpr (soundness H certificate t labels) | |
| end MinUncutGames.Foundations.PCP.PreprocessingGuarantees | |
| end | |
| end | |
| section | |
| namespace MinUncutGames.Foundations.PCP.PoweringLabels | |
| open PoweringWalks | |
| open scoped BigOperators | |
| variable {V D A : Type*} | |
| abbrev PortWords (D : Type*) (t : Nat) := (n : Fin (t + 1)) × (Fin n.val → D) | |
| instance finitePortWords [Finite D] (t : Nat) : Finite (PortWords D t) := by | |
| let := Fintype.ofFinite D | |
| exact Finite.of_fintype _ | |
| def Ball (G : PortGraph V D) (t : Nat) (v : V) := | |
| {u : V // ∃ n, n ≤ t ∧ ∃ p : Fin n → D, wordEnd G n v p = u} | |
| def wordToBall (G : PortGraph V D) (t : Nat) (v : V) (w : PortWords D t) : Ball G t v := | |
| ⟨wordEnd G w.1.val v w.2, w.1.val, Nat.le_of_lt_succ w.1.isLt, w.2, rfl⟩ | |
| theorem wordToBall_surjective (G : PortGraph V D) (t : Nat) (v : V) : | |
| Function.Surjective (wordToBall G t v) := by | |
| intro u | |
| obtain ⟨n, hn, p, hp⟩ := u.property | |
| refine ⟨⟨⟨n, Nat.lt_succ_of_le hn⟩, p⟩, ?_⟩ | |
| exact Subtype.ext hp | |
| instance finiteBall [Finite D] (G : PortGraph V D) (t : Nat) (v : V) : | |
| Finite (Ball G t v) := | |
| Finite.of_surjective (wordToBall G t v) (wordToBall_surjective G t v) | |
| theorem card_portWords [Finite D] (t : Nat) : | |
| Nat.card (PortWords D t) = ∑ n : Fin (t + 1), Nat.card D ^ n.val := by | |
| simp [PortWords, Nat.card_sigma, Nat.card_fun] | |
| theorem card_ball_le [Finite D] (G : PortGraph V D) (t : Nat) (v : V) : | |
| Nat.card (Ball G t v) ≤ ∑ n : Fin (t + 1), Nat.card D ^ n.val := by | |
| calc | |
| _ ≤ Nat.card (PortWords D t) := Nat.card_le_card_of_surjective | |
| (wordToBall G t v) (wordToBall_surjective G t v) | |
| _ = _ := card_portWords t | |
| structure AddressSelector (G : PortGraph V D) (t : Nat) (v : V) where | |
| address : Ball G t v → PortWords D t | |
| correct : ∀ u, wordToBall G t v (address u) = u | |
| noncomputable def classicalSelector (G : PortGraph V D) (t : Nat) (v : V) : | |
| AddressSelector G t v where | |
| address u := Classical.choose (wordToBall_surjective G t v u) | |
| correct u := Classical.choose_spec (wordToBall_surjective G t v u) | |
| def scanWitness {A : Type*} (p : A → Prop) [DecidablePred p] : | |
| (xs : List A) → (∃ a ∈ xs, p a) → {a // p a} | |
| | [], h => False.elim (by simp at h) | |
| | a :: xs, h => | |
| if ha : p a then ⟨a, ha⟩ else | |
| scanWitness p xs (by | |
| obtain ⟨b, hb, hp⟩ := h | |
| rcases List.mem_cons.mp hb with he | hm | |
| · exact False.elim (ha (he ▸ hp)) | |
| · exact ⟨b, hm, hp⟩) | |
| def listSelector [DecidableEq V] (G : PortGraph V D) (t : Nat) (v : V) | |
| (addresses : List (PortWords D t)) (complete : ∀ w, w ∈ addresses) : | |
| AddressSelector G t v where | |
| address u := (scanWitness (fun w => (wordToBall G t v w).val = u.val) addresses (by | |
| obtain ⟨w, hw⟩ := wordToBall_surjective G t v u | |
| exact ⟨w, complete w, congrArg Subtype.val hw⟩)).val | |
| correct u := Subtype.ext (scanWitness | |
| (fun w => (wordToBall G t v w).val = u.val) addresses (by | |
| obtain ⟨w, hw⟩ := wordToBall_surjective G t v u | |
| exact ⟨w, complete w, congrArg Subtype.val hw⟩)).property | |
| abbrev PaddedLabel (D : Type*) (t : Nat) (A : Type*) := PortWords D t → A | |
| def encode (G : PortGraph V D) (t : Nat) (v : V) (ℓ : Ball G t v → A) : | |
| PaddedLabel D t A := fun w => ℓ (wordToBall G t v w) | |
| def decode {G : PortGraph V D} {t : Nat} {v : V} (S : AddressSelector G t v) | |
| (a : PaddedLabel D t A) : Ball G t v → A := fun u => a (S.address u) | |
| theorem decode_encode {G : PortGraph V D} {t : Nat} {v : V} | |
| (S : AddressSelector G t v) (ℓ : Ball G t v → A) : | |
| decode S (encode G t v ℓ) = ℓ := by | |
| funext u | |
| change ℓ (wordToBall G t v (S.address u)) = ℓ u | |
| rw [S.correct] | |
| theorem decode_surjective {G : PortGraph V D} {t : Nat} {v : V} | |
| (S : AddressSelector G t v) : Function.Surjective (decode (A := A) S) := | |
| fun ℓ => ⟨encode G t v ℓ, decode_encode S ℓ⟩ | |
| theorem encode_injective (G : PortGraph V D) (t : Nat) (v : V) : | |
| Function.Injective (encode (A := A) G t v) := by | |
| intro a b h | |
| funext u | |
| obtain ⟨w, rfl⟩ := wordToBall_surjective G t v u | |
| exact congrFun h w | |
| theorem decoded_word_collision {G : PortGraph V D} {t : Nat} {v : V} | |
| (S : AddressSelector G t v) (a : PaddedLabel D t A) (w z : PortWords D t) | |
| (h : (wordToBall G t v w).val = (wordToBall G t v z).val) : | |
| decode S a (wordToBall G t v w) = decode S a (wordToBall G t v z) := | |
| congrArg (decode S a) (Subtype.ext h) | |
| theorem card_paddedLabel [Finite D] [Finite A] (t : Nat) : | |
| Nat.card (PaddedLabel D t A) = | |
| Nat.card A ^ (∑ n : Fin (t + 1), Nat.card D ^ n.val) := by | |
| rw [Nat.card_fun, card_portWords] | |
| end MinUncutGames.Foundations.PCP.PoweringLabels | |
| end | |
| section | |
| namespace MinUncutGames.Foundations.PCP.PoweringAddresses | |
| open PoweringWalks PoweringLabels | |
| open scoped BigOperators | |
| variable {V : Type*} | |
| def allWords (d : Nat) : (n : Nat) → List (Fin n → Fin d) | |
| | 0 => [Fin.elim0] | |
| | n + 1 => (List.finRange d).flatMap fun a => | |
| (allWords d n).map fun p => Fin.cases a p | |
| theorem mem_allWords (d : Nat) : | |
| ∀ n (p : Fin n → Fin d), p ∈ allWords d n := by | |
| intro n | |
| induction n with | |
| | zero => | |
| intro p | |
| simp only [allWords, List.mem_singleton] | |
| funext i | |
| exact Fin.elim0 i | |
| | succ n ih => | |
| intro p | |
| simp only [allWords, List.mem_flatMap, List.mem_map] | |
| refine ⟨p 0, List.mem_finRange (p 0), (fun j => p j.succ), ih _, ?_⟩ | |
| funext j | |
| exact Fin.cases rfl (fun _ => rfl) j | |
| def allAddresses (d t : Nat) : List (PortWords (Fin d) t) := | |
| (List.finRange (t + 1)).flatMap fun n => | |
| (allWords d n.val).map fun p => Sigma.mk n p | |
| theorem mem_allAddresses (d t : Nat) (w : PortWords (Fin d) t) : | |
| w ∈ allAddresses d t := by | |
| rcases w with ⟨n, p⟩ | |
| unfold allAddresses | |
| apply List.mem_flatMap.mpr | |
| refine ⟨n, List.mem_finRange n, ?_⟩ | |
| exact List.mem_map.mpr ⟨p, mem_allWords d n.val p, rfl⟩ | |
| theorem length_allWords (d : Nat) : | |
| ∀ n, (allWords d n).length = d ^ n := by | |
| intro n | |
| induction n with | |
| | zero => rfl | |
| | succ n ih => | |
| simp only [allWords, List.length_flatMap, List.length_map, ih, List.map_const', List.length_finRange, List.sum_replicate_nat] | |
| exact (Nat.mul_comm d (d ^ n)).trans (Nat.pow_succ d n).symm | |
| theorem length_allAddresses (d t : Nat) : | |
| (allAddresses d t).length = ∑ n : Fin (t + 1), d ^ n.val := by | |
| unfold allAddresses | |
| simp only [List.length_flatMap, List.length_map, length_allWords] | |
| exact (Fin.sum_univ_def (fun n : Fin (t + 1) => d ^ n.val)).symm | |
| def finitePortSelector {d : Nat} [DecidableEq V] (G : PortGraph V (Fin d)) | |
| (t : Nat) (v : V) : AddressSelector G t v := | |
| listSelector G t v (allAddresses d t) (mem_allAddresses d t) | |
| end MinUncutGames.Foundations.PCP.PoweringAddresses | |
| end | |
| section | |
| namespace MinUncutGames.Foundations.PCP.PoweringEnumeration | |
| open PoweringLabels | |
| open scoped BigOperators | |
| def addressCount (d t : Nat) : Nat := ∑ i : Fin (t + 1), d ^ i.val | |
| def reverseWordEquiv (d n : Nat) : (Fin n → Fin d) ≃ (Fin n → Fin d) where | |
| toFun p i := p i.rev | |
| invFun p i := p i.rev | |
| left_inv p := by funext i; simp only [Fin.rev_rev] | |
| right_inv p := by funext i; simp only [Fin.rev_rev] | |
| def wordEquiv (d n : Nat) : (Fin n → Fin d) ≃ Fin (d ^ n) := | |
| (reverseWordEquiv d n).trans finFunctionFinEquiv | |
| theorem wordEquiv_val (d n : Nat) (p : Fin n → Fin d) : | |
| (wordEquiv d n p).val = ∑ i : Fin n, (p i.rev).val * d ^ i.val := rfl | |
| def addressEquiv (d t : Nat) : PortWords (Fin d) t ≃ Fin (addressCount d t) := | |
| (Equiv.sigmaCongrRight (fun i : Fin (t + 1) => wordEquiv d i.val)).trans | |
| finSigmaFinEquiv | |
| theorem addressEquiv_val (d t : Nat) (w : PortWords (Fin d) t) : | |
| (addressEquiv d t w).val = | |
| (∑ i : Fin w.1.val, d ^ i.val) + (wordEquiv d w.1.val w.2).val := by | |
| change (finSigmaFinEquiv | |
| (⟨w.1, wordEquiv d w.1.val w.2⟩ : (i : Fin (t + 1)) × Fin (d ^ i.val))).val = _ | |
| rw [finSigmaFinEquiv_apply] | |
| rfl | |
| def paddedLabelEquiv (d t q : Nat) : | |
| PaddedLabel (Fin d) t (Fin q) ≃ Fin (q ^ addressCount d t) := | |
| ((addressEquiv d t).arrowCongr (Equiv.refl (Fin q))).trans | |
| (wordEquiv q (addressCount d t)) | |
| theorem paddedLabelEquiv_val (d t q : Nat) (a : PaddedLabel (Fin d) t (Fin q)) : | |
| (paddedLabelEquiv d t q a).val = | |
| ∑ i : Fin (addressCount d t), | |
| (a ((addressEquiv d t).symm i.rev)).val * q ^ i.val := rfl | |
| def orientationEquiv : Bool ≃ Fin 2 := finTwoEquiv.symm | |
| @[simp] theorem orientationEquiv_false : orientationEquiv false = 0 := rfl | |
| @[simp] theorem orientationEquiv_true : orientationEquiv true = 1 := rfl | |
| def dartBlockEquiv (d n : Nat) : | |
| ((Fin (n + 1) → Fin d) × Bool) ≃ Fin (2 * d ^ (n + 1)) := | |
| ((wordEquiv d (n + 1)).prodCongr orientationEquiv).trans | |
| (finProdFinEquiv.trans (finCongr (Nat.mul_comm (d ^ (n + 1)) 2))) | |
| theorem dartBlockEquiv_val (d n : Nat) (p : Fin (n + 1) → Fin d) (b : Bool) : | |
| (dartBlockEquiv d n (p, b)).val = | |
| 2 * (wordEquiv d (n + 1) p).val + (orientationEquiv b).val := by | |
| change (orientationEquiv b).val + 2 * (wordEquiv d (n + 1) p).val = _ | |
| exact Nat.add_comm _ _ | |
| def dartVertexEquiv (vertices d n : Nat) : | |
| (Bool × (Fin vertices × (Fin (n + 1) → Fin d))) ≃ | |
| (Fin vertices × ((Fin (n + 1) → Fin d) × Bool)) where | |
| toFun x := (x.2.1, (x.2.2, x.1)) | |
| invFun x := (x.2.2, (x.1, x.2.1)) | |
| left_inv x := by rcases x with ⟨b, v, p⟩; rfl | |
| right_inv x := by rcases x with ⟨v, p, b⟩; rfl | |
| def dartEquiv (vertices d n : Nat) : | |
| (Bool × (Fin vertices × (Fin (n + 1) → Fin d))) ≃ | |
| Fin (2 * vertices * d ^ (n + 1)) := | |
| (dartVertexEquiv vertices d n).trans | |
| (((Equiv.refl (Fin vertices)).prodCongr (dartBlockEquiv d n)).trans | |
| (finProdFinEquiv.trans | |
| (finCongr (show vertices * (2 * d ^ (n + 1)) = | |
| 2 * vertices * d ^ (n + 1) by ac_rfl)))) | |
| theorem dartEquiv_val (vertices d n : Nat) (b : Bool) (v : Fin vertices) | |
| (p : Fin (n + 1) → Fin d) : | |
| (dartEquiv vertices d n (b, (v, p))).val = | |
| (2 * d ^ (n + 1)) * v.val + | |
| 2 * (wordEquiv d (n + 1) p).val + (orientationEquiv b).val := by | |
| change (dartBlockEquiv d n (p, b)).val + (2 * d ^ (n + 1)) * v.val = _ | |
| rw [dartBlockEquiv_val] | |
| omega | |
| theorem dartEquiv_true_eq_false_add_one (vertices d n : Nat) (v : Fin vertices) | |
| (p : Fin (n + 1) → Fin d) : | |
| (dartEquiv vertices d n (true, (v, p))).val = | |
| (dartEquiv vertices d n (false, (v, p))).val + 1 := by | |
| rw [dartEquiv_val, dartEquiv_val, orientationEquiv_true, orientationEquiv_false] | |
| rfl | |
| def encodeWord (d n : Nat) : (Fin n → Fin d) → Fin (d ^ n) := wordEquiv d n | |
| def decodeWord (d n : Nat) : Fin (d ^ n) → (Fin n → Fin d) := (wordEquiv d n).symm | |
| @[simp] theorem decodeWord_encodeWord (d n : Nat) (p : Fin n → Fin d) : | |
| decodeWord d n (encodeWord d n p) = p := (wordEquiv d n).symm_apply_apply p | |
| @[simp] theorem encodeWord_decodeWord (d n : Nat) (i : Fin (d ^ n)) : | |
| encodeWord d n (decodeWord d n i) = i := (wordEquiv d n).apply_symm_apply i | |
| def encodeAddress (d t : Nat) : PortWords (Fin d) t → Fin (addressCount d t) := | |
| addressEquiv d t | |
| def decodeAddress (d t : Nat) : Fin (addressCount d t) → PortWords (Fin d) t := | |
| (addressEquiv d t).symm | |
| @[simp] theorem decodeAddress_encodeAddress (d t : Nat) (w : PortWords (Fin d) t) : | |
| decodeAddress d t (encodeAddress d t w) = w := (addressEquiv d t).symm_apply_apply w | |
| @[simp] theorem encodeAddress_decodeAddress (d t : Nat) (i : Fin (addressCount d t)) : | |
| encodeAddress d t (decodeAddress d t i) = i := (addressEquiv d t).apply_symm_apply i | |
| def encodeLabel (d t q : Nat) : | |
| PaddedLabel (Fin d) t (Fin q) → Fin (q ^ addressCount d t) := paddedLabelEquiv d t q | |
| def decodeLabel (d t q : Nat) : | |
| Fin (q ^ addressCount d t) → PaddedLabel (Fin d) t (Fin q) := | |
| (paddedLabelEquiv d t q).symm | |
| @[simp] theorem decodeLabel_encodeLabel (d t q : Nat) (a : PaddedLabel (Fin d) t (Fin q)) : | |
| decodeLabel d t q (encodeLabel d t q a) = a := (paddedLabelEquiv d t q).symm_apply_apply a | |
| @[simp] theorem encodeLabel_decodeLabel (d t q : Nat) (i : Fin (q ^ addressCount d t)) : | |
| encodeLabel d t q (decodeLabel d t q i) = i := (paddedLabelEquiv d t q).apply_symm_apply i | |
| @[simp] theorem decodeLabel_apply (d t q : Nat) (i : Fin (q ^ addressCount d t)) | |
| (w : PortWords (Fin d) t) : | |
| decodeLabel d t q i w = decodeWord q (addressCount d t) i (encodeAddress d t w) := rfl | |
| def encodeDart (vertices d n : Nat) : | |
| (Bool × (Fin vertices × (Fin (n + 1) → Fin d))) → | |
| Fin (2 * vertices * d ^ (n + 1)) := dartEquiv vertices d n | |
| def decodeDart (vertices d n : Nat) : | |
| Fin (2 * vertices * d ^ (n + 1)) → | |
| (Bool × (Fin vertices × (Fin (n + 1) → Fin d))) := (dartEquiv vertices d n).symm | |
| @[simp] theorem decodeDart_encodeDart (vertices d n : Nat) | |
| (e : Bool × (Fin vertices × (Fin (n + 1) → Fin d))) : | |
| decodeDart vertices d n (encodeDart vertices d n e) = e := | |
| (dartEquiv vertices d n).symm_apply_apply e | |
| @[simp] theorem encodeDart_decodeDart (vertices d n : Nat) | |
| (i : Fin (2 * vertices * d ^ (n + 1))) : | |
| encodeDart vertices d n (decodeDart vertices d n i) = i := | |
| (dartEquiv vertices d n).apply_symm_apply i | |
| theorem card_words (d n : Nat) : Nat.card (Fin n → Fin d) = d ^ n := by | |
| simpa only [Nat.card_fin] using Nat.card_congr (wordEquiv d n) | |
| theorem card_addresses (d t : Nat) : | |
| Nat.card (PortWords (Fin d) t) = addressCount d t := by | |
| simpa only [Nat.card_fin] using Nat.card_congr (addressEquiv d t) | |
| theorem card_labels (d t q : Nat) : | |
| Nat.card (PaddedLabel (Fin d) t (Fin q)) = q ^ addressCount d t := by | |
| simpa only [Nat.card_fin] using Nat.card_congr (paddedLabelEquiv d t q) | |
| theorem card_darts (vertices d n : Nat) : | |
| Nat.card (Bool × (Fin vertices × (Fin (n + 1) → Fin d))) = | |
| 2 * vertices * d ^ (n + 1) := by | |
| simpa only [Nat.card_fin] using Nat.card_congr (dartEquiv vertices d n) | |
| theorem length_allAddresses (d t : Nat) : | |
| (PoweringAddresses.allAddresses d t).length = addressCount d t := | |
| PoweringAddresses.length_allAddresses d t | |
| end MinUncutGames.Foundations.PCP.PoweringEnumeration | |
| end | |
| section | |
| namespace MinUncutGames.Foundations.PCP.PoweringDecoding | |
| open scoped BigOperators | |
| variable {Ω A : Type*} [Fintype Ω] [Nonempty Ω] [Fintype A] [Nonempty A] | |
| noncomputable def mass (opinion : Ω → A) (a : A) : ℝ := by | |
| classical | |
| exact Finset.univ.expect (fun ω => if opinion ω = a then 1 else 0) | |
| omit [Nonempty A] in | |
| theorem mass_sum (opinion : Ω → A) : (∑ a, mass opinion a) = 1 := by | |
| classical | |
| calc | |
| (∑ a, mass opinion a) = | |
| (Finset.univ : Finset Ω).expect | |
| (fun ω => ∑ a : A, if opinion ω = a then (1 : ℝ) else 0) := | |
| (Finset.expect_sum_comm (Finset.univ : Finset Ω) (Finset.univ : Finset A) | |
| (fun ω a => if opinion ω = a then (1 : ℝ) else 0)).symm | |
| _ = (Finset.univ : Finset Ω).expect (fun _ => (1 : ℝ)) := by | |
| apply Finset.expect_congr rfl | |
| intro ω _ | |
| simp | |
| _ = 1 := Finset.expect_const Finset.univ_nonempty 1 | |
| omit [Nonempty Ω] in | |
| theorem exists_mode (opinion : Ω → A) : | |
| ∃ a : A, ∀ b : A, mass opinion b ≤ mass opinion a := by | |
| obtain ⟨a, _, ha⟩ := Finset.exists_max_image (Finset.univ : Finset A) | |
| (mass opinion) Finset.univ_nonempty | |
| exact ⟨a, fun b => ha b (Finset.mem_univ b)⟩ | |
| noncomputable def mode (opinion : Ω → A) : A := Classical.choose (exists_mode opinion) | |
| omit [Nonempty Ω] in | |
| theorem mode_max (opinion : Ω → A) (b : A) : | |
| mass opinion b ≤ mass opinion (mode opinion) := | |
| Classical.choose_spec (exists_mode opinion) b | |
| theorem mode_mass_lower (opinion : Ω → A) : | |
| 1 / (Fintype.card A : ℝ) ≤ mass opinion (mode opinion) := by | |
| have hk : 0 < (Fintype.card A : ℝ) := Nat.cast_pos.mpr Fintype.card_pos | |
| have hsum : (1 : ℝ) ≤ mass opinion (mode opinion) * (Fintype.card A : ℝ) := by | |
| calc | |
| (1 : ℝ) = ∑ a : A, mass opinion a := (mass_sum opinion).symm | |
| _ ≤ ∑ _a : A, mass opinion (mode opinion) := | |
| Finset.sum_le_sum (fun a _ => mode_max opinion a) | |
| _ = mass opinion (mode opinion) * (Fintype.card A : ℝ) := by simp [mul_comm] | |
| exact (div_le_iff₀ hk).2 hsum | |
| theorem exists_letter_mass_lower (opinion : Ω → A) : | |
| ∃ a : A, 1 / (Fintype.card A : ℝ) ≤ mass opinion a := | |
| ⟨mode opinion, mode_mass_lower opinion⟩ | |
| end MinUncutGames.Foundations.PCP.PoweringDecoding | |
| end | |
| section | |
| noncomputable section | |
| namespace MinUncutGames.Foundations.PCP.PoweringMoment | |
| open scoped BigOperators | |
| def bit (p : Prop) : ℝ := by | |
| classical | |
| exact if p then 1 else 0 | |
| def hits {I Ω : Type*} [Fintype I] (E : I → Ω → Prop) (ω : Ω) : ℝ := | |
| ∑ i, bit (E i ω) | |
| def mean {Ω : Type*} [Fintype Ω] (f : Ω → ℝ) : ℝ := Finset.univ.expect f | |
| theorem bit_nonneg (p : Prop) : 0 ≤ bit p := by | |
| classical | |
| by_cases hp : p <;> simp [bit, hp] | |
| theorem bit_sq (p : Prop) : bit p ^ 2 = bit p := by | |
| classical | |
| by_cases hp : p <;> simp [bit, hp] | |
| theorem bit_mul (p q : Prop) : bit p * bit q = bit (p ∧ q) := by | |
| classical | |
| by_cases hp : p <;> by_cases hq : q <;> simp [bit, hp, hq] | |
| theorem bit_mono {p q : Prop} (hpq : p → q) : bit p ≤ bit q := by | |
| classical | |
| by_cases hp : p | |
| · simp [bit, hp, hpq hp] | |
| · have hz : bit p = 0 := by simp [bit, hp] | |
| rw [hz] | |
| exact bit_nonneg q | |
| theorem hits_nonneg {I Ω : Type*} [Fintype I] (E : I → Ω → Prop) (ω : Ω) : | |
| 0 ≤ hits E ω := Finset.sum_nonneg (fun i _ => bit_nonneg (E i ω)) | |
| theorem mean_nonneg {Ω : Type*} [Fintype Ω] (f : Ω → ℝ) (hf : ∀ ω, 0 ≤ f ω) : | |
| 0 ≤ mean f := Finset.expect_nonneg (fun ω _ => hf ω) | |
| theorem mean_hits {I Ω : Type*} [Fintype I] [Fintype Ω] (E : I → Ω → Prop) : | |
| mean (hits E) = ∑ i, mean (fun ω => bit (E i ω)) := by | |
| exact Finset.expect_sum_comm _ _ _ | |
| theorem second_moment_eq {I Ω : Type*} [Fintype I] [Fintype Ω] | |
| (E : I → Ω → Prop) : | |
| mean (fun ω => hits E ω ^ 2) = | |
| ∑ i, ∑ j, mean (fun ω => bit (E i ω ∧ E j ω)) := by | |
| simp only [hits, pow_two, Finset.sum_mul, Finset.mul_sum, bit_mul, | |
| mean, Finset.expect_sum_comm] | |
| exact Finset.sum_comm | |
| theorem mean_witness_sq_le {I Ω : Type*} [Fintype I] [Fintype Ω] | |
| (E W : I → Ω → Prop) (reject : Ω → Prop) | |
| (hWE : ∀ i ω, W i ω → E i ω) | |
| (hWR : ∀ i ω, W i ω → reject ω) : | |
| mean (hits W) ^ 2 ≤ | |
| mean (fun ω => bit (reject ω)) * mean (fun ω => hits E ω ^ 2) := by | |
| classical | |
| have hNH (ω : Ω) : hits W ω ≤ hits E ω := | |
| Finset.sum_le_sum (fun i _ => bit_mono (hWE i ω)) | |
| have hzero (ω : Ω) (hr : ¬ reject ω) : hits W ω = 0 := by | |
| apply Finset.sum_eq_zero | |
| intro i _ | |
| have hw : ¬ W i ω := fun h => hr (hWR i ω h) | |
| simp [bit, hw] | |
| have hsupport (ω : Ω) : bit (reject ω) * hits W ω = hits W ω := by | |
| by_cases hr : reject ω | |
| · simp [bit, hr] | |
| · rw [hzero ω hr] | |
| simp | |
| have hCS := Finset.expect_mul_sq_le_sq_mul_sq Finset.univ | |
| (fun ω => bit (reject ω)) (hits W) | |
| have hsquares : mean (fun ω => hits W ω ^ 2) ≤ mean (fun ω => hits E ω ^ 2) := by | |
| apply Finset.expect_le_expect | |
| intro ω _ | |
| simpa only [pow_two] using | |
| (mul_le_mul (hNH ω) (hNH ω) (hits_nonneg W ω) (hits_nonneg E ω)) | |
| calc | |
| _ ≤ mean (fun ω => bit (reject ω)) * mean (fun ω => hits W ω ^ 2) := by | |
| simpa only [mean, hsupport, bit_sq] using hCS | |
| _ ≤ _ := mul_le_mul_of_nonneg_left hsquares | |
| (mean_nonneg _ (fun ω => bit_nonneg (reject ω))) | |
| theorem rejection_lower_bound {I Ω : Type*} [Fintype I] [Fintype Ω] | |
| (E W : I → Ω → Prop) (reject : Ω → Prop) | |
| (hWE : ∀ i ω, W i ω → E i ω) | |
| (hWR : ∀ i ω, W i ω → reject ω) | |
| (a b : ℝ) (ha : 0 < a) (hb : 0 < b) | |
| (hfirst : a ≤ mean (hits W)) | |
| (hsecond : mean (fun ω => hits E ω ^ 2) ≤ b) : | |
| a ^ 2 / b ≤ mean (fun ω => bit (reject ω)) := by | |
| have hN : 0 ≤ mean (hits W) := mean_nonneg _ (hits_nonneg W) | |
| have hρ : 0 ≤ mean (fun ω => bit (reject ω)) := | |
| mean_nonneg _ (fun ω => bit_nonneg (reject ω)) | |
| have haSq : a ^ 2 ≤ mean (hits W) ^ 2 := by | |
| simpa only [pow_two] using mul_le_mul hfirst hfirst ha.le hN | |
| have hCS := mean_witness_sq_le E W reject hWE hWR | |
| apply (div_le_iff₀ hb).2 | |
| exact haSq.trans (hCS.trans (mul_le_mul_of_nonneg_left hsecond hρ)) | |
| end MinUncutGames.Foundations.PCP.PoweringMoment | |
| end | |
| end | |
| end OAI | |
Xet Storage Details
- Size:
- 30.9 kB
- Xet hash:
- fc5dc227a6e2f75366366165b2f809d8824088d1c6556776908eca8fc0ec9f5c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.