Releases: leanprover/lean4
v4.13.0-rc3
Reapply "refactor: reduce Reservoir build fetch attempts & warnings (…
v4.13.0-rc2
Revert "feat: lake: Reservoir build cache (#5486)" This reverts commit ffb4c5becf89d57560dd6f48f7693b2fdb9de6f9.
v4.13.0-rc1
chore: update CMakeLists.txt
v4.12.0
v4.12.0
Language features, tactics, and metaprograms
-
bv_decide
tactic. This release introduces a new tactic for proving goals involvingBitVec
andBool
. It reduces the goal to a SAT instance that is refuted by an external solver, and the resulting LRAT proof is checked in Lean. This is used to synthesize a proof of the goal by reflection. As this process uses verified algorithms, proofs generated by this tactic useLean.ofReduceBool
, so this tactic includes the Lean compiler as part of the trusted code base. The external solver CaDiCaL is included with Lean and does not need to be installed separately to make use ofbv_decide
.For example, we can use
bv_decide
to verify that a bit twiddling formula leaves at most one bit set:def popcount (x : BitVec 64) : BitVec 64 := let rec go (x pop : BitVec 64) : Nat → BitVec 64 | 0 => pop | n + 1 => go (x >>> 2) (pop + (x &&& 1)) n go x 0 64 example (x : BitVec 64) : popcount ((x &&& (x - 1)) ^^^ x) ≤ 1 := by simp only [popcount, popcount.go] bv_decide
When the external solver fails to refute the SAT instance generated by
bv_decide
, it can report a counterexample:/-- error: The prover found a counterexample, consider the following assignment: x = 0xffffffffffffffff#64 -/ #guard_msgs in example (x : BitVec 64) : x < x + 1 := by bv_decide
See
Lean.Elab.Tactic.BVDecide
for a more detailed overview, and look intests/lean/run/bv_*
for examples. -
simp
tactic- #4988 fixes a panic in the
reducePow
simproc. - #5071 exposes the
index
option to thedsimp
tactic, introduced tosimp
in #4202. - #5159 fixes a panic at
Fin.isValue
simproc. - #5167 and #5175 rename the
simpCtorEq
simproc toreduceCtorEq
and makes it optional. (See breaking changes.) - #5187 ensures
reduceCtorEq
is enabled in thenorm_cast
tactic. - #5073 modifies the simp debug trace messages to tag with "dpre" and "dpost" instead of "pre" and "post" when in definitional rewrite mode. #5054 explains the
reduce
steps fortrace.Debug.Meta.Tactic.simp
trace messages.
- #4988 fixes a panic in the
-
ext
tactic- #4996 reduces default maximum iteration depth from 1000000 to 100.
-
induction
tactic- #5117 fixes a bug where
let
bindings in minor premises wouldn't be counted correctly.
- #5117 fixes a bug where
-
omega
tactic- #5157 fixes a panic.
-
conv
tactic- #5149 improves
arg n
to handle subsingleton instance arguments.
- #5149 improves
-
#5044 upstreams the
#time
command. -
#5079 makes
#check
and#reduce
typecheck the elaborated terms. -
Incrementality
- #4974 fixes regression where we would not interrupt elaboration of previous document versions.
- #5004 fixes a performance regression.
- #5001 disables incremental body elaboration in presence of
where
clauses in declarations. - #5018 enables infotrees on the command line for ilean generation.
- #5040 and #5056 improve performance of info trees.
- #5090 disables incrementality in the
case .. | ..
tactic. - #5312 fixes a bug where changing whitespace after the module header could break subsequent commands.
-
Definitions
- #5016 and #5066 add
clean_wf
tactic to clean up tactic state indecreasing_by
. This can be disabled withset_option debug.rawDecreasingByGoal false
. - #5055 unifies equational theorems between structural and well-founded recursion.
- #5041 allows mutually recursive functions to use different parameter names among the “fixed parameter prefix”
- #4154 and #5109 add fine-grained equational lemmas for non-recursive functions. See breaking changes.
- #5129 unifies equation lemmas for recursive and non-recursive definitions. The
backward.eqns.deepRecursiveSplit
option can be set tofalse
to get the old behavior. See breaking changes. - #5141 adds
f.eq_unfold
lemmas. Now Lean produces the following zoo of rewrite rules:TheOption.map.eq_1 : Option.map f none = none Option.map.eq_2 : Option.map f (some x) = some (f x) Option.map.eq_def : Option.map f p = match o with | none => none | (some x) => some (f x) Option.map.eq_unfold : Option.map = fun f p => match o with | none => none | (some x) => some (f x)
f.eq_unfold
variant is especially useful to rewrite withrw
under binders. - #5136 fixes bugs in recursion over predicates.
- #5016 and #5066 add
-
Variable inclusion
- #5206 documents that
include
currently only applies to theorems.
- #5206 documents that
-
Elaboration
- #4926 fixes a bug where autoparam errors were associated to an incorrect source position.
- #4833 fixes an issue where cdot anonymous functions (e.g.
(· + ·)
) would not handle ambiguous notation correctly. Numbers the parameters, making this example expand asfun x1 x2 => x1 + x2
rather thanfun x x_1 => x + x_1
. - #5037 improves strength of the tactic that proves array indexing is in bounds.
- #5119 fixes a bug in the tactic that proves indexing is in bounds where it could loop in the presence of mvars.
- #5072 makes the structure type clickable in "not a field of structure" errors for structure instance notation.
- #4717 fixes a bug where mutual
inductive
commands could create terms that the kernel rejects. - #5142 fixes a bug where
variable
could fail when mixing binder updates and declarations.
-
Other fixes or improvements
- #5118 changes the definition of the
syntheticHole
parser so that hovering over_
in?_
gives the docstring for synthetic holes. - #5173 uses the emoji variant selector for ✅️,❌️,💥️ in messages, improving fonts selection.
- #5183 fixes a bug in
rename_i
where implementation detail hypotheses could be renamed.
- #5118 changes the definition of the
Language server, widgets, and IDE extensions
- #4821 resolves two language server bugs that especially affect Windows users. (1) Editing the header could result in the watchdog not correctly restarting the file worker, which would lead to the file seemingly being processed forever. (2) On an especially slow Windows machine, we found that starting the language server would sometimes not succeed at all. This PR also resolves an issue where we would not correctly emit messages that we received while the file worker is being restarted to the corresponding file worker after the restart.
- #5006 updates the user widget manual.
- #5193 updates the quickstart guide with the new display name for the Lean 4 extension ("Lean 4").
- #5185 fixes a bug where over time "import out of date" messages would accumulate.
- #4900 improves ilean loading performance by about a factor of two. Optimizes the JSON parser and the conversion from JSON to Lean data structures; see PR description for details.
- Other fixes or improvements
- #5031 localizes an instance in
Lsp.Diagnostics
.
- #5031 localizes an instance in
Pretty printing
- #4976 introduces
@[app_delab]
, a macro for creating delaborators for particular constants. The@[app_delab ident]
syntax resolvesident
to its constant namename
and th...
v4.12.0-rc1
chore: use `Expr.numObjs` instead of `lean_expr_size_shared` (#5239) Remark: declarations like `sizeWithSharing` must be in `IO` since they are not functions. The commit also uses the more efficient `ShareCommon.shareCommon'`.
v4.11.0
Language features, tactics, and metaprograms
-
The variable inclusion mechanism has been changed. Like before, when a definition mentions a variable, Lean will add it as an argument of the definition, but now in theorem bodies, variables are not included based on usage in order to ensure that changes to the proof cannot change the statement of the overall theorem. Instead, variables are only available to the proof if they have been mentioned in the theorem header or in an
include
command or are instance implicit and depend only on such variables. Theomit
command can be used to omit included variables.See breaking changes below.
-
Recursive definitions
-
Structural recursion can now be explicitly requested using
termination_by structural x
in analogy to the existing
termination_by x
syntax that causes well-founded recursion to be used.
#4542 -
#4672 fixes a bug that could lead to ill-typed terms.
-
The
termination_by?
syntax no longer forces the use of well-founded recursion, and when structural
recursion is inferred, it will print the result using thetermination_by structural
syntax. -
Mutual structural recursion is now supported. This feature supports both mutual recursion over a non-mutual
data type, as well as recursion over mutual or nested data types:mutual def Even : Nat → Prop | 0 => True | n+1 => Odd n def Odd : Nat → Prop | 0 => False | n+1 => Even n end mutual inductive A | other : B → A | empty inductive B | other : A → B | empty end mutual def A.size : A → Nat | .other b => b.size + 1 | .empty => 0 def B.size : B → Nat | .other a => a.size + 1 | .empty => 0 end inductive Tree where | node : List Tree → Tree mutual def Tree.size : Tree → Nat | node ts => Tree.list_size ts def Tree.list_size : List Tree → Nat | [] => 0 | t::ts => Tree.size t + Tree.list_size ts end
Functional induction principles are generated for these functions as well (
A.size.induct
,A.size.mutual_induct
).Nested structural recursion is still not supported.
PRs: #4639, #4715, #4642, #4656, #4684, #4715, #4728, #4575, #4731, #4658, #4734, #4738, #4718, #4733, #4787, #4788, #4789, #4807, #4772
-
#4809 makes unnecessary
termination_by
clauses cause warnings, not errors. -
#4831 improves handling of nested structural recursion through non-recursive types.
-
#4839 improves support for structural recursive over inductive predicates when there are reflexive arguments.
-
-
simp
tactic- #4784 sets configuration
Simp.Config.implicitDefEqProofs
totrue
by default.
- #4784 sets configuration
-
omega
tactic -
decide
tactic- #4711 switches from using default transparency to at least default transparency when reducing the
Decidable
instance. - #4674 adds detailed feedback on
decide
tactic failure. It tells you whichDecidable
instances it unfolded, if it get stuck onEq.rec
it gives a hint about avoiding tactics when definingDecidable
instances, and if it gets stuck onClassical.choice
it gives hints about classical instances being in scope. During this process, it processesDecidable.rec
s and matches to pin blame on a non-reducing instance.
- #4711 switches from using default transparency to at least default transparency when reducing the
-
@[ext]
attribute- #4543 and #4762 make
@[ext]
realizeext_iff
theorems from userext
theorems. Fixes the attribute so that@[local ext]
and@[scoped ext]
are usable. The@[ext (iff := false)]
option can be used to turn offext_iff
realization. - #4694 makes "go to definition" work for the generated lemmas. Also adjusts the core library to make use of
ext_iff
generation. - #4710 makes
ext_iff
theorem preserve inst implicit binder types, rather than making all binder types implicit.
- #4543 and #4762 make
-
#eval
command- #4810 introduces a safer
#eval
command that prevents evaluation of terms that containsorry
. The motivation is that failing tactics, in conjunction with operations such as array accesses, can lead to the Lean process crashing. Users can use the new#eval!
command to use the previous unsafe behavior. (#4829 adjusts a test.)
- #4810 introduces a safer
-
#4447 adds
#discr_tree_key
and#discr_tree_simp_key
commands, for helping debug discrimination tree failures. The#discr_tree_key t
command prints the discrimination tree keys for a termt
(or, if it is a single identifier, the type of that constant). It uses the default configuration for generating keys. The#discr_tree_simp_key
command is similar to#discr_tree_key
, but treats the underlying type as one of a simp lemma, that is it transforms it into an equality and produces the key of the left-hand side.For example,
#discr_tree_key (∀ {a n : Nat}, bar a (OfNat.ofNat n)) -- bar _ (@OfNat.ofNat Nat _ _) #discr_tree_simp_key Nat.add_assoc -- @HAdd.hAdd Nat Nat Nat _ (@HAdd.hAdd Nat Nat Nat _ _ _) _
-
#4741 changes option parsing to allow user-defined options from the command line. Initial options are now re-parsed and validated after importing. Command line option assignments prefixed with
weak.
are silently discarded if the option name without the prefix does not exist. -
Deriving handlers
-
Metaprogramming
- #4593 adds
unresolveNameGlobalAvoidingLocals
. - #4618 deletes deprecated functions from 2022.
- #4642 adds
Meta.lambdaBoundedTelescope
. - #4731 adds
Meta.withErasedFVars
, to enter a context with some fvars erased from the local context. - #4777 adds assignment validation at
closeMainGoal
, preventing users from circumventing the occurs check for tactics such asexact
. - #4807 introduces
Lean.Meta.PProdN
module for packing and projecting nestedPProd
s. - #5170 fixes
Syntax.unsetTrailing
. A consequence of this is that "go to definition" now works on the last module name in animport
block (issue #4958).
- #4593 adds
Language server, widgets, and IDE extensions
- #4727 makes it so that responses to info view requests come as soon as the relevant tactic has finished execution.
- #4580 makes it so that whitespace changes do not invalidate imports, and so starting to type the first declaration after imports should no longer cause them to reload.
- [#4780](https://github.com/leanprover/lean4/pull...
v4.11.0-rc3
v4.11.0-rc2
chore: adapt stdlib to new `variable` behavior
v4.11.0-rc1
What's Changed
- feat: upstream
List.attach
andArray.attach
from Batteries by @llllvvuu in #4586 - fix: typo hearbeats -> heartbeats by @kmill in #4590
- feat: total ByteArray.toList/findIdx? by @Vtec234 in #4582
- chore: release triggers update of release.lean-lang.org by @nomeata in #4531
- chore: begin development cycle for v4.11.0 by @semorrison in #4594
- chore: pr-release: adjust to new lakefile.lean syntax by @nomeata in #4598
- fix: adapt kernel interruption to new cancellation system by @Kha in #4584
- feat: omega error message: normalize constraint order by @nomeata in #4612
- fix: diagnostics: show kernel diags even if it is the only section by @nomeata in #4611
- feat: termination_by structural by @nomeata in #4542
- feat: mul recurrence theorems for LeanSAT by @bollu in #4568
- fix: unresolve name avoiding locals by @digama0 in #4593
- feat: Nat.and_le_(left|right) by @TwoFX in #4597
- feat: additional lemmas for Option by @TwoFX in #4599
- feat: additional lemmas for lists by @TwoFX in #4602
- feat: getElem_congr by @TwoFX in #4603
- feat: additional lemmas for cond by @TwoFX in #4604
- feat: additional lemmas for bounded integers by @TwoFX in #4605
- chore: defs that should be theorems by @semorrison in #4619
- chore: delete deprecations from 2022 by @semorrison in #4618
- chore: satisfy duplicate namespace linter by @semorrison in #4616
- chore: follow simpNF linter's advice by @semorrison in #4620
- chore: add 'since' dates to deprecated by @semorrison in #4617
- chore: make constructor-as-variable test more robust by @TwoFX in #4625
- fix: enforce
isDefEqStuckEx
atunstuckMVar
procedure by @leodemoura in #4596 - fix: Windows build by @Kha in #4628
- chore: pr-release: use right tag name by @nomeata in #4632
- fix: set default value of
pp.instantiateMVars
to true and make the option be effective by @kmill in #4558 - feat: USize.and_toNat by @TwoFX in #4629
- feat: Option.or by @TwoFX in #4600
- chore: typo by @alok in #4635
- feat: safe exponentiation by @leodemoura in #4637
- fix: make sure syntax nodes always run their formatters by @kmill in #4631
- chore: manual nightly trigger by @Kha in #4638
- chore: CI: restart-on-label: view run more often by @nomeata in #4640
- refactor: include declNames in Structural.EqnInfo by @nomeata in #4639
- fix: snapshot subtree was not restored on reuse by @Kha in #4643
- refactor: lambdaBoundedTelescope by @nomeata in #4642
- fix: improve
synthAppInstances
by @leodemoura in #4646 - feat: EquivBEq and LawfulHashable classes by @TwoFX in #4607
- feat: additional lemmas for arrays by @TwoFX in #4627
- fix: universe level in .below and .brecOn construction by @nomeata in #4651
- refactor: Split Constructions module by @nomeata in #4656
- feat: Std.HashMap by @TwoFX in #4583
- chore: restart-on-label: wait for 30s by @nomeata in #4663
- fix: don't set
pp.tagAppFns
when pretty printing signatures by @kmill in #4665 - fix: move Std from libleanshared to much smaller libInit_shared by @Kha in #4661
- fix: explicitly initialize
Std
inlean_initialize
by @Kha in #4668 - chore: make Antisymm a Prop by @semorrison in #4666
- fix:
hasBadParamDep?
to look at term, not type by @nomeata in #4672 - chore: bump actions/checkout and actions/upload-artifacts by @nomeata in #4664
- chore: cleanup unused arguments (from linter) by @semorrison in #4621
- fix: unorphan modules in Init by @TwoFX in #4680
- fix: unorphan modules in Std.Data by @TwoFX in #4679
- chore: update codeowners by @TwoFX in #4681
- chore:
Inhabited
instances forStd.HashMap
by @TwoFX in #4682 - chore: fix "max dynamic symbols" metric by @Kha in #4669
- fix: calculate error suppression per snapshot by @Kha in #4657
- chore: update comments in kernel/declaration.h by @nomeata in #4683
- feat: structural mutual recursion by @nomeata in #4575
- feat:
Process.tryWait
by @hargoniX in #4660 - chore: adjust
List.replicate
simp lemmas by @semorrison in #4687 - chore: upstream
ToExpr FilePath
andcompile_time_search_path%
by @semorrison in #4453 - chore: forward and backward directions of not_exists by @semorrison in #4688
- chore: upstream SMap.foldM by @semorrison in #4690
- chore: improve compatibility of tests/list_simp with Mathlib by @semorrison in #4691
- chore: add step to release checklist by @semorrison in #4693
- refactor:
InductiveVal.numNested
instead of.isNested
by @nomeata in #4684 - feat: make
@[ext]
deriveext_iff
theorems from userext
theorems by @kmill in #4543 - chore: upstream eq_iff_true_of_subsingleton by @semorrison in #4689
- chore: make use of
ext_iff
realization now that stage0 is updated by @kmill in #4694 - feat: lake:
require @ git
by @tydeu in #4692 - feat: omega doesn't push coercion over multiplication unnecessarily by @semorrison in #4695
- feat: chore upstream
List.Sublist
and API from Batteries by @semorrison in #4697 - fix: prefer original module in const2ModIdx by @digama0 in #4652
- feat: characterisations of List.Sublist by @semorrison in #4704
- feat: basic material on List.Pairwise and Nodup by @semorrison in #4706
- doc: update release checklist for new release notes workflow by @kmill in #4458
- feat: lemmas for List.head and List.getLast by @semorrison in #4678
- feat: simp normal form tests for Pairwise and Nodup by @semorrison in #4707
- chore: reorganise lemmas on list getters by @semorrison in #4708
- fix:
Repr
instances forInt
andFloat
by @leodemoura in #4709 - fix:
decide
tactic transparency by @leodemoura in #4711 - fix: make iff theorem generated by
@[ext]
preserve inst implicits by @kmill in #4710 - fix: deprecated warnings for overloaded symbols by @leodemoura in #4713
- fix: mutual structural recursion: check that datatype parameters agree by @nomeata in #4715
- feat: upstream more erase API by @semorrison in #4720
- chore: fix typo in doc-string by @grunweg in #4719
- feat: further theorems for List.erase by @semorrison in #4723
- fix: make matcher pretty printer sensitive to
pp.explicit
by @kmill in #4724 - fix: nested structural recursion over reflexive data type by @nomeata in #4728
- feat: detailed feedback on
decide
tactic failure by @kmill in #4674 - feat: Meta.withErasedFVars by @no...
v4.10.0
Language features, tactics, and metaprograms
-
split
tactic:- #4401 improves the strategy
split
uses to generalize discriminants of matches and addstrace.split.failure
trace class for diagnosing issues.
- #4401 improves the strategy
-
rw
tactic: -
simp
tactic:- #4430 adds
dsimproc
s forif
expressions (ite
anddite
). - #4434 improves heuristics for unfolding. Equational lemmas now have priorities where more-specific equationals lemmas are tried first before a possible catch-all.
- #4481 fixes an issue where function-valued
OfNat
numeric literals would become denormalized. - #4467 fixes an issue where dsimp theorems might not apply to literals.
- #4484 fixes the source position for the warning for deprecated simp arguments.
- #4258 adds docstrings for
dsimp
configuration. - #4567 improves the accuracy of used simp lemmas reported by
simp?
. - fb9727 adds (but does not implement) the simp configuration option
implicitDefEqProofs
, which will enable includingrfl
-theorems in proof terms.
- #4430 adds
-
omega
tactic:- #4360 makes the tactic generate error messages lazily, improving its performance when used in tactic combinators.
-
bv_omega
tactic:- #4579 works around changes to the definition of
Fin.sub
in this release.
- #4579 works around changes to the definition of
-
#4490 sets up groundwork for a tactic index in generated documentation, as there was in Lean 3. See PR description for details.
-
Commands
- #4370 makes the
variable
command fully elaborate binders during validation, fixing an issue where some errors would be reported only at the next declaration. - #4408 fixes a discrepency in universe parameter order between
theorem
anddef
declarations. - #4493 and #4482 fix a discrepancy in the elaborators for
theorem
,def
, andexample
,
makingProp
-valuedexample
s and other definition commands elaborate liketheorem
s. - 8f023b, 3c4d6b and 0783d0 change the
#reduce
command to be able to control what gets reduced.
For example,#reduce (proofs := true) (types := false) e
reduces both proofs and types in the expressione
.
By default, neither proofs or types are reduced. - #4489 fixes an elaboration bug in
#check_tactic
. - #4505 adds support for
open _root_.<namespace>
.
- #4370 makes the
-
Options
- #4576 adds the
debug.byAsSorry
option. Settingset_option debug.byAsSorry true
causes allby ...
terms to elaborate assorry
. - 7b56eb and d8e719 add the
debug.skipKernelTC
option. Settingset_option debug.skipKernelTC true
turns off kernel typechecking. This is meant for temporarily working around kernel performance issues, and it compromises soundness since buggy tactics may produce invalid proofs, which will not be caught if this option is set to true.
- #4576 adds the
-
#4301 adds a linter to flag situations where a local variable's name is one of
the argumentless constructors of its type. This can arise when a user either
doesn't open a namespace or doesn't add a dot or leading qualifier, as
in the following:inductive Tree (α : Type) where | leaf | branch (left : Tree α) (val : α) (right : Tree α) def depth : Tree α → Nat | leaf => 0
With this linter, the
leaf
pattern is highlighted as a local
variable whose name overlaps with the constructorTree.leaf
.The linter can be disabled with
set_option linter.constructorNameAsVariable false
.Additionally, the error message that occurs when a name in a pattern that takes arguments isn't valid now suggests similar names that would be valid. This means that the following definition:
def length (list : List α) : Nat := match list with | nil => 0 | cons x xs => length xs + 1
now results in the following warning:
warning: Local variable 'nil' resembles constructor 'List.nil' - write '.nil' (with a dot) or 'List.nil' to use the constructor. note: this linter can be disabled with `set_option linter.constructorNameAsVariable false`
and error:
invalid pattern, constructor or constant marked with '[match_pattern]' expected Suggestion: 'List.cons' is similar
-
Metaprogramming
- #4454 adds public
Name.isInternalDetail
function for filtering declarations using naming conventions for internal names.
- #4454 adds public
-
Other fixes or improvements
Language server, widgets, and IDE extensions
- #4443 makes the watchdog be more resilient against badly behaving clients.
Pretty printing
- #4433 restores fallback pretty printers when context is not available, and documents
addMessageContext
. - #4556 introduces
pp.maxSteps
option and sets the default value ofpp.deepTerms
tofalse
. Together, these keep excessively large or deep terms from overwhelming the Infoview.
Library
- #4560 splits
GetElem
class intoGetElem
andGetElem?
.
This enables removingDecidable
instance arguments fromGetElem.getElem?
andGetElem.getElem!
, improving their rewritability.
See the docstrings for these classes for more information. Array
List
- #4469 and #4475 improve the organization of the
List
API. - #4470 improves the
List.set
andList.concat
API. - #4472 upstreams lemmas about
List.filter
from Batteries. - #4473 adjusts
@[simp]
attributes. - #4488 makes
List.getElem?_eq_getElem
be a simp lemma. - #4487 adds missing
List.replicate
API. - #4521 adds lemmas about
List.map
. - #4500 changes
List.length_cons
to useas.length + 1
instead ofas.length.succ
. - #4524 fixes the statement of
List.filter_congr
. - #4525 changes binder explicitness in
List.bind_map
. - #4550 adds
maximum?_eq_some_iff'
andminimum?_eq_some_iff?
.
- #4469 and #4475 improve the organization of the
- #4400 switches the normal forms for indexing
List
andArray
toxs[n]
andxs[n]?
. HashMap
- #4372 fixes linearity in
HashMap.insert
andHashMap.erase
, leading to a 40% speedup in a replace-heavy workload.
- #4372 fixes linearity in
Option
Nat
Int
- #3850 adds complete div/mod simprocs for
Int
.
*...
- #3850 adds complete div/mod simprocs for