Buckets:
| 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 | |
Xet Storage Details
- Size:
- 1.8 kB
- Xet hash:
- 9e08ecf33deaa2c7af36b2f46419198adecb3f697b5c70ff396052ad54e0cc32
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.