Lean 4 · Problems

Solve problems. Lean checks every step.

Programs, proofs and verified code, judged by the Lean compiler: programs run against hidden tests, and proofs are accepted only when Lean checks every step. Core library only, no Mathlib.

Study paths

Start here5 problems

Five short problems: a program, a proof, a definition to unfold, a string, and a first verified function.

Proofs about programs6 problems

Unfold, simplify, split on cases and finish the arithmetic: the tools of the Academy course of the same name.

Logic and quantifiers7 problems

From swapping a conjunction to Cantor’s diagonal argument, including the classical steps.

Verified programs8 problems

No tests, only specifications: write the function and prove it correct for every input.

Induction6 problems

Sums, powers and lists, then strong induction for prime factors.

Classic algorithms10 problems

The interview classics in Lean, with hidden tests sized so that slow solutions run out of time.

Read every problem without an account. Create a free account to run solutions, track what you have solved and join the leaderboard. Easy problems, the daily problem and one Medium a week are free, and the Academy Pass opens the rest.

StatusKind
Not started1. Fizz BuzzstringsarithmeticProgram—Easy
Not started2. Swap a conjunctionlogicconjunctionProof—Easy
Not started3. PalindromestringslistsProgram—Easy
Not started4. Two sumPasslistsarrayssearchProgram—Medium
Not started5. ContrapositivelogicnegationProof—Easy
Not started6. Climbing stairsrecursionperformanceProgram—Easy
Not started7. Valid parenthesesPassstringsstacksrecursionProgram—Medium
Not started8. Gauss’s sumPassinductionarithmeticProof—Medium
Not started9. Count the evenslistshigher-order functionsProgram—Easy
Not started10. An even number above nquantifiersarithmeticomegaProof—Easy
Not started11. Maximum subarrayPasslistsdynamic programmingfoldsProgram—Medium
Not started12. Verified maximumPasslistsspecificationsinductionVerified program—Medium
Not started13. Digit sumrecursionterminationarithmeticProgram—Easy
Not started14. Classical De MorganPasslogicclassicalProof—Medium
Not started15. Fast Fibonacci is correctPassinductionprogram correctnessProof—Hard
Not started16. Run-length encodingPassstringslistsrecursionProgram—Medium
Not started17. Sum of odd numbersPassinductionarithmeticProof—Medium
Not started18. Reversing twicePasslistsinductiongeneralizationVerified program—Hard
Not started19. Insertion sort sortsPasssortinginductive predicatesinductionVerified program—Hard
Not started20. Single numberbit manipulationfoldsProgram—Easy
Not started21. Roman to integerstringspattern matchingProgram—Easy
Not started22. Coin changePassdynamic programmingarraysperformanceProgram—Medium
Not started23. Sum over an appendinductionlistsProof—Easy
Not started24. Best time to buy and selllistsfoldsperformanceProgram—Easy
Not started25. N-QueensPassbacktrackingrecursionProgram—Hard
Not started26. Merge two sorted listslistsrecursionsortingProgram—Easy
Not started27. Divisibility is transitivedivisibilityexistentialsProof—Easy
Not started28. Longest substring without repeatsPassstringssliding windowProgram—Medium
Not started29. No witness means neverPassquantifierslogicProof—Medium
Not started30. Edit distancePassdynamic programmingstringsperformanceProgram—Hard
Not started31. Powers of two grow fastPassinductionarithmeticProof—Medium
Not started32. Valid anagramstringssortingProgram—Easy
Not started33. Cantor’s diagonal argumentPasslogicsetsclassic theoremsProof—Medium
Not started34. Binary searcharrayssearchperformanceProgram—Easy
Not started35. Merge intervalsPasssortinglistsperformanceProgram—Medium
Not started36. Verified membership testlistsspecificationsinductionVerified program—Easy
Not started37. Longest common prefixstringsfoldsProgram—Easy
Not started38. Number of islandsPassgridsgraph searcharraysProgram—Medium
Not started39. The drinker paradoxPasslogicquantifiersclassical logicProof—Medium
Not started40. Longest increasing subsequencePassdynamic programminglistsarraysProgram—Medium
Not started41. Trapping rain waterPasslistsprefix scansperformanceProgram—Hard
Not started42. Infinitely many primesChallengePassnumber theorystrong inductionclassic theoremsProof—Hard
Not started43. Every number has a prime factorPassnumber theorystrong inductionProof—Hard
Not started44. The square root of 2 is irrationalChallengePassnumber theorystrong inductionclassic theoremsProof—Hard
Not started45. Insertion sort is correctChallengePasssortinginductive predicatespermutationsVerified program—Hard
Not started46. Doubling gives an even numberarithmeticunfoldomegaProof—Easy
Not started47. Clamp never goes below the boundconditionalsunfoldomegaProof—Easy
Not started48. What comes before redcasescontradictioninductive typesProof—Easy
Not started49. A nonempty list has a first elementlistsoptioncasesProof—Easy
Not started50. Verified maximum of two numbersspecificationsconditionalsomegaVerified program—Easy
Not started51. Verified distance between numbersspecificationsconditionalstruncated subtractionVerified program—Easy
Not started52. Missing numberlistsarithmeticfoldsProgram—Easy
Not started53. Reverse the wordsstringslistsProgram—Easy
Not started54. Verified count of occurrencesPasslistsspecificationsinductionVerified program—Medium
Not started55. Majority elementPasslistsfoldsperformanceProgram—Medium

Proof

The statement is fixed and you write the proof. The judge accepts it only when Lean closes every goal without sorry or extra axioms.

Program

Write a function in Lean. Run it against the examples and your own inputs, then submit it against hidden tests, some sized so that slow algorithms run out of time.

Verified program

There are no tests: you prove that the code meets a specification, so it is correct for every input, not just the ones someone thought of.