Commit graph

87 commits

Author SHA1 Message Date
Leonardo de Moura
4d913370a7 chore(library/init): eliminate whitespaces using another patch script 2019-08-09 09:01:39 -07:00
Sebastian Ullrich
3ed67138d5 chore(*): update equation syntax in files and old parser
for f in ../../**/*.lean; do echo $f; ./patch.lean.out $f > tmp && cat tmp > $f; done
2019-08-09 11:11:34 +02:00
Leonardo de Moura
1b5fc0e2c1 fix(library/init/data/array/basic): incorrect universe level 2019-08-07 11:33:23 -07:00
Leonardo de Moura
84c4637722 fix(library/init/data/array/basic): fix and rename eraseIdxSz ==> eraseIdx' 2019-08-02 14:06:35 -07:00
Leonardo de Moura
69bca3ad42 feat(library/init/data/array/basic): add version of Array.indexOf with property about resulting size 2019-08-02 13:31:29 -07:00
Leonardo de Moura
19e341cfcc feat(library/init/data/array/basic): add Array.indexOf and Array.eraseIdx 2019-08-02 13:31:29 -07:00
Leonardo de Moura
c371b43970 feat(library/init/data): add PersistentHashMap 2019-08-02 13:31:29 -07:00
Rob Dockins
a9ebf23fab fix(libraray/init/data): generalize universe variables in array and persistent array operations
This change allows the monadic traversal operations on arrays to use monads that
are defined to raise universe levels.  This happens, for example, when defining
monads using certain continuation-passing idioms.
2019-07-11 17:52:04 -07:00
Leonardo de Moura
1a81d60820 chore(frontends/lean/parser): simplify binder notation
The `<ident> : <expr>` now requires explicit brackets.
2019-07-08 08:54:19 -07:00
Leonardo de Moura
9d5b0fd309 feat(library/init/data/array/basic): add findRev 2019-07-05 15:51:25 -07:00
Leonardo de Moura
ea6eee516b chore(frontends/lean): use => instead of := in match-expressions
Motivation: use same separator used in lambda expressions as in
other programming languages.
2019-07-04 11:38:38 -07:00
Leonardo de Moura
07cff06b6e chore(library): Π ==> 2019-07-02 17:35:15 -07:00
Leonardo de Moura
a02443d23d chore(frontends/lean): fun x, e ==> fun x => e 2019-07-02 13:22:11 -07:00
Leonardo de Moura
e29bf35d15 chore(frontends/lean/builtin_exprs): remove hard coded (::) notation 2019-07-02 11:01:05 -07:00
Leonardo de Moura
6841e47aa4 chore(frontends/lean/builtin_exprs): remove support for (<infix>) and (<infix> <expr>) notations
In Lean 4, we will support the more general

`a + ·` ==> `fun x, a + x`
`· + b` ==> `fun x, x + b`
`· + ·` ==> `fun x y, x + y`
`f · y` ==> `fun x, f a y`
`g · · b` ==> `fun x y, g x y b`
2019-07-02 08:06:06 -07:00
Leonardo de Moura
91e1d30cf8 feat(frontends/lean/builtin_exprs): use ; in do-notation 2019-06-27 18:00:43 -07:00
Leonardo de Moura
ab487ea4ac feat(frontends/lean): allow ; instead of in in let-decls 2019-06-27 17:12:03 -07:00
Leonardo de Moura
af2d6dbd45 chore(library/init): avoid local attribute 2019-06-24 15:48:11 -07:00
Leonardo de Moura
0f43c2e2d9 feat(library/init/data/array/basic): efficient heterogeneous Array.map
This commit also removes Array.hmap.
Motivation: I wanted to use Array.hmap as an example in the paper, but
I found it would be too distracting to explain why we had `Array.hmap`
and `Array.map`.

cc @kha
2019-05-25 16:32:59 -07:00
Leonardo de Moura
40ecbb7cbc feat(library/init/control/monad): mark monadInhabited as an instance 2019-05-20 09:33:17 -07:00
Leonardo de Moura
b717177a1a chore(library/init/data/array/basic): make sure Array.*foldl and List.*foldl have similar signatures 2019-05-07 15:23:03 -07:00
Leonardo de Moura
4e5121fb5b chore(library/init/data/array/basic): more general miterate2 mfold2 iterate2 fold2 2019-05-07 15:06:11 -07:00
Leonardo de Moura
4b4ff9bf69 feat(library/init/data/array/basic): add Array.mfor 2019-05-06 18:21:29 -07:00
Leonardo de Moura
c1fecc8939 feat(library/init/data/array/basic): add anyM and allM 2019-05-06 13:47:36 -07:00
Sebastian Ullrich
c77970a00f refactor(library): remove now-redundant parentheses 2019-05-03 13:57:21 +02:00
Leonardo de Moura
3628b39cb6 feat(library/init/lean/compiler): add simpcase transformation 2019-05-02 12:40:37 -07:00
Leonardo de Moura
81d11db5d2 chore(runtime/object): rename runtime primitives 2019-05-02 10:55:29 -07:00
Leonardo de Moura
4c9a488446 chore(library/init/data/array): naming convention
@kha Trying again :)
I started using the prefix `f` for the `Fin` version (e.g., `fswap` and
`fswapAt`). So, it seemed natural to use the prefix `f` for the `Fin`
versions of `get` and `set`.
BTW, is it too crazy to use `a[i]` (without spaces) as notation for
`a.get i`? The constraint is to make sure `f a [i]` is not ambiguous.
That is, `f a[i]` is `f (a.get i)` and `f a [i]` is `f a (i::nil)`.
This is doable with the new parser.

Then, we could have `a[i]` as notation for `a.fget i` if `i` is a `Fin`,
and `a.get i` if `i` is `Nat`.
Similarly, `a[i := v]` would be notation for `a.fset i v` if `i` is
`Fin`, and `a.set i` if `i` is `Nat`.

It would also be awesome to have
```
let a[i] := v in
e
```
as notation for
```
let a := a[i := v] in
```
2019-05-02 10:23:53 -07:00
Leonardo de Moura
970941db2c feat(library/init/data/array/basic): add Array.filter 2019-05-02 09:51:08 -07:00
Leonardo de Moura
5a83a2d7bb feat(library/init/data/array/basic): add swapAt 2019-05-02 07:46:11 -07:00
Leonardo de Moura
e52e787ad5 fix(library/init/lean/compiler/pushproj): bug and cleanup 2019-05-01 21:01:03 -07:00
Leonardo de Moura
2991b966e5 featg(library/init/lean/compiler): add pushproj 2019-05-01 17:38:44 -07:00
Leonardo de Moura
1707628b6b feat(library/init/data/array/basic): Array.reverse 2019-05-01 17:38:44 -07:00
Leonardo de Moura
af1d521706 feat(library/init/data/array/basic): add Array.swap 2019-05-01 17:38:44 -07:00
Leonardo de Moura
711fab451b refactor(library/init/data/array): Array.foldl argument order 2019-04-29 10:48:33 -07:00
Leonardo de Moura
63442ebde7 feat(library/init/data/array/basic): add iterate₂ and foldl₂ 2019-04-29 10:48:33 -07:00
Leonardo de Moura
df84868ab4 feat(library/init/data/array/basic): array helper functions 2019-04-28 10:10:24 -07:00
Leonardo de Moura
c6d0083456 fear(library/init/data/array/basic): add Array.modify 2019-04-26 14:41:17 -07:00
Leonardo de Moura
b1503f2c56 perf(library/init/data/array/basic): remove inefficient mforeachAux and add new hmmap and hmap
The `mforeachAux` function was keeping two references to the array
because it was implemented using `miterate a ⟨a, rfl⟩ ...`
Thus, we would have to allocate a new array even if `a` was not shared.

Another issue is that when invoking `x ← f i v`, the array would still
have a reference to `v`, and consequently `RC(v) > 1`, and `f` would not
be able to perform destructive updates to `v` or reuse its memory cell.

Thus, I removed `mforeach` (we only used it to implement `hmap`: the
homogeneous map), and implemented a new `hmap` which makes sure
destructive updates can be performed modulo the issue with float `let`
inwards I described in the previous commit.

@kha I found the problem described in the previous commit when I was
using `Array.hmap`. If we use `Array`s to implement `Syntax` as we discussed,
then a `hmap` that does not prevent destructive updates from happening is
a must-have. Otherwise, any benefit we get from using `Array`s instead
of `List`s is gone.
2019-04-19 14:52:52 -07:00
Leonardo de Moura
549b07a815 chore(library/init/data/array/basic): missing [inline] 2019-04-19 14:52:52 -07:00
Leonardo de Moura
62b8954ec4 chore(library/init/data/array/basic): heterogeneous Array.mmap 2019-04-19 14:52:52 -07:00
Leonardo de Moura
52b72c85bf fix(library/init/data/array/basic): typo 2019-04-12 09:03:20 -07:00
Leonardo de Moura
804ff74350 feat(library/init/data/array/basic): add Array.back 2019-04-10 08:56:42 -07:00
Leonardo de Moura
9c81cd7f1d feat(library/init/data/array/basic): add Array.extract 2019-04-07 13:08:23 -07:00
Leonardo de Moura
8d2d43beb2 feat(library/init/data/array/basic): add shrink 2019-04-07 12:42:56 -07:00
Leonardo de Moura
4d3689ea33 feat(library/init/data/array/basic): add new array functions
@kha I renamed the homogeneous `map` to `hmap`, and added the
heterogeneous one as `map`. As soon as we add user-defined rewriting
rules, we will be able to replace `map` with `hmap` whenever the types
are the same.
2019-04-06 19:25:32 -07:00
Leonardo de Moura
273a0775d6 perf(library/init/data/array): mkArray in Lean doesn't seem to buy us anything
The primitive implementation combines all `inc`'s into a single one.
2019-04-03 10:27:58 -07:00
Leonardo de Moura
568b598729 fix(library/init/data/array/basic): incorrect borrow annotation 2019-04-03 05:50:53 -07:00
Leonardo de Moura
5e1a3a7e6a feat(library/init/data/array/basic): make sure we reduce List.length too at List.toArray 2019-04-01 10:54:45 -07:00
Leonardo de Moura
e58949e938 chore(library/init/control/id): rename id monad to Id 2019-03-29 16:45:52 -07:00