openAI-math-dataset / lean /OAI /Combinatorics /ContingencyTables /Dense /DenseExponentListSemantics.lean
Download lean/OAI/Combinatorics/ContingencyTables/Dense/DenseExponentListSemantics.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 3.81 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Combinatorics/ContingencyTables/Dense/DenseExponentListSemantics.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Combinatorics/ContingencyTables/Dense/DenseExponentListSemantics.lean
-
curl -L -o DenseExponentListSemantics.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Combinatorics/ContingencyTables/Dense/DenseExponentListSemantics.lean
3.81 kB
| import OAI.Combinatorics.ContingencyTables.Dense.DenseExponentListProgram | |
| namespace OAI | |
| /-! # The binary list exponent equals the geometric dense exponent -/ | |
| namespace ContingencyTables.DensePrograms | |
| open scoped BigOperators Classical | |
| open GridBoundary ProfilePrograms | |
| variable {m n : ℕ} | |
| def exponentDataCode (R : Option (Fin m) → ℕ) (P : Option (Fin n) → ℕ) | |
| (d : ℕ) (z : Fin m → Fin n → ℕ) : ExponentData := | |
| (((marginCode R,marginCode P),matrixCode z),d) | |
| lemma optionIndex_lt (i : Option (Fin m)) : optionIndex i < m + 1 := by | |
| cases i with | |
| | none => simp [optionIndex] | |
| | some i => simpa only [optionIndex,Nat.add_lt_add_iff_right] using i.isLt | |
| lemma exists_optionIndex (a : ℕ) (ha : a < m + 1) : | |
| ∃ i : Option (Fin m),optionIndex i=a := by | |
| cases a with | |
| | zero => exact ⟨none,rfl⟩ | |
| | succ a => exact ⟨some ⟨a,by omega⟩,rfl⟩ | |
| lemma exponentCell_code (R : Option (Fin m) → ℕ) (P : Option (Fin n) → ℕ) | |
| (d : ℕ) (z : Fin m → Fin n → ℕ) (i : Option (Fin m)) (j : Option (Fin n)) : | |
| exponentCell (exponentDataCode R P d z,(optionIndex i,optionIndex j))= | |
| componentExponent d (min (R i) (P j)) | |
| (integerParts R P (fun p => z p.1 p.2) i j).1 | |
| (integerParts R P (fun p => z p.1 p.2) i j).2 := by | |
| simp only [exponentCell,exponentCellData,exponentDataCode,componentValue, | |
| marginCode_getD,completionParts_code] | |
| lemma mem_exponentCells_code (R : Option (Fin m) → ℕ) (P : Option (Fin n) → ℕ) | |
| (d : ℕ) (z : Fin m → Fin n → ℕ) (i : Option (Fin m)) (j : Option (Fin n)) : | |
| (optionIndex i,optionIndex j)∈exponentCells (exponentDataCode R P d z) := by | |
| apply (mem_cellPairs _ _ _ _).mpr | |
| simpa only [marginCode,List.length_cons,List.length_ofFn] using | |
| And.intro (optionIndex_lt i) (optionIndex_lt j) | |
| /-- The list maximum contains every cell once; its initial zero accounts | |
| for the extra zero component in the nonnegative rational penalty. -/ | |
| theorem fullExponent_code {q K : ℕ} (R : Option (Fin m) → ℕ) | |
| (P : Option (Fin n) → ℕ) (d : ℕ) (e : Fin m×Fin n ≃ Fin q) | |
| (a : Grid (I := Fin q) K) : | |
| fullExponent (exponentDataCode R P d (fun i j => cornerFree R P d e a (i,j)))= | |
| denseExponent R P d e a := by | |
| let z := fun i j => cornerFree R P d e a (i,j) | |
| let data := exponentDataCode R P d z | |
| rw [denseExponent_eq_arithmetic] | |
| apply le_antisymm | |
| · apply (listMaximum_le (exponentValues data) 0 _).mpr | |
| refine ⟨Nat.zero_le _,?_⟩ | |
| intro b hb | |
| obtain ⟨ij,hij,rfl⟩ := List.mem_map.mp hb | |
| have hbound := (mem_cellPairs _ _ ij.1 ij.2).mp hij | |
| have hi : ij.1 < m + 1 := by | |
| simpa only [data,exponentDataCode,marginCode,List.length_cons,List.length_ofFn] using hbound.1 | |
| have hj : ij.2 < n + 1 := by | |
| simpa only [data,exponentDataCode,marginCode,List.length_cons,List.length_ofFn] using hbound.2 | |
| obtain ⟨i,hi⟩ := exists_optionIndex ij.1 hi | |
| obtain ⟨j,hj⟩ := exists_optionIndex ij.2 hj | |
| have he : ij=(optionIndex i,optionIndex j) := Prod.ext hi.symm hj.symm | |
| rw [he] | |
| change exponentCell (exponentDataCode R P d z,(optionIndex i,optionIndex j))≤_ | |
| rw [exponentCell_code] | |
| exact Finset.le_sup' (arithmeticExponentAt R P d e a) (Finset.mem_univ (some (i,j))) | |
| · apply Finset.sup'_le | |
| intro g _ | |
| cases g with | |
| | none => exact Nat.zero_le _ | |
| | some ij => | |
| have hmem : exponentCell (data,(optionIndex ij.1,optionIndex ij.2))∈exponentValues data := | |
| List.mem_map.mpr ⟨(optionIndex ij.1,optionIndex ij.2), | |
| mem_exponentCells_code R P d z ij.1 ij.2,rfl⟩ | |
| have hle := le_listMaximum_member (exponentValues data) 0 _ hmem | |
| rw [show data=exponentDataCode R P d z from rfl,exponentCell_code] at hle | |
| exact hle | |
| end ContingencyTables.DensePrograms | |
| end OAI | |