Commit graph

132 commits

Author SHA1 Message Date
Kyle Miller
83129b7e3a
fix: inductive elaboration should keep track of universe level parameters created in binders (#5814)
Refactors `inductive` elaborator to keep track of universe level
parameters created during elaboration of `variable`s and binders. This
fixes an issue in Mathlib where its `Type*` elaborator can result in
unexpected universe levels.

For example, in
```lean4
variable {F : Type*}
inductive I1 (A B : Type*) (x : F) : Type
```
before this change the signature would be
```
I1.{u_1, u_2} {F : Type u_1} (A : Type u_1) (B : Type u_2) (x : F) : Type
```
but now it is
```
I1.{u_1, u_2, u_3} {F : Type u_1} (A : Type u_2) (B : Type u_3) (x : F) : Type
```
Fixes this for the `axiom` elaborator too.

Adds more accurate universe level validation for mutual inductives.

Breaking change: removes `Lean.Elab.Command.expandDeclId`. Use
`Lean.Elab.Term.expandDeclId` from within `runCommandElabM`.
2024-10-23 04:07:40 +00:00
Sebastian Ullrich
11ae8bae42
fix: include references in attributes in call hierarchy (#5650)
By ensuring all `declModifiers` are included in `addDeclarationRanges`,
`implementedBy` references etc are included in the call hierarchy
2024-10-18 15:38:32 +00:00
Kyle Miller
8e88e8061a
chore: deprecate := variants of inductive and structure (#5542)
Deprecates `inductive ... :=`, `structure ... :=`, and `class ... :=` in
favor of the `... where` variant. Currently this syntax produces a
warning, controlled by the `linter.deprecated` option.

Breaking change: modifies `Lean.Linter.logLintIf` to use
`Lean.Linter.getLinterValue` to determine if a linter value is set. This
means that the `linter.all` option now is taken into account when the
linter option is not set.

Part of #5236
2024-10-11 05:54:18 +00:00
Sebastian Ullrich
3584a62411
fix: call hierarchy into (builtin_)initialize (#5560)
While `initialize` pretended it had the declaration name of the constant
to be initialized, missing declaration ranges for the latter led call
hierarchy etc. to ignore the definition
2024-10-03 12:03:44 +00:00
Leonardo de Moura
458835360f
fix: [implemented_by] at functions defined by well-founded recursion (#4508)
closes #2899
2024-06-20 00:06:38 +00:00
Sebastian Ullrich
9d47377bda
feat: incrementality for careful command macros such as set_option in theorem, theorem foo.bar, lemma (#4364)
See Note [Incremental Macros] for the caveat on correct `withRef` use
2024-06-05 14:10:38 +00:00
Sebastian Ullrich
811bad16e1
fix: ensure incremental commands and tactics are reached only on supported paths (#4259)
Without this, it would not easy but perhaps be feasible to break
incrementality when editing command prefixes such as `set_option ... in
theorem` or also `theorem namesp.name ...` (which is a macro),
especially if at some later point we support incrementality in input
shifted by an edit. Explicit, sound support for these common cases will
be brought back soon.
2024-05-23 17:57:42 +00:00
Mario Carneiro
fb82428f2d
feat: hover / go-to-def for attribute cmd (#3896)
`attribute [attr] foo` was missing a hover on `foo`.
2024-04-13 07:13:25 +00:00
David Thrane Christiansen
966fa800f8
chore: remove the coercion from String to Name (#3589)
This coercion caused difficult-to-diagnose bugs sometimes. Because there
are some situations where converting a string to a name should be done
by parsing the string, and others where it should not, an explicit
choice seems better here.

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-03-21 23:46:03 +00:00
Leonardo de Moura
173b956961
feat: reserved names (#3675)
- Add support for reserved declaration names. We use them for theorems
generated on demand.
- Equation theorems are not private declarations anymore.
- Generate equation theorems on demand when resolving symbols.
- Prevent users from creating declarations using reserved names. Users
can bypass it using meta-programming.

See next test for examples.
2024-03-15 00:33:22 +00:00
Leonardo de Moura
9ee1ff2435 chore: remove bootstrapping workaround 2024-03-13 21:15:48 -07:00
Leonardo de Moura
2c8fd7fb95 chore: avoid reserved name
TODO: update state0 and cleanup
2024-03-13 21:15:48 -07:00
Leonardo de Moura
5e101cf983
feat: use attribute command to add and erase simprocs (#3511) 2024-02-26 23:41:49 +00:00
Henrik Böving
23e49eb519 perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
Joachim Breitner
b5122b6a7b feat: per-function termination hints
This change

 * moves `termination_by` and `decreasing_by` next to the function they
   apply to
 * simplify the syntax of `termination_by`
 * apply the `decreasing_by` goal to all goals at once, for better
   interactive use.

See the section in `RELEASES.md` for more details and migration advise.

This is a hard breaking change, requiring developers to touch every
`termination_by` in their code base. We decided to still do it as a
hard-breaking change, because supporting both old and new syntax at the
same time would be non-trivial, and not save that much. Moreover, this
requires changes to some metaprograms that developers might have
written, and supporting both syntaxes at the same time would make
_their_ migration harder.
2024-01-10 17:27:35 +01:00
bc²
d4f10bc07e
feat: detail error message about invalid mutual blocks (#2949)
To prevent user confusion as in this [Zulip
message](https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/Matching.20on.20prop/near/341456011)
2023-12-05 10:50:10 +00:00
Leonardo de Moura
a7107aedb3 fix: fixes #1848 2022-11-18 08:49:10 -08:00
Mario Carneiro
583e023314 chore: snake-case attributes (part 2) 2022-10-19 09:28:08 -07:00
Mario Carneiro
dd5948d641 chore: snake-case attributes (part 1) 2022-10-19 09:28:08 -07:00
Gabriel Ebner
59abb9a332 feat: move docstring before | in ctors 2022-09-14 08:26:17 -07:00
Gabriel Ebner
00793fcdd8 chore: remove old bootstrapping hack 2022-09-14 08:26:17 -07:00
Sebastian Ullrich
2e98726973 fix: levelMVarToParam must update levelNames 2022-08-31 17:57:07 -07:00
Leonardo de Moura
413db56b89 refactor: simplify runTermElabM and liftTermElabM 2022-08-07 07:35:02 -07:00
Leonardo de Moura
f0272d9309 feat: multiple namespaces in mutual declarations 2022-08-04 19:18:49 -07:00
Mario Carneiro
323c94ef34 feat: doc comments on anonymous initialize 2022-07-30 11:20:24 +02:00
Mario Carneiro
05e42b51b3 feat: use with_decl_name% in initialize 2022-07-30 11:20:24 +02:00
Sebastian Ullrich
5160cb7b0f refactor: remove some unnecessary antiquotation kind annotations 2022-07-23 17:09:32 +02:00
Mario Carneiro
f6211b1a74
chore: convert doc/mod comments from /- to /--//-! (#1354) 2022-07-22 12:05:31 -07:00
Sebastian Ullrich
c43a84ca30 fix: unsafe initialize 2022-07-20 22:37:01 +02:00
Sebastian Ullrich
15bb3ccf6b chore: reduce TSyntax.Compat scope in Elab.Declaration 2022-07-20 22:12:20 +02:00
Sebastian Ullrich
cdb855d281 feat: support all sensible modifiers on (builtin_)initialize
Resolves #1324
2022-07-20 22:12:20 +02:00
Gabriel Ebner
ff3c67d1ad feat: recover from errors in attributes 2022-07-16 06:19:54 -07:00
Gabriel Ebner
eba400543d refactor: use computed fields for Name 2022-07-11 14:19:41 -07:00
Gabriel Ebner
243439a75c feat: support modifiers in computed fields 2022-07-11 12:26:53 -07:00
Gabriel Ebner
3a55228be0 chore: prepare for bootstrapping 2022-07-11 12:26:53 -07:00
Gabriel Ebner
b1eb022027 feat: computed fields 2022-07-11 12:26:53 -07:00
Leonardo de Moura
38e1f6ba82 fix: missing instantiateMVars 2022-07-05 20:45:53 -07:00
Leonardo de Moura
2ebcf29cde chore: use a[i]! for array accesses that may panic 2022-07-02 15:12:05 -07:00
Sebastian Ullrich
5e334b3e90 chore: postpone TSyntax adoption for some parts
The namespace `TSyntax.Compat` can be opened for a coercion
`Syntax -> TSyntax k` for any `k`, as otherwise this PR would never be done.
2022-06-27 22:37:02 +02:00
Leonardo de Moura
22c8f10b12 chore: remove constant command 2022-06-14 17:14:28 -07:00
Leonardo de Moura
346c4beb70 feat: elaborate opaque command 2022-06-14 16:36:24 -07:00
Leonardo de Moura
9ba5831de8 fix: _root_ prefix in declarations
closes #490
2022-06-13 14:03:18 -07:00
Leonardo de Moura
328586988c chore: style 2022-06-13 13:58:29 -07:00
Leonardo de Moura
041827bed5 chore: unused variables 2022-06-07 17:54:10 -07:00
Sebastian Ullrich
ae7b895f7a refactor: unname some unused variables 2022-06-07 16:37:45 -07:00
Leonardo de Moura
bd35e8a2be chore: remove {} from ctor parser 2022-04-13 08:47:21 -07:00
Leonardo de Moura
ea682830d1 refactor: change addTermInfo type 2022-04-08 15:01:57 -07:00
Leonardo de Moura
0bfcf434ac fix: jump to definition inside of a mutually inductive declaration 2022-04-06 14:43:30 -07:00
Leonardo de Moura
12e2a79170 chore: fix codebase after removing auto pure 2022-02-03 18:08:14 -08:00
Leonardo de Moura
d4d9995952 feat: reject user declared namespaces containing _root
see #490
2022-01-26 19:15:45 -08:00