Commit graph

18672 commits

Author SHA1 Message Date
Leonardo de Moura
1c99fe92ac feat: add dotIdent parser
see #944
2022-03-10 16:04:41 -08:00
Leonardo de Moura
3214a20d33 feat: allow overloaded notation in patterns 2022-03-10 12:51:34 -08:00
Leonardo de Moura
fddc8b06ac fix: missing case at getStuckMVar?
Fix issue reported at
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/'rewrite'.20failed.20but.20it.20should.20work/near/274870747
2022-03-10 10:33:11 -08:00
Leonardo de Moura
92318d07bb feat: add MonadBacktrack instance for CollectPatternVars.M monad 2022-03-10 10:23:18 -08:00
Leonardo de Moura
7a39be225d refactor: move methods to MetaM 2022-03-10 10:00:46 -08:00
Leonardo de Moura
2fb9a39cb4 refactor: implement MonadQuotation at CoreM 2022-03-10 09:55:20 -08:00
Leonardo de Moura
7850dc023b fix: make sure the structure instance notation does not leak auxiliary type annotations (e.g., autoParam and optParam) 2022-03-10 08:41:00 -08:00
Leonardo de Moura
efc89eb4e1 fix: make sure inferProjType consume auxiliary type annotations 2022-03-10 08:15:34 -08:00
Leonardo de Moura
0ef8aaeda0 feat: make sure minor premises in recursors do not include auxiliary type annotations (e.g., autoParam and optParam) 2022-03-10 08:08:36 -08:00
Leonardo de Moura
1afee372f7 refactor: move consume_type_annotations declaration to expr.h 2022-03-10 08:00:39 -08:00
Leonardo de Moura
33883e9d2a fix: resulting type of projection functions should not include auxiliary type annotations (e.g., autoParam) 2022-03-10 07:47:38 -08:00
Leonardo de Moura
5825eb394f refactor: move isOutParam to Expr.lean, rename consumeAutoOptParam => consumeTypeAnnotations 2022-03-10 07:37:41 -08:00
Leonardo de Moura
38668308ef fix: do not rename metavariables that are already in the patternVars array
It fixes a regression introduced yesterday.
2022-03-10 05:53:54 -08:00
Leonardo de Moura
9c5f6361a3 doc: document the new pattern elaboration procedure 2022-03-09 18:58:23 -08:00
Leonardo de Moura
ca253c43e1 refactor: pattern elaboration
We don't use the following hack anymore:
-  /- HACK: `fvarId` is not in the scope of `mvarId`
-     If this generates problems in the future, we should update the metavariable declarations. -/
-  assignExprMVar mvarId (mkFVar fvarId)

This hack was corrupting the `InfoTree`.
2022-03-09 18:19:14 -08:00
Leonardo de Moura
b0246172fa chore: add comment and remove dbg trace message 2022-03-09 14:02:30 -08:00
Leonardo de Moura
caa1366b62 fea: erase nested inaccessible annotations 2022-03-09 14:01:59 -08:00
Leonardo de Moura
1609f96128 refactor: simplify PatternVar.lean and Match.lean 2022-03-09 14:01:40 -08:00
Leonardo de Moura
74411aa472 fix: do not display implicit fields 2022-03-09 12:33:22 -08:00
Leonardo de Moura
50ae170bcc feat: allow mkLambdaFVars and mkForallFVars to abstract unassigned metavars too 2022-03-09 11:27:58 -08:00
Leonardo de Moura
4660485ac8 refactor: collectDeps => collectForwardDeps 2022-03-09 11:27:58 -08:00
Leonardo de Moura
5636c94cd0 chore: remove old comment, simplify exception 2022-03-09 11:27:58 -08:00
Leonardo de Moura
1263cea6af feat: add support for unassigned metavariables at dependsOn 2022-03-09 11:27:58 -08:00
Leonardo de Moura
164f07a5e5 feat: generalize Expr.abstractRange
It now takes free variables **and** metavariables.
This is the first step to make `mkForallFVars` and `mkLambdaFVars`
more general.
2022-03-08 18:19:17 -08:00
Leonardo de Moura
d6b782f811 chore: remove workaround
for regression introduced by the following change

* Auto implicit behavior changed for inductive families. An auto implicit argument occurring in inductive family index is also treated as an index (IF it is not fixed, see next item)
2022-03-08 17:58:20 -08:00
Leonardo de Moura
4ee131981d feat: in an inductive family the longest fixed prefix of indices is now promoted to parameters
This modification is relevant for fixing regressions on recent changes
to the auto implicit behavior for inductive families.

The following declarations are now accepted:
```lean
inductive HasType : Fin n → Vector Ty n → Ty → Type where
  | stop : HasType 0 (ty :: ctx) ty
  | pop  : HasType k ctx ty → HasType k.succ (u :: ctx) ty

inductive Sublist : List α → List α → Prop
  | slnil : Sublist [] []
  | cons l₁ l₂ a : Sublist l₁ l₂ → Sublist l₁ (a :: l₂)
  | cons2 l₁ l₂ a : Sublist l₁ l₂ → Sublist (a :: l₁) (a :: l₂)

inductive Lst : Type u → Type u
  | nil  : Lst α
  | cons : α → Lst α → Lst α
```

TODO: universe inference for `inductive` should be improved. The
current approach is not good enough when we have auto implicits.

TODO: allow implicit fixed indices that do not depend on indices that
cannot be moved to become parameters.
2022-03-08 17:56:34 -08:00
Leonardo de Moura
234046521a feat: print number of parameters for an inductive type 2022-03-08 17:48:46 -08:00
Leonardo de Moura
7b84b4cdaa fix: improve inductive indices elaboration
TODO: convert fixed indices to parameters. Motivation: types such as
```lean
inductive Foo : List α → Type
  | mk : Foo []
```
Users should not need to write
```lean
inductive Foo {α} : List α → Type
  | mk : Foo []
```
2022-03-08 17:48:46 -08:00
Leonardo de Moura
f74513384e refactor: cleanup addAutoBoundImplicits 2022-03-08 17:48:46 -08:00
Sebastian Ullrich
e9b8e54dcc feat: scientific parser alias for scientificLit 2022-03-08 18:54:05 +01:00
Jonathan Coates
11cce61e4d chore: Clean up LSP folding a little
- Wait for all terms to be elaborated before showing folding regions.
   May want to change this to support partial results.
 - Use .span to extract import statements, rather than mutually
   recursive functions.
 - Some tiny other bits of cleanup
2022-03-07 17:23:35 +01:00
Jonathan Coates
04e60cebd1 feat: LSP code folding support
The following constructs are foldable:
 - Sections and namespaces
 - Blocks of import/open statements
 - Multi-line commands (so mostly definitions)
 - Mutual definitions
 - Module-level doc comments
 - Top-level definition doc comments

Fixes #1012
2022-03-07 17:23:35 +01:00
Sebastian Ullrich
f2d5470f19 feat: allow interpretation of constants initialized by native code 2022-03-07 10:59:49 +01:00
Sebastian Ullrich
ff097e952f chore: link orphan file 2022-03-07 10:59:49 +01:00
Leonardo de Moura
619186b2a8 feat: only use set_option codegen false where needed 2022-03-06 19:15:05 -08:00
Leonardo de Moura
46d1111d3d fix: typo at unfoldBothDefEq 2022-03-06 13:54:42 -08:00
Leonardo de Moura
ff0f3bfc61 fix: interaction between overloaded notation and delayed coercions
The new test exposes this issue.
2022-03-06 09:49:15 -08:00
Leonardo de Moura
b664a93d8e fix: a match application is stuck if one of the discriminants contain metavariables 2022-03-06 07:51:09 -08:00
Leonardo de Moura
8bcaafb28b fix: universe metavariables should not be taken into account at getKeyArgs 2022-03-06 07:50:19 -08:00
Leonardo de Moura
b105c006a5 fix: PrefixTree WellFormed type
`β` is a parameter.
2022-03-06 07:30:34 -08:00
Leonardo de Moura
1450a86c4d feat: include types in the "ambiguous, possible interpretations" error message 2022-03-06 07:26:31 -08:00
Leonardo de Moura
d3b2028a05 feat: add Fin.succ 2022-03-05 17:36:38 -08:00
Leonardo de Moura
3f9c854194 feat: auto local implicit chaining 2022-03-05 17:30:15 -08:00
Leonardo de Moura
f7130d8e07 refactor: use CPS at addAutoBoundImplicits
We want to be able to declare new local variables there.
2022-03-05 16:24:33 -08:00
Leonardo de Moura
22731c02b0 fix: auto implicit locals in inductive families 2022-03-05 15:47:20 -08:00
Leonardo de Moura
613cf19509 fix: discrimination trees and "stuck" terms
See comments and new test.
2022-03-05 15:12:20 -08:00
Leonardo de Moura
d39102f865 fix: smart unfolding for reducible definitions
When `TransparencyMode.reducible`, smart unfolding for reducible
definitions was not being used.
2022-03-05 14:42:47 -08:00
Leonardo de Moura
9e76cd7d65 fix: toName function at elabAppFnId
closes #1038
2022-03-04 16:56:02 -08:00
Leonardo de Moura
a670ed1e2d fix: use withoutErrToSorry at apply
closes #1037
2022-03-04 14:36:10 -08:00
Leonardo de Moura
8b248e2d8c feat: elaborate for h : x in xs do ... notation 2022-03-03 19:52:26 -08:00