Lean 4.14.0 (2024-12-02)
Full Changelog: https://github.com/leanprover/lean4/compare/v4.13.0...v4.14.0
Language features, tactics, and metaprograms
-
structureandinductivecommands-
#5517 improves universe level inference for the resulting type of an
inductiveorstructure.Recall that aProp-valued inductive type is a syntactic subsingleton if it has at most one constructor and all the arguments to the constructor are inProp. Such types have large elimination, so they could be defined inTypeorPropwithout any trouble. The way inference has changed is that if a type is a syntactic subsingleton with exactly one constructor, and the constructor has at least one parameter/field, then theinductive/structurecommand will prefer creating aPropinstead of aType. The upshot is that the: Propinstructure S : Propis often no longer needed. (With @arthur-adjedj). -
#5842 and #5783 implement a feature where the
structurecommand can now define recursive inductive types:structure Tree where n : Nat children : Fin n → Tree def Tree.size : Tree → Nat | {n, children} => Id.run do let mut s := 0 for h : i in [0 : n] do s := s + (children ⟨i, h.2⟩).size pure s -
#5814 fixes a bug where Mathlib's
Type*elaborator could lead to incorrect universe parameters with theinductivecommand. -
#3152 and #5844 fix bugs in default value processing for structure instance notation (with @arthur-adjedj).
-
#5399 promotes instance synthesis order calculation failure from a soft error to a hard error.
-
#5542 deprecates
:=variants ofinductiveandstructure(see breaking changes).
-
-
Application elaboration improvements
-
#5671 makes
@[elab_as_elim]require at least one discriminant, since otherwise there is no advantage to this alternative elaborator. -
#5528 enables field notation in explicit mode. The syntax
@x.felaborates as@S.fwithxsupplied to the appropriate parameter. -
#5692 modifies the dot notation resolution algorithm so that it can apply
CoeFuninstances. For example, Mathlib hasMultiset.card : Multiset α →+ Nat, and now withm : Multiset α, the notationm.cardresolves to⇑Multiset.card m. -
#5658 fixes a bug where 'don't know how to synthesize implicit argument' errors might have the incorrect local context when the eta arguments feature is activated.
-
#5933 fixes a bug where
..ellipses in patterns made use of optparams and autoparams. -
#5770 makes dot notation for structures resolve using all ancestors. Adds a resolution order for generalized field notation. This is the order of namespaces visited during resolution when trying to resolve names. The algorithm to compute a resolution order is the commonly used C3 linearization (used for example by Python), which when successful ensures that immediate parents' namespaces are considered before more distant ancestors' namespaces. By default we use a relaxed version of the algorithm that tolerates inconsistencies, but using
set_option structure.strictResolutionOrder truemakes inconsistent parent orderings into warnings.
-
-
Recursion and induction principles
-
#5619 fixes functional induction principle generation to avoid over-eta-expanding in the preprocessing step.
-
#5766 fixes structural nested recursion so that it is not confused when a nested type appears first.
-
#5803 fixes a bug in functional induction principle generation when there are
letbindings. -
#5904 improves functional induction principle generation to unfold aux definitions more carefully.
-
#5850 refactors code for
Predefinition.Structural.
-
-
Error messages
-
#5276 fixes a bug in "type mismatch" errors that would structurally assign metavariables during the algorithm to expose differences.
-
#5919 makes "type mismatch" errors add type ascriptions to expose differences for numeric literals.
-
#5922 makes "type mismatch" errors expose differences in the bodies of functions and pi types.
-
#5888 improves the error message for invalid induction alternative names in
matchexpressions (@josojo). -
#5719 improves
calcerror messages.
-
-
#5627 and #5663 improve the
#evalcommand and introduce some new features.-
Now results can be pretty printed if there is a
ToExprinstance, which means hoverable output. IfToExprfails, it then tries looking for aReprorToStringinstance like before. Settingset_option eval.pp falsedisables making use ofToExprinstances. -
There is now auto-derivation of
Reprinstances, enabled with thepp.derive.reproption (default to true). For example:inductive Baz | a | b #eval Baz.a -- Baz.a
It simply does
deriving instance Repr for Bazwhen there's no way to representBaz. -
The option
eval.typecontrols whether or not to include the type in the output. For now the default is false. -
Now expressions such as
#eval do return 2, where monad is unknown, work. It tries unifying the monad withCommandElabM,TermElabM, orIO. -
The classes
Lean.EvalandLean.MetaEvalhave been removed. These each used to be responsible for adapting monads and printing results. Now theMonadEvalclass is responsible for adapting monads for evaluation (it is similar toMonadLift, but instances are allowed to use default data when initializing state), and representing results is handled through a separate process. -
Error messages about failed instance synthesis are now more precise. Once it detects that a
MonadEvalclass applies, then the error message will be specific about missingToExpr/Repr/ToStringinstances. -
Fixes bugs where evaluating
MetaMandCoreMwouldn't collect log messages. -
Fixes a bug where
let reccould not be used in#eval.
-
-
partialdefinitions -
New tactic configuration syntax. The configuration syntax for all core tactics has been given an upgrade. Rather than
simp (config := { contextual := true, maxSteps := 22}), one can now writesimp +contextual (maxSteps := 22). Tactic authors can migrate by switching from(config)?tooptConfigin tactic syntaxes and potentially deletingmkOptionalNodein elaborators. #5883, #5898, #5928, and #5932. (Tactic authors, see breaking changes.) -
simptactic-
#5632 fixes the simpproc for
Finliterals to reduce more consistently. -
#5648 fixes a bug in
simpa ... using twhere metavariables intwere not properly accounted for, and also improves the type mismatch error. -
#5838 fixes the docstring of
simp!to actually talk aboutsimp!. -
#5870 adds support for
attribute [simp ←](note the reverse direction). This adds the reverse of a theorem as a global simp theorem.
-
-
decidetactic-
#5665 adds
decide!tactic for using kernel reduction (warning: this is renamed todecide +kernelin a future release).
-
-
bv_decidetactic-
#5714 adds inequality regression tests (@alexkeizer).
-
#5608 adds
bv_toNattag fortoNat_ofInt(@bollu). -
#5618 adds support for
atinac_nfand uses it inbv_normalize(@tobiasgrosser). -
#5628 adds udiv support.
-
#5635 adds auxiliary bitblasters for negation and subtraction.
-
#5637 adds more
getLsbDbitblaster theory. -
#5652 adds umod support.
-
#5653 adds performance benchmark for modulo.
-
#5655 reduces error on
bv_checkto warning. -
#5670 adds
~~~(-x)support. -
#5673 disables
ac_nfby default. -
#5675 fixes context tracking in
bv_decidecounter example. -
#5676 adds an error when the LRAT proof is invalid.
-
#5781 introduces uninterpreted symbols everywhere.
-
#5823 adds
BitVec.sdivsupport. -
#5852 adds
BitVec.ofBoolsupport. -
#5855 adds
ifsupport. -
#5869 adds support for all the SMTLIB BitVec divison/remainder operations.
-
#5886 adds embedded constraint substitution.
-
#5918 fixes loose mvars bug in
bv_normalize. -
Documentation:
-
#5636 adds remarks about multiplication.
-
-
-
convmode-
#5861 improves the
congrconv tactic to handle "over-applied" functions. -
#5894 improves the
argconv tactic so that it can access more arguments and so that it can handle "over-applied" functions (it generates a specialized congruence lemma for the specific argument in question). Makesarg 1andarg 2apply to pi types in more situations. Adds negative indexing, for examplearg -2is equivalent to thelhstactic. Makes theenter [...]tactic show intermediate states likerw.
-
-
Other tactics
-
#4846 fixes a bug where
generalize ... at *would apply to implementation details (@ymherklotz). -
#5730 upstreams the
classicaltactic combinator. -
#5815 improves the error message when trying to unfold a local hypothesis that is not a local definition.
-
#5862 and #5863 change how
applyandsimpelaborate, making them not disable error recovery. This improves hovers and completions when the term has elaboration errors.
-
-
derivingclauses -
#5065 upstreams and updates
#where, a command that reports the current scope information. -
Linters
-
Metaprogramming interface
-
#5720 adds
pushGoal/pushGoalsandpopGoalfor manipulating the goal state. These are an alternative toreplaceMainGoalandgetMainGoal, and with them you don't need to worry about making sure nothing clears assigned metavariables from the goal list between assigning the main goal and usingreplaceMainGoal. ModifiescloseMainGoalUsing, which is like aTacticMversion ofliftMetaTactic. Now the callback is run in a context where the main goal is removed from the goal list, and the callback is free to modify the goal list. Furthermore, thecheckUnassignedargument has been replaced withcheckNewUnassigned, which checks whether the value assigned to the goal has any new metavariables, relative to the start of execution of the callback. ModifieswithCollectingNewGoalsFromto take theparentTagargument explicitly rather than indirectly viagetMainTag. ModifieselabTermWithHolesto optionally takeparentTag?. -
#5563 fixes
getFunInfoandinferTypeto usewithAtLeastTransparencyrather thanwithTransparency. -
#5679 fixes
RecursorVal.getInductto return the name of major argument’s type. This makes "structure eta" work for nested inductives. -
#5681 removes unused
mkRecursorInfoForKernelRec. -
#5686 makes discrimination trees index the domains of foralls, for better performance of the simplify and type class search.
-
#5760 adds
Lean.Expr.name?recognizer forNameexpressions. -
#5800 modifies
liftCommandElabMto preserve more state, fixing an issue where using it would drop messages. -
#5857 makes it possible to use dot notation in
m!strings, for examplem!"{.ofConstName n}". -
#5841 and #5853 record the complete list of
structureparents in theStructureInfoenvironment extension.
-
-
Other fixes or improvements
-
#5566 fixes a bug introduced in #4781 where heartbeat exceptions were no longer being handled properly. Now such exceptions are tagged with
runtime.maxHeartbeats(@eric-wieser). -
#5708 modifies the proof objects produced by the proof-by-reflection tactics
ac_nf0andsimp_arithso that the kernel is less prone to reducing expensive atoms. -
#5768 adds a
#versioncommand that prints Lean's version information. -
#5822 fixes elaborator algorithms to match kernel algorithms for primitive projections (
Expr.proj). -
#5811 improves the docstring for the
rwatactic.
-
Language server, widgets, and IDE extensions
-
#5224 fixes
WorkspaceClientCapabilitiesto makeapplyEditoptional, in accordance with the LSP specification (@pzread). -
#5340 fixes a server deadlock when shutting down the language server and a desync between client and language server after a file worker crash.
-
#5560 makes
initializeandbuiltin_initializeparticipate in the call hierarchy and other requests. -
#5650 makes references in attributes participate in the call hierarchy and other requests.
-
#5666 add auto-completion in tactic blocks without having to type the first character of the tactic, and adds tactic completion docs to tactic auto-completion items.
-
#5677 fixes several cases where goal states were not displayed in certain text cursor positions.
-
#5707 indicates deprecations in auto-completion items.
-
#5736, #5752, #5763, #5802, and #5805 fix various performance issues in the language server.
-
#5801 distinguishes theorem auto-completions from non-theorem auto-completions.
Pretty printing
-
#5640 fixes a bug where goal states in messages might print newlines as spaces.
-
#5643 adds option
pp.mvars.delayed(default false), which when false causes delayed assignment metavariables to pretty print with what they are assigned to. Nowfun x : Nat => ?apretty prints asfun x : Nat => ?arather thanfun x ↦ ?m.7 x. -
#5711 adds options
pp.mvars.anonymousandpp.mvars.levels, which when false respectively cause expression metavariables and level metavariables to pretty print as?_. -
#5710 adjusts the
⋯elaboration warning to mentionpp.maxSteps. -
#5759 fixes the app unexpander for
sorryAx. -
#5827 improves accuracy of binder names in the signature pretty printer (like in output of
#check). Also fixes the issue where consecutive hygienic names pretty print without a space separating them, so we now have(x✝ y✝ : Nat)rather than(x✝y✝ : Nat). -
#5830 makes sure all the core delaborators respond to
pp.explicitwhen appropriate. -
#5639 makes sure name literals use escaping when pretty printing.
-
#5854 adds delaborators for
<|>,<*>,>>,<*, and*>.
Library
-
Array-
#5687 deprecates
Array.data. -
#5705 uses a better default value for
Array.swapAt!. -
#5748 moves
Array.mapIdxlemmas to a new file. -
#5749 simplifies signature of
Array.mapIdx. -
#5758 upstreams
Array.reduceOption. -
#5786 adds simp lemmas for
Array.isEqvandBEq. -
#5796 renames
Array.shrinktoArray.take, and relates it toList.take. -
#5798 upstreams
List.modify, adds lemmas, relates toArray.modify. -
#5799 relates
Array.forInandList.forIn. -
#5833 adds
Array.forIn', and relates toList. -
#5848 fixes deprecations in
Init.Data.Array.Basicto not recommend the deprecated constant. -
#5895 adds
LawfulBEq (Array α) ↔ LawfulBEq α. -
#5896 moves
@[simp]fromback_eq_back?toback_push. -
#5897 renames
Array.backtoback!.
-
-
List-
#5605 removes
List.redLength. -
#5696 upstreams
List.mapIdxand adds lemmas. -
#5697 upstreams
List.foldxM_map. -
#5701 renames
List.jointoList.flatten. -
#5703 upstreams
List.sum. -
#5706 marks
prefix_append_right_injas a simp lemma. -
#5716 fixes
List.drop_dropaddition order. -
#5731 renames
List.bindandArray.concatMaptoflatMap. -
#5732 renames
List.puretoList.singleton. -
#5742 upstreams
ne_of_mem_of_not_mem. -
#5743 upstreams
ne_of_apply_ne. -
#5816 adds more
List.modifylemmas. -
#5879 renames
List.groupBytosplitBy. -
#5913 relates
forloops overListwithfoldlM.
-
-
Nat -
Fixed width integers
-
BitVec-
#5604 completes
BitVec.[getMsbD|getLsbD|msb]for shifts (@luisacicolini). -
#5609 adds lemmas for division when denominator is zero (@bollu).
-
#5620 documents Bitblasting (@bollu)
-
#5623 moves
BitVec.udiv/umod/sdiv/smodafteradd/sub/mul/lt(@tobiasgrosser). -
#5645 defines
udivnormal form to be/, resp.umodand%(@bollu). -
#5646 adds lemmas about arithmetic inequalities (@bollu).
-
#5680 expands relationship with
toFin(@tobiasgrosser). -
#5691 adds
BitVec.(getMSbD, msb)_(add, sub)andBitVec.getLsbD_sub(@luisacicolini). -
#5712 adds
BitVec.[udiv|umod]_[zero|one|self](@tobiasgrosser). -
#5718 adds
BitVec.sdiv_[zero|one|self](@tobiasgrosser). -
#5721 adds
BitVec.(msb, getMsbD, getLsbD)_(neg, abs)(@luisacicolini). -
#5772 adds
BitVec.toInt_sub, simplifiesBitVec.toInt_neg(@tobiasgrosser). -
#5778 prove that
intMinthe smallest signed bitvector (@alexkeizer). -
#5851 adds
(msb, getMsbD)_twoPow(@luisacicolini). -
#5858 adds
BitVec.[zero_ushiftRight|zero_sshiftRight|zero_mul]and cleans up BVDecide (@tobiasgrosser). -
#5865 adds
BitVec.(msb, getMsbD)_concat(@luisacicolini). -
#5881 adds
Hashable (BitVec n)
-
-
String/Char -
HashMap-
#5880 adds interim implementation of
HashMap.modify/alter
-
-
Other
-
#5704 removes
@[simp]fromOption.isSome_eq_isSome. -
#5739 upstreams material on
Prod. -
#5740 moves
AntisymmtoStd.Antisymm. -
#5741 upstreams basic material on
Sum. -
#5756 adds
Nat.log2_two_pow(@spinylobster). -
#5892 removes duplicated
ForIninstances. -
#5900 removes
@[simp]fromSum.forallandSum.exists. -
#5812 removes redundant
Decidableassumptions (@FR-vdash-bot).
-
Compiler, runtime, and FFI
-
#5685 fixes help message flags, removes the
-fflag and adds the-gflag (@James-Oswald). -
#5930 adds
--short-version(-V) option to display short version (@juhp). -
#5144 switches all 64-bit platforms over to consistently using GMP for bignum arithmetic.
-
#5753 raises the minimum supported Windows version to Windows 10 1903 (released May 2019).
Lake
-
#5715 changes
lake new mathto useautoImplicit false(@eric-wieser). -
#5688 makes
Lakenot create core aliases in theLakenamespace. -
#5924 adds a
textoption forbuildFile*utilities. -
#5789 makes
lake initnotgit initwhen inside git work tree (@haoxins). -
#5684 has Lake update a package's
lean-toolchainfile onlake updateif it finds the package's direct dependencies use a newer compatible toolchain. To skip this step, use the--keep-toolchainCLI option. (See breaking changes.) -
#6218 makes Lake no longer automatically fetch GitHub cloud releases if the package build directory is already present (mirroring the behavior of the Reservoir cache). This prevents the cache from clobbering existing prebuilt artifacts. Users can still manually fetch the cache and clobber the build directory by running
lake build <pkg>:release. -
#6231 improves the errors Lake produces when it fails to fetch a dependency from Reservoir. If the package is not indexed, it will produce a suggestion about how to require it from GitHub.
Documentation
Breaking changes
-
The syntax for providing arguments to deriving handlers has been removed, which was not used by any major Lean projects in the ecosystem. As a result, the
applyDerivingHandlersnow takes one fewer argument,registerDerivingHandlerWithArgsis now simplyregisterDerivingHandler,DerivingHandlerno longer includes the unused parameter, andDerivingHandlerNoArgshas been deprecated. To migrate code, delete the unusednoneargument and useregisterDerivingHandlerandDerivingHandler. (#5265) -
The minimum supported Windows version has been raised to Windows 10 1903, released May 2019. (#5753)
-
The
--leanCLI option forlakewas removed. Use theLEANenvironment variable instead. (#5684) -
The
inductive ... :=,structure ... :=, andclass ... :=syntaxes have been deprecated in favor of the... wherevariants. The old syntax produces a warning, controlled by thelinter.deprecatedoption. (#5542) -
The generated tactic configuration elaborators now land in
TacticMto make use of the current recovery state. Commands that wish to elaborate configurations should now usedeclare_command_config_elabinstead ofdeclare_config_elabto get an elaborator landing inCommandElabM. Syntaxes should migrate tooptConfiginstead of(config)?, but the elaborators are reverse compatible. (#5883)