Download data/lean/OAI/Computability/LoopMatching/Model.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 2.74 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/LoopMatching/Model.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/LoopMatching/Model.lean
-
curl -L -o Model.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/LoopMatching/Model.lean
2.74 kB
| import OAI.Combinatorics.PerfectMatching.Model | |
| namespace OAI | |
| /-! Polynomial-time approximation of weighted matchings with singleton loops. -/ | |
| open scoped BigOperators | |
| namespace LoopMatching | |
| structure LoopRecord where | |
| vertex : β | |
| multiplicity : β | |
| deriving DecidableEq | |
| structure Input where | |
| ordinary : BinaryMatching.Input | |
| loops : List LoopRecord | |
| valid : β e β loops, e.vertex < ordinary.n | |
| unique : (loops.map LoopRecord.vertex).Nodup | |
| abbrev Input.n (G : Input) : β := G.ordinary.n | |
| def loopMultiplicity (G : Input) (v : Fin G.n) : β := | |
| match G.loops.find? (fun r => r.vertex == v.val) with | |
| | none => 0 | |
| | some r => r.multiplicity | |
| def IsPartialMatching (n : β) (M : Finset (BinaryMatching.Pair n)) : Prop := | |
| β v : Fin n, β e β M, β f β M, | |
| (BinaryMatching.completeGraph n).Incident v e β | |
| (BinaryMatching.completeGraph n).Incident v f β e = f | |
| abbrev PartialMatching (n : β) := | |
| { M : Finset (BinaryMatching.Pair n) // IsPartialMatching n M } | |
| noncomputable instance partialMatchingFintype (n : β) : Fintype (PartialMatching n) := | |
| Fintype.ofFinite _ | |
| noncomputable def loopVertices {n : β} (M : PartialMatching n) : Finset (Fin n) := by | |
| classical | |
| exact Finset.univ.filter (fun v => | |
| β e β M.val, Β¬ (BinaryMatching.completeGraph n).Incident v e) | |
| noncomputable def weight (G : Input) (M : PartialMatching G.n) : β := | |
| (β e β M.val, BinaryMatching.multiplicity G.ordinary e) * | |
| β v β loopVertices M, loopMultiplicity G v | |
| noncomputable def count (G : Input) : β := β M : PartialMatching G.n, weight G M | |
| noncomputable def countWithLoops (G : Input) (j : β) : β := by | |
| classical | |
| exact β M : PartialMatching G.n, | |
| if (loopVertices M).card = j then weight G M else 0 | |
| def encodeLoopRecord (r : LoopRecord) : List Bool := | |
| BinaryMatching.encodeNat r.vertex ++ BinaryMatching.encodeNat r.multiplicity | |
| def encodeInput (G : Input) : List Bool := | |
| BinaryMatching.encodeInput G.ordinary ++ | |
| BinaryMatching.encodeNat G.loops.length ++ G.loops.flatMap encodeLoopRecord | |
| def encodeOutput (a : β Γ β) : List Bool := | |
| BinaryMatching.encodeNat a.1 ++ BinaryMatching.encodeNat a.2 | |
| def outputValue (a : β Γ β) : β := (a.1 : β) / a.2 | |
| def FullEndpoint : Prop := | |
| β A : Input β β Γ β, | |
| β machine : Turing.TM2ComputableInPolyTime encodeInput encodeOutput A, | |
| (β k, Finite (machine.tm.Ξ k)) β§ | |
| (β P : Polynomial β, β G, | |
| (encodeOutput (A G)).length β€ P.eval (encodeInput G).length) β§ | |
| β G, 0 < (A G).2 β§ | |
| (A G).1 β€ (A G).2 * count G β§ | |
| (A G).2 * count G β€ 2 ^ (18 * G.n) * (A G).1 β§ | |
| ((A G).1 = 0 β count G = 0) | |
| end LoopMatching | |
| end OAI | |