Compfiles/Usa2017P4.lean
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
24 declarations, 0 contain sorry, 0 declared as axioms
USA Mathematical Olympiad 2017, Problem 4
Let P₁, P₂, ..., P_{2n} be 2n distinct points on the unit circle x² + y² = 1, other than (1, 0). Each point is colored either red or blue, with exactly n red points and n blue points. Let R₁, R₂, ..., Rₙ be any ordering of the red points. Let B₁ be the nearest blue point to R₁ traveling counterclockwise around the circle starting from R₁. Then let B₂ be the nearest of the remaining blue points to R₂ traveling counterclockwise around the circle from R₂, and so on, until we have labeled all of the blue points B₁, ..., Bₙ. Show that the number of counterclockwise arcs of the form Rᵢ → Bᵢ that contain the point (1, 0) is independent of the way we chose the ordering R₁, ..., Rₙ of the red points.
Imported by 1 file
- def
Usa2017P4.shiftShiftpforward (counterclockwise) bydpositions, cyclically line 49 sourceSource documentation
Shift
pforward (counterclockwise) bydpositions, cyclically.no axioms what this means
Statement uses:
Nat,FinProof uses:
Fin.mk,HMod.hMod,HAdd.hAdd6 instances, coercions and auxiliary constants left out.
def shift (p : Fin m) (d : ℕ) : Fin m := …
- def
Usa2017P4.cdistThe cyclic (counterclockwise) distance fromatob; it is0iffa = bline 53 sourceSource documentation
The cyclic (counterclockwise) distance from
atob; it is0iffa = b.no axioms what this means
Statement uses:
Nat,FinProof uses:
HMod.hMod,HSub.hSub,HAdd.hAdd7 instances, coercions and auxiliary constants left out.
def cdist (a b : Fin m) : ℕ := (b.val + m - a.val) % m
- def
Usa2017P4.wrapwrap r bis1when the counterclockwise arc fromrtobpasses through the cut point (1, 0), and0otherwise line 57 sourceSource documentation
wrap r bis1when the counterclockwise arc fromrtobpasses through the cut point (1, 0), and0otherwise.no axioms what this means
Statement uses:
Nat,FinProof uses:
ite,LT.lt,OfNat.ofNat4 instances, coercions and auxiliary constants left out.
def wrap (r b : Fin m) : ℕ := if b.val < r.val then 1 else 0 …
- def
Usa2017P4.availThe set of blue points that have not been used yet line 66 sourceSource documentation
The set of blue points that have not been used yet.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,FinsetProof uses:
Finset.filter,And,Eq,Bool.false,Not,Membership.mem,Finset.univ8 instances, coercions and auxiliary constants left out.
def avail (used : Finset (Fin m)) : Finset (Fin m) := …
- def
Usa2017P4.nbThe nearest available blue point tor, going counterclockwise fromr(if one exists; otherwise, arbitrarily,ritself) line 71 sourceSource documentation
The nearest available blue point to
r, going counterclockwise fromr(if one exists; otherwise, arbitrarily,ritself).standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,FinsetProof uses:
dite,Finset.Nonempty, Usa2017P4.avail,Classical.choose,And,Membership.mem,LE.le, Usa2017P4.cdist,Not11 instances, coercions and auxiliary constants left out.
noncomputable def nb (used : Finset (Fin m)) (r : Fin m) : Fin m := …
- def
Usa2017P4.wrapsThe total number of arcs through (1, 0) produced when the red points listed inlare processed in order, starting from the setusedof already-taken blue points line 79 sourceSource documentation
The total number of arcs through (1, 0) produced when the red points listed in
lare processed in order, starting from the setusedof already-taken blue points.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,List,Finset2 instances, coercions and auxiliary constants left out.
noncomputable def wraps : List (Fin m) → Finset (Fin m) → ℕ | [], _ => 0 | (r :: rs), used => wrap r (nb c used r) + wraps rs (insert (nb c used r) used) end Process snip begin section GeometryLemmas variable {m : ℕ}Mentions: Usa2017P4.wrap, Usa2017P4.nb
- lemma
Usa2017P4.cdist_ifline 91 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Eq, Usa2017P4.cdist,ite,LE.le,HSub.hSub,HAdd.hAddProof uses:
id,dite,HMod.hMod,Eq.mpr,congrArg,ite_eq_left,Nat.add_mod_right,Nat.mod_eq_of_lt,Eq.refl,Not,ite_eq_right19 instances, coercions and auxiliary constants left out.
Tactic trace: 10 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2017P4.shift_cdistline 99 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Eq, Usa2017P4.shift, Usa2017P4.cdistProof uses:
Fin.ext,id,LE.le,Or,HMod.hMod,HAdd.hAdd,HSub.hSub,le_total,Eq.mpr,congrArg,Nat.add_mod_right,Nat.mod_eq_of_lt,Fin.isLt,Eq.refl,LT.lt,eq_or_lt_of_le,OfNat.ofNat,Nat.mod_self,Nat.add_zero21 instances, coercions and auxiliary constants left out.
Tactic trace: 24 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2017P4.cdist_left_injline 116 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Eq, Usa2017P4.cdistProof uses:
Eq.mpr, Usa2017P4.shift,id,congrArg,Eq.symm, Usa2017P4.shift_cdist,Eq.reflTactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2017P4.cdist_posline 119 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Ne,LT.lt,OfNat.ofNat, Usa2017P4.cdistProof uses:
Eq.mpr,ite,LE.le,HSub.hSub,HAdd.hAdd,id,Eq,congrArg, Usa2017P4.cdist_if,Fin.ext,dite,ite_eq_left,Not,ite_eq_right13 instances, coercions and auxiliary constants left out.
Tactic trace: 4 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2017P4.cdist_add_of_ltline 124 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,LT.lt, Usa2017P4.cdist,Eq,HAdd.hAddProof uses:
Eq.mpr,ite,LE.le,HSub.hSub,id,congr,congrArg, Usa2017P4.cdist_if,Fin.isLt,dite,congrFun',ite_eq_left,Eq.mp,Not,ite_eq_right19 instances, coercions and auxiliary constants left out.
Tactic trace: 6 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2017P4.arc_rotateline 130 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Ne,LT.lt, Usa2017P4.cdistProof uses:
Eq.mpr,ite,LE.le,HSub.hSub,HAdd.hAdd,id,Eq,congr,congrArg, Usa2017P4.cdist_if,Fin.isLt,Fin.ext,dite,congrFun',ite_eq_left,Not,Eq.mp,ite_eq_right21 instances, coercions and auxiliary constants left out.
Tactic trace: 7 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2017P4.wrap_eq_of_mem_arcKey fact for the swapping argument: ifplies on the open counterclockwise arc fromytox, thenwrap p yandwrap p xdiffer by an amount that does not depend onpline 140 sourceSource documentation
Key fact for the swapping argument: if
plies on the open counterclockwise arc fromytox, thenwrap p yandwrap p xdiffer by an amount that does not depend onp.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Ne,LT.lt, Usa2017P4.cdist,Eq, Usa2017P4.wrap,HAdd.hAdd,ite,OfNat.ofNatProof uses: Usa2017P4.cdist_pos,
Ne.symm,Fin.isLt,rfl,Eq.mpr,id,congrArg,dite,congrFun',ite_eq_left,LE.le,Eq.mp,HSub.hSub, Usa2017P4.cdist_if,congr,Not,ite_eq_right,False,Eq.trans,eq_false'and 3 more32 instances, coercions and auxiliary constants left out.
Tactic trace: 10 steps
Open to load the checked before-and-after goal states.
lemma wrap_eq_of_mem_arc {y x p : Fin m} (hpy : p ≠ y) (h : cdist y p < cdist y x) : wrap p y = wrap p x + (if y.val < x.val then 1 else 0) := by …Mentions: h, Usa2017P4.cdist, Usa2017P4.wrap
- lemma
Usa2017P4.mem_availline 156 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Finset,Iff,Membership.mem, Usa2017P4.avail,And,Eq,Bool.false,NotProof uses:
of_eq_true,Eq.trans,True,congrFun',congrArg,Finset.filter,Finset.univ,true_and,iff_self12 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2017P4.nb_eq_chooseline 160 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Finset,Finset.Nonempty, Usa2017P4.avail,Eq, Usa2017P4.nb,Classical.choose,And,Membership.mem,LE.le, Usa2017P4.cdist,Finset.exists_min_imageProof uses:
dite_eq_left,Not20 instances, coercions and auxiliary constants left out.
- lemma
Usa2017P4.nb_memline 164 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Finset,Finset.Nonempty, Usa2017P4.avail,Membership.mem, Usa2017P4.nbProof uses:
Eq.mpr,Classical.choose,And,LE.le, Usa2017P4.cdist,Finset.exists_min_image,id,Eq,congrArg, Usa2017P4.nb_eq_choose,And.left,Classical.choose_spec11 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2017P4.nb_minline 169 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Finset,Finset.Nonempty, Usa2017P4.avail,Membership.mem,LE.le, Usa2017P4.cdist, Usa2017P4.nbProof uses:
Eq.mpr,Classical.choose,And,Finset.exists_min_image,id,Eq,congrArg, Usa2017P4.nb_eq_choose,And.right,Classical.choose_spec13 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2017P4.nb_eq_ofUniqueness of the nearest available blue point line 176 sourceSource documentation
Uniqueness of the nearest available blue point.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Finset,Finset.Nonempty, Usa2017P4.avail,Membership.mem,LE.le, Usa2017P4.cdist,Eq, Usa2017P4.nbProof uses: Usa2017P4.cdist_left_inj,
le_antisymm, Usa2017P4.nb_min, Usa2017P4.nb_mem7 instances, coercions and auxiliary constants left out.
lemma nb_eq_of {used : Finset (Fin m)} {r b : Fin m} (h : (avail c used).Nonempty) (hb : b ∈ avail c used) (hmin : ∀ q ∈ avail c used, cdist r b ≤ cdist r q) : nb c used r = b := …Mentions: h, Usa2017P4.avail, Usa2017P4.cdist, Usa2017P4.nb
- lemma
Usa2017P4.avail_insertline 181 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Finset,Eq, Usa2017P4.avail,Insert.insert,Finset.eraseProof uses:
Finset.ext,Eq.mpr,Iff,Membership.mem,And,Bool.false,Not,Ne,id,congr,congrArg,Eq.trans,Or,Iff.intro,And.intro11 instances, coercions and auxiliary constants left out.
Tactic trace: 3 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2017P4.card_avail_insertline 187 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Finset,Membership.mem, Usa2017P4.avail,Eq,Finset.card,Insert.insert,HSub.hSub,OfNat.ofNatProof uses:
Eq.mpr,Finset.erase,id,congrArg, Usa2017P4.avail_insert,Finset.card_erase_of_mem,Eq.refl14 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2017P4.wraps_consline 191 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,List,Finset,Eq, Usa2017P4.wraps,List.cons,HAdd.hAdd, Usa2017P4.wrap, Usa2017P4.nb,Insert.insertProof uses:
rfl4 instances, coercions and auxiliary constants left out.
- lemma
Usa2017P4.wraps_swap_pairThe heart of the proof: processing two consecutive red points in either order produces the same number of arcs through (1, 0) and the same set of used blue points line 197 sourceSource documentation
The heart of the proof: processing two consecutive red points in either order produces the same number of arcs through (1, 0) and the same set of used blue points.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,Eq,Bool.true,Finset,LE.le,OfNat.ofNat,Finset.card, Usa2017P4.avail,And,HAdd.hAdd, Usa2017P4.wrap, Usa2017P4.nb,Insert.insertProof uses:
Finset.Nonempty,Iff.mp,LT.lt,Finset.card_pos,Membership.mem, Usa2017P4.nb_mem,Eq.mpr,id,congrArg,Eq.symm,propext,HSub.hSub, Usa2017P4.card_avail_insert,Ne, Usa2017P4.cdist,lt_of_le_of_ne, Usa2017P4.nb_min, Usa2017P4.cdist_left_inj,dite,Finset.eraseand 23 more25 instances, coercions and auxiliary constants left out.
Tactic trace: 96 steps
Open to load the checked before-and-after goal states.
lemma wraps_swap_pair {r r' : Fin m} (hr : c r = true) (hr' : c r' = true) {used : Finset (Fin m)} (hcard : 2 ≤ (avail c used).card) : wrap r (nb c used r) + wrap r' (nb c (insert (nb c used r) used) r') = wrap r' (nb c used r') + wrap r (nb c (insert (nb c used r') used) r) ∧ insert (nb c (insert (nb c used r) used) r') (insert (nb c used r) used) = insert (nb c (insert (nb c used r') used) r) (insert (nb c used r') used) := by …Mentions: Usa2017P4.avail, Usa2017P4.wrap, Usa2017P4.nb
- lemma
Usa2017P4.wraps_permThe wrap count is invariant under permuting the processing order of the red points (given that enough blue points remain available at every step) line 329 sourceSource documentation
The wrap count is invariant under permuting the processing order of the red points (given that enough blue points remain available at every step).
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Fin,Bool,List,List.Perm,Membership.mem,Eq,Bool.true,Finset,LE.le,List.length,Finset.card, Usa2017P4.avail, Usa2017P4.wrapsProof uses:
List.Perm.rec,List.nil,Eq.refl,List.cons,LT.lt,OfNat.ofNat,HAdd.hAdd,rfl, Usa2017P4.nb, Usa2017P4.nb_mem,Iff.mp,Finset.Nonempty,Finset.card_pos,Eq.mpr, Usa2017P4.wrap,Insert.insert,id,congrArg, Usa2017P4.wraps_cons,HSub.hSuband 17 more20 instances, coercions and auxiliary constants left out.
Tactic trace: 32 steps
Open to load the checked before-and-after goal states.
lemma wraps_perm {l₁ l₂ : List (Fin m)} (h : List.Perm l₁ l₂) : (∀ r ∈ l₁, c r = true) → ∀ used : Finset (Fin m), l₁.length ≤ (avail c used).card → wraps c l₁ used = wraps c l₂ used := by …Mentions: h, Usa2017P4.avail, Usa2017P4.wraps
- problem
Usa2017P4.usa2017_p4USAMO 2017 Problem 4 line 370 sourceSource documentation
USAMO 2017 Problem 4. With the notation introduced above (points recorded in counterclockwise order starting from (1, 0),
true= red), the number of counterclockwise arcsRᵢ → Bᵢcontaining (1, 0) does not depend on the orderingR₁, ..., Rₙof the red points.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,OfNat.ofNat,Fin,HMul.hMul,Bool,Eq,Finset.card,Finset.filter,Bool.true,Finset.univ,List,List.Nodup,List.length,Membership.mem, Usa2017P4.wraps,EmptyCollection.emptyCollection,FinsetProof uses:
List.toFinset,Finset.eq_of_subset_of_card_le,Iff.mpr,And,Finset.mem_filter,And.intro,Finset.mem_univ,Eq.mp,congrArg,propext,List.mem_toFinset,Eq.mpr,LE.le,id,List.toFinset_card_of_nodup,le_refl,Iff,Eq.symm,Iff.rfl,List.Permand 24 more29 instances, coercions and auxiliary constants left out.
Tactic trace: 35 steps
Open to load the checked before-and-after goal states.
problem usa2017_p4 (n : ℕ) (_hn : 0 < n) (c : Fin (2 * n) → Bool) (hred : (Finset.univ.filter (fun i => c i = true)).card = n) (l₁ l₂ : List (Fin (2 * n))) (hnod₁ : l₁.Nodup) (hlen₁ : l₁.length = n) (hred₁ : ∀ r ∈ l₁, c r = true) (hnod₂ : l₂.Nodup) (hlen₂ : l₂.length = n) (hred₂ : ∀ r ∈ l₂, c r = true) : wraps c l₁ ∅ = wraps c l₂ ∅ := by …Mentions: Usa2017P4.wraps