Download data/lean/OAI/Computability/BinPacking/Hardness/PCPPackingGap.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.37 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/BinPacking/Hardness/PCPPackingGap.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/BinPacking/Hardness/PCPPackingGap.lean
-
curl -L -o PCPPackingGap.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/BinPacking/Hardness/PCPPackingGap.lean
7.37 kB
| import Mathlib.Data.Rat.Cast.Order | |
| import Mathlib.Basic.Real.Basic | |
| import Mathlib.Tactic.Linarith | |
| import Mathlib.Tactic.NormNum | |
| import OAI.Computability.BinPacking.Configurations.K4Soundness | |
| import OAI.Computability.BinPacking.Configurations.ReductionCompleteness | |
| import OAI.Computability.BinPacking.Machines.GraphPackingOutput | |
| import OAI.Computability.BinPacking.PCP.PCPSourceHardness | |
| import OAI.Computability.BinPacking.Packing.LiteralSlotGap | |
| namespace OAI | |
| noncomputable section | |
| namespace BinPackingGap.PCPFoundation | |
| section | |
| open BinPackingGames.Foundations | |
| open Target | |
| open BinPackingCompleteness | |
| def gap : β := PCPSource.sourceGap | |
| def rho : β := (gap : β) / 6 | |
| theorem gap_pos : 0 < gap := PCPSource.sourceGap_pos | |
| theorem gap_cast_pos : (0 : β) < gap := by exact_mod_cast gap_pos | |
| theorem rho_pos : 0 < rho := div_pos gap_cast_pos (by norm_num) | |
| theorem rho_lt_gap_third : rho < (gap : β) / 3 := by | |
| unfold rho | |
| nlinarith [gap_cast_pos] | |
| def formula (F : Formula) : Formula := PCPSource.normalizedFormula F | |
| def graph (F : Formula) : GraphInput := LiteralSlotGraph.graph (formula F) | |
| def target (F : Formula) : β := 2 * (formula F).clauses.length | |
| theorem formula_nonempty (F : Formula) : (formula F).clauses β [] := | |
| PCPSource.normalizedFormula_nonempty F | |
| theorem clause_count_pos (F : Formula) : 0 < (formula F).clauses.length := | |
| List.length_pos_iff.mpr (formula_nonempty F) | |
| theorem edges_nonempty (F : Formula) : (graph F).edges β [] := | |
| LiteralSlotGraph.graph_edges_nonempty (formula F) (formula_nonempty F) | |
| theorem target_le_vertices (F : Formula) : target F β€ (graph F).n := by | |
| change 2 * (formula F).clauses.length β€ 3 * (formula F).clauses.length | |
| omega | |
| theorem cover_complete (F : Formula) (hF : F.Satisfiable) : | |
| (graph F).CoverAtMost (target F) := | |
| LiteralSlotGraph.coverAtMost_of_satisfiable (formula F) | |
| ((PCPSource.normalizedFormula_satisfiable_iff F).mpr hF) | |
| theorem failedCount_eq_card (F : Formula) (A : Fin F.variables β Bool) : | |
| PCP.NameCompaction.failedCount F A = (LiteralSlotGraph.failedClauses F A).card := by | |
| rw [PCPSource.failedCount_eq_fin_sum] | |
| simpa only [PCP.clauseAt, Fin.getElem_fin] using! (LiteralSlotGraph.failedClauses_card_sum F A).symm | |
| private theorem realGapOfRatGap (q : β) (m n : β) | |
| (h : q * (m : β) β€ (n : β)) : (q : β) * (m : β) β€ (n : β) := by | |
| exact_mod_cast h | |
| private theorem realCountBound (a b c : β) (h : a + b β€ c) : | |
| (a : β) + (b : β) β€ (c : β) := by | |
| exact_mod_cast h | |
| theorem normalized_failed_gap (F : Formula) (hF : Β¬ F.Satisfiable) | |
| (A : Fin (PCPSource.normalizedFormula F).variables β Bool) : | |
| PCPSource.sourceGap * ((PCPSource.normalizedFormula F).clauses.length : β) β€ | |
| ((LiteralSlotGraph.failedClauses (PCPSource.normalizedFormula F) A).card : β) := by | |
| have bound := PCPSource.clauseGap F hF A | |
| rw [PCPSource.violatedCount_eq_failedCount F A, failedCount_eq_card] at bound | |
| exact bound | |
| private theorem cover_bound_from_failed_gap (G : Formula) (q : β) | |
| (bound : β A : Fin G.variables β Bool, | |
| q * (G.clauses.length : β) β€ ((LiteralSlotGraph.failedClauses G A).card : β)) | |
| (C : Finset (LiteralSlotGraph.graph G).Vertex) | |
| (hC : (LiteralSlotGraph.graph G).IsCover C) : | |
| ((2 * G.clauses.length : β) : β) + (q : β) * (G.clauses.length : β) β€ | |
| (C.card : β) := by | |
| obtain β¨A, hAβ© := LiteralSlotGraph.assignment_count_of_cover G C hC | |
| have hgap := realGapOfRatGap q G.clauses.length _ (bound A) | |
| have hcount := realCountBound (2 * G.clauses.length) | |
| (LiteralSlotGraph.failedClauses G A).card C.card hA | |
| linarith only [hgap, hcount] | |
| theorem cover_sound (F : Formula) (hF : Β¬ F.Satisfiable) | |
| (C : Finset (graph F).Vertex) (hC : (graph F).IsCover C) : | |
| (target F : β) + (gap : β) * ((formula F).clauses.length : β) β€ (C.card : β) := | |
| cover_bound_from_failed_gap (formula F) gap (normalized_failed_gap F hF) C hC | |
| theorem no_small_cover (F : Formula) (hF : Β¬ F.Satisfiable) | |
| (C : Finset (graph F).Vertex) (hC : (graph F).IsCover C) : | |
| Β¬ (C.card : β) β€ (target F : β) + rho * ((graph F).n : β) := by | |
| intro hsmall | |
| have hlarge := cover_sound F hF C hC | |
| have hm : (0 : β) < (formula F).clauses.length := by | |
| exact_mod_cast clause_count_pos F | |
| have hn : ((graph F).n : β) = 3 * ((formula F).clauses.length : β) := by | |
| norm_num [graph, LiteralSlotGraph.graph_n] | |
| rw [hn] at hsmall | |
| unfold rho at hsmall | |
| nlinarith [mul_pos gap_cast_pos hm] | |
| theorem normalizedSource (language : List Bool β Prop) | |
| (membership : Complexity.CookLevin.InNP language) : | |
| β source : Complexity.CookLevin.PolynomialThreeSATReduction language, | |
| β runtime : Turing.TM2ComputableInPolyTime (id : List Bool β List Bool) | |
| Complexity.formulaBits (PCPSourceHardness.formula source), | |
| Complexity.MachineFiniteAlphabet.FiniteAlphabet runtime.tm β§ | |
| β input : List Bool, | |
| ((PCPSourceHardness.formula source input).Satisfiable β language input) β§ | |
| (PCPSourceHardness.formula source input).clauses β [] β§ | |
| (β (clause : Clause (PCPSourceHardness.formula source input).variables), | |
| clause β (PCPSourceHardness.formula source input).clauses β | |
| β i j : Fin 3, clause[i].variableIndex = clause[j].variableIndex β i = j) β§ | |
| (Β¬ language input β | |
| SourceAmplification.ClauseGap (PCPSource.clauseFamily (source.reduce input)) | |
| PCPSource.sourceGap) := | |
| PCPSourceHardness.normalizedSource language membership | |
| end | |
| open BinPackingGames.Foundations.Target | |
| def graphInput (F : Formula) : GraphReductionInput where | |
| graph := graph F | |
| k := target F | |
| k_le := target_le_vertices F | |
| nonempty := edges_nonempty F | |
| def packingOutput (c : Nat) (F : Formula) : RawReductionOutput := | |
| graphPackingOutput c rho (graphInput F) | |
| theorem packingOutput_valid (c : Nat) (F : Formula) : | |
| (packingOutput c F).2.Valid := | |
| graphPackingOutput_valid c rho (graphInput F) | |
| theorem packingOutput_count (c : Nat) (F : Formula) : | |
| (packingOutput c F).2.length = 5 * (packingOutput c F).1 := | |
| graphPackingOutput_length c rho (graphInput F) | |
| theorem packingOutput_size_lower (c : Nat) (F : Formula) | |
| (i : ((packingOutput c F).2.toInstance (packingOutput_valid c F)).Item) : | |
| (1 / 6 : β) < ((packingOutput c F).2.toInstance (packingOutput_valid c F)).size i := | |
| (graphPackingOutput_size_bounds c rho (graphInput F) i).1 | |
| theorem packingOutput_complete (c : Nat) (F : Formula) (hF : F.Satisfiable) : | |
| HasPacking ((packingOutput c F).2.toInstance (packingOutput_valid c F)) | |
| (packingOutput c F).1 := by | |
| apply (graphPackingOutput_hasPacking_iff c rho (graphInput F) _).mpr | |
| exact cover_hasPacking_reduction c rho (graph F) (target F) | |
| (target_le_vertices F) (cover_complete F hF) | |
| theorem packingOutput_sound (c : Nat) (F : Formula) (hF : Β¬ F.Satisfiable) : | |
| Β¬ HasPacking ((packingOutput c F).2.toInstance (packingOutput_valid c F)) | |
| ((packingOutput c F).1 + c) := by | |
| intro hp | |
| obtain β¨pβ© := (graphPackingOutput_hasPacking_iff c rho (graphInput F) _).mp hp | |
| obtain β¨C, hcover, hsmallβ© := packing_extracts_cover c rho rho_pos | |
| (graph F) (target F) (target_le_vertices F) p (Nat.le_refl _) | |
| exact no_small_cover F hF C hcover hsmall | |
| end BinPackingGap.PCPFoundation | |
| end | |
| end OAI | |