Commit graph

4252 commits

Author SHA1 Message Date
Leonardo de Moura
c4e755c8d3 feat(library/init/io): add init_io and mk_global_ref 2019-03-18 15:33:29 -07:00
Sebastian Ullrich
15fe51b8bd chore(library/Makefile): make .olean and .cpp files in a single run 2019-03-18 20:25:59 +01:00
Sebastian Ullrich
bf5c2ea123 chore(src/CMakeLists,library/Makefile): remove stage1 on clean-olean as well 2019-03-18 20:25:59 +01:00
Sebastian Ullrich
0db283023c chore(src/boot): rename to stage0 2019-03-18 17:14:30 +01:00
Sebastian Ullrich
dec8b76c32 feat(src/CMakeLists): build stdlib using leanc instead of nested CMake run 2019-03-18 16:11:39 +01:00
Sebastian Ullrich
8a04ae56d5 chore(library/Makefile.in): update stage1/CMakeLists.txt only when out of date
not sure this really improves anything
2019-03-18 16:09:20 +01:00
Sebastian Ullrich
074b179984 feat(shell/CMakeLists): do not touch src/boot by default, use untracked dir src/stage1 instead 2019-03-18 16:09:20 +01:00
Leonardo de Moura
1da4782483 feat(runtime, library/init/io): add io.ref 2019-03-16 22:16:28 -07:00
Leonardo de Moura
8f6444c76a chore(library/init/core): remove todo 2019-03-16 18:42:37 -07:00
Leonardo de Moura
9984d28bb2 fix(library/init/lean/frontend): make sure new frontend works with new io monad 2019-03-16 18:24:53 -07:00
Leonardo de Moura
b1c187f717 feat(library/compiler): allow io unit as main function result type
When `io unit` is used, we use `return 0` for `result.ok`, and `return
1` for `result.except`.
2019-03-16 16:05:45 -07:00
Leonardo de Moura
6d0ec3a8c9 refactor(library/init/io): implement io monad using estate monad 2019-03-16 15:34:58 -07:00
Leonardo de Moura
62284c7f39 feat(library/init/control): add estate monad
Optimized `except_t ε (state_t σ id) α`
2019-03-16 15:24:12 -07:00
Sebastian Ullrich
e19ed79414 feat(shell/lean): pass environment to and from Lean, remove environment.mk_empty axiom
/cc @leodemoura

I didn't remove the implementation of `environment.mk_empty`, we may want to use
it in tests.
2019-03-16 19:27:16 +01:00
Leonardo de Moura
ffc3436dd6 feat(library/init/lean): remove some TODOs using the new opaque constants 2019-03-15 17:49:10 -07:00
Leonardo de Moura
0b7d987699 feat(frontends/lean, library/init/lean): opaque constants
@kha I have added support for opaque constants to the old C++ frontend,
and made sure the new frontend can still parse `library/init/core.lean`.
The kernel should enforce that opaque constants are really opaque, and
the following example should fail
```
constant x : nat := 0
theorem foo : x = 0 := rfl
```
If it doesn't, it is a bug.

Here are some remaining issues:
1- `environment.mk_empty` is currently an axiom because we cannot create
an inhabitant of an opaque type. A possible solution is to use
`option environment` instead of `environment`.

2- There is no support for opaque constants in the new
frontend. However, I modified it to handle axioms, and fixed the literal
values with decl_cmd_kind. I tried to mark some of my changes with
comments, but it is probably much easier for you to just check the
commit change list.

3- I did not add any support for automatically constructing `e`
at `constant x : t := e`. I think we can do this later
after we replace the old frontend with the new one. BTW, it took only a
few minutes to provide the inhabitants manually.
2019-03-15 17:41:44 -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
a78c773f37 feat(library/init/lean): unsafe support in the new frontend 2019-03-15 15:49:03 -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
39dd079e37 feat(runtime): low tech allocation profiler
```
@[extern 4 "lean_io_allocprof"]
constant allocprof {α : Type} (msg : @& string) (fn : io α) : io α
```
2019-03-14 15:15:29 -07:00
Leonardo de Moura
77dc3f3d32 feat(library/init/io): use fix to implement iterate 2019-03-12 18:06:23 -07:00
Leonardo de Moura
51838aede9 refactor(library/init/lean/parser/rec): use init.fix 2019-03-12 08:31:58 -07:00
Leonardo de Moura
68ebc2a5c5 feat(library/init/data/string/basic): implement iterators using uft8 low level API 2019-03-12 06:56:05 -07:00
Leonardo de Moura
cf3bbd7e25 feat(runtime): add utf8_prev and utf8_set
Next goal: implement string.iterator in Lean
2019-03-11 18:05:40 -07:00
Leonardo de Moura
1e821d4057 chore(library/init/fix): rename primitives 2019-03-11 13:41:13 -07:00
Leonardo de Moura
a1cbd39d74 feat(library/init/lean/extern): remove restriction from expand_extern_pattern 2019-03-10 11:42:39 -07:00
Leonardo de Moura
ff3bf508aa feat(library/init/fix, runtime): add fixpoint2, ..., fixpoint6
The idea is to avoid allocating tuples when creating the fixpoint of
nary functions. For example, consider the new tests:
- tests/playground/fix.lean
- tests/playground/fix_with_tuples.lean

The second one (`fix_with_tuples`) uses the `fix` operator and tuples. For input = 20,
it creates more than 1 million extra objects. The first implementation
(`fix.lean`) using `fix₂` avoids this overhead.

TODO: Add support for pattern #N with N > 9 at
```
def expand_extern_pattern_aux (args : list string) : nat → string.iterator → string → string
```
2019-03-10 11:19:02 -07:00
Leonardo de Moura
4ca9c6f22e feat(runtime): add efficient fixpoint implementation 2019-03-10 10:09:57 -07:00
Leonardo de Moura
c862ce4a75 feat(runtime, library/init/data/string/basic): add utf8_pos
`utf8_pos` is a low level alternative for `string.iterator`.
TODO: implement `string.iterator` using it.
2019-03-09 12:30:19 -08:00
Leonardo de Moura
2c3cfcf1dd feat(library/init/data/char/basic): add char.utf8_size 2019-03-09 10:46:29 -08:00
Leonardo de Moura
402034df1f chore(library/init/data): move usize to uint 2019-03-09 10:32:23 -08:00
Leonardo de Moura
2032b10482 feat(library/init/data): bitwise operations 2019-03-09 10:19:35 -08:00
Leonardo de Moura
4828df1c7a chore(library/init/lean/frontend): revert 4333ab620
The specializer has been fixed. So, we don't need this workaround
anymore.
2019-03-08 12:06:49 -08:00
Leonardo de Moura
baec9a1b78 chore(library/init/lean/compiler/ir): minor 2019-03-08 09:14:54 -08:00
Sebastian Ullrich
d0929c93cd perf(library/init/lean/frontend): make file_map construction explicit, do it only once 2019-03-08 17:17:27 +01:00
Sebastian Ullrich
4333ab620c refactor(library/init/lean/frontend): use direct unbounded recursion instead of iterate_eio 2019-03-08 17:04:46 +01:00
Sebastian Ullrich
e0bbc094ad chore(library/init): remove coroutines from stdlib 2019-03-08 15:34:17 +01:00
Sebastian Ullrich
234e4d1e8a refactor(library/init/lean/elaborator): replace coroutines with explicit state 2019-03-08 15:23:01 +01:00
Leonardo de Moura
db6f08e66d feat(library/init/lean/compiler/ir): collect fnbody free variables 2019-03-07 15:37:45 -08:00
Leonardo de Moura
27028309a3 feat(library/init/lean/kvmap): add == for kvmap 2019-03-07 14:12:10 -08:00
Leonardo de Moura
a836bcc204 feat(library/init/lean/compiler/ir): alpha equivalence 2019-03-07 13:50:35 -08:00
Sebastian Ullrich
81615fc856 refactor(library/init/lean/parser/module): replace coroutines with explicit snapshot state 2019-03-07 10:32:28 -08:00
Leonardo de Moura
0d4da4bc76 fix(library/init/lean/elaborator): borrow annotations
@kha I see you found this problem too :)
2019-03-07 10:26:40 -08:00
Leonardo de Moura
4e04d373e4 feat(library/init): unicode notation for heq: ≅ 2019-03-07 10:21:14 -08:00
Leonardo de Moura
819d17ebbd chore(library/init/lean/compiler/ir): use has_beq 2019-03-07 10:21:14 -08:00
Leonardo de Moura
79521e7e49 feat(library/init/core): add has_beq type class 2019-03-07 10:21:14 -08:00
Leonardo de Moura
67b01cddd0 chore(library/init): heq notation == ==> ~= 2019-03-07 10:21:14 -08:00
Leonardo de Moura
626d155c81 feat(library/init/lean/compiler/ir): alpha eqv for lean.ir.expr 2019-03-07 10:21:14 -08:00
Sebastian Ullrich
0e01871182 fix(library/init/lean/elaborator): re-add borrow annotations 2019-03-07 15:51:40 +01:00