Commit graph

4357 commits

Author SHA1 Message Date
Leonardo de Moura
90a6b36783 refactor(library/init/data/string/basic): avoid artificial "fuel" using partial
After we restore the tactic framework, we will be able to eliminate the
`partial` keywords in this module by using well-founded recursion.
2019-03-27 13:51:52 -07:00
Leonardo de Moura
a43a40b7f5 chore(library/init): remove fix.lean
`partial def` is much more general
2019-03-27 13:11:00 -07:00
Leonardo de Moura
3936b2ba79 chore(library/init/io): we don't need fix anymore
`partial def` are much more general
2019-03-27 12:59:43 -07:00
Leonardo de Moura
62d7cc6b37 feat(library/init/wf): remove wf_term_hack 2019-03-27 12:41:16 -07:00
Leonardo de Moura
a3f30a5573 feat(library/init/lean): avoid wf_term_hack 2019-03-27 12:36:17 -07:00
Leonardo de Moura
895bf2c91d feat(library/equations_compiler/partial_rec): try assumption if inhabitant could not be found 2019-03-27 12:24:24 -07:00
Leonardo de Moura
b66f5dcf5c chore(library/init): avoid wf_term_hack 2019-03-27 12:12:21 -07:00
Leonardo de Moura
9a071c18e7 feat(library/equations_compiler): add support for partial definitions 2019-03-27 11:09:32 -07:00
Leonardo de Moura
b29fb57fcf refactor(library/init/data/string/basic): String.Pos as Nat
@kha: I initially planned to use the UTF8 API only in very special
cases, but I found them to be super useful. They allow us to implement
an efficient String library mostly in Lean.
However, the there was a problem: `abbrev String.Pos := USize`.
This definition is fine for a low level API, but this is not the case
anymore. By having `String.Pos := USize`, we will not be able to
prove natural theorems for the `String` API. For example,
`String.map id s = s` did not hold. We would have to include the
artificial antecedent `s.length <= usizeMax` (or something like this).
I suspect it would be very painful.
So, this commit defines `String.Pos` as `Nat`. The performance
overhead seems to be very small.
2019-03-26 15:35:52 -07:00
Leonardo de Moura
b0da4360d0 chore(runtime, library/init/data/string/basic): prepare to change String.Pos 2019-03-26 12:25:12 -07:00
Leonardo de Moura
681f3ec81b fix(library/compiler/llnf): constructor reuse
We were not reusing constructor values for constructors that contained only
scalar values.
2019-03-26 11:10:51 -07:00
Sebastian Ullrich
040ec9767d fix(library/init/lean/parser/combinators): (x) -> e should not be a dependent function 2019-03-26 11:26:39 +01:00
Leonardo de Moura
2a37e60ba9 feat(library/init/core): add != notation 2019-03-25 16:58:01 -07:00
Leonardo de Moura
3ad7d2ba81 fix(library/compiler/lcnf): disable transformation for Bool
@kha Here is another motivation for re-implementing the equation compiler.
2019-03-25 16:48:11 -07:00
Leonardo de Moura
7db4f60e50 feat(library/init/core): eagerly expanding Decidable.toBool seems to be a bad idea
After we erase types and proofs, `Decidable.toBool` can be replaced with
the identity function since `Decidable A` and `Bool` have the same
runtime representation. By eagerly expanding `toBool`, we introduce
unnecessary `cases` expressions.
2019-03-25 16:48:11 -07:00
Leonardo de Moura
87cab24a1d fix(library/compiler/csimp): at_most_once at elim_jp1_fn
`elim_jp1_fn` was incorrectly expanding join points that were used more
than once. The issue is that the `foreach` combinator "may" skip nodes
that have already been visited.
2019-03-25 14:19:11 -07:00
Leonardo de Moura
7f58843d48 feat(library/init/lean/compiler/util): atMostOnce visitor 2019-03-25 14:19:10 -07:00
Leonardo de Moura
79b6a144d5 feat(library/init/data/string/basic): improve and cleanup String/Substring API 2019-03-25 14:19:10 -07:00
Leonardo de Moura
bbe93c036d feat(library/init/data/string): add Substring 2019-03-25 09:29:06 -07:00
Leonardo de Moura
18f3ec41a9 chore(library/init/data/string/basic): reorg and cleanup 2019-03-25 09:29:06 -07:00
Sebastian Ullrich
beec014890 feat(library/init/lean/{parser/term,expander}): remove (x : e) → f macro hack and replace with actual parser 2019-03-25 16:12:14 +01:00
Leonardo de Moura
60f8d17942 refactor(library/init/data/string/basic): simplify String.Iterator
The `offset` field is problematic because it prevents us from having an
efficient way of moving back and forth between `String.Pos` and `String.Iterator`.

@kha I temporarily added `String.OldIterator` for making sure the
parser doesn't break. This is a temporary fix that will be eliminated
after we replace `parsec`.
2019-03-25 07:57:12 -07:00
Sebastian Ullrich
6ea5f5196e feat(library/init/lean/expander): support Agda-like (a : b) → c syntax 2019-03-24 20:25:11 +01:00
Leonardo de Moura
5b08bf18c5 feat(library/init/lean): improving options
@kha It will be awesome to automate the following idiom with a macro :)
```
def defIndent  := 4
def getIndent (o : Options) : Nat   := o.get `format.indent defIndent
@[init] def indentOption : IO Unit :=
registerOption `format.indent { defValue := defIndent, group := "format", descr := "indentation" }
```
2019-03-24 09:30:20 -07:00
Leonardo de Moura
9d1f4a4f29 chore(library/init/control/state): indentation consistency 2019-03-23 19:03:26 -07:00
Leonardo de Moura
4d9150859b chore(library/init/core): avoid {{x : A}} strict implicit arguments, and cleanup 2019-03-23 19:03:26 -07:00
Sebastian Ullrich
07059fe2bf fix(library/init/lean/frontend): naming style misrenamings 2019-03-23 23:09:55 +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
41f373cd0d chore(library/init/lean/declaration): naming convention 2019-03-23 09:28:38 -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
cc8ccae754 feat(library/init/data/string/basic): add String.foldl and String.foldr 2019-03-22 17:26:43 -07:00
Leonardo de Moura
d4aab31ada feat(library/init/io): IO.userError 2019-03-22 17:26:43 -07:00
Leonardo de Moura
c10a99e96f feat(library/init/lean/name): add String.toName 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
Leonardo de Moura
98163e53ac chore(library/init/data/string/basic): simplify UTF8 API names
@kha I am finding the UTF8 API super useful. So, I am giving nice names
to it. The API is safe for users and the runtime implementation should
match the reference one.
2019-03-22 17:26:43 -07:00
Leonardo de Moura
050985121d chore(library/init/data/string/basic): utf8Pos => Pos 2019-03-22 17:26:43 -07:00
Leonardo de Moura
1c671965c5 feat(library/init/lean/options): add registerOption 2019-03-22 17:26:43 -07:00
Leonardo de Moura
dc73d5443d refactor(library/init/lean): add MData abbreviation 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
Leonardo de Moura
2b76d79791 chore(library/init/core): remove more nonsense 2019-03-22 13:14:20 -07:00
Leonardo de Moura
930653f292 chore(library/init): Unit.star => Unit.unit
@kha Our stdlib is starting to match the names we used in our paper :)
2019-03-22 13:06:45 -07:00
Leonardo de Moura
3fe5cf1528 chore(library/init/core): remove another weirdness: the bs at bnot, band and bor 2019-03-22 12:57:31 -07:00
Leonardo de Moura
e1ea2b3948 chore(library/init): fix names and add HasEmptyc instances 2019-03-22 12:38:22 -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
87b066b87e refactor(library/init): move function.lean definitions to core.lean 2019-03-22 09:33:10 -07:00
Leonardo de Moura
e31c3fde56 chore(library/init): remove dead code, lemma => theorem 2019-03-22 09:27:30 -07:00
Leonardo de Moura
46cb2436d8 chore(library/init/core): remove dead code, and naming convention 2019-03-22 09:19:28 -07:00
Leonardo de Moura
7552b2e1e4 chore(library/init/data/list/basic): mem => Mem 2019-03-22 09:10:21 -07:00
Sebastian Ullrich
fa0381cecf fix(library/Makefile): clean STAGE1_OUT too
vanished during merge
2019-03-22 10:18:33 +01: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