Compfiles/Usa2020P4.lean

GitHub source file

Explanation legend Lean4 Domain Explanation Language (L4DEL)

L4DEL explanations are a separate layer. They do not change the Lean source. Intuition is explanatory prose; numbered items are a reading path; sources link the wording back to evidence.

L4DEL
Lean4 Domain Explanation Language

Credit: The upstream authors and contributors retain credit for the project and mathematics. lean4-explainer only renders their pinned source and adds the separately disclosed explanation layer.

Project sources: Pinned compfiles documentation, Pinned compfiles corpus index

12 declarations, 0 contain sorry, 0 declared as axioms

USA Mathematical Olympiad 2020, Problem 4

Suppose that (a₁, b₁), (a₂, b₂), ..., (a₁₀₀, b₁₀₀) are distinct ordered pairs of nonnegative integers. Let N denote the number of pairs of integers (i, j) satisfying 1 ≤ i < j ≤ 100 and |aᵢbⱼ − aⱼbᵢ| = 1. Determine the largest possible value of N over all possible choices of the 100 ordered pairs.

Imports (8)
Imported by 1 file
  1. def Usa2020P4.det The determinant aᵢ bⱼ − aⱼ bᵢ of two ordered pairs of nonnegative integers, viewed as an integer line 35 source

    Source documentation

    The determinant aᵢ bⱼ − aⱼ bᵢ of two ordered pairs of nonnegative integers, viewed as an integer.

    no axioms what this means

    Statement uses: Prod, Nat, Int

    Proof uses: HSub.hSub, HMul.hMul, Prod.fst, Prod.snd

    6 instances, coercions and auxiliary constants left out.

    def det (P Q : ℕ × ℕ) : ℤ := (P.1 : ℤ) * (Q.2 : ℤ) - (Q.1 : ℤ) * (P.2 : ℤ)

    Mentions: P

  2. determine Usa2020P4.answer line 37 source

    no axioms what this means

    Statement uses: Nat

    Proof uses: OfNat.ofNat

    1 instances, coercions and auxiliary constants left out.

  3. def Usa2020P4.goodSets The good two-element subsets of a set of points: those {P, Q} with |det P Q| = 1 line 65 source

    Source documentation

    The good two-element subsets of a set of points: those {P, Q} with |det P Q| = 1.

    private def goodSets (S : Finset (ℕ × ℕ)) : Finset (Finset (ℕ × ℕ)) :=
    …

    Mentions: S

  4. def Usa2020P4.goodPairs The good index pairs of a choice v of 100 points line 69 source

    Source documentation

    The good index pairs of a choice v of 100 points.

    private def goodPairs (v : Fin 100 → ℕ × ℕ) : Finset (Fin 100 × Fin 100) :=
    …
  5. lemma Usa2020P4.det_swap line 72 source
  6. lemma Usa2020P4.eq_zero_of_eq_add_mul If (u, v) = (u', v') + t • (a, b) with t ≥ 1, all of u' v' a b nonnegative, and u² + v² ≤ a² + b², then (u', v') = (0, 0) line 76 source

    Source documentation

    If (u, v) = (u', v') + t • (a, b) with t ≥ 1, all of u' v' a b nonnegative, and u² + v² ≤ a² + b², then (u', v') = (0, 0).

    private lemma eq_zero_of_eq_add_mul {u v u' v' a b t : ℤ} (ha : 0 ≤ a) (hb : 0 ≤ b)
        (hu' : 0 ≤ u') (hv' : 0 ≤ v') (ht : 1 ≤ t)
        (huu : u = u' + t * a) (hvv : v = v' + t * b)
        (hn : u ^ 2 + v ^ 2 ≤ a ^ 2 + b ^ 2) : u' = 0 ∧ v' = 0 := by
    …
  7. lemma Usa2020P4.eq_of_det_eq_of_le Two points of the first quadrant having the same determinant of absolute value 1 with a primitive point P, and both at most as far from the origin as P, must coincide line 110 source

    Source documentation

    Two points of the first quadrant having the same determinant of absolute value 1 with a primitive point P, and both at most as far from the origin as P, must coincide.

    private lemma eq_of_det_eq_of_le {P Q₁ Q₂ : ℕ × ℕ} (hP : Nat.Coprime P.1 P.2)
        (hdet : det P Q₁ = det P Q₂) (habs : |det P Q₁| = 1)
        (hn₁ : Q₁.1 ^ 2 + Q₁.2 ^ 2 ≤ P.1 ^ 2 + P.2 ^ 2)
        (hn₂ : Q₂.1 ^ 2 + Q₂.2 ^ 2 ≤ P.1 ^ 2 + P.2 ^ 2) : Q₁ = Q₂ := by
    …

    Mentions: P, Usa2020P4.det

  8. lemma Usa2020P4.gcd_dvd_det The gcd of the coordinates of P divides every determinant det P Q line 166 source

    Source documentation

    The gcd of the coordinates of P divides every determinant det P Q.

    private lemma gcd_dvd_det (P Q : ℕ × ℕ) : (Nat.gcd P.1 P.2 : ℤ) ∣ det P Q := by
    …

    Mentions: P, Usa2020P4.det

  9. lemma Usa2020P4.card_partners_le_two A farthest point P of S forms good pairs with at most two points of S line 174 source

    Source documentation

    A farthest point P of S forms good pairs with at most two points of S.

    private lemma card_partners_le_two {S : Finset (ℕ × ℕ)} {P : ℕ × ℕ}
        (hmax : ∀ Q ∈ S, Q.1 ^ 2 + Q.2 ^ 2 ≤ P.1 ^ 2 + P.2 ^ 2) :
        ((S.erase P).filter fun Q => |det P Q| = 1).card ≤ 2 := by
    …

    Mentions: S, P, Usa2020P4.det

  10. lemma Usa2020P4.card_goodSets_le A set of n ≥ 2 points determines at most 2 * n - 3 good pairs line 212 source

    Source documentation

    A set of n ≥ 2 points determines at most 2 * n - 3 good pairs.

    private lemma card_goodSets_le : ∀ n : ℕ, 2 ≤ n → ∀ S : Finset (ℕ × ℕ),
        S.card = n → (goodSets S).card ≤ 2 * n - 3 := by
    …

    Mentions: S, Usa2020P4.goodSets

  11. lemma Usa2020P4.card_goodPairs_eq For an injective choice v of points, the good index pairs and the good two-element subsets of the image are equinumerous line 273 source

    Source documentation

    For an injective choice v of points, the good index pairs and the good two-element subsets of the image are equinumerous.

    private lemma card_goodPairs_eq {v : Fin 100 → ℕ × ℕ} (hv : Function.Injective v) :
        (goodPairs v).card = (goodSets (Finset.univ.image v)).card := by
    …

    Mentions: Usa2020P4.goodPairs, Usa2020P4.goodSets

  12. problem Usa2020P4.usa2020_p4 USA Mathematical Olympiad 2020, Problem 4 line 343 source

    Source documentation

    USA Mathematical Olympiad 2020, Problem 4

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: IsGreatest, Nat, Set.ofPred, Exists, Fin, OfNat.ofNat, Prod, And, Function.Injective, Eq, Finset.card, Finset.filter, LT.lt, Prod.fst, Prod.snd, Int, abs, Usa2020P4.det, Finset.univ, Usa2020P4.answer

    Proof uses: And.intro, Membership.mem, Set, upperBounds, Exists.intro, ite, Prod.mk, of_decide_eq_true, id, Bool, Decidable.decide, Bool.true, Eq.refl, LE.le, Eq.mpr, congrArg, Finset, Finset.image, Finset.card_image_of_injective, Fintype.card and 10 more

    50 instances, coercions and auxiliary constants left out.

    Tactic trace: 16 steps

    Open to load the checked before-and-after goal states.

    problem usa2020_p4 :
        IsGreatest {N : ℕ | ∃ v : Fin 100 → ℕ × ℕ, Function.Injective v ∧
          N = (Finset.univ.filter fun p : Fin 100 × Fin 100 =>
            p.1 < p.2 ∧ |det (v p.1) (v p.2)| = 1).card} answer := by
    …

    Mentions: Usa2020P4.det, Usa2020P4.answer