Commit graph

26741 commits

Author SHA1 Message Date
Leonardo de Moura
f896bb27d6 chore: update stage0 2020-12-03 10:46:45 -08:00
Leonardo de Moura
963b0f1270 feat: scoped attributes cont. 2020-12-03 10:46:09 -08:00
Leonardo de Moura
4a879fcd2c chore: update stage0 2020-12-03 10:40:35 -08:00
Leonardo de Moura
2408b5c6b5 feat: basic support for scoped attributes 2020-12-03 10:39:59 -08:00
Sebastian Ullrich
23b0e6ca5b fix: Nix: use stage 1 outside of src/
Hopefully we can solve this using a src/flake.nix as soon as relative flake inputs are supported
2020-12-03 18:49:29 +01:00
Sebastian Ullrich
58dc7a791f refactor: more dynamic quot tests 2020-12-03 18:21:16 +01:00
Sebastian Ullrich
e0016662c6 refactor: test dynmaic quotations
/cc @leodemoura
2020-12-03 18:05:15 +01:00
Sebastian Ullrich
e74e72a938 chore: update stage0 2020-12-03 17:58:30 +01:00
Sebastian Ullrich
dbf9fc9799 feat: elaborate dynamic quotations 2020-12-03 17:58:30 +01:00
Sebastian Ullrich
07ba3cd171 chore: update stage0 2020-12-03 17:57:40 +01:00
Sebastian Ullrich
80d4ae82e8 feat: arbitrary quotation kinds via name resolution in the parser and execution in the interpreter 2020-12-03 17:46:13 +01:00
Sebastian Ullrich
21f4257da5 feat: name resolution during parsing 2020-12-03 17:46:13 +01:00
Leonardo de Moura
f4c9f9579b chore: update stage0 2020-12-03 08:08:58 -08:00
Leonardo de Moura
b95c4788c1 refactor: OfDecimal ==> OfScientific
`decimalLit` ==> `scientificLit`
2020-12-03 08:08:19 -08:00
Leonardo de Moura
d1f4d4f57e feat: scientific notation 2020-12-03 07:49:20 -08:00
Leonardo de Moura
962cffbaaa feat: add lean_float_of_decimal using GMP 2020-12-03 06:15:18 -08:00
Leonardo de Moura
e8b58abffc chore: update stage0 2020-12-02 15:32:17 -08:00
Leonardo de Moura
85c9ab072c feat: elaborate and delaborate decimals 2020-12-02 15:31:06 -08:00
Leonardo de Moura
983a1e596b chore: update stage0 2020-12-02 14:57:26 -08:00
Leonardo de Moura
facb28d080 feat: basic support for decimal numbers 2020-12-02 14:54:59 -08:00
Leonardo de Moura
133ecb111b chore: remove workaround 2020-12-02 13:33:45 -08:00
Leonardo de Moura
6f9d3a1447 chore: update stage0 2020-12-02 13:29:58 -08:00
Leonardo de Moura
469de09280 fix: bug at isDefEq
The new test contains a minimal example that triggers the bug.
2020-12-02 13:27:21 -08:00
Leonardo de Moura
3a08dd2771 chore: typo 2020-12-02 13:27:21 -08:00
Sebastian Ullrich
d96393ee47 doc: building Lean packages with Nix 2020-12-02 17:52:57 +01:00
Sebastian Ullrich
2437b1cea1 fix: support single-file packages 2020-12-02 17:29:01 +01:00
Sebastian Ullrich
797bec86f5 chore: Nix: overhaul nix-dev, lift technical restrictions 2020-12-02 16:49:25 +01:00
Sebastian Ullrich
b90f93966d fix: Nix: add transitive external dependencies to the LEAN_PATH 2020-12-02 13:59:19 +01:00
Leonardo de Moura
c2ea02b7c4 chore: update stage0 2020-12-01 18:42:41 -08:00
Leonardo de Moura
c476954eef feat: heterogeneous OrElse and AndThen
@Kha I had a few issues similar to the `Append` issues.
We used a similar idiom for writing builtin parsers where we may write
```
def p : Parser := "foo " >> "bla "
```
as a shorthand for
```
def p : Parser := symbol "foo " >> symbol "bla "
```
I want to support `builtin syntax` one day :)

That being said, we should decide whether we keep `HAppend`, `HOrElse`,
and `HAndThen` or not.
The only one I wish I had in the past is `HAndThen`.
2020-12-01 18:32:24 -08:00
Leonardo de Moura
892e9c63ec chore: update stage0 2020-12-01 16:43:17 -08:00
Leonardo de Moura
9d304df757 feat: heterogeneous Append experiment
@Kha This one required a bunch of manual fixes. The main issue is that
before we added the string interpolation feature, we created
`MessageData`s using `++` and coercions. For example, given
`(e : Expr)`, we would write
```
let msg : MessageData := "type: " ++ e
```
and rely on the coercions `String -> MessageData` and
`Expr -> MessageData`, and the instance `Append MessageData`.
However, heterogeneous operators "block" the expected type propagation downwards.
This kind of code is obsolete now since we can write a more compact
version using string interpolation
```
let msg := m!"type: {e}"
```
2020-12-01 16:32:41 -08:00
Leonardo de Moura
baabfc13e0 chore: remove occurrences of Append.append 2020-12-01 15:44:03 -08:00
Leonardo de Moura
e31b17484a feat: add instances from coe + homogeneous operator to heterogeneous operator
@Kha The new `rational.lean` test shows their usefulness. We just
define the monorphic version and a coercion, and get a bunch of `HAdd`
instances for free.
2020-12-01 15:30:10 -08:00
Leonardo de Moura
599c2f68ef chore: update stage0 2020-12-01 15:09:07 -08:00
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
574aa62fa8 chore: update stage0 2020-12-01 12:42:00 -08:00
Leonardo de Moura
d629c76f9e chore: more heterogeneous operators support 2020-12-01 12:39:45 -08:00
Sebastian Ullrich
0242b0e1eb fix: test 2020-12-01 12:05:54 -08:00
Sebastian Ullrich
3aad1348ff chore: add back removed prefix operators as non-builtins 2020-12-01 12:01:23 -08:00
Sebastian Ullrich
5c047e392f chore: update stage0 2020-12-01 12:01:23 -08:00
Sebastian Ullrich
32618b0398 chore: remove built-in prefix operators
To reappear soon
2020-12-01 11:57:20 -08:00
Sebastian Ullrich
5b2b2d8069 chore: declare ASCII notations first 2020-12-01 11:57:20 -08:00
Sebastian Ullrich
1f9e8bc93d fix: <&> 2020-12-01 11:57:20 -08:00
Sebastian Ullrich
07f25a19db chore: remove obsolete builtin delaborators 2020-12-01 11:57:20 -08:00
Sebastian Ullrich
d18596d4ca feat: add Unexpander for delaborating without importing Lean, use for simple notations
/cc @leodemoura
2020-12-01 11:57:20 -08:00
Sebastian Ullrich
4843f933fa feat: mkAntiquotNode 2020-12-01 11:57:20 -08:00
Sebastian Ullrich
39edb949c1 feat: allow KeyedDeclsAttribute without built-in attribute 2020-12-01 11:57:20 -08:00
Leonardo de Moura
a1f6fc8382 chore: update stage0 2020-12-01 11:56:11 -08:00
Leonardo de Moura
e213a7ecca feat: add support for heterogeneous operators at Offset.lean 2020-12-01 11:53:44 -08:00