Commit graph

46 commits

Author SHA1 Message Date
Leonardo de Moura
dda0e38802 chore(library/init): avoid local notation 2019-06-24 15:48:11 -07:00
Leonardo de Moura
9e73d92e42 chore(library/init): remove instances of scoped notation 2019-06-20 14:08:35 -07:00
Leonardo de Moura
ef89945ea0 fix(library/init/lean/compiler/ir/emitcpp): tail call
Implement fix used at 4d2837430a in the new IR compiler.
2019-05-22 07:58:33 -07:00
Leonardo de Moura
83692eef6d feat(library/init/lean/compiler/ir): explicit RC 2019-05-19 16:46:51 -07:00
Leonardo de Moura
251890b490 feat(library/init/control/combinators): add Nat.mfold and rename Nat.for => Nat.fold 2019-05-10 10:47:57 -07:00
Leonardo de Moura
49551036ed refactor(library/init): minor changes
Old `Nat.repeat` => `Nat.for`
Old `Nat.mrepeat` => `Nat.mfor`
New `Nat.repeat` has type
```
def repeat {α : Type u} (f : α → α) (n : Nat) (a : α) : α :=
``
`List.repeat` => `List.replicate` (like in Haskell)
Avoid weird `ℕ` in List library
2019-03-29 10:39:00 -07:00
Leonardo de Moura
8225146aa2 chore(library/init/core): HasLt => HasLess, HasLe => HasLessEq, ... 2019-03-23 10:07:46 -07:00
Sebastian Ullrich
7615c9f92f chore(library/init/core): style review of the first half 2019-03-21 15:06:45 -07:00
Sebastian Ullrich
b9edaf888f chore(library/init/core): ne -> Ne, not -> Not 2019-03-21 15:06:45 -07:00
Leonardo de Moura
4c50859129 chore(*): or => Or 2019-03-21 15:06:44 -07:00
Leonardo de Moura
2be87ecd92 chore(library/init): Bool.tt => Bool.true and Bool.ff => Bool.false 2019-03-21 15:06:44 -07:00
Leonardo de Moura
675003318e chore(*): small fixes 2019-03-21 15:06:44 -07:00
Sebastian Ullrich
beda5f5f43 chore(library): capitalize types and namespaces 2019-03-21 15:06:43 -07:00
Sebastian Ullrich
f7aeeaf237 exclude export/extern, translate constants.txt 2019-03-21 15:06:43 -07:00
Sebastian Ullrich
b939162168 chore(library): switch from snake_case to camelCase 2019-03-21 15:06:43 -07:00
Leonardo de Moura
4ca9c6f22e feat(runtime): add efficient fixpoint implementation 2019-03-10 10:09:57 -07:00
Leonardo de Moura
456ed23cc2 feat(library/init): use extern when declarating nat primitives 2019-02-12 18:12:29 -08:00
Leonardo de Moura
afc2569f7c fix(library/init/data/nat/basic): tail recursive nat.repeat 2019-02-08 11:00:48 -08:00
Leonardo de Moura
835b3a10cc chore(library/init): consistent names 2018-11-14 13:08:57 -08:00
Leonardo de Moura
34f01ff32e chore(library/init/data/nat/basic): missing [specialize] 2018-10-31 14:44:23 -07:00
Leonardo de Moura
4bcb7051a8 chore(library/init/data/nat/basic): missing @[inline] 2018-10-03 17:24:53 -07:00
Sebastian Ullrich
fea637288d fix(library/init/data/nat/basic,library/vm/vm_nat): regression in old compiler: primitive for nat equality was ignored
Improves parser performance by 26%
2018-09-14 16:33:04 -07:00
Leonardo de Moura
71dd8653bc feat(library/init/core): decidable_eq is a proper class
We need this to take advantage of the new indexing structure we are
going to add to improve performance.
2018-09-07 16:38:11 -07:00
Leonardo de Moura
c48eaed9a4 chore(library): remove relation_manager 2018-09-07 12:35:04 -07:00
Leonardo de Moura
66adac6af6 chore(library/init): avoid calc at corelib 2018-08-27 12:17:30 -07:00
Leonardo de Moura
70fc656931 refactor(library/init/data/nat/basic): remove nat.less_than_or_equal inductive predicate
We now define nat.le using (nat.ble : nat -> nat -> bool) function.
We will add builtin support for reducing `nat.ble` efficiently when the arguments are the to be added nat literals.
2018-06-14 11:30:09 -07:00
Leonardo de Moura
a7d08d2f3d feat(kernel/inductive/inductive): dependent elimination for inductive predicates
In Lean4, we will not generate non dependent recursors for inductive
predicates. The main goal is to make the shape of the automatically
generated recursors more uniform. The non uniform representation is
leftover from Lean2. In Lean2, we wanted to support different kernels
with different features. For example: we could create proof relevant
kernels, no impredicative universe, etc.
Recall that, in a kernel with an impredicative Prop and no proof
irrelevance, inductive predicates without dependent elimination are
weaker that inductive predicates with dependent elimination.
When proof irrelevance is enabled, we can generate the dependent
recursor from the non dependent one. Actually, the module drec.cpp
generates the dependent recursor.
Now, we only support one kind of kernel, and it doesn't make sense
anymore to generate non dependent recursors for inductive predicates.
This would only produce an unnecessary asymmetry on the inductive
datatype module.

Remark: we had to create non dependent recursors to help the elaborator.
This can be avoid if we improve the elaborator. I will do that in the
new elaborator implemented in Lean.

Remark: equation lemmas are broken for definitions that pattern match on
nested inductive datatypes. The problem is the super messy
`prove_eq_rec_invertible_aux` function. This function will not be needed
after I finish the new inductive datatype support in the kernel.

cc @kha
2018-06-12 13:03:26 -07:00
Leonardo de Moura
4d7ae73d39 feat(library/init/lean): add level 2018-05-22 09:45:18 -07:00
Leonardo de Moura
752e0a134e chore(library/init/data/nat/basic): cleanup 2018-05-04 11:30:06 -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
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
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
9efd07d18c chore(library/init): move logic.lean => core.lean 2018-04-30 09:25:25 -07:00
Leonardo de Moura
1289037e56 chore(library/init): cleanup 2018-04-30 09:25:25 -07:00
Leonardo de Moura
1ad1080f11 refactor(library): keep only basic nat theorems
All theorems are proved without using the tactic framework.
Thus, we can define `fin/uint32/uint64` types and their operations
before we define the tactic framework.
2018-04-11 16:47:54 -07:00
Leonardo de Moura
d387103aa2 fix(library/init/core): closes #1951
- Add has_pow type class
- Make `^` notation right associative
2018-03-29 16:25:47 -07:00
Leonardo de Moura
bddc84664c chore(library/init/data/nat): remove pow.lean 2018-02-20 13:50:23 -08:00
Leonardo de Moura
ddfbaa6c8d fix(library/init/data/nat/basic): missing lemma 2018-02-15 14:36:28 -08:00
Leonardo de Moura
f048da4c98 refactor(library/init/data): replace char.zero_lt_d800 proof
See issue https://github.com/leanprover/tc/issues/8

cc @dselsam
2018-02-15 14:36:28 -08:00
Leonardo de Moura
62c24f9bb5 chore(*): remove pos_num and num from stdlib 2017-05-25 18:24:16 -07:00
Leonardo de Moura
38557b5d6c feat(library/init/data/nat/basic): missing lemma 2017-02-07 17:21:26 -08:00
Leonardo de Moura
d0c86f13bb chore(library/init/data/nat): rename nat.less_than to nat.less_than_or_equal as suggested by Rob 2017-01-11 17:47:49 -08:00
Leonardo de Moura
422d43cf47 fix(library/init/data/nat/basic): issue reported by @kha 2016-12-17 13:17:30 -08:00
Jeremy Avigad
814da88858 refactor(library/init/data/nat/basic,lemmas): alternative name, and rename le.elim to le.dest 2016-12-08 07:20:02 -08:00
Leonardo de Moura
e423588463 refactor(library/init): merge some files 2016-12-02 16:13:45 -08:00
Leonardo de Moura
e11fd8820a refactor(library/init): create init.data folder 2016-12-02 14:23:06 -08:00
Renamed from library/init/nat.lean (Browse further)