Download lean/OAI/Combinatorics/MatrixRemoval/Model.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Combinatorics/MatrixRemoval/Model.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Combinatorics/MatrixRemoval/Model.lean
-
curl -L -o Model.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Combinatorics/MatrixRemoval/Model.lean
1.8 kB
| import Mathlib | |
| namespace OAI | |
| noncomputable section | |
| namespace Problem348 | |
| abbrev BinaryMatrix (n : ℕ) := Fin n → Fin n → Bool | |
| abbrev IncreasingMap (k n : ℕ) := {f : Fin k → Fin n // StrictMono f} | |
| def orderedCopies {k n : ℕ} (H : BinaryMatrix k) (A : BinaryMatrix n) : | |
| Finset (IncreasingMap k n × IncreasingMap k n) := by | |
| classical | |
| exact Finset.univ.filter (fun rc => | |
| ∀ i j, A ((rc.1).val i) ((rc.2).val j) = H i j) | |
| def copyCount {k n : ℕ} (H : BinaryMatrix k) (A : BinaryMatrix n) : ℕ := | |
| (orderedCopies H A).card | |
| def HFree {k n : ℕ} (H : BinaryMatrix k) (A : BinaryMatrix n) : Prop := | |
| copyCount H A = 0 | |
| def hammingDistance {n : ℕ} (A B : BinaryMatrix n) : ℕ := by | |
| classical | |
| exact (Finset.univ.filter (fun rc : Fin n × Fin n => | |
| A rc.1 rc.2 ≠ B rc.1 rc.2)).card | |
| def etaBit (a b : ℕ) : Bool := | |
| decide (((a / (2 ^ (5 - b))) % 2) = 1) | |
| def anchor64 (u v : Fin 64) : Bool := | |
| if 32 ≤ u.val ∧ 59 ≤ v.val then | |
| etaBit (u.val - 32) (v.val - 58) | |
| else | |
| decide (u.val ≠ v.val) | |
| def fixedH : BinaryMatrix 66 := fun u v => | |
| if hu : u.val < 64 then | |
| if hv : v.val < 64 then | |
| anchor64 ⟨u.val, hu⟩ ⟨v.val, hv⟩ | |
| else | |
| decide ((v.val = 64 ∧ u.val = 0) ∨ | |
| (v.val = 65 ∧ u.val = 1)) | |
| else | |
| if v.val < 64 then | |
| decide ((u.val = 64 ∧ v.val = 0) ∨ | |
| (u.val = 65 ∧ v.val = 1)) | |
| else | |
| decide (u.val = 65 ∨ v.val = 64) | |
| def fixedMinEdits {n : ℕ} (A : BinaryMatrix n) : ℕ := by | |
| classical | |
| exact | |
| (Finset.univ.image (fun B : BinaryMatrix n => | |
| if HFree fixedH B then hammingDistance A B else n * n + 1)).min' | |
| (by simp) | |
| def fixedDistance {n : ℕ} (A : BinaryMatrix n) : ℝ := | |
| (fixedMinEdits A : ℝ) / ((n : ℝ) ^ 2) | |
| end Problem348 | |
| end | |
| end OAI | |