Commit graph

4304 commits

Author SHA1 Message Date
Leonardo de Moura
9a071c18e7 feat(library/equations_compiler): add support for partial definitions 2019-03-27 11:09:32 -07:00
Leonardo de Moura
829a50ccf7 test(tests/playground/partial_eq_lemma): partial equation lemmas
@kha I added this example as a template for what the equation compiler
will have to do. The plan is:
- We can use `partial` to define any function if the result type is
inhabited.
- If the result type is of the form `Partial a`, the equation compiler
generates lemmas of the form:

```
theorem fooEq args : terminates (foo args) → foo args = lhs
```
The new test contains an example.
2019-03-26 18:06:04 -07:00
Leonardo de Moura
0ce97893de chore(tests/playground/parser): port test file to new String API 2019-03-26 16:00:03 -07:00
Sebastian Ullrich
762ccb0d1d feat(tests/playground/environment_extension): scoped extensions in Lean 2019-03-25 17:35:01 +01:00
Sebastian Ullrich
360a1476cc chore(tests/playground/environment_ext): use nicer full name like in C++ 2019-03-25 16:12:14 +01:00
Leonardo de Moura
8225146aa2 chore(library/init/core): HasLt => HasLess, HasLe => HasLessEq, ... 2019-03-23 10:07:46 -07:00
Leonardo de Moura
df9ce10623 feat(library/compiler): special support for initialization functions of the form def initFn : IO Unit
We can now write
```
@[init] def initFn : IO Unit := ...
```
instead of
```
def initFn : IO Unit := ...
@[init initFn] constant execInitFn : Unit := ()
```
2019-03-23 08:46:38 -07:00
Leonardo de Moura
3b70e8785b chore(tests/compiler/str): fix test 2019-03-22 17:26:43 -07:00
Leonardo de Moura
412d0ea578 feat(library/init/lean/options): add setOptionFromString
We can use this primitive to process command line arguments of the form
`-D <key> = <value>`

TODO: allow users to attach `[init]` to definitions of the form
```
@[init] def foo : IO Unit := ...
```
and avoid the awkward auxiliary constant.
2019-03-22 17:26:43 -07:00
Leonardo de Moura
4f80e30574 feat(library/init/data/string/basic): add String.split 2019-03-22 17:26:43 -07:00
Sebastian Ullrich
91b244f679 chore(tests/playground/environment_ext): style and minor changes 2019-03-22 22:51:21 +01:00
Sebastian Ullrich
dc93bc37cc chore(tests/playground/environment_ext): fix 2019-03-22 22:51:21 +01:00
Leonardo de Moura
45c4a78f59 chore(tests/playground/environment_ext): revert accidental commit 2019-03-22 13:26:17 -07:00
Leonardo de Moura
e24ad8c0b5 feat(library/init/core): add HasBeq default instances for types that implement DecidableEq
@kha I think code looks less weird if we don't mix Booleans and
propositions in the same expression.
2019-03-22 11:23:45 -07:00
Leonardo de Moura
548e7c5436 chore(tests/playground): fix playground tests 2019-03-21 18:30:58 -07:00
Leonardo de Moura
452d5107ac chore(library/init/data/array): naming convention
The array read and write operations are now called:

- "Comfortable" version (with runtime bound checks):
  `Array.get` and `Array.set` like OCaml.
   It is also consistent with `Ref.get` and `Ref.put`,
   and `get` and `set` for `MonadState`.

- `Fin` version (without runtime bound checks):
  `Array.index` and `Array.update` like in F*.

- `USize` version (without runtime bound checks and unboxing):
  `Array.idx` and `Array.updt`.

cc @kha
2019-03-21 18:03:29 -07:00
Leonardo de Moura
3befc219c9 chore(library/init): Empty => empty when it is a function 2019-03-21 17:03:15 -07:00
Leonardo de Moura
4bf41f0036 chore(tests/lean/run/coroutine): fix test 2019-03-21 16:46:53 -07:00
Leonardo de Moura
7bb015c6b3 chore(tests/lean): fix more tests 2019-03-21 15:11:05 -07:00
Leonardo de Moura
2cbdb287c3 chore(tests): fix/disable some tests 2019-03-21 15:11:05 -07:00
Sebastian Ullrich
f34d37c371 chore(tests): port tests, fix at least compiler tests 2019-03-21 15:11:05 -07:00
Sebastian Ullrich
25ac67516e chore(tests/playground/environment_ext): remove unused attr field 2019-03-20 15:05:59 +01:00
Leonardo de Moura
3184023ab3 feat(tests/playground): force test to backtrack 2019-03-19 16:34:08 -07:00
Leonardo de Moura
adffbdd5a8 test(tests/playground): new parser monad 2019-03-19 15:14:58 -07:00
Sebastian Ullrich
93c2a47ad1 chore(tests/playground/environment_ext): reduce number of callbacks 2019-03-19 23:04:45 +01: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
2e21e0122c test(tests/playground/flat_parser2): another experiment 2019-03-18 18:27:05 -07:00
Leonardo de Moura
970ebd2b91 test(tests/playground/ref2): small example using [init] 2019-03-18 15:52:36 -07:00
Sebastian Ullrich
f160fd8de0 chore(tests): compile tests using -O3 again 2019-03-18 17:55:28 +01:00
Sebastian Ullrich
f6d3062524 feat(bin/leanc): add simple C++ compiler wrapper script 2019-03-18 16:11:30 +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
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
3eedc327c7 feat(tests/playground/flat_parser): tail recursive many combinator 2019-03-14 16:11:51 -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
39e752d28a chore(tests/playground/flat_parser): remove debugging stuff 2019-03-14 11:05:13 -07:00
Leonardo de Moura
44cdb1fc56 chore(tests/playground/flat_parser): add new file_map
Goal: minimize the number of constructor object allocations.
They derailed me when I was looking for performance bottlenecks in the
flat_parser.
2019-03-14 08:38:08 -07:00
Leonardo de Moura
e50d8e0b92 chore(tests/playground/flat_parser): continue experiment 2019-03-13 16:40:12 -07:00
Leonardo de Moura
3fe6858a93 feat(library/compiler/csimp): make csimp simplifies unreachable branches
`let x := lc_unreachable in e` => `lc_unreachable`
`let x := e in lc_unreachable` => `lc_unreachable`
2019-03-13 11:45:40 -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
d55a439542 test(tests/playground/fix_1): add fix.lean variant: fix_1.lean
`fix.lean` and `fix_1.lean` are very similar, but fix.lean is almost
twice as fast. Reason: `fix.lean` uses `fix_2` instead of `fix_1` and
avoid the creation of many closures. Here are runtime numbers on my
machine.

```
time ./fix_1.lean.out 23
352321527

real	0m0.729s
user	0m0.724s
sys	0m0.000s
```

```
~/projects/lean4/tests/playground (master +)$ time ./fix.lean.out 23
352321527

real	0m0.396s
user	0m0.388s
sys	0m0.004s
```

TODO: modify the compiler to replace `fix_core_n f a_1 ... a_m`
with `fix_core_m f a_1 ... a_m` whenever `n < m`.
This feature is quite useful for writing reusable/generic code. For
example, we cannot write an efficient `rec_t` without it because we
don't know the arity of `m A` when we write `rec_t`.
2019-03-11 13:44:07 -07:00
Leonardo de Moura
1e821d4057 chore(library/init/fix): rename primitives 2019-03-11 13:41:13 -07:00
Leonardo de Moura
5402178f73 test(tests/playground): fix tests
Forgot to add them.
2019-03-11 08:11:00 -07:00
Leonardo de Moura
01b4983fa2 fix(runtime/object): string_utf8_extract 2019-03-09 12:57:51 -08:00
Leonardo de Moura
67944a6c81 test(tests/compiler/str): new test for utf8 primitives 2019-03-09 12:41:33 -08:00
Leonardo de Moura
114f7ed190 feat(tests/playground/flat_parser): minor edits
We need a low level string.iterator to efficiently implement
primitives such as `str`.
2019-03-09 08:08:37 -08:00
Leonardo de Moura
489eaf3b71 test(tests/playground/flat_parser): experiment 2019-03-08 17:09:42 -08:00
Leonardo de Moura
7b1d15ec43 fix(library/compiler/specialize): avoid work duplication in the specializer 2019-03-08 11:21:49 -08:00
Sebastian Ullrich
e0bbc094ad chore(library/init): remove coroutines from stdlib 2019-03-08 15:34:17 +01:00