Download data/lean/OAI/Combinatorics/ContingencyTables/Dense/DenseGeometry.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.03 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/ContingencyTables/Dense/DenseGeometry.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/ContingencyTables/Dense/DenseGeometry.lean
-
curl -L -o DenseGeometry.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/ContingencyTables/Dense/DenseGeometry.lean
6.03 kB
| import OAI.Combinatorics.ContingencyTables.Dense.DenseRegularity | |
| import OAI.Combinatorics.ContingencyTables.Transport.RealCompletion | |
| namespace OAI | |
| /-! | |
| # Feasible region and interior point of the dense block | |
| These statements use the actual integer margins and quotient widths. Every | |
| feasible real completion lies in the declared scaled cube, and one scaled | |
| completion has normalized slack at least `1/(2d)` in every cell. | |
| -/ | |
| namespace ContingencyTables.DenseAffine | |
| open scoped BigOperators | |
| variable {I J : Type*} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J] | |
| def Feasible (R : Option I β β) (P : Option J β β) (d : β) | |
| (u : I Γ J β β) : Prop := | |
| β i j, 0 β€ table (fun i => (R i : β)) (fun j => (P j : β)) (denseWidth R P d) u i j | |
| omit [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J] in | |
| theorem denseWidth_pos (R : Option I β β) (P : Option J β β) (d : β) | |
| (hd : 14 β€ d) (hR : β i, d ^ 12 β€ R i) (hP : β j, d ^ 12 β€ P j) (i : I) (j : J) : | |
| 0 < denseWidth R P d i j := by | |
| unfold denseWidth | |
| exact_mod_cast dense_width_positive d (min (R (some i)) (P (some j))) hd | |
| (le_min (hR _) (hP _)) | |
| omit [DecidableEq I] [DecidableEq J] in | |
| private theorem table_entry_upper (R : Option I β β) (P : Option J β β) | |
| (w : I β J β β) (u : I Γ J β β) (htotal : β i, R i = β j, P j) | |
| (hfeas : β i j, 0 β€ table R P w u i j) (i : Option I) (j : Option J) : | |
| table R P w u i j β€ min (R i) (P j) := by | |
| apply le_min | |
| Β· have h := Finset.single_le_sum (fun k _ => hfeas i k) (Finset.mem_univ j) | |
| rwa [table_rows] at h | |
| Β· have h := Finset.single_le_sum (fun k _ => hfeas k j) (Finset.mem_univ i) | |
| rwa [table_columns _ _ _ _ htotal] at h | |
| omit [DecidableEq I] [DecidableEq J] in | |
| theorem feasible_in_cube (R : Option I β β) (P : Option J β β) (d : β) | |
| (hd : 14 β€ d) (hR : β i, d ^ 12 β€ R i) (hP : β j, d ^ 12 β€ P j) | |
| (htotal : β i, R i = β j, P j) (u : I Γ J β β) (hu : Feasible R P d u) : | |
| β p, 0 β€ u p β§ u p β€ 2 * (d : β) ^ 8 := by | |
| intro p | |
| have hw := denseWidth_pos R P d hd hR hP p.1 p.2 | |
| have hlo := hu (some p.1) (some p.2) | |
| have ht : (β i, (R i : β)) = β j, (P j : β) := by exact_mod_cast htotal | |
| have hhi := table_entry_upper (fun i => (R i : β)) (fun j => (P j : β)) | |
| (denseWidth R P d) u ht hu (some p.1) (some p.2) | |
| change denseWidth R P d p.1 p.2 * u p β€ min (R (some p.1) : β) (P (some p.2) : β) at hhi | |
| change 0 β€ denseWidth R P d p.1 p.2 * u p at hlo | |
| have hwidth := (dense_width_bounds d (min (R (some p.1)) (P (some p.2))) hd | |
| (le_min (hR _) (hP _))).1 | |
| have hdβ : (0 : β) < d := by exact_mod_cast (show 0 < d by omega) | |
| have hs : min (R (some p.1) : β) (P (some p.2) : β) β€ | |
| denseWidth R P d p.1 p.2 * (2 * (d : β) ^ 8) := by | |
| apply (div_le_iffβ (show (0 : β) < 2 * (d : β) ^ 8 by positivity)).mp | |
| simpa only [Nat.cast_min, denseWidth] using hwidth | |
| exact β¨nonneg_of_mul_nonneg_right hlo hw, le_of_mul_le_mul_left (hhi.trans hs) hwβ© | |
| omit [DecidableEq I] [DecidableEq J] in | |
| /-- Real residual completion constructs the strict interior point. -/ | |
| theorem dense_interior_exists (R : Option I β β) (P : Option J β β) (d : β) | |
| (hd : 14 β€ d) (hR : β i, d ^ 12 β€ R i) (hP : β j, d ^ 12 β€ P j) | |
| (hdimR : Fintype.card (Option I) β€ d) (hdimP : Fintype.card (Option J) β€ d) | |
| (htotal : β i, R i = β j, P j) : | |
| β u : I Γ J β β, Feasible R P d u β§ | |
| (β p, 0 β€ u p β§ u p β€ 2 * (d : β) ^ 8) β§ | |
| β g : Option I Γ Option J, | |
| 1 / (2 * (d : β)) β€ | |
| table (fun i => (R i : β)) (fun j => (P j : β)) (denseWidth R P d) u g.1 g.2 / | |
| cellScale (fun i => (R i : β)) (fun j => (P j : β)) g := by | |
| have hdβ : (0 : β) < d := by exact_mod_cast (show 0 < d by omega) | |
| have hscale (g : Option I Γ Option J) : | |
| 0 < cellScale (fun i => (R i : β)) (fun j => (P j : β)) g := by | |
| change 0 < min (R g.1 : β) (P g.2 : β) | |
| apply lt_min | |
| Β· exact_mod_cast (lt_of_lt_of_le (pow_pos (show 0 < d by omega) _) (hR _)) | |
| Β· exact_mod_cast (lt_of_lt_of_le (pow_pos (show 0 < d by omega) _) (hP _)) | |
| obtain β¨X, hX, hXR, hXPβ© := strict_real_completion | |
| (fun i => (R i : β)) (fun j => (P j : β)) (d : β) hdβ | |
| (fun _ => Nat.cast_nonneg _) (fun _ => Nat.cast_nonneg _) | |
| (by exact_mod_cast hdimR) (by exact_mod_cast hdimP) (by exact_mod_cast htotal) | |
| let u : I Γ J β β := fun p => X (some p.1) (some p.2) / denseWidth R P d p.1 p.2 | |
| have heq : table (fun i => (R i : β)) (fun j => (P j : β)) (denseWidth R P d) u = X := | |
| table_recover _ _ _ (fun i j => ne_of_gt (denseWidth_pos R P d hd hR hP i j)) X hXR hXP | |
| have hfeas : Feasible R P d u := by | |
| intro i j | |
| rw [heq] | |
| exact (div_nonneg (hscale (i, j)).le (by positivity)).trans (hX i j) | |
| refine β¨u, hfeas, feasible_in_cube R P d hd hR hP htotal u hfeas, ?_β© | |
| intro g | |
| rw [heq] | |
| apply (le_div_iffβ (hscale g)).mpr | |
| simpa only [cellScale, div_mul_eq_mul_div, one_mul] using hX g.1 g.2 | |
| theorem densePenalty_eq_zero_of_feasible (R : Option I β β) (P : Option J β β) | |
| (d : β) (u : I Γ J β β) (hu : Feasible R P d u) : densePenalty R P d u = 0 := by | |
| apply le_antisymm | |
| Β· unfold densePenalty AffinePenalty.penalty | |
| apply Finset.sup'_le | |
| intro g _ | |
| cases g with | |
| | none => exact le_rfl | |
| | some g => | |
| change -AffinePenalty.affineValue _ _ u - (d : β) / (d : β) ^ 8 β€ 0 | |
| rw [β normalized_table_affine] | |
| have hnorm : 0 β€ table (fun i => (R i : β)) (fun j => (P j : β)) | |
| (denseWidth R P d) u g.1 g.2 / | |
| cellScale (fun i => (R i : β)) (fun j => (P j : β)) g := | |
| div_nonneg (hu g.1 g.2) (le_min (Nat.cast_nonneg _) (Nat.cast_nonneg _)) | |
| linarith [show (0 : β) β€ (d : β) / (d : β) ^ 8 by positivity] | |
| Β· exact AffinePenalty.penalty_nonnegative _ _ _ _ | |
| end ContingencyTables.DenseAffine | |
| end OAI | |