Commit graph

31 commits

Author SHA1 Message Date
Leonardo de Moura
a31f12d8cd chore(library/init/core): revert ite+thunks modification
We don't need it since we marked `ite` as `[macro_inline]`
2018-09-23 19:27:06 -07:00
Leonardo de Moura
b07c718425 refactor(library/init/core): change ite signature 2018-09-17 14:27:28 -07:00
Sebastian Ullrich
80745ba776 chore(library/init/data/string/basic): rename string.iterator's next_to_string to remaining_to_string
The old name implied that `curr` was not part of its result
2018-07-05 10:42:37 +02:00
Leonardo de Moura
0c785f8ab7 feat(library/init/data): add instances for has_repr (id A) and has_to_string (id A) 2018-05-10 17:37:57 -07:00
Leonardo de Moura
224fdc7a78 refactor(library/init/lean/ir): platform dependent IR
Motivation: in 64-bit machines, we can store boxed uint32 values as a
tagged pointer. In 32-bit machines, we need to allocated an object (like
Haskell) to store the uint32 value. So, the generated bytecode is quite
different in each platform.

This change also allow us to simplify the IR. Example: we don't need the
type `sizet` anymore.

Impact: To be able to bootstrap in both platforms,
we will have to store two versions of the generated code: 32 and 64
versions. In principle, we only need to store the 64-bit version,
and use cross-compilation to build the 32-bit version.
2018-05-10 13:15:02 -07:00
Leonardo de Moura
d85c30fde1 perf(library/init/data): mark usize, uint16, uint32 and uint64 as [irreducible]
Without these annotations, Lean will timeout when trying to synthesize
the type class instance `decidable_eq uint32`. The type class resolution
problem will produce the unification problem:
```
decidable (@eq uint32 a b) =?= decidable (@eq usize ?x ?y)
```
which Lean tries to solve by assigning `?x := a`.
During the assignment, the types of `?x` and `a` are unified with "full
force". Thus, we get the constraint
```
usize_sz =?= uint32_sz
```
which will take forever to be solved when peforming the computation in
unary arithmetic.

Remark: this commit also makes sure that `type_context` will not unfold
irreducible definitions when trying to unify/match the types.

The new test `type_class_performance1.lean` exposes the problem fixed
by this commit.
2018-05-07 18:07:04 -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
65e3c96b28 chore(library/init): remove sum micro module 2018-04-30 09:25:26 -07:00
Leonardo de Moura
2503d6026e chore(library/init): remove prod micro module 2018-04-30 09:25:25 -07:00
Leonardo de Moura
e9d4780ccb chore(library/init): remove subtype micro module 2018-04-30 09:25:25 -07:00
Leonardo de Moura
21d9409629 feat(library/init/data): modify unit has_to_string and has_repr instances 2018-04-27 13:39:19 -07:00
Leonardo de Moura
ba633df7e7 chore(library/init/data): add missing instances 2018-04-27 13:39:19 -07:00
Leonardo de Moura
e602ac873a feat(library/init): modify && and || precedence
The idea is to match the precedence used in regular programming
languages, where `x = y || x = z` is parsed as `(x = y) || (x = z)`.

This commit also adds `!x` as notation for `bnot x`
2018-04-26 13:40:57 -07:00
Leonardo de Moura
50328d62e1 feat(library/init/data): add uint16 and make sure uint* - uses wraparound semantics like most programming languages 2018-04-20 18:27:13 -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
8b88f21c91 refactor(library): add has_to_string back (but it produces unquoted values)
See issue #1664
2017-06-18 18:30:10 -07:00
Leonardo de Moura
dc1a1c8540 refactor(library): has_to_string ==> has_repr
See issue #1664

This is just the first step to implement proposal described at issue #1664.
2017-06-18 18:29:19 -07:00
Gabriel Ebner
dc81915da6 refactor(library): unify char.to_string and char.has_to_string 2017-06-12 16:32:35 +02:00
Leonardo de Moura
4eefc41b6e refactor(*): wrap string in a structure
We want to make sure string users do not depend on the string
implementation. This is the first step.

We need this refactoring *now* to make sure it will not be
super painful to address issue #1175
2017-06-07 17:30:49 -07:00
Leonardo de Moura
73b4e42485 chore(frontends/lean,library): fix character pretty printer 2017-05-02 13:17:22 -07:00
Leonardo de Moura
a0a8103804 chore(frontends/lean): go back to 'c' as notation for characters
This suggestion has been discussed at Slack.
We have decided to use #"c" as notation because we wanted to allow `'`
in the beginning of identifiers like in SML and F*. In particular,
we wanted to allow users to use 'a 'b 'c for naming type parameters
like in SML. However, nobody used this notation. In the Lean standard
library, we are using greek letters for naming type parameters.
So, there is no real motivation for the ugly #"c" syntax.
2017-05-02 13:00:51 -07:00
Leonardo de Moura
5cef84709f refactor(library): avoid auxiliary definitions such as add/mul/le/etc
See Section "Other goodies" at
https://github.com/leanprover/lean/wiki/Refactoring-structures

This commit also improves the support for projections in the
unifier/matcher.

Now, we consider the extra case-split for projections.
Given a projection `proj`, and the constraint `proj s =?= proj t`, we need to try first `s =?= t` and if it fails, then try to reduce.
This is needed in the standard library because we now have constraints such as:
```
@has_le.le ?A ?s ?a ?b  =?=  @has_le.le nat nat.has_add x y
```
If we reduce the right hand side, we get the unsolvable constraint
```
@has_le.le ?A ?s ?a ?b  =?=  nat.le x y
```
Before this change, the constraint was `@le ?A ?s ?a ?b  =?=  @le nat nat.has_add x y`, and we already perform a case-split in this case.
Moreover, projections were eagerly reduced whenever possible.
The extra case-split generates a performance problem in several tests. For example `fib 8 = 34` was timing out.
I worked around this issue by performing the case-split only when the constraint contains meta-variables.
There are also minor issues. Example. `<` is notation for `has_lt.lt`, but `>` is for `gt`.
2017-05-01 08:52:19 -07:00
Jeremy Avigad
95f75bbbee refactor(library/init/data/subtype/basic): rename subtype constructor and projections 2017-03-08 19:31:27 -08:00
Leonardo de Moura
9a263a2766 chore(library/init): instances are reducible and are inlined by the compiler
So, these instances would create two copies of `p` after inlining
2017-03-07 10:58:09 -08:00
Leonardo de Moura
1cdf13821c feat(library/init/data/unsigned): add basic unsigned operations 2017-03-05 16:14:16 -08:00
Leonardo de Moura
32e6442d0a feat(frontends/lean): no global universes in the frontend 2017-02-08 17:23:04 -08:00
Leonardo de Moura
df91ae3738 fix(library/string,library/init/data/to_string): handle ASCII control characters 2017-01-11 23:44:33 -08:00
Leonardo de Moura
1d0d45d890 feat(library/init/data/to_string): mark list.to_string as protected 2016-12-18 13:17:10 -08:00
Sebastian Ullrich
26ead0e7ac feat(library/data/int/basic): has_to_string int 2016-12-18 13:15:41 -08:00
Leonardo de Moura
5d1716a983 refactor(library/data): delete init/data/instances.lean 2016-12-02 16:41:16 -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/to_string.lean (Browse further)