Commit graph

7 commits

Author SHA1 Message Date
Kyle Miller
68c006a95b
feat: transform nondependent lets into haves in declarations and equation lemmas (#8373)
This PR enables transforming nondependent `let`s into `have`s in a
number of contexts: the bodies of nonrecursive definitions, equation
lemmas, smart unfolding definitions, and types of theorems. A motivation
for this change is that when zeta reduction is disabled, `simp` can only
effectively rewrite `have` expressions (e.g. `split` uses `simp` with
zeta reduction disabled), and so we cache the nondependence calculations
by transforming `let`s to `have`s. The transformation can be disabled
using `set_option cleanup.letToHave false`.

Uses `Meta.letToHave`, introduced in #8954.
2025-06-29 19:45:45 +00:00
Kyle Miller
d39b0415f0
feat: enable pp.fieldNotation.generalized globally (#3744)
Sets the default value to `pp.fieldNotation.generalized` to `true`.
Updates tests, and fixes some minor flaws in the implementation of the
generalized field notation pretty printer.

Now generalized field notation won't be used for any function that has a
`motive` argument. This is intended to prevent recursors from pretty
printing using it as (1) recursors are more like control flow structures
than actual functions and (2) generalized field notation tends to cause
elaboration problems for recursors.

Note: be sure functions that have an `@[app_unexpander]` use
`@[pp_nodot]` if applicable. For example, `List.toArray` needs
`@[pp_nodot]` to ensure the unexpander prints it using `#[...]`
notation.
2024-03-23 02:38:09 +00:00
Leonardo de Moura
09bc477016
feat: better support for reducing Nat.rec (#3616)
closes #3022

With this commit, given the declaration
```
def foo : Nat → Nat
  | 0 => 2
  | n + 1 => foo n
```
when we unfold `foo (n+1)`, we now obtain `foo n` instead of `foo
(Nat.add n 0)`.
2024-03-06 13:28:07 +00:00
Leonardo de Moura
5d8b4f33c0 feat: improve binder names introduced by the match discriminant refinement feature 2022-04-08 06:49:09 -07:00
Gabriel Ebner
b905824024 chore: fix tests 2021-12-15 11:42:38 +00:00
Leonardo de Moura
f2a418a7ae chore: smartUnfolding cleanup
We remove dead code, update comments, and add new tests

See #445
2021-09-19 15:29:11 -07:00
Leonardo de Moura
c2d33a1a58 fix: bug at addSmartUnfoldingDef
The approach using `matcherBelowDep : NameSet` was not correct because
we "reuse" matcher-declarations. For example, in the definition
```
def f : Nat → Bool
  | 0 => true
  | n + 1 => (match n with
    | 0 => true
    | _ + 1 => true) && f n
```
we have to `match`-expressions but they can be compiled the same
matcher `f.match_1`. Thus, the set `matcherBelowDep` would contain
`f.match_1` since the first occurence refined the `Nat.below` argument
at `mkBRecOn`. Thus, `addSmartUnfoldingDef` was incorrectly assuming the second
`match` was refined too.

We fixed this issue by simulating `mkBRecOn` behavior.

fixes #445
2021-09-18 19:15:38 -07:00