Let $p_n$ denote the probability that $c + d$ will be a perfect square if $c$ and $d$ are selected independently and uniformly at random from $\{1, 2, 3, \dots, n\}$. Express $\lim_{n \rightarrow \infty} p_n \sqrt{n}$ in the form $r(\sqrt{s} - t)$ for integers $s$ and $t$ and rational $r$.

The limit equals $\frac{4}{3}(\sqrt{2} - 1)$.

@Eq Real answer
  (@HMul.hMul Real Real Real (@instHMul Real Real.instMul)
    (@HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid))
      (@OfNat.ofNat Real (nat_lit 4)
        (@instOfNatAtLeastTwo Real (nat_lit 4) Real.instNatCast
          (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))))
      (@OfNat.ofNat Real (nat_lit 3)
        (@instOfNatAtLeastTwo Real (nat_lit 3) Real.instNatCast
          (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))))))
    (@HSub.hSub Real Real Real (@instHSub Real Real.instSub)
      (Real.sqrt
        (@OfNat.ofNat Real (nat_lit 2)
          (@instOfNatAtLeastTwo Real (nat_lit 2) Real.instNatCast
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))))))
      (@OfNat.ofNat Real (nat_lit 1) (@One.toOfNat1 Real Real.instOne))))

hp

p = fun n : ℕ => ({c : Finset.Icc 1 n × Finset.Icc 1 n | ∃ m : ℕ, m^2 = c.1 + c.2}.ncard : ℝ) / n^2

Tendsto (fun n : ℕ => p n * Real.sqrt n) atTop (𝓝 answer)


Let $n_1, n_2, \dots, n_s$ be distinct integers such that, for every integer $k$, $n_1n_2\cdots n_s$ divides $(n_1 + k)(n_2 + k) \cdots (n_s + k)$. Prove or provide a counterexample to the following claims:
\begin{enumerate}
\item
For some $i$, $|n_i| = 1$.
\item
If all $n_i$ are positive, then $\{n_1, n_2, \dots, n_s\} = \{1, 2, \dots, s\}$.
\end{enumerate}

open Set Function Filter Topology Polynomial Real

@Eq (Prod Prop Prop) answer (@Prod.mk Prop Prop True True)

∀ n, P n ↔ n.Nonempty ∧ ∀ k, ∏ i in n, i ∣ ∏ i in n, (i + k)

((∀ n, P n → 1 ∈ n ∨ -1 ∈ n) ↔ answer.1) ∧
    ((∀ n, P n → (∀ i ∈ n, 0 < i) → n = Finset.Icc (1 : ℤ) n.card) ↔ answer.2)


How many positive integers $n$ are there such that $n$ is an exact divisor of at least one of the numbers $10^{40},20^{30}$?

@Eq Nat answer (@OfNat.ofNat Nat (nat_lit 2301) (instOfNatNat (nat_lit 2301)))

{n : ℤ | n > 0 ∧ (n ∣ 10 ^ 40 ∨ n ∣ 20 ^ 30)}.encard = answer


Prove or disprove that there exists a positive real number $\alpha$ such that $[\alpha_n] - n$ is even for all integers $n > 0$. (Here $[x]$ denotes the greatest integer less than or equal to $x$.)

answer ↔ (∃ α : ℝ, α > 0 ∧ ∀ n : ℕ, n > 0 → Even (⌊α ^ n⌋ - n))


Let $T$ be the triangle with vertices $(0, 0)$, $(a, 0)$, and $(0, a)$. Find $\lim_{a \to \infty} a^4 \exp(-a^3) \int_T \exp(x^3+y^3) \, dx \, dy$.

Show that the integral evaluates to $\frac{2}{9}$.

@Eq Real answer
  (@HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid))
    (@OfNat.ofNat Real (nat_lit 2)
      (@instOfNatAtLeastTwo Real (nat_lit 2) Real.instNatCast
        (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0))))))
    (@OfNat.ofNat Real (nat_lit 9)
      (@instOfNatAtLeastTwo Real (nat_lit 9) Real.instNatCast
        (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 7) (instOfNatNat (nat_lit 7)))))))


Let $f(n)$ be the number of ways of representing $n$ as a sum of powers of $2$ with no power being used more than $3$ times. For example, $f(7) = 4$ (the representations are $4 + 2 + 1$, $4 + 1 + 1 + 1$, $2 + 2 + 2 + 1$, $2 + 2 + 1 + 1 + 1$). Can we find a real polynomial $p(x)$ such that $f(n) = [p(n)]$, where $[u]$ denotes the greatest integer less than or equal to $u$?

hf

f = fun (n : ℕ+) ↦
      Set.ncard {M : Multiset ℕ |
        (∀ m ∈ M, ∃ k : ℕ, m = (2 ^ k : ℤ)) ∧
        (∀ m ∈ M, M.count m ≤ 3) ∧
        (M.sum : ℤ) = n}

answer ↔ (∃ p : Polynomial ℝ, ∀ n : ℕ+, ⌊p.eval (n : ℝ)⌋ = f n)


Define $\left\lVert x \right\rVert$ as the distance from $x$ to the nearest integer. Find $\lim_{n \to \infty} \frac{1}{n} \int_{1}^{n} \left\lVert \frac{n}{x} \right\rVert \, dx$. You may assume that $\prod_{n=1}^{\infty} \frac{2n}{(2n-1)} \cdot \frac{2n}{(2n+1)} = \frac{\pi}{2}$.

Show that the limit equals $\ln \left( \frac{4}{\pi} \right)$.

@Eq Real answer
  (Real.log
    (@HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid))
      (@OfNat.ofNat Real (nat_lit 4)
        (@instOfNatAtLeastTwo Real (nat_lit 4) Real.instNatCast
          (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))))
      Real.pi))

dist_fun = fun (x : ℝ) ↦ min (x - ⌊x⌋) (⌈x⌉ - x)

fact

Tendsto (fun N ↦ ∏ n in Finset.Icc 1 N, (2 * n / (2 * n - 1)) * (2 * n / (2 * n + 1)) : ℕ → ℝ) atTop (𝓝 (Real.pi / 2))

Tendsto (fun n ↦ (1 / n) * ∫ x in (1)..n, dist_fun (n / x) : ℕ → ℝ) atTop (𝓝 answer)


Express $\sum_{k=1}^\infty (6^k/(3^{k+1}-2^{k+1})(3^k-2^k))$ as a rational number.

@Eq Rat answer (@OfNat.ofNat Rat (nat_lit 2) (@Rat.instOfNat (nat_lit 2)))


Let $n$ be a positive integer. Let $a,b,x$ be real numbers, with $a \neq b$, and let $M_n$ denote the $2n \times 2n$ matrix whose $(i,j)$ entry $m_{ij}$ is given by
\[
m_{ij}=\begin{cases}
x & \text{if }i=j, \\
a & \text{if }i \neq j\text{ and }i+j\text{ is even}, \\
b & \text{if }i \neq j\text{ and }i+j\text{ is odd}.
\end{cases}
\]
Thus, for example, $M_2=\begin{pmatrix} x & b & a & b \\ b & x & b & a \\ a & b & x & b \\ b & a & b & x \end{pmatrix}$. Express $\lim_{x \to a} \det M_n/(x-a)^{2n-2}$ as a polynomial in $a$, $b$, and $n$, where $\det M_n$ denotes the determinant of $M_n$.

@Eq (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring) answer
  (@HMul.hMul (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
    (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
    (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
    (@instHMul
      (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
      (@Distrib.toMul
        (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
        (@NonUnitalNonAssocSemiring.toDistrib
          (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
          (@NonUnitalNonAssocCommSemiring.toNonUnitalNonAssocSemiring
            (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
            (@NonUnitalNonAssocCommRing.toNonUnitalNonAssocCommSemiring
              (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
              (@NonUnitalCommRing.toNonUnitalNonAssocCommRing
                (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real
                  Real.instCommSemiring)
                (@CommRing.toNonUnitalCommRing
                  (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real
                    Real.instCommSemiring)
                  (@MvPolynomial.instCommRingMvPolynomial Real
                    (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real.commRing))))))))
    (@HPow.hPow
      (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring) Nat
      (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
      (@instHPow
        (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring) Nat
        (@Monoid.toNatPow
          (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
          (@MonoidWithZero.toMonoid
            (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
            (@Semiring.toMonoidWithZero
              (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
              (@CommSemiring.toSemiring
                (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real
                  Real.instCommSemiring)
                (@MvPolynomial.commSemiring Real (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3))))
                  Real.instCommSemiring))))))
      (@MvPolynomial.X Real (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real.instCommSemiring
        (@OfNat.ofNat (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) (nat_lit 2)
          (@Fin.instOfNat (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))
            (@Nat.instNeZeroSucc (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) (nat_lit 2))))
      (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
    (@HSub.hSub
      (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
      (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
      (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
      (@instHSub
        (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
        (@SubNegMonoid.toSub
          (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
          (@AddGroup.toSubNegMonoid
            (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
            (@AddGroupWithOne.toAddGroup
              (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
              (@Ring.toAddGroupWithOne
                (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real
                  Real.instCommSemiring)
                (@CommRing.toRing
                  (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real
                    Real.instCommSemiring)
                  (@MvPolynomial.instCommRingMvPolynomial Real
                    (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real.commRing)))))))
      (@HPow.hPow
        (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring) Nat
        (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
        (@instHPow
          (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring) Nat
          (@Monoid.toNatPow
            (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
            (@MonoidWithZero.toMonoid
              (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
              (@Semiring.toMonoidWithZero
                (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real
                  Real.instCommSemiring)
                (@CommSemiring.toSemiring
                  (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real
                    Real.instCommSemiring)
                  (@MvPolynomial.commSemiring Real (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3))))
                    Real.instCommSemiring))))))
        (@MvPolynomial.X Real (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real.instCommSemiring
          (@OfNat.ofNat (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) (nat_lit 0)
            (@Fin.instOfNat (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))
              (@Nat.instNeZeroSucc (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) (nat_lit 0))))
        (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
      (@HPow.hPow
        (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring) Nat
        (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
        (@instHPow
          (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring) Nat
          (@Monoid.toNatPow
            (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
            (@MonoidWithZero.toMonoid
              (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real Real.instCommSemiring)
              (@Semiring.toMonoidWithZero
                (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real
                  Real.instCommSemiring)
                (@CommSemiring.toSemiring
                  (@MvPolynomial (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real
                    Real.instCommSemiring)
                  (@MvPolynomial.commSemiring Real (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3))))
                    Real.instCommSemiring))))))
        (@MvPolynomial.X Real (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) Real.instCommSemiring
          (@OfNat.ofNat (Fin (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))) (nat_lit 1)
            (@Fin.instOfNat (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))
              (@Nat.instNeZeroSucc (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) (nat_lit 1))))
        (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))))

Mn

ℝ → Matrix (Fin (2 * n)) (Fin (2 * n)) ℝ

hMn

Mn = fun x : ℝ => fun i j : Fin (2 * n) => if i = j then x else if Even (i.1 + j.1) then a else b

hpolyabn

polyabn 0 = a ∧ polyabn 1 = b ∧ polyabn 2 = n

Tendsto (fun x : ℝ => (Mn x).det / (x - a) ^ (2 * n - 2)) (𝓝[≠] a) (𝓝 (MvPolynomial.eval polyabn answer))


Let $R$ be the region consisting of all triples $(x,y,z)$ of nonnegative real numbers satisfying $x+y+z \leq 1$. Let $w=1-x-y-z$. Express the value of the triple integral $\iiint_R x^1y^9z^8w^4\,dx\,dy\,dz$ in the form $a!b!c!d!/n!$, where $a$, $b$, $c$, $d$, and $n$ are positive integers.

Show that the integral we desire is $1!9!8!4!/25!$.

@Eq (Prod Nat (Prod Nat (Prod Nat (Prod Nat Nat)))) answer
  (@Prod.mk Nat (Prod Nat (Prod Nat (Prod Nat Nat))) (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))
    (@Prod.mk Nat (Prod Nat (Prod Nat Nat)) (@OfNat.ofNat Nat (nat_lit 9) (instOfNatNat (nat_lit 9)))
      (@Prod.mk Nat (Prod Nat Nat) (@OfNat.ofNat Nat (nat_lit 8) (instOfNatNat (nat_lit 8)))
        (@Prod.mk Nat Nat (@OfNat.ofNat Nat (nat_lit 4) (instOfNatNat (nat_lit 4)))
          (@OfNat.ofNat Nat (nat_lit 25) (instOfNatNat (nat_lit 25)))))))

ℕ × ℕ × ℕ × ℕ × ℕ


Let $n$ be a positive integer, and let $f(n)$ denote the last nonzero digit in the decimal expansion of $n!$. For instance, $f(5)=2$.
\begin{enumerate}
\item[(a)] Show that if $a_1,a_2,\dots,a_k$ are \emph{distinct} nonnegative integers, then $f(5^{a_1}+5^{a_2}+\dots+5^{a_k})$ depends only on the sum $a_1+a_2+\dots+a_k$.
\item[(b)] Assuming part (a), we can define $g(s)=f(5^{a_1}+5^{a_2}+\dots+5^{a_k})$, where $s=a_1+a_2+\dots+a_k$. Find the least positive integer $p$ for which $g(s)=g(s + p)$, for all $s \geq 1$, or else show that no such $p$ exists.
\end{enumerate}

@Eq Nat answer (@OfNat.ofNat Nat (nat_lit 4) (instOfNatNat (nat_lit 4)))

hf

∀ n, some (f n) = (Nat.digits 10 (n !)).find? (fun d ↦ d ≠ 0)

IsPeriodicFrom

ℕ → (ℕ → ℕ) → ℕ → Prop

∀ x f p, IsPeriodicFrom x f p ↔ Periodic (f ∘ (· + x)) p

P

ℕ → (ℕ → ℕ) → ℕ → Prop

∀ x g p, P x g p ↔ if p = 0 then (∀ q > 0, ¬ IsPeriodicFrom x g q) else
        IsLeast {q | 0 < q ∧ IsPeriodicFrom x g q} p

∃ g : ℕ → ℕ,
      (∀ᵉ (k > 0) (a : Fin k → ℕ) (ha : Injective a), f (∑ i, 5 ^ (a i)) = g (∑ i, a i)) ∧
      P 1 g answer


Let $n$ be a positive integer, and define $f(n)=1!+2!+\dots+n!$. Find polynomials $P(x)$ and $Q(x)$ such that $f(n+2)=P(n)f(n+1)+Q(n)f(n)$ for all $n \geq 1$.

Show that we can take $P(x)=x+3$ and $Q(x)=-x-2$.

@Eq (Prod (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring)) answer
  (@Prod.mk (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring)
    (@HAdd.hAdd (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring)
      (@instHAdd (@Polynomial Real Real.semiring) (@Polynomial.add' Real Real.semiring))
      (@Polynomial.X Real Real.semiring)
      (@OfNat.ofNat (@Polynomial Real Real.semiring) (nat_lit 3)
        (@instOfNatAtLeastTwo (@Polynomial Real Real.semiring) (nat_lit 3) (@Polynomial.instNatCast Real Real.semiring)
          (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))))))
    (@HSub.hSub (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring)
      (@instHSub (@Polynomial Real Real.semiring) (@Polynomial.sub Real Real.instRing))
      (@Neg.neg (@Polynomial Real Real.semiring) (@Polynomial.neg' Real Real.instRing)
        (@Polynomial.X Real Real.semiring))
      (@OfNat.ofNat (@Polynomial Real Real.semiring) (nat_lit 2)
        (@instOfNatAtLeastTwo (@Polynomial Real Real.semiring) (nat_lit 2) (@Polynomial.instNatCast Real Real.semiring)
          (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0))))))))

hf

∀ n > 0, f n = ∑ i : Set.Icc 1 n, ((i)! : ℤ)

∀ n ≥ 1, f (n + 2) = (answer.1).eval (n : ℝ) * f (n + 1) + (answer.2).eval (n : ℝ) * f n


Find the minimum value of $(u-v)^2+(\sqrt{2-u^2}-\frac{9}{v})^2$ for $0<u<\sqrt{2}$ and $v>0$.

@Eq Real answer
  (@OfNat.ofNat Real (nat_lit 8)
    (@instOfNatAtLeastTwo Real (nat_lit 8) Real.instNatCast
      (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 6) (instOfNatNat (nat_lit 6))))))

IsLeast {y | ∃ᵉ (u : Set.Ioo 0 √2) (v > 0), f u v = y} answer


Prove or disprove the following statement: If $F$ is a finite set with two or more elements, then there exists a binary operation $*$ on F such that for all $x,y,z$ in $F$,
\begin{enumerate}
\item[(i)] $x*z=y*z$ implies $x=y$ (right cancellation holds), and
\item[(ii)] $x*(y*z) \neq (x*y)*z$ (\emph{no} case of associativity holds).
\end{enumerate}

(∀ (F : Type*) (_ : Fintype F), Fintype.card F ≥ 2 → (∃ mul : F → F → F, ∀ x y z : F, (mul x z = mul y z → x = y) ∧ (mul x (mul y z) ≠ mul (mul x y) z))) ↔ answer


For each nonnegative integer $k$, let $d(k)$ denote the number of $1$'s in the binary expansion of $k$ (for example, $d(0)=0$ and $d(5)=2$). Let $m$ be a positive integer. Express $\sum_{k=0}^{2^m-1} (-1)^{d(k)}k^m$ in the form $(-1)^ma^{f(m)}(g(m))!$, where $a$ is an integer and $f$ and $g$ are polynomials.

(2, (Polynomial.X * (Polynomial.X - 1)) / 2, Polynomial.X)

@Eq (Prod Int (Prod (@Polynomial Real Real.semiring) (@Polynomial Nat Nat.instSemiring))) answer
  (@Prod.mk Int (Prod (@Polynomial Real Real.semiring) (@Polynomial Nat Nat.instSemiring))
    (@OfNat.ofNat Int (nat_lit 2) (@instOfNat (nat_lit 2)))
    (@Prod.mk (@Polynomial Real Real.semiring) (@Polynomial Nat Nat.instSemiring)
      (@HDiv.hDiv (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring)
        (@instHDiv (@Polynomial Real Real.semiring) (@Polynomial.instDiv Real Real.field))
        (@HMul.hMul (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring)
          (@instHMul (@Polynomial Real Real.semiring) (@Polynomial.mul' Real Real.semiring))
          (@Polynomial.X Real Real.semiring)
          (@HSub.hSub (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring)
            (@instHSub (@Polynomial Real Real.semiring) (@Polynomial.sub Real Real.instRing))
            (@Polynomial.X Real Real.semiring)
            (@OfNat.ofNat (@Polynomial Real Real.semiring) (nat_lit 1)
              (@One.toOfNat1 (@Polynomial Real Real.semiring) (@Polynomial.one Real Real.semiring)))))
        (@OfNat.ofNat (@Polynomial Real Real.semiring) (nat_lit 2)
          (@instOfNatAtLeastTwo (@Polynomial Real Real.semiring) (nat_lit 2)
            (@Polynomial.instNatCast Real Real.semiring)
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))))))
      (@Polynomial.X Nat Nat.instSemiring)))

hsumbits

∀ bits : List ℕ, sumbits bits = ∑ i : Fin bits.length, bits[i]


Determine, with proof, the number of ordered triples $(A_1, A_2, A_3)$ of sets which have the property that
\begin{enumerate}
\item[(i)] $A_1 \cup A_2 \cup A_3 = \{1,2,3,4,5,6,7,8,9,10\}$, and
\item[(ii)] $A_1 \cap A_2 \cap A_3 = \emptyset$.
\end{enumerate}
Express your answer in the form $2^a 3^b 5^c 7^d$, where $a,b,c,d$ are nonnegative integers.

Prove that the number of such triples is $2^{10}3^{10}$.

@Eq (Prod Nat (Prod Nat (Prod Nat Nat))) answer
  (@Prod.mk Nat (Prod Nat (Prod Nat Nat)) (@OfNat.ofNat Nat (nat_lit 10) (instOfNatNat (nat_lit 10)))
    (@Prod.mk Nat (Prod Nat Nat) (@OfNat.ofNat Nat (nat_lit 10) (instOfNatNat (nat_lit 10)))
      (@Prod.mk Nat Nat (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))
        (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0))))))

ℕ × ℕ × ℕ × ℕ

let (a, b, c, d) := answer;
  {(A1, A2, A3) : Set ℤ × Set ℤ × Set ℤ | A1 ∪ A2 ∪ A3 = Icc 1 10 ∧ A1 ∩ A2 ∩ A3 = ∅}.ncard = 2 ^ a * 3 ^ b * 5 ^ c * 7 ^ d


Let $d$ be a real number. For each integer $m \geq 0$, define a sequence $\{a_m(j)\}$, $j=0,1,2,\dots$ by the condition
\begin{align*}
a_m(0) &= d/2^m, \\
a_m(j+1) &= (a_m(j))^2 + 2a_m(j), \qquad j \geq 0.
\end{align*}
Evaluate $\lim_{n \to \infty} a_n(n)$.

@Eq (Real → Real) answer fun (d_1 : Real) =>
  @HSub.hSub Real Real Real (@instHSub Real Real.instSub) (Real.exp d_1)
    (@OfNat.ofNat Real (nat_lit 1) (@One.toOfNat1 Real Real.instOne))

Tendsto (fun n ↦ a n n) atTop (𝓝 (answer d))


Define a sequence $\{a_i\}$ by $a_1=3$ and $a_{i+1}=3^{a_i}$ for $i \geq 1$. Which integers between $00$ and $99$ inclusive occur as the last two digits in the decimal expansion of infinitely many $a_i$?

Prove that the only number that occurs infinitely often is $87$.

@Eq (Set (Fin (@OfNat.ofNat Nat (nat_lit 100) (instOfNatNat (nat_lit 100))))) answer
  (@Singleton.singleton (Fin (@OfNat.ofNat Nat (nat_lit 100) (instOfNatNat (nat_lit 100))))
    (Set (Fin (@OfNat.ofNat Nat (nat_lit 100) (instOfNatNat (nat_lit 100)))))
    (@Set.instSingletonSet (Fin (@OfNat.ofNat Nat (nat_lit 100) (instOfNatNat (nat_lit 100)))))
    (@OfNat.ofNat (Fin (@OfNat.ofNat Nat (nat_lit 100) (instOfNatNat (nat_lit 100)))) (nat_lit 87)
      (@Fin.instOfNat (@OfNat.ofNat Nat (nat_lit 100) (instOfNatNat (nat_lit 100)))
        (@Nat.instNeZeroSucc (@OfNat.ofNat Nat (nat_lit 99) (instOfNatNat (nat_lit 99)))) (nat_lit 87))))

{k : Fin 100 | ∀ N : ℕ, ∃ i ≥ N, a i % 100 = k} = answer


Let $I_m = \int_0^{2\pi} \cos(x)\cos(2x)\cdots \cos(mx)\,dx$. For which integers $m$, $1 \leq m \leq 10$ is $I_m \neq 0$?

Prove that the integers $m$ with $1 \leq m \leq 10$ and $I_m \neq 0$ are $m = 3, 4, 7, 8$.

@Eq (Set Nat) answer
  (@Insert.insert Nat (Set Nat) (@Set.instInsert Nat) (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))
    (@Insert.insert Nat (Set Nat) (@Set.instInsert Nat) (@OfNat.ofNat Nat (nat_lit 4) (instOfNatNat (nat_lit 4)))
      (@Insert.insert Nat (Set Nat) (@Set.instInsert Nat) (@OfNat.ofNat Nat (nat_lit 7) (instOfNatNat (nat_lit 7)))
        (@Singleton.singleton Nat (Set Nat) (@Set.instSingletonSet Nat)
          (@OfNat.ofNat Nat (nat_lit 8) (instOfNatNat (nat_lit 8)))))))

hI

I = fun (m : ℕ) ↦ ∫ x in (0)..(2 * Real.pi), ∏ k in Finset.Icc 1 m, cos (k * x)

{m ∈ Finset.Icc 1 10 | I m ≠ 0} = answer


If $p(x)= a_0 + a_1 x + \cdots + a_m x^m$ is a polynomial with real coefficients $a_i$, then set
\[
\Gamma(p(x)) = a_0^2 + a_1^2 + \cdots + a_m^2.
\]
Let $F(x) = 3x^2+7x+2$. Find, with proof, a polynomial $g(x)$ with real coefficients such that
\begin{enumerate}
\item[(i)] $g(0)=1$, and
\item[(ii)] $\Gamma(f(x)^n) = \Gamma(g(x)^n)$
\end{enumerate}
for every integer $n \geq 1$.

Show that $g(x) = 6x^2 + 5x + 1$ satisfies the conditions.

open Set Filter Topology Real Polynomial

@Eq (@Polynomial Real Real.semiring) answer
  (@HAdd.hAdd (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring)
    (@instHAdd (@Polynomial Real Real.semiring) (@Polynomial.add' Real Real.semiring))
    (@HAdd.hAdd (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring)
      (@instHAdd (@Polynomial Real Real.semiring) (@Polynomial.add' Real Real.semiring))
      (@HMul.hMul (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring)
        (@instHMul (@Polynomial Real Real.semiring) (@Polynomial.mul' Real Real.semiring))
        (@OfNat.ofNat (@Polynomial Real Real.semiring) (nat_lit 6)
          (@instOfNatAtLeastTwo (@Polynomial Real Real.semiring) (nat_lit 6)
            (@Polynomial.instNatCast Real Real.semiring)
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 4) (instOfNatNat (nat_lit 4))))))
        (@HPow.hPow (@Polynomial Real Real.semiring) Nat (@Polynomial Real Real.semiring)
          (@instHPow (@Polynomial Real Real.semiring) Nat
            (@Monoid.toNatPow (@Polynomial Real Real.semiring)
              (@MonoidWithZero.toMonoid (@Polynomial Real Real.semiring)
                (@Semiring.toMonoidWithZero (@Polynomial Real Real.semiring)
                  (@Polynomial.semiring Real Real.semiring)))))
          (@Polynomial.X Real Real.semiring) (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
      (@HMul.hMul (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring) (@Polynomial Real Real.semiring)
        (@instHMul (@Polynomial Real Real.semiring) (@Polynomial.mul' Real Real.semiring))
        (@OfNat.ofNat (@Polynomial Real Real.semiring) (nat_lit 5)
          (@instOfNatAtLeastTwo (@Polynomial Real Real.semiring) (nat_lit 5)
            (@Polynomial.instNatCast Real Real.semiring)
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3))))))
        (@Polynomial.X Real Real.semiring)))
    (@OfNat.ofNat (@Polynomial Real Real.semiring) (nat_lit 1)
      (@One.toOfNat1 (@Polynomial Real Real.semiring) (@Polynomial.one Real Real.semiring))))

hΓ

Γ = fun p ↦ ∑ k in Finset.range (p.natDegree + 1), coeff p k ^ 2

hf

f = 3 * Polynomial.X ^ 2 + 7 * Polynomial.X + 2

let g := answer;
  g.eval 0 = 1 ∧ ∀ n : ℕ, n ≥ 1 → Γ (f ^ n) = Γ (g ^ n)


Let $k$ be the smallest positive integer for which there exist distinct integers $m_1, m_2, m_3, m_4, m_5$ such that the polynomial
\[
p(x) = (x-m_1)(x-m_2)(x-m_3)(x-m_4)(x-m_5)
\]
has exactly $k$ nonzero coefficients. Find, with proof, a set of integers $m_1, m_2, m_3, m_4, m_5$ for which this minimum $k$ is achieved.

open Set Filter Topology Real Polynomial Function

@Eq (Fin (@OfNat.ofNat Nat (nat_lit 5) (instOfNatNat (nat_lit 5))) → Int) answer
  fun (i : Fin (@OfNat.ofNat Nat (nat_lit 5) (instOfNatNat (nat_lit 5)))) =>
  @HSub.hSub Int Int Int (@instHSub Int Int.instSub)
    (@Nat.cast Int instNatCastInt (@Fin.val (@OfNat.ofNat Nat (nat_lit 5) (instOfNatNat (nat_lit 5))) i))
    (@OfNat.ofNat Int (nat_lit 2) (@instOfNat (nat_lit 2)))

hp

p = fun m ↦ ∏ i : Fin 5, ((X : Polynomial ℝ) - m i)

hnumnzcoeff

numnzcoeff = fun p ↦ {j ∈ Finset.range (p.natDegree + 1) | coeff p j ≠ 0}.card

(Injective answer ∧ ∀ m : Fin 5 → ℤ, Injective m → numnzcoeff (p answer) ≤ numnzcoeff (p m))


Define polynomials $f_n(x)$ for $n \geq 0$ by $f_0(x)=1$, $f_n(0)=0$ for $n \geq 1$, and
\[
\frac{d}{dx} f_{n+1}(x) = (n+1)f_n(x+1)
\]
for $n \geq 0$. Find, with proof, the explicit factorization of $f_{100}(1)$ into powers of distinct primes.

@Eq (Nat → Nat) answer fun (n : Nat) =>
  @ite Nat (@Eq Nat n (@OfNat.ofNat Nat (nat_lit 101) (instOfNatNat (nat_lit 101))))
    (instDecidableEqNat n (@OfNat.ofNat Nat (nat_lit 101) (instOfNatNat (nat_lit 101))))
    (@OfNat.ofNat Nat (nat_lit 99) (instOfNatNat (nat_lit 99)))
    (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))

hfderiv

∀ n : ℕ, derivative (f (n + 1)) = (n + 1) * (Polynomial.comp (f n) (X + 1))

Nat.factorization ((f 100).eval 1) = answer


Evaluate $\int_0^\infty t^{-1/2}e^{-1985(t+t^{-1})}\,dt$. You may assume that $\int_{-\infty}^\infty e^{-x^2}\,dx = \sqrt{\pi}$.

Show that the integral evaluates to $\sqrt{\frac{\pi}{1985}}e^{-3970}$.

@Eq Real answer
  (@HMul.hMul Real Real Real (@instHMul Real Real.instMul)
    (Real.sqrt
      (@HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid)) Real.pi
        (@OfNat.ofNat Real (nat_lit 1985)
          (@instOfNatAtLeastTwo Real (nat_lit 1985) Real.instNatCast
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 1983) (instOfNatNat (nat_lit 1983))))))))
    (Real.exp
      (@Neg.neg Real Real.instNeg
        (@OfNat.ofNat Real (nat_lit 3970)
          (@instOfNatAtLeastTwo Real (nat_lit 3970) Real.instNatCast
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 3968) (instOfNatNat (nat_lit 3968)))))))))

fact

∫ x in Set.univ, Real.exp (- x ^ 2) = Real.sqrt Real.pi


Find, with explanation, the maximum value of $f(x)=x^3-3x$ on the set of all real numbers $x$ satisfying $x^4+36 \leq 13x^2$.

@Eq Real answer
  (@OfNat.ofNat Real (nat_lit 18)
    (@instOfNatAtLeastTwo Real (nat_lit 18) Real.instNatCast
      (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 16) (instOfNatNat (nat_lit 16))))))


What is the units (i.e., rightmost) digit of
\[
\left\lfloor \frac{10^{20000}}{10^{100}+3}\right\rfloor ?
\]

@Eq Nat answer (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))


Evaluate $\sum_{n=0}^\infty \mathrm{Arccot}(n^2+n+1)$, where $\mathrm{Arccot}\,t$ for $t \geq 0$ denotes the number $\theta$ in the interval $0 < \theta \leq \pi/2$ with $\cot \theta = t$.

@Eq Real answer
  (@HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid)) Real.pi
    (@OfNat.ofNat Real (nat_lit 2)
      (@instOfNatAtLeastTwo Real (nat_lit 2) Real.instNatCast
        (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))))))

harccot

∀ t : ℝ, t ≥ 0 → arccot t ∈ Set.Ioc 0 (Real.pi / 2) ∧ cot (arccot t) = t

(∑' n : ℕ, arccot (n ^ 2 + n + 1)) = answer


A \emph{transversal} of an $n\times n$ matrix $A$ consists of $n$ entries of $A$, no two in the same row or column. Let $f(n)$ be the number of $n \times n$ matrices $A$ satisfying the following two conditions:
\begin{enumerate}
\item[(a)] Each entry $\alpha_{i,j}$ of $A$ is in the set
$\{-1,0,1\}$.
\item[(b)] The sum of the $n$ entries of a transversal is the same for all transversals of $A$.
\end{enumerate}
An example of such a matrix $A$ is
\[
A = \left( \begin{array}{ccc} -1 & 0 & -1 \\ 0 & 1 & 0 \\ 0 & 1 & 0
\end{array}
\right).
\]
Determine with proof a formula for $f(n)$ of the form
\[
f(n) = a_1 b_1^n + a_2 b_2^n + a_3 b_3^n + a_4,
\]
where the $a_i$'s and $b_i$'s are rational numbers.

Prove that $f(n) = 4^n + 2 \cdot 3^n - 4 \cdot 2^n + 1$.

@Eq (Prod Rat (Prod Rat (Prod Rat (Prod Rat (Prod Rat (Prod Rat Rat)))))) answer
  (@Prod.mk Rat (Prod Rat (Prod Rat (Prod Rat (Prod Rat (Prod Rat Rat)))))
    (@OfNat.ofNat Rat (nat_lit 1) (@Rat.instOfNat (nat_lit 1)))
    (@Prod.mk Rat (Prod Rat (Prod Rat (Prod Rat (Prod Rat Rat))))
      (@OfNat.ofNat Rat (nat_lit 4) (@Rat.instOfNat (nat_lit 4)))
      (@Prod.mk Rat (Prod Rat (Prod Rat (Prod Rat Rat))) (@OfNat.ofNat Rat (nat_lit 2) (@Rat.instOfNat (nat_lit 2)))
        (@Prod.mk Rat (Prod Rat (Prod Rat Rat)) (@OfNat.ofNat Rat (nat_lit 3) (@Rat.instOfNat (nat_lit 3)))
          (@Prod.mk Rat (Prod Rat Rat)
            (@Neg.neg Rat Rat.instNeg (@OfNat.ofNat Rat (nat_lit 4) (@Rat.instOfNat (nat_lit 4))))
            (@Prod.mk Rat Rat (@OfNat.ofNat Rat (nat_lit 2) (@Rat.instOfNat (nat_lit 2)))
              (@OfNat.ofNat Rat (nat_lit 1) (@Rat.instOfNat (nat_lit 1)))))))))

ℚ × ℚ × ℚ × ℚ × ℚ × ℚ × ℚ

hf

f = fun n ↦
  Set.ncard {A : Matrix (Fin n) (Fin n) ℤ |
  (∀ i j : Fin n, A i j ∈ ({-1, 0, 1} : Set ℤ)) ∧
  ∃ S : ℤ, ∀ ϕ : Perm (Fin n), ∑ i : Fin n, A i (ϕ i) = S}


Let $a_1, a_2, \dots, a_n$ be real numbers, and let $b_1, b_2, \dots, b_n$ be distinct positive integers. Suppose that there is a polynomial $f(x)$ satisfying the identity
\[
(1-x)^n f(x) = 1 + \sum_{i=1}^n a_i x^{b_i}.
\]
Find a simple expression (not involving any sums) for $f(1)$ in terms of $b_1, b_2, \dots, b_n$ and $n$ (but independent of $a_1, a_2, \dots, a_n$).

fun b n ↦ (∏ i : Finset.Icc 1 n, b i) / Nat.factorial n

Show that $f(1) = b_1 b_2 \dots b_n / n!$.

@Eq ((Nat → Nat) → Nat → Real) answer fun (b_1 : Nat → Nat) (n_1 : Nat) =>
  @HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid))
    (@Nat.cast Real Real.instNatCast
      (@Finset.prod
        (@Subtype Nat fun (x : Nat) =>
          @Membership.mem Nat (Finset Nat) (@Finset.instMembership Nat)
            (@Finset.Icc Nat Nat.instPreorder Nat.instLocallyFiniteOrder
              (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1))) n_1)
            x)
        Nat Nat.instCommMonoid
        (@Finset.univ
          (@Subtype Nat fun (x : Nat) =>
            @Membership.mem Nat (Finset Nat) (@Finset.instMembership Nat)
              (@Finset.Icc Nat Nat.instPreorder Nat.instLocallyFiniteOrder
                (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1))) n_1)
              x)
          (@Finset.Subtype.fintype Nat
            (@Finset.Icc Nat Nat.instPreorder Nat.instLocallyFiniteOrder
              (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1))) n_1)))
        fun
          (i :
            @Subtype Nat fun (x : Nat) =>
              @Membership.mem Nat (Finset Nat) (@Finset.instMembership Nat)
                (@Finset.Icc Nat Nat.instPreorder Nat.instLocallyFiniteOrder
                  (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1))) n_1)
                x) =>
        b_1
          (@Subtype.val Nat
            (fun (x : Nat) =>
              @Membership.mem Nat (Finset Nat) (@Finset.instMembership Nat)
                (@Finset.Icc Nat Nat.instPreorder Nat.instLocallyFiniteOrder
                  (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1))) n_1)
                x)
            i)))
    (@Nat.cast Real Real.instNatCast (Nat.factorial n_1))

(ℕ → ℕ) → ℕ → ℝ

binj

∀ i ∈ Finset.Icc 1 n, ∀ j ∈ Finset.Icc 1 n, b i = b j → i = j

hf

∀ x : ℝ, (1 - x) ^ n * f.eval x = 1 + ∑ i : Finset.Icc 1 n, (a i) * x ^ (b i)


Inscribe a rectangle of base $b$ and height $h$ and an isosceles triangle of base $b$ (against a corresponding side of the rectangle and pointed in the other direction) in a circle of radius one. For what value of $h$ do the rectangle and triangle have the same area?

Show that the only such value of $h$ is $2/5$.

@Eq Real answer
  (@HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid))
    (@OfNat.ofNat Real (nat_lit 2)
      (@instOfNatAtLeastTwo Real (nat_lit 2) Real.instNatCast
        (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0))))))
    (@OfNat.ofNat Real (nat_lit 5)
      (@instOfNatAtLeastTwo Real (nat_lit 5) Real.instNatCast
        (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))))))


Prove that there are only a finite number of possibilities for the ordered triple $T=(x-y,y-z,z-x)$, where $x,y,z$ are complex numbers satisfying the simultaneous equations
\[
x(x-1)+2yz = y(y-1)+2zx = z(z-1)+2xy,
\]
and list all such triples $T$.

@Eq (Finset (Prod Complex (Prod Complex Complex))) answer
  (@Insert.insert (Prod Complex (Prod Complex Complex)) (Finset (Prod Complex (Prod Complex Complex)))
    (@Finset.instInsert (Prod Complex (Prod Complex Complex)) fun (a b : Prod Complex (Prod Complex Complex)) =>
      @instDecidableEqProd Complex (Prod Complex Complex) Complex.instDecidableEq
        (fun (a_1 b_1 : Prod Complex Complex) =>
          @instDecidableEqProd Complex Complex Complex.instDecidableEq Complex.instDecidableEq a_1 b_1)
        a b)
    (@Prod.mk Complex (Prod Complex Complex)
      (@OfNat.ofNat Complex (nat_lit 0) (@Zero.toOfNat0 Complex Complex.instZero))
      (@Prod.mk Complex Complex (@OfNat.ofNat Complex (nat_lit 0) (@Zero.toOfNat0 Complex Complex.instZero))
        (@OfNat.ofNat Complex (nat_lit 0) (@Zero.toOfNat0 Complex Complex.instZero))))
    (@Insert.insert (Prod Complex (Prod Complex Complex)) (Finset (Prod Complex (Prod Complex Complex)))
      (@Finset.instInsert (Prod Complex (Prod Complex Complex)) fun (a b : Prod Complex (Prod Complex Complex)) =>
        @instDecidableEqProd Complex (Prod Complex Complex) Complex.instDecidableEq
          (fun (a_1 b_1 : Prod Complex Complex) =>
            @instDecidableEqProd Complex Complex Complex.instDecidableEq Complex.instDecidableEq a_1 b_1)
          a b)
      (@Prod.mk Complex (Prod Complex Complex)
        (@OfNat.ofNat Complex (nat_lit 0) (@Zero.toOfNat0 Complex Complex.instZero))
        (@Prod.mk Complex Complex
          (@Neg.neg Complex Complex.instNeg (@OfNat.ofNat Complex (nat_lit 1) (@One.toOfNat1 Complex Complex.instOne)))
          (@OfNat.ofNat Complex (nat_lit 1) (@One.toOfNat1 Complex Complex.instOne))))
      (@Insert.insert (Prod Complex (Prod Complex Complex)) (Finset (Prod Complex (Prod Complex Complex)))
        (@Finset.instInsert (Prod Complex (Prod Complex Complex)) fun (a b : Prod Complex (Prod Complex Complex)) =>
          @instDecidableEqProd Complex (Prod Complex Complex) Complex.instDecidableEq
            (fun (a_1 b_1 : Prod Complex Complex) =>
              @instDecidableEqProd Complex Complex Complex.instDecidableEq Complex.instDecidableEq a_1 b_1)
            a b)
        (@Prod.mk Complex (Prod Complex Complex)
          (@OfNat.ofNat Complex (nat_lit 1) (@One.toOfNat1 Complex Complex.instOne))
          (@Prod.mk Complex Complex (@OfNat.ofNat Complex (nat_lit 0) (@Zero.toOfNat0 Complex Complex.instZero))
            (@Neg.neg Complex Complex.instNeg
              (@OfNat.ofNat Complex (nat_lit 1) (@One.toOfNat1 Complex Complex.instOne)))))
        (@Singleton.singleton (Prod Complex (Prod Complex Complex)) (Finset (Prod Complex (Prod Complex Complex)))
          (@Finset.instSingleton (Prod Complex (Prod Complex Complex)))
          (@Prod.mk Complex (Prod Complex Complex)
            (@Neg.neg Complex Complex.instNeg
              (@OfNat.ofNat Complex (nat_lit 1) (@One.toOfNat1 Complex Complex.instOne)))
            (@Prod.mk Complex Complex (@OfNat.ofNat Complex (nat_lit 1) (@One.toOfNat1 Complex Complex.instOne))
              (@OfNat.ofNat Complex (nat_lit 0) (@Zero.toOfNat0 Complex Complex.instZero))))))))


For a positive real number $r$, let $G(r)$ be the minimum value of $|r - \sqrt{m^2+2n^2}|$ for all integers $m$ and $n$. Prove or disprove the assertion that $\lim_{r\to \infty}G(r)$ exists and equals $0$.

Show that the limit exists and equals $0$.

open Real Equiv Polynomial Filter Topology

hGeq

∀ r : ℝ, ∃ m n : ℤ, G r = |r - Real.sqrt (m ^ 2 + 2 * n ^ 2)|

hGlb

∀ r : ℝ, ∀ m n : ℤ, G r ≤ |r - Real.sqrt (m ^ 2 + 2 * n ^ 2)|


Let $f(x,y,z) = x^2+y^2+z^2+xyz$. Let $p(x,y,z), q(x,y,z)$, $r(x,y,z)$ be polynomials with real coefficients satisfying
\[
f(p(x,y,z), q(x,y,z), r(x,y,z)) = f(x,y,z).
\]
Prove or disprove the assertion that the sequence $p,q,r$ consists of some permutation of $\pm x, \pm y, \pm z$, where the number of minus signs is $0$ or $2$.

open Real Equiv Polynomial Filter Topology MvPolynomial

answer ↔ (∀ pqr : Fin 3 → MvPolynomial (Fin 3) ℝ,
      (∀ xyz : Fin 3 → ℝ, MvPolynomial.eval (fun i ↦ MvPolynomial.eval xyz (pqr i)) f = MvPolynomial.eval xyz f) →
      ({pqr 0, pqr 1, pqr 2} ∈ perms))


The sequence of digits $123456789101112131415161718192021 \dots$ is obtained by writing the positive integers in order. If the $10^n$-th digit in this sequence occurs in the part of the sequence in which the $m$-digit numbers are placed, define $f(n)$ to be $m$. For example, $f(2)=2$ because the $100$th digit enters the sequence in the placement of the two-digit integer $55$. Find, with proof, $f(1987)$.

Show that the value of $f(1987)$ is $1984$.

@Eq Nat answer (@OfNat.ofNat Nat (nat_lit 1984) (instOfNatNat (nat_lit 1984)))

hseqind

seqind 1 = 1 ∧ ∀ i ≥ 2, seqind i = seqind (i - 1) + (Nat.digits 10 (i - 1)).length

hseqsize

∀ i ≥ 1, ∀ j : Fin ((Nat.digits 10 i).length), seqsize (seqind i + j) = (Nat.digits 10 i).length


Let $P$ be a polynomial, with real coefficients, in three variables and $F$ be a function of two variables such that
\[
P(ux, uy, uz) = u^2 F(y-x,z-x) \quad \mbox{for all real $x,y,z,u$},
\]
and such that $P(1,0,0)=4$, $P(0,1,0)=5$, and $P(0,0,1)=6$. Also let $A,B,C$ be complex numbers with $P(A,B,C)=0$ and $|B-A|=10$. Find $|C-A|$.

Prove that $|C - A| = \frac{5}{3}\sqrt{30}$.

@Eq Complex answer
  (@HMul.hMul Complex Complex Complex (@instHMul Complex Complex.instMul)
    (@HDiv.hDiv Complex Complex Complex (@instHDiv Complex (@DivInvMonoid.toDiv Complex Complex.instDivInvMonoid))
      (@OfNat.ofNat Complex (nat_lit 5)
        (@instOfNatAtLeastTwo Complex (nat_lit 5)
          (@AddMonoidWithOne.toNatCast Complex (@AddGroupWithOne.toAddMonoidWithOne Complex Complex.addGroupWithOne))
          (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3))))))
      (@OfNat.ofNat Complex (nat_lit 3)
        (@instOfNatAtLeastTwo Complex (nat_lit 3)
          (@AddMonoidWithOne.toNatCast Complex (@AddGroupWithOne.toAddMonoidWithOne Complex Complex.addGroupWithOne))
          (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))))))
    ↑(Real.sqrt
        (@OfNat.ofNat Real (nat_lit 30)
          (@instOfNatAtLeastTwo Real (nat_lit 30) Real.instNatCast
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 28) (instOfNatNat (nat_lit 28))))))))

vars

ℂ → ℂ → ℂ → (Fin 3 → ℂ)

hvars

vars = fun a b c ↦ fun i ↦ ite (i = 0) a (ite (i = 1) b c)

h

∀ x y z u : ℝ, eval (vars (u * x) (u * y) (u * z)) P = u ^ 2 * F (y - x) (z - x)

hPval

eval (vars 1 0 0) P = 4 ∧ eval (vars 0 1 0) P = 5 ∧ eval (vars 0 0 1) P = 6


Let $\vec{G}(x,y)=\left(\frac{-y}{x^2+4y^2},\frac{x}{x^2+4y^2},0\right)$. Prove or disprove that there is a vector-valued function $\vec{F}(x,y,z)=(M(x,y,z),N(x,y,z),P(x,y,z))$ with the following properties:
\begin{enumerate}
\item[(i)] $M$, $N$, $P$ have continuous partial derivatives for all $(x,y,z) \neq (0,0,0)$;
\item[(ii)] $\text{Curl}\,\vec{F}=\vec{0}$ for all $(x,y,z) \neq (0,0,0)$;
\item[(iii)] $\vec{F}(x,y,0)=\vec{G}(x,y)$.
\end{enumerate}

curl

((Fin 3 → ℝ) → (Fin 3 → ℝ)) → ((Fin 3 → ℝ) → (Fin 3 → ℝ))

∀ f x, curl f x = ![
      fderiv ℝ f x (Pi.single 1 1) 2 - fderiv ℝ f x (Pi.single 2 1) 1,
      fderiv ℝ f x (Pi.single 2 1) 0 - fderiv ℝ f x (Pi.single 0 1) 2,
      fderiv ℝ f x (Pi.single 0 1) 1 - fderiv ℝ f x (Pi.single 1 1) 0]

(∃ F : (Fin 3 → ℝ) → (Fin 3 → ℝ),
        ContDiffOn ℝ 1 F {v | v ≠ ![0,0,0]} ∧
        (∀ x, x ≠ 0 → curl F x = 0) ∧
        ∀ x y, F ![x, y, 0] = G ![x, y]) ↔ answer


For each positive integer $n$, let $a(n)$ be the number of zeroes in the base $3$ representation of $n$. For which positive real numbers $x$ does the series
\[
\sum_{n=1}^\infty \frac{x^{a(n)}}{n^3}
\]
converge?

the set of positive real numbers $x$ such that $0 < x < 25$

Show that for positive $x$, the series converges if and only if $x < 25$.

@Eq (Set Real) answer
  (@setOf Real fun (x : Real) =>
    And (@GT.gt Real Real.instLT x (@OfNat.ofNat Real (nat_lit 0) (@Zero.toOfNat0 Real Real.instZero)))
      (@LT.lt Real Real.instLT x
        (@OfNat.ofNat Real (nat_lit 25)
          (@instOfNatAtLeastTwo Real (nat_lit 25) Real.instNatCast
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 23) (instOfNatNat (nat_lit 23))))))))

ha

a = fun n ↦ {i | (digits 3 n).get i = 0}.ncard

{x : ℝ | x > 0 ∧ Summable (fun n ↦ x ^ (a n) / (n ^ 3))} = answer


Prove that the integral evaluates to $1$.

@Eq Real answer (@OfNat.ofNat Real (nat_lit 1) (@One.toOfNat1 Real Real.instOne))

answer = ∫ x in (2)..4, sqrt (log (9 - x)) / (sqrt (log (9 - x)) + sqrt (log (x + 3)))


Let $(x_1,y_1) = (0.8, 0.6)$ and let $x_{n+1} = x_n \cos y_n - y_n \sin y_n$ and $y_{n+1}= x_n \sin y_n + y_n \cos y_n$ for $n=1,2,3,\dots$. For each of $\lim_{n\to \infty} x_n$ and $\lim_{n \to \infty} y_n$, prove that the limit exists and find it or prove that the limit does not exist.

Show that $\lim_{n \to \infty} x_n = -1$ and $\lim_{n \to \infty} y_n = 0$.

open MvPolynomial Real Nat Filter Topology

@Eq (Prod Prop (Prod Real (Prod Prop Real))) answer
  (@Prod.mk Prop (Prod Real (Prod Prop Real)) True
    (@Prod.mk Real (Prod Prop Real)
      (@Neg.neg Real Real.instNeg (@OfNat.ofNat Real (nat_lit 1) (@One.toOfNat1 Real Real.instOne)))
      (@Prod.mk Prop Real True (@OfNat.ofNat Real (nat_lit 0) (@Zero.toOfNat0 Real Real.instZero)))))

hx

∀ n ≥ 1, x (n + 1) = (x n) * cos (y n) - (y n) * sin (y n)

hy

∀ n ≥ 1, y (n + 1) = (x n) * sin (y n) + (y n) * cos (y n)

let (existsx, limx, existsy, limy) := answer
((∃ c : ℝ, Tendsto x atTop (𝓝 c)) → existsx) ∧
(existsx → Tendsto x atTop (𝓝 limx)) ∧
((∃ c : ℝ, Tendsto y atTop (𝓝 c)) → existsy) ∧
(existsy → Tendsto y atTop (𝓝 limy))


Let $R$ be the region consisting of the points $(x,y)$ of the cartesian plane satisfying both $|x|-|y| \leq 1$ and $|y| \leq 1$. Find the area of $R$.

@Eq Real answer
  (@OfNat.ofNat Real (nat_lit 6)
    (@instOfNatAtLeastTwo Real (nat_lit 6) Real.instNatCast
      (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 4) (instOfNatNat (nat_lit 4))))))


A not uncommon calculus mistake is to believe that the product rule for derivatives says that $(fg)' = f'g'$. If $f(x)=e^{x^2}$, determine, with proof, whether there exists an open interval $(a,b)$ and a nonzero function $g$ defined on $(a,b)$ such that this wrong product rule is true for $x$ in $(a,b)$.

answer ↔
      (∃ a b : ℝ,
        a < b ∧
        ∃ g : ℝ → ℝ,
          (∃ x ∈ Ioo a b, g x ≠ 0) ∧
          DifferentiableOn ℝ g (Ioo a b) ∧
          ∀ x ∈ Ioo a b, deriv (fun y ↦ f y * g y) x = (deriv f x) * (deriv g x))


Determine, with proof, the set of real numbers $x$ for which
\[
\sum_{n=1}^\infty \left( \frac{1}{n} \csc \frac{1}{n} - 1 \right)^x
\]
converges.

Show that the series converges if and only if $x > \frac{1}{2}$.

@Eq (Set Real) answer
  (@setOf Real fun (x : Real) =>
    @GT.gt Real Real.instLT x
      (@HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid))
        (@OfNat.ofNat Real (nat_lit 1) (@One.toOfNat1 Real Real.instOne))
        (@OfNat.ofNat Real (nat_lit 2)
          (@instOfNatAtLeastTwo Real (nat_lit 2) Real.instNatCast
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0))))))))

answer = {x : ℝ | ∃ L : ℝ, Tendsto (fun t ↦ ∑ n in Finset.Icc (1 : ℕ) t, (((1 / n) / Real.sin (1 / n) - 1) ^ x)) atTop (𝓝 L)}


\begin{enumerate}
\item[(a)] If every point of the plane is painted one of three colors, do there necessarily exist two points of the same color exactly one inch apart?
\item[(b)] What if ``three'' is replaced by ``nine''?
\end{enumerate}

Prove that the points must exist with three colors, but not necessarily with nine.

@Eq (Prod Prop Prop) answer (@Prod.mk Prop Prop True False)

hp

∀ n, p n ↔
      ∀ color : (EuclideanSpace ℝ (Fin 2)) → Fin n,
        ∃ p q : EuclideanSpace ℝ (Fin 2),
          color p = color q ∧ dist p q = 1

let (a, b) := answer; (p 3 ↔ a) ∧ (p 9 ↔ b)


If a linear transformation $A$ on an $n$-dimensional vector space has $n+1$ eigenvectors such that any $n$ of them are linearly independent, does it follow that $A$ is a scalar multiple of the identity? Prove your answer.

Show that the answer is yes, $A$ must be a scalar multiple of the identity.

(∀ (F V : Type*) (_ : Field F) (_ : AddCommGroup V) (_ : Module F V) (_ : FiniteDimensional F V) (n : ℕ) (A : Module.End F V) (evecs : Set V), (n = Module.finrank F V ∧ evecs ⊆ {v : V | ∃ f : F, A.HasEigenvector f v} ∧ evecs.encard = n + 1 ∧ (∀ sevecs : Fin n → V, (Set.range sevecs ⊆ evecs ∧ (Set.range sevecs).encard = n) → LinearIndependent F sevecs)) → (∃ c : F, A = c • LinearMap.id)) ↔ answer


Prove or disprove: If $x$ and $y$ are real numbers with $y \geq 0$ and $y(y+1) \leq (x+1)^2$, then $y(y-1) \leq x^2$.


For every $n$ in the set $N=\{1,2,\dots\}$ of positive integers, let $r_n$ be the minimum value of $|c-d \sqrt{3}|$ for all nonnegative integers $c$ and $d$ with $c+d=n$. Find, with proof, the smallest positive real number $g$ with $r_n \leq g$ for all $n \in N$.

Show that the smallest such $g$ is $(1+\sqrt{3})/2$.

@Eq Real answer
  (@HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid))
    (@HAdd.hAdd Real Real Real (@instHAdd Real Real.instAdd)
      (@OfNat.ofNat Real (nat_lit 1) (@One.toOfNat1 Real Real.instOne))
      (Real.sqrt
        (@OfNat.ofNat Real (nat_lit 3)
          (@instOfNatAtLeastTwo Real (nat_lit 3) Real.instNatCast
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1))))))))
    (@OfNat.ofNat Real (nat_lit 2)
      (@instOfNatAtLeastTwo Real (nat_lit 2) Real.instNatCast
        (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))))))

hr

∀ n ≥ 1,
      (∃ c d : ℤ,
        (c ≥ 0 ∧ d ≥ 0) ∧
        c + d = n ∧ r n = |c - d * Real.sqrt 3|) ∧
        (∀ c d : ℤ, (c ≥ 0 ∧ d ≥ 0 ∧ c + d = n) → |c - d * Real.sqrt 3| ≥ r n)

IsLeast {g : ℝ | g > 0 ∧ (∀ n : ℤ, n ≥ 1 → r n ≤ g)} answer


For positive integers $n$, let $M_n$ be the $2n+1$ by $2n+1$ skew-symmetric matrix for which each entry in the first $n$ subdiagonals below the main diagonal is $1$ and each of the remaining entries below the main diagonal is $-1$. Find, with proof, the rank of $M_n$. (According to one definition, the rank of a matrix is the largest $k$ such that there is a $k \times k$ submatrix with nonzero determinant.) One may note that
\begin{align*}
M_1&=\begin{pmatrix} 0 & -1 & 1 \\ 1 & 0 & -1 \\ -1 & 1 & 0 \end{pmatrix} \\
M_2&=\begin{pmatrix} 0 & -1 & -1 & 1 & 1 \\ 1 & 0 & -1 & -1 & 1 \\ 1 & 1 & 0 & -1 & -1 \\ -1 & 1 & 1 & 0 & -1 \\ -1 & -1 & 1 & 1 & 0 \end{pmatrix}.
\end{align*}

Show that the rank of $M_n$ equals $2n$.

@Eq (Nat → Nat) answer fun (n_1 : Nat) =>
  @HMul.hMul Nat Nat Nat (@instHMul Nat instMulNat) (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) n_1


How many primes among the positive integers, written as usual in base $10$, are alternating $1$'s and $0$'s, beginning and ending with $1$?

@Eq ENat answer
  (@OfNat.ofNat ENat (nat_lit 1)
    (@One.toOfNat1 ENat
      (@AddMonoidWithOne.toOne ENat
        (@AddCommMonoidWithOne.toAddMonoidWithOne ENat
          (@NonAssocSemiring.toAddCommMonoidWithOne ENat
            (@Semiring.toNonAssocSemiring ENat
              (@OrderedSemiring.toSemiring ENat
                (@OrderedCommSemiring.toOrderedSemiring ENat
                  (@CanonicallyOrderedCommSemiring.toOrderedCommSemiring ENat
                    instENatCanonicallyOrderedCommSemiring)))))))))

hpdigalt

∀ l, pdigalt l ↔ Odd l.length ∧ (∀ i, l.get i = if Even (i : ℕ) then 1 else 0)

{p : ℕ | p.Prime ∧ pdigalt (Nat.digits 10 p)}.encard = answer


Evaluate $\int_0^a \int_0^b e^{\max\{b^2x^2,a^2y^2\}}\,dy\,dx$ where $a$ and $b$ are positive.

Show that the value of the integral is $(e^{a^2b^2}-1)/(ab)$.

@Eq (Real → Real → Real) answer fun (a_1 b_1 : Real) =>
  @HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid))
    (@HSub.hSub Real Real Real (@instHSub Real Real.instSub)
      (Real.exp
        (@HMul.hMul Real Real Real (@instHMul Real Real.instMul)
          (@HPow.hPow Real Nat Real (@instHPow Real Nat (@Monoid.toNatPow Real Real.instMonoid)) a_1
            (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
          (@HPow.hPow Real Nat Real (@instHPow Real Nat (@Monoid.toNatPow Real Real.instMonoid)) b_1
            (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))))
      (@OfNat.ofNat Real (nat_lit 1) (@One.toOfNat1 Real Real.instOne)))
    (@HMul.hMul Real Real Real (@instHMul Real Real.instMul) a_1 b_1)

∫ x in Set.Ioo 0 a, ∫ y in Set.Ioo 0 b, Real.exp (max (b ^ 2 * x ^ 2) (a ^ 2 * y ^ 2)) = answer a b


A dart, thrown at random, hits a square target. Assuming that any two parts of the target of equal area are equally likely to be hit, find the probability that the point hit is nearer to the center than to any edge. Express your answer in the form $(a\sqrt{b}+c)/d$, where $a$, $b$, $c$, $d$ are integers and $b$, $d$ are positive.

Show that the probability is $(4\sqrt{2}-5)/3$.

@Eq (Prod Int (Prod Int (Prod Int Int))) answer
  (@Prod.mk Int (Prod Int (Prod Int Int)) (@OfNat.ofNat Int (nat_lit 4) (@instOfNat (nat_lit 4)))
    (@Prod.mk Int (Prod Int Int) (@OfNat.ofNat Int (nat_lit 2) (@instOfNat (nat_lit 2)))
      (@Prod.mk Int Int (@Neg.neg Int Int.instNegInt (@OfNat.ofNat Int (nat_lit 5) (@instOfNat (nat_lit 5))))
        (@OfNat.ofNat Int (nat_lit 3) (@instOfNat (nat_lit 3))))))

ℤ × ℤ × ℤ × ℤ

square = {p | ∀ i : Fin 2, p i ∈ Set.Icc 0 1}

perimeter = {p ∈ square | p 0 = 0 ∨ p 0 = 1 ∨ p 1 = 0 ∨ p 1 = 1}

hScloser

Scloser = {p ∈ square | ∀ q ∈ perimeter, dist p center < dist p q}

let (a, b, c, d) := answer;
    b > 0 ∧ d > 0 ∧ (¬∃ n : ℤ, n^2 = b) ∧
    (volume Scloser).toReal / (volume square).toReal = (a * Real.sqrt b + c) / d


Let $S$ be a non-empty set with an associative operation that is left and right cancellative ($xy=xz$ implies $y=z$, and $yx=zx$ implies $y=z$). Assume that for every $a$ in $S$ the set $\{a^n:\,n=1, 2, 3, \ldots\}$ is finite. Must $S$ be a group?

(∀ (S : Type) [Nonempty S] [Semigroup S] [IsCancelMul S]
    (h_fin : ∀ a : S, {(a * ·)^[n] a | n : ℕ}.Finite),
      ∃ e : S, ∀ x, e * x = x ∧ x * e = x ∧ ∃ y, x * y = e ∧ y * x = e) ↔
    answer


Let $f$ be a function on $[0,\infty)$, differentiable and satisfying
\[
f'(x)=-3f(x)+6f(2x)
\]
for $x>0$. Assume that $|f(x)|\le e^{-\sqrt{x}}$ for $x\ge 0$ (so that $f(x)$ tends rapidly to $0$ as $x$ increases). For $n$ a non-negative integer, define
\[
\mu_n=\int_0^\infty x^n f(x)\,dx
\]
(sometimes called the $n$th moment of $f$).
\begin{enumerate}
\item[a)] Express $\mu_n$ in terms of $\mu_0$.
\item[b)] Prove that the sequence $\{\mu_n \frac{3^n}{n!}\}$ always converges, and that the limit is $0$ only if $\mu_0=0$.
\end{enumerate}

fun n c ↦ c * n ! / (3 ^ n * ∏ m in Finset.Icc (1 : ℤ) n, (1 - 2 ^ (-m)))

@Eq (Nat → Real → Real) answer fun (n : Nat) (c : Real) =>
  @HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid))
    (@HMul.hMul Real Real Real (@instHMul Real Real.instMul) c (@Nat.cast Real Real.instNatCast (Nat.factorial n)))
    (@HMul.hMul Real Real Real (@instHMul Real Real.instMul)
      (@HPow.hPow Real Nat Real (@instHPow Real Nat (@Monoid.toNatPow Real Real.instMonoid))
        (@OfNat.ofNat Real (nat_lit 3)
          (@instOfNatAtLeastTwo Real (nat_lit 3) Real.instNatCast
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1))))))
        n)
      (@Finset.prod Int Real Real.instCommMonoid
        (@Finset.Icc Int
          (@PartialOrder.toPreorder Int
            (@OrderedAddCommGroup.toPartialOrder Int
              (@StrictOrderedRing.toOrderedAddCommGroup Int
                (@LinearOrderedRing.toStrictOrderedRing Int
                  (@LinearOrderedCommRing.toLinearOrderedRing Int Int.instLinearOrderedCommRing)))))
          Int.instLocallyFiniteOrder (@OfNat.ofNat Int (nat_lit 1) (@instOfNat (nat_lit 1)))
          (@Nat.cast Int instNatCastInt n))
        fun (m : Int) =>
        @HSub.hSub Real Real Real (@instHSub Real Real.instSub)
          (@OfNat.ofNat Real (nat_lit 1) (@One.toOfNat1 Real Real.instOne))
          (@HPow.hPow Real Int Real (@instHPow Real Int (@DivInvMonoid.toZPow Real Real.instDivInvMonoid))
            (@OfNat.ofNat Real (nat_lit 2)
              (@instOfNatAtLeastTwo Real (nat_lit 2) Real.instNatCast
                (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0))))))
            (@Neg.neg Int Int.instNegInt m))))

∀ n, μ n = ∫ x in Set.Ioi 0, x ^ n * f x

(∀ n, μ n = answer n (μ 0)) ∧
  (∃ L, Tendsto (fun n ↦ (μ n) * 3 ^ n / n !) atTop (𝓝 L)) ∧
  (Tendsto (fun n ↦ (μ n) * 3 ^ n / n !) atTop (𝓝 0) → μ 0 = 0)


Can a countably infinite set have an uncountable collection of non-empty subsets such that the intersection of any two of them is finite?

answer ↔
    (∃ S : Type,
      Countable S ∧ Infinite S ∧
      ∃ C : Set (Set S),
        ¬Countable C ∧
        (∀ R ∈ C, R ≠ ∅) ∧
        (∀ A ∈ C, ∀ B ∈ C, A ≠ B → (A ∩ B).Finite)
    )


Let $T_0=2,T_1=3,T_2=6$, and for $n \geq 3$, $T_n=(n+4)T_{n-1}-4nT_{n-2}+(4n-8)T_{n-3}$. The first few terms are $2,3,6,14,40,152,784,5168,40576$. Find, with proof, a formula for $T_n$ of the form $T_n=A_n+B_n$, where $\{A_n\}$ and $\{B_n\}$ are well-known sequences.

@Eq (Nat → Nat) answer fun (n : Nat) =>
  @HAdd.hAdd Nat Nat Nat (@instHAdd Nat instAddNat) (Nat.factorial n)
    (@HPow.hPow Nat Nat Nat (@instHPow Nat Nat (@Monoid.toNatPow Nat Nat.instMonoid))
      (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))) n)


Is $\sqrt{2}$ the limit of a sequence of numbers of the form $\sqrt[3]{n}-\sqrt[3]{m}$ ($n,m=0,1,2,\dots$)?

answer ↔ (∃ s : ℕ → ℝ, (∀ i : ℕ, numform (s i)) ∧ Tendsto s atTop (𝓝 (Real.sqrt 2)))


Consider a paper punch that can be centered at any point of the plane and that, when operated, removes from the plane precisely those points whose distance from the center is irrational. How many punches are needed to remove every point?

@Eq Nat answer (@OfNat.ofNat Nat (nat_lit 3) (instOfNatNat (nat_lit 3)))

sInf {n : ℕ | ∃ S : Set (EuclideanSpace ℝ (Fin 2)), S.encard = n ∧ ∀ Q : EuclideanSpace ℝ (Fin 2), ∃ P ∈ S, Irrational (dist P Q)} = answer


If $\mathbf{A}$ and $\mathbf{B}$ are square matrices of the same size such that $\mathbf{ABAB}=\mathbf{0}$, does it follow that $\mathbf{BABA}=\mathbf{0}$?

answer ↔
    (∀ n ≥ 1, ∀ A B : Matrix (Fin n) (Fin n) ℝ,
      A * B * A * B = 0 → B * A * B * A = 0)


If $X$ is a finite set, let $|X|$ denote the number of elements in $X$. Call an ordered pair $(S,T)$ of subsets of $\{1,2,\dots,n\}$ \emph{admissible} if $s>|T|$ for each $s \in S$, and $t>|S|$ for each $t \in T$. How many admissible ordered pairs of subsets of $\{1,2,\dots,10\}$ are there? Prove your answer.

Show that the number of admissible ordered pairs of subsets of $\{1,2,\dots,10\}$ equals the $22$nd Fibonacci number $F_{22}=17711$.

@Eq Nat answer (@OfNat.ofNat Nat (nat_lit 17711) (instOfNatNat (nat_lit 17711)))

((Finset.univ : Finset <| Finset (Set.Icc 1 10) × Finset (Set.Icc 1 10)).filter
      fun ⟨S, T⟩ ↦ (∀ s ∈ S, T.card < s) ∧ (∀ t ∈ T, S.card < t)).card =
    answer


Find all real-valued continuously differentiable functions $f$ on the real line such that for all $x$, $(f(x))^2=\int_0^x [(f(t))^2+(f'(t))^2]\,dt+1990$.

Show that there are two such functions, namely $f(x)=\sqrt{1990}e^x$, and $f(x)=-\sqrt{1990}e^x$.

@Eq (Set (Real → Real)) answer
  (@Insert.insert (Real → Real) (Set (Real → Real)) (@Set.instInsert (Real → Real))
    (fun (x : Real) =>
      @HMul.hMul Real Real Real (@instHMul Real Real.instMul)
        (Real.sqrt
          (@OfNat.ofNat Real (nat_lit 1990)
            (@instOfNatAtLeastTwo Real (nat_lit 1990) Real.instNatCast
              (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 1988) (instOfNatNat (nat_lit 1988)))))))
        (Real.exp x))
    (@Singleton.singleton (Real → Real) (Set (Real → Real)) (@Set.instSingletonSet (Real → Real)) fun (x : Real) =>
      @HMul.hMul Real Real Real (@instHMul Real Real.instMul)
        (@Neg.neg Real Real.instNeg
          (Real.sqrt
            (@OfNat.ofNat Real (nat_lit 1990)
              (@instOfNatAtLeastTwo Real (nat_lit 1990) Real.instNatCast
                (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 1988) (instOfNatNat (nat_lit 1988))))))))
        (Real.exp x)))


Let $G$ be a finite group of order $n$ generated by $a$ and $b$. Prove or disprove: there is a sequence $g_1,g_2,g_3,\dots,g_{2n}$ such that
\begin{itemize}
\item[(1)] every element of $G$ occurs exactly twice, and
\item[(2)] $g_{i+1}$ equals $g_ia$ or $g_ib$ for $i=1,2,\dots,2n$. (Interpret $g_{2n+1}$ as $g_1$.)
\end{itemize}

∀ (G : Type*) (_ : Fintype G) (_ : Group G) (n : ℕ) (a b : G), (n = Fintype.card G ∧ G = Subgroup.closure {a, b} ∧ G ≠ Subgroup.closure {a} ∧ G ≠ Subgroup.closure {b}) → (∃ g : ℕ → G, (∀ x : G, {i : Fin (2 * n) | g i = x}.encard = 2)
  ∧ (∀ i : Fin (2 * n), (g ((i + 1) % (2 * n)) = g i * a) ∨ (g ((i + 1) % (2 * n)) = g i * b))) ↔ answer


Is there an infinite sequence $a_0,a_1,a_2,\dots$ of nonzero real numbers such that for $n=1,2,3,\dots$ the polynomial $p_n(x)=a_0+a_1x+a_2x^2+\cdots+a_nx^n$ has exactly $n$ distinct real roots?

Show that the answer is yes, such an infinite sequence exists.

answer ↔ (∃ a : ℕ → ℝ, (∀ i, a i ≠ 0) ∧ (∀ n ≥ 1, (∑ i in Finset.Iic n, a i • Polynomial.X ^ i : Polynomial ℝ).roots.toFinset.card = n))


Let $\mathbf{A}$ and $\mathbf{B}$ be different $n \times n$ matrices with real entries. If $\mathbf{A}^3=\mathbf{B}^3$ and $\mathbf{A}^2\mathbf{B}=\mathbf{B}^2\mathbf{A}$, can $\mathbf{A}^2+\mathbf{B}^2$ be invertible?

answer ↔ (∃ A B : Matrix (Fin n) (Fin n) ℝ,
    A ≠ B ∧ A ^ 3 = B ^ 3 ∧
    A ^ 2 * B = B ^ 2 * A ∧
    Nonempty (Invertible (A ^ 2 + B ^ 2)))


Find all real polynomials $p(x)$ of degree $n \geq 2$ for which there exist real numbers $r_1<r_2<\cdots<r_n$ such that
\begin{enumerate}
\item $p(r_i)=0, \qquad i=1,2,\dots,n$, and
\item $p'(\frac{r_i+r_{i+1}}{2})=0 \qquad i=1,2,\dots,n-1$,
\end{enumerate}
where $p'(x)$ denotes the derivative of $p(x)$.

the set of all real polynomials of degree 2 with two distinct real roots

Show that the real polynomials with the required property are exactly those that are of degree $2$ with $2$ distinct real zeros.

@Eq (Set (@Polynomial Real Real.semiring)) answer
  (@setOf (@Polynomial Real Real.semiring) fun (p_1 : @Polynomial Real Real.semiring) =>
    And
      (@Eq (WithBot Nat) (@Polynomial.degree Real Real.semiring p_1)
        (@OfNat.ofNat (WithBot Nat) (nat_lit 2)
          (@instOfNatAtLeastTwo (WithBot Nat) (nat_lit 2)
            (@AddMonoidWithOne.toNatCast (WithBot Nat) (@WithBot.addMonoidWithOne Nat Nat.instAddMonoidWithOne))
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))))))
      (@Exists Real fun (r1 : Real) =>
        @Exists Real fun (r2 : Real) =>
          And (@Ne Real r1 r2)
            (And
              (@Eq Real (@Polynomial.eval Real Real.semiring r1 p_1)
                (@OfNat.ofNat Real (nat_lit 0) (@Zero.toOfNat0 Real Real.instZero)))
              (@Eq Real (@Polynomial.eval Real Real.semiring r2 p_1)
                (@OfNat.ofNat Real (nat_lit 0) (@Zero.toOfNat0 Real Real.instZero))))))

p ∈ answer ↔
    (∃ r : ℕ → ℝ, (∀ i : Fin (n - 1), r i < r (i + 1)) ∧
    (∀ i : Fin n, p.eval (r i) = 0) ∧
    (∀ i : Fin (n - 1), (Polynomial.derivative p).eval ((r i + r (i + 1)) / 2) = 0))


Does there exist an infinite sequence of closed discs $D_1,D_2,D_3,\dots$ in the plane, with centers $c_1,c_2,c_3,\dots$, respectively, such that
\begin{enumerate}
\item the $c_i$ have no limit point in the finite plane,
\item the sum of the areas of the $D_i$ is finite, and
\item every line in the plane intersects at least one of the $D_i$?
\end{enumerate}

Show that the answer is yes, such a sequence of closed discs exists.

(∃ (c : ℕ → EuclideanSpace ℝ (Fin 2)) (r : ℕ → ℝ),
      (¬ ∃ p, MapClusterPt p atTop c) ∧
      (Summable <| fun i ↦ r i ^ 2) ∧
      (∀ L : AffineSubspace ℝ (EuclideanSpace ℝ (Fin 2)),
        Module.finrank ℝ L.direction = 1 → ∃ i, (↑L ∩ closedBall (c i) (r i)).Nonempty)) ↔
    answer


Find the maximum value of $\int_0^y \sqrt{x^4+(y-y^2)^2}\,dx$ for $0 \leq y \leq 1$.

Show that the maximum value of the integral is $1/3$.

@Eq Real answer
  (@HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid))
    (@OfNat.ofNat Real (nat_lit 1) (@One.toOfNat1 Real Real.instOne))
    (@OfNat.ofNat Real (nat_lit 3)
      (@instOfNatAtLeastTwo Real (nat_lit 3) Real.instNatCast
        (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1)))))))

hf

∀ y : Set.Icc 0 1, f y = ∫ x in Set.Ioo 0 y, Real.sqrt (x ^ 4 + (y - y ^ 2) ^ 2)


For each integer $n \geq 0$, let $S(n)=n-m^2$, where $m$ is the greatest integer with $m^2 \leq n$. Define a sequence $(a_k)_{k=0}^\infty$ by $a_0=A$ and $a_{k+1}=a_k+S(a_k)$ for $k \geq 0$. For what positive integers $A$ is this sequence eventually constant?

the set of positive integers $A$ such that $A$ is a perfect square

Show that this sequence is eventually constant if and only if $A$ is a perfect square.

@Eq (Set Int) answer
  (@setOf Int fun (A_1 : Int) =>
    @Exists Int fun (x : Int) =>
      And (@GT.gt Int Int.instLTInt x (@OfNat.ofNat Int (nat_lit 0) (@instOfNat (nat_lit 0))))
        (@Eq Int A_1
          (@HPow.hPow Int Nat Int (@instHPow Int Nat (@Monoid.toNatPow Int Int.instMonoid)) x
            (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))))

hm

∀ n, 0 ≤ n → (m n) ^ 2 ≤ n ∧ (∀ m' : ℤ, m' ^ 2 ≤ n → m' ≤ m n)

(∃ (K : ℕ) (c : ℕ), ∀ k ≥ K, a k = c) ↔ A ∈ answer


Let $p$ be an odd prime and let $\mathbb{Z}_p$ denote (the field of) integers modulo $p$. How many elements are in the set $\{x^2:x \in \mathbb{Z}_p\} \cap \{y^2+1:y \in \mathbb{Z}_p\}$?

Show that the number of elements in the intersection is $\lceil p/4 \rceil$.

@Eq (Nat → Nat) answer fun (p_1 : Nat) =>
  @Nat.ceil Real Real.orderedSemiring (@FloorRing.toFloorSemiring Real Real.instLinearOrderedRing Real.instFloorRing)
    (@HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid))
      (@Nat.cast Real Real.instNatCast p_1)
      (@OfNat.ofNat Real (nat_lit 4)
        (@instOfNatAtLeastTwo Real (nat_lit 4) Real.instNatCast
          (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))))

({z : ZMod p | ∃ x : ZMod p, z = x ^ 2} ∩ {z : ZMod p | ∃ y : ZMod p, z = y ^ 2 + 1}).encard = answer p


Let $a$ and $b$ be positive numbers. Find the largest number $c$, in terms of $a$ and $b$, such that $a^xb^{1-x} \leq a\frac{\sinh ux}{\sinh u}+b\frac{\sinh u(1-x)}{\sinh u}$ for all $u$ with $0<|u| \leq c$ and for all $x$, $0<x<1$. (Note: $\sinh u=(e^u-e^{-u})/2$.)

Show that the largest $c$ for which the inequality holds for $0<|u| \leq c$ is $c=|\ln(a/b)|$.

@Eq (Real → Real → Real) answer fun (a_1 b_1 : Real) =>
  @abs Real Real.lattice Real.instAddGroup
    (Real.log (@HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid)) a_1 b_1))

IsGreatest {c | ∀ u, (0 < |u| ∧ |u| ≤ c) → (∀ x ∈ Set.Ioo 0 1, a ^ x * b ^ (1 - x) ≤ a * (Real.sinh (u * x) / Real.sinh u) + b * (Real.sinh (u * (1 - x)) / Real.sinh u))} (answer a b)


Define $C(\alpha)$ to be the coefficient of $x^{1992}$ in the power series about $x=0$ of $(1 + x)^\alpha$. Evaluate
\[
\int_0^1 \left( C(-y-1) \sum_{k=1}^{1992} \frac{1}{y+k} \right)\,dy.
\]

Prove that the integral evaluates to $1992$.

@Eq Real answer
  (@OfNat.ofNat Real (nat_lit 1992)
    (@instOfNatAtLeastTwo Real (nat_lit 1992) Real.instNatCast
      (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 1990) (instOfNatNat (nat_lit 1990))))))

hC

C = fun α ↦ taylorCoeffWithin (fun x ↦ (1 + x) ^ α) 1992 Set.univ 0


For a given positive integer $m$, find all triples $(n, x, y)$ of positive integers, with $n$ relatively prime to $m$, which satisfy
\[
(x^2 + y^2)^m = (xy)^n.
\]

Prove that if $m$ is odd, there are no solutions, and if $m$ is even, the only solution is
$(n, x, y) = (m + 1, 2 ^ {m/2}, 2 ^{m/2})$.

@Eq (Nat → Set (Prod Nat (Prod Nat Nat))) answer fun (m_1 : Nat) =>
  @ite (Set (Prod Nat (Prod Nat Nat))) (@Odd Nat Nat.instSemiring m_1) (Nat.instDecidablePredOdd m_1)
    (@EmptyCollection.emptyCollection (Set (Prod Nat (Prod Nat Nat)))
      (@Set.instEmptyCollection (Prod Nat (Prod Nat Nat))))
    (@Singleton.singleton (Prod Nat (Prod Nat Nat)) (Set (Prod Nat (Prod Nat Nat)))
      (@Set.instSingletonSet (Prod Nat (Prod Nat Nat)))
      (@Prod.mk Nat (Prod Nat Nat)
        (@HAdd.hAdd Nat Nat Nat (@instHAdd Nat instAddNat) m_1
          (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1))))
        (@Prod.mk Nat Nat
          (@HPow.hPow Nat Nat Nat (@instHPow Nat Nat (@Monoid.toNatPow Nat Nat.instMonoid))
            (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))
            (@HDiv.hDiv Nat Nat Nat (@instHDiv Nat Nat.instDiv) m_1
              (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
          (@HPow.hPow Nat Nat Nat (@instHPow Nat Nat (@Monoid.toNatPow Nat Nat.instMonoid))
            (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))
            (@HDiv.hDiv Nat Nat Nat (@instHDiv Nat Nat.instDiv) m_1
              (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))))))

ℕ → Set (ℕ × ℕ × ℕ)

S

Set (ℕ × ℕ × ℕ)

hS

∀ n x y : ℕ, (n, x, y) ∈ S ↔ n > 0 ∧ x > 0 ∧ y > 0 ∧ Coprime n m ∧ (x ^ 2 + y ^ 2) ^ m = (x * y) ^ n


Let $f$ be an infinitely differentiable real-valued function defined on the real numbers. If
\[
f\left( \frac{1}{n} \right) = \frac{n^2}{n^2 + 1}, \qquad n = 1, 2, 3, \dots,
\]
compute the values of the derivatives $f^{(k)}(0), k = 1, 2, 3, \dots$.

fun k ↦ ite (Even k) ((-1) ^ (k / 2) * factorial k) 0

Prove that
\[
f^{(k)}(0) =
\begin{cases}
(-1)^{k/2}k! & \text{if $k$ is even;} \\
0 & \text{if $k$ is odd.} \\
\end{cases}
\]

@Eq (Nat → Real) answer fun (k : Nat) =>
  @ite Real (@Even Nat instAddNat k) (Nat.instDecidablePredEven k)
    (@HMul.hMul Real Real Real (@instHMul Real Real.instMul)
      (@HPow.hPow Real Nat Real (@instHPow Real Nat (@Monoid.toNatPow Real Real.instMonoid))
        (@Neg.neg Real Real.instNeg (@OfNat.ofNat Real (nat_lit 1) (@One.toOfNat1 Real Real.instOne)))
        (@HDiv.hDiv Nat Nat Nat (@instHDiv Nat Nat.instDiv) k
          (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
      (@Nat.cast Real Real.instNatCast (Nat.factorial k)))
    (@OfNat.ofNat Real (nat_lit 0) (@Zero.toOfNat0 Real Real.instZero))

∀ k : ℕ, k > 0 → iteratedDeriv k f 0 = answer k


Let $S$ be a set of $n$ distinct real numbers. Let $A_S$ be the set of numbers that occur as averages of two distinct elements of $S$. For a given $n \geq 2$, what is the smallest possible number of elements in $A_S$?

@Eq (Nat → Int) answer fun (n_1 : Nat) =>
  @HSub.hSub Int Int Int (@instHSub Int Int.instSub)
    (@HMul.hMul Int Int Int (@instHMul Int Int.instMul) (@OfNat.ofNat Int (nat_lit 2) (@instOfNat (nat_lit 2)))
      (@Nat.cast Int instNatCastInt n_1))
    (@OfNat.ofNat Int (nat_lit 3) (@instOfNat (nat_lit 3)))

hA

A = fun S ↦ {x | ∃ a ∈ S, ∃ b ∈ S, a ≠ b ∧ (a + b) / 2 = x}

IsLeast {k : ℤ | ∃ S : Finset ℝ, S.card = n ∧ k = (A S).ncard} (answer n)


For any pair $(x,y)$ of real numbers, a sequence $(a_n(x,y))_{n \geq 0}$ is defined as follows:
\begin{align*}
a_0(x,y)&=x, \\
a_{n+1}(x,y)&=\frac{(a_n(x,y))^2+y^2}{2},\text{ for $n \geq 0$.}
\end{align*}
Find the area of the region $\{(x,y) \mid (a_n(x,y))_{n \geq 0}\text{ converges}\}$.

open Topology Filter Nat Function Polynomial

@Eq Real answer
  (@HAdd.hAdd Real Real Real (@instHAdd Real Real.instAdd)
    (@OfNat.ofNat Real (nat_lit 4)
      (@instOfNatAtLeastTwo Real (nat_lit 4) Real.instNatCast
        (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))))
    Real.pi)

answer = (MeasureTheory.volume {p | ∃ L, Tendsto (a p) atTop (𝓝 L)}).toReal


Let $p(x)$ be a nonzero polynomial of degree less than $1992$ having no nonconstant factor in common with $x^3 - x$. Let
\[
\frac{d^{1992}}{dx^{1992}} \left( \frac{p(x)}{x^3 - x} \right) = \frac{f(x)}{g(x)}
\]
for polynomials $f(x)$ and $g(x)$. Find the smallest possible degree of $f(x)$.

@Eq Nat answer (@OfNat.ofNat Nat (nat_lit 3984) (instOfNatNat (nat_lit 3984)))

∀ p, IsValid p ↔ p ≠ 0 ∧ p.degree < 1992 ∧ IsCoprime p (X ^ 3 - X)

hpair

∀ p f, pair p f ↔ ∃ g : Polynomial ℝ, iteratedDeriv 1992 (fun x ↦ p.eval x / (x ^ 3 - x)) = fun x ↦ f.eval x / g.eval x

IsLeast {k : ℕ | ∃ p f, IsValid p ∧ pair p f ∧ k = f.degree} answer


Let $D_n$ denote the value of the $(n-1) \times (n-1)$ determinant
\[
\left[
\begin{array}{cccccc}
3 & 1 & 1 & 1 & \cdots & 1 \\
1 & 4 & 1 & 1 & \cdots & 1 \\
1 & 1 & 5 & 1 & \cdots & 1 \\
1 & 1 & 1 & 6 & \cdots & 1 \\
\vdots & \vdots & \vdots & \vdots & \ddots & \vdots \\
1 & 1 & 1 & 1 & \cdots & n+1
\end{array}
\right].
\]
Is the set $\left\{ \frac{D_n}{n!} \right\}_{n \geq 2}$ bounded?

hD

∀ n, D n = Matrix.det (fun i j : Fin (n - 1) ↦ ite (i = j) ((i : ℕ) + 3 : ℚ) 1)

answer ↔ (Bornology.IsBounded {x | ∃ n ≥ 2, D n / factorial n = x})


The horizontal line $y=c$ intersects the curve $y=2x-3x^3$ in the first quadrant as in the figure. Find $c$ so that the areas of the two shaded regions are equal. [Figure not included. The first region is bounded by the $y$-axis, the line $y=c$ and the curve; the other lies under the curve and above the line $y=c$ between their two points of intersection.]

Show that the area of the two regions are equal when $c=4/9$.

@Eq Real answer
  (@HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid))
    (@OfNat.ofNat Real (nat_lit 4)
      (@instOfNatAtLeastTwo Real (nat_lit 4) Real.instNatCast
        (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))))
    (@OfNat.ofNat Real (nat_lit 9)
      (@instOfNatAtLeastTwo Real (nat_lit 9) Real.instNatCast
        (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 7) (instOfNatNat (nat_lit 7)))))))

0 < answer ∧ answer < (4 * Real.sqrt 2) / 9 ∧
    (∫ x in Set.Ioo 0 ((Real.sqrt 2) / 3), max (answer - (2 * x - 3 * x ^ 3)) 0) =
    (∫ x in Set.Ioo 0 ((Real.sqrt 6) / 3), max ((2 * x - 3 * x ^ 3) - answer) 0)


Find the smallest positive integer $n$ such that for every integer $m$ with $0<m<1993$, there exists an integer $k$ for which $\frac{m}{1993}<\frac{k}{n}<\frac{m+1}{1994}$.

Show that the smallest positive integer $n$ satisfying the condition is $n=3987$.

@Eq Nat answer (@OfNat.ofNat Nat (nat_lit 3987) (instOfNatNat (nat_lit 3987)))


Two real numbers $x$ and $y$ are chosen at random in the interval $(0,1)$ with respect to the uniform distribution. What is the probability that the closest integer to $x/y$ is even? Express the answer in the form $r+s\pi$, where $r$ and $s$ are rational numbers.

Show that the limit is $(5-\pi)/4$. That is, $r=5/4$ and $s=-1/4$.

@Eq (Prod Rat Rat) answer
  (@Prod.mk Rat Rat
    (@HDiv.hDiv Rat Rat Rat (@instHDiv Rat Rat.instDiv) (@OfNat.ofNat Rat (nat_lit 5) (@Rat.instOfNat (nat_lit 5)))
      (@OfNat.ofNat Rat (nat_lit 4) (@Rat.instOfNat (nat_lit 4))))
    (@HDiv.hDiv Rat Rat Rat (@instHDiv Rat Rat.instDiv)
      (@Neg.neg Rat Rat.instNeg (@OfNat.ofNat Rat (nat_lit 1) (@Rat.instOfNat (nat_lit 1))))
      (@OfNat.ofNat Rat (nat_lit 4) (@Rat.instOfNat (nat_lit 4)))))

(MeasureTheory.volume
    {p : Fin 2 → ℝ | 0 < p 0 ∧ p 0 < 1 ∧ 0 < p 1 ∧ p 1 < 1 ∧ Even (round (p 0 / p 1))}
  ).toReal = answer.1 + answer.2 * Real.pi


Find all positive integers $n$ that are within $250$ of exactly $15$ perfect squares.

the set of integers $n$ such that $315 \leq n \leq 325$ or $332 \leq n \leq 350$

Show that an integer $n$ is within $250$ of exactly $15$ perfect squares if and only if either $315 \leq n \leq 325$ or $332 \leq n \leq 350$.

@Eq (Set Int) answer
  (@setOf Int fun (n_1 : Int) =>
    Or
      (And (@LE.le Int Int.instLEInt (@OfNat.ofNat Int (nat_lit 315) (@instOfNat (nat_lit 315))) n_1)
        (@LE.le Int Int.instLEInt n_1 (@OfNat.ofNat Int (nat_lit 325) (@instOfNat (nat_lit 325)))))
      (And (@LE.le Int Int.instLEInt (@OfNat.ofNat Int (nat_lit 332) (@instOfNat (nat_lit 332))) n_1)
        (@LE.le Int Int.instLEInt n_1 (@OfNat.ofNat Int (nat_lit 350) (@instOfNat (nat_lit 350))))))

n ∈ answer ↔ (0 < n ∧ {m : ℕ | |n - m ^ 2| ≤ 250}.encard = 15)


For which real numbers $c$ is there a straight line that intersects the curve $x^4+9x^3+cx^2+9x+4$ in four distinct points?

Show that there exists such a line if and only if $c<243/8$.

@Eq (Set Real) answer
  (@setOf Real fun (c_1 : Real) =>
    @LT.lt Real Real.instLT c_1
      (@HDiv.hDiv Real Real Real (@instHDiv Real (@DivInvMonoid.toDiv Real Real.instDivInvMonoid))
        (@OfNat.ofNat Real (nat_lit 243)
          (@instOfNatAtLeastTwo Real (nat_lit 243) Real.instNatCast
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 241) (instOfNatNat (nat_lit 241))))))
        (@OfNat.ofNat Real (nat_lit 8)
          (@instOfNatAtLeastTwo Real (nat_lit 8) Real.instNatCast
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 6) (instOfNatNat (nat_lit 6))))))))


Find the set of all real numbers $k$ with the following property: For any positive, differentiable function $f$ that satisfies $f'(x)>f(x)$ for all $x$, there is some number $N$ such that $f(x)>e^{kx}$ for all $x>N$.

Show that the desired set is $(-\infty,1)$.

@Eq (Set Real) answer
  (@Set.Iio Real Real.instPreorder (@OfNat.ofNat Real (nat_lit 1) (@One.toOfNat1 Real Real.instOne)))

{k | ∀ f (hf : (∀ x, 0 < f x ∧ f x < deriv f x) ∧ Differentiable ℝ f),
      ∃ N, ∀ x > N, Real.exp (k * x) < f x} = answer


For what pairs $(a,b)$ of positive real numbers does the improper integral \[ \int_{b}^{\infty} \left( \sqrt{\sqrt{x+a}-\sqrt{x}} - \sqrt{\sqrt{x}-\sqrt{x-b}} \right)\,dx \] converge?

Show that the solution is those pairs $(a,b)$ where $a = b$.

@Eq (Set (Prod Real Real)) answer
  (@setOf (Prod Real Real) fun (x : Prod Real Real) =>
    _example.match_1 (fun (x_1 : Prod Real Real) => Prop) x fun (a b : Real) => @Eq Real a b)

habconv = fun ⟨a,b⟩ => ∃ limit : ℝ, Tendsto (fun t : ℝ => ∫ x in (Set.Icc b t), (sqrt (sqrt (x + a) - sqrt x) - sqrt (sqrt x - sqrt (x - b)))) atTop (𝓝 limit)

∀ ab : ℝ × ℝ, ab.1 > 0 ∧ ab.2 > 0 → (habconv ab ↔ ab ∈ answer)


Let $x_{1},x_{2},\dots,x_{n}$ be differentiable (real-valued) functions of a single variable $f$ which satisfy \begin{align*} \frac{dx_{1}}{dt} &= a_{11}x_{1} + a_{12}x_{2} + \cdots + a_{1n}x_{n} \ \frac{dx_{2}}{dt} &= a_{21}x_{1} + a_{22}x_{2} + \cdots + a_{2n}x_{n} \ \vdots && \vdots \ \frac{dx_{n}}{dt} &= a_{n1}x_{1} + a_{n2}x_{2} + \cdots + a_{nn}x_{n} \end{align*} for some constants $a_{ij}>0$. Suppose that for all $i$, $x_{i}(t) \to 0$ as $t \to \infty$. Are the functions $x_{1},x_{2},\dots,x_{n}$ necessarily linearly dependent?

Show that the answer is yes, the functions must be linearly dependent.

hsys

∀ t i, (deriv (x i)) t = ∑ j : Fin n, (a i j) * ((x j) t)

answer ↔ ¬(∀ b : Fin n → ℝ, (∀ t : ℝ, ∑ i : Fin n, (b i) * ((x i) t) = 0) → (∀ i, b i = 0))


To each positive integer with $n^{2}$ decimal digits, we associate the determinant of the matrix obtained by writing the digits in order across the rows. For example, for $n=2$, to the integer 8617 we associate $\det \left( \begin{array}{cc} 8 & 6 \ 1 & 7 \end{array} \right) = 50$. Find, as a function of $n$, the sum of all the determinants associated with $n^{2}$-digit integers. (Leading digits are assumed to be nonzero; for example, for $n=2$, there are 9000 determinants.)

45 if n = 1, 10 * 45² if n = 2, and 0 otherwise

Show that the solution is $45$ if $n = 1$, $45^2*10$ if $n = 2$, and $0$ if $n$ is greater than 2.

@Eq (Nat → Int) answer fun (n_1 : Nat) =>
  @ite Int (@Eq Nat n_1 (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1))))
    (instDecidableEqNat n_1 (@OfNat.ofNat Nat (nat_lit 1) (instOfNatNat (nat_lit 1))))
    (@OfNat.ofNat Int (nat_lit 45) (@instOfNat (nat_lit 45)))
    (@ite Int (@Eq Nat n_1 (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
      (instDecidableEqNat n_1 (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
      (@HMul.hMul Int Int Int (@instHMul Int Int.instMul) (@OfNat.ofNat Int (nat_lit 10) (@instOfNat (nat_lit 10)))
        (@HPow.hPow Int Nat Int (@instHPow Int Nat (@Monoid.toNatPow Int Int.instMonoid))
          (@OfNat.ofNat Int (nat_lit 45) (@instOfNat (nat_lit 45)))
          (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
      (@OfNat.ofNat Int (nat_lit 0) (@instOfNat (nat_lit 0))))

digits_set = {f | f 0 ≠ 0 ∧ (∀ i : Fin (n ^ 2), f i ≤ 9) ∧ (∀ i ≥ n ^ 2, f i = 0)}

digits_to_matrix = fun f => (fun i j => f (i.1 * n + j.1))

∑' f : digits_set, (digits_to_matrix f).det = answer n


Evaluate \[ \sqrt[8]{2207 - \frac{1}{2207-\frac{1}{2207-\dots}}}. \] Express your answer in the form $\frac{a+b\sqrt{c}}{d}$, where $a,b,c,d$ are integers.

Show that the solution is $(3 + 1*\sqrt{5})/2.

@Eq (Prod Int (Prod Int (Prod Int Int))) answer
  (@Prod.mk Int (Prod Int (Prod Int Int)) (@OfNat.ofNat Int (nat_lit 3) (@instOfNat (nat_lit 3)))
    (@Prod.mk Int (Prod Int Int) (@OfNat.ofNat Int (nat_lit 1) (@instOfNat (nat_lit 1)))
      (@Prod.mk Int Int (@OfNat.ofNat Int (nat_lit 5) (@instOfNat (nat_lit 5)))
        (@OfNat.ofNat Int (nat_lit 2) (@instOfNat (nat_lit 2))))))

ℤ × ℤ × ℤ × ℤ

let ⟨a, b, c, d⟩ := answer;
    contfrac ^ ((1 : ℝ) / 8) = (a + b * sqrt c) / d


Let $C_1$ and $C_2$ be circles whose centers are $10$ units apart, and whose radii are $1$ and $3$. Find, with proof, the locus of all points $M$ for which there exist points $X$ on $C_1$ and $Y$ on $C_2$ such that $M$ is the midpoint of the line segment $XY$.

the set of points $p$ such that the distance from $p$ to the midpoint of $O_1$ and $O_2$ is between 1 and 2

Let $O_1$ and $O_2$ be the centers of $C_1$ and $C_2$, respectively. Then show that the desired locus is an annulus centered at the midpoint $O$ of $O_1O_2$, with inner radius $1$ and outer radius $2$.

@Eq
  (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) →
    EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) →
      Set (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))))
  answer fun (O1_1 O2_1 : EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) =>
  @setOf (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
    fun (p : EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) =>
    And
      (@GE.ge Real Real.instLE
        (@Dist.dist (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
          (@PiLp.instDist
            (@OfNat.ofNat ENNReal (nat_lit 2)
              (@instOfNatAtLeastTwo ENNReal (nat_lit 2)
                (@AddMonoidWithOne.toNatCast ENNReal
                  (@AddCommMonoidWithOne.toAddMonoidWithOne ENNReal instENNRealAddCommMonoidWithOne))
                EuclideanSpace.proof_1))
            (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
            (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real)
            (Fin.fintype (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
            fun (i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) =>
            @PseudoMetricSpace.toDist Real Real.pseudoMetricSpace)
          p
          (@midpoint Real (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
            (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) Real.instRing
            (@invertibleTwo Real Real.instDivisionRing (@RCLike.charZero_rclike Real Real.instRCLike))
            (@WithLp.instAddCommGroup
              (@OfNat.ofNat ENNReal (nat_lit 2)
                (@instOfNatAtLeastTwo ENNReal (nat_lit 2)
                  (@AddMonoidWithOne.toNatCast ENNReal
                    (@AddCommMonoidWithOne.toAddMonoidWithOne ENNReal instENNRealAddCommMonoidWithOne))
                  EuclideanSpace.proof_1))
              ((i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) →
                (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real) i)
              (@Pi.addCommGroup (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real)
                fun (i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real.instAddCommGroup))
            (@WithLp.instModule
              (@OfNat.ofNat ENNReal (nat_lit 2)
                (@instOfNatAtLeastTwo ENNReal (nat_lit 2)
                  (@AddMonoidWithOne.toNatCast ENNReal
                    (@AddCommMonoidWithOne.toAddMonoidWithOne ENNReal instENNRealAddCommMonoidWithOne))
                  EuclideanSpace.proof_1))
              Real
              ((i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) →
                (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real) i)
              (@Ring.toSemiring Real Real.instRing)
              (@Pi.addCommGroup (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real)
                fun (i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real.instAddCommGroup)
              (@Pi.Function.module (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) Real Real
                (@Ring.toSemiring Real Real.instRing)
                (@NonUnitalNonAssocSemiring.toAddCommMonoid Real
                  (@NonUnitalSemiring.toNonUnitalNonAssocSemiring Real
                    (@Semiring.toNonUnitalSemiring Real (@Ring.toSemiring Real Real.instRing))))
                (@NormedSpace.toModule Real Real Real.normedField
                  (@NonUnitalSeminormedRing.toSeminormedAddCommGroup Real
                    (@NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing Real
                      (@SeminormedCommRing.toNonUnitalSeminormedCommRing Real
                        (@NormedCommRing.toSeminormedCommRing Real Real.normedCommRing))))
                  (@InnerProductSpace.toNormedSpace Real Real Real.instRCLike
                    (@NonUnitalSeminormedRing.toSeminormedAddCommGroup Real
                      (@NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing Real
                        (@SeminormedCommRing.toNonUnitalSeminormedCommRing Real
                          (@NormedCommRing.toSeminormedCommRing Real Real.normedCommRing))))
                    (@RCLike.toInnerProductSpaceReal Real Real.instRCLike)))))
            (@NormedAddTorsor.toAddTorsor
              (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
              (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
              (@PiLp.seminormedAddCommGroup
                (@OfNat.ofNat ENNReal (nat_lit 2)
                  (@instOfNatAtLeastTwo ENNReal (nat_lit 2)
                    (@AddMonoidWithOne.toNatCast ENNReal
                      (@AddCommMonoidWithOne.toAddMonoidWithOne ENNReal instENNRealAddCommMonoidWithOne))
                    EuclideanSpace.proof_1))
                (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real)
                fact_one_le_two_ennreal (Fin.fintype (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                fun (i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) =>
                @NonUnitalSeminormedRing.toSeminormedAddCommGroup Real
                  (@NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing Real
                    (@SeminormedCommRing.toNonUnitalSeminormedCommRing Real
                      (@NormedCommRing.toSeminormedCommRing Real Real.normedCommRing))))
              (@SeminormedAddCommGroup.toPseudoMetricSpace
                (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
                (@PiLp.seminormedAddCommGroup
                  (@OfNat.ofNat ENNReal (nat_lit 2)
                    (@instOfNatAtLeastTwo ENNReal (nat_lit 2)
                      (@AddMonoidWithOne.toNatCast ENNReal
                        (@AddCommMonoidWithOne.toAddMonoidWithOne ENNReal instENNRealAddCommMonoidWithOne))
                      EuclideanSpace.proof_1))
                  (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                  (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real)
                  fact_one_le_two_ennreal (Fin.fintype (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                  fun (i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) =>
                  @NonUnitalSeminormedRing.toSeminormedAddCommGroup Real
                    (@NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing Real
                      (@SeminormedCommRing.toNonUnitalSeminormedCommRing Real
                        (@NormedCommRing.toSeminormedCommRing Real Real.normedCommRing)))))
              (@SeminormedAddCommGroup.toNormedAddTorsor
                (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
                (@PiLp.seminormedAddCommGroup
                  (@OfNat.ofNat ENNReal (nat_lit 2)
                    (@instOfNatAtLeastTwo ENNReal (nat_lit 2)
                      (@AddMonoidWithOne.toNatCast ENNReal
                        (@AddCommMonoidWithOne.toAddMonoidWithOne ENNReal instENNRealAddCommMonoidWithOne))
                      EuclideanSpace.proof_1))
                  (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                  (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real)
                  fact_one_le_two_ennreal (Fin.fintype (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                  fun (i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) =>
                  @NonUnitalSeminormedRing.toSeminormedAddCommGroup Real
                    (@NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing Real
                      (@SeminormedCommRing.toNonUnitalSeminormedCommRing Real
                        (@NormedCommRing.toSeminormedCommRing Real Real.normedCommRing))))))
            O1_1 O2_1))
        (@OfNat.ofNat Real (nat_lit 1) (@One.toOfNat1 Real Real.instOne)))
      (@LE.le Real Real.instLE
        (@Dist.dist (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
          (@PiLp.instDist
            (@OfNat.ofNat ENNReal (nat_lit 2)
              (@instOfNatAtLeastTwo ENNReal (nat_lit 2)
                (@AddMonoidWithOne.toNatCast ENNReal
                  (@AddCommMonoidWithOne.toAddMonoidWithOne ENNReal instENNRealAddCommMonoidWithOne))
                EuclideanSpace.proof_1))
            (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
            (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real)
            (Fin.fintype (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
            fun (i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) =>
            @PseudoMetricSpace.toDist Real Real.pseudoMetricSpace)
          p
          (@midpoint Real (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
            (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))) Real.instRing
            (@invertibleTwo Real Real.instDivisionRing (@RCLike.charZero_rclike Real Real.instRCLike))
            (@WithLp.instAddCommGroup
              (@OfNat.ofNat ENNReal (nat_lit 2)
                (@instOfNatAtLeastTwo ENNReal (nat_lit 2)
                  (@AddMonoidWithOne.toNatCast ENNReal
                    (@AddCommMonoidWithOne.toAddMonoidWithOne ENNReal instENNRealAddCommMonoidWithOne))
                  EuclideanSpace.proof_1))
              ((i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) →
                (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real) i)
              (@Pi.addCommGroup (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real)
                fun (i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real.instAddCommGroup))
            (@WithLp.instModule
              (@OfNat.ofNat ENNReal (nat_lit 2)
                (@instOfNatAtLeastTwo ENNReal (nat_lit 2)
                  (@AddMonoidWithOne.toNatCast ENNReal
                    (@AddCommMonoidWithOne.toAddMonoidWithOne ENNReal instENNRealAddCommMonoidWithOne))
                  EuclideanSpace.proof_1))
              Real
              ((i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) →
                (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real) i)
              (@Ring.toSemiring Real Real.instRing)
              (@Pi.addCommGroup (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real)
                fun (i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real.instAddCommGroup)
              (@Pi.Function.module (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) Real Real
                (@Ring.toSemiring Real Real.instRing)
                (@NonUnitalNonAssocSemiring.toAddCommMonoid Real
                  (@NonUnitalSemiring.toNonUnitalNonAssocSemiring Real
                    (@Semiring.toNonUnitalSemiring Real (@Ring.toSemiring Real Real.instRing))))
                (@NormedSpace.toModule Real Real Real.normedField
                  (@NonUnitalSeminormedRing.toSeminormedAddCommGroup Real
                    (@NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing Real
                      (@SeminormedCommRing.toNonUnitalSeminormedCommRing Real
                        (@NormedCommRing.toSeminormedCommRing Real Real.normedCommRing))))
                  (@InnerProductSpace.toNormedSpace Real Real Real.instRCLike
                    (@NonUnitalSeminormedRing.toSeminormedAddCommGroup Real
                      (@NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing Real
                        (@SeminormedCommRing.toNonUnitalSeminormedCommRing Real
                          (@NormedCommRing.toSeminormedCommRing Real Real.normedCommRing))))
                    (@RCLike.toInnerProductSpaceReal Real Real.instRCLike)))))
            (@NormedAddTorsor.toAddTorsor
              (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
              (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
              (@PiLp.seminormedAddCommGroup
                (@OfNat.ofNat ENNReal (nat_lit 2)
                  (@instOfNatAtLeastTwo ENNReal (nat_lit 2)
                    (@AddMonoidWithOne.toNatCast ENNReal
                      (@AddCommMonoidWithOne.toAddMonoidWithOne ENNReal instENNRealAddCommMonoidWithOne))
                    EuclideanSpace.proof_1))
                (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real)
                fact_one_le_two_ennreal (Fin.fintype (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                fun (i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) =>
                @NonUnitalSeminormedRing.toSeminormedAddCommGroup Real
                  (@NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing Real
                    (@SeminormedCommRing.toNonUnitalSeminormedCommRing Real
                      (@NormedCommRing.toSeminormedCommRing Real Real.normedCommRing))))
              (@SeminormedAddCommGroup.toPseudoMetricSpace
                (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
                (@PiLp.seminormedAddCommGroup
                  (@OfNat.ofNat ENNReal (nat_lit 2)
                    (@instOfNatAtLeastTwo ENNReal (nat_lit 2)
                      (@AddMonoidWithOne.toNatCast ENNReal
                        (@AddCommMonoidWithOne.toAddMonoidWithOne ENNReal instENNRealAddCommMonoidWithOne))
                      EuclideanSpace.proof_1))
                  (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                  (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real)
                  fact_one_le_two_ennreal (Fin.fintype (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                  fun (i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) =>
                  @NonUnitalSeminormedRing.toSeminormedAddCommGroup Real
                    (@NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing Real
                      (@SeminormedCommRing.toNonUnitalSeminormedCommRing Real
                        (@NormedCommRing.toSeminormedCommRing Real Real.normedCommRing)))))
              (@SeminormedAddCommGroup.toNormedAddTorsor
                (EuclideanSpace Real (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))))
                (@PiLp.seminormedAddCommGroup
                  (@OfNat.ofNat ENNReal (nat_lit 2)
                    (@instOfNatAtLeastTwo ENNReal (nat_lit 2)
                      (@AddMonoidWithOne.toNatCast ENNReal
                        (@AddCommMonoidWithOne.toAddMonoidWithOne ENNReal instENNRealAddCommMonoidWithOne))
                      EuclideanSpace.proof_1))
                  (Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                  (fun (x : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) => Real)
                  fact_one_le_two_ennreal (Fin.fintype (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2))))
                  fun (i : Fin (@OfNat.ofNat Nat (nat_lit 2) (instOfNatNat (nat_lit 2)))) =>
                  @NonUnitalSeminormedRing.toSeminormedAddCommGroup Real
                    (@NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing Real
                      (@SeminormedCommRing.toNonUnitalSeminormedCommRing Real
                        (@NormedCommRing.toSeminormedCommRing Real Real.normedCommRing))))))
            O1_1 O2_1))
        (@OfNat.ofNat Real (nat_lit 2)
          (@instOfNatAtLeastTwo Real (nat_lit 2) Real.instNatCast
            (@instNatAtLeastTwo (@OfNat.ofNat Nat (nat_lit 0) (instOfNatNat (nat_lit 0)))))))

(EuclideanSpace ℝ (Fin 2)) → (EuclideanSpace ℝ (Fin 2)) → Set (EuclideanSpace ℝ (Fin 2))

{M : EuclideanSpace ℝ (Fin 2) | ∃ X Y, X ∈ C1 ∧ Y ∈ C2 ∧ M = midpoint ℝ X Y} = answer O1 O2