Download data/lean/OAI/Combinatorics/BalancedRyser/Local/Local.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.86 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/BalancedRyser/Local/Local.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/BalancedRyser/Local/Local.lean
-
curl -L -o Local.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/BalancedRyser/Local/Local.lean
8.86 kB
| import Mathlib.Analysis.SpecialFunctions.Log.Basic | |
| import Mathlib.Data.Fintype.Powerset | |
| import Mathlib.Data.Nat.Cast.Order.Field | |
| import Mathlib.Order.Filter.AtTopBot.Basic | |
| import OAI.Combinatorics.BalancedRyser.Construction.Construction | |
| namespace OAI | |
| namespace Balanced.Local | |
| open scoped BigOperators | |
| open Filter | |
| universe u | |
| noncomputable section | |
| attribute [local instance] Classical.propDecidable | |
| abbrev TupleCode (F : Type u) := (Fin 4 β Direction F) Γ (Fin 4 β Bool) | |
| abbrev ChoiceCode (F : Type u) := Line F Γ TupleCode F | |
| abbrev Output (F : Type u) := Slot F β ChoiceCode F | |
| def decodeTuple {F : Type u} (t : TupleCode F) : FourTuple F := β¨t.1, t.2β© | |
| def decodeChoice {F : Type u} (c : ChoiceCode F) : SplitChoice F := | |
| β¨c.1, decodeTuple c.2β© | |
| def configuration {F : Type u} (M : MergedPairs F) (v : Output F) : Configuration F := | |
| β¨M, fun s => decodeChoice (v s)β© | |
| variable {F : Type u} [Field F] [Fintype F] [DecidableEq F] | |
| def constituentMultiplicity (M : MergedPairs F) (p : Point F) : β := | |
| (Finset.univ.filter (fun ds : Direction F Γ Bool => | |
| OnLine p (constituent M ds.1 ds.2))).card | |
| def logBudget (F : Type u) [Fintype F] : β := Nat.ceil (Real.log (Fintype.card F)) | |
| def offsetProbability (E : MergedPairs F β Prop) : β := | |
| (β M : MergedPairs F, if E M then (1 : β) else 0) / | |
| Fintype.card (MergedPairs F) | |
| def conditionedOffsetProbability (A E : MergedPairs F β Prop) : β := | |
| offsetProbability (fun M => A M β§ E M) / offsetProbability A | |
| structure RetentionRule (F : Type u) [Field F] [Fintype F] [DecidableEq F] where | |
| candidates : MergedPairs F β Direction F β Finset (ChoiceCode F) | |
| valid : β M g c, c β candidates M g β ValidChoice M g (decodeChoice c) | |
| uniqueLine : β M g c d, c β candidates M g β d β candidates M g β | |
| c.1 = d.1 β c = d | |
| complete : β M g c, ValidChoice M g (decodeChoice c) β | |
| β d β candidates M g, d.1 = c.1 | |
| abbrev Kernel (F : Type u) := MergedPairs F β Output F β β | |
| def KernelConditions (Q : RetentionRule F) (w : Kernel F) (K : β) : Prop := | |
| (β M v, 0 β€ w M v) β§ | |
| (β M, β v, w M v β€ 1) β§ | |
| (β M v, 0 < w M v β | |
| (configuration M v).Valid β§ (configuration M v).Compatible β§ | |
| (β s, v s β Q.candidates M s.1) β§ | |
| (β p, constituentMultiplicity M p β€ logBudget F)) β§ | |
| (β M (S : Finset (Slot F)) (t : Slot F β TupleCode F), | |
| (β v, if (β s β S, (v s).2 = t s) then w M v else 0) β€ | |
| (K / Fintype.card F) ^ S.card) | |
| def selectedProbability (w : Kernel F) (E : Configuration F β Prop) : β := | |
| (β M : MergedPairs F, β v : Output F, | |
| if E (configuration M v) then w M v else 0) / | |
| Fintype.card (MergedPairs F) | |
| def generatorUnionAt (C : Configuration F) (p : Point F) : Finset (Direction F) := | |
| (Finset.univ.filter (fun s => OnLine p (C.choice s).line)).biUnion | |
| (fun s => generatorSet (C.choice s).tuple) | |
| def reuseCount (C : Configuration F) (p : Point F) : β := | |
| 4 * C.splitMultiplicity p - (generatorUnionAt C p).card | |
| structure EqualityPattern (b ΞΊ : β) where | |
| classOf : Fin b β Fin 4 β Fin (4 * b - ΞΊ) | |
| everyClass : Function.Surjective (fun ij : Fin b Γ Fin 4 => classOf ij.1 ij.2) | |
| withinTuple : β i, Function.Injective (classOf i) | |
| pairOverlap : β i j, i β j β | |
| ((Finset.univ.image (classOf i)) β© (Finset.univ.image (classOf j))).card β€ 1 | |
| abbrev DirectionAssignment (F : Type u) (b ΞΊ : β) := | |
| (Fin b β Direction F) Γ (Fin (4 * b - ΞΊ) β Direction F) | |
| abbrev Bits (b : β) := Fin b β Fin 4 β Bool | |
| def Eligible {b ΞΊ : β} (P : EqualityPattern b ΞΊ) | |
| (a : DirectionAssignment F b ΞΊ) : Prop := | |
| Function.Injective a.1 β§ Function.Injective a.2 β§ | |
| β i j, a.2 (P.classOf i j) β a.1 i | |
| def prescribedTuple {b ΞΊ : β} (P : EqualityPattern b ΞΊ) | |
| (a : DirectionAssignment F b ΞΊ) (bits : Bits b) (i : Fin b) : FourTuple F := | |
| β¨fun j => a.2 (P.classOf i j), bits iβ© | |
| def prescribedPoint {b ΞΊ : β} (P : EqualityPattern b ΞΊ) | |
| (a : DirectionAssignment F b ΞΊ) (bits : Bits b) | |
| (M : MergedPairs F) (ij : Fin b Γ Fin 4) : Point F := | |
| tuplePoint M (prescribedTuple P a bits ij.1) ij.2 | |
| def Aligned {b ΞΊ : β} (P : EqualityPattern b ΞΊ) | |
| (a : DirectionAssignment F b ΞΊ) (bits : Bits b) (p : Point F) | |
| (M : MergedPairs F) : Prop := | |
| β ij, OnLine (prescribedPoint P a bits M ij) (lineThrough (a.1 ij.1) p) | |
| def Admissible {b ΞΊ : β} (P : EqualityPattern b ΞΊ) | |
| (a : DirectionAssignment F b ΞΊ) (bits : Bits b) (p : Point F) | |
| (M : MergedPairs F) : Prop := | |
| Aligned P a bits p M β§ Function.Injective (prescribedPoint P a bits M) β§ | |
| (β ij, prescribedPoint P a bits M ij β p) β§ | |
| (β i, lineThrough (a.1 i) p β constituentLines M) β§ | |
| (β x, constituentMultiplicity M x β€ logBudget F) | |
| def prescribedDesignated {b ΞΊ : β} (P : EqualityPattern b ΞΊ) | |
| (a : DirectionAssignment F b ΞΊ) (bits : Bits b) (M : MergedPairs F) : | |
| Finset (Point F) := Finset.univ.image (prescribedPoint P a bits M) | |
| def prescribedPartners {b ΞΊ : β} (P : EqualityPattern b ΞΊ) | |
| (a : DirectionAssignment F b ΞΊ) (bits : Bits b) (p : Point F) | |
| (M : MergedPairs F) : Finset (Point F) := | |
| (prescribedDesignated P a bits M).filter (fun x => | |
| β ds : Direction F Γ Bool, OnLine p (constituent M ds.1 ds.2) β§ | |
| OnLine x (constituent M ds.1 (!ds.2))) | |
| def piecePoints (M : MergedPairs F) : LocalPiece F β Finset (Point F) | |
| | Sum.inl U => U | |
| | Sum.inr (Sum.inl l) => linePoints l | |
| | Sum.inr (Sum.inr d) => mergedPoints M d | |
| def AllowedPiece {b ΞΊ : β} (a : DirectionAssignment F b ΞΊ) (p : Point F) | |
| (M : MergedPairs F) : LocalPiece F β Prop | |
| | Sum.inl U => U.card β€ 2 | |
| | Sum.inr (Sum.inl l) => | |
| l β (Finset.univ.image (fun i => lineThrough (a.1 i) p)) βͺ constituentLines M | |
| | Sum.inr (Sum.inr _) => True | |
| def BadCover {b ΞΊ : β} (P : EqualityPattern b ΞΊ) | |
| (a : DirectionAssignment F b ΞΊ) (bits : Bits b) (p : Point F) | |
| (M : MergedPairs F) : Prop := | |
| β A : Finset (LocalPiece F), A.card β€ b - 1 β§ | |
| (β x β A, AllowedPiece a p M x) β§ | |
| prescribedDesignated P a bits M β | |
| prescribedPartners P a bits p M βͺ A.biUnion (piecePoints M) | |
| def AdmissibleBadCover {b ΞΊ : β} (P : EqualityPattern b ΞΊ) | |
| (a : DirectionAssignment F b ΞΊ) (bits : Bits b) (p : Point F) | |
| (M : MergedPairs F) : Prop := | |
| Admissible P a bits p M β§ BadCover P a bits p M | |
| def PencilLocalResult : Prop := | |
| β K : β, 0 < K β β Ξ΅ : β β β, | |
| Tendsto Ξ΅ atTop (nhds 0) β§ (β q, 0 β€ Ξ΅ q) β§ | |
| β qβ : β, β (F : Type u) [Field F] [Fintype F] [DecidableEq F], | |
| qβ β€ Fintype.card F β β (Q : RetentionRule F) (w : Kernel F), | |
| KernelConditions Q w K β | |
| selectedProbability w (fun C => Β¬ C.LocalCondition) β€ Ξ΅ (Fintype.card F) | |
| def PencilReuseResult : Prop := | |
| β K : β, 0 < K β β C : β, 0 < C β§ β qβ : β, | |
| β (F : Type u) [Field F] [Fintype F] [DecidableEq F], | |
| qβ β€ Fintype.card F β β (Q : RetentionRule F) (w : Kernel F), | |
| KernelConditions Q w K β β p : Point F, | |
| selectedProbability w (fun X => 2 β€ X.splitMultiplicity p β§ 3 β€ reuseCount X p) β€ | |
| C / (Fintype.card F : β) ^ 3 | |
| def AlignmentNormalizationResult : Prop := | |
| β (F : Type u) [Field F] [Fintype F] [DecidableEq F], | |
| β b ΞΊ : β, 3 β€ b β b β€ logBudget F β ΞΊ β€ 2 β | |
| β (P : EqualityPattern b ΞΊ) (a : DirectionAssignment F b ΞΊ), Eligible P a β | |
| β (bits : Bits b) (p : Point F), | |
| offsetProbability (Aligned P a bits p) = 1 / (Fintype.card F : β) ^ (4 * b) | |
| def PencilSmallReuseResult : Prop := | |
| AlignmentNormalizationResult.{u} β§ | |
| β C : β, 0 < C β§ β d qβ : β, | |
| β (F : Type u) [Field F] [Fintype F] [DecidableEq F], | |
| qβ β€ Fintype.card F β β b ΞΊ : β, 3 β€ b β b β€ logBudget F β ΞΊ β€ 1 β | |
| β (P : EqualityPattern b ΞΊ) (a : DirectionAssignment F b ΞΊ), Eligible P a β | |
| β (bits : Bits b) (p : Point F), | |
| conditionedOffsetProbability (Aligned P a bits p) (AdmissibleBadCover P a bits p) β€ | |
| C * (b : β) ^ d * (2 * (logBudget F : β) / Fintype.card F) ^ (3 - ΞΊ) | |
| def PencilTwoReusesResult : Prop := | |
| β C : β, 0 < C β§ β qβ : β, | |
| β (F : Type u) [Field F] [Fintype F] [DecidableEq F], | |
| qβ β€ Fintype.card F β β b : β, 3 β€ b β b β€ logBudget F β | |
| β (P : EqualityPattern b 2) (bits : Bits b) (p : Point F), | |
| (β a : DirectionAssignment F b 2, | |
| if Eligible P a then offsetProbability (fun M => | |
| Aligned P a bits p M β§ AdmissibleBadCover P a bits p M) else 0) β€ | |
| ((Fintype.card F + 1 : β) : β) ^ (5 * b - 2) / | |
| (Fintype.card F : β) ^ (4 * b) * (C * (b : β) ^ 3 / Fintype.card F) | |
| end | |
| end Balanced.Local | |
| end OAI | |