Lean 4 fork for HoTT-compatible kernel extensions (Path types, transport, HITs). Maintained against upstream leanprover/lean4.
Find a file
Leonardo de Moura 04fbbbb0d6 refactor(library/init/lean/declaration): declaration -> constant_info
This is the first step in the declaration vs constant_info refactor.
Here is the design notes:

In Lean3, we use the `declaration` objects to represent new declarations
that are sent to the kernel, and to store information for all constants
declared in an environment.
This design decision was done when we did not have support for
mutual (meta) declarations, and information about inductive datatypes,
constructors and recursors were stored in an environment extension.
This design now seems weird since we have four different methods for
adding declarations into the environment:
```
    environment add(certified_declaration const & d) const;
    environment add_meta(buffer<declaration> const & ds, bool check = true) const;
    environment add(inductive_decl const & decl) const;
    environment add_quot() const;
```
Moreover, we use `mk_constant_assumption` to represent inductive
datatype, constructors, recursors, and `quot` primitives.
Since inductive datatypes, constructors, recursors and `quot` primitives
are not considered axioms, we have the method:
```
    bool environment::is_builtin(name const & n) const;
```

We can avoid these hacks by having a type for representing
declarations (i.e., objects that are sent to the kernel) and
objects for storing information of the constant declarations stored
in an environment object.

A `declaration` object is now of the form
```
inductive declaration
| defn_decl        (val : definition_val)
| axiom_decl       (val : axiom_val)
| thm_decl         (val : theorem_val)
| quot_decl
| mutual_defn_decl (defns : list definition_val) -- All definitions must be marked as `meta`
| induct_decl      (lparams : list name) (nparams : nat) (types : list inductive_type) (is_meta : bool)

/-
If we want, we can let users specify their own names for `quot`,
`quot.mk`, `quot.lift` and `quot.ind`. We just need to add them
as fields of `declaration.quot_decl`.
-/
```

When we check a declaration, one or more `constant_info` objects are
created for each new constant in the declaration.
```
inductive constant_info
| assump_info   (val : assumption_val)
| defn_info     (val : definition_val)
| axiom_info    (val : axiom_val)
| thm_info      (val : theorem_val)
| quot_info     (val : quot_val)
| induct_info   (val : inductive_val)
| cnstr_info    (val : constructor_val)
| rec_info      (val : recursor_val)
```
For simple declarations `constant` (aka `assumption`), `definition`,
`theorem` and `axiom`, the information stored in the `constant_info` is
identical to the information in the `declaration` object. This is
expected since these are the original Lean3 declarations.

The `environment` object stores a mapping from `name` to
`constant_info`. The function `check` validates a declaration
and produces a `certified_declaration`. A `certified_declaration` is
a pair `(declaration, list constant_info)`. The `list` here makes it
explicit that a declaration may add one or more new constants into the
environment. Finally, the `environment` object has a single `add`
method and a single `get` and `find`:
```
    environment add(certified_declaration const & d) const;

    /** \brief Return info for the constant with name \c n (if it is defined in this environment). */
    optional<constant_info> find(name const & n) const;

    /** \brief Return info for the constant with name \c n. Throws an
        exception if has not been declared in this environment. */
    constant_info get(name const & n) const;
```

Moreover, the method `environment::builtin` is not necessary anymore.
If `environment::get(n)` returns an `axiom_info` or an `assump_info`, then
we know for sure the constant named `n` has been postulated.

This commit only defined the new types in Lean. I still need to make
the changes to the C++ code base.
2018-08-21 09:59:30 -07:00
.github chore(.github/CONTRIBUTING): fix typos and URLs 2017-10-30 16:23:22 +01:00
bin chore(bin/lean-gdb.py): fix lean::name pretty printer and add lean::obj_list pretty printer 2018-06-06 15:36:28 +02:00
doc doc(doc/coding_style,doc/commit_convention): fix git hook commands 2018-07-05 10:20:25 +02:00
extras/latex chore(extras/depgraph): remove leandeps 2017-07-15 02:27:17 -07:00
gen chore(*): fix style 2018-08-21 09:32:01 -07:00
images chore(CMakeLists.txt): move Lean logo to make sure we can test leanemacs without installing Lean 2015-01-31 17:38:49 -08:00
leanpkg chore(leanpkg): delete 2018-04-10 12:43:17 -07:00
library refactor(library/init/lean/declaration): declaration -> constant_info 2018-08-21 09:59:30 -07:00
old_tests/tests chore(library/init/io): rename io.print_ln to io.println 2018-08-21 08:43:10 -07:00
packages chore(script/test_registry): Replace with leanpkg. Execute in every artifact-producing build configuration. 2017-12-20 14:01:45 -08:00
script refactor(library/system/io): move into init 2018-08-21 08:43:09 -07:00
src refactor(library/init/lean/declaration): declaration -> constant_info 2018-08-21 09:59:30 -07:00
tests chore(library/init/io): rename io.print_ln to io.println 2018-08-21 08:43:10 -07:00
tmp chore(tmp/lean4.md): moved to google docs 2018-03-20 17:26:43 -07:00
.appveyor.yml chore(.appveyor,.travis): disable leanpkg registry tests 2018-04-12 18:32:20 +02:00
.clang-format feat(library/vm/process): add basic process support 2017-03-28 18:08:06 -07:00
.codecov.yml fix(.codecov.yml): do not fail github ci if coverage drops by 0.01% 2017-06-25 10:35:02 +02:00
.gitattributes chore(.gitattributes): use union merge strategy for doc/changes.md 2017-12-11 12:49:10 +01:00
.gitignore chore(.gitignore): ignore *.produced.out files 2018-05-01 08:43:46 -07:00
.travis.yml chore(.travis.yml): trigger AppVeyor nightly build from Travis 2018-04-13 16:44:27 +02:00
LICENSE Add LICENSE file 2013-07-15 18:55:48 -07:00
README.md chore(README): point CI links to lean4 branch 2018-04-12 13:50:42 +02:00

logo

LicenseWindowsLinux / macOSTest CoverageChat
Codecov Join the Zulip chat

About

Installation

Stable and nightly binary releases of Lean are available on the homepage. For building Lean from source, see the build instructions.

Miscellaneous

Roadmap