Lean 4.7.0 (2024-04-03)
-
simpandrwnow use instance arguments found by unification, rather than always resynthesizing. For backwards compatibility, the original behaviour is available viaset_option tactic.skipAssignedInstances false. #3507 and #3509. -
When the
pp.proofsis false, now omitted proofs use⋯rather than_, which gives a more helpful error message when copied from the Infoview. Thepp.proofs.thresholdoption lets small proofs always be pretty printed. #3241. -
pp.proofs.withTypeis now set to false by default to reduce noise in the info view. -
The pretty printer for applications now handles the case of over-application itself when applying app unexpanders. In particular, the
| `($_ $a $b $xs*) => `(($a + $b) $xs*)case of anapp_unexpanderis no longer necessary. #3495. -
New
simp(anddsimp) configuration option:zetaDelta. It isfalseby default. Thezetaoption is stilltrueby default, but their meaning has changed.-
When
zeta := true,simpanddsimpreduce terms of the formlet x := val; e[x]intoe[val]. -
When
zetaDelta := true,simpanddsimpwill expand let-variables in the context. For example, suppose the context containsx := val. Then, any occurrence ofxis replaced withval.
See issue #2682 for additional details. Here are some examples:
example (h : z = 9) : let x := 5; let y := 4; x + y = z := by intro x simp /- New goal: h : z = 9; x := 5 |- x + 4 = z -/ rw [h] example (h : z = 9) : let x := 5; let y := 4; x + y = z := by intro x -- Using both `zeta` and `zetaDelta`. simp (config := { zetaDelta := true }) /- New goal: h : z = 9; x := 5 |- 9 = z -/ rw [h] example (h : z = 9) : let x := 5; let y := 4; x + y = z := by intro x simp [x] -- asks `simp` to unfold `x` /- New goal: h : z = 9; x := 5 |- 9 = z -/ rw [h] example (h : z = 9) : let x := 5; let y := 4; x + y = z := by intro x simp (config := { zetaDelta := true, zeta := false }) /- New goal: h : z = 9; x := 5 |- let y := 4; 5 + y = z -/ rw [h] -
-
When adding new local theorems to
simp, the system assumes that the function application arguments have been annotated withno_index. This modification, which addresses issue #2670, restores the Lean 3 behavior that users expect. With this modification, the following examples are now operational:example {α β : Type} {f : α × β → β → β} (h : ∀ p : α × β, f p p.2 = p.2) (a : α) (b : β) : f (a, b) b = b := by simp [h] example {α β : Type} {f : α × β → β → β} (a : α) (b : β) (h : f (a,b) (a,b).2 = (a,b).2) : f (a, b) b = b := by simp [h]In both cases,
his applicable becausesimpdoes not index f-arguments anymore when addinghto thesimp-set. It's important to note, however, that global theorems continue to be indexed in the usual manner. -
Improved the error messages produced by the
decidetactic. #3422 -
Improved auto-completion performance. #3460
-
Improved initial language server startup performance. #3552
-
Changed call hierarchy to sort entries and strip private header from names displayed in the call hierarchy. #3482
-
There is now a low-level error recovery combinator in the parsing framework, primarily intended for DSLs. #3413
-
You can now write
termination_by?after a declaration to see the automatically inferred termination argument, and turn it into atermination_by …clause using the “Try this” widget or a code action. #3514 -
A large fraction of
Stdhas been moved into the Lean repository. This was motivated by:-
Making universally useful tactics such as
ext,by_cases,change at,norm_cast,rcases,simpa,simp?,omega, andexact?available to all users of Lean, without imports. -
Minimizing the syntactic changes between plain Lean and Lean with
import Std. -
Simplifying the development process for the basic data types
Nat,Int,Fin(and variants such asUInt64),List,Array, andBitVecas we begin making the APIs and simp normal forms for these types more complete and consistent. -
Laying the groundwork for the Std roadmap, as a library focused on essential datatypes not provided by the core language (e.g.
RBMap) and utilities such as basic IO. While we have achieved most of our initial aims inv4.7.0-rc1, some upstreaming will continue over the coming months.
-
-
The
/and%notations inIntnow useInt.edivandInt.emod(i.e. the rounding conventions have changed). PreviouslyStdoverrode these notations, so this is no change for users ofStd. There is now kernel support for these functions. #3376. -
omega, our integer linear arithmetic tactic, is now available in the core language.-
It is supplemented by a preprocessing tactic
bv_omegawhich can solve goals aboutBitVecwhich naturally translate into linear arithmetic problems. #3435. -
omeganow has support forFin#3427, the<<<operator #3433. -
During the port
omegawas modified to no longer identify atoms up to definitional equality (so in particular it can no longer proveid x ≤ x). #3525. This may cause some regressions. We plan to provide a general purpose preprocessing tactic later, or anomega!mode. -
omegais now invoked in Lean's automation for termination proofs #3503 as well as in array indexing proofs #3515. This automation will be substantially revised in the medium term, and whileomegadoes help automate some proofs, we plan to make this much more robust.
-
-
The library search tactics
exact?andapply?that were originally in Mathlib are now available in Lean itself. These use the implementation using lazy discrimination trees fromStd, and thus do not require a disk cache but have a slightly longer startup time. The order used for selection lemmas has changed as well to favor goals purely based on how many terms in the head pattern match the current goal. -
The
solve_by_elimtactic has been ported fromStdto Lean so that library search can use it. -
New
#check_tacticand#check_simpcommands have been added. These are useful for checking tactics (particularlysimp) behave as expected in test suites. -
Previously, app unexpanders would only be applied to entire applications. However, some notations produce functions, and these functions can be given additional arguments. The solution so far has been to write app unexpanders so that they can take an arbitrary number of additional arguments. However this leads to misleading hover information in the Infoview. For example, while
HAdd.hAdd f g 1pretty prints as(f + g) 1, hovering overf + gshowsf. There is no way to fix the situation from within an app unexpander; the expression position forHAdd.hAdd f gis absent, and app unexpanders cannot register TermInfo.This commit changes the app delaborator to try running app unexpanders on every prefix of an application, from longest to shortest prefix. For efficiency, it is careful to only try this when app delaborators do in fact exist for the head constant, and it also ensures arguments are only delaborated once. Then, in
(f + g) 1, thef + ggets TermInfo registered for that subexpression, making it properly hoverable.
Breaking changes:
-
Lean.withTraceNodeand variants got a strongerMonadAlwaysExceptassumption to fix trace trees not being built on elaboration runtime exceptions. Instances for most elaboration monads built onEIO Exceptionshould be synthesized automatically. -
The
match ... with.andfun.notations previously in Std have been replaced bynomatch ...andnofun. #3279 and #3286
Other improvements:
-
several bug fixes for
simp: -
fixes for
matchexpressions: -
improve
termination_byerror messages #3255 -
fix excessive resource usage in
generalize, fixes #3524 #3575 -
an equation lemma with autoParam arguments fails to rewrite, fixing #2243 #3316
-
add_decl_docshould check that declarations are local #3311 -
instantiate the types of inductives with the right parameters, closing #3242 #3246
-
New simprocs for many basic types. #3407
Lake fixes: