Commit graph

26011 commits

Author SHA1 Message Date
Leonardo de Moura
aa56578a29 fix(library/compiler/compiler): assertion violations 2019-03-19 11:25:55 -07:00
Leonardo de Moura
e31e562c79 test(tests/playground/flat_parser2): more experiments 2019-03-19 11:25:55 -07:00
Sebastian Ullrich
b61fb79ea9 chore(tests/playground/environment_ext): prototype 2019-03-19 17:18:43 +01:00
Leonardo de Moura
4d9d4523fa chore(state0/.gitignore): ignore .o 2019-03-18 18:30:28 -07:00
Leonardo de Moura
2e21e0122c test(tests/playground/flat_parser2): another experiment 2019-03-18 18:27:05 -07:00
Leonardo de Moura
36faa595f5 refactor(library/init): move inhabited (except ...) to except.lean 2019-03-18 16:48:58 -07:00
Leonardo de Moura
970ebd2b91 test(tests/playground/ref2): small example using [init] 2019-03-18 15:52:36 -07:00
Leonardo de Moura
d5180ffa17 fix(library/init/lean/elaborator): make sure new frontend can parse the latest core.lean 2019-03-18 15:47:05 -07:00
Leonardo de Moura
81a105cb20 chore(stage0): update 2019-03-18 15:33:30 -07:00
Leonardo de Moura
2610ace69d feat(library/init/io): remove init_io
In the Haskell proposal for top level mutable state
https://wiki.haskell.org/Top_level_mutable_state, they describe the
following problems with using the `IO` monad during initialization.

"A more serious problem is that there is nothing to prevent arbitrary
observable IO actions from appearing to the right of the arrow. If we
perform all actions before executing main, then import becomes a
side-effectful operation, rather than simply a way of bringing names
into scope; furthermore we must specify the order in which actions from
different modules are executed, which would appear to be difficult in
general. If we execute actions on demand (as the unsafePerformIO hack
does) then we are building an unsafe syntactic construct into the
language."

I believe this is not applicable to us. First, our imports are already
side-effectful since we update attributes and the order we import
modules already matters. Second, we have already a well-defined order
in which we import modules. Finally, all global constants are already
being initialized eagerly.

Their ACIO proposal (`init_io` in our implementation) is too restrictive
for what we want to do. For example, to implement an environment
extension mechanism like we have discussed, we would also need `io.ref.write` and
`io.ref.read`. I imagine, we would have a global table, and `register`
would update this table. These extra actions do not satisfy the ACIO restrictions
described in the Haskell proposal. From their document:
"AC stands for Affine Central.
An IO action u is affine if its effect is not indirectly observable, hence need not be performed if the result is unneeded. That is, if u >> v === v for all actions v.
It is central if its effect commutes with every other IO action. That is, if do { x <- u; y <- v; w } === do { y <- v; x <- u; w } for all actions v and w."
It feels like we would have to keep fighting with the ACIO
restrictions. As I said above, our initialization order is well
defined. So, we must document the `[init]` feature and tell users they
should be aware that the `import` is important for initialization
purposes, and that their initialization actions should be
affine central whenever possible.
2019-03-18 15:33:29 -07:00
Leonardo de Moura
4e02edf71f fix(library/compiler/emit_cpp): emit code for invoking user provided initialization functions 2019-03-18 15:33:29 -07:00
Leonardo de Moura
b839ecb3d9 fix(library/compiler/emit_cpp): typo 2019-03-18 15:33:29 -07:00
Leonardo de Moura
08f3459ea3 fix(library/compiler/emit_cpp): stop initialization when error is reported 2019-03-18 15:33:29 -07:00
Leonardo de Moura
9b1c5c09fb feat(library/compiler/emit_cpp): thread io state 2019-03-18 15:33:29 -07:00
Leonardo de Moura
15d89b24a3 feat(library/compiler): [init] attribute
TODO: use attribute when emitting code in the backends.
2019-03-18 15:33:29 -07:00
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
74eab92c7c doc(doc/make/index): add some bootstrapping docs
@leodemoura
2019-03-18 21:50:07 +01:00
Sebastian Ullrich
c57e3f7736 fix(shell/CMakeLists): fix REBUILD_STAGE0=OFF, somehow? 2019-03-18 21:19:42 +01:00
Leonardo de Moura
06ac89e184 chore(CMakeLists): temporary fix
@kha Added this fix to make sure I can build Lean
2019-03-18 12:49:49 -07:00
Leonardo de Moura
d45da2d5ba fix(shell/lean): check whether output file was created or not 2019-03-18 12:44:28 -07:00
Sebastian Ullrich
6bd3f1168a chore(src/CMakeLists): remove now-useless standard_lib target and introduce stdlib target at stage0 2019-03-18 20:25:59 +01: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
Leonardo de Moura
06695b5942 chore(CMakeLists.txt): update cmake min version 2019-03-18 11:12:56 -07:00
Sebastian Ullrich
246d2914da chore(CMakeLists): remove dead code 2019-03-18 17:56:40 +01:00
Sebastian Ullrich
f160fd8de0 chore(tests): compile tests using -O3 again 2019-03-18 17:55:28 +01:00
Sebastian Ullrich
9df8d97f0f chore(CMakeLists): add bin target 2019-03-18 17:44:21 +01:00
Sebastian Ullrich
0db283023c chore(src/boot): rename to stage0 2019-03-18 17:14:30 +01:00
Leonardo de Moura
43cbd1e2a3 chore(bin/leanc.in): remove flags that do not exist on clang++ for OSX
@kha If we need these flags on Linux, we need to test which platform
is being used.
2019-03-18 08:38:50 -07: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
f6d3062524 feat(bin/leanc): add simple C++ compiler wrapper script 2019-03-18 16:11:30 +01:00
Sebastian Ullrich
b4ce2ba1a5 chore(shell/CMakeLists): add REBUILD_STAGE0 dev option 2019-03-18 16:09:20 +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
ee15a70098 fix(*/CMakeLists): build all binaries via (staged) leanstatic 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
1935986f3c fix(library/compiler/compiler): we must compile (non external) opaque constants 2019-03-16 18:41:58 -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
dcdeff1794 chore(runtime): remove dead file 2019-03-16 15:34:58 -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
b325908d4a chore(frontends/lean/vm_elaborator): rename to lean_elaborator, update some comments 2019-03-16 19:29:12 +01: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