Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Add Lean3 #773

@DonaldKellett

Description

@DonaldKellett

Lean is a theorem prover based on the Calculus of Constructions. It is similar in nature to Coq. The current official stable release from Microsoft is 3.4.2, but it has been recommended to support v3.5.c instead which is a community-supported version.

N.B. Lean is currently in active development and Lean4 is expected to be out in about a year or so, though there is no official statement on the exact release date of Lean4. Since Lean4 is expected to break backward compatibility with Lean3, it has been suggested that Lean3 and Lean4 should be treated as two separate languages. This issue ticket deals with adding Lean3 support; please open a new issue ticket if you would like to request Lean4 support.

Installation

https://github.com/leanprover-community/lean/releases/tag/v3.5.1

N.B. mathlib for Lean (similar to mathcomp in Coq?) is also practically required in order to prove trivial identities such as 100 * 100 = 10000 within a reasonable amount of effort (thanks @monadius for bringing this to my attention!).

Compiling Proof Scripts

For standalone files

Suppose your proof script is Solution.lean. Then just execute the following:

$ lean Solution.lean

For multiple files (Preloaded, Solution, SolutionTest)

Initial Setup

$ leanpkg new kata
$ cd kata
$ leanpkg add leanprover-community/mathlib # Practically required; see above
$ leanpkg configure # Maybe we don't need this as this might already be done by the command above
$ update-mathlib # Download olean files from cloud to save mathlib compilation time (~30 mins!)
$ cd src

Then add .lean files (in the src/ subdirectory) as required, e.g. Preloaded.lean, Solution.lean, SolutionTest.lean

Compiling the Kata

Suppose we have two files: Solution.lean and SolutionTest.lean.

-- Solution.lean

lemma my_add_comm (m n : ℕ) : m + n = n + m :=
by simp
-- SolutionTest.lean

import Solution

#print axioms my_add_comm

Then just run lean SolutionTest.lean.

Testing Frameworks

None that I know of. But Lean has #print axioms (like Print Assumptions in Coq) so we could perhaps preprocess the output generated until we have a proper test framework available. The output of #print axioms in Lean also looks much cleaner and more regular than in Coq. E.g.

lemma trivial (n m : ℕ) : n + m = n + m :=
begin
  refl,
end

#print axioms trivial

outputs no axioms and

lemma my_add_comm (n m : ℕ) : n + m = m + n :=
begin
  simp,
end

#print axioms my_add_comm

outputs propext. Using sorry as in the following (similar to admit/Admitted in Coq):

lemma my_add_comm (n m : ℕ) : n + m = m + n :=
begin
  sorry,
end

#print axioms my_add_comm

outputs:

[sorry]
no axioms

Progress

  • Install Lean v3.5.1
    • Add leanprover/mathlib
  • Figure out how to support testing
  • Implement test support
  • Icon
  • CodeMirror mode (use Agda mode for now)

👍 reaction might help.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions