Commit graph

13118 commits

Author SHA1 Message Date
Leonardo de Moura
445cd8f0ae chore(library/init/data/list/lemmas): ._ ==> _ 2017-11-13 21:50:25 -08:00
Leonardo de Moura
2c8a901df9 feat(library/init/data/prod): has_lt for prod 2017-11-13 15:51:14 -08:00
Leonardo de Moura
a39c0531cf feat(library/init/data): has_lt for string and list 2017-11-13 15:30:41 -08:00
Leonardo de Moura
e421808b8c refactor(library/init/data/char, library/init/data/fin): has_lt, has_le for char and fin 2017-11-13 15:09:08 -08:00
Leonardo de Moura
c4605b3b96 refactor(library/init): rename has_ordering => has_cmp 2017-11-13 14:47:14 -08:00
Sebastian Ullrich
c838cdab34 fix(library/process): do not strip signal information from child exit status
This should match the meaning of "$?" in bash:

"3.7.5 Exit Status

The exit status of an executed command is the value returned by the waitpid system call or equivalent function. Exit statuses fall between 0 and 255."

Fixes #1868
2017-11-13 17:15:28 +01:00
Gabriel Ebner
d7c90ecbf5 chore(bin): remove obsolete files 2017-11-12 12:04:47 +01:00
Sebastian Ullrich
55276a5c36 chore(emacs): remove obsolete files 2017-11-11 15:17:05 +01:00
Leonardo de Moura
0388dd9640 perf(init/data/ordering): avoid thunk 2017-11-10 17:05:17 -08:00
Leonardo de Moura
308bc8de4a chore(tests/lean): fix test suite 2017-11-10 16:59:09 -08:00
Leonardo de Moura
31461b6fc7 feat(library/init): add ordering unbundled type classes, add has_strict_weak_ordering for cmp
This commit also shows that nat.cmp is an instance of has_strict_weak_ordering.
2017-11-10 16:45:54 -08:00
Leonardo de Moura
db4c9838d1 test(tmp/rbtree_no_index): rbtree without indexed families 2017-11-09 19:42:53 -08:00
Leonardo de Moura
97d875eb9a perf(library/vm): add native int.cmp and nat.cmp 2017-11-09 14:18:28 -08:00
Leonardo de Moura
f2ef24696d perf(library/compiler/cse): make sure we eliminate common sub expressions in match-cases associated with 0-ary constructors
The new test exposes the problem. Before this commit, the common
subexpressions at

```
def tst : tree → nat
| (tree.leaf v) := v
| (tree.node v l r) :=
  match f v with
  | tt := tst l + tst l - tst l   -- <<< HERE
  | ff := tst r
  end
```

were not converted into a let-exprs.
2017-11-09 13:32:15 -08:00
Leonardo de Moura
0bbe51615e chore(library/compiler/vm_compiler): add helper function 2017-11-09 13:29:32 -08:00
Leonardo de Moura
76ddda493d refactor(library/compiler/cse): isolate cse processor procedure
We will use it to fix a performance problem in case expressions for
inductive datatypes that have constructors without data.
2017-11-09 12:41:36 -08:00
Leonardo de Moura
fabf7f6380 perf(library/equations_compiler, library/compiler): expand auxiliary _match_idx definitions when generating byte code
We use the auxiliary procedure pull_nested_rec_fn to pull recursive
application in nested match expressions. This is needed because the
nested match expression is compiled before we process the recursive
procedure that contains it. This transformation may produce
performance problems if the recursive application does not depend on
the data being matched. Here is an example from the new test:

```
def tst : tree → nat
| (tree.leaf v) := v
| (tree.node v l r) :=
  match f v with
  | tt := tst l
  | ff := tst r
  end
```

pull_nested_rec_fn will convert it into

```
def tst : tree → nat
| (tree.leaf v)     := v
| (tree.node v l r) := tst._match_1 (f v) (tst l) (tst r)
```

Since our interpreter uses eager evaluation, both `(tst l)` and `(tst r)`
are executed. This commit fixes this issue by expanding `tst._match_1`
during code generation.
2017-11-09 11:14:57 -08:00
Leonardo de Moura
2c1f50cc04 fix(library/num): fixes #1862 2017-11-09 09:49:53 -08:00
Leonardo de Moura
2c3e99d538 chore(tmp): save rbtree experiment 2017-11-08 16:23:12 -08:00
Leonardo de Moura
bb2587c54e chore(library/init/data/ordering): mark aux functions as protected 2017-11-08 16:23:12 -08:00
Leonardo de Moura
4fbc172099 chore(library/init/data/nat/lemmas): tail recursive version 2017-11-08 16:23:11 -08:00
Leonardo de Moura
b61920e9a3 perf(library/compiler/lambda_lifting): missing opportunity for applying eta-reduction and avoiding unnecessary aux decl 2017-11-08 16:23:11 -08:00
Leonardo de Moura
b40f3af801 feat(library/init/meta): move rb_tree and rb_map to native namespace
cc @kha
2017-11-07 13:41:45 -08:00
Sebastian Ullrich
3930085865 fix(library/type_context): zeta-expand reflected quotations before trying to substitute local refs
Fixes #1860
2017-11-07 11:27:39 +01:00
Leonardo de Moura
426a9064bf feat(frontends/lean/builtin_cmds): display warning message if has_repr instance could not be synthesized
See issue #1861
2017-11-06 19:26:18 -08:00
Leonardo de Moura
8ffdef0b3a feat(library/vm/vm): add # when displaying simple VM objects.
See explanation at issue #1861.
2017-11-06 19:15:57 -08:00
Leonardo de Moura
e96026651b feat(library/init): add d_array type
@kha I added the `d_array` type that we discussed today.
However, the VM implemantion is still using persistent arrays.
If we remove the persistent array support, then code using
hash_map will only be efficient if the hash_map is used linearly.
This is not the case in the reader module because we are planning
to support backtracking.

On the other hand, it is awkward we currently don't have a vanilla
array implementation in the VM. I suspect this will be a problem in
the future.

So, I see the following possibilities:

1- We implement a map data-structure using red-black trees in Lean.
We use this new data-structure to implement all maps in the new reader and
macro expander.

2- We implement a very simple map as a list of pairs.
Then, we replace it in the VM with an efficient implementation.
The VM implementation may use our internal red-black trees.
We may also use a persistent hash table implemented in C++,
but it would be awkward to ask the user to provide a hash function in the reference
implementation (i.e., the one using list of pairs), but not use it
anywhere :)
In contrast, if we use the red-black tree implementation we
would have to ask the user to provide a total order.
It is overkill for the list of pair reference implementation because
we just need an equality test, but, at least, the comparison function
will be used in the implementation.

3- Add types `d_parray` (dependent persistent array) and
`parray` (persistent array). In Lean, they would just wrap the
`d_array` and `array` types. In the VM, `d_array` and `array` would
be implemented using vanilla arrays and `d_parray` and `parray` would
be implemented using persistent arrays. Then, we could have
`d_hash_map`, `hash_map`, `d_phash_map` and `phash_map`. Argh, so many
versions :(
We would use `phash_map` to implement our reader and macro expander.

4- Add a `(persistent : bool := ff)` parameter to `d_array` and
`array` types. The disadvantage of this approach is that it has
a performance impact. The VM implementation would have to check
the `persisent` flag at runtime. The value of this flag is known
at compilation time, but we currently don't have a mechanism
for specializing native builtin C++ implementations for VM functions.
2017-11-06 14:56:11 -08:00
Leonardo de Moura
06f9da8d4a feat(library/init/data/bool/lemmas): helper lemmas 2017-11-06 14:19:44 -08:00
Leonardo de Moura
8ab90acb6b feat(library/init/ite_simp): add simp lemmas 2017-11-06 12:34:52 -08:00
Sebastian Ullrich
191065d963 fix(frontends/lean/elaborator): change assertion into type mismatch error
Fixes #1859
2017-11-06 10:51:37 +01:00
Floris van Doorn
1b4d2a850a test(focus): add test 2017-11-03 12:58:48 -07:00
Floris van Doorn
52ee29cb48 fix(interactive): fix focus tactic.
Previously it would fail if there was more than one goal.
2017-11-03 12:58:48 -07:00
Mario Carneiro
f847622c93 fix(init/algebra/field): move one_div_div to division_ring
also adds a few supporting lemmas about inv
2017-11-03 12:51:21 -07:00
Leonardo de Moura
91079faf97 fix(library/equations_compiler/compiler): problem introduced by recent changes
The problem was reported by @digama at slack.
2017-11-03 10:46:40 -07:00
Leonardo de Moura
403059acac doc(doc/changes): document change in the code generator 2017-11-01 14:41:36 -07:00
Leonardo de Moura
6ddfd14a32 fix(library/equations_compiler/compiler): make sure non exhaustiveness couterexamples are reported only once 2017-11-01 14:33:34 -07:00
Leonardo de Moura
cd8c154bcd feat(library/compiler/vm_compiler): clear runtime cost model
The equation compiler uses different strategies for processing
recursive equations. Some of them may produce unclear runtime cost
model. For example, the following fibonacci functions was running in
linear time instead of exponential time because the equation compiler
used the brec_on recursor.

def fib : nat → nat
| 0     := 1
| 1     := 1
| (n+2) := fib (n+1) + fib n

@dselsam and @jroesch have reported examples were the equation compiler
produces a negative performance impact. The new test (`eval` function)
captures the problem reported by @jroesch. In this example, the runtime
should not depend on the "amount of fuel".

This commit addresses this issue.
2017-11-01 14:11:09 -07:00
Leonardo de Moura
14301a7f9f feat(library/equations_compiler/compiler): generate meta auxiliary definitions for regular (recursive) definitions
Motivations:

- Clear execution cost semantics for recursive functions.

- Auxiliary meta definition may assist recursive definition unfolding in the type_context object.

Next step: use meta auxiliary definition at code generation.
2017-11-01 11:58:45 -07:00
Leonardo de Moura
15660c94f1 chore(frontends/lean/definition_cmds): remove workarounds for meta definitions
The new approach used to compile meta (and mutual meta) definitions does
not require these hacks in the frontend anymore.
2017-10-30 15:16:51 -07:00
Leonardo de Moura
482e06427b feat(library/equations_compiler): meta mutual definitions
closes #1622
2017-10-30 15:06:12 -07:00
Leonardo de Moura
7b683427da feat(library/aux_definition): add closure_helper 2017-10-30 15:00:14 -07:00
Leonardo de Moura
7999200676 chore(library/equations_compiler/equations): add aux function 2017-10-30 15:00:13 -07:00
Leonardo de Moura
7caa88b61e refactor(library/vm/vm): remove unnecessary field from vm_decl_cell 2017-10-30 15:00:13 -07:00
Sebastian Ullrich
853b0f7648
chore(.github/CONTRIBUTING): fix typos and URLs 2017-10-30 16:23:22 +01:00
Floris van Doorn
da1fc03d15 doc(CONTRIBUTING): add instructions to run test suite 2017-10-30 16:20:36 +01:00
Sebastian Ullrich
1a80ea9c8e fix(util/utf8): UTF8 decoding 2017-10-27 09:48:09 -07:00
Sebastian Ullrich
734ee66514 fix(library/string): unicode char literals 2017-10-27 09:48:09 -07:00
Leonardo de Moura
ce4e316e09 fix(library/equations_compiler/util): fixes #1841 2017-10-26 11:25:16 -07:00
Leonardo de Moura
d2497d554f feat(frontends/lean): add support for unicode char literals and escape sequences
TODO: we are not checking if the unicode escape values provide by the
user correspond to valud unicode scalar values. We should check how
other languanges handle this case.
2017-10-23 13:46:57 -07:00
Mario Carneiro
0f7fdae33e refactor(algebra/ordered_group): remove redundant axioms
for ordered_cancel_comm_monoid. The change to partial_order, with a derived lt relation, makes the lt axioms of ordered groups derivable with no additional assumptions.
2017-10-23 12:20:42 -07:00