Commit graph

30 commits

Author SHA1 Message Date
Leonardo de Moura
7049f4a889 feat(library/init/lean/class): register attributes and export functions 2019-06-27 13:27:13 -07:00
Leonardo de Moura
08cdb757b4 feat(library/init/lean/environment): add Environment.addAndCompile
To fix `BuiltinParserAttribute`, we need to be able to add auxiliary declarations programmatically.
2019-06-18 18:20:17 -07:00
Leonardo de Moura
02f90485e6 feat(library/init/lean): use Environment in the new frontend 2019-05-13 13:04:57 -07:00
Leonardo de Moura
41f373cd0d chore(library/init/lean/declaration): naming convention 2019-03-23 09:28:38 -07:00
Sebastian Ullrich
91b244f679 chore(tests/playground/environment_ext): style and minor changes 2019-03-22 22:51:21 +01:00
Leonardo de Moura
1fe3f14ad0 chore(*): Uint => UInt, Usize => USize 2019-03-21 15:06:44 -07:00
Leonardo de Moura
2be87ecd92 chore(library/init): Bool.tt => Bool.true and Bool.ff => Bool.false 2019-03-21 15:06:44 -07:00
Leonardo de Moura
04e20623e6 chore(*): use lowercase dir names 2019-03-21 15:06:44 -07:00
Leonardo de Moura
67fb78bb47 chore(*): renaming files 2019-03-21 15:06:44 -07:00
Sebastian Ullrich
beda5f5f43 chore(library): capitalize types and namespaces 2019-03-21 15:06:43 -07:00
Sebastian Ullrich
b939162168 chore(library): switch from snake_case to camelCase 2019-03-21 15:06:43 -07:00
Leonardo de Moura
ecdb9d6df0 feat(library/init, frontends/lean): add abbreviation for abbreviation 2019-03-15 16:01:25 -07:00
Leonardo de Moura
20ba4c4b04 feat(kernel): opaque constants
They are very similar to `theorems`, but they are never ever unfolded.
2019-03-15 15:45:06 -07:00
Leonardo de Moura
0888dee25e chore(*): meta ==> unsafe 2019-03-15 15:04:40 -07:00
Leonardo de Moura
4874e25715 feat(kernel): save constructor idx and nfields at constructor_val 2018-09-14 13:45:58 -07:00
Leonardo de Moura
afb9584a63 feat(kernel): store at inductive_val whether the type is reflexive or not 2018-09-05 14:46:03 -07:00
Leonardo de Moura
517923d362 feat(kernel/inductive): generate recursors in the new inductive datatype module 2018-08-31 17:47:22 -07:00
Leonardo de Moura
863355c6a0 feat(kernel/inductive): continue new inductive datatype module
Add more validation, and create new inductive_val and constant_val objects.
2018-08-29 09:27:06 -07:00
Leonardo de Moura
101886ffae feat(kernel): proper constant_info and declaration objects for quot type 2018-08-28 13:46:31 -07:00
Leonardo de Moura
3f5db74ab4 refactor(library/init/lean/declaration): rename declaration_val ==> constant_val
It doesn't make sense to call it `declaration_val` anymore.
2018-08-27 16:07:38 -07:00
Leonardo de Moura
27ef29a50f refactor(kernel/declaration): continue constant_info/declaration refactoring 2018-08-27 13:22:10 -07:00
Leonardo de Moura
d64a49a7da feat(library/init/lean/declaration): use task at theorem and definition declaration objects 2018-08-22 10:31:50 -07:00
Leonardo de Moura
682cfa14e8 chore(library/init/lean/declaration): add new declaration type 2018-08-21 10:13:16 -07:00
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
Leonardo de Moura
9d35d31529 refactor(kernel): merge constant_assumption and axiom 2018-08-01 09:57:47 -07:00
Leonardo de Moura
bda46cc9ac feat(kernel): add inductive_decl type on top of runtime/object, and ajust kernel/inductive.cpp 2018-06-26 12:16:33 -07:00
Leonardo de Moura
bb0b43798c feat(kernel/declaration): add wrappers for accessing inductive/constructor/recursor declarations 2018-06-25 15:01:02 -07:00
Leonardo de Moura
f62256853c refactor(library/init/lean/declaration): use lean.declaration to implement init.meta.declaration 2018-06-25 13:08:13 -07:00
Leonardo de Moura
9c6238e1ac refactor(kernel/declaration): reducibility hints as runtime/object 2018-06-25 08:04:44 -07:00
Leonardo de Moura
ef6ed1e660 feat(library/init/lean/declaration): add lean.declaration 2018-06-23 10:19:26 -07:00