Compfiles/Usa2022P1.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
22 declarations, 0 contain sorry, 0 declared as axioms
USA Mathematical Olympiad 2022, Problem 1
Let a and b be positive integers. The cells of an (a+b+1) × (a+b+1) grid are colored amber and bronze such that there are at least a² + ab - b amber cells and at least b² + ab - a bronze cells. Prove that it is possible to choose a amber cells and b bronze cells such that no two of the a + b chosen cells lie in the same row or column.
Imports (13)
- Mathlib.Data.Finset.Card
- Mathlib.Data.Finset.Prod
- Mathlib.Data.Finset.Sum
- Mathlib.Data.Fintype.Card
- Mathlib.Data.Fintype.Prod
- Mathlib.Combinatorics.Hall.Finite
- Mathlib.GroupTheory.Perm.Sign
- Mathlib.Logic.Equiv.Fintype
- Mathlib.Tactic.FinCases
- Mathlib.Tactic.GCongr
- Mathlib.Tactic.Ring
- Lean.Elab.Tactic.Omega
- ProblemExtraction
Imported by 1 file
- abbrev
Usa2022P1.Cellline 40 sourceno axioms what this means
Statement uses:
NatProof uses:
Prod,Fin - def
Usa2022P1.colorCountline 42 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat, Usa2022P1.Cell,Fin,OfNat.ofNat,Equiv.PermProof uses:
Finset.card,Finset.filter,Eq,Prod.mk,Finset.univ7 instances, coercions and auxiliary constants left out.
- def
Usa2022P1.rowsToCellsline 45 sourcestandard axioms: Quot.sound, propext what this means
Statement uses:
Nat,Equiv.Perm,Fin,Finset, Usa2022P1.CellProof uses:
Finset.map,Function.Embedding.mk,Prod.mk4 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2022P1.rowsToCells_cardline 51 sourcestandard axioms: Quot.sound, propext what this means
Statement uses:
Nat,Equiv.Perm,Fin,Finset,Eq,Finset.card, Usa2022P1.Cell, Usa2022P1.rowsToCellsProof uses:
of_eq_true,Eq.trans,True,congrFun',congrArg,Finset.card_map,Function.Embedding.mk,Prod.mk,eq_self4 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2022P1.mem_rowsToCellsline 55 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Equiv.Perm,Fin,Finset, Usa2022P1.Cell,Iff,Membership.mem, Usa2022P1.rowsToCells,Exists,And,Eq,Prod.mkProof uses:
Iff.intro,Function.Embedding,Function.Embedding.mk,Eq.mp,Finset.map,congrArg,propext,Finset.mem_map,Usa2022P1.rowsToCells.eq_1,Exists.intro,And.intro,Eq.symm,of_eq_true,Eq.trans,True,eq_true16 instances, coercions and auxiliary constants left out.
Tactic trace: 9 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2022P1.rowsToCells_colorline 65 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat, Usa2022P1.Cell,Fin,OfNat.ofNat,Equiv.Perm,Finset,Membership.mem,Eq,Prod.mk, Usa2022P1.rowsToCellsProof uses:
And,Exists,Eq.mp,congrArg,propext, Usa2022P1.mem_rowsToCells,Eq.symm15 instances, coercions and auxiliary constants left out.
Tactic trace: 4 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2022P1.rowsToCells_no_conflictline 74 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Equiv.Perm,Fin,Finset, Usa2022P1.Cell,Membership.mem,Union.union, Usa2022P1.rowsToCells,Ne,And,Prod.fst,Prod.sndProof uses:
Exists,Eq,Prod.mk,Or,Eq.mp,congrArg,propext,Finset.mem_union, Usa2022P1.mem_rowsToCells,Exists.intro,And.intro,of_eq_true,Eq.trans,True,congrFun',Prod,congr,eq_self,Equiv.injective,Eq.symm17 instances, coercions and auxiliary constants left out.
Tactic trace: 35 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2022P1.color_ne_zero_iff_eq_oneline 107 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Fin,OfNat.ofNat,Nat,Iff,Ne,EqProof uses:
List,List.Mem,List.finRange,HEq,Membership.mem,Finset,Fintype.elems,Fintype.complete,List.cons,List.Mem.head,Fin.mk,Nat.le_of_lt,Nat.le_refl,List.nil,of_eq_true,Eq.trans,False,True,congr,congrArgand 15 more23 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2022P1.colorCount_zero_add_oneline 110 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat, Usa2022P1.Cell,Fin,OfNat.ofNat,Equiv.Perm,Eq,HAdd.hAdd, Usa2022P1.colorCountProof uses:
Eq.mpr,Finset.card,Finset.filter,Prod.mk,Finset.univ,id,congrArg,Usa2022P1.colorCount.eq_1,Finset,Not,Finset.ext,of_eq_true,Iff,Membership.mem,Eq.trans,True,congr,And,congrFun',true_andand 7 more21 instances, coercions and auxiliary constants left out.
Tactic trace: 6 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2022P1.colorCount_one_le_iffline 121 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat, Usa2022P1.Cell,Fin,OfNat.ofNat,Equiv.Perm,LE.le,Iff, Usa2022P1.colorCount,HSub.hSubProof uses:
Iff.intro,Eq,HAdd.hAdd, Usa2022P1.colorCount_zero_add_one16 instances, coercions and auxiliary constants left out.
Tactic trace: 9 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2022P1.colorCount_swap_le_add_twoAdjacent permutations in the transposition graph differ in at most two rows line 133 sourceSource comment
Adjacent permutations in the transposition graph differ in at most two rows.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat, Usa2022P1.Cell,Fin,OfNat.ofNat,Equiv.Perm,LE.le, Usa2022P1.colorCount,HMul.hMul,Equiv.swap,HAdd.hAddProof uses:
id,Finset,Finset.filter,Eq,Prod.mk,Finset.univ,Union.union,Insert.insert,Singleton.singleton,Membership.mem,dite,of_eq_true,Eq.trans,Or,True,congr,congrArg,Finset.union_insert,Finset.union_singleton,eq_selfand 18 more41 instances, coercions and auxiliary constants left out.
Tactic trace: 21 steps
Open to load the checked before-and-after goal states.
lemma colorCount_swap_le_add_two (color : Cell N → Fin 2) (p : Equiv.Perm (Fin N)) (x y : Fin N) : colorCount color 0 (p * Equiv.swap x y) ≤ colorCount color 0 p + 2 := by …Mentions: Usa2022P1.Cell, Usa2022P1.colorCount
- lemma
Usa2022P1.colorCount_swap_ge_sub_twoline 157 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat, Usa2022P1.Cell,Fin,OfNat.ofNat,Equiv.Perm,LE.le, Usa2022P1.colorCount,HAdd.hAdd,HMul.hMul,Equiv.swapProof uses:
Eq.mp,congrFun',congrArg,Eq.trans,mul_assoc,Equiv.swap_mul_self,mul_one, Usa2022P1.colorCount_swap_le_add_two26 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2022P1.exists_transversal_with_exact_or_succ_color_countWalking from a color-rich transversal to a color-poor one gives count a or a+1 line 164 sourceSource comment
Walking from a color-rich transversal to a color-poor one gives count a or a+1.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat, Usa2022P1.Cell,Fin,OfNat.ofNat,Equiv.Perm,LE.le, Usa2022P1.colorCount,HAdd.hAdd,Exists,Or,EqProof uses:
HMul.hMul,Equiv,Equiv.symm,Equiv.Perm.ext,Fin.ext,of_eq_true,Eq.trans,True,congrFun',congrArg,Equiv.apply_symm_apply,eq_self,Eq.mpr,id,GE.ge,Equiv.Perm.swap_induction_on',Exists.intro,Eq.mp,mul_one,Neand 5 more35 instances, coercions and auxiliary constants left out.
Tactic trace: 29 steps
Open to load the checked before-and-after goal states.
lemma exists_transversal_with_exact_or_succ_color_count (color : Cell N → Fin 2) (a : ℕ) (p q : Equiv.Perm (Fin N)) (hp : a ≤ colorCount color 0 p) (hq : colorCount color 0 q ≤ a + 1) : ∃ r : Equiv.Perm (Fin N), colorCount color 0 r = a ∨ colorCount color 0 r = a + 1 := by …Mentions: Usa2022P1.Cell, Usa2022P1.colorCount
- def
Usa2022P1.neighborColsColumns containing a good cell in one of the rows inRline 198 sourceSource documentation
Columns containing a good cell in one of the rows in
R.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat, Usa2022P1.Cell,DecidablePred,Finset,FinProof uses:
Finset.filter,Exists,And,Membership.mem,Prod.mk,Finset.univ7 instances, coercions and auxiliary constants left out.
def neighborCols (good : Cell N → Prop) [DecidablePred good] (R : Finset (Fin N)) : Finset (Fin N) := …Mentions: Usa2022P1.Cell
- def
Usa2022P1.dummyColsThe dummy columns used to turn "at leastkreal matches" into a full matching line 203 sourceSource documentation
The dummy columns used to turn "at least
kreal matches" into a full matching.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Finset,Sum,Fin,HSub.hSubProof uses:
Finset.map,Function.Embedding.inr,Finset.univ5 instances, coercions and auxiliary constants left out.
def dummyCols (N k : ℕ) : Finset (Fin N ⊕ Fin (N - k)) := …
- def
Usa2022P1.hallTargetsHall targets for rowr: good real columns, plus all dummy columns line 207 sourceSource documentation
Hall targets for row
r: good real columns, plus all dummy columns.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat, Usa2022P1.Cell,DecidablePred,Fin,Finset,Sum,HSub.hSubProof uses:
Finset.disjSum,Finset.filter,Prod.mk,Finset.univ5 instances, coercions and auxiliary constants left out.
def hallTargets (good : Cell N → Prop) [DecidablePred good] (k : ℕ) (r : Fin N) : Finset (Fin N ⊕ Fin (N - k)) := …Mentions: Usa2022P1.Cell
- lemma
Usa2022P1.line_count_le_of_hall_failureIf Hall fails on rowsR, then the rows outsideRtogether with the neighboring columns ofRform at mostk - 1covering lines line 215 sourceSource documentation
If Hall fails on rows
R, then the rows outsideRtogether with the neighboring columns ofRform at mostk - 1covering lines.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat, Usa2022P1.Cell,DecidablePred,Finset,Fin,LT.lt,Finset.card,Sum,HSub.hSub,Finset.biUnion, Usa2022P1.hallTargets,LE.le,HAdd.hAdd,SDiff.sdiff,Finset.univ, Usa2022P1.neighborCols,OfNat.ofNatProof uses:
Finset.Nonempty,Iff.mp,Finset.card_pos,Eq.mp,Fintype.card,congrArg,Fintype.card_fin,Finset.card_le_univ, Usa2022P1.dummyCols,Membership.mem,Eq.mpr,Exists,And,id,Eq,propext,Finset.mem_biUnion,Function.Embedding,Function.Embedding.inr,Finset.mapand 31 more50 instances, coercions and auxiliary constants left out.
Tactic trace: 37 steps
Open to load the checked before-and-after goal states.
lemma line_count_le_of_hall_failure (good : Cell N → Prop) [DecidablePred good] {k : ℕ} {R : Finset (Fin N)} (hfail : (R.biUnion (hallTargets good k)).card < R.card) : ((univ : Finset (Fin N)) \ R).card + (neighborCols good R).card ≤ k - 1 := by …Mentions: Usa2022P1.Cell, Usa2022P1.hallTargets, Usa2022P1.neighborCols
- lemma
Usa2022P1.good_cells_card_le_of_neighbor_line_countAny good cells covered by at mostk - 1rows/columns number at most(k - 1) * Nline 272 sourceSource documentation
Any good cells covered by at most
k - 1rows/columns number at most(k - 1) * N.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat, Usa2022P1.Cell,DecidablePred,Finset,Fin,LE.le,HAdd.hAdd,Finset.card,SDiff.sdiff,Finset.univ, Usa2022P1.neighborCols,HSub.hSub,OfNat.ofNat,Finset.filter,HMul.hMulProof uses:
Union.union,SProd.sprod,Prod,Membership.mem,Prod.mk,dite,Eq.mpr,Exists,And,id,Eq,Eq.trans,True,congrFun',congrArg,true_and,Exists.intro,And.intro,Eq.mp,of_eq_trueand 42 more66 instances, coercions and auxiliary constants left out.
Tactic trace: 22 steps
Open to load the checked before-and-after goal states.
lemma good_cells_card_le_of_neighbor_line_count (good : Cell N → Prop) [DecidablePred good] {k : ℕ} (R : Finset (Fin N)) (hline : ((univ : Finset (Fin N)) \ R).card + (neighborCols good R).card ≤ k - 1) : (univ.filter good).card ≤ (k - 1) * N := by …Mentions: Usa2022P1.Cell, Usa2022P1.neighborCols
- lemma
Usa2022P1.exists_transversal_with_many_good_cellsHall step: more than (k-1)N good cells force a transversal with k good cells line 308 sourceSource comment
Hall step: more than (k-1)N good cells force a transversal with k good cells.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat, Usa2022P1.Cell,DecidablePred,LE.le,LT.lt,HMul.hMul,HSub.hSub,OfNat.ofNat,Finset.card,Finset.filter,Finset.univ,Fin,Exists,Equiv.Perm,Prod.mkProof uses:
Finset,Sum, Usa2022P1.dummyCols, Usa2022P1.hallTargets,Finset.biUnion,Decidable.byContradiction,Not,Nat.lt_of_not_ge,HAdd.hAdd,SDiff.sdiff, Usa2022P1.neighborCols, Usa2022P1.line_count_le_of_hall_failure, Usa2022P1.good_cells_card_le_of_neighbor_line_count,not_lt_of_ge,And,Function.Injective,Membership.mem,Iff.mp,Finset.all_card_le_biUnion_card_iff_existsInjective',Eqand 47 more58 instances, coercions and auxiliary constants left out.
Tactic trace: 60 steps
Open to load the checked before-and-after goal states.
lemma exists_transversal_with_many_good_cells (good : Cell N → Prop) [DecidablePred good] {k : ℕ} (hkN : k ≤ N) (hcard : (k - 1) * N < (univ.filter good).card) : ∃ p : Equiv.Perm (Fin N), k ≤ (univ.filter fun r : Fin N => good (r, p r)).card := by …Mentions: Usa2022P1.Cell
- lemma
Usa2022P1.exists_intermediate_transversal_of_card_boundsThe density hypotheses give a transversal with exactlyaora+1amber cells line 385 sourceSource documentation
The density hypotheses give a transversal with exactly
aora+1amber cells.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,OfNat.ofNat, Usa2022P1.Cell,HAdd.hAdd,Fin,LE.le,HSub.hSub,HPow.hPow,HMul.hMul,Fintype.card,Subtype,Eq,Exists,Equiv.Perm,Or, Usa2022P1.colorCountProof uses:
Finset.card,Finset.filter,Finset.univ,Eq.mpr,id,Eq.mp,Eq.trans,congrArg,Fintype.card_subtype,Nat.casesAuxOn,Nat.succ,Nat.le,HEq,False.elim,Nat.le.refl,noConfusion_of_Nat,Nat.ctorIdx,Nat.le.step,Eq.refl,HEq.refland 51 more87 instances, coercions and auxiliary constants left out.
Tactic trace: 37 steps
Open to load the checked before-and-after goal states.
lemma exists_intermediate_transversal_of_card_bounds (a b : ℕ) (ha : 0 < a) (hb : 0 < b) (color : Cell (a + b + 1) → Fin 2) (c0 : a ^ 2 + a * b - b ≤ Fintype.card {s // color s = 0}) (c1 : b ^ 2 + a * b - a ≤ Fintype.card {s // color s = 1}) : ∃ p : Equiv.Perm (Fin (a + b + 1)), colorCount color 0 p = a ∨ colorCount color 0 p = a + 1 := by …Mentions: Usa2022P1.Cell, Usa2022P1.colorCount
- lemma
Usa2022P1.exists_cells_of_intermediate_transversalA transversal withaora+1amber cells contains the required amber/bronze choices line 442 sourceSource documentation
A transversal with
aora+1amber cells contains the required amber/bronze choices.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat, Usa2022P1.Cell,HAdd.hAdd,OfNat.ofNat,Fin,Equiv.Perm,Or,Eq, Usa2022P1.colorCount,Exists,Finset,And,Finset.card,Membership.mem,Union.union,Ne,Prod.fst,Prod.sndProof uses:
Finset.filter,Prod.mk,Finset.univ,id, Usa2022P1.colorCount_zero_add_one,LE.le,Finset.exists_subset_card_eq,Exists.intro, Usa2022P1.rowsToCells,And.intro,of_eq_true,Eq.trans,True,congrFun',congrArg, Usa2022P1.rowsToCells_card,eq_self, Usa2022P1.rowsToCells_color,Eq.mp,true_andand 1 more36 instances, coercions and auxiliary constants left out.
Tactic trace: 51 steps
Open to load the checked before-and-after goal states.
lemma exists_cells_of_intermediate_transversal {a b : ℕ} (color : Cell (a + b + 1) → Fin 2) (p : Equiv.Perm (Fin (a + b + 1))) (hp : colorCount color 0 p = a ∨ colorCount color 0 p = a + 1) : ∃ A B : Finset (Cell (a + b + 1)), A.card = a ∧ B.card = b ∧ (∀ x ∈ A, color x = 0) ∧ (∀ y ∈ B, color y = 1) ∧ ∀ x ∈ A ∪ B, ∀ y ∈ A ∪ B, x ≠ y → x.fst ≠ y.fst ∧ x.snd ≠ y.snd := by …Mentions: Usa2022P1.Cell, Usa2022P1.colorCount
- problem
Usa2022P1.usa2022_p1line 493 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LT.lt,OfNat.ofNat,Prod,Fin,HAdd.hAdd,LE.le,HSub.hSub,HPow.hPow,HMul.hMul,Fintype.card,Subtype,Eq,Exists,Finset,And,Finset.card,Membership.mem,Union.union,Neand 2 moreProof uses:
Equiv.Perm,Or, Usa2022P1.colorCount, Usa2022P1.exists_intermediate_transversal_of_card_bounds, Usa2022P1.exists_cells_of_intermediate_transversal47 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.