Lean / Reader
Lean readerCubeGrid.lean
Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports CubeLayers, CubeCounting, which it does not have: you can read it there, but it will not check. Build the project itself to check it.
import CubeLayersimport CubeCountingnamespace CubeGrid/-- If all outer corners are covered by unit cubes, they require every grid point. -/theorem outer_forces_grid (A : Finset (Point 4)) (hA : A ⊆ box 4 3)(ho : vertices 4 3 (origin 4) ⊆ expansion 4 A) : box 4 4 ⊆ expansion 4 A := byintro x hxhave hout := ho (outer_contains 4 x)obtain ⟨a, ha, hav⟩ := Finset.mem_biUnion.mp houtexact Finset.mem_biUnion.mpr ⟨a,ha,unit_near_outer 4 hx (hA ha) hav⟩theorem unit_bound (S : Finset (Point 4)) (hS : S.card ≤ 81) : (anchors S 1).card ≤ 16 := byby_contra! hobtain ⟨A,hs,hc⟩ := Finset.exists_subset_card_eq (s := anchors S 1) (n := 17) hhave hg : A ⊆ box 4 3 := hs.trans (Finset.filter_subset _ _)have v := profile_bound 4 (by decide) A hg (by omega)rw [hc] at vchange 89 ≤ _ at vhave hu := Finset.card_le_card (expansion_inside S A hs)omegatheorem unit_bound_outer (S : Finset (Point 4)) (hS : S.card ≤ 81)(h3 : 0 < (anchors S 3).card) : (anchors S 1).card ≤ 15 := byby_contra! hobtain ⟨A,hs,hc⟩ := Finset.exists_subset_card_eq (s := anchors S 1) (n := 16) hhave hg : A ⊆ box 4 3 := hs.trans (Finset.filter_subset _ _)have v := profile_bound 4 (by decide) A hg (by omega)rw [hc] at vchange 81 ≤ _ at vhave eu : expansion 4 A = S :=Finset.eq_of_subset_of_card_le (expansion_inside S A hs) (by omega)obtain ⟨a,ha⟩ := Finset.card_pos.mp h3obtain ⟨ga,outer⟩ := Finset.mem_filter.mp hahave one : box 4 (4-3) = {origin 4} := by decide +kernelrw [one, Finset.mem_singleton] at gasubst arw [← eu] at outerhave huge := Finset.card_le_card (outer_forces_grid A hg outer)rw [box_card,eu] at hugeomega/-- At most 17 positive axis-parallel vertex cubes on any at-most-81-pointhost in the four-dimensional grid of side four. The enumerated anchor domainsgive precisely the positive integral side lengths and placements in the grid. -/theorem at_most_seventeen (S : Finset (Point 4)) (hS : S.card ≤ 81) : cubeCount S ≤ 17 := byhave a := unit_bound S hShave b := full_count_le S hShave c : (anchors S 3).card ≤ 1 := byhave v : (anchors S 3).card ≤ (box 4 (4-3)).card := Finset.card_le_card (Finset.filter_subset _ _)simpa [box_card] using vunfold cubeCountby_cases h13 : 13 ≤ (anchors S 1).card· have hb := packing_if_thirteen S hS h13by_cases ho : 0 < (anchors S 3).card· have := unit_bound_outer S hS ho; omega· omega· by_cases hu : 0 < (anchors S 1).card· have := packing_if_units S hS hu; omega· omegaset_option maxHeartbeats 0 intheorem sharp_grid : (box 4 3).card = 81 ∧ cubeCount (box 4 3) = 17 :=⟨by rw [box_card]; decide, by decide +kernel⟩theorem exact_maximum :(∀ S : Finset (Point 4), S ⊆ box 4 4 → S.card = 81 → cubeCount S ≤ 17) ∧∃ S : Finset (Point 4), S ⊆ box 4 4 ∧ S.card = 81 ∧ cubeCount S = 17 := byexact ⟨fun S _ hc => at_most_seventeen S hc.le,box 4 3, by decide +kernel, sharp_grid⟩#print axioms exact_maximum#print axioms at_most_seventeen#print axioms profile_boundend CubeGrid