Commit graph

44 commits

Author SHA1 Message Date
Leonardo de Moura
e3578c2f36
fix: discrepancy theorem vs example (#4493)
When the type of an `example` is a proposition,
we should elaborate on them as we elaborate on theorems.
This is particularly important for examples that are often
used in educational material.

Recall that when elaborating theorem headers, we convert unassigned
universe metavariables into universe parameters. The motivation is
that the proof of a theorem should not influence its statement.
However, before this commit, this was not the case for examples when
their type was a proposition.
This discrepancy often confused users.

Additionally, we considered extending the above behavior to definitions
when
1- When their type is a proposition. However, it still caused disruption
in Mathlib.
2- When their type is provided. That is, we would keep the current
behavior only if `: <type>` was omitted. This would make the elaborator
for `def` much closer to the one for `theorem`, but it proved to be too
restrictive.
For example, the following instance in `Core.lean` would fail:
```
instance {α : Sort u} [Setoid α] : HasEquiv α :=
  ⟨Setoid.r⟩
```
and we would have to write instead:
```
instance {α : Sort u} [Setoid α] : HasEquiv.{u, 0} α :=
  ⟨Setoid.r⟩
```
There are other failures like this in the core, and we assume many more
in Mathlib.

closes #4398
closes #4482 Remark: PR #4482 implements option 1 above. We may consider
it again in the future.
2024-06-24 01:18:41 +00:00
Joachim Breitner
5cd9f805b7
fix: without recover bad simp arg should fail (#4359)
this is an amendment to #4177, after @kmill pointed out an issue:

Users might expect that within a tactic combinator like `first`, `simp
[h]` fails if `h` does not exist. Therefore the behavior introduced in
PR #4177, which is really most useful in mormal interactive use of
`skip`, is restricted to when `recover := true`.
2024-06-05 08:05:38 +00:00
Joachim Breitner
f65e3ae985
feat: simp to still work even if one simp arg does not work (#4177)
this fixes a usability paper cut that just annoyed me. When editing a
larger simp proof, I usually want to see the goal state after the simp,
and this is what I see while the `simp` command is complete. But then,
when I start typing, and necessarily type incomplete lemma names, that
error makes `simp` do nothing again and I see the original goal state.
In fact, if a prefix of the simp theorem name I am typing is a valid
identifier, it jumps even more around.

With this PR, using `logException`, I still get the red squiggly lines
for the unknown identifer, but `simp` just ignores that argument and
still shows me the final goal. Much nicer.

I also demoted the message for `[-foo]` when `foo` isn’t `simp` to a
warning and gave it the correct `ref`.

See it in action here: (in the middle, when you suddenly see the
terminal,
I am switching lean versions.)


https://github.com/leanprover/lean4/assets/148037/8cb3c563-1354-4c2d-bcee-26dfa1005ae0
2024-06-03 14:21:31 +00:00
Kyle Miller
45fccc5906
feat: custom eliminators for induction and cases tactics, and beautiful eliminators for Nat (#3629)
Replaces `@[eliminator]` with two attributes `@[induction_eliminator]`
and `@[cases_eliminator]` for defining custom eliminators for the
`induction` and `cases` tactics, respectively.

Adds `Nat.recAux` and `Nat.casesAuxOn`, which are eliminators that are
defeq to `Nat.rec` and `Nat.casesOn`, but these use `0` and `n + 1`
rather than `Nat.zero` and `Nat.succ n`.

For example, using `induction` to prove that the factorial function is
positive now has the following goal states (thanks also to #3616 for the
goal state after unfolding).
```lean
example : 0 < fact x := by
  induction x with
  | zero => decide
  | succ x ih =>
    /-
    x : Nat
    ih : 0 < fact x
    ⊢ 0 < fact (x + 1)
    -/
    unfold fact
    /-
    ...
    ⊢ 0 < (x + 1) * fact x
    -/
    simpa using ih
```

Thanks to @adamtopaz for initial work on splitting the `@[eliminator]`
attribute.
2024-03-09 15:31:51 +00:00
Marc Huisinga
7ff7cf9b5a
feat: per-package server options (#2858)
This PR adds per-package server options to resolve #2455. It is based on
the previous work in #2456, but takes a different approach: options are
loaded for the specific file in the file worker when `print-paths` is
called, instead of loading them in the watchdog with a separate Lake
command. This change addresses review comments made in #2456.

In doing so, it introduces two new Lake config fields: 
- `leanOptions`: `-D` flag options that are passed to both the language
server and `lean` when building.
- `moreServerOptions`: `-D` flag options that are passed to the language
server.

Since `print-paths` must also accept a file path to compute the options
for that file, this PR is changing the API for `print-paths`. As there
have been numerous complaints about the name `print-paths`, I also
decided to change it to `setup-file` in this PR, since it would break
compatibility with the old Lake API anyways.

This PR deprecates the Lakefile field `moreServerArgs` in favor of
`moreGlobalServerArgs`, as suggested in the review for #2456.

Fixes #2455

---------

Co-authored-by: digama0 <mcarneir@andrew.cmu.edu>
2023-11-26 13:42:38 +00:00
Mario Carneiro
8881517018 fix: report goals in induction with parse error 2023-11-20 09:15:27 +01:00
Sebastian Ullrich
a62d412dce fix: implement · tacs as a builtin elaborator, part 2
Fixes #2153
2023-03-15 17:00:15 +01:00
Sebastian Ullrich
b8cc5b277e fix: strict indentation check in · tacs 2023-03-15 11:33:19 +01:00
Sebastian Ullrich
43c5ab802f fix: show tactic info on canonical by 2023-01-18 10:23:37 +01:00
Sebastian Ullrich
88c8cd5cf2 fix: show correct goal state after an empty by 2022-12-13 01:39:45 +01:00
Gabriel Ebner
15d7744cca chore: fix tests 2022-10-11 17:24:35 -07:00
Gabriel Ebner
3add955382 fix: preserve separators in evalSepByIndentTactic 2022-09-18 16:43:23 -07:00
Leonardo de Moura
7f9be4198b fix: Induction.lean after binderIdent normalization 2022-08-04 21:28:12 -07:00
Leonardo de Moura
8f4ad15a47 fix: ensure messages associated with last exception are not lost at evalTactic
closes #1358
2022-07-22 12:05:29 -04:00
Leonardo de Moura
b581c2fa17 fix: evalTactic
Another bug reported by Patrick.
2022-07-20 19:12:53 -04:00
Sebastian Ullrich
43b08239b0 fix: further conv goal state refinements 2022-06-14 11:09:47 +02:00
Sebastian Ullrich
8ffa07ab25 fix: goal state on conv => 2022-06-07 17:43:16 +02:00
Sebastian Ullrich
0b264889ae fix: goal state on ; after · 2022-06-03 13:41:04 +02:00
Sebastian Ullrich
d3cf60e86a chore: further refine goal state heuristics 2022-05-30 13:27:56 +02:00
Sebastian Ullrich
b31690b1d7 fix: go to definition/goal state at end of syntax 2022-05-30 11:16:25 +02:00
Sebastian Ullrich
39a0de40dd feat: annotate <;> with expected state 2022-04-29 16:16:09 +02:00
Sebastian Ullrich
a167828b79 fix: refine previous commit's heuristic
Show indented state if there is no outer state that is leading & not indented
relative to the cursor position
2022-04-29 16:16:09 +02:00
Sebastian Ullrich
cc5e7ee731 test: part of #1119 2022-04-29 16:16:09 +02:00
Sebastian Ullrich
b714a32d27 fix: revert "fix: show single final state after tactic combinator"
This reverts commit eb7bf2b272.
2022-04-29 16:16:09 +02:00
Sebastian Ullrich
eb7bf2b272 fix: show single final state after tactic combinator 2022-04-23 17:42:32 +02:00
Sebastian Ullrich
240c5e15e9 fix: show final goal state at end of tactic combinator 2022-04-23 17:15:32 +02:00
Leonardo de Moura
fa9b0f6c7e feat: remove space before propositions with inaccessible names 2022-04-07 07:54:50 -07:00
Leonardo de Moura
9fe5458077 feat: do not display inaccessible proposition names if they do not have forward dependencies
Even if `pp.inaccessibleNames = true`
2022-04-02 13:15:17 -07:00
Sebastian Ullrich
93327e2324 fix: tactic state on {/· 2021-05-21 17:13:33 -07:00
Sebastian Ullrich
9f3ddb0c43 fix: do not store solved goals in info tree 2021-05-20 15:17:54 -07:00
Sebastian Ullrich
eb93894683 fix: do not abort elaboration on unclosed parenthesis 2021-05-17 22:29:06 +02:00
Sebastian Ullrich
8ae726203d fix: plainGoal: consider original positions only when deciding whether a tactic is a combinator 2021-05-12 10:51:42 +02:00
Sebastian Ullrich
66c0f6ae9d fix: goal state at induction/cases e with 2021-05-05 15:27:40 +02:00
Leonardo de Moura
7398db5f3f fix: rw final goal state 2021-05-04 16:58:44 -07:00
Leonardo de Moura
56d5d6c564 chore: fix tests 2021-05-04 15:42:03 -07:00
Sebastian Ullrich
aabb4a50aa feat: remove bracket-less rw 2021-05-04 15:24:22 -07:00
Sebastian Ullrich
c22f4ffaec fix: partial fix of focus goal state 2021-05-04 19:11:05 +02:00
Sebastian Ullrich
e76fc17b0e fix: rw goal state positions 2021-05-03 14:14:12 +02:00
Sebastian Ullrich
4fb01f7c06 fix: goal state on ; 2021-05-03 13:32:00 +02:00
Sebastian Ullrich
b8b8cc79a9 feat: show initial case goal on ... => for induction/cases/case/match 2021-05-02 23:07:15 +02:00
Sebastian Ullrich
8863761401 feat: show initial state for tactic combinators by default 2021-05-02 23:07:15 +02:00
Sebastian Ullrich
2734a5baba feat: show state on by 2021-05-02 23:07:15 +02:00
Sebastian Ullrich
e20b2c359a feat: server: show goal state after tactic if cursor not strictly before tactic 2021-04-03 00:23:46 +02:00
Sebastian Ullrich
ac9fee5854 test: add Lean 3-style interactive server tests
Fixes #376
2021-04-03 00:23:46 +02:00