Commit graph

22902 commits

Author SHA1 Message Date
Sebastian Ullrich
2afbb2ce42 doc: fix 2020-12-09 11:07:02 +01:00
Sebastian Ullrich
f4267c9bf8 chore: revise Syntax.Traverser changes 2020-12-09 10:38:22 +01:00
Leonardo de Moura
7705769139 doc: default instances and heterogeneous operators 2020-12-08 18:56:30 -08:00
Leonardo de Moura
4d6b80cd51 doc: structures 2020-12-08 16:25:19 -08:00
Leonardo de Moura
14c438234a chore: update stage0 2020-12-08 13:46:11 -08:00
Leonardo de Moura
f2339268b1 fix: adjust code to new match-compiler
In the new frontend,
```lean
@[macroInline] def or : Bool → Bool → Bool
  | true,  _ => true
  | false, b => b
```
is compiled as
```lean
def or (x y : Bool) : Bool :=
  or.match_1 _ x y (fun _ => true) (fun b => b)
```
Thus, the `[macroInline]` attribute does not guarantee that `y` is
evalutated only when `x` is `false`. The new definition does.

This issue was not exposed before because the compiler has an
optimization that float let-decls when they are used in a single
branch.

@Kha We have talked about removing `macroInline`, and defining
functions such as `or` as
```lean
@[inline] def or (x : Bool) (y : Unit -> Bool) : Bool :=
  match x with
  | true  => true
  | false => y ()
```
and define `x || y` as notation for `or x (fun _ => y)`.
I think this is the way to go for polymorphic operators such as `<|>`,
but I am not sure about `or`. New users will probably be puzzled by
it. In particular when they are writing proofs.
2020-12-08 13:46:00 -08:00
Leonardo de Moura
7a014d2ec1 chore: update stage0 2020-12-08 12:42:25 -08:00
Leonardo de Moura
f14826a730 fix: incorrect context used at addDecForDeadParams 2020-12-08 12:38:33 -08:00
Leonardo de Moura
9a422ddc23 fix: Array.back on empty array 2020-12-08 12:21:01 -08:00
Leonardo de Moura
2ebee8d00c fix: missing addJP 2020-12-08 12:09:52 -08:00
Leonardo de Moura
702c258773 fix: index out of bounds
@Kha Please take a look at `Traverser` and check whether the
workaround is appropriate or not.
2020-12-08 11:44:10 -08:00
Leonardo de Moura
6a41d04827 fix: missing panics 2020-12-08 10:36:53 -08:00
Leonardo de Moura
825bc3aa65 doc: array 2020-12-08 10:36:47 -08:00
Leonardo de Moura
ebf4a8877e chore: mark Neg Int as a default instance 2020-12-08 10:09:58 -08:00
Leonardo de Moura
1509a1ab18 doc: builtin types 2020-12-08 10:09:58 -08:00
Sebastian Ullrich
a20f7a2e8e chore: Elab.Quotation: avoid non-builtin syntax 2020-12-08 18:03:21 +01:00
Sebastian Ullrich
037144d3bd refactor: Delaborator.Builtins: eliminate remainder of manual syntax 2020-12-08 17:53:58 +01:00
Sebastian Ullrich
3c9619ed09 feat: Syntax.isNone: return true on missing 2020-12-08 17:33:51 +01:00
Sebastian Ullrich
e6493755e9 chore: stdlib: match_syntax ~> match 2020-12-08 17:32:02 +01:00
Sebastian Ullrich
194e635a6e chore: update stage0 2020-12-08 17:24:47 +01:00
Sebastian Ullrich
290e1cf15f feat: syntax_match: check arity only for nullKind nodes 2020-12-08 17:20:36 +01:00
Sebastian Ullrich
00e167b2f0 feat: match_syntax ~> match 2020-12-08 17:20:36 +01:00
Sebastian Ullrich
6fac0c0b16 feat: support syntax patterns in do 2020-12-08 17:20:36 +01:00
Sebastian Ullrich
93a9d79088 refactor: move around quotation helpers once more 2020-12-08 17:20:36 +01:00
Sebastian Ullrich
dcd3b90522 chore: update stage0 2020-12-08 17:16:00 +01:00
Sebastian Ullrich
32eeac88c8 fix: ensure matchAlts have same shape with and without optionalFirstBar 2020-12-08 17:13:32 +01:00
Sebastian Ullrich
6fc03d0f29 feat: quotation scopes in match_syntax 2020-12-08 17:13:32 +01:00
Sebastian Ullrich
c63b770a7c refactor: reduce dependencies on Lean.Elab.Quotation 2020-12-08 17:13:32 +01:00
Sebastian Ullrich
73ae39313d fix: Nix: better stage 0 detection 2020-12-08 17:13:32 +01:00
Sebastian Ullrich
b12be950bf feat: support complex antiquotations in antiquotation scopes 2020-12-08 17:13:32 +01:00
Leonardo de Moura
12e22cf439 chore: update stage0 2020-12-08 06:24:17 -08:00
Leonardo de Moura
ae5aa51712 chore: add explicit discard 2020-12-08 06:18:18 -08:00
Leonardo de Moura
071c0fdcec chore: update stage0 2020-12-08 06:18:18 -08:00
Leonardo de Moura
06ad52575a feat: force users to use discard when action result is not being bound and it is not PUnit
After this commit, we have to use an explicit `discard` in code such as
```
def g (x : Nat) : IO Nat := ...
def f (x : Nat) : IO Unit := do
  discard <| g x   -- type error without the `discard`
  IO.println x
```

Motivation: prevent users from making mistakes such as
```
def f (xs : Array Nat) : IO Unit := do
  xs.set! 0 1
  IO.println xs
```
when they meant to write
```
def f (xs : Array Nat) : IO Unit := do
  let xs := xs.set! 0 1
  IO.println xs
```
2020-12-08 06:14:48 -08:00
Leonardo de Moura
6dddcde25c chore: increase priority of defaultInstance for heterogeneous operators
@Kha The motivation is to allow users to define default instances such as
```lean
@[defaultInstance 1]
instance : OfScientific Real where
  ...
```
Then, numerals such as `1.2` and `3.4e10` will be `Real` by default instead of `Float`.
2020-12-07 16:58:34 -08:00
Leonardo de Moura
eb11416edc doc: auto bound implicit arguments 2020-12-07 16:38:55 -08:00
Leonardo de Moura
d4c67a6bf0 doc: implicit arguments 2020-12-07 16:12:16 -08:00
Leonardo de Moura
1c8432b814 doc: Type* as a macro 2020-12-07 15:14:52 -08:00
Leonardo de Moura
021d5804f8 doc: add deptypes section 2020-12-07 13:58:52 -08:00
Leonardo de Moura
7e4b7e1400 fix: getFunBinderIds 2020-12-07 12:15:55 -08:00
Leonardo de Moura
9eef4bc65c chore: update stage0 2020-12-07 10:48:44 -08:00
Leonardo de Moura
cbf2b6c0db feat: change synthinstance threshold
Before this commit, the threshold was the amount of "fuel".
Now, it is the maximum number of instances used to solve a TC problem.
We have two thresholds
- `maxInstSize`: default 128
- `maxCoeSize`: default 16. It is similar to `maxInstSize`, but used for automatic coercions.

cc @Kha
2020-12-07 10:45:08 -08:00
Leonardo de Moura
a08dcef4f6 chore: update stage0 2020-12-06 19:08:18 -08:00
Leonardo de Moura
6af3eac142 feat: add MonadStateCacheT based on StateT 2020-12-06 19:07:28 -08:00
Leonardo de Moura
906cb81319 feat: improve inferAppType
See comment at `Expr.instantiateRevRange`
2020-12-06 19:01:23 -08:00
Leonardo de Moura
32325838a3 chore: fix test 2020-12-06 19:00:24 -08:00
Leonardo de Moura
91dec25a35 fix: bug at runST and runEST 2020-12-06 18:52:28 -08:00
Leonardo de Moura
265b7571b4 chore: change checkCache type 2020-12-06 16:24:51 -08:00
Leonardo de Moura
d25f520143 feat: elaborate #reduce command 2020-12-06 10:54:57 -08:00
Leonardo de Moura
e2c934ccea chore: update stage0 2020-12-06 09:33:26 -08:00