Datasets:

Modalities:
Text
Formats:
parquet
Size:
< 1K
Libraries:
Datasets
pandas
License:
Dataset Viewer
Auto-converted to Parquet
theorem_name
stringlengths
10
17
natural_language
stringlengths
48
1.25k
answer
sequencelengths
1
3
βŒ€
source
stringclasses
1 value
tag
stringclasses
4 values
formal_statement
stringlengths
93
3.05k
hackmath_1
How many ways can a teacher select a group of 6 students to sit in the front row if the class has 13 students?
[ "1716" ]
https://www.hackmath.net/en/word-math-problems/combinatorics
hackmath
import Mathlib abbrev hackmath_1_solution : β„• := sorry theorem hackmath_1 (sols : Finset (Fin 13 β†’ Fin 2)) (h_sols : βˆ€ f, f ∈ sols ↔ ((List.ofFn f).count 0 = 6)) : sols.card = hackmath_1_solution := by sorry
hackmath_2
There are 8 athletes participating in a sprint competition. The referee needs to select 3 athletes and assign them specific rankings (first place, second place, and third place). How many different arrangements are possible?
[ "336" ]
https://www.hackmath.net/en/word-math-problems/combinatorics
hackmath
import Mathlib abbrev hackmath_2_solution : β„• := sorry theorem hackmath_2 (sols : Finset (Fin 8 β†’ Fin 4)) (h_sols : βˆ€ f, f ∈ sols ↔ ((List.ofFn f).count 0 = 1) ∧ ((List.ofFn f).count 1 = 1) ∧ ((List.ofFn f).count 2 = 1)) : sols.card = hackmath_2_solution := by sorry
hackmath_3
How many four-digit numbers can be formed from the numbers 3 5 8 9 if they are not allowed to be repeated?
[ "24" ]
https://www.hackmath.net/en/word-math-problems/combinatorics
hackmath
import Mathlib abbrev hackmath_3_solution : β„• := sorry theorem hackmath_3 (sol : Finset β„•) (h_sol : βˆ€ s ∈ sol, 1000 ≀ s ∧ s ≀ 9999 ∧ (Nat.digits 10 s).toFinset = {3, 5, 8, 9}) : sol.card = hackmath_3_solution := by sorry
hackmath_4
How many people must be in a group for at least two of them to be born in the same month?
[ "13" ]
https://www.hackmath.net/en/word-math-problems/combinatorics
hackmath
import Mathlib abbrev hackmath_4_solution : β„• := sorry theorem hackmath_4 : IsLeast {n | βˆ€ f : Fin n β†’ Fin 12, βˆƒ a b, f a = f b} hackmath_4_solution := by sorry
hackmath_5
There are 10 red marbles, 6 green marbles, and 4 blue marbles in a box. What is the probability of picking the next red marble?
[ "1 / 2" ]
https://www.hackmath.net/en/word-math-problems/combinatorics
hackmath
import Mathlib open MeasureTheory ProbabilityTheory ENNReal noncomputable abbrev hackmath_5_solution : ENNReal := sorry theorem hackmath_5 : uniformOn (Ω := (Fin 20)) ⊀ {i | i.1 < 10} = hackmath_5_solution := by sorry
hackmath_6
Two coins are tossed simultaneously. What is the probability of getting (i) At least one head? (ii) At most one tail? (iii) A head and a tail?
[ "3 / 4", "3 / 4", "1 / 2" ]
https://www.hackmath.net/en/word-math-problems/combinatorics
hackmath
import Mathlib noncomputable abbrev hackmath_6_1_solution : ENNReal := sorry noncomputable abbrev hackmath_6_2_solution : ENNReal := sorry noncomputable abbrev hackmath_6_3_solution : ENNReal := sorry theorem hackmath_6 : PMF.binomial (1/2 : _) ENNReal.half_le_self 2 1 + PMF.binomial (1/2 : _) ENNReal.half_le_self 2 2 = hackmath_6_1_solution ∧ PMF.binomial (1/2 : _) ENNReal.half_le_self 2 0 + PMF.binomial (1/2 : _) ENNReal.half_le_self 2 1 = hackmath_6_2_solution ∧ PMF.binomial (1/2 : _) ENNReal.half_le_self 2 1 = hackmath_6_3_solution := by sorry
hackmath_7
The group of 10 girls should be divided into two groups with at least four girls in each group. How many ways can this be done?
[ "462" ]
https://www.hackmath.net/en/word-math-problems/combinatorics
hackmath
import Mathlib abbrev hackmath_7_solution : β„• := sorry theorem hackmath_7 (sols : Finset (Finpartition (@Finset.univ (Fin 10)))) (h_sols : βˆ€ f, f ∈ sols ↔ (f.parts.card = 2) ∧ (βˆ€ i, i ∈ f.parts β†’ i.card β‰₯ 4)) : sols.card = hackmath_7_solution := by sorry
hackmath_8
A ferry with a capacity of 10 people takes a group of 13 men and 7 women across a river. Find the number of ways in which the qroup may be taken across the if all women go on the first group.
[ "286" ]
https://www.hackmath.net/en/word-math-problems/combinatorics
hackmath
import Mathlib abbrev hackmath_8_solution : β„• := sorry theorem hackmath_8 (sols : Finset ((Fin 13 β†’ Fin 2) Γ— (Fin 7 β†’ Fin 2))) (h_women : βˆ€ f ∈ sols, βˆ€ i, f.2 i = 0) (h_sols : βˆ€ f, f ∈ sols ↔ βˆ€ k, ((List.ofFn f.1).count k + (List.ofFn f.2).count k = 10)) : sols.card = hackmath_8_solution := by sorry
hackmath_9
The father has six sons and ten identical, indistinguishable balls. How many ways can he give the balls to his sons if everyone gets at least one?
[ "126" ]
https://www.hackmath.net/en/word-math-problems/combinatorics
hackmath
import Mathlib abbrev hackmath_9_solution : β„• := sorry theorem hackmath_9 (sols : Finset (Fin 6 β†’ β„•)) (h_sols : βˆ€ f, f ∈ sols ↔ ((βˆ€ i, f i > 0) ∧ (βˆ‘ i, f i = 10))) : sols.card = hackmath_9_solution := by sorry
hackmath_10
How many different ways can three people divide seven pears and five apples?
[ "756" ]
https://www.hackmath.net/en/word-math-problems/combinatorics
hackmath
import Mathlib abbrev hackmath_10_solution : β„• := sorry theorem hackmath_10 (sols : Finset (Fin 3 β†’ (β„• Γ— β„•))) (h_sols : βˆ€ f, f ∈ sols ↔ (βˆ‘ i, (f i).1 = 7 ∧ βˆ‘ i, (f i).2 = 5)) : sols.card = hackmath_10_solution := by sorry
brualdi_ch1_16
Show that the result of replacing every integer a in a magic square of order n with $n^2 + 1 βˆ’ a$ is a magic square of order n.
null
null
brualdi
import Mathlib structure IsMagicSquare {n : β„•} (M : Matrix (Fin n) (Fin n) β„•) : Prop where mem : βˆ€ i j, M i j ∈ Finset.Icc 1 (n * n) pairwise : βˆ€ i j i' j', i β‰  i' ∨ j β‰  j' β†’ M i j β‰  M i' j' same_sum : βˆƒ s, (βˆ€ i, βˆ‘ j, M i j = s) ∧ (βˆ€ j, βˆ‘ i, M i j = s) ∧ (βˆ‘ i, M i i.rev = s) ∧ βˆ‘ i, M i i = s abbrev replace {n : β„•}: Matrix (Fin n) (Fin n) β„• β†’ Matrix (Fin n) (Fin n) β„• := fun A i j ↦ n^2 + 1 - A i j theorem brualdi_ch1_16 {n : β„•} (M : Matrix (Fin n) (Fin n) β„•) (hM : IsMagicSquare M) : IsMagicSquare (replace M) := by sorry
brualdi_ch1_10
Verify that there is no magic square of order 2.
null
null
brualdi
import Mathlib structure IsMagicSquare {n : β„•} (M : Matrix (Fin n) (Fin n) β„•) : Prop where mem : βˆ€ i j, M i j ∈ Finset.Icc 1 (n * n) pairwise : βˆ€ i j i' j', i β‰  i' ∨ j β‰  j' β†’ M i j β‰  M i' j' same_sum : βˆƒ s, (βˆ€ i, βˆ‘ j, M i j = s) ∧ (βˆ€ j, βˆ‘ i, M i j = s) ∧ (βˆ‘ i, M i i.rev = s) ∧ βˆ‘ i, M i i = s theorem brualdi_ch1_10 : Β¬βˆƒ (M : Matrix (Fin 2) (Fin 2) β„•), IsMagicSquare M := by sorry
brualdi_ch1_5
Find the number of different perfect covers of a 3-by-4 chessboard by dominoes.
[ "9" ]
null
brualdi
import Mathlib abbrev Board := Fin 3 Γ— Fin 4 def formsDomino (i j : Board) : Bool := (i.1.val = j.1.val ∧ (i.2.val + 1 = j.2.val ∨ j.2.val + 1 = i.2.val)) ∨ (i.2.val = j.2.val ∧ (i.1.val + 1 = j.1.val ∨ j.1.val + 1 = i.1.val)) structure PerfectCover where tiles : Fin 6 β†’ (Board Γ— Board) domino : βˆ€ i, formsDomino (tiles i).1 (tiles i).2 covers : βˆ€ i : Board, βˆƒ j, i = (tiles j).1 ∨ i = (tiles j).2 noncomputable instance : Fintype PerfectCover := Fintype.ofInjective PerfectCover.tiles <| by rintro ⟨tiles, _⟩ ⟨tiles', _⟩ (rfl : tiles = tiles') rfl abbrev brualdi_ch1_5_solution : β„• := sorry theorem brualdi_ch1_5 : Fintype.card PerfectCover = brualdi_ch1_5_solution := by sorry
brualdi_ch2_6
How many integers greater than 5400 have both of the following properties? (a) The digits are distinct. (b) The digits 2 and 7 do not occur.
[ "94830" ]
null
brualdi
import Mathlib abbrev brualdi_ch2_6_solution : β„• := sorry theorem brualdi_ch2_6 (s : Finset β„•) (hs0 : βˆ€ n ∈ s, n > 5400) (hs1 : βˆ€ n ∈ s, (Nat.digits 10 n).Nodup) (hs2 : βˆ€ n ∈ s, 2 βˆ‰ (Nat.digits 10 n) ∧ 7 βˆ‰ (Nat.digits 10 n)) : s.card = brualdi_ch2_6_solution := by sorry
brualdi_ch2_36
Determine the total number of combinations (of any size) of a multiset of objects of $k$ different types with finite repetition numbers $n_{1}, n_{2}, \ldots, n_{k}$, respectively.
[ "fun n => (βˆ‘ i : Fin k, (n i + 1))" ]
null
brualdi
import Mathlib abbrev brualdi_ch2_36_solution {k} : (Fin k β†’ β„•) β†’ β„• := sorry theorem brualdi_ch2_36 {k : β„•} (n : Fin k β†’ β„•) (sols : Finset (Fin k β†’ β„•)) (h_sols : βˆ€ f, f ∈ sols ↔ (βˆ€ i, f i ≀ n i)) : sols.card = brualdi_ch2_36_solution n := by sorry
brualdi_ch2_11
How many sets of three integers between 1 and 20 are possible if no two consecutive integers are to be in a set?
[ "816" ]
null
brualdi
import Mathlib open Finset abbrev brualdi_ch2_11_solution : β„• := sorry theorem brualdi_ch2_11 : ((Icc (1 : β„•) 20).powersetCard 3 |>.filter (fun S => βˆ€ a ∈ S, a - 1 βˆ‰ S ∧ a + 1 βˆ‰ S)).card = brualdi_ch2_11_solution := by sorry
brualdi_ch3_18
Prove that of any five points chosen within a square of side length 2 , there are two whose distance apart is at most $\sqrt{2}$.
null
null
brualdi
import Mathlib theorem brualdi_ch3_18 (points : Fin 5 β†’ Set.Icc (0 : ℝ) 2 Γ— Set.Icc (0 : ℝ) 2) : βˆƒ i j, i β‰  j ∧ Dist.dist (points i) (points j) ≀ √2 := by sorry
brualdi_ch3_4
Show that if $n+1$ integers are chosen from the set ${1,2, \ldots, 2 n}$, then there are always two which differ by 1.
null
null
brualdi
import Mathlib theorem brualdi_ch3_4 (n : β„•) (S : Finset β„•) (elem_range : βˆ€ s ∈ S, (1 ≀ s ∧ s ≀ 2 * n)) (card : S.card = n + 1) : βˆƒ s ∈ S, βˆƒ s' ∈ S, s = s' + 1 := by sorry
brualdi_ch3_27
A collection of subsets of ${1,2, \ldots, n}$ has the property that each pair of subsets has at least one element in common. Prove that there are at most $2^{n-1}$ subsets in the collection.
null
null
brualdi
import Mathlib theorem brualdi_ch3_27 (n : β„•) (hn : n β‰₯ 1) (subsets : Set (Set (Set.Icc 1 n))) (cond : βˆ€ S ∈ subsets, βˆ€ T ∈ subsets, (S ∩ T).Nonempty) : βˆƒ (m : β„•), m ≀ 2 ^ (n - 1) ∧ Nonempty (Fin m ≃ subsets) := by sorry
brualdi_ch4_35
The complement $\bar{A}$ of an $r$-subset $A$ of $\{1,2, \ldots, n\}$ is the $(n-r)$-subset of $\{1,2, \ldots, n\}$, consisting of all those elements that do not belong to $A$. Let $M=\binom{n}{r}$, the number of $r$-subsets and, at the same time, the number of $(n-r)$ subsets of $\{1,2, \ldots, n\}$. Prove that, if $A_{1}, A_{2}, A_{3}, \ldots, A_{M}$ are the $r$-subsets in lexicographic order, then $\overline{A_{M}}, \ldots, \overline{A_{3}}, \overline{A_{2}}, \overline{A_{1}}$ are the $(n-r)$-subsets in lexicographic order.
null
null
brualdi
import Mathlib open List Lex theorem brualdi_ch4_35 (r n M : β„•) (hM : M = ((@Finset.univ (Fin n)).powersetCard r).card) (A : Fin M β†’ (Finset.powersetCard r (@Finset.univ (Fin M) _))) : βˆ€ i j, (List.Lex (fun x1 x2 : Fin M => x1 ≀ x2) (Finset.sort (Β· ≀ Β·) (A i)) (Finset.sort (Β· ≀ Β·) (A j))) β†’ (List.Lex (fun x1 x2 : Fin M => x1 ≀ x2) (Finset.sort (Β· ≀ Β·) (A j)ᢜ) (Finset.sort (Β· ≀ Β·) (A i)ᢜ)) := by sorry
brualdi_ch4_59
Let $n \geq 2$ be an integer. Prove that the total number of inversions of all $n$ ! permutations of $1,2, \ldots, n$ equals $\frac{1}{2} n!\binom{n}{2}=n!\frac{n(n-1)}{4}$ (Hint: Pair up the permutations so that the number of inversions in each pair is $\frac{n(n-1)}{2}$.)
null
null
brualdi
import Mathlib def invNum {n : β„•} (Οƒ : Equiv.Perm (Fin n)) : β„• := βˆ‘ x ∈ Equiv.Perm.finPairsLT n, if Οƒ x.fst ≀ Οƒ x.snd then 0 else 1 theorem brualdi_ch4_59 (n : β„•) (hn : n β‰₯ 2) : βˆ‘ Οƒ : Equiv.Perm (Fin n), invNum Οƒ = n.factorial * n * (n - 1) / 4 := by sorry
brualdi_ch4_9
Show that the largest number of inversions of a permutation of ${1, 2, ... , n}$ equals $\frac{n(n -1)}{2}$.
null
null
brualdi
import Mathlib def invNum {n : β„•} (Οƒ : Equiv.Perm (Fin n)) : β„• := βˆ‘ x ∈ Equiv.Perm.finPairsLT n, if Οƒ x.fst ≀ Οƒ x.snd then 0 else 1 theorem brualdi_ch4_9 (n : β„•) : IsGreatest {k | βˆƒ Οƒ : Equiv.Perm (Fin n), k = invNum Οƒ} (n * (n - 1) / 2) := by sorry
brualdi_ch5_51
Let $R$ and $S$ be two partial orders on the same set $X$. Considering $R$ and $S$ as subsets of $X \times X$, we assume that $R \subseteq S$ but $R \neq S$. Show that there exists an ordered pair $(p, q)$, where $(p, q) \in S$ and $(p, q) \notin R$ such that $R^{\prime}=R \cup\{(p, q)\}$ is also a partial order on $X$.
null
null
brualdi
import Mathlib theorem brualdi_ch5_51 {X : Type} [DecidableEq X] (R S : Rel X X) [IsPartialOrder X R] [IsPartialOrder X S] (le : R < S) : βˆƒ (p q : X), S p q ∧ Β¬ R p q ∧ IsPartialOrder X (R βŠ” fun x y ↦ if x = p ∧ y = q then true else false) := by sorry
brualdi_ch5_9
Evaluate the sum $\sum_{k=0}^{n}(-1)^{k}\binom{n}{k} 10^{k}$.
[ "fun n => (-9 : β„€)^n" ]
null
brualdi
import Mathlib abbrev brualdi_ch5_9_solution : β„• β†’ β„€ := sorry theorem brualdi_ch5_9 (n : β„•) : βˆ‘ k ∈ Finset.range (n + 1), (-1 : β„€) ^ k * (n.choose k) * 10 ^ k = brualdi_ch5_9_solution n := by sorry
brualdi_ch5_26
Let $n$ and $k$ be integers with $1 \leq k \leq n$. Prove that $\sum_{k=1}^{n}\binom{n}{k}\binom{n}{k-1}=\frac{1}{2}\binom{2 n+1}{n+1}-\binom{2 n}{n}$.
null
null
brualdi
import Mathlib theorem brualdi_ch5_26 (n k : β„•) (h1 : 1 ≀ k) (h2 : k ≀ n) : βˆ‘ k ∈ Finset.Icc 1 n, Nat.choose n k * Nat.choose n (k - 1) = (1 / 2 : β„š) * Nat.choose (2 * n + 1) (n + 1) - Nat.choose (2 * n) n := by sorry
brualdi_ch6_11
Determine the number of permutations of $\{1,2, \ldots, 8\}$ in which no even integer is in its natural position.
[ "24024" ]
null
brualdi
import Mathlib abbrev brualdi_ch6_11_solution : β„• := sorry theorem brualdi_ch6_11 (sols : Finset (Equiv.Perm (Finset.Icc 1 8))) (h_sols : βˆ€ Οƒ, Οƒ ∈ sols ↔ (βˆ€ i, Even i.1 β†’ Οƒ i β‰  i)) : sols.card = brualdi_ch6_11_solution := by sorry
brualdi_ch6_21
Prove that $D_{n}$ is an even number if and only if $n$ is an odd number.
null
null
brualdi
import Mathlib theorem brualdi_ch6_21 (n : β„•) : Even (numDerangements n) ↔ Odd n := by sorry
brualdi_ch6_9
Determine the number of integral solutions of the equation $x_{1}+x_{2}+x_{3}+x_{4}=20$ that satisfy $1 \leq x_{1} \leq 6,0 \leq x_{2} \leq 7,4 \leq x_{3} \leq 8,2 \leq x_{4} \leq 6$.
[ "96" ]
null
brualdi
import Mathlib open Finset abbrev brualdi_ch6_9_solution : β„• := sorry theorem brualdi_ch6_9 : {x : Fin 4 β†’ β„• | x 0 ∈ Icc 1 6 ∧ x 1 ∈ Icc 0 7 ∧ x 2 ∈ Icc 4 8 ∧ x 3 ∈ Icc 2 6}.ncard = brualdi_ch6_9_solution := by sorry
brualdi_ch7_15
Determine the generating function for the sequence of cubes \[ 0, 1, 8, \ldots, n^{3}, \ldots \]
[ "PowerSeries.X * (PowerSeries.X ^ 2 + 4 * PowerSeries.X + 1) * PowerSeries.inv (1 - PowerSeries.X) ^ 4" ]
null
brualdi
import Mathlib abbrev brualdi_ch7_15_solution : PowerSeries ℝ := sorry theorem brualdi_ch7_15 : PowerSeries.mk (fun (n : β„•) => (n : ℝ) ^ 3) = brualdi_ch7_15_solution := by sorry
brualdi_ch7_7
Let $m$ and $n$ be positive integers whose greatest common divisor is $d$. Prove that the greatest common divisor of the Fibonacci numbers $f_{m}$ and $f_{n}$ is the Fibonacci number $f_{d}$.
null
null
brualdi
import Mathlib theorem brualdi_ch7_7 (m n d : β„•+) (hmd : d = Nat.gcd m n) : Nat.gcd (Nat.fib m) (Nat.fib n) = Nat.fib d := by sorry
brualdi_ch7_27
Determine the number of n-digit numbers with all digits odd, such that 1 and 3 each occur a nonzero, even number of times.
[ "fun n => (5 ^ n - 4 ^ (n + 1) + 6 * 3 ^ n - 4 * 2 ^ n + 1) / 4 " ]
null
brualdi
import Mathlib abbrev S (n : β„•) : Finset β„• := {m < 10^n | (Nat.digits 10 m).length = n ∧ (βˆ€ i : Fin (Nat.digits 10 m).length, Odd ((Nat.digits 10 m).get i)) ∧ Even ((Nat.digits 10 m).count 1) ∧ Even ((Nat.digits 10 m).count 3) ∧ ((Nat.digits 10 m).count 1) β‰  0 ∧ ((Nat.digits 10 m).count 3) β‰  0} abbrev brualdi_ch7_27_solution : β„• β†’ β„• := sorry theorem brualdi_ch7_27 (n : β„•) : (S n).card = brualdi_ch7_27_solution n := by sorry
brualdi_ch8_6
Let the sequence $h_{0}, h_{1}, \ldots, h_{n}, \ldots$ be defined by $h_{n}=2 n^{2}-n+3,(n \geq 0)$. Find a formula for $\sum_{k=0}^{n} h_{k}$.
[ "fun n => ((n + 1) * (4 * n ^ 2 - n + 18) / 6)" ]
null
brualdi
import Mathlib abbrev brualdi_ch8_6_solution : β„• β†’ ℝ := sorry theorem brualdi_ch8_6 (n : β„•) (h : β„• β†’ ℝ) (h' : βˆ€ i, h i = 2 * i ^ 2 - i + 3) : βˆ‘ i ∈ Finset.range (n + 1), h i = brualdi_ch8_6_solution n := by sorry
brualdi_ch8_30
Prove that the partition function satisfies $p_{n} > p_{n-1}$ when $2 ≀ n$.
null
null
brualdi
import Mathlib theorem brualdi_ch8_30 (n : β„•) (hn : 2 ≀ n) : Fintype.card (Nat.Partition (n - 1)) < Fintype.card (Nat.Partition n) := by sorry
brualdi_ch8_9
Prove that the following formula holds for the $k$ th-order differences of a sequence $h_{0}, h_{1}, \ldots, h_{n}, \ldots$ : \Delta^{k} h_{n}=\sum_{j=0}^{k}(-1)^{k-j}\binom{k}{j} h_{n+j}
null
null
brualdi
import Mathlib theorem brualdi_ch8_9 (h : β„• β†’ β„€) (k n : β„•): (fwdDiff 1)^[k] h n = βˆ‘ j ∈ Finset.range (k + 1), (-1 : β„€) ^ (k - j) * Nat.choose k j * h (n + j) := by sorry
brualdi_ch9_13
Let $A$ be a matrix with $n$ columns, with integer entries taken from the set $S=\{1,2, \ldots, k\}$. Assume that each integer $i$ in $S$ occurs exactly $n r_{i}$ times in $A$, where $r_{i}$ is an integer. Prove that it is possible to permute the entries in each row of $A$ to obtain a matrix $B$ in which each integer $i$ in $S$ appears $r_{i}$ times in each column.
null
null
brualdi
import Mathlib theorem brualdi_ch9_13 (n m : β„•) (k : β„•+) (A : Matrix (Fin m) (Fin n) β„•) (hA : βˆ€ i j, A i j ∈ Finset.Icc 1 k.1) : βˆƒ (rΟƒ : Fin m β†’ Equiv.Perm (Fin n)), βˆ€ j : Fin n, βˆ€ i ∈ Set.Icc 1 k.1, (βˆ‘ x : Fin m, if A x ((rΟƒ x).symm j) = x then 1 else 0) * n = (βˆ‘ x : Fin m, βˆ‘ y : Fin n, if A x y = i then 1 else 0) := by sorry
brualdi_ch9_8
Let $\mathcal{A}=\left(A_{1}, A_{2}, A_{3}, A_{4}, A_{5}, A_{6}\right)$, where \[ \begin{aligned} & A_{1}=\{1,2\}, A_{2}=\{2,3\}, A_{3}=\{3,4\} \\ & A_{4}=\{4,5\}, A_{5}=\{5,6\}, A_{6}=\{6,1\} \end{aligned} \] Determine the number of different SDRs that $\mathcal{A}$ has.
[ "2" ]
null
brualdi
import Mathlib variable {Ξ± : Type*} structure SDR {n : β„•} (A : Fin n β†’ Finset Ξ±) where toFun : Fin n β†’ Ξ± mem_Ai : βˆ€ i, toFun i ∈ A i pairwise : βˆ€ i j, i β‰  j β†’ toFun i β‰  toFun j instance {n : β„•} (A : Fin n β†’ Finset Ξ±) : CoeFun (SDR A) (fun _ => Fin n β†’ Ξ±) where coe s := s.toFun noncomputable instance {n : β„•} (A : Fin n β†’ Finset Ξ±) : Fintype (SDR A) := by classical let Y := Finset.biUnion (@Finset.univ (Fin n) _) A if h : Nonempty (SDR A) then exact Fintype.ofSurjective (Ξ± := (Fin n β†’ Y)) (fun f ↦ if h1 : (βˆƒ(g : SDR A), βˆ€ i, f i = g i) then ⟨fun i => f i, fun i ↦ by have ⟨g, hg⟩ := h1; simp [hg, g.mem_Ai], fun i j hij ↦ by have ⟨g, hg⟩ := h1; simp [hg, g.pairwise i j hij]⟩ else Classical.choice (Ξ± := (SDR A)) h) <| fun g ↦ ⟨fun i => ⟨g i, by simp [Y]; use i; simp [g.mem_Ai]⟩, by simp; suffices βˆƒ (g' : SDR A), βˆ€ (i : Fin n), g.toFun i = g'.toFun i by simp [this] use g; simp⟩ else exact fintypeOfNotInfinite (fun h1 ↦ by aesop) abbrev A : Fin 6 β†’ Finset β„• := fun i ↦ match i with | 1 => {1, 2} | 2 => {2, 3} | 3 => {3, 4} | 4 => {4, 5} | 5 => {5, 6} | 6 => {6, 1} abbrev brualdi_ch9_8_solution : β„• := sorry theorem brualdi_ch9_8 : Fintype.card (SDR A) = brualdi_ch9_8_solution := by sorry
brualdi_ch9_11
Let $n>1$, and let $\mathcal{A}=\left(A_{1}, A_{2}, \ldots, A_{n}\right)$ be the family of subsets of $\{1,2, \ldots, n\}$, where \[ A_{i}=\{1,2, \ldots, n\}-\{i\}, \quad(i=1,2, \ldots, n) \] Prove that $\mathcal{A}$ has an SDR and that the number of SDRs is the $n$th derangement number $D_{n}$.
null
null
brualdi
import Mathlib variable {Ξ± : Type*} structure SDR {n : β„•} (A : Fin n β†’ Finset Ξ±) where toFun : Fin n β†’ Ξ± mem_Ai : βˆ€ i, toFun i ∈ A i pairwise : βˆ€ i j, i β‰  j β†’ toFun i β‰  toFun j instance {n : β„•} (A : Fin n β†’ Finset Ξ±) : CoeFun (SDR A) (fun _ => Fin n β†’ Ξ±) where coe s := s.toFun noncomputable instance {n : β„•} (A : Fin n β†’ Finset Ξ±) : Fintype (SDR A) := by classical let Y := Finset.biUnion (@Finset.univ (Fin n) _) A if h : Nonempty (SDR A) then exact Fintype.ofSurjective (Ξ± := (Fin n β†’ Y)) (fun f ↦ if h1 : (βˆƒ(g : SDR A), βˆ€ i, f i = g i) then ⟨fun i => f i, fun i ↦ by have ⟨g, hg⟩ := h1; simp [hg, g.mem_Ai], fun i j hij ↦ by have ⟨g, hg⟩ := h1; simp [hg, g.pairwise i j hij]⟩ else Classical.choice (Ξ± := (SDR A)) h) <| fun g ↦ ⟨fun i => ⟨g i, by simp [Y]; use i; simp [g.mem_Ai]⟩, by simp; suffices βˆƒ (g' : SDR A), βˆ€ (i : Fin n), g.toFun i = g'.toFun i by simp [this] use g; simp⟩ else exact fintypeOfNotInfinite (fun h1 ↦ by aesop) theorem brualdi_ch9_11 (n : β„•) (hn : n > 1) (A : Fin n β†’ Finset β„•) (hA : βˆ€ i, A i = Finset.Icc 1 n \ {i.1 + 1}) : Nonempty (SDR A) ∧ Fintype.card (SDR A) = numDerangements n := by sorry
brualdi_ch10_31
Prove that $B = {0,3,4,9,11}$ is a difference set in $Z_{21}$.
null
null
brualdi
import Mathlib def isDifferenceSet (n : β„•) (B : Finset (ZMod n)) : Prop := βˆƒ k, βˆ€ x : (ZMod n), x β‰  0 β†’ βˆ‘ i ∈ B, βˆ‘ j ∈ B \ {i}, List.count x [i - j] = k theorem brualdi_ch10_31 : isDifferenceSet 21 {0, 3, 4, 9, 11} := by sorry
brualdi_ch10_34
Let $t$ be a positive integer. Prove that, if there exists a Steiner triple system of index 1 having $v$ varieties, then there exists a Steiner triple system having $v^{t}$ varieties.
null
null
brualdi
import Mathlib structure SteinerTripleSystemOfIndOne (t k n : β„•) where carrier : Fin n blocks : Finset (Finset (Fin n)) card_blocks : βˆ€ b ∈ blocks, b.card = k block_inner : βˆ€ s : (Finset (Fin n)), s.card = t β†’ βˆƒ! b ∈ blocks, s βŠ† b theorem brualdi_ch10_34 (t v : β„•) (ht : t > 1): Nonempty (SteinerTripleSystemOfIndOne 2 3 v) β†’ Nonempty (SteinerTripleSystemOfIndOne 2 3 (v ^ t)) := by sorry
brualdi_ch10_60
Prove that a symmetric, idempotent Latin square has odd order.
null
null
brualdi
import Mathlib structure LatinSquare (n : β„•) where carrier : Matrix (Fin n) (Fin n) (ZMod n) pairwise_1 : βˆ€ i j1 j2, j1 β‰  j2 β†’ carrier i j1 β‰  carrier i j2 pairwise_2 : βˆ€ j i1 i2, i1 β‰  i2 β†’ carrier i1 j β‰  carrier i2 j theorem brualdi_ch10_60 {n : β„•} (L : LatinSquare n) : IsIdempotentElem L.1 ∧ L.1.IsSymm β†’ Odd n := by sorry
brualdi_ch11_5
Use the pigeonhole principle to prove that a graph of order n β‰₯ 2 always has two vertices of the same degree.
null
null
brualdi
import Mathlib theorem brualdi_ch11_5 {V : Type*} (n : β„•) (h_n: n β‰₯ 2) (G : SimpleGraph (Fin n)) [DecidableRel G.Adj] : βˆƒ v1 v2, v1 β‰  v2 ∧ G.degree v1 = G.degree v2 := by sorry
brualdi_ch11_59
Prove that the removal of an edge from a tree leaves a forest of two trees.
null
null
brualdi
import Mathlib open SimpleGraph theorem brualdi_ch11_59 {V : Type*} [Fintype V] [DecidableEq V] (T : SimpleGraph V) (hT : IsTree T) (e : Sym2 V) (he : e ∈ T.edgeSet) : βˆƒ (T1 T2 : SimpleGraph V), IsTree T1 ∧ IsTree T2 ∧ T1.edgeSet βˆͺ T2.edgeSet = T.edgeSet \ {e} ∧ Disjoint (T1.support) (T2.support) := by sorry
brualdi_ch11_20
Prove that a graph of order n with at least `(n-1)(n-2)/2 + 1` edges must be connected.
null
null
brualdi
import Mathlib theorem brualdi_ch11_20 {V : Type*} [Fintype V] (n : β„•) (hn : n β‰₯ 1) (hV : Fintype.card V = n) (G : SimpleGraph V) (h : (n - 1) * (n - 2) / 2 + 1 ≀ (SimpleGraph.edgeSet G).ncard) : G.Connected := by sorry
brualdi_ch12_37
Determine the domination number of the graph $Q_{3}$ of vertices and edges of a three-dimensional cube.
[ "1" ]
null
brualdi
import Mathlib open SimpleGraph BigOperators Classical variable (n : β„•) {V : Type*} (G : SimpleGraph V) def SimpleGraph.IsDominatingSet (D : Set V) : Prop := βˆ€ v : V, Β¬ (v ∈ D) β†’ βˆƒ u ∈ D, G.Adj u v lemma IsDominatingSet.univ : G.IsDominatingSet Set.univ := by simp [IsDominatingSet] noncomputable def SimpleGraph.eDominationNum : β„•βˆž := iInf (fun s ↦ if (G.IsDominatingSet s) then s.card else ⊀ : (Finset V) β†’ β„•βˆž) noncomputable def SimpleGraph.dominationNum : β„• := G.eDominationNum.toNat abbrev Q_3 := (pathGraph 2) β–‘ (pathGraph 2) β–‘ (pathGraph 2) abbrev brualdi_ch12_37_solution : β„• := sorry theorem brualdi_ch12_37 : Q_3.dominationNum = brualdi_ch12_37_solution:= by sorry
brualdi_ch12_62
Let $G$ be a graph. Prove that $G$ is 2-connected if and only if, for each vertex $x$ and each edge $\alpha$, there is a cycle that contains both the vertex $x$ and the edge $\alpha$.
null
null
brualdi
import Mathlib structure TwoConnected {V : Type*} (G : SimpleGraph V) : Prop where selfconnected : G.Connected remains_connected : βˆ€ x : V, ((⊀ : SimpleGraph.Subgraph G).deleteVerts {x}).coe.Connected theorem brualdi_ch12_62 {V : Type*} (G : SimpleGraph V) : TwoConnected G ↔ βˆ€ x : V, βˆ€ e ∈ G.edgeSet, βˆƒ G' : SimpleGraph.Subgraph G, x ∈ G'.verts ∧ e ∈ G'.edgeSet ∧ G'.coe.IsCycles := by sorry
brualdi_ch12_34
Prove that the complement of a disconnected graph is connected.
null
null
brualdi
import Mathlib theorem brualdi_ch12_34 {V : Type*} (G : SimpleGraph V) (h : ¬ G.Connected) : Gᢜ.Connected := by sorry
brualdi_ch13_6
Prove that a digraph is strongly connected if and only if there is a closed, directed walk that contains each vertex at least once.
null
null
brualdi
import Mathlib universe u inductive Digraph.Walk {V : Type u} (G : Digraph V) : V β†’ V β†’ Type u | nil {u : V} (h : G.Adj u u) : Digraph.Walk G u u | cons {u v w : V} (h : G.Adj u v) (p : Digraph.Walk G v w) : Digraph.Walk G u w deriving DecidableEq structure Digraph.StronglyConnected {V : Type u} (G : Digraph V) : Prop where exists_walk ⦃u v : V⦄ (neq : u β‰  v) : Nonempty (Digraph.Walk G u v) def Digraph.Walk.support {V : Type u} {G : Digraph V} {u v : V} : Digraph.Walk G u v β†’ List V | .nil h => [u] | .cons _ p => u :: p.support theorem brualdi_ch13_6 {V : Type u} (T : Digraph V) : T.StronglyConnected ↔ βˆƒ (u : V) (p : T.Walk u u), βˆ€ v : V, v ∈ p.support := by sorry
brualdi_ch13_10
Prove that every tournament contains a vertex $u$ such that, for every other vertex $x$, there is a path from $u$ to $x$ of length at most 2.
null
null
brualdi
import Mathlib universe u structure IsTournament {V : Type u} (G : Digraph V) : Prop where irrefl : βˆ€ (u : V), Β¬ G.Adj u u adj : βˆ€ (u v : V), u β‰  v β†’ (G.Adj u v ↔ Β¬ G.Adj v u) inductive Digraph.Walk {V : Type u} (G : Digraph V) : V β†’ V β†’ Type u | nil {u : V} (h : G.Adj u u) : Digraph.Walk G u u | cons {u v w : V} (h : G.Adj u v) (p : Digraph.Walk G v w) : Digraph.Walk G u w deriving DecidableEq def Digraph.Walk.support {V : Type u} {G : Digraph V} {u v : V} : Digraph.Walk G u v β†’ List V | .nil h => [u] | .cons _ p => u :: p.support def Digraph.Walk.IsPath {V : Type u} {G : Digraph V} {u v : V} (p : Digraph.Walk G u v) : Prop := p.support.Nodup def Digraph.Walk.length {V : Type u} {G : Digraph V} {u v : V} : Digraph.Walk G u v β†’ β„• | .nil h => 0 | .cons _ p => 1 + p.length theorem brualdi_ch13_10 {V : Type u} (T : Digraph V) (hT : IsTournament T) : βˆƒ (u : V), βˆ€ (x : V), βˆƒ (p : T.Walk u x), p.IsPath ∧ p.length ≀ 2 := by sorry
brualdi_ch13_9
Prove that a tournament is strongly connected if and only if it has a directed Hamilton cycle.
null
null
brualdi
import Mathlib universe u structure IsTournament {V : Type u} (G : Digraph V) : Prop where irrefl : βˆ€ (u : V), Β¬ G.Adj u u adj : βˆ€ (u v : V), u β‰  v β†’ (G.Adj u v ↔ Β¬ G.Adj v u) inductive Digraph.Walk {V : Type u} (G : Digraph V) : V β†’ V β†’ Type u | nil {u : V} (h : G.Adj u u) : Digraph.Walk G u u | cons {u v w : V} (h : G.Adj u v) (p : Digraph.Walk G v w) : Digraph.Walk G u w deriving DecidableEq structure Digraph.StronglyConnected {V : Type u} (G : Digraph V) : Prop where exists_walk ⦃u v : V⦄ (neq : u β‰  v) : Nonempty (Digraph.Walk G u v) def Digraph.Walk.support {V : Type u} {G : Digraph V} {u v : V} : Digraph.Walk G u v β†’ List V | .nil h => [u] | .cons _ p => u :: p.support def Digraph.Walk.IsPath {V : Type u} {G : Digraph V} {u v : V} (p : Digraph.Walk G u v) : Prop := p.support.Nodup structure Digraph.Walk.IsHamiltonianCycle {V : Type u} {G : Digraph V} {u : V} (p : Digraph.Walk G u u) : Prop where is_path : p.IsPath visit_all (v : V) : v ∈ p.support theorem brualdi_ch13_9 {V : Type u} (T : Digraph V) (hT : IsTournament T) : T.StronglyConnected ↔ βˆƒ (u : V) (p : T.Walk u u), p.IsHamiltonianCycle := by sorry
brualdi_ch14_45
Let $n$ be an odd prime number. Prove that each of the permutations, $\rho_{n}, \rho_{n}^{2}, \ldots, \rho_{n}^{n}$ of $\{1,2, \ldots, n\}$ is an $n$-cycle. (Recall that $\rho_{n}$ is the permutation that sends 1 to 2,2 to $3, \ldots, n-1$ to $n$, and $n$ to 1.)
null
null
brualdi
import Mathlib theorem brualdi_ch14_45 {n : β„•} (h : Odd n) (hp : Nat.Prime n) : βˆ€ i ∈ Finset.Icc 1 n, ((finRotate n) ^ i).IsCycle := by sorry
brualdi_ch14_26
How many different necklaces are there that contain four red and three blue beads?
[ "15" ]
null
brualdi
import Mathlib structure PreNecklaces where c : Fin 7 β†’ Fin 2 deriving Fintype def myDihedralGroup (n : β„•) : Subgroup (Equiv.Perm (Fin n)) := Subgroup.closure {finRotate n, Fin.revPerm} instance Necklaces.setoid : Setoid PreNecklaces where r n1 n2 := βˆƒ s ∈ myDihedralGroup 7, n1.c = n2.c ∘ s iseqv := { refl n := ⟨1, one_mem _, by simp⟩ symm := by rintro m n ⟨p, hp, eqp⟩ refine ⟨p⁻¹, inv_mem hp, eqp β–Έ ?_⟩ ext x simp trans := by rintro a b c ⟨p, hp, eqp⟩ ⟨q, hq, eqq⟩ refine ⟨q * p, mul_mem hq hp, ?_⟩ rw [eqp, eqq] ext x simp } abbrev Necklaces := Quotient Necklaces.setoid noncomputable instance : Fintype Necklaces := by have := Quotient.finite (Necklaces.setoid) exact Fintype.ofFinite Necklaces abbrev brualdi_ch14_26_solution : β„• := sorry theorem brualdi_ch14_26 : Fintype.card Necklaces = brualdi_ch14_26_solution := by sorry
brualdi_ch14_33
Prove that a permutation and its inverse have the same type.
null
null
brualdi
import Mathlib theorem brualdi_ch14_33 {Ξ± : Type*} [Fintype Ξ±] [DecidableEq Ξ±] (Οƒ : Equiv.Perm Ξ±) : Οƒ.cycleType = σ⁻¹.cycleType := by sorry
apmo_1991_p2
Suppose there are 997 points given in a plane. If every two points are joined by a line segment with its midpoint coloured in red, show that there are at least 1991 red points in the plane.
null
null
math_competitions
import Mathlib noncomputable def red_points {k} (points : Fin k β†’ ℝ Γ— ℝ) : Finset (ℝ Γ— ℝ) := ((Finset.univ (Ξ± := Fin k Γ— Fin k)).image (fun x => midpoint ℝ (points x.1) (points x.2))) theorem apmo_1991_p2 (points : Fin 997 β†’ ℝ Γ— ℝ) : (red_points points).card β‰₯ 1991 := by sorry
apmo_2023_p1
Let $n \geq 5$ be an integer. Consider $n$ squares with side lengths $1,2, \ldots, n$, respectively. The squares are arranged in the plane with their sides parallel to the $x$ and $y$ axes. Suppose that no two squares touch, except possibly at their vertices.\nShow that it is possible to arrange these squares in a way such that every square touches exactly two other squares.
null
null
math_competitions
import Mathlib structure Square where (pos : ℝ Γ— ℝ) (side_length : β„•) def Square.vertices (s: Square) : List (ℝ Γ— ℝ) := let x := s.pos.1; let y := s.pos.2; let n : ℝ := s.side_length; [(x, y), (x + n, y), (x, y + n), (x + n, y + n)] def Square.contains (s : Square) (p : ℝ Γ— ℝ) : Prop := let x := s.pos.1; let y := s.pos.2; let n : ℝ := s.side_length; x ≀ p.1 ∧ p.1 ≀ x + n ∧ y ≀ p.2 ∧ p.2 ≀ y + n def touches (s1: Square) (s2: Square): Prop := βˆƒ v ∈ s1.vertices, s2.contains v def touches_interior_or_edge (s1: Square) (s2: Square): Prop := βˆƒ v ∈ s1.vertices, s2.contains v ∧ v βˆ‰ s2.vertices theorem apmo_2023_p1 (n : β„•) (h_n: n β‰₯ 5) : βˆƒ position: Fin n β†’ ℝ Γ— ℝ, (βˆ€ n1 n2 : Fin n, n1 β‰  n2 β†’ Β¬ touches_interior_or_edge ⟨position n1, n1 + 1⟩ ⟨position n2, n2 + 1⟩) ∧ βˆ€m : Fin n, βˆƒ l k, m β‰  l ∧ m β‰  k ∧ l β‰  k ∧ touches ⟨position m, m + 1⟩ ⟨position l, l + 1⟩ ∧ touches ⟨position m, m + 1⟩ ⟨position k, k + 1⟩ ∧ (βˆ€ j : Fin n, j βˆ‰ [m, l, k] β†’ Β¬ touches ⟨position m, m + 1⟩ ⟨position j, j + 1⟩) := by sorry
balticway_2015_p7
There are 100 members in a ladies' club. Each lady has had tea (in private) with exactly 56 of the other members of the club. The Board, consisting of the 50 most distinguished ladies, have all had tea with one another. Prove that the entire club may be split into two groups in such a way that, within each group, any lady has had tea with any other.
null
null
math_competitions
import Mathlib open SimpleGraph Finset abbrev Ladies := Fin 100 theorem balticway_2015_p7 (had_tea: SimpleGraph (Ladies)) [DecidableRel had_tea.Adj] (h_had_tea_with_56: βˆ€ l : Ladies, had_tea.degree l = 56) (h_board: βˆƒ board : Finset Ladies, board.card = 50 ∧ (βˆ€ l1 l2: board, had_tea.Adj l1 l2)) : βˆƒ group1 group2: Finset Ladies, group1 βˆͺ group2 = Finset.univ ∧ Disjoint group1 group2 ∧ (βˆ€ l1 l2: group1, had_tea.Adj l1 l2) ∧ (βˆ€ l1 l2: group2, had_tea.Adj l1 l2) := by sorry
egmo_2022_p5
For all positive integers $n, k$, let $f(n, 2k)$ be the number of ways an $n \times 2k$ board can be fully covered by $nk$ dominoes of size $2 \times 1$. (For example, $f(2,2)=2$ and $f(3,2)=3$.)\nFind all positive integers $n$ such that for every positive integer $k$, the number $f(n, 2k)$ is odd.
[ "{x | βˆƒ m > 0, 2 ^ m - 1 = x}" ]
null
math_competitions
import Mathlib def formsDomino (n k : β„•) (i j : Fin n Γ— Fin (2 * k)) : Bool := (i.1.val = j.1.val ∧ (i.2.val + 1 = j.2.val ∨ j.2.val + 1 = i.2.val)) ∨ (i.2.val = j.2.val ∧ (i.1.val + 1 = j.1.val ∨ j.1.val + 1 = i.1.val)) structure PerfectCover (n k : β„•) where d : Fin (n * k) β†’ ((Fin n Γ— Fin (2 * k)) Γ— (Fin n Γ— Fin (2 * k))) domino : βˆ€ i, formsDomino n k (d i).1 (d i).2 covers : βˆ€ i : Fin n Γ— Fin (2 * k), βˆƒ j, i = (d j).1 ∨ i = (d j).2 noncomputable instance {n k} : Fintype (PerfectCover n k) := Fintype.ofInjective PerfectCover.d <| by rintro ⟨d, _⟩ ⟨d', _⟩ (rfl : d = d') rfl abbrev egmo_2022_p5_solution : Set β„• := sorry theorem egmo_2022_p5 : {n | n > 0 ∧ βˆ€ k > 0, Odd (Fintype.card (PerfectCover n k))} = egmo_2022_p5_solution := by sorry
imosl_2011_c6
Let $n$ be a positive integer and let $W=\ldots x_{-1} x_{0} x_{1} x_{2} \ldots$ be an infinite periodic word consisting of the letters $a$ and $b$. Suppose that the minimal period $N$ of $W$ is greater than $2^{n}$. A finite nonempty word $U$ is said to appear in $W$ if there exist indices $k \leq \ell$ such that $U=x_{k} x_{k+1} \ldots x_{\ell}$. A finite word $U$ is called ubiquitous if the four words $U a, U b, a U$, and $b U$ all appear in $W$. Prove that there are at least $n$ ubiquitous finite nonempty words.
null
null
math_competitions
import Mathlib def appears (W : β„€ β†’ Fin 2) (U : Ξ£ n, Fin n β†’ Fin 2) : Prop := βˆƒ k, βˆ€ i : Fin U.1, U.2 i = W (k + i) def ubiquitous (W : β„€ β†’ Fin 2) (U : Ξ£ n, Fin n β†’ Fin 2) : Prop := appears W ⟨U.1 + 1, Fin.snoc U.2 0⟩ ∧ appears W ⟨U.1 + 1, Fin.snoc U.2 1⟩ ∧ appears W ⟨U.1 + 1, Fin.cons 0 U.2⟩ ∧ appears W ⟨U.1 + 1, Fin.cons 1 U.2⟩ theorem imosl_2011_c6 (W : β„€ β†’ Fin 2) (n : β„•+) (N : β„•) (hN : 2 ^ n.1 < N) (hW : Function.Periodic W N) (hW' : βˆ€ N' < N, Β¬ Function.Periodic W N') : βˆƒ (x : Fin n β†ͺ (Ξ£ k, Fin k β†’ Fin 2)), (βˆ€ i, (x i).1 β‰  0) ∧ (βˆ€ i, ubiquitous W (x i)) := by sorry
imosl_2015_c6
Let $S$ be a nonempty set of positive integers. We say that a positive integer $n$ is clean if it has a unique representation as a sum of an odd number of distinct elements from $S$. Prove that there exist infinitely many positive integers that are not clean.
null
null
math_competitions
import Mathlib def clean (S : Set β„•+) (n : β„•) : Prop := βˆƒ! (f : β„• β†’β‚€ β„•), (βˆ‘ i ∈ f.support, f i = n) ∧ (Odd f.support.card) ∧ (βˆ€ (i : β„•) (h : i ∈ f.support), ⟨f i, Nat.pos_of_ne_zero <| by aesop⟩ ∈ S) theorem imosl_2015_c6 (S : Set β„•+) : βˆ€ (N : β„•), βˆƒ (m : β„•), N < m ∧ Β¬ clean S m := by sorry
imosl_2019_c2
You are given a set of $n$ blocks, each weighing at least 1; their total weight is $2 n$. Prove that for every real number $r$ with $0 \leqslant r \leqslant 2 n-2$ you can choose a subset of the blocks whose total weight is at least $r$ but at most $r+2$.
null
null
math_competitions
import Mathlib theorem imosl_2019_c2 (n : β„•) (blocks : Fin n β†’ ℝ) (h1 : βˆ€ i, blocks i β‰₯ 1) (h2 : βˆ‘ i, blocks i = 2 * n) : βˆ€ r : ℝ, 0 ≀ r ∧ r ≀ 2 * n - 2 β†’ βˆƒ (s : Finset (Fin n)), (βˆ‘ i ∈ s, blocks i) β‰₯ r ∧ (βˆ‘ i ∈ s, blocks i) ≀ r + 2 := by sorry
imosl_2021_c5
Let $n$ and $k$ be two integers with $n > k \geqslant 1$. There are $2n+1$ students standing in a circle. Each student $S$ has $2k$ neighbours - namely, the $k$ students closest to $S$ on the right, and the $k$ students closest to $S$ on the left. Suppose that $n+1$ of the students are girls, and the other $n$ are boys. Prove that there is a girl with at least $k$ girls among her neighbours.
null
null
math_competitions
import Mathlib def leftNeighbors {n : β„•+} (people : Fin (2*n+1) β†’ ZMod 2) (k : β„•+) (i : Fin (2*n+1)) : Fin k β†’ ZMod 2 := fun j ↦ people <| (finRotate (2*n+1))^[j.1 + 1] i def rightNeighbors {n : β„•+} (people : Fin (2*n+1) β†’ ZMod 2) (k : β„•+) (i : Fin (2*n+1)) : Fin k β†’ ZMod 2 := fun j ↦ people <| (finRotate (2*n+1)).symm^[j.1 + 1] i theorem imosl_2021_c5 (n k : β„•+) (h : k < n) (people : Fin (2*n+1) β†’ ZMod 2) (num_boys : (List.ofFn people).count 0 = n) (num_girls : (List.ofFn people).count 1 = n+1): βˆƒ (i : Fin (2*n+1)), people i = 1 ∧ ((List.ofFn (leftNeighbors people k i)).count 1 + (List.ofFn (rightNeighbors people k i)).count 1 >= k) := by sorry
izho_2014_p3
There are given 100 distinct positive integers. We call a pair of integers among them good if the ratio of its elements is either 2 or 3. What is the maximum number $g$ of good pairs that these 100 numbers can form? (A same number can be used in several pairs.)
[ "180" ]
null
math_competitions
import Mathlib structure goodPairs (s : Fin 100 β†ͺ β„•+) where (i j : Fin 100) (ratio : s i = 2 * s j ∨ s i = 3 * s j) deriving Fintype abbrev izho_2014_p3_solution : β„• := sorry theorem izho_2014_p3 : IsGreatest (Set.range fun x => Fintype.card (goodPairs x)) izho_2014_p3_solution := by sorry
izho_2019_p1
Prove that there are at least 100! ways to partition the number 100! into summands from the set $\{1!, 2!, 3!, \ldots, 99!\}$. (Partitions differing in the order of summands are considered the same; any summand can be taken multiple times. We remind that $n!=1 \cdot 2 \cdot \ldots \cdot n$.)
null
null
math_competitions
import Mathlib open Nat theorem izho_2019_p1 : ((@Finset.univ 100!.Partition).filter (fun p => βˆ€ i ∈ p.parts, βˆƒ k ∈ Finset.Icc 1 99, i = Nat.factorial k)).card β‰₯ 100! := by sorry
bxmo_2017_p2
Let $n \geqslant 2$ be an integer. Alice and Bob play a game concerning a country made of $n$ islands. Exactly two of those $n$ islands have a factory. Initially there is no bridge in the country. Alice and Bob take turns in the following way. In each turn, the player must build a bridge between two different islands $I_{1}$ and $I_{2}$ such that:\n\n- $I_{1}$ and $I_{2}$ are not already connected by a bridge;\n- at least one of the two islands $I_{1}$ and $I_{2}$ is connected by a series of bridges to an island with a factory (or has a factory itself). (Indeed, access to a factory is needed for the construction.)\n\nAs soon as a player builds a bridge that makes it possible to go from one factory to the other, this player loses the game. (Indeed, it triggers an industrial battle between both factories.) If Alice starts, then determine (for each $n \geqslant 2$) who has a winning strategy.\n\n(Note: It is allowed to construct a bridge passing above another bridge.)
[ "fun x => if x % 4 = 3 then 0 else 1" ]
null
math_competitions
import Mathlib variable (m : β„•) local notation3 (prettyPrint := false) "n" => (m + 2) local notation3 (prettyPrint := false) "F1" => (0 : Fin n) local notation3 (prettyPrint := false) "F2" => (1 : Fin n) structure GameState where islands: SimpleGraph (Fin n) decidable: DecidableRel islands.Adj instance (s : GameState m) : DecidableRel s.islands.Adj := by exact s.decidable def GameState.initial : GameState m := { islands := βŠ₯ decidable := SimpleGraph.Bot.adjDecidable (Fin n) } structure Bridge where island1 : Fin n island2 : Fin n def reachableByFactory (s : GameState m) (b : Bridge m) : Prop := s.islands.Reachable b.island1 F1 ∨ s.islands.Reachable b.island1 F2 ∨ s.islands.Reachable b.island2 F1 ∨ s.islands.Reachable b.island2 F2 def isValidMove (s : GameState m) (b : Bridge m) : Prop := b.island1 β‰  b.island2 ∧ Β¬ s.islands.Adj b.island1 b.island2 ∧ reachableByFactory m s b def GameState.next (s : GameState m) (b : Bridge m) : GameState m := { islands := s.islands βŠ” (SimpleGraph.fromEdgeSet {s(b.island1, b.island2)}) decidable := by have newEdge: DecidableRel (SimpleGraph.fromEdgeSet {s(b.island1, b.island2)}).Adj := by intro x y; unfold SimpleGraph.fromEdgeSet simp only [Pi.inf_apply, Sym2.toRel_prop, Set.mem_singleton_iff, Sym2.eq, Sym2.rel_iff', Prod.mk.injEq, Prod.swap_prod_mk, ne_eq, inf_Prop_eq] infer_instance exact SimpleGraph.Sup.adjDecidable (Fin n) s.islands (SimpleGraph.fromEdgeSet {s(b.island1, b.island2)}) } def GameState.is_losing_state (s : GameState m) : Prop := s.islands.Reachable F1 F2 abbrev Strategy := GameState m β†’ Bridge m instance (s: GameState m) : Decidable (GameState.is_losing_state m s) := by simp [GameState.is_losing_state]; infer_instance instance (s: GameState m) (b : Bridge m) : Decidable (reachableByFactory m s b) := by simp [reachableByFactory]; infer_instance instance (s: GameState m) (b : Bridge m) : Decidable (isValidMove m s b) := by simp [isValidMove]; infer_instance structure MoveOutcome where nextState : GameState m hasLost : Bool def executeStrategy (s : GameState m) (strategy: Strategy m): MoveOutcome m := let bridge := strategy s if Β¬ isValidMove m s bridge then { nextState := s, hasLost := true } else let nextState := s.next m bridge { nextState := nextState, hasLost := nextState.is_losing_state m } partial def aliceWins (s : GameState m) (sA: Strategy m) (sB: Strategy m): Bool := let ⟨stateAfterAlicesMove, aliceHasLost⟩ := executeStrategy m s sA; if aliceHasLost then False else let ⟨stateAfterBobsMove, bobHasLost⟩ := executeStrategy m stateAfterAlicesMove sB; if bobHasLost then True else aliceWins stateAfterBobsMove sA sB abbrev bxmo_2017_p2_solution : β„• β†’ Fin 2 := sorry theorem bxmo_2017_p2 : (bxmo_2017_p2_solution n = 0 β†’ βˆƒ strategyA , βˆ€ strategyB, aliceWins m (GameState.initial m) strategyA strategyB) ∧ (bxmo_2017_p2_solution n = 1 β†’ βˆƒ strategyB, βˆ€ strategyA, Β¬ aliceWins m (GameState.initial m) strategyA strategyB) := by sorry
usamo_2000_p4
Find the smallest positive integer $n$ such that if $n$ squares of a $1000 \times 1000$ chessboard are colored, then there will exist three colored squares whose centers form a right triangle with sides parallel to the edges of the board.
[ "1999" ]
null
math_competitions
import Mathlib def colored_card : Finset β„• := (Finset.image (fun s => s.card) (@Finset.univ (Finset (Fin 1000 Γ— Fin 1000)) _ |>.filter (fun s => βˆƒ a ∈ s, βˆƒ b ∈ s, βˆƒ c ∈ s, a β‰  b ∧ b β‰  c ∧ a β‰  c ∧ a.1 = b.1 ∧ a.2 = c.2))) abbrev usamo_2000_p4_solution : β„•+ := sorry theorem usamo_2000_p4 : IsLeast colored_card usamo_2000_p4_solution.1 := by sorry
imo_2009_p6
Let $a_1,a_2,\ldots,a_n$ be distinct positive integers and let $M$ be a set of $n-1$ positive integers not containing $s=a_1+a_2+\ldots+a_n$. A grasshopper is to jump along the real axis, starting at the point $0$ and making $n$ jumps to the right with lengths $a_1,a_2,\ldots,a_n$ in some order. Prove that the order can be chosen in such a way that the grasshopper never lands on any point in $M$.
null
null
imo
import Mathlib open BigOperators Finset theorem imo_2009_p6 (n : β„•) (hn : n β‰₯ 1) (a : Fin n β†’ β„•) (ha : Function.Injective a) (M : Finset β„•) (ha' : βˆ€ i, a i > 0) (hM : M.card = n - 1) (hM' : βˆ€ m ∈ M, m > 0) (haM : βˆ‘ n, (a n) βˆ‰ M) : βˆƒ (Οƒ : Equiv.Perm (Fin n)), βˆ€ k, (βˆ‘ i ≀ k, (a ∘ Οƒ) i) βˆ‰ M := by sorry
imo_2020_p3
There are $4n$ pebbles of weights $1, 2, 3, \ldots, 4n$. Each pebble is colored in one of $n$ colors and there are four pebbles of each color. Show that we can arrange the pebbles into two piles so that the following two conditions are both satisfied: 1) The total weights of both piles are the same. 2) Each pile contains two pebbles of each color.
null
null
imo
import Mathlib structure Pebble (n : β„•) where weight : β„• color : Fin n deriving DecidableEq theorem imo_2020_p3 (n : β„•) (PebbleSet : Finset (Pebble n)) (hP : PebbleSet.card = 4 * n) (h_weight : βˆ€ p ∈ PebbleSet, p.weight ∈ Finset.Icc 1 (4 * n)) (h_ne_weight : βˆ€ p ∈ PebbleSet, βˆ€ q ∈ PebbleSet, p β‰  q β†’ p.weight β‰  q.weight) (h_color : βˆ€ i, (PebbleSet.filter (fun p => p.color = i)).card = 4) : βˆƒ (P1 P2 : Finset (Pebble n)), P1 βˆͺ P2 = PebbleSet ∧ P1 ∩ P2 = βˆ… ∧ βˆ‘ p ∈ P1, p.weight = βˆ‘ p ∈ P2, p.weight ∧ (βˆ€ i, (P1.filter (fun p => p.color = i)).card = 2) ∧ (βˆ€ i, (P2.filter (fun p => p.color = i)).card = 2) := by sorry
imo_2022_p6
Let $n$ be a positive integer. A Nordic square is an $n \times n$ board containing all the integers from $1$ to $n^2$ so that each cell contains exactly one number. Two different cells are considered adjacent if they share an edge. Every cell that is adjacent only to cells containing larger numbers is called a valley. An uphill path is a sequence of one or more cells such that: (i) the first cell in the sequence is a valley, (ii) each subsequent cell in the sequence is adjacent to the previous cell, and (iii) the numbers written in the cells in the sequence are in increasing order. Find, as a function of $n$, the smallest possible total number of uphill paths in a Nordic square.
[ "fun n => 2 * n ^ 2 - 2 * n + 1" ]
null
imo
import Mathlib open Function set_option autoImplicit false variable {n : β„•} def Adjacent (x y : Fin n Γ— Fin n) : Prop := x β‹– y ∨ y β‹– x abbrev NordicSquare (n : β„•) := Fin n Γ— Fin n ≃ Fin (n ^ 2) namespace NordicSquare variable {sq : NordicSquare n} def IsValley (sq : NordicSquare n) (x : Fin n Γ— Fin n) : Prop := βˆ€ ⦃y : Fin n Γ— Fin n⦄, Adjacent x y β†’ sq x ≀ sq y structure UphillPath (sq : NordicSquare n) extends RelSeries fun x y ↦ Adjacent x y ∧ sq x < sq y where head : sq.IsValley toRelSeries.head namespace UphillPath lemma toRelSeries_injective : Injective (toRelSeries : sq.UphillPath β†’ RelSeries _) := fun p q ↦ by cases p; congr! instance [NeZero n] : Inhabited sq.UphillPath where default.toRelSeries := .singleton _ <| sq.symm 0 default.head y _ := by simp instance : CoeFun sq.UphillPath fun x ↦ Fin (x.length + 1) β†’ Fin n Γ— Fin n where coe f := f.1 instance : IsTrans (Fin n Γ— Fin n) fun x y ↦ sq x < sq y where trans _ _ _ := lt_trans lemma strictMono (p : sq.UphillPath) : StrictMono fun x ↦ sq (p x) := fun _ _ ↦ (p.ofLE fun _ _ ↦ And.right).rel_of_lt lemma length_lt (p : sq.UphillPath) : p.length < n ^ 2 := by simpa using Fintype.card_le_of_injective _ p.strictMono.injective instance : Finite sq.UphillPath := @Finite.of_injective _ {l : List (Fin n Γ— Fin n) // l.length ≀ n ^ 2} (List.finite_length_le _ _) (fun p ↦ ⟨p.toList, by simpa using p.length_lt⟩) fun p q hpq ↦ toRelSeries_injective <| RelSeries.toList_injective congr(($hpq).val) noncomputable instance : Fintype sq.UphillPath := .ofFinite _ end NordicSquare.UphillPath abbrev imo_2022_p6_solution : β„• β†’ β„• := sorry lemma imo_2022_p6 (n : β„•) (hn : n > 0) : IsLeast {k | βˆƒ (sq : NordicSquare n), k = Fintype.card sq.UphillPath} (imo_2022_p6_solution n) := by sorry
imo_2024_p3
Let $a_1, a_2, a_3, \dots$ be an infinite sequence of positive integers, and let $N$ be a positive integer. Suppose that, for each $n > N$, $a_n$ is equal to the number of times $a_{n-1}$ appears in the list $a_1, a_2, \dots, a_{n-1}$. Prove that at least one of the sequence $a_1, a_3, a_5, \dots$ and $a_2, a_4, a_6, \dots$ is eventually periodic. (An infinite sequence $b_1, b_2, b_3, \dots$ is eventually periodic if there exist positive integers $p$ and $M$ such that $b_{m+p} = b_m$ for all $m \ge M$.)
null
null
imo
import Mathlib open scoped Finset def Condition (a : β„• β†’ β„•) (N : β„•) : Prop := (βˆ€ i, 0 < a i) ∧ βˆ€ n, N < n β†’ a n = #{i ∈ Finset.range n | a i = a (n - 1)} def EventuallyPeriodic (b : β„• β†’ β„•) : Prop := βˆƒ p M, 0 < p ∧ βˆ€ m, M ≀ m β†’ b (m + p) = b m theorem imo_2024_p3 {a : β„• β†’ β„•} {N : β„•} (h : Condition a N) : EventuallyPeriodic (fun i ↦ a (2 * i)) ∨ EventuallyPeriodic (fun i ↦ a (2 * i + 1)) := by sorry
imo_2000_p4
A magician has one hundred cards numbered $1$ to $100$. He puts them into three boxes, a red one, a white one and a blue one, so that each box contains at least one card. A member of the audience selects two of the three boxes, chooses one card from each and announces the sum of the numbers on the chosen cards. Given this sum, the magician identifies the box from which no card has been chosen. How many ways are there to put all the cards into the boxes so that this trick always works? (Two ways are considered different if at least one card is put into a different box.)
[ "12" ]
null
imo
import Mathlib abbrev Cards := Fin 100 abbrev Boxes := Fin 3 abbrev Allocation := { f : Cards β†’ Boxes | Function.Surjective f } abbrev Trick := β„• β†’ Boxes def trick_works (f : Allocation) (t : Trick) : Prop := βˆ€ c₁ cβ‚‚ : Cards, (f.1 c₁ = 0 β†’ f.1 cβ‚‚ = 1 β†’ t (c₁.1 + cβ‚‚.1) = 2) ∧ (f.1 c₁ = 0 β†’ f.1 cβ‚‚ = 2 β†’ t (c₁.1 + cβ‚‚.1) = 1) ∧ (f.1 c₁ = 1 β†’ f.1 cβ‚‚ = 2 β†’ t (c₁.1 + cβ‚‚.1) = 0) abbrev imo_2000_p4_solution : β„• := sorry theorem imo_2000_p4 (good_allocations : Finset Allocation) (h : βˆ€ f ∈ good_allocations, βˆƒ (t : Trick), trick_works f t) : good_allocations.card = imo_2000_p4_solution := by sorry
imo_2001_p3
Twenty-one girls and twenty-one boys took part in a mathematical competition. It turned out that each contestant solved at most six problems, and for each pair of a girl and a boy, there was at least one problem that was solved by both the girl and the boy. Show that there is a problem that was solved by at least three girls and at least three boys.
null
null
imo
import Mathlib def solved_by_at_least_three {n : β„•} (problem : β„•) (solved_problems: Fin n β†’ Finset β„•) : Prop := βˆƒ a b c, a β‰  b ∧ b β‰  c ∧ a β‰  c ∧ problem ∈ solved_problems a ∩ solved_problems b ∩ solved_problems c theorem imo_2001_p3 (solved_problems_girls: Fin 21 β†’ Finset β„•) (solved_problems_boys: Fin 21 β†’ Finset β„•) (h_max_6_girls: βˆ€ girl: Fin 21, (solved_problems_girls girl).card ≀ 6) (h_max_6_boys: βˆ€ boy: Fin 21, (solved_problems_boys boy).card ≀ 6) (h_pairs: βˆ€ boy girl: Fin 21, solved_problems_boys boy ∩ solved_problems_girls girl β‰  βˆ…): βˆƒ problem: β„•, solved_by_at_least_three problem solved_problems_girls ∧ solved_by_at_least_three problem solved_problems_boys := by sorry
imo_2001_p4
Let $n_1, n_2, \dots , n_m$ be integers where $m>1$ is odd. Let $x = (x_1, \dots , x_m)$ denote a permutation of the integers $1, 2, \cdots , m$. Let $f(x) = x_1n_1 + x_2n_2 + ... + x_mn_m$. Show that for some distinct permutations $a$, $b$ the difference $f(a) - f(b)$ is a multiple of $m!$.
null
null
imo
import Mathlib open Nat def f {m : β„•} (n : Finset.Icc 1 m β†’ β„€) (x : Equiv.Perm (Finset.Icc 1 m)) : β„€ := βˆ‘ i, x i * n i theorem imo_2001_p4 (m : β„•) (h_m_pos: m > 1) (h_m_odd: Odd m) (n : Finset.Icc 1 m β†’ β„€): βˆƒ a b : Equiv.Perm (Finset.Icc 1 m), a β‰  b ∧ ↑(m !) ∣ (f n a - f n b) := by sorry
imo_2002_p1
$S$ is the set of all $(h,k)$ with $h,k$ non-negative integers such that $h + k < n$. Each element of $S$ is colored red or blue, so that if $(h,k)$ is red and $h' \le h,k' \le k$, then $(h',k')$ is also red. A type $1$ subset of $S$ has $n$ blue elements with different first member and a type $2$ subset of $S$ has $n$ blue elements with different second member. Show that there are the same number of type $1$ and type $2$ subsets.
null
null
imo
import Mathlib open Finset def S (n : β„•) : Finset (Fin n Γ— Fin n) := { (h, k) | h + k < n } structure Coloring (n : β„•) where is_red: S n β†’ Bool coloring_condition: βˆ€ hk hk' : S n, match hk.val, hk'.val with | (h, k), (h', k') => is_red hk ∧ h' ≀ h ∧ k' ≀ k β†’ is_red hk' def is_type_1 {n : β„•} (c : Coloring n) (subset: Finset (S n)) : Bool := let blueElements := subset.filter (Ξ» x => Β¬ c.is_red x) let firstMembersOfBlueElements : Finset (Fin n) := blueElements.image (Ξ» x : S n => x.val.1) firstMembersOfBlueElements.card = n def is_type_2 {n : β„•} (c : Coloring n) (subset: Finset (S n)) : Bool := let blueElements := subset.filter (Ξ» x => Β¬ c.is_red x) let secondMembersOfBlueElements : Finset (Fin n) := blueElements.image (Ξ» x : S n => x.val.2) secondMembersOfBlueElements.card = n theorem imo_2002_p1 (n : β„•) (c : Coloring n): #{ s | is_type_1 c s }.toFinset = #{ s | is_type_2 c s }.toFinset := by sorry
imo_2003_p1
$S$ is the set $\{1, 2, 3, \dots ,1000000\}$. Show that for any subset $A$ of $S$ with $101$ elements we can find $100$ distinct elements $x_i$ of $S$, such that the sets $\{a + x_i \mid a \in A\}$ are all pairwise disjoint.
null
null
imo
import Mathlib def S := Finset.Icc 1 1000000 theorem imo_2003_p1 (A : Finset S) (hA: A.card = 101): βˆƒ x : Function.Embedding (Fin 100) S, βˆ€ i j, i β‰  j β†’ Disjoint { a.1 + (x i).1 | a ∈ A } { a.1 + (x j).1 | a ∈ A } := by sorry
imo_2005_p6
In a mathematical competition, in which 6 problems were posed to the participants, every two of these problems were solved by more than 2/5 of the contestants. Moreover, no contestant solved all the 6 problems. Show that there are at least 2 contestants who solved exactly 5 problems each.
null
null
imo
import Mathlib theorem imo_2005_p6 {participants : Type} [Fintype participants] [DecidableEq participants] (solved : Fin 6 β†’ Finset participants) (h : βˆ€ i j, i β‰  j β†’ (solved i ∩ solved j).card > (2 * Fintype.card participants : ℝ) / 5) (h' : βˆ€ i, (solved i).card < Fintype.card participants) : βˆƒ s : Finset participants, s.card β‰₯ 2 ∧ (βˆ€ i ∈ s, βˆƒ p : Finset (Fin 6), p.card = 5 ∧ βˆ€ j, j ∈ p ↔ i ∈ solved j) := by sorry
imo_2006_p2
Let $P$ be a regular 2006-gon. A diagonal of $P$ is called good if its endpoints divide the boundary of $P$ into two parts, each composed of an odd number of sides of $P$. The sides of $P$ are also called good. Suppose $P$ has been dissected into triangles by 2003 diagonals, no two of which have a common point in the interior of $P$. Find the maximum number of isosceles triangles having two good sides that could appear in such a configuration.
[ "1003" ]
null
imo
import Mathlib open scoped Classical Finset instance {N : β„•} : CircularOrder (Fin N) := LinearOrder.toCircularOrder _ variable {Ξ± : Type*} [CircularOrder Ξ±] {a b c d : Ξ±} def SBtwβ‚„ (a b c d : Ξ±) : Prop := sbtw a b c ∧ sbtw c d a lemma sbtwβ‚„_swap : SBtwβ‚„ a b c d ↔ SBtwβ‚„ c d a b := and_comm variable {N : β„•} abbrev Diagonal (N : β„•) := {e : Sym2 (Fin N) // Β¬ e.IsDiag} namespace Diagonal def Intersect (d₁ dβ‚‚ : Diagonal N) : Prop := Sym2.liftβ‚‚ { val a b c d := SBtwβ‚„ a c b d ∨ SBtwβ‚„ a d b c property a b c d := by simp only [eq_iff_iff]; constructor <;> rw [sbtwβ‚„_swap, or_comm, sbtwβ‚„_swap] } d₁.1 dβ‚‚.1 def Good (d : Diagonal N) : Prop := Sym2.lift { val a b := Odd (a.val + b.val : β„•) property a b := by simp [add_comm] } d.1 end Diagonal structure TriangleDissection (N : β„•) where diagonals : Fin (2 * N - 3) β†ͺ Diagonal N pairwise_not_intersect_diagonals : Pairwise fun i j ↦ Β¬ (diagonals i).Intersect (diagonals j) noncomputable def TriangleDissection.numOfIsoscelesTriangle (C : TriangleDissection N) : β„• := by classical exact #{(a, b, c) : Fin N Γ— Fin N Γ— Fin N | βˆƒ (hab : a < b) (hbc : b < c), (βˆƒ i, C.diagonals i = s(a, b)) ∧ (βˆƒ i, C.diagonals i = s(b, c)) ∧ (βˆƒ i, C.diagonals i = s(c, a)) ∧ ( Diagonal.Good ⟨s(a, b), by simpa using hab.ne⟩ ∧ Diagonal.Good ⟨s(b, c), by simpa using hbc.ne⟩ ∨ Diagonal.Good ⟨s(b, c), by simpa using hbc.ne⟩ ∧ Diagonal.Good ⟨s(c, a), by simpa using (hab.trans hbc).ne'⟩ ∨ Diagonal.Good ⟨s(c, a), by simpa using (hab.trans hbc).ne'⟩ ∧ Diagonal.Good ⟨s(a, b), by simpa using hab.ne⟩) ∧ ((b.val - a.val : β„€) = c.val - b.val ∨ (c.val - b.val : β„€) = N + a.val - c.val ∨ (N + a.val - c.val : β„€) = b.val - a.val)} abbrev imo_2006_p2_solution : β„• := sorry theorem imo_2006_p2 : IsGreatest {k | βˆƒ c : TriangleDissection 2006, c.numOfIsoscelesTriangle = k} imo_2006_p2_solution := by sorry
imo_2007_p3
In a mathematical competition some competitors are friends. Friendship is always mutual. Call a group of competitors a clique if each two of them are friends. (In particular, any group of fewer than two competitors is a clique.) The number of members of a clique is called its size. Given that, in this competition, the largest size of a clique is even, prove that the competitors can be arranged in two rooms such that the largest size of a clique contained in one room is the same as the largest size of a clique contained in the other room.
null
null
imo
import Mathlib theorem imo_2007_p3 {player : Type} [Fintype player] (math_competiton : SimpleGraph player) (h : Even math_competiton.cliqueNum) : βˆƒ a : SimpleGraph.Subgraph math_competiton, a.coe.cliqueNum = aᢜ.coe.cliqueNum := by sorry
imo_2008_p5
Let $n$ and $k$ be positive integers with $k \geq n$ and $k - n$ an even number. Let $2n$ lamps labelled $1$, $2$, ..., $2n$ be given, each of which can be either on or off. Initially all the lamps are off. We consider sequences of steps: at each step one of the lamps is switched (from on to off or from off to on). Let $N$ be the number of such sequences consisting of $k$ steps and resulting in the state where lamps $1$ through $n$ are all on, and lamps $n + 1$ through $2n$ are all off. Let $M$ be number of such sequences consisting of $k$ steps, resulting in the state where lamps $1$ through $n$ are all on, and lamps $n + 1$ through $2n$ are all off, but where none of the lamps $n + 1$ through $2n$ is ever switched on. Determine $\frac{N}{M}$.
[ "fun n k => 2 ^ (k.1 - n.1)" ]
null
imo
import Mathlib def switch_lamp (n : β„•+) (switch_label : Fin (2 * n)) (lamps_state : List Bool) : List Bool := List.mapIdx (fun j (x : Bool) => if j = switch_label then Β¬x else x) lamps_state def lamps_final_state (n : β„•+) (switch_list : List (Fin (2 * n))) : List Bool := match switch_list with | [] => (List.ofFn (fun _ : Fin (2 * n) => false)) | h :: t => switch_lamp n h (lamps_final_state n t) def final_goal (n : β„•+) := List.ofFn (fun (i : Fin (2 * n)) => if i < n then true else false) def N (n k : β„•+) := @Finset.univ (Fin k β†’ Fin (2 * n)) _ |>.filter (fun f => lamps_final_state n (List.ofFn f) = final_goal n) |>.card def M (n k : β„•+) := @Finset.univ (Fin k β†’ Fin (2 * n)) _ |>.filter (fun f => βˆ€ (i : Fin k), f i < (n : Fin (2 * n))) |>.filter (fun f => lamps_final_state n (List.ofFn f) = final_goal n) |>.card abbrev imo_2008_p5_solution : β„•+ β†’ β„•+ β†’ ℝ := sorry theorem imo_2008_p5 (n k : β„•+) (hnk : k β‰₯ n) (hnk' : Even (k - n)) : N n k / M n k = imo_2008_p5_solution n k := by sorry
imo_2010_p5
Each of the six boxes $B_1$, $B_2$, $B_3$, $B_4$, $B_5$, $B_6$ initially contains one coin. The following operations are allowed: Type 1) Choose a non-empty box $B_j$, $1\leq j \leq 5$, remove one coin from $B_j$ and add two coins to $B_{j+1}$; Type 2) Choose a non-empty box $B_k$, $1\leq k \leq 4$, remove one coin from $B_k$ and swap the contents (maybe empty) of the boxes $B_{k+1}$ and $B_{k+2}$. Determine if there exists a finite sequence of operations of the allowed types, such that the five boxes $B_1$, $B_2$, $B_3$, $B_4$, $B_5$ become empty, while box $B_6$ contains exactly $2010^{2010^{2010}}$ coins.
[ "true" ]
null
imo
import Mathlib structure Boxes where (B1 B2 B3 B4 B5 B6 : β„•) def op11 : Boxes β†’ Boxes | ⟨b1, b2, b3, b4, b5, b6⟩ => ⟨b1 - 1, b2 + 2, b3, b4, b5, b6⟩ def op12 : Boxes β†’ Boxes | ⟨b1, b2, b3, b4, b5, b6⟩ => ⟨b1, b2 - 1, b3 + 2, b4, b5, b6⟩ def op13 : Boxes β†’ Boxes | ⟨b1, b2, b3, b4, b5, b6⟩ => ⟨b1, b2, b3 - 1, b4 + 2, b5, b6⟩ def op14 : Boxes β†’ Boxes | ⟨b1, b2, b3, b4, b5, b6⟩ => ⟨b1, b2, b3, b4 - 1, b5 + 2, b6⟩ def op15 : Boxes β†’ Boxes | ⟨b1, b2, b3, b4, b5, b6⟩ => ⟨b1, b2, b3, b4, b5 - 1, b6 + 2⟩ def op21 : Boxes β†’ Boxes | ⟨b1, b2, b3, b4, b5, b6⟩ => ⟨b1 - 1, b3, b2, b4, b5, b6⟩ def op22 : Boxes β†’ Boxes | ⟨b1, b2, b3, b4, b5, b6⟩ => ⟨b1, b2 - 4, b4, b3, b5, b6⟩ def op23 : Boxes β†’ Boxes | ⟨b1, b2, b3, b4, b5, b6⟩ => ⟨b1, b2, b3 - 1, b5, b4, b6⟩ def op24 : Boxes β†’ Boxes | ⟨b1, b2, b3, b4, b5, b6⟩ => ⟨b1, b2, b3, b4 - 1, b6, b5⟩ inductive OP | op11 | op12 | op13 | op14 | op15 | op21 | op22 | op23 | op24 def apply_op : OP β†’ (Boxes β†’ Boxes) | OP.op11 => op11 | OP.op12 => op12 | OP.op13 => op13 | OP.op14 => op14 | OP.op15 => op15 | OP.op21 => op21 | OP.op22 => op22 | OP.op23 => op23 | OP.op24 => op24 def init : Boxes := ⟨1, 1, 1, 1, 1, 1⟩ abbrev imo_2010_p5_solution : Bool := sorry theorem imo_2010_p5 : imo_2010_p5_solution = (βˆƒ seq : List OP, (seq.map apply_op).foldl (Β· ∘ Β·) id init = ⟨0, 0, 0, 0, 0, 2010 ^ (2010 ^ 2010)⟩) := by sorry
imo_2011_p2
Let $\mathcal{S}$ be a finite set of at least two points in the plane. Assume that no three points of $\mathcal S$ are collinear. A windmill is a process that starts with a line $\ell$ going through a single point $P \in \mathcal S$. The line rotates clockwise about the pivot $P$ until the first time that the line meets some other point belonging to $\mathcal S$. This point, $Q$, takes over as the new pivot, and the line now rotates clockwise about $Q$, until it next meets a point of $\mathcal S$. This process continues indefinitely. Show that we can choose a point $P$ in $\mathcal S$ and a line $\ell$ going through $P$ such that the resulting windmill uses each point of $\mathcal S$ as a pivot infinitely many times.
null
null
imo
import Mathlib open EuclideanGeometry Real Filter namespace List variable {Ξ± Ξ² : Type*} @[mk_iff] inductive Triplewise (p : Ξ± β†’ Ξ± β†’ Ξ± β†’ Prop) : List Ξ± β†’ Prop | nil : [].Triplewise p | cons {a : Ξ±} {l : List Ξ±} : l.Pairwise (p a) β†’ l.Triplewise p β†’ (a :: l).Triplewise p end List instance : Fact (Module.finrank ℝ (EuclideanSpace ℝ (Fin 2)) = 2) := ⟨by simp⟩ variable {n} [Fintype n] [DecidableEq n] noncomputable instance : Module.Oriented ℝ (EuclideanSpace ℝ n) n where positiveOrientation := Basis.orientation (Pi.basisFun ℝ n) structure IsWindmillProcess (S : Set (EuclideanSpace ℝ (Fin 2))) (f : β„• β†’ EuclideanSpace ℝ (Fin 2)) where forall_mem n : f n ∈ S oangle_le_oangle n x : x ∈ S β†’ toIocMod two_pi_pos 0 (oangle (f n) (f (n + 1)) (f (n + 2))).toReal ≀ toIocMod two_pi_pos 0 (oangle (f n) (f (n + 1)) x).toReal theorem imo_2011_p2 (l : List (EuclideanSpace ℝ (Fin 2))) (hl : l.Triplewise (Β¬ Collinear ℝ {Β·, Β·, Β·})) : βˆƒ f : β„• β†’ EuclideanSpace ℝ (Fin 2), IsWindmillProcess {x | x ∈ l} f ∧ βˆ€ x ∈ l, βˆƒαΆ  n in atTop, f n = x := by sorry
imo_2011_p4
Let $n > 0$ be an integer. We are given a balance and $n$ weights of weight $2^0,2^1, \cdots ,2^{n-1}$. We are to place each of the $n$ weights on the balance, one after another, in such a way that the right pan is never heavier than the left pan. At each step we choose one of the weights that has not yet been placed on the balance, and place it on either the left pan or the right pan, until all of the weights have been placed. Determine the number of ways in which this can be done.
[ "fun n => Nat.doubleFactorial (2 * n - 1)" ]
null
imo
import Mathlib def weight_of_left_pan {n : β„•} (Οƒ : Equiv.Perm (Fin n)) (place_left : Fin n β†’ Bool) (step : β„•) : β„• := βˆ‘ j with place_left j = true ∧ Οƒ j ≀ step, 2 ^ j.1 def weight_of_right_pan {n : β„•} (Οƒ : Equiv.Perm (Fin n)) (place_left : Fin n β†’ Bool) (step : β„•) : β„• := βˆ‘ j with place_left j = false ∧ Οƒ j ≀ step, 2 ^ j.1 def is_valid_placement {n : β„•} (Οƒ : Equiv.Perm (Fin n)) (place_left : Fin n β†’ Bool) : Prop := βˆ€ step : Fin n, weight_of_right_pan Οƒ place_left step ≀ weight_of_left_pan Οƒ place_left step instance {n : β„•} (Οƒ : Equiv.Perm (Fin n)) (place_left : Fin n β†’ Bool) : Decidable (is_valid_placement Οƒ place_left) := by simp [is_valid_placement]; infer_instance abbrev all_placements (n : β„•) := Finset.product (@Finset.univ (Equiv.Perm (Fin n)) _) (@Finset.univ (Fin n β†’ Bool) _) abbrev valid_placements (n : β„•) := all_placements n |>.filter (fun (Οƒ, f) => is_valid_placement Οƒ f) abbrev imo_2011_p4_solution : β„• β†’ β„• := sorry theorem imo_2011_p4 (n : β„•) (hn : n > 0) : (valid_placements n).card = imo_2011_p4_solution n := by sorry
imo_2012_p3
The liar’s guessing game is a game played between two players A and B. The rules of the game depend on two positive integers $k$ and $n$ which are known to both players. At the start of the game the player A chooses integers $x$ and $N$ with $1 \le x \le N$. Player A keeps $x$ secret, and truthfully tells $N$ to the player B. The player B now tries to obtain information about $x$ by asking player A questions as follows: each question consists of B specifying an arbitrary set $S$ of positive integers (possibly one specified in some previous question), and asking A whether $x$ belongs to $S$. Player B may ask as many questions as he wishes. After each question, player A must immediately answer it with yes or no, but is allowed to lie as many times as she wants; the only restriction is that, among any $k+1$ consecutive answers, at least one answer must be truthful. After B has asked as many questions as he wants, he must specify a set $X$ of at most $n$ positive integers. If $x \in X$, then B wins; otherwise, he loses. Prove that: (a) If $n \ge 2^k$ then B has a winning strategy. (b) There exists a positive integer $k_0$ such that for every $k \ge k_0$ there exists an integer $n \ge 1.99^k$ for which B cannot guarantee a victory.
null
null
imo
import Mathlib open scoped Finset set_option autoImplicit false structure AliceStrategy where N : β„• x : Fin N nextAnswer : List (Set (Fin N) Γ— Bool) β†’ Set (Fin N) β†’ Bool structure BobStrategy where nextQuestion N : List (Set (Fin N) Γ— Bool) β†’ Set (Fin N) guess N : List (Set (Fin N) Γ— Bool) β†’ Finset (Fin N) variable {k n : β„•} def history (A : AliceStrategy) (B : BobStrategy) : β„• β†’ List (Set (Fin A.N) Γ— Bool) | 0 => [] | t + 1 => (B.nextQuestion A.N (history A B t), A.nextAnswer (history A B t) (B.nextQuestion A.N (history A B t))) :: history A B t def AliceStrategy.IsValid (A : AliceStrategy) (B : BobStrategy) (k : β„•) : Prop := βˆ€ tβ‚€ : β„•, βˆƒ t ∈ Finset.Ico tβ‚€ (tβ‚€ + k), A.nextAnswer (history A B t) (B.nextQuestion A.N (history A B t)) = (A.x ∈ B.nextQuestion A.N (history A B t)) def BobStrategy.IsValid (A : AliceStrategy) (B : BobStrategy) (n t : β„•) : Prop := #(B.guess A.N (history A B t)) ≀ n def BobStrategy.IsWinning (B : BobStrategy) (k n : β„•) : Prop := βˆ€ (A : AliceStrategy), A.IsValid B k β†’ βˆƒ t, B.IsValid A n t ∧ A.x ∈ B.guess A.N (history A B t) theorem imo_2012_p3 : (βˆ€ k n, 2 ^ k ≀ n β†’ βˆƒ B : BobStrategy, B.IsWinning k n) ∧ βˆƒ kβ‚€, βˆ€ k β‰₯ kβ‚€, βˆƒ n : β„•, n β‰₯ (1.99 : ℝ) ^ k ∧ βˆ€ B : BobStrategy, Β¬ B.IsWinning k n := by sorry
imo_2013_p2
A configuration of $4027$ points in the plane is called Colombian if it consists of $2013$ red points and $2014$ blue points, and no three of the points of the configuration are collinear. By drawing some lines, the plane is divided into several regions. An arrangement of lines is good for a Colombian configuration if the following two conditions are satisfied: (1) no line passes through any point of the configuration; (2)no region contains points of both colours. Find the least value of $k$ such that for any Colombian configuration of $4027$ points, there is a good arrangement of $k$ lines.
[ "2013" ]
null
imo
import Mathlib structure Colombian_config : Type where (R B : Finset (ℝ Γ— ℝ)) (hR : R.card = 2013) (hB : B.card = 2014) (hC : R ∩ B = βˆ…) (h_no_collinear : βˆ€ p ∈ R βˆͺ B, βˆ€ q ∈ R βˆͺ B, βˆ€ r ∈ R βˆͺ B, p β‰  q β†’ p β‰  r β†’ q β‰  r β†’ Β¬ βˆƒ t : ℝ, t β‰  0 ∧ t * (q.1 - p.1) = (r.1 - p.1) ∧ t * (q.2 - p.2) = (r.2 - p.2)) def Good_arrange (C : Colombian_config) (L : Finset (ℝ Γ— ℝ Γ— ℝ)) : Prop := (βˆ€ l ∈ L, l.1 β‰  0 ∨ l.2.1 β‰  0) ∧ (βˆ€ p ∈ C.R βˆͺ C.B, βˆ€ l ∈ L, l.1 * p.1 + l.2.1 * p.2 + l.2.2 β‰  0) ∧ Β¬ (βˆƒ q ∈ C.R, βˆƒ p ∈ C.B, βˆ€ l ∈ L, Real.sign (l.1 * p.1 + l.2.1 * p.2 + l.2.2) = Real.sign (l.1 * q.1 + l.2.1 * q.2 + l.2.2)) abbrev imo_2013_p2_solution : β„• := sorry theorem imo_2013_p2 : IsLeast {k | βˆ€ C : Colombian_config, βˆƒ L : Finset (ℝ Γ— ℝ Γ— ℝ), L.card = k ∧ Good_arrange C L} imo_2013_p2_solution := by sorry
imo_2013_p6
Let $n \ge 3$ be an integer, and consider a circle with $n + 1$ equally spaced points marked on it. Consider all labellings of these points with the numbers $0, 1, ... , n$ such that each label is used exactly once; two such labellings are considered to be the same if one can be obtained from the other by a rotation of the circle. A labelling is called beautiful if, for any four labels $a < b < c < d$ with $a + d = b + c$, the chord joining the points labelled $a$ and $d$ does not intersect the chord joining the points labelled $b$ and $c$. Let $M$ be the number of beautiful labelings, and let N be the number of ordered pairs $(x, y)$ of positive integers such that $x + y \le n$ and $\gcd(x, y) = 1$. Prove that\[ M = N + 1.\]
null
null
imo
import Mathlib open Equiv Fintype Finset def IsBeautiful {n} (e : Perm (Fin (n + 1))) : Prop := βˆ€ ⦃a b⦄, a < b β†’ βˆ€ ⦃c⦄, b < c β†’ βˆ€ ⦃d⦄, c < d β†’ a.val + d.val = b.val + c.val β†’ e a < e b ∧ e b < e d ∧ e a < e c ∧ e c < e d ∨ e d < e b ∧ e b < e a ∧ e d < e c ∧ e c < e a ∨ e b < e a ∧ e a < e c ∧ e b < e d ∧ e d < e c ∨ e c < e a ∧ e a < e b ∧ e c < e d ∧ e d < e b ∨ e a < e b ∧ e a < e c ∧ e d < e b ∧ e d < e c ∨ e b < e a ∧ e c < e a ∧ e b < e d ∧ e c < e d instance {n} : DecidablePred (IsBeautiful (n := n)) := by unfold IsBeautiful; infer_instance def M (n : β„•) : β„• := #{e : Perm (Fin (n + 1)) | IsBeautiful e} / (n + 1) def N (n : β„•) : β„• := #{xy ∈ .Icc 1 n Γ—Λ’ .Icc 1 n | xy.1 + xy.2 ≀ n ∧ xy.1.gcd xy.2 = 1} theorem imo_2013_p6 (n : β„•) (hn : n β‰₯ 3) : M n = N n + 1 := by sorry
imo_2014_p2
Let $n\ge2$ be an integer. Consider an $n\times n$ chessboard consisting of $n^2$ unit squares. A configuration of $n$ rooks on this board is $\textit{peaceful}$ if every row and every column contains exactly one rook. Find the greatest positive integer $k$ such that, for each peaceful configuration of $n$ rooks, there is a $k\times k$ square which does not contain a rook on any of its $k^2$ squares.
[ "fun n => ⌈√nβŒ‰β‚Š - 1" ]
null
imo
import Mathlib structure peaceful_rooks (n : β„•) : Type where carrier : Matrix (Fin n) (Fin n) Bool is_peaceful_row : βˆ€ i, List.count true (List.ofFn (fun j => carrier i j)) = 1 is_peaceful_col : βˆ€ j, List.count true (List.ofFn (fun i => carrier i j)) = 1 deriving Fintype noncomputable abbrev imo_2014_p2_solution : β„• β†’ β„• := sorry theorem imo_2014_p2 (n : β„•) (hn : n β‰₯ 2) : IsGreatest {(k : β„•) | (k > 0) ∧ βˆ€ r : peaceful_rooks n, βˆƒ i j : Fin n, i.val + k - 1 < n ∧ i.val + k - 1 < n ∧ βˆ€ m n, m.val < k ∧ n.val < k ∧ r.carrier (i + m) (j + n) = false} (imo_2014_p2_solution n) := by sorry
imo_2014_p6
A set of lines in the plane is in $\textit{general position}$ if no two are parallel and no three pass through the same point. A set of lines in general position cuts the plane into regions, some of which have finite area; we call these its $\textit{finite regions}$. Prove that for all sufficiently large $n$, in any set of $n$ lines in general position it is possible to colour at least $\sqrt{n}$ of the lines blue in such a way that none of its finite regions has a completely blue boundary.
null
null
imo
import Mathlib def General_position (L : Finset (ℝ Γ— ℝ Γ— ℝ)) : Prop := (βˆ€ l ∈ L, l.1 β‰  0 ∨ l.2.1 β‰  0) ∧ (βˆ€ l1 ∈ L, βˆ€ l2 ∈ L, l1 β‰  l2 β†’ l1.1 * l2.2.1 β‰  l1.2.1 * l2.1) ∧ (βˆ€ l1 ∈ L, βˆ€ l2 ∈ L, βˆ€ l3 ∈ L, l1 β‰  l2 β†’ l1 β‰  l3 β†’ l2 β‰  l3 β†’ (Β¬ βˆƒ (p : ℝ Γ— ℝ), l1.1 * p.1 + l1.2.1 * p.2 + l1.2.2 = 0 ∧ l2.1 * p.1 + l2.2.1 * p.2 + l2.2.2 = 0 ∧ l3.1 * p.1 + l3.2.1 * p.2 + l3.2.2 = 0)) def finite_regions (S : Set (ℝ Γ— ℝ)) (L : Finset (ℝ Γ— ℝ Γ— ℝ)) : Prop := S β‰  βˆ… ∧ (βˆƒ a b : ℝ, βˆ€ p ∈ S, |p.1| ≀ a ∧ |p.2| ≀ b) ∧ (βˆ€ p ∈ S, βˆ€ q ∈ S, p β‰  q β†’ βˆ€ l ∈ L, Real.sign (l.1 * p.1 + l.2.1 * p.2 + l.2.2) = Real.sign (l.1 * q.1 + l.2.1 * q.2 + l.2.2)) theorem imo_2014_p6 : βˆ€αΆ  n in Filter.atTop, βˆ€ (L : Finset (ℝ Γ— ℝ Γ— ℝ)), General_position L ∧ L.card = n β†’ βˆƒ B ≀ L, B.card β‰₯ Nat.sqrt n ∧ βˆ€ S ≀ B, βˆ€ (R : Set (ℝ Γ— ℝ)), Β¬finite_regions R S := by sorry
imo_2015_p1
We say that a finite set $\mathcal{S}$ in the plane is balanced if, for any two different points $A$, $B$ in $\mathcal{S}$, there is a point $C$ in $\mathcal{S}$ such that $AC=BC$. We say that $\mathcal{S}$ is centre-free if for any three points $A$, $B$, $C$ in $\mathcal{S}$, there is no point $P$ in $\mathcal{S}$ such that $PA=PB=PC$. (1) Show that for all integers $n\geq 3$, there exists a balanced set consisting of $n$ points. (1) Determine all integers $n\geq 3$ for which there exists a balanced centre-free set consisting of $n$ points.
[ "{n | n β‰₯ 3 ∧ Odd n}" ]
null
imo
import Mathlib def balanced (S : Set (ℝ Γ— ℝ)) : Prop := βˆ€ A ∈ S, βˆ€ B ∈ S, A β‰  B β†’ (βˆƒ C ∈ S, dist A C = dist B C) def centre_free (S : Set (ℝ Γ— ℝ)) : Prop := βˆ€ A ∈ S, βˆ€ B ∈ S, βˆ€ C ∈ S, A β‰  B β†’ B β‰  C β†’ A β‰  C β†’ Β¬ (βˆƒ P ∈ S, dist A P = dist B P ∧ dist B P = dist C P) abbrev imo_2015_p1_solution : Set β„• := sorry theorem imo_2015_p1 : (βˆ€ n β‰₯ 3, βˆƒ (S : Finset (ℝ Γ— ℝ)), balanced S ∧ S.card = n) ∧ {n | n β‰₯ 3 ∧ (βˆƒ (S : Finset (ℝ Γ— ℝ)), balanced S ∧ centre_free S ∧ S.card = n)} = imo_2015_p1_solution := by sorry
imo_2015_p6
The sequence $a_1,a_2,\dots$ of integers satisfies the conditions: (i) $1\le a_j\le2015$ for all $j\ge1$, (ii) $k+a_k\neq \ell+a_\ell$ for all $1\le k<\ell$. Prove that there exist two positive integers $b$ and $N$ for which\[\left\vert\sum_{j=m+1}^n(a_j-b)\right\vert\le1007^2\]for all integers $m$ and $n$ such that $n>m\ge N$.
null
null
imo
import Mathlib theorem imo_2015_p6 (a : β„•+ β†’ β„€) (ha1 : βˆ€ j : β„•+, 1 ≀ a j ∧ a j ≀ 2015) (ha2 : βˆ€ k l, k < l β†’ k + a k β‰  l + a l) : βˆƒ b N : β„•+, βˆ€ m n, n > m ∧ m β‰₯ N β†’ |(βˆ‘ j ∈ Finset.Icc (m + 1) n, (a j - b))| ≀ 1007^2 := by sorry
imo_2016_p2
Find all integers $n$ for which each cell of $n \times n$ table can be filled with one of the letters $I,M$ and $O$ in such a way that: in each row and each column, one third of the entries are $I$, one third are $M$ and one third are $O$; and in any diagonal, if the number of entries on the diagonal is a multiple of three, then one third of the entries are $I$, one third are $M$ and one third are $O$. Note. The rows and columns of an $n \times n$ table are each labelled $1$ to $n$ in a natural order. Thus each cell corresponds to a pair of positive integer $(i,j)$ with $1 \le i,j \le n$. For $n>1$, the table has $4n-2$ diagonals of two types. A diagonal of first type consists all cells $(i,j)$ for which $i+j$ is a constant, and the diagonal of this second type consists all cells $(i,j)$ for which $i-j$ is constant.
[ "{n | 9 ∣ n}" ]
null
imo
import Mathlib open Finset inductive Letters | I | M | O deriving BEq, DecidableEq def diagonal_I_set (n k : β„•) : Finset (Fin n Γ— Fin n) := (@Finset.univ (Fin n Γ— Fin n) _ |>.filter (fun (i, j) => i.1 + j.1 = k)) def diagonal_I (n k : β„•) (A : Matrix (Fin n) (Fin n) Letters) : Prop := 3 ∣ #(diagonal_I_set n k) β†’ #(diagonal_I_set n k) = 3 * #{x ∈ diagonal_I_set n k | A x.1 x.2 = Letters.I} ∧ #(diagonal_I_set n k) = 3 * #{x ∈ diagonal_I_set n k | A x.1 x.2 = Letters.M} ∧ #(diagonal_I_set n k) = 3 * #{x ∈ diagonal_I_set n k | A x.1 x.2 = Letters.O} def diagonal_II_set (n : β„•) (k : β„€) : Finset (Fin n Γ— Fin n) := (@Finset.univ (Fin n Γ— Fin n) _ |>.filter (fun (i, j) => (i.1 : β„€) - (j.1 : β„€) = k)) def diagonal_II (n : β„•) (k : β„€) (A : Matrix (Fin n) (Fin n) Letters) : Prop := 3 ∣ #(diagonal_II_set n k) β†’ #(diagonal_II_set n k) = 3 * #{x ∈ diagonal_II_set n k | A x.1 x.2 = Letters.I} ∧ #(diagonal_II_set n k) = 3 * #{x ∈ diagonal_II_set n k | A x.1 x.2 = Letters.M} ∧ #(diagonal_II_set n k) = 3 * #{x ∈ diagonal_II_set n k | A x.1 x.2 = Letters.O} def exists_valid_table (n : β„•) : Prop := βˆƒ (A : Matrix (Fin n) (Fin n) Letters), (βˆ€ i : Fin n, n = 3 * #{j | A i j = Letters.I} ∧ n = 3 * #{j | A i j = Letters.M} ∧ n = 3 * #{j | A i j = Letters.O}) ∧ (βˆ€ j : Fin n, n = 3 * #{i | A i j = Letters.I} ∧ n = 3 * #{i | A i j = Letters.M} ∧ n = 3 * #{i | A i j = Letters.O}) ∧ (βˆ€ k ∈ Finset.range (2 * n - 1), diagonal_I n k A) ∧ βˆ€ k ∈ Finset.Icc (-(n : β„€) + 1) (n - 1), diagonal_II n k A abbrev imo_2016_p2_solution : Set β„• := sorry theorem imo_2016_p2 : {n | exists_valid_table n} = imo_2016_p2_solution := by sorry
imo_2016_p6
There are $n\ge 2$ line segments in the plane such that every two segments cross and no three segments meet at a point. Geoff has to choose an endpoint of each segment and place a frog on it facing the other endpoint. Then he will clap his hands $n-1$ times. Every time he claps, each frog will immediately jump forward to the next intersection point on its segment. Frogs never change the direction of their jumps. Geoff wishes to place the frogs in such a way that no two of them will ever occupy the same intersection point at the same time. (a) Prove that Geoff can always fulfill his wish if $n$ is odd. (b) Prove that Geoff can never fulfill his wish if $n$ is even.
null
null
imo
import Mathlib open Function structure FrogSystem (N : β„•) where otherSegment (s : Fin N) : Fin (N - 1) ≃ {s' : Fin N // s β‰  s'} point : {p : Sym2 (Fin N) // Β¬ p.IsDiag} β†’ EuclideanSpace ℝ (Fin 2) mem_collinear {s tβ‚€ t₁ tβ‚‚} : tβ‚€ < t₁ β†’ t₁ < tβ‚‚ β†’ Sbtw ℝ (point ⟨s(s, otherSegment s tβ‚€), by simpa using (otherSegment s tβ‚€).2⟩) (point ⟨s(s, otherSegment s t₁), by simpa using (otherSegment s t₁).2⟩) (point ⟨s(s, otherSegment s tβ‚‚), by simpa using (otherSegment s tβ‚‚).2⟩) def FrogSystem.GeoffsWish {N : β„•} (F : FrogSystem N) : Prop := βˆ€ t, Injective fun s ↦ s(s, F.otherSegment s t) theorem imo_2016_p6 : (βˆ€ n β‰₯ 2, Odd n β†’ βˆƒ F : FrogSystem n, F.GeoffsWish) ∧ βˆ€ n β‰₯ 2, Even n β†’ βˆ€ F : FrogSystem n, Β¬ F.GeoffsWish := by sorry
imo_2017_p3
A hunter and an invisible rabbit play a game in the Euclidean plane. The rabbit's starting point, $A_0$, and the hunter's starting point, $B_0$, are the same. After $n-1$ rounds of the game, the rabbit is at point $A_{n-1}$ and the hunter is at point $B_{n-1}$. In the nth round of the game, three things occur in order. (i) The rabbit moves invisibly to a point $A_n$ such that the distance between $A_{n-1}$ and $A_n$ is exactly 1. (ii) A tracking device reports a point $P_n$ to the hunter. The only guarantee provided by the tracking device is that the distance between $P_n$ and $A_n$ is at most 1. (iii) The hunter moves visibly to a point $B_n$ such that the distance between $B_{n-1}$ and $B_n$ is exactly 1. Is it always possible, no matter how the rabbit moves, and no matter what points are reported by the tracking device, for the hunter to choose her moves so that after $10^9$ rounds she can ensure that the distance between her and the rabbit is at most 100?
[ "false" ]
null
imo
import Mathlib abbrev imo_2017_p3_solution : Bool := sorry theorem imo_2017_p3 (start : ℝ Γ— ℝ) : imo_2017_p3_solution = βˆ€ (A : β„• β†’ (Fin 2 β†’ ℝ)), A 0 = ![start.1, start.2] β†’ βˆ€ n, dist (A n) (A (n + 1)) = 1 β†’ (βˆƒ (P : β„• β†’ (Fin 2 β†’ ℝ)), βˆ€ n > 0, dist (P n) (A n) ≀ 1) β†’ (βˆƒ (B : β„• β†’ (Fin 2 β†’ ℝ)), B 0 = ![start.1, start.2] ∧ βˆ€ n, dist (B n) (B (n + 1)) = 1 ∧ dist (A (10 ^ 9)) (B (10 ^9)) ≀ 100) := by sorry
imo_2017_p5
An integer $N \ge 2$ is given. A collection of $N(N + 1)$ soccer players, no two of whom are of the same height, stand in a row. Sir Alex wants to remove $N(N - 1)$ players from this row leaving a new row of $2N$ players in which the following $N$ conditions hold: ($1$) no one stands between the two tallest players, ($2$) no one stands between the third and fourth tallest players, $\cdots$ ($N$) no one stands between the two shortest players. Show that this is always possible.
null
null
imo
import Mathlib open Equiv Finset theorem imo_2017_p5 (N : β„•) (h_N : N β‰₯ 2) (height : Perm (Fin (N * (N + 1)))) : βˆƒ kept : Fin (2 * N) β†ͺo Fin (N * (N + 1)), βˆ€ i j, Even #{l | height (kept l) < height (kept i)} β†’ (βˆ€ k, height (kept i) < height (kept k) ↔ height (kept j) ≀ height (kept k)) β†’ (βˆ€ k, kept i < kept k ↔ kept j ≀ kept k) ∨ (βˆ€ k, kept j < kept k ↔ kept i ≀ kept k) := by sorry
imo_2018_p3
An anti-Pascal triangle is an equilateral triangular array of numbers such that, except for the numbers in the bottom row, each number is the absolute value of the difference of the two numbers immediately below it. For example, the following is an anti-Pascal triangle with four rows which contains every integer from $1$ to $10$ \[4\]\[2\quad 6\]\[5\quad 7 \quad 1\] \[8\quad 3 \quad 10 \quad 9\] Does there exist an anti-Pascal triangle with $2018$ rows which contains every integer from $1$ to $1 + 2 + 3 + \dots + 2018$?
[ "false" ]
null
imo
import Mathlib def IsAntiPascal (L : List (List β„•)) : Prop := L β‰  [] ∧ L[0]!.length = L.length ∧ (βˆ€ i, i < L.length - 1 β†’ (L[i]!.length = L[i+1]!.length + 1 ∧ βˆ€ j, j < (L[i+1]!).length β†’ ((L[i+1]!)[j]! = (((L[i]!)[j]! : β„€) - (L[i]!)[j+1]!).natAbs))) abbrev imo_2018_p3_solution : Bool := sorry theorem imo_2018_p3 : imo_2018_p3_solution = βˆƒ l, IsAntiPascal l ∧ List.range' 1 (βˆ‘ i ∈ Finset.Icc 1 2018, i) = List.insertionSort (Β· ≀ Β·) (List.flatten l) := by sorry
imo_2018_p4
A site is any point $(x, y)$ in the plane such that $x$ and $y$ are both positive integers less than or equal to 20. Initially, each of the 400 sites is unoccupied. Amy and Ben take turns placing stones with Amy going first. On her turn, Amy places a new red stone on an unoccupied site such that the distance between any two sites occupied by red stones is not equal to $\sqrt{5}$. On his turn, Ben places a new blue stone on any unoccupied site. (A site occupied by a blue stone is allowed to be at any distance from any other occupied site.) They stop as soon as a player cannot place a stone. Find the greatest $K$ such that Amy can ensure that she places at least $K$ red stones, no matter how Ben places his blue stones.
[ "100" ]
null
imo
import Mathlib abbrev Site := Fin 20 Γ— Fin 20 def Site.asPoint (s : Site) : ℝ Γ— ℝ := (s.1.1 + 1, s.2.1 + 1) inductive State | red | blue | unoccupied abbrev Game := Site β†’ State def initialGame : Game := fun _ => State.unoccupied def valid_Amy_move (x : Site) (g : Game) : Prop := g x = State.unoccupied ∧ βˆ€ y, g y = State.red β†’ dist x.asPoint y.asPoint β‰  √5 def valid_Ben_move (x : Site) (g : Game) : Prop := g x = State.unoccupied def AmyStrategy := Ξ  (g : Game), Option ((x : Site) Γ—' valid_Amy_move x g) def Game.updateAccordingToAmyStrategy (g : Game) (s : AmyStrategy) : Option Game := (s g) >>= fun p => .some <| Function.update g p.1 .red def BenStrategy := Ξ  (g : Game), Option ((x : Site) Γ—' valid_Ben_move x g) def Game.updateAccordingToBenStrategy (g : Game) (s : BenStrategy) : Option Game := (s g) >>= fun p => .some <| Function.update g p.1 .blue def updateOneTurn (a : AmyStrategy) (b : BenStrategy) (g : Game) : Option Game := g.updateAccordingToAmyStrategy a >>= fun g' => g'.updateAccordingToBenStrategy b def updateGame (a : AmyStrategy) (b : BenStrategy) (g : Game) : β„• β†’ Option Game | 0 => .some g | (n + 1) => updateOneTurn a b g >>= (updateGame a b Β· n) def CanPlaceKRedStones (a : AmyStrategy) (b : BenStrategy) : β„• β†’ Prop | 0 => True | n+1 => βˆƒ (h : updateGame a b initialGame n |>.isSome), a ((updateGame a b initialGame n).get h) |>.isSome abbrev imo_2018_p4_solution : β„• := sorry theorem imo_2018_p4 : (βˆƒ a : AmyStrategy, βˆ€ b : BenStrategy, CanPlaceKRedStones a b imo_2018_p4_solution) ∧ (βˆ€ a : AmyStrategy, βˆƒ b : BenStrategy, Β¬ CanPlaceKRedStones a b (imo_2018_p4_solution + 1)) := by sorry
imo_2019_p3
A social network has $2019$ users, some pairs of whom are friends. Whenever user $A$ is friends with user $B$, user $B$ is also friends with user $A$. Events of the following kind may happen repeatedly, one at a time: Three users $A$, $B$, and $C$ such that $A$ is friends with both $B$ and $C$, but $B$ and $C$ are not friends, change their friendship statuses such that $B$ and $C$ are now friends, but $A$ is no longer friends with $B$, and no longer friends with $C$. All other friendship statuses are unchanged. Initially, $1010$ users have $1009$ friends each, and $1009$ users have $1010$ friends each. Prove that there exists a sequence of such events after which each user is friends with at most one other user.
null
null
imo
import Mathlib noncomputable instance (users : SimpleGraph (Fin 2019)) (a : Fin 2019) : Fintype (users.neighborSet a) := Fintype.ofFinite ↑(users.neighborSet a) def IsTriple (l : List (Fin 2019)) (G : SimpleGraph (Fin 2019)) : Prop := l.length = 3 ∧ G.Adj l[0]! l[1]! ∧ G.Adj l[0]! l[2]! ∧ Β¬ G.Adj l[1]! l[2]! ∧ l[1]! β‰  l[2]! @[simp] lemma triple.hab' (l : List (Fin 2019)) (users : SimpleGraph (Fin 2019)) (h : IsTriple l users) : l[1]! = l[2]! ↔ False := by constructor Β· exact (h.2.2.2.2 Β·) Β· tauto attribute [local aesop safe] SimpleGraph.Adj.symm IsTriple def update (l : List (Fin 2019)) (users : SimpleGraph (Fin 2019)) (h : IsTriple l users) : SimpleGraph (Fin 2019) where Adj x y := if x = l[0]! then if y = l[1]! then False else if y = l[2]! then False else users.Adj l[0]! y else if x = l[1]! then if y = l[0]! then False else if y = l[2]! then True else users.Adj l[1]! y else if x = l[2]! then if y = l[0]! then False else if y = l[1]! then True else users.Adj l[2]! y else users.Adj x y symm := by simp only [if_false_left, if_true_left] intro x y simp only split_ifs <;> aesop loopless := by intro x simp only [if_false_left, if_true_left, SimpleGraph.irrefl, if_false_right] split_ifs with h1 h2 Β· aesop Β· subst h2 simp_all only [not_false_eq_true, SimpleGraph.irrefl, imp_false, Decidable.not_not, true_and] apply Aesop.BuiltinRules.not_intro intro a_1 apply h.2.2.2.2; simp [a_1] Β· aesop structure ExpectSeq where l : List (SimpleGraph (Fin 2019) Γ— List (Fin 2019)) h_length : l.length > 0 h_card : βˆ€ li ∈ l, li.2.length = 3 h_triple : βˆ€ li ∈ l, IsTriple li.2 li.1 h_update : βˆ€ i : Fin l.length, (finRotate _ i).1 β‰  0 β†’ update l[i].2 l[i].1 (h_triple l[i] (by simp)) = l[finRotate _ i].1 def final_state (seq : ExpectSeq) : SimpleGraph (Fin 2019) := update seq.l[((finRotate seq.l.length).symm ⟨0, by simp [seq.h_length]⟩ )]!.2 seq.l[((finRotate seq.l.length).symm ⟨0, by simp [seq.h_length]⟩)]!.1 (seq.h_triple seq.l[((finRotate seq.l.length).symm ⟨0, by simp [seq.h_length]⟩)]! (by simp)) theorem imo_2019_p3 (users : SimpleGraph (Fin 2019)) (cond : βˆƒ (A B : Finset (Fin 2019)), A.card = 1010 ∧ B.card = 1009 ∧ (βˆ€ a ∈ A, (users.neighborFinset a).card = 1009) ∧ (βˆ€ b ∈ B, (users.neighborFinset b).card = 1010)) : βˆƒ seq : ExpectSeq, βˆ€ i, ((final_state seq).neighborFinset i).card ≀ 1 := by sorry
imo_2019_p5
The Bank of Bath issues coins with an $H$ on one side and a $T$ on the other. Harry has $n$ of these coins arranged in a line from left to right. He repeatedly performs the following operation: If there are exactly $k > 0$ coins showing $H$, then he turns over the $k^{th}$ coin from the left; otherwise, all coins show $T$ and he stops. For example, if $n = 3$ the process starting with the configuration $THT$ would be $THT \rightarrow HHT \rightarrow HTT \rightarrow TTT$, which stops after three operations. (a) Show that, for each initial configuration, Harry stops after a finite number of operations. (b) For each initial configuration $C$, let $L(C)$ be the number of operations before Harry stops. For example, $L(THT) = 3$ and $L(TTT) = 0$. Determine the average value of $L(C)$ over all $2^n$ possible initial configurations $C$.
[ "fun n => n * (n + 1) / 4" ]
null
imo
import Mathlib abbrev Coin := Fin 2 abbrev Coin.H : Coin := 0 abbrev Coin.T : Coin := 1 abbrev CoinConfig (n : β„•) := Fin n β†’ Coin def CoinConfig.countH {n : β„•} (c : CoinConfig n) : β„• := (List.ofFn c).count .H def CoinConfig.flip {n : β„•} (c : CoinConfig n) (k : β„•) : CoinConfig n := fun i => if i.val + 1 = k then match c i with | .H => .T | .T => .H else c i def CoinConfig.update {n : β„•} (c : CoinConfig n) : Option (CoinConfig n) := if c.countH = 0 then none else .some <| c.flip c.countH def CoinConfig.updateMultipleTimes {n : β„•} (c : CoinConfig n) : β„• β†’ Option (CoinConfig n) | 0 => if c.countH = 0 then none else .some c | k+1 => c.updateMultipleTimes k >>= update abbrev imo_2019_p5_2_solution : β„• β†’ β„š := sorry theorem imo_2019_p5_1 {n : β„•} (hn : n > 0) : βˆ€ (c : CoinConfig n), βˆƒ N : β„•, c.updateMultipleTimes N = .none := by sorry theorem imo_2019_p5_2 {n : β„•} (hn : n > 0) : imo_2019_p5_2_solution n = βˆ‘ c : CoinConfig n, (Nat.find (imo_2019_p5_1 hn c) : β„š) / (Fintype.card (CoinConfig n)) := by sorry
imo_2020_p4
There is an integer $n > 1$. There are $n^2$ stations on a slope of a mountain, all at different altitudes. Each of two cable car companies, $A$ and $B$, operates $k$ cable cars; each cable car provides a transfer from one of the stations to a higher one (with no intermediate stops). The $k$ cable cars of $A$ have $k$ different starting points and $k$ different finishing points, and a cable car that starts higher also finishes higher. The same conditions hold for $B$. We say that two stations are linked by a company if one can start from the lower station and reach the higher one by using one or more cars of that company (no other movements between stations are allowed). Determine the smallest positive integer k for which one can guarantee that there are two stations that are linked by both companies.
[ "fun n => n ^ 2 - n + 1" ]
null
imo
import Mathlib def Iscompanies (n k : β„•) (car_set : Finset (Fin n Γ— Fin n)) : Prop := car_set.card = k ∧ (βˆ€ (a b : Fin n), (a, b) ∈ car_set β†’ a < b)∧ (βˆ€ a ∈ car_set, βˆ€ b ∈ car_set, a β‰  b β†’ a.1 β‰  b.1 ∧ a.2 β‰  b.2) def Islinked {n : β„•} (a b : Fin n) (car_set : Finset (Fin n Γ— Fin n)) : Prop := βˆƒ s : List (Fin n Γ— Fin n), s.Nodup ∧ (βˆ€ i ∈ s, (i ∈ car_set ∧ (List.foldl (fun x y => if x.2 = y.1 then (x.1, y.2) else x) (a, a) s = (a, b)))) def Condition (n k : β„•) : Prop := βˆƒ (companyA companyB : Finset (Fin n Γ— Fin n)), Iscompanies n k companyA ∧ Iscompanies n k companyB ∧ (βˆƒ (a b : Fin n), a β‰  b ∧ Islinked a b companyA ∧ Islinked a b companyB) abbrev imo_2020_p4_solution : β„• β†’ β„• := sorry theorem imo_2020_p4 (n : β„•) (hn : n > 1) : IsLeast {k | Condition n k} (imo_2020_p4_solution n) := by sorry
imo_2021_p5
Two squirrels, Bushy and Jumpy, have collected 2021 walnuts for the winter. Jumpy numbers the walnuts from 1 through 2021, and digs 2021 little holes in a circular pattern in the ground around their favourite tree. The next morning Jumpy notices that Bushy had placed one walnut into each hole, but had paid no attention to the numbering. Unhappy, Jumpy decides to reorder the walnuts by performing a sequence of 2021 moves. In the $k$-th move, Jumpy swaps the positions of the two walnuts adjacent to walnut $k$. Prove that there exists a value of $k$ such that, on the $k$-th move, Jumpy swaps some walnuts $a$ and $b$ such that $a < k < b$.
null
null
imo
import Mathlib def move (k : Fin 2021) (order : Fin 2021 ≃ Fin 2021) : Fin 2021 ≃ Fin 2021 := order.trans (Equiv.swap (order (finRotate _ (order.symm k))) (order ((finRotate _).symm (order.symm k)))) def performMoves (originalOrder : Fin 2021 ≃ Fin 2021) : (Fin 2021) β†’ (Fin 2021 ≃ Fin 2021) | 0 => originalOrder | ⟨n + 1, lt⟩ => move n (performMoves originalOrder ⟨n, lt_trans (by omega) lt⟩) theorem imo_2021_p5 (originalOrder : Fin 2021 ≃ Fin 2021) : βˆƒ k, min (finRotate _ ((performMoves originalOrder k).symm k) : β„•) ((finRotate _).symm ((performMoves originalOrder k).symm k) : β„•) < (k : β„•) ∧ (k : β„•) < max (finRotate _ ((performMoves originalOrder k).symm k) : β„•) ((finRotate _).symm ((performMoves originalOrder k).symm k) : β„•) := by sorry
imo_2022_p1
The Bank of Oslo issues two types of coin: aluminium (denoted A) and bronze (denoted B). Marianne has $n$ aluminium coins and $n$ bronze coins, arranged in a row in some arbitrary initial order. A chain is any subsequence of consecutive coins of the same type. Given a fixed positive integer $k\le 2n$, Marianne repeatedly performs the following operation: she identifies the longest chain containing the $k^{th}$ coin from the left, and moves all coins in that chain to the left end of the row. For example, if $n = 4$ and $k = 4$, the process starting from the ordering AABBBABA would be $AABBBABA \rightarrow BBBAAABA \rightarrow AAABBBBA \rightarrow BBBBAAAA \rightarrow BBBBAAAA \rightarrow \ldots$. Find all pairs $(n, k)$ with $1 \le k \le 2n$ such that for every initial ordering, at some moment during the process, the leftmost $n$ coins will all be of the same type.
[ "fun n => {p | p.1 = n ∧ n ≀ p.2 ∧ p.2 ≀ ⌈(3 * n : ℝ) / 2βŒ‰β‚Š}" ]
null
imo
import Mathlib abbrev sortedList (n : β„•) := (List.range (2 * n))|>.map (fun i ↦ if i < n then 0 else 1) def checkList (k : β„•) : List β„• β†’ β„• Γ— β„• := fun L ↦ Id.run do let mut i0 := k - 1 let mut i1 := k - 1 for i in [k : L.length] do if L[i]! = L[k-1]! then i1 := i1 + 1 else break for j in [1 : k] do if L[k-1-j]! = L[k-1]! then i0 := i0 - 1 else break return (i0, i1) abbrev action (k : β„•) : List β„• β†’ List β„• := fun L ↦ (List.range ((checkList k L).2 - (checkList k L).1 + 1)).map (fun _ ↦ L[k-1]!) ++ (List.range (checkList k L).1).map (fun i ↦ L[i]!) ++ (List.range (L.length - (checkList k L).2 - 1)).map (fun i ↦ L[i + (checkList k L).2 + 1]!) abbrev pown (k m : β„•) : List β„• β†’ List β„• := fun L ↦ Id.run do let mut L' := L for _ in [0 : m] do L' := action k L' return L' abbrev checkLeft (n : β„•) : List β„• β†’ Bool := fun L ↦ Id.run do for i in [0 : n] do if L[i]! β‰  L[0]! then return false else continue return true def initial (n : β„•) : Finset (List β„•) := (List.replicate n 0 ++ List.replicate n 1).permutations.toFinset abbrev imo_2022_p1_solution : β„• β†’ Set (β„• Γ— β„•) := sorry theorem imo_2022_p1 (n : β„•) (hn : n > 0) : {(n', k) | n = n' ∧ k β‰₯ 1 ∧ k ≀ 2 * n ∧ (βˆ€ I ∈ initial n, βˆƒ m : β„•, checkLeft n' (pown k m I))} = imo_2022_p1_solution n := by sorry
imo_2023_p5
Let $n$ be a positive integer. A Japanese triangle consists of $1 + 2 + \dots + n$ circles arranged in an equilateral triangular shape such that for each $i = 1$, $2$, $\dots$, $n$, the $i^{th}$ row contains exactly $i$ circles, exactly one of which is coloured red. A ninja path in a Japanese triangle is a sequence of $n$ circles obtained by starting in the top row, then repeatedly going from a circle to one of the two circles immediately below it and finishing in the bottom row. In terms of $n$, find the greatest $k$ such that in each Japanese triangle there is a ninja path containing at least $k$ red circles.
[ "fun n => ⌊Real.log nβŒ‹β‚Š + 1" ]
null
imo
import Mathlib structure Index (n : β„•+) where row : β„• col : β„• le_row : 1 ≀ row row_le : row ≀ n le_col : 1 ≀ col col_le : col ≀ row def Index.atBottomLeft {n : β„•+} (p q : Index n) : Prop := q.row + 1 = p.row ∧ q.col = p.col def Index.atBottomRight {n : β„•+} (p q : Index n) : Prop := q.row + 1 = p.row ∧ q.col + 1 = p.col @[simps] def triangleGraph (n : β„•+) : Digraph (Index n) where Adj p q := p.atBottomLeft q ∨ p.atBottomRight q ∨ q.atBottomLeft p ∨ q.atBottomRight p abbrev JapaneseTriangle (n : β„•+) := βˆ€ (i : Fin n), Fin (i + 1) structure NinjaPath {n : β„•+} (jt : JapaneseTriangle n) where path : RelSeries (triangleGraph n |>.Adj) length : path.length = n.natPred @[simp] lemma NinjaPath.path_length_succ {n : β„•+} {jt : JapaneseTriangle n} (p : NinjaPath jt) : p.path.length + 1 = n := by simp [p.length] def NinjaPath.countRed {n : β„•+} {jt : JapaneseTriangle n} (p : NinjaPath jt) : β„• := βˆ‘ (i : Fin (p.path.length + 1)), if (jt (Fin.cast (by simp) i) : β„•) = (p.path i).col then 1 else 0 noncomputable abbrev imo_2023_p5_solution : β„•+ β†’ β„• := sorry theorem imo_2023_p5 (n : β„•+) : IsGreatest {k | βˆ€ (jt : JapaneseTriangle n), βˆƒ (p : NinjaPath jt), k ≀ p.countRed} (imo_2023_p5_solution n) := by sorry
imo_2024_p5
Turbo the snail plays a game on a board with 2024 rows and 2023 columns. There are hidden monsters in 2022 of the cells. Initially, Turbo does not know where any of the monsters are, but he knows that there is exactly one monster in each row except the first row and the last row, and that each column contains at most one monster. Turbo makes a series of attempts to go from the first row to the last row. On each attempt, he chooses to start on any cell in the first row, then repeatedly moves to an adjacent cell sharing a common side. (He is allowed to return to a previously visited cell.) If he reaches a cell with a monster, his attempt ends and he is transported back to the first row to start a new attempt. The monsters do not move, and Turbo remembers whether or not each cell he has visited contains a monster. If he reaches any cell in the last row, his attempt ends and the game is over. Determine the minimum value of $n$ for which Turbo has a strategy that guarantees reaching the last row on the $n^{th}$ attempt or earlier, regardless of the locations of the monsters.
[ "3" ]
null
imo
import Mathlib namespace Imo_2024_p5 abbrev Cell (N : β„•) : Type := Fin (N + 2) Γ— Fin (N + 1) abbrev InteriorRow (N : β„•) : Type := (Set.Icc 1 ⟨N, by omega⟩ : Set (Fin (N + 2))) abbrev MonsterData (N : β„•) : Type := InteriorRow N β†ͺ Fin (N + 1) def MonsterData.monsterCells {N} (m : MonsterData N) : Set (Cell N) := Set.range (fun x : InteriorRow N ↦ ((x : Fin (N + 2)), m x)) def Adjacent {N} (x y : Cell N) : Prop := Nat.dist x.1 y.1 + Nat.dist x.2 y.2 = 1 structure Path (N : β„•) where cells : List (Cell N) nonempty : cells β‰  [] head_first_row : (cells.head nonempty).1 = 0 last_last_row : (cells.getLast nonempty).1 = N + 1 valid_move_seq : cells.Chain' Adjacent noncomputable def Path.firstMonster {N} (p : Path N) (m : MonsterData N) : Option (Cell N) := letI := Classical.propDecidable p.cells.find? (fun x ↦ (x ∈ m.monsterCells : Bool)) abbrev Strategy (N : β„•) : Type := ⦃k : ℕ⦄ β†’ (Fin k β†’ Option (Cell N)) β†’ Path N noncomputable def Strategy.play {N} (s : Strategy N) (m : MonsterData N) : (k : β„•) β†’ Fin k β†’ Option (Cell N) | 0 => Fin.elim0 | k + 1 => Fin.snoc (s.play m k) ((s (s.play m k)).firstMonster m) def Strategy.WinsIn {N} (s : Strategy N) (m : MonsterData N) (k : β„•) : Prop := none ∈ Set.range (s.play m k) def Strategy.ForcesWinIn {N} (s : Strategy N) (k : β„•) : Prop := βˆ€ m, s.WinsIn m k abbrev imo_2024_p5_solution : β„• := sorry theorem imo_2024_p5 : IsLeast {k | βˆƒ s : Strategy 2022, s.ForcesWinIn k} imo_2024_p5_solution := by sorry

CombiBench

CombiBench is the first benchmark focused on combinatorial problems, based on the formal language LEAN4. CombiBench is a manually produced benchmark, including 100 combinatorial mathematics problems of varying difficulty and knowledge levels. It aims to provide a benchmark for evaluating the combinatorial mathematics capabilities of automated theorem proving systems to advance the field. For problems that require providing a solution first and then proving its correctness, we have referred to the style of PutnamBench.

We are hosting a leaderboard and will readily receive evaluation results which are accompanied by a preprint or publication. Please reach out privately at [email protected] with any requests for additions to the leaderboard.

Statistics

We collected all combinatorics problems from the official IMO problems since 2000, except for one problem that relies on a figure. And We selected problems through random sampling from 14 chapters in the book, choosing 3 problems from each chapter, ensuring that the 42 problems are evenly distributed across all 14 chapters. We randomly selected 10 simple combinatorics problems at the middle school level from a mathematics problem collection website hackmath. Then, we randomly collected 12 problems from other mathematics competitions.

Source Count
Easy 10
Brualdi's book 42
IMO 36
APMO 2
Balticway 1
EGMO 1
IMO-Shortlist 4
IZHO 2
BXMO 1
USAMO 1

Note : The complete proofs of Problem 3 and Problem 5 from 2024 have already been formalized in mathlib4/Archive. Therefore, we directly refer to the statements of these problems, along with the necessary definitions used in the statements. We are very grateful to Joseph Myers, the author of these two problems. We also appreciate his suggestions on the formalization of our problems.

Evaluation

Our evaluation code is released at https://github.com/MoonshotAI/CombiBench

πŸ™Œ Contributing

Contributions are welcome! If anyone notices any mistakes, please raise an issue on the repository and we will address it.

πŸ“ License

This project is licensed under the MIT License. See the LICENSE file for full details.

Downloads last month
6

Collection including AI-MO/CombiBench