Commit graph

171 commits

Author SHA1 Message Date
Leonardo de Moura
2120883307 refactor: heterogeneous operators
@Kha I had some unexpected surprises, but it is a good change.
Here is the summary.

1- We could get rid of `a %ₙ b` and `ModN` class. We can use `HMod`
instead. It was a positive surprise since I didn't remember we had
this `ModN` class.

2- Coercions are never used in heterogeneous operators. This is
expected since `a * b` is now notation for `HMul.hMul a b`, and
`a` and `b` may have different types. I manually added instances such
as `HMul Nat Int Int`. However, I did not try to add generic instances
such as
```
instance [Coe a b] [Mul b] : HMul a b b where
  hMul x y := mul (coe x) y
```
I will try later.

3- Give `h : cs.size > 0`, I got a type error at
```
let idx : Fin cs.size := ⟨cs.size - 1, Nat.predLt h⟩
```
`Nat.predLt h` has type `Nat.pred cs.size < cs.size`
However, `Nat.pred cs.size` doesn't unify with `cs.size - 1`.
The problem is that we can't synthesize the `HSub` instance until
we apply the default instances.
It worked before because `isDefEq` would force the pending TC
problem `Sub Nat` to be resolved, and after that we would be able
to reduce `cs.size - 1` and establish that it is definitionally
equal to `Nat.pred cs.size`.
I considered two possible workarounds
a) `let idx : Fin cs.size := ⟨cs.size - (1:Nat), Nat.predLt h⟩`
b) `let idx : Fin cs.size := ⟨cs.size - 1, by exact Nat.predLt h⟩`
The first one works because we are not providing enough information
for synthesizing the `HSub` instance. The second works because it
postpones the elaboration of `Nat.predLt h`. The default instances
will be applied before we start applying tactics.

4- The `.` notation is affected too. For example, `(x + 1).toUInt8`
doesn't work since we don't know the type of `x+1` until we apply
default instances. I fixed it by using `(x + (1:Nat)).toUInt8`.
Another possible fix is `Nat.toUInt8 (x + 1)`.
Similarly, `(x+1).fold ...` doesn't work.

5- The following code failed to be elaborated
```
indent (push s!"{ss'}\n") (some (0 - Format.getIndent (← getOptions)))
```
It was working before, but it relied on how the expected type is
propagated. The elaborator process
```
some (0 - Format.getIndent (← getOptions))
```
with expected type `(Option Int)`. So, the `-` is interpreted as
`Int.sub` although `Format.getIndent (← getOptions)` has type `Nat`.
In the new `HSub`, the expected type doesn't really influence TC
resolution since it is an `outparam`. So, we failed with the error
failed to synthesize `HSub Nat Nat Int`.
One possible fix was to add the instance `HSub Nat Nat Int` with
`Int.sub`, but I used the following fix
```
some ((0 : Int) - Format.getIndent (← getOptions))
```
which makes it clear that we want the `Int.sub` operator instead of
`Nat.sub`.
2020-12-01 14:02:46 -08:00
Leonardo de Moura
e3fb7010f1 chore: fix tests 2020-11-25 09:25:45 -08:00
Leonardo de Moura
b6a1914299 chore: remove $. notation
It has been replaced by `|>.`
2020-11-19 08:47:35 -08:00
Leonardo de Moura
7e533b4650 refactor: use Lists for Array reference implementation
Motivation: better reduction in the kernel.

cc @Kha
2020-11-17 17:05:53 -08:00
Leonardo de Moura
dbf99a17b6 chore: define notation using infix commands 2020-11-11 08:26:12 -08:00
Leonardo de Moura
7e8a7e6660 feat: elaborate fun/forall binder extensions 2020-11-09 19:00:40 -08:00
Leonardo de Moura
6c6595cd9b feat: only allow variables declared with mut to be reassigned 2020-11-07 17:32:13 -08:00
Leonardo de Moura
1c558d279f feat: add mut modifier to doLet 2020-11-07 17:32:13 -08:00
Leonardo de Moura
f9194737f0 chore: fix tests 2020-10-31 19:19:18 -07:00
Leonardo de Moura
4ba21ea10c chore: cleanup src/Array/Basic.lean 2020-10-28 19:35:42 -07:00
Leonardo de Moura
898a08a0c1 chore: avoid Has prefix in type classes
closes #203
2020-10-27 18:29:19 -07:00
Leonardo de Moura
10c32fcf94 chore: HasToString => ToString 2020-10-27 16:11:48 -07:00
Sebastian Ullrich
6fb0ae91c7 test: fix tests 2020-10-27 16:50:58 +01:00
Leonardo de Moura
db9e390b4d chore: remove new_frontend from tests 2020-10-25 09:16:38 -07:00
Leonardo de Moura
fa101444b4 chore: fix tests 2020-10-25 09:11:13 -07:00
Leonardo de Moura
a4c69ec32c chore: fix tests 2020-10-24 16:46:21 -07:00
Leonardo de Moura
21587ff19b chore: move tests to new frontend 2020-10-23 16:18:52 -07:00
Leonardo de Moura
8cb1ff206c chore: move tests to new frontend 2020-10-23 14:07:26 -07:00
Leonardo de Moura
7111eb4d79 chore: move to new frontend 2020-10-21 13:30:43 -07:00
Leonardo de Moura
192d45d867 chore: fix tests 2020-10-20 16:15:30 -07:00
Leonardo de Moura
2899e09754 chore: fix test 2020-10-14 13:23:25 -07:00
Leonardo de Moura
dc670bfd5d fix: handle optParam at consumeImplicits
`consumeImplicits` is used during LVal resolution.
2020-10-11 15:26:10 -07:00
Leonardo de Moura
adc33da468 chore: $. and · 2020-10-11 15:08:12 -07:00
Leonardo de Moura
89eebc9534 fix: use resolveGlobalConstNoOverload at init attribute handler 2020-10-10 11:37:37 -07:00
Leonardo de Moura
63edecf106 feat: expand initialize macro 2020-10-10 08:23:49 -07:00
Leonardo de Moura
f80345a6d4 chore: move tests to new frontend 2020-10-10 07:41:04 -07:00
Leonardo de Moura
5a40d9eb13 feat: add Subarray 2020-10-09 16:06:24 -07:00
Leonardo de Moura
ac07999e95 chore: cleanup do expander, and make sure it can handle the "easy" doLetArrows 2020-10-07 17:00:07 -07:00
Sebastian Ullrich
c3ebb6ad1f fix: Format.group ignored preceding content on line 2020-10-07 09:43:05 +02:00
Leonardo de Moura
0447966b72 chore: adjust elaborator to new syntax 2020-10-06 06:53:12 -07:00
Leonardo de Moura
a84b3ac8de chore: fix old elabDo and test 2020-10-03 08:36:22 -07:00
Leonardo de Moura
40640b85bd fix: doSeqBracketed parser
It was failing to parse
```
def f2 (x : Nat) : IO Nat := do {
  let y := 1;
  if x > 0 then
    y := y + 1;
  IO.println y
}
```

cc @Kha
2020-10-02 15:05:22 -07:00
Leonardo de Moura
65834b95ff chore: fix test 2020-09-28 17:11:00 -07:00
Leonardo de Moura
7f2c5ffd9a chore: fix test 2020-09-28 17:10:57 -07:00
Leonardo de Moura
a0a724ddbd fix: tests and elabDo 2020-09-26 19:12:01 -07:00
Leonardo de Moura
6892a957d6 feat: trailing ; in indented "do" sequences
cc @Kha
2020-09-26 16:08:30 -07:00
Leonardo de Moura
13ded3f964 chore: use doElem category 2020-09-26 12:51:24 -07:00
Leonardo de Moura
98f7e9b3e4 chore: naming convention 2020-09-24 19:22:24 -07:00
Sebastian Ullrich
77cbaa752c fix: Task: make reference and -j0 semantics eager, simplify 2020-09-14 17:57:33 +02:00
Leonardo de Moura
250dc3e3a9 fix: adjust expanders and elaborators to new matchAlts node 2020-09-04 18:59:28 -07:00
Sebastian Ullrich
c88784ef9d refactor: consistent io_result_mk* naming
/cc @leodemoura
2020-08-31 11:08:57 +02:00
Sebastian Ullrich
eb5a171764 feat: adjust semantics to new syntax 2020-08-19 09:56:23 -07:00
Leonardo de Moura
3342ba08d2 feat: implement let elaborators without using match_syntax
@Kha I had to do this because of the `ident` vs `Term.id` recurrent
issue. `match_syntax` fails if a `Term.id` is used at `Term.letIdDecl`
where an `ident` is expected.
We should try to remove `Term.id` in the future.
2020-08-17 09:27:54 -07:00
Leonardo de Moura
d1d91b3a50 chore: fix test 2020-08-10 11:19:05 -07:00
Leonardo de Moura
e59735bde9 chore: fix test
@Kha the tests `Reparen.lean` and `Reformat.lean` are still
broken. Could you please take a look?
They broke because I changed the `match` syntax at 3ce794c58.
2020-08-10 10:20:57 -07:00
Sebastian Ullrich
a0b0dbd0ac fix: formatStx 2020-08-06 09:27:12 -07:00
Sebastian Ullrich
c8b6020bb3 test: do not ignore whitespace in diff
It doesn't look like we were relying on it much
2020-08-06 09:26:48 -07:00
Leonardo de Moura
cbb14673ef chore: move RBTree and RBMap to Std 2020-06-25 13:26:16 -07:00
Leonardo de Moura
657879fcaa chore: fix tests 2020-06-25 11:58:49 -07:00
Leonardo de Moura
77e1260ed2 chore: simplify checkPrec 2020-06-10 14:34:58 -07:00