Commit graph

612 commits

Author SHA1 Message Date
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
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
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
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
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
c10a99e96f feat(library/init/lean/name): add String.toName 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
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
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
4a08d6715a chore(library/init/data/array): add HasEmptyc instance 2019-03-21 17:06:56 -07:00
Leonardo de Moura
91204a52d6 chore(library/init/data/dlist): Dlist => DList 2019-03-21 17:03:22 -07:00
Leonardo de Moura
3befc219c9 chore(library/init): Empty => empty when it is a function 2019-03-21 17:03:15 -07:00
Leonardo de Moura
dfe15cf743 refactor(library/init): use get and set for State EState and Ref
TODO: use the same naming convention for array reads and writes.
2019-03-21 16:34:32 -07:00
Leonardo de Moura
7982420d8d fix(library/init/lean/expander, frontends/lean/lean_elaborator): conversion issues 2019-03-21 15:06:46 -07:00
Leonardo de Moura
930164b597 chore(library/init/lean/parser/term): remove hack used during conversion 2019-03-21 15:06:45 -07:00
Sebastian Ullrich
97e5aa2411 chore(library): s/Punit/PUnit/g etc 2019-03-21 15:06:45 -07:00
Leonardo de Moura
1b1946f0e0 fix(library/init/lean/expander): unit => Unit 2019-03-21 15:06:45 -07:00
Leonardo de Moura
11688fd813 fix(library/init/lean): [export...] 2019-03-21 15:06:44 -07:00
Leonardo de Moura
430bbef6d7 chore(*): minor 2019-03-21 15:06:44 -07:00
Leonardo de Moura
1fe3f14ad0 chore(*): Uint => UInt, Usize => USize 2019-03-21 15:06:44 -07:00
Leonardo de Moura
79a8d9aa65 chore(*): decidablePred/decidableRel => DecidablePred/DecidableRel 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
f8113a01eb chore(library): unit => Unit 2019-03-21 15:06:44 -07:00
Leonardo de Moura
62e6341014 chore(*): lowercase file names 2019-03-21 15:06:44 -07:00
Leonardo de Moura
04e20623e6 chore(*): use lowercase dir names 2019-03-21 15:06:44 -07:00
Leonardo de Moura
67fb78bb47 chore(*): renaming files 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
d5180ffa17 fix(library/init/lean/elaborator): make sure new frontend can parse the latest core.lean 2019-03-18 15:47:05 -07:00
Leonardo de Moura
9984d28bb2 fix(library/init/lean/frontend): make sure new frontend works with new io monad 2019-03-16 18:24:53 -07:00
Leonardo de Moura
6d0ec3a8c9 refactor(library/init/io): implement io monad using estate monad 2019-03-16 15:34:58 -07:00
Sebastian Ullrich
e19ed79414 feat(shell/lean): pass environment to and from Lean, remove environment.mk_empty axiom
/cc @leodemoura

I didn't remove the implementation of `environment.mk_empty`, we may want to use
it in tests.
2019-03-16 19:27:16 +01:00
Leonardo de Moura
ffc3436dd6 feat(library/init/lean): remove some TODOs using the new opaque constants 2019-03-15 17:49:10 -07:00
Leonardo de Moura
0b7d987699 feat(frontends/lean, library/init/lean): opaque constants
@kha I have added support for opaque constants to the old C++ frontend,
and made sure the new frontend can still parse `library/init/core.lean`.
The kernel should enforce that opaque constants are really opaque, and
the following example should fail
```
constant x : nat := 0
theorem foo : x = 0 := rfl
```
If it doesn't, it is a bug.

Here are some remaining issues:
1- `environment.mk_empty` is currently an axiom because we cannot create
an inhabitant of an opaque type. A possible solution is to use
`option environment` instead of `environment`.

2- There is no support for opaque constants in the new
frontend. However, I modified it to handle axioms, and fixed the literal
values with decl_cmd_kind. I tried to mark some of my changes with
comments, but it is probably much easier for you to just check the
commit change list.

3- I did not add any support for automatically constructing `e`
at `constant x : t := e`. I think we can do this later
after we replace the old frontend with the new one. BTW, it took only a
few minutes to provide the inhabitants manually.
2019-03-15 17:41:44 -07:00
Leonardo de Moura
ecdb9d6df0 feat(library/init, frontends/lean): add abbreviation for abbreviation 2019-03-15 16:01:25 -07:00
Leonardo de Moura
a78c773f37 feat(library/init/lean): unsafe support in the new frontend 2019-03-15 15:49:03 -07:00
Leonardo de Moura
20ba4c4b04 feat(kernel): opaque constants
They are very similar to `theorems`, but they are never ever unfolded.
2019-03-15 15:45:06 -07:00