Commit graph

13860 commits

Author SHA1 Message Date
Leonardo de Moura
e64cb10ded feat(library/init): add hashable type class 2018-05-05 20:48:57 -07:00
Leonardo de Moura
d5fe509c36 chore(*): remove end after each match-expression
`end` is not optional anymore
2018-05-04 11:30:06 -07:00
Leonardo de Moura
752e0a134e chore(library/init/data/nat/basic): cleanup 2018-05-04 11:30:06 -07:00
Sebastian Ullrich
7da6d5c50d test(tests/lean/run/ext_eff): add extensible effects monad example 2018-05-04 19:44:33 +02:00
Leonardo de Moura
11a8a7c4f3 feat(library/init): use usize instead of uint32 in the low level array access primitives 2018-05-04 10:40:14 -07:00
Leonardo de Moura
af4f831a9f feat(library/init/data/hashmap): hash function produces an uint32 instead of nat
Most efficient hash functions use uint32/uint64 and produce values
that do not fit in out small nat representation. Thus, GMP big numbers
would have to be created.
2018-05-03 17:56:10 -07:00
Leonardo de Moura
7aeae54522 chore(tests/lean/trust0/basic): fix test 2018-05-03 15:57:59 -07:00
Leonardo de Moura
ff7e691d66 feat(library/vm): add support for system.platform.nbits in the VM 2018-05-03 15:54:54 -07:00
Leonardo de Moura
acade175b6 feat(library/init/data/array): store dimension in the array
The array dimension is now stored inside the array.
The main motivation is that it reflects the actual runtime implementation.
We need to store the array size to be able to GC it.
So, it feels silly to have the array size stored in each array object,
but we cannot use this information.
For example, in the `hashmap` we implemented the bucket array using
`array`, and we store the `size` of the array.
Same for the Lean3 `buffer` object.
The `buffer` object doesn't even need to exist.
The actual `array` implementation is the `buffer`
2018-05-03 15:43:03 -07:00
Leonardo de Moura
668d198991 feat(library/init/data/usize): add usize 2018-05-03 15:43:00 -07:00
Leonardo de Moura
732d638bb8 chore(library/init/data/array/lemmas): remove array theorems 2018-05-03 15:38:42 -07:00
Leonardo de Moura
9aa459c7e1 feat(library/init/data/nat/basic): add auxiliary power theorems 2018-05-03 11:23:59 -07:00
Leonardo de Moura
c135d0ae61 chore(library/init/data/uint): cleanup 2018-05-03 10:42:50 -07:00
Leonardo de Moura
dde79a8783 fix(library/vm/vm_io): compilation warning 2018-05-03 10:30:39 -07:00
Sebastian Ullrich
bd7109dc02 chore(library/init/core): cleanup matches 2018-05-03 10:35:39 +02:00
Sebastian Ullrich
16190610dc feat(frontends/lean/match_expr): make end after match optional, remove eventually 2018-05-03 10:35:39 +02:00
Leonardo de Moura
82bf618972 feat(library/init/lean/disjoint_set): disjoint sets
We need this datastructure to eliminate phi nodes from the IR.
The phi nodes need to be eliminated when mapping to C++ and/or
interpreting the IR.
2018-05-02 22:24:33 -07:00
Leonardo de Moura
d9101cb950 chore(tests/lean/parser1): fix test 2018-05-02 17:37:55 -07:00
Leonardo de Moura
48ba4370d5 feat(library/system/io): implement io using string instead of char_buffer 2018-05-02 17:31:51 -07:00
Leonardo de Moura
bf71068b14 feat(library/init/lean/ir): parse IR definitions 2018-05-02 16:59:50 -07:00
Leonardo de Moura
0d49ae3f69 feat(library/init/lean/parser): add not_followed_by and not_followed_by_sat
The new parsers are useful to implement the longest match rule.
2018-05-02 15:55:57 -07:00
Leonardo de Moura
beae2d936b chore(library/init/lean/ir/parser): remove leftover 2018-05-02 12:44:23 -07:00
Leonardo de Moura
f44bfb3e59 feat(library/init/lean/parser/parser): use dlist to implement expected messages
The idiom `p1 <|> p2 <|> ... <|> pn` generates many append operations.
`dlist` provides an O(1) append.
2018-05-02 12:43:21 -07:00
Leonardo de Moura
f2df67053f feat(library/init/data/dlist): add dlist back without tactic framework dependency 2018-05-02 12:36:31 -07:00
Leonardo de Moura
4d6cbf62a2 refactor(library/init/lean/parser/parser): we don't need to store the whole message in ok_eps
In the original parsec paper, they store messages in OK silent/epsilon
results too. This is not necessary, we only need the "expected" field
for the `ok_eps` constructor.
2018-05-02 11:37:57 -07:00
Leonardo de Moura
6e2ebb5fab feat(library/init/lean/ir): add IR instruction parser 2018-05-01 17:45:50 -07:00
Leonardo de Moura
6672cc2a34 fix(library/init/lean/parser/parser): bug 2018-05-01 17:15:12 -07:00
Leonardo de Moura
7361dc7b96 chore(library/init/lean): join_with ==> join_sep 2018-05-01 17:14:49 -07:00
Leonardo de Moura
3c53ef1562 chore(library/init/lean/ir): rename instructions gets and sets to sget and sset
Motivation: consistency with `swrite` and `sread`
2018-05-01 17:01:45 -07:00
Leonardo de Moura
619394f3da feat(library/init/lean/parser/string): parser for string literals 2018-05-01 16:17:16 -07:00
Leonardo de Moura
ffdc6cca8a refactor(library/init/lean/ir): move reserved set to different file 2018-05-01 15:27:25 -07:00
Leonardo de Moura
0daeb7d17f feat(library/init/lean/ir/format): escape identifiers when needed 2018-05-01 14:27:38 -07:00
Leonardo de Moura
4aafa82a9c feat(library/init/lean/ir/format): IR => format 2018-05-01 13:39:57 -07:00
Leonardo de Moura
92fa43e7d8 feat(library/init/lean/ir/ir): use name 2018-05-01 12:40:49 -07:00
Leonardo de Moura
263391bdbb refactor(library/init/lean): add init/lean/parser/identifier 2018-05-01 11:53:55 -07:00
Leonardo de Moura
45694ae44a fix(library/init/data/nat/basic): performance problem
Before this commit, given `x n : nat` the expression
```
to_bool (n <= x)
```
where `n` is a numeral <= 1024 was being elaborated as
```
@decidable.to_bool (@has_le.le.{0} nat nat.has_le n x) (nat.decidable_lt n' x)
```
where `n'` denotes the numeral `n-1`
Example:
```
to_bool (800 <= x)
```
was elaborated as
```
@decidable.to_bool (@has_le.le.{0} nat nat.has_le 800 x) (nat.decidable_lt 799 x)
```

Reason: `nat.lt` and `nat.le` were reducible. The module `type_context`
has support for solving "offset constraints" for small numerals.
These constraints include:
- `succ ?x =?= n`  ===> `?x := n - 1`

For elaborating `to_bool (800 <= x)`, we need to synthesize
```
decidable (@has_le.le.{0} nat nat.has_le 800 x)
```
using type class resolution.

The instance `nat.decidable_lt` is tried before `nat.decidable_le`. For
this instance, we need to solve the unification problem.
```
decidable (@has_lt.lt.{0} nat nat.has_lt ?n ?x) =?= decidable (@has_le.le.{0} nat nat.has_le 800 x)
```
which reduces to:
```
nat.less_than_or_equal (succ ?n) ?x =?= nat.less_than_or_equal 800 x
```
because `nat.le` and `nat.lt` are marked as `[reducible]`.
This constraint reduces to
```
succ ?n =?= 800
```
which is solved using the offset constraint support as
```
?n := 799
```

The kernel does not have support for offset constraints, and may take
a considerable amount of time to check that `succ 799` is definitionally
equal to `800`. This is particularly expensive when trust level 0 is
used.
It was taking almost 1 minute to execute the leanchecker test before
this commit because we add the new predicates for checking which
characters can be used in a Lean identifier.

This commit fixes the problem by removing the annotation `[reducible]`
from `nat.lt` and `nat.le`. This performance issue may be triggered
by any reducible instance that may create offset constraints during
type class resolution.

cc @kha
2018-05-01 11:50:54 -07:00
Leonardo de Moura
7305a7a65e feat(library/init/lean): identifier parser 2018-05-01 10:29:34 -07:00
Leonardo de Moura
054f6717de chore(.gitignore): ignore *.produced.out files 2018-05-01 08:43:46 -07:00
Leonardo de Moura
05239d20cd refactor(library/init/lean/ir): split ir.lean 2018-05-01 08:43:34 -07:00
Leonardo de Moura
5a560b6d43 feat(library/init/data): add hashmap
We use the same approach used to define rbtree:
1- Structure with minimal number of invariants, AND
2- well_formed inductive predicate

We can use the well_formed predicate to prove auxiliary invariants later.
Example: the keys stored in every bucket have the correct hash code.

This implementation does not depend on the tactic framework,
and it is not a mess like the one in mathlib.
2018-04-30 18:28:29 -07:00
Leonardo de Moura
50b7efe00d refactor(library/init/data/array/basic): make sure init/data/array/basic does not depend on init.meta 2018-04-30 17:16:45 -07:00
Leonardo de Moura
ba8b85f4c0 chore(library/init/lean/parser/parser): adjust variable names 2018-04-30 16:36:09 -07:00
Leonardo de Moura
cd10ca74f7 chore(tests/lean/string_imp): fix test 2018-04-30 16:15:51 -07:00
Leonardo de Moura
485b16a413 feat(library/init/lean/parser/syntax): use position 2018-04-30 16:13:01 -07:00
Leonardo de Moura
9879cb46be feat(library/init/lean/parser/parser): store offset in error messages 2018-04-30 16:08:52 -07:00
Leonardo de Moura
f20f50254c feat(library/init/data/string/basic): add string.line_column 2018-04-30 15:55:34 -07:00
Leonardo de Moura
62d425073e feat(library/init/data/string/basic): add string.iterator.offset 2018-04-30 15:43:51 -07:00
Leonardo de Moura
1b5c3c117e fix(library/init/lean/parser/syntax): leanchecker error: multiple definitions of lean.parser.position 2018-04-30 13:44:23 -07:00
Leonardo de Moura
3c317a30db chore(library/init/lean/parser): remove sorry warnings and init/meta dependencies 2018-04-30 13:38:25 -07:00
Leonardo de Moura
4fa43f18dd chore(library/init/data/rbtree,library/init/data/rbmap): remove auto_param dependency
The problem is that `auto_param` is defined in the old `init/meta/name` module,
and we don't want to have `init/meta` dependencies in the `init/lean` modules.
2018-04-30 13:24:13 -07:00