Compfiles/Usa2019P4.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
23 declarations, 0 contain sorry, 0 declared as axioms
USA Mathematical Olympiad 2019, Problem 4
Let n be a nonnegative integer. Determine the number of ways to choose sets Sᵢⱼ ⊆ {1, 2, ..., 2n}, for all 0 ≤ i ≤ n and 0 ≤ j ≤ n (not necessarily distinct), such that
• |Sᵢⱼ| = i + j, and • Sᵢⱼ ⊆ Sₖₗ if 0 ≤ i ≤ k ≤ n and 0 ≤ j ≤ l ≤ n.
Imports (5)
Imported by 1 file
- abbrev
Usa2019P4.CellThe grid cells indexing the setsSᵢⱼline 37 sourceSource documentation
The grid cells indexing the sets
Sᵢⱼ.no axioms what this means
Statement uses:
NatProof uses:
Prod,Fin,HAdd.hAdd,OfNat.ofNat3 instances, coercions and auxiliary constants left out.
abbrev Cell (n : ℕ) := Fin (n + 1) × Fin (n + 1)
- def
Usa2019P4.targetThe cardinality required at cell(i, j)line 40 sourceSource documentation
The cardinality required at cell
(i, j).no axioms what this means
Statement uses:
Nat, Usa2019P4.CellProof uses:
HAdd.hAdd,OfNat.ofNat,Prod.fst,Fin,Prod.snd4 instances, coercions and auxiliary constants left out.
def target {n : ℕ} (c : Cell n) : ℕ := c.1.val + c.2.valMentions: Usa2019P4.Cell
- def
Usa2019P4.FillingsDocumented declaration: Fillings line 45 sourceSource documentation
Partial configurations on a set
Dof cells: the cardinality and monotonicity conditions hold onD, and the value is∅offD(the latter condition keeps the ambient function type finite).standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Set, Usa2019P4.Cell,Finset,Fin,HMul.hMul,OfNat.ofNatProof uses:
Set.ofPred,And,Membership.mem,Eq,Finset.card, Usa2019P4.target,LE.le,HAdd.hAdd,Not,EmptyCollection.emptyCollection15 instances, coercions and auxiliary constants left out.
def Fillings (n : ℕ) (D : Set (Cell n)) : Set (Cell n → Finset (Fin (2 * n))) := …
Mentions: Usa2019P4.Cell
- def
Usa2019P4.colZeroThe cells of column0in rows≤ jline 51 sourceSource documentation
The cells of column
0in rows≤ j.no axioms what this means
Statement uses:
Nat,Set, Usa2019P4.CellProof uses:
Set.ofPred,And,Eq,HAdd.hAdd,OfNat.ofNat,Prod.fst,Fin,LE.le,Prod.snd5 instances, coercions and auxiliary constants left out.
def colZero (n j : ℕ) : Set (Cell n) := {c | c.1.val = 0 ∧ c.2.val ≤ j}Mentions: Usa2019P4.Cell
- def
Usa2019P4.topRowThe cells of rownin columns1..iline 54 sourceSource documentation
The cells of row
nin columns1..i.no axioms what this means
Statement uses:
Nat,Set, Usa2019P4.CellProof uses:
Set.ofPred,And,LE.le,OfNat.ofNat,HAdd.hAdd,Prod.fst,Fin,Eq,Prod.snd5 instances, coercions and auxiliary constants left out.
def topRow (n i : ℕ) : Set (Cell n) := {c | 1 ≤ c.1.val ∧ c.1.val ≤ i ∧ c.2.val = n}Mentions: Usa2019P4.Cell
- def
Usa2019P4.intColsThe interior cells (rows< n) in columns1..iline 57 sourceSource documentation
The interior cells (rows
< n) in columns1..i.no axioms what this means
Statement uses:
Nat,Set, Usa2019P4.CellProof uses:
Set.ofPred,And,LE.le,OfNat.ofNat,HAdd.hAdd,Prod.fst,Fin,LT.lt,Prod.snd6 instances, coercions and auxiliary constants left out.
def intCols (n i : ℕ) : Set (Cell n) := {c | 1 ≤ c.1.val ∧ c.1.val ≤ i ∧ c.2.val < n}Mentions: Usa2019P4.Cell
- def
Usa2019P4.colPartThe interior cells of columnkin rows `n - r line 60 sourceSource documentation
The interior cells of column
kin rowsn - r .. n - 1.no axioms what this means
Statement uses:
Nat,Set, Usa2019P4.CellProof uses:
Set.ofPred,And,Eq,HAdd.hAdd,OfNat.ofNat,Prod.fst,Fin,LE.le,HSub.hSub,Prod.snd,LT.lt8 instances, coercions and auxiliary constants left out.
def colPart (n k r : ℕ) : Set (Cell n) := {c | c.1.val = k ∧ n - r ≤ c.2.val ∧ c.2.val < n}Mentions: Usa2019P4.Cell
- lemma
Usa2019P4.cell_extCell equality in terms of coordinate values line 63 sourceSource documentation
Cell equality in terms of coordinate values.
no axioms what this means
Statement uses:
Nat, Usa2019P4.Cell,LT.lt,HAdd.hAdd,OfNat.ofNat,Iff,Eq,Prod.mk,Fin,Fin.mk,And,Prod.fst,Prod.sndProof uses:
Iff.intro,Eq.mpr,id,congrArg,And.intro,rfl,Iff.mpr,Prod,Prod.ext_iff,Fin.ext_iff11 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.
lemma cell_ext {n : ℕ} {c : Cell n} {a b : ℕ} {ha : a < n + 1} {hb : b < n + 1} : c = (⟨a, ha⟩, ⟨b, hb⟩) ↔ c.1.val = a ∧ c.2.val = b := …Mentions: Usa2019P4.Cell
- lemma
Usa2019P4.fillings_emptyThe only filling of the empty set of cells line 69 sourceSource documentation
The only filling of the empty set of cells.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq,Set, Usa2019P4.Cell,Finset,Fin,HMul.hMul,OfNat.ofNat, Usa2019P4.Fillings,EmptyCollection.emptyCollection,Singleton.singletonProof uses:
Set.ext,of_eq_true,Iff,Membership.mem,Eq.trans,HAdd.hAdd,Prod.mk,True,congr,congrArg,congrFun',Set.ofPred,And,Finset.card, Usa2019P4.target,LE.le,Not,funext,forall_congr,Falseand 7 more29 instances, coercions and auxiliary constants left out.
Tactic trace: 2 steps
Open to load the checked before-and-after goal states.
lemma fillings_empty (n : ℕ) : Fillings n (∅ : Set (Cell n)) = {fun _ ↦ ∅} := by …Mentions: Usa2019P4.Fillings, Usa2019P4.Cell
- lemma
Usa2019P4.restrict_memRestricting a filling ofinsert s Dto a filling ofDby resetting the value atsto∅line 75 sourceSource documentation
Restricting a filling of
insert s Dto a filling ofDby resetting the value atsto∅.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Set, Usa2019P4.Cell,Not,Membership.mem,Finset,Fin,HMul.hMul,OfNat.ofNat, Usa2019P4.Fillings,Insert.insert,Function.update,HAdd.hAdd,EmptyCollection.emptyCollectionProof uses:
Eq,Finset.card, Usa2019P4.target,And,LE.le,And.intro,Eq.mpr,id,congrArg,Function.update_of_ne,ne_of_mem_of_not_mem,Set.mem_insert_of_mem,dite,Function.update_self,Set.mem_of_mem_insert_of_ne26 instances, coercions and auxiliary constants left out.
Tactic trace: 19 steps
Open to load the checked before-and-after goal states.
lemma restrict_mem {n : ℕ} {D : Set (Cell n)} {s : Cell n} (hs : s ∉ D) {S : Cell n → Finset (Fin (2 * n))} (hS : S ∈ Fillings n (insert s D)) : Function.update S s ∅ ∈ Fillings n D := by …Mentions: Usa2019P4.Cell, S, Usa2019P4.Fillings
- lemma
Usa2019P4.extend_memExtending a filling ofDby an admissible valueXatsline 94 sourceSource documentation
Extending a filling of
Dby an admissible valueXats.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Set, Usa2019P4.Cell,Not,Membership.mem,Finset,Fin,HMul.hMul,OfNat.ofNat, Usa2019P4.Fillings,LE.le,HAdd.hAdd,Eq,Finset.card, Usa2019P4.target,Insert.insert,Function.updateProof uses:
And.intro,And,EmptyCollection.emptyCollection,Or,Iff.mp,Set.mem_insert_iff,Eq.mpr,id,congrArg,Function.update_self,Function.update_of_ne,ne_of_mem_of_not_mem,And.left,Finset.Subset.refl,Finset.Subset.trans,And.right,Ne,Eq.mp,Set.mem_insert,Set.mem_insert_of_mem31 instances, coercions and auxiliary constants left out.
Tactic trace: 33 steps
Open to load the checked before-and-after goal states.
lemma extend_mem {n : ℕ} {D : Set (Cell n)} {s : Cell n} (hs : s ∉ D) {A C : (Cell n → Finset (Fin (2 * n))) → Finset (Fin (2 * n))} (hlo : ∀ f ∈ Fillings n D, ∀ d ∈ D, d ≤ s → f d ⊆ A f) (hhi : ∀ f ∈ Fillings n D, ∀ d ∈ D, s ≤ d → C f ⊆ f d) {f : Cell n → Finset (Fin (2 * n))} (hf : f ∈ Fillings n D) {X : Finset (Fin (2 * n))} (hXA : A f ⊆ X) (hXC : X ⊆ C f) (hXt : X.card = target s) : Function.update f s X ∈ Fillings n (insert s D) := by …Mentions: Usa2019P4.Cell, f, Usa2019P4.Fillings, Usa2019P4.target
- lemma
Usa2019P4.card_betweenThe sets betweenAandCwith cardinalitytare counted by a binomial coefficient line 128 sourceSource documentation
The sets between
AandCwith cardinalitytare counted by a binomial coefficient.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
DecidableEq,Finset,LE.le,Nat,Finset.card,Eq,Nat.card,Subtype,And,Nat.choose,HSub.hSubProof uses:
Equiv,Membership.mem,Finset.powersetCard,SDiff.sdiff,Equiv.mk,Subtype.mk,Iff.mpr,Finset.mem_powersetCard,And.intro,Finset.sdiff_subset_sdiff,And.left,And.right,Subtype.property,Finset.Subset.refl,Eq.mpr,id,congrArg,Finset.card_sdiff_of_subset,Eq.refl,Union.unionand 18 more20 instances, coercions and auxiliary constants left out.
Tactic trace: 9 steps
Open to load the checked before-and-after goal states.
lemma card_between {α : Type*} [DecidableEq α] {A C : Finset α} (hAC : A ⊆ C) {t : ℕ} (hAt : A.card ≤ t) : Nat.card {X : Finset α // A ⊆ X ∧ X ⊆ C ∧ X.card = t} = (C.card - A.card).choose (t - A.card) := by … - abbrev
Usa2019P4.FiberThe possible values of a filling at a fresh cells, given the valuesA fandC fforced by the neighbors ofsline 153 sourceSource documentation
The possible values of a filling at a fresh cell
s, given the valuesA fandC fforced by the neighbors ofs.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Set, Usa2019P4.Cell,Finset,Fin,HMul.hMul,OfNat.ofNat, Usa2019P4.FillingsProof uses:
Subtype,And,LE.le,Membership.mem,Eq,Finset.card, Usa2019P4.target13 instances, coercions and auxiliary constants left out.
abbrev Fiber {n : ℕ} {D : Set (Cell n)} (A C : (Cell n → Finset (Fin (2 * n))) → Finset (Fin (2 * n))) (s : Cell n) (f : ↥(Fillings n D)) : Type := …Mentions: Usa2019P4.Cell, f, Usa2019P4.Fillings
- lemma
Usa2019P4.ncard_fillings_insertAdding one cell to the domain multiplies the number of fillings by a binomial coefficient line 160 sourceSource documentation
Adding one cell to the domain multiplies the number of fillings by a binomial coefficient.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Set, Usa2019P4.Cell,Not,Membership.mem,Finset,Fin,HMul.hMul,OfNat.ofNat, Usa2019P4.Fillings,LE.le,HAdd.hAdd,Insert.insert,Function.update,EmptyCollection.emptyCollection,Eq,Finset.card, Usa2019P4.target,Set.ncard,Nat.chooseand 1 moreProof uses:
Nat.card, Usa2019P4.Fiber,Subtype,And, Usa2019P4.card_between,Subtype.property,Eq.mp,congrArg,Sigma,Sigma.mk,Subtype.mk, Usa2019P4.restrict_mem,And.intro,And.left,Set.mem_insert,Sigma.fst,Sigma.snd, Usa2019P4.extend_mem,And.right,Function.Injectiveand 28 more78 instances, coercions and auxiliary constants left out.
Tactic trace: 65 steps
Open to load the checked before-and-after goal states.
lemma ncard_fillings_insert {n : ℕ} {D : Set (Cell n)} {s : Cell n} (hs : s ∉ D) {A C : (Cell n → Finset (Fin (2 * n))) → Finset (Fin (2 * n))} (hlo : ∀ f ∈ Fillings n D, ∀ d ∈ D, d ≤ s → f d ⊆ A f) (hhi : ∀ f ∈ Fillings n D, ∀ d ∈ D, s ≤ d → C f ⊆ f d) (hAs : ∀ g ∈ Fillings n (insert s D), A (Function.update g s ∅) ⊆ g s) (hsC : ∀ g ∈ Fillings n (insert s D), g s ⊆ C (Function.update g s ∅)) (hAC : ∀ f ∈ Fillings n D, A f ⊆ C f) {a₀ c₀ : ℕ} (hAcard : ∀ f ∈ Fillings n D, (A f).card = a₀) (hCcard : ∀ f ∈ Fillings n D, (C f).card = c₀) (hAt : ∀ f ∈ Fillings n D, (A f).card ≤ target s) : (Fillings n (insert s D)).ncard = …Mentions: Usa2019P4.Cell, f, Usa2019P4.Fillings, Usa2019P4.target
- lemma
Usa2019P4.stageACounting the fillings of the leftmost column: afterjsteps there are∏ i ∈ range j, (2 * n - i)fillings line 249 sourceSource documentation
Counting the fillings of the leftmost column: after
jsteps there are∏ i ∈ range j, (2 * n - i)fillings.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,Eq,Set.ncard, Usa2019P4.Cell,Finset,Fin,HMul.hMul,OfNat.ofNat, Usa2019P4.Fillings, Usa2019P4.colZero,Finset.prod,Finset.range,HSub.hSubProof uses:
Nat.recAux,LT.lt,HAdd.hAdd,Nat.zero_lt_succ,Set,Insert.insert,Prod,Prod.mk,Fin.mk,EmptyCollection.emptyCollection,Set.ext,Eq.mpr,Iff,Membership.mem,And,Prod.fst,Prod.snd,id,congrArg,Eq.transand 68 more80 instances, coercions and auxiliary constants left out.
Tactic trace: 87 steps
Open to load the checked before-and-after goal states.
lemma stageA (n : ℕ) : ∀ j, j ≤ n → (Fillings n (colZero n j)).ncard = ∏ i ∈ Finset.range j, (2 * n - i) := by …Mentions: Usa2019P4.Fillings, Usa2019P4.colZero
- lemma
Usa2019P4.stageBCounting the fillings of the left column together with the top row line 331 sourceSource documentation
Counting the fillings of the left column together with the top row.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,Eq,Set.ncard, Usa2019P4.Cell,Finset,Fin,HMul.hMul,OfNat.ofNat, Usa2019P4.Fillings,Union.union,Set, Usa2019P4.colZero, Usa2019P4.topRow,Finset.prod,Finset.range,HSub.hSubProof uses:
Nat.recAux,EmptyCollection.emptyCollection,Set.ext,Eq.mpr,Iff,Membership.mem,Not,And,HAdd.hAdd,Prod.fst,Prod.snd,id,Eq.trans,False,congrArg,iff_false,Set.union_empty,Finset.prod_range_zero,one_mul, Usa2019P4.stageA and 55 more76 instances, coercions and auxiliary constants left out.
Tactic trace: 70 steps
Open to load the checked before-and-after goal states.
lemma stageB (n : ℕ) : ∀ i, i ≤ n → (Fillings n (colZero n n ∪ topRow n i)).ncard = (∏ j ∈ Finset.range i, (n - j)) * ∏ j ∈ Finset.range n, (2 * n - j) := by …Mentions: Usa2019P4.Fillings, Usa2019P4.colZero, Usa2019P4.topRow
- lemma
Usa2019P4.stageC_innerFilling the interior columnk + 1from the top down: each of thencells doubles the number of fillings line 404 sourceSource documentation
Filling the interior column
k + 1from the top down: each of thencells doubles the number of fillings.standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,LT.lt,Eq,Set.ncard, Usa2019P4.Cell,Finset,Fin,HMul.hMul,OfNat.ofNat, Usa2019P4.Fillings,Union.union,Set, Usa2019P4.colZero, Usa2019P4.topRow, Usa2019P4.intCols, Usa2019P4.colPart,HAdd.hAdd,HPow.hPowProof uses:
Nat.recAux,EmptyCollection.emptyCollection,Set.ext,Eq.mpr,Iff,Membership.mem,Not,And,Prod.fst,HSub.hSub,Prod.snd,id,Eq.trans,False,congrArg,iff_false,Set.union_empty,pow_zero,one_mul,Eq.refland 54 more89 instances, coercions and auxiliary constants left out.
Tactic trace: 97 steps
Open to load the checked before-and-after goal states.
lemma stageC_inner (n : ℕ) : ∀ r, r ≤ n → ∀ k, k < n → (Fillings n (colZero n n ∪ topRow n n ∪ intCols n k ∪ colPart n (k + 1) r)).ncard = 2 ^ r * (Fillings n (colZero n n ∪ topRow n n ∪ intCols n k)).ncard := by …Mentions: Usa2019P4.Fillings, Usa2019P4.colZero, Usa2019P4.topRow, Usa2019P4.intCols, Usa2019P4.colPart
- lemma
Usa2019P4.stageCCounting the fillings of everything except the right column of the grid line 501 sourceSource documentation
Counting the fillings of everything except the right column of the grid.
standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,LE.le,Eq,Set.ncard, Usa2019P4.Cell,Finset,Fin,HMul.hMul,OfNat.ofNat, Usa2019P4.Fillings,Union.union,Set, Usa2019P4.colZero, Usa2019P4.topRow, Usa2019P4.intCols,HPow.hPow,Finset.prod,Finset.range,HSub.hSubProof uses:
Nat.recAux,EmptyCollection.emptyCollection,Set.ext,Eq.mpr,Iff,Membership.mem,Not,And,HAdd.hAdd,Prod.fst,LT.lt,Prod.snd,id,Eq.trans,False,congrArg,iff_false,Set.union_empty, Usa2019P4.stageB,le_refland 41 more57 instances, coercions and auxiliary constants left out.
Tactic trace: 20 steps
Open to load the checked before-and-after goal states.
lemma stageC (n : ℕ) : ∀ k, k ≤ n → (Fillings n (colZero n n ∪ topRow n n ∪ intCols n k)).ncard = 2 ^ (n * k) * ((∏ i ∈ Finset.range n, (n - i)) * ∏ j ∈ Finset.range n, (2 * n - j)) := by …Mentions: Usa2019P4.Fillings, Usa2019P4.colZero, Usa2019P4.topRow, Usa2019P4.intCols
- theorem
Usa2019P4.prod_range_self_subline 526 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq,Finset.prod,Finset.range,HSub.hSub,Nat.factorialProof uses:
Eq.mpr,HAdd.hAdd,OfNat.ofNat,id,congrArg,Eq.symm,Finset.prod_range_add_one_eq_factorial,Finset.prod_range_reflect,Finset.prod_congr,rfl,Finset,Membership.mem,Eq.mp,LT.lt,propext,Finset.mem_range13 instances, coercions and auxiliary constants left out.
Tactic trace: 4 steps
Open to load the checked before-and-after goal states.
- theorem
Usa2019P4.prod_range_two_mul_sub_mulline 534 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq,HMul.hMul,Finset.prod,Finset.range,HSub.hSub,OfNat.ofNat,Nat.factorialProof uses:
HAdd.hAdd,Eq.mpr,id,congrArg,Eq.symm,Finset.prod_range_reflect,Finset.prod_congr,rfl,Finset,Membership.mem,Eq.mp,LT.lt,propext,Finset.mem_range,Finset.prod_range_add,Finset.prod_range_add_one_eq_factorial,Nat.two_mul,Nat.mul_comm, Usa2019P4.prod_range_self_sub,Eq.refl22 instances, coercions and auxiliary constants left out.
Tactic trace: 11 steps
Open to load the checked before-and-after goal states.
- lemma
Usa2019P4.main_countThe full count: the number of valid configurations is `(2 * n)! line 551 sourceSource documentation
The full count: the number of valid configurations is
(2 * n)! * 2 ^ (n ^ 2).standard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq,Set.ncard, Usa2019P4.Cell,Finset,Fin,HMul.hMul,OfNat.ofNat, Usa2019P4.Fillings,Set.univ,Nat.factorial,HPow.hPowProof uses:
Set,Union.union, Usa2019P4.colZero, Usa2019P4.topRow, Usa2019P4.intCols,Set.ext,Eq.mpr,Iff,Membership.mem,Or,And,HAdd.hAdd,Prod.fst,LE.le,Prod.snd,LT.lt,id,Eq.trans,True,congrand 15 more36 instances, coercions and auxiliary constants left out.
Tactic trace: 7 steps
Open to load the checked before-and-after goal states.
lemma main_count (n : ℕ) : (Fillings n Set.univ).ncard = (2 * n)! * 2 ^ (n ^ 2) := by …
Mentions: Usa2019P4.Fillings
- determine
Usa2019P4.answerline 565 sourcestandard axioms: propext what this means
Statement uses:
NatProof uses:
HMul.hMul,Nat.factorial,OfNat.ofNat,HPow.hPow7 instances, coercions and auxiliary constants left out.
- problem
Usa2019P4.usa2019_p4line 567 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
Nat,Eq,Nat.card,Subtype,Fin,HAdd.hAdd,OfNat.ofNat,Finset,HMul.hMul,And,Finset.card,LE.le, Usa2019P4.answerProof uses:
Equiv, Usa2019P4.Cell, Usa2019P4.Fillings,Set.univ,Equiv.mk,Subtype.mk,Membership.mem,Set,Prod.fst,Prod.snd,And.intro, Usa2019P4.target,Not,EmptyCollection.emptyCollection,And.left,Subtype.property,And.right,Iff.mp,Prod,Prod.le_defand 18 more29 instances, coercions and auxiliary constants left out.
Tactic trace: 33 steps
Open to load the checked before-and-after goal states.