Download lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderTableWords.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 3.78 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderTableWords.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderTableWords.lean
-
curl -L -o ExpanderTableWords.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Combinatorics/IndependentSets/Expansion/ExpanderTableWords.lean
3.78 kB
Lean 4 · 14
declarations statementsfull
def rotationWords (table : Table v d) : List Nat := table.rows.toList.map Fin.val @[simp] theorem rotationWords_length (table : Table v d) :
(rotationWords table).length = v * d := by proof · 1 line
simp [rotationWords]
theorem rotationWords_getElem (table : Table v d) (i : ℕ) (hi : i < v * d) :
(rotationWords table)[i]'(by simpa only [rotationWords_length] using hi) =
(reverseIndex table ⟨i, hi⟩).val := by proof · 2 lines
simp only [rotationWords, List.getElem_map, Vector.getElem_toList,
reverseIndex, Fin.getElem_fin]theorem rotationWords_get (table : Table v d) (i : Fin (v * d)) :
(rotationWords table).get
⟨i.val, by simpa only [rotationWords_length] using i.isLt⟩ =
(reverseIndex table i).val := by proof · 1 line
simpa only [List.get_eq_getElem] using rotationWords_getElem table i.val i.isLttheorem rotationWords_getElem? (table : Table v d) (i : Fin (v * d)) :
(rotationWords table)[i.val]? = some (reverseIndex table i).val := by proof · 3 lines
apply List.getElem?_eq_some_iff.mpr
exact ⟨by simpa only [rotationWords_length] using i.isLt,
rotationWords_getElem table i.val i.isLt⟩theorem rotationWords_getElem?_none (table : Table v d) (i : ℕ) (hi : v * d ≤ i) :
(rotationWords table)[i]? = none := proof · 1 line
List.getElem?_eq_none (by simpa only [rotationWords_length] using hi)theorem rotationWords_entry_lt (table : Table v d) (n : ℕ)
(hn : n ∈ rotationWords table) : n < v * d := by proof · 2 lines
obtain ⟨a, _, rfl⟩ := List.mem_map.mp hn
exact a.isLttheorem rotationWords_lookup (table : Table v d) (x : Fin v × Fin d) :
(rotationWords table)[(rowIndex v d x).val]? =
some (rowIndex v d (lookup table x)).val := by proof · 2 lines
simpa only [lookup, Equiv.apply_symm_apply] using
rotationWords_getElem? table (rowIndex v d x)theorem rotationWords_row_order (table : Table v d) (x : Fin v × Fin d) :
(rotationWords table)[x.2.val + d * x.1.val]? =
some ((lookup table x).2.val + d * (lookup table x).1.val) := by proof · 1 line
simpa only [rowIndex_val] using rotationWords_lookup table x@[simp] theorem decode_rotationWords (table : Table v d) :
decodeWords (encodeWords (rotationWords table)) = some (rotationWords table) := proof · 1 line
Complexity.decodeWords_encodeWords _theorem decoded_lookup (table : Table v d) (i : Fin (v * d)) :
(decodeWords (encodeWords (rotationWords table))).bind (fun words => words[i.val]?) =
some (reverseIndex table i).val := by proof · 2 lines
rw [decode_rotationWords] exact rotationWords_getElem? table i
theorem decoded_coordinate_lookup (table : Table v d) (x : Fin v × Fin d) :
(decodeWords (encodeWords (rotationWords table))).bind
(fun words => words[x.2.val + d * x.1.val]?) =
some ((lookup table x).2.val + d * (lookup table x).1.val) := by proof · 2 lines
rw [decode_rotationWords] exact rotationWords_row_order table x
theorem encode_rotationWords_length_eq (table : Table v d) :
(encodeWords (rotationWords table)).length = (rotationWords table).sum + v * d := by proof · 1 line
rw [Complexity.encodeWords_length, rotationWords_length]theorem encode_rotationWords_length_le (table : Table v d) :
(encodeWords (rotationWords table)).length ≤ (v * d) * (v * d + 1) := by proof · 5 lines
calc
_ ≤ (rotationWords table).length * (v * d + 1) :=
Complexity.encodeWords_length_le _ _
(fun n hn => (rotationWords_entry_lt table n hn).le)
_ = _ := by rw [rotationWords_length]Outline
- def
rotationWords14 - theorem
rotationWords_length16 - theorem
rotationWords_getElem20 - theorem
rotationWords_get26 - theorem
rotationWords_getElem?32 - theorem
rotationWords_getElem?_none38 - theorem
rotationWords_entry_lt42 - theorem
rotationWords_lookup47 - theorem
rotationWords_row_order53 - theorem
decode_rotationWords58 - theorem
decoded_lookup62 - theorem
decoded_coordinate_lookup68 - theorem
encode_rotationWords_length_eq75 - theorem
encode_rotationWords_length_le79