Commit graph

100 commits

Author SHA1 Message Date
Kyle Miller
d1a99d8d45
fix: avoid delaborating with field notation if object is a metavariable (#6014)
This PR prevents `Nat.succ ?_` from pretty printing as `?_.succ`, which
should make `apply?` be more usable.

Closes #5993
2024-11-08 20:57:37 +00:00
Kyle Miller
fdd5aec172
feat: better #eval command (#5627)
This refactors and improves the `#eval` command, introducing some new
features.
* Now evaluated results can be represented using `ToExpr` and pretty
printing. This means **hoverable output**. If `ToExpr` fails, it then
tries `Repr` and then `ToString`. The `eval.pp` option controls whether
or not to try `ToExpr`.
* There is now **auto-derivation** of `Repr` instances, enabled with the
`pp.derive.repr` option (default to **true**). For example:
  ```lean
  inductive Baz
    | a | b

  #eval Baz.a
  -- Baz.a
  ```
It simply does `deriving instance Repr for Baz` when there's no way to
represent `Baz`. If core Lean gets `ToExpr` derive handlers, they could
be used here as well.
* The option `eval.type` controls whether or not to include the type in
the output. For now the default is false.
* Now things like `#eval do return 2` work. It tries using
`CommandElabM`, `TermElabM`, or `IO` when the monad is unknown.
* Now there is no longer `Lean.Eval` or `Lean.MetaEval`. These each used
to be responsible for both adapting monads and printing results. The
concerns have been split into two. (1) The `MonadEval` class is
responsible for adapting monads for evaluation (it is similar to
`MonadLift`, but instances are allowed to use default data when
initializing state) and (2) finding a way to represent results is
handled separately.
* Error messages about failed instance synthesis are now more precise.
Once it detects that a `MonadEval` class applies, then the error message
will be specific about missing `ToExpr`/`Repr`/`ToString` instances.
* Fixes a bug where `Repr`/`ToString` instances can't be found by
unfolding types "under the monad". For example, this works now:
  ```lean
  def Foo := List Nat
  def Foo.mk (l : List Nat) : Foo := l
  #eval show Lean.CoreM Foo from do return Foo.mk [1,2,3]
  ```
* Elaboration errors now abort evaluation. This eliminates some
not-so-relevant error messages.
* Now evaluating a value of type `m Unit` never prints a blank message.
* Fixes bugs where evaluating `MetaM` and `CoreM` wouldn't collect log
messages.

The `run_cmd`, `run_elab`, and `run_meta` commands are now frontends for
`#eval`.
2024-10-08 20:51:46 +00:00
Kim Morrison
1225b0f651
chore: delete deprecations from 2022 (#4618) 2024-07-02 03:47:33 +00:00
Kim Morrison
3a457e6ad6
chore: use #guard_msgs in run tests (#4175)
Many of our tests in `tests/lean/run/` produce output from `#eval` (or
`#check`) statements, that is then ignored.

This PR tries to capture all the useful output using `#guard_msgs`. I've
only done a cursory check that the output is still sane --- there is a
chance that some "unchecked" tests have already accumulated regressions
and this just cements them!

In the other direction, I did identify two rotten tests:
* a minor one in `setStructInstNotation.lean`, where a comment says `Set
Nat`, but `#check` actually prints `?_`. Weird?
* `CompilerProbe.lean` is generating empty output, apparently indicating
that something is broken, but I don't know the signficance of this file.

In any case, I'll ask about these elsewhere.

(This started by noticing that a recent `grind` test file had an
untested `trace_state`, and then got carried away.)
2024-05-16 00:38:31 +00:00
Leonardo de Moura
5302b7889a
fix: fold raw Nat literals at dsimp (#3624)
closes #2916

Remark: this PR also renames `Expr.natLit?` ==> `Expr.rawNatLit?`.
Motivation: consistent naming convention: `Expr.isRawNatLit`.
2024-03-06 18:29:20 +00:00
Leonardo de Moura
3a13200772 refactor: add configuration options to control WHNF
This commit also removes parameter `simpleReduce` from discrimination
trees, and take WHNF configuration options.
Reason: it is more dynamic now. For example, the simplifier
will be able to use different configurations for discrimination tree insertion
and retrieval. We need this feature to address issues #2669 and #2281

This commit also removes the dead Meta.Config field `zetaNonDep`.
2023-10-25 03:12:35 -07:00
Gabriel Ebner
34b0b4b7e2 chore: fix tests 2022-08-15 08:55:25 -07:00
Leonardo de Moura
4568fe755c chore: fix tests 2022-07-02 15:25:06 -07:00
Leonardo de Moura
bba9353619 fix: make sure isDefEqOffset does not expose kernel nat literals
This issue is similar to a bug where `isDefEqOffset` was exposing
`Nat.add` when processing `HAdd.hAdd`.

Fixes #561
The example at issue #561 is now working, but we may have other places
where raw literals are being accidentally exposed.
2021-08-02 11:27:00 -07:00
Leonardo de Moura
8c12a264ee fix: offset support at isDefEq should not use HAdd.hAdd
fixes #550
2021-07-27 16:16:03 -07:00
Leonardo de Moura
90a79a0b06 chore: remove command universes
Now, `universe` may declare many universes. The goal is to make it
consistent with the `variable` command
2021-06-29 17:01:07 -07:00
Gabriel Ebner
3cff5ceb99 perf: make trace[...] ... notation lazy 2021-06-23 00:07:27 -07:00
Leonardo de Moura
48b855bfe5 chore: fix tests 2021-03-10 18:45:22 -08:00
Leonardo de Moura
bb2ca97df9 refactor: add options for controlling whether variables are included or not at mkLambdaFVars and mkForallFVars 2021-02-17 13:49:27 -08:00
Sebastian Ullrich
a3a8d76e96 chore: move pp_options.cpp to Lean 2021-01-27 14:16:12 +01:00
Leonardo de Moura
ea0fda39bc chore: Declaration.lean naming convention
`Declaration.lean` was one of the first Lean 4 files, and was still
using an old naming convention.

cc @Kha
2021-01-20 17:07:02 -08:00
Leonardo de Moura
8b51f6279e chore: fix tests 2020-12-16 10:45:27 -08:00
Leonardo de Moura
fa6d35adfa chore: fix tests 2020-11-20 17:00:13 -08:00
Leonardo de Moura
a8c791ecae chore: remove dead files and functions
Remove obsolete combinators: `whenM`, `unlessM`, and `condM`

cc @Kha
2020-11-10 18:37:15 -08:00
Leonardo de Moura
898a08a0c1 chore: avoid Has prefix in type classes
closes #203
2020-10-27 18:29:19 -07:00
Leonardo de Moura
10c32fcf94 chore: HasToString => ToString 2020-10-27 16:11:48 -07:00
Leonardo de Moura
c979d81934 refactor: add polymorphic methods for updating/querying reducibility status 2020-10-26 17:07:28 -07:00
Leonardo de Moura
fa101444b4 chore: fix tests 2020-10-25 09:11:13 -07:00
Leonardo de Moura
72f969e9dd test: new frontend 2020-09-29 18:22:34 -07:00
Sebastian Ullrich
af8dc5eeab feat: pretty print Syntax in messages 2020-09-29 07:59:22 -07:00
Leonardo de Moura
d6db541366 chore: cleanup 2020-09-28 19:05:48 -07:00
Leonardo de Moura
8e81db0d2b chore: add temporary workaround to tests
We will remove it after we implement `doMatch`
2020-09-27 06:58:10 -07:00
Leonardo de Moura
a0a724ddbd fix: tests and elabDo 2020-09-26 19:12:01 -07:00
Leonardo de Moura
4c6a589e6c feat: indented do blocks
@Kha it is soooooo much nicer :)
2020-09-14 13:44:51 -07:00
Leonardo de Moura
b02cda0408 chore: move more tests to new frontend 2020-09-11 15:31:14 -07:00
Leonardo de Moura
14f973d5a0 chore: fix tests 2020-08-24 17:59:11 -07:00
Leonardo de Moura
fab100abb4 chore: fix tests 2020-08-24 12:17:47 -07:00
Leonardo de Moura
d6b96b4d8b chore: fix some tests 2020-08-20 18:36:29 -07:00
Leonardo de Moura
94689ca91f chore: fix test 2020-08-13 16:55:03 -07:00
Leonardo de Moura
08f1c2310b chore: enforce naming convention 2020-08-13 14:09:00 -07:00
Leonardo de Moura
5b1b11ffe0 feat: add isCharLit 2020-08-13 13:15:15 -07:00
Leonardo de Moura
f934a86646 feat: add (ref : Syntax) to Meta.Exception.other
@Kha The Syntax is here just to provide possition information. The
goal is to improve error message location information in code such as `DepElim`.
2020-08-06 09:40:16 -07:00
Leonardo de Moura
1e1ac497da feat: add Meta.mkListLit and Meta.mkArrayLit 2020-07-29 18:01:26 -07:00
Leonardo de Moura
235b97a3ba chore: fix test 2020-07-27 15:27:17 -07:00
Leonardo de Moura
eba7a28df0 feat: add Meta.mkProjection 2020-07-20 16:01:36 -07:00
Leonardo de Moura
18fce4f455 feat: add Expr.inferImplicit 2020-07-13 16:22:48 -07:00
Leonardo de Moura
e26ec036ba feat: add instantiateForall 2020-07-11 08:01:36 -07:00
Leonardo de Moura
9c0bd9dd41 chore: fix tests 2020-05-26 15:05:00 -07:00
Leonardo de Moura
2f959e23ca fix: checkAssignment was overwriting assignment 2020-02-11 16:11:56 -08:00
Leonardo de Moura
55231b960e feat: simplify and improve processAssignmentFOApproxAux 2020-02-11 14:42:02 -08:00
Leonardo de Moura
f6ae8560e8 fix: isDefEq issue exposed by new test 2020-02-10 23:46:17 -08:00
Leonardo de Moura
f39586a237 test: expose problem at isDefEq 2020-02-10 22:22:42 -08:00
Leonardo de Moura
e732eac899 fix: but at elimMVarDepsApp 2020-02-10 20:49:43 -08:00
Leonardo de Moura
f0e2a3cfa4 chore: add small test 2020-02-10 20:37:37 -08:00
Leonardo de Moura
95ad26cc23 feat: add mkEqNDRec and mkEqRec 2020-02-09 11:02:35 -08:00