Commit graph

27 commits

Author SHA1 Message Date
Kyle Miller
a19ff61e15
feat: allow structure in mutual blocks (#6125)
This PR adds support for `structure` in `mutual` blocks, allowing
inductive types defined by `inductive` and `structure` to be mutually
recursive. The limitations are (1) that the parents in the `extends`
clause must be defined before the `mutual` block and (2) mutually
recursive classes are not allowed (a limitation shared by `class
inductive`). There are also improvements to universe level inference for
inductive types and structures. Breaking change: structure parents now
elaborate with the structure in scope (fix: use qualified names or
rename the structure to avoid shadowing), and structure parents no
longer elaborate with autoimplicits enabled.

Internally, this is a large refactor of both the `inductive` and
`structure` commands. Common material is now in
`Lean.Elab.MutualInductive`, and each command plugs into this mutual
inductive elaboration framework with the logic specific to the
respective command. For example, `structure` has code to add projections
after the inductive types are added to the environment.

Closes #4182
2024-11-22 09:20:07 +00:00
Gabriel Ebner
1c561c39a8 feat: function coercions with unification 2022-10-14 12:08:10 -07:00
Gabriel Ebner
ff3c67d1ad feat: recover from errors in attributes 2022-07-16 06:19:54 -07:00
Gabriel Ebner
70ef4e529c feat: allow attributes on structures and inductives 2021-12-23 08:04:36 -08:00
Daniel Selsam
e6b90dde8f fix: pp.analyze mvars can bottom-up 2021-08-03 09:13:18 +02:00
Daniel Selsam
c3d62c1076 chore: patch tests for pp.analyze default 2021-08-03 09:13:18 +02:00
Leonardo de Moura
5d3f0606d2 feat: include type of type in "mismatch errors"
@Kha we do that in Lean 3. It helps when the error is due to incorrect universe levels.

BTW, I had to update `tests/lean/server/content_diag.json` since the
error message is different, but a few other stuff changed too.
Could you please take a look whether the test is still correct?
2021-03-08 09:30:34 -08:00
Leonardo de Moura
729047b5a2 feat: auto bound implicit at constructors
@Kha This commit adds auto bound implicits to constructors.
I was excited until I tried to define the `Bigstep` type again without
`autoBoundImplicitLocal`, and found small typos.
Example, I had
```
  | ifTrue  : eval σ₁ b = true  → Bigstep (c₁, σ₁) σ₂ t → Bigstep (cond b c₁ c₂, σ₁) σ₂ (t₁ + 1)
```
where `t₁` should be `t`, but the declaration was accepted. I am
wondering whether Isabelle performs some kind of sanity checking,
and/or enforces rules such as: auto-bound implicits may only be
introduced by hypotheses.
Note that this is not an issue for definitions, because the body of
the definition will probably not type check when we have this kind of
typo in the header.
Anyway, I am putting the experiment in this branch for now.
That being said, the `Bigstep` declaration is way nicer with
`autoBoundImplicitLocal`s.

Another option is to add a new option `ctorAutoBoundImplicitLocal`
that is false by default, and activates auto implicit locals for
constructors when set to true.
2021-02-02 10:18:21 -08:00
Sebastian Ullrich
b2b78eb222 test: use printMessageEndPos for leantests 2021-01-15 16:27:59 +01:00
Leonardo de Moura
c7ae8354fd feat: improve type mismatch error messages
Use heuristic to automatically annotate terms with `pp.explicit`.
2020-12-17 07:11:52 -08:00
Leonardo de Moura
e899b63def feat: suppress "synthetic sorry" at #check
@Kha The message `sorryAx ?m : ?m` is content free.
2020-12-09 14:17:16 -08:00
Leonardo de Moura
dd4ae81774 chore: move to new frontend 2020-10-16 09:16:33 -07:00
Sebastian Ullrich
3834a89cdc feat: activate new pretty printer 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
897f277a3e test: strip mvar suffixes 2020-09-15 09:32:00 -07:00
Leonardo de Moura
d8855c2673 feat: elaborate all definitions using elabMutualDef 2020-09-06 07:23:47 -07:00
Leonardo de Moura
988bb09aaf feat: new inductive command syntax
cc @Kha
2020-09-02 09:41:52 -07:00
Leonardo de Moura
5ba9aad7a3 refactor: eliminate ref plumbing 2020-08-13 10:37:53 -07:00
Leonardo de Moura
fe27eab6f1 chore: fix tests
Metavariables are not being purified anymore
2020-08-04 18:55:26 -07:00
Leonardo de Moura
8a2dd414ff feat: inductive command
cc @Kha
2020-07-15 16:32:23 -07:00
Leonardo de Moura
d4ae4da222 feat: check given constructor resulting type 2020-07-13 16:22:49 -07:00
Leonardo de Moura
920343d36b fix: unspecified constructor resulting type is not allowed inductive families 2020-07-13 16:22:49 -07:00
Leonardo de Moura
2744ae96bb feat: check unsafe annotations in mutually inductive datatype declarations 2020-07-13 16:22:49 -07:00
Leonardo de Moura
77ad630c80 test: inductive command 2020-07-13 16:22:49 -07:00
Leonardo de Moura
d5f64f52a9 feat: add CtorView and modifier validation for inductive and constructors 2020-07-13 16:22:48 -07:00
Leonardo de Moura
667f2ed601 feat: resolve inductive and ctor names 2020-07-13 16:22:48 -07:00
Leonardo de Moura
cda11dea25 feat: check universe parameters in mutually recursive inductive declaration 2020-07-11 08:01:36 -07:00
Leonardo de Moura
f559576994 feat: inductive datatype header validation 2020-07-09 15:34:25 -07:00