{
  "id": "4332",
  "ident": "NS.04332",
  "slug": "mathoverflow-34145--lbmeasure-rectangle-toset",
  "title": "Mathoverflow 34145 · lbMeasure_rectangle_toSet",
  "status": "test",
  "statement_status": "reviewed",
  "statement_md": "The Lebesgue measure of the a rectangle `r` is `r.width * r.height`",
  "subjects": [
    "math.MG",
    "msc:51"
  ],
  "tags": [],
  "collection": "mathoverflow",
  "source_url": "https://mathoverflow.net/q/34145",
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Mathoverflow34145.lbMeasure_rectangle_toSet",
  "statement_lean": "lemma lbMeasure_rectangle_toSet (r : Rectangle) :\n    lbMeasure r.toSet = .ofReal |r.width * r.height|",
  "challenge_source": "/-\nCopyright 2025 The Formal Conjectures Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-/\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Mathoverflow 34145\n\nCan the unit square be covered by $1/k$-by-$1/(k+1)$ rectangles (across $1 \\le k$ natural)?\n\nI am deliberately not requiring that the rotations can only be $0^\\circ, 90^\\circ, 180^\\circ, \\text{ or } 270^\\circ$.\n\nBecause of indexing, since `n : ℕ` starts at 0, we change the side lengths to $1 / (n + 1)$ and\n$1 / (n + 2)$, so that the first rectangle is $1/1$ by $1/2$, the second is $1/2$ by $1/3$, etc.\n\n*Reference:* [mathoverflow/34145](https://mathoverflow.net/q/34145)\nasked by user [*Kaveh*](https://mathoverflow.net/users/7507/kaveh)\n-/\n\n@[expose] public section\n\nopen Real MeasureTheory Measure Module\nnamespace Mathoverflow34145\n\n/-- A rectangle is specified by its width, height, starting point, and rotation.\nThe rectangle is assumed to start in the lower left corner. For example, the unit square\n$\\{ (x, y) \\mid 0 \\le x \\le 1, 0 \\le y \\le 1 \\}$ is specified as `⟨1, 1, (0, 0), 0⟩`  -/\nstructure Rectangle : Type where\n  width : ℝ\n  height : ℝ\n  start : ℝ × ℝ\n  rotation : Angle\n\n/-- A combination of a rotation and a translation to map the standard rectangle to the desired\nrectangle.\n-/\nnoncomputable def rigidMotion (start : ℝ × ℝ) (θ : Angle) (p : ℝ × ℝ) : (ℝ × ℝ) :=\n  (start.1 + p.1 * θ.cos - p.2 * θ.sin, start.2 + p.1 * θ.sin + p.2 * θ.cos)\n\n@[category test, AMS 51]\nlemma rigidMotion_test : rigidMotion (sqrt 2, sqrt 11) (2 * π / 3 : ℝ) (sqrt 5, sqrt 7) =\n    (sqrt 2 - sqrt 5 / 2 - sqrt 21 / 2, -sqrt 7 / 2 + sqrt 11 + sqrt 15 / 2) := by\n  simp [rigidMotion, mul_div_assoc, cos_two_mul, sin_two_mul,\n    show (21 : ℝ) = 3 * 7 by norm_num, show (15 : ℝ) = 3 * 5 by norm_num]\n  ring_nf; simp\n\n/-- A scaling to map the unit square to a standard rectangle. -/\nnoncomputable def scale (x y : ℝ) (p : ℝ × ℝ) : (ℝ × ℝ) :=\n  (x * p.1, y * p.2)\n\n/-- The unit square. -/\ndef unitSquare : Set (ℝ × ℝ) :=\n  { p | 0 ≤ p.1 ∧ p.1 ≤ 1 ∧ 0 ≤ p.2 ∧ p.2 ≤ 1 }\n\n/-- Converts a rectangle to a set in `ℝ × ℝ`. -/\ndef Rectangle.toSet (r : Rectangle) : Set (ℝ × ℝ) :=\n  rigidMotion r.start r.rotation '' (scale r.width r.height '' unitSquare)\n\n/-- The standard Lebesgue measure on `ℝ²`. -/\nnoncomputable abbrev lbMeasure : Measure (ℝ × ℝ) :=\n  (Basis.finTwoProd ℝ).addHaar\n\n/-- `lbMeasure` is invariant under `rigidMotion start θ`. -/\n@[category test, AMS 51]\nlemma lbMeasure_rigidMotion (start : ℝ × ℝ) (θ : Angle) (s : Set (ℝ × ℝ)) :\n    lbMeasure (rigidMotion start θ '' s) = lbMeasure s := by\n  let α (x : ℝ × ℝ) := (x.1 * θ.cos - x.2 * θ.sin, x.1 * θ.sin + x.2 * θ.cos)\n  trans (Basis.finTwoProd _).addHaar (α '' s)\n  · exact (measure_preimage_add_right _ start _).symm.trans (congr_arg _ (Set.ext <| by\n      simp [rigidMotion, α, add_sub_assoc, add_assoc, Prod.ext_iff, ← eq_sub_iff_add_eq']))\n  · let β := Basis.finTwoProd ℝ\n    trans β.addHaar (β.constr ℝ ![α (β 0), α (β 1)] '' s)\n    · exact congr_arg _ <| Set.image_congr <| by aesop\n    · rw [addHaar_image_linearMap, eq_comm, ← LinearMap.det_toMatrix β, Matrix.det_fin_two]\n      simp [α, β, LinearMap.toMatrix_apply, ← sq]\n\n/-- `lbMeasure` is scaled by `scale`. -/\n@[category test, AMS 51]\nlemma lbMeasure_scale (x y : ℝ) (s : Set (ℝ × ℝ)) :\n    lbMeasure (scale x y '' s) = .ofReal |x * y| * lbMeasure s := by\n  let scaleLinear : (ℝ × ℝ) →ₗ[ℝ] (ℝ × ℝ) :=\n  { toFun p := (x * p.1, y * p.2)\n    map_add' p q := by simp [mul_add]\n    map_smul' c p := by simp [mul_left_comm] }\n  have h₁ : scale x y = scaleLinear := rfl\n  have h₂ : scaleLinear.toMatrix (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ) = !![x, 0; 0, y] := by\n    ext i j; unfold scaleLinear; fin_cases i <;> fin_cases j <;> simp [LinearMap.toMatrix_apply]\n  simp [h₁, ← LinearMap.det_toMatrix (Basis.finTwoProd ℝ), h₂]\n\n/-- The Lebesgue measure of the unit square is `1`. -/\n@[category test, AMS 51]\nlemma lbMeasure_unitSquare : lbMeasure unitSquare = 1 := by\n  convert (Basis.addHaar_eq_iff (Basis.finTwoProd ℝ) _).1 rfl\n  ext p\n  simp only [unitSquare, Set.mem_ofPred_eq, Basis.coe_parallelepiped, mem_parallelepiped_iff,\n    Set.mem_Icc, Fin.sum_univ_two, Fin.isValue, Basis.finTwoProd_zero, Prod.smul_mk, smul_eq_mul,\n    mul_one, mul_zero, Basis.finTwoProd_one, Prod.mk_add_mk, add_zero, zero_add, Pi.le_def]\n  exact ⟨fun h ↦ ⟨![p.1, p.2], by simp [Fin.forall_fin_succ, h]⟩,\n    fun ⟨t, ht⟩ ↦ ht.2 ▸ ⟨ht.1.1 0, ht.1.2 0, ht.1.1 1, ht.1.2 1⟩⟩\n\n/-- The Lebesgue measure of the a rectangle `r` is `r.width * r.height` -/\n@[category test, AMS 51]\nlemma lbMeasure_rectangle_toSet (r : Rectangle) :\n    lbMeasure r.toSet = .ofReal |r.width * r.height| := by\n  rw [Rectangle.toSet, lbMeasure_rigidMotion, lbMeasure_scale, lbMeasure_unitSquare, mul_one]\n\n/-- The areas of the required rectangles sum to 1. -/\n@[category test, AMS 51]\nlemma tsum_area_eq_one : ∑' (n : ℕ), ((1 / (n + 1)) * (1 / (n + 2)) : ℝ) = 1 := by\n  have (n : ℕ) : ∑ i ∈ Finset.range n, (1 / (i + 1) * (1 / (i + 2)) : ℝ) = 1 - 1 / (n + 1) := by\n    induction n with\n    | zero => simp\n    | succ n ih => rw [Finset.sum_range_succ, ih]; field_simp; push_cast; ring\n  refine HasSum.tsum_eq ((hasSum_iff_tendsto_nat_of_nonneg (fun i ↦ ?_) _).2 ?_)\n  · positivity\n  · simp_rw [this]\n    convert tendsto_one_div_add_atTop_nhds_zero_nat.const_sub (1 : ℝ) (c := 0) using 1\n    norm_num\n\n/-- A configuration of rectangles of sides `1 / (n + 1)` and `1 / (n + 2)`. -/\nstructure Configuration : Type where\n  rect (n : ℕ) : Rectangle\n  rect_width (n : ℕ) : (rect n).width = 1 / (n + 1)\n  rect_height (n : ℕ) : (rect n).height = 1 / (n + 2)\n\n/-- A \"packing\" means that the interiors of any two rectangles are disjoint. -/\ndef Configuration.IsPacking (c : Configuration) : Prop :=\n  Pairwise fun m n ↦ interior (c.rect m).toSet ∩ interior (c.rect n).toSet = ∅\n\n/-- Can a unit square be covered by rectangles of width `1 / (n + 1)` and height `1 / (n + 2)`? -/\n@[category research open, question, AMS 51]\ntheorem rectangles_cover_unit_square :\n    ∃ c : Configuration, ∀ p ∈ unitSquare, ∃ n, p ∈ (c.rect n).toSet := by\n  sorry\n\n/-- Equivalently, can a unit square be packed with rectangles of width `1 / (n + 1)` and height\n`1 / (n + 2)`? -/\n@[category research open, question, AMS 51]\ntheorem rectangles_pack_unit_square :\n    ∃ c : Configuration, (∀ n, (c.rect n).toSet ⊆ unitSquare) ∧ c.IsPacking := by\n  sorry\n\n/-- It is known that packing the rectangles into a square of side length `133/132` is possible.\n\nReference: https://www.sciencedirect.com/science/article/pii/0097316594901163\n-/\n@[category research solved, AMS 51]\ntheorem rectangles_pack_square_133_div_132 :\n    (∃ c : Configuration,\n      (∀ n, (c.rect n).toSet ⊆ Rectangle.toSet ⟨133/132, 133/132, (0, 0), 0⟩) ∧\n      c.IsPacking) := by\n  sorry\n\n/-- It is known that packing the rectangles into a square of side length `501/500` is possible.\n\nReference: https://www.sciencedirect.com/science/article/pii/S0167506008706009\n-/\n@[category research solved, AMS 51]\ntheorem rectangles_pack_square_501_div_500 :\n    (∃ c : Configuration,\n      (∀ n, (c.rect n).toSet ⊆ Rectangle.toSet ⟨501/500, 501/500, (0, 0), 0⟩) ∧\n      c.IsPacking) := by\n  sorry\n\nend Mathoverflow34145\n",
  "statement_hash": "937ffe1b6c3ec9c137e1938b6578fe26cdd0e6ba35619074f02d7db2b2c6d2e3",
  "toolchain": "leanprover/lean4:v4.33.1",
  "upstream_commit": "f9b3868d5ca994a7bf95039bcec05338c0c21e2f",
  "workspace": "formal-conjectures",
  "field": "math",
  "formalization": "formal",
  "verification": "lean-kernel",
  "license": "Apache-2.0",
  "attribution": "google-deepmind/formal-conjectures contributors",
  "metric_name": null,
  "metric_direction": null,
  "critiques": [],
  "public_partial_proofs": [],
  "research_threads": [],
  "instructions": "Read research_threads first: other people's public repositories and what they already tried. Write Solution.lean starting from challenge_source. Keep every definition identical, prove decl_name with exactly the same type, no sorry in its dependency closure, no new axioms, no native_decide, no metaprogramming. Submit with POST /api/v1/submissions."
}