Lean 4.27.0 (2026-01-24)
此版本有 372 项更改。除了下面列出的 118 项功能添加和 71 项修复之外,还有 28 项重构更改、13 项文档改进、25 项性能改进、6 项测试套件改进和 111 项其他更改。
亮点
模块系统稳定
#11637 声明模块系统不再是实验性的,并使 experimental.module 选项成为无操作。
有关文档,请参阅参考手册中的 模块和可见性 部分。
向后兼容性选项
#11304 记录 backward.* 选项只是临时的
移民辅助工具,可能会在 6 个月后消失,恕不另行通知
经过他们的介绍。如果用户依赖的话,请举报
关于这些选项。
性能提升
此版本包含许多性能改进,特别是:
错误信息
此版本包含对错误消息的一系列更改,旨在使其更加有用和可操作。 具体来说,一些消息现在有提示、建议和解释链接。
公关: #11119, #11245, #11346, #11347, #11456, #11482, #11518, #11554, #11555, #11621。
研磨的新功能
函数值同余闭包
#11323 引入了新的 grind 选项 funCC(默认启用),
它将同余闭包扩展到函数值相等。当
funCC 已启用,grind 跟踪部分应用的等式
函数,允许推理步骤,例如:
a : Nat → Nat f : (Nat → Nat) → (Nat → Nat) h : f a = a ⊢ (f a) m = a m g : Nat → Nat f : Nat → Nat → Nat h : f a = g ⊢ f a b = g b
此功能大大提高了 grind 对高阶和高阶的支持
部分应用函数等式,同时保持与
禁用 funCC 时的一阶 SMT 行为。
有关使用的更多详细信息,请参阅 PR 描述。
控制定理实例化
#11428 在 Lean.Parser.Command.grind_patterngrind_pattern 中实现对 guards 的支持。新的
功能提供了对定理实例化的额外控制。对于
例如,考虑以下单调性定理:
opaque f : Nat → Nat
theorem fMono : x ≤ y → f x ≤ f y := sorry
通过新的 guard 功能,我们可以指示 grind 实例化
theorem only if x ≤ y is already known to be true in the current grind state:
grind_pattern fMono => f x, f y where
guard x ≤ y
x =/= y
这可以显着减少定理实例化的数量。
有关更详细的讨论和示例证明跟踪,请参阅 PR 描述。
提供任意参数
#11268 实现对任意 grind 参数的支持。特点
与 simp 中提供的类似,其中处理证明项
作为局部宇宙多态引理。此功能依赖于 grind -revert(请参阅 #11248)。
例如,用户现在可以编写:
def snd (p : α × β) : β := p.2
theorem snd_eq (a : α) (b : β) : snd (a, b) = b := rfl
/--
trace: [grind.ematch.instance] snd_eq (a + 1): snd (a + 1, Type) = Type
[grind.ematch.instance] snd_eq (a + 1): snd (a + 1, true) = true
-/
#guard_msgs (trace) in
set_option trace.grind.ematch.instance true in
example (a : Nat) :
(snd (a + 1, true), snd (a + 1, Type), snd (2, 2)) =
(true, Type, snd (2, 2)) := a:Nat⊢ (snd (a + 1, true), snd (a + 1, Type), snd (2, 2)) = (true, Type, snd (2, 2))
All goals completed! 🐙
请注意,在上面的示例中,snd_eq 仅实例化两次,但具有不同的 Universe 参数。
研磨回复
#11248 实现选项 revert,该选项设置为 false
默认。
这是与还原假设相关的内部变化。
使用新的默认值,grind 生成的迹线、反例和证明项有所不同。
要恢复旧的 grind 行为,请使用 grind +revert。
Grind 的其他新功能
良基递归上 Nat
使用良基递归的定义通常是不可约的。
对于 #7965,当终止措施的类型为 Nat 时,
这样的定义可以减少,并且接受显式的 @[semireducible] 注释
没有通常的警告。
图书馆亮点
此版本完成了 String API 的修订,包括相关类型的 String.Pos、
对 String.Slice 的完整 API 支持,以及使用新的 Iterator API 的迭代器。
TreeMap/HashMap API 还添加了许多内容,包括交集、差值和相等。
这些更新包括一些“重大更改”,即:
-
#11180 重新定义了
String.take和要操作的变体String.Slice。虽然以前的函数返回一个子字符串 输入有时返回String有时返回Substring.Raw,他们现在统一返回String.Slice。这是一个重大变化,因为现在许多函数都有不同的 返回类型。例如,如果
s是一个字符串,而f是一个函数 接受字符串,f (s.drop 1)将不再编译,因为s.drop 1是String.Slice。要解决此问题,请插入对copy的调用 恢复旧行为:f (s.drop 1).copy。当然,很多情况下,还会有更高效的选择。对于 例如,不要写
f <| s.drop 1 |>.copy |>.dropEnd 1 |>.copy,写 改为f <| s.drop 1 |>.dropEnd 1 |>.copy。另外,代替(s.drop 1).copy = "Hello", writes.drop 1 == "Hello".toSlice.
重大变化
-
#11474 和 11562 将
noConfusion结构推广到异构 等式(假设参数和索引之间的命题等价)。 对于使用noConfusion原理的人来说,这是一个重大变化 对于带有索引的类型手动并显式地 传递合适的rfl参数,并根据需要对结果等式使用eq_of_heq。 -
#11490 防止嵌套
simp中的try吞咽心跳错误 调用,更一般地确保isRuntime标志通过throwNestedTacticEx。这可以防止证明的行为(特别是 使用aesop的用户)受到当前递归深度的影响或 心跳限制。 这会破坏 Mathlib 中的单个调用者,其中simp使用引理 形成x = f (g x)和堆栈溢出,可以通过以下方式修复 概括g x。
语言
-
#7965 lets recursive functions defined by well-founded recursion use a different
fixfunction when the termination measure is of typeNat. This fix-point operator use structural recursion on “fuel”, initialized by the given measure, and is thus reasonable to reduce, e.g. inby decideproofs. -
#11196 avoids match splitter calculation from testing all quadratically many pairs of alternatives for overlaps, by keeping track of possible overlaps during matcher calculation, storing that information in the
MatcherInfo, and using that during matcher calculation. -
#11200 changes how sparse case expressions represent the none-of-the-above information. Instead of many
x.ctorIdx ≠ ihypotheses, it introduces a singleNat.hasNotBit mask x.ctorIdxhypothesis which compresses that information into a bitmask. This avoids a quadratic overhead during splitter generation, where all n assumptions would be refined through.substand.casesconstructions for all n assumption of the splitter alternative. -
#11221 lets
realizeConstusewithDeclNameForAuxNamingso that auxiliary definitions created there get non-clashing names. -
#11222 implements
elabToSyntaxfor creating scoped syntaxs : Syntaxfor an arbitrary elaboratorel : Option Expr -> TermElabM Exprsuch thatelabTerm s = el. -
#11236 extracts two modules from
Match.MatchEqs, in preparation of #11220 and to use the module system to draw clear boundaries between concerns here. -
#11239 adds a
Unitassumption to alternatives of the splitter that would otherwise not have arguments. This fixes #11211. -
#11245 improves the error message encountered in the case of a type class instance resolution failure, and adds an error explanation that discusses the common new-user case of binary operation overloading and points to the
trace.Meta.synthInstanceoption for advanced debugging. -
#11256 replaces
MatcherInfo.numAltParamswith a more detailed data structure that allows us, in particular, to distinguish between an alternative for a constructor with aUnitfield and the alternative for a nullary constructor, where an artificialUnitargument is introduced. -
#11261 continues the homogenization between matchers and splitters, following up on #11256. In particular it removes the ambiguity whether
numParamsincludes thediscrEqnsor not. -
#11269 adds support for decidable equality of empty lists and empty arrays. Decidable equality for lists and arrays is suitably modified so that all diamonds are definitionally equal.
-
#11292 adds intersection operation on
ExtDTreeMap/ExtTreeMap/ExtTreeSetand proves several lemmas about it. -
#11301 allows setting reducibilityCoreExt in async contexts (e.g. when using
mkSparseCasesOnin a realizable definition) -
#11302 renames the CTests tests to use filenames as test names. So instead of
2080-leanruntest_issue5767.lean(失败)
we get
2080 - 测试/Lean/运行/issue5767.lean(失败)
which allows Ctrl-Click’ing on them in the VSCode terminal.
-
#11303 renames rename wrongly named
backwards.options tobackward. -
#11304 documents that
backward.*options are only temporary migration aids and may disappear without further notice after 6 months after their introduction. Users are kindly asked to report if they rely on these options. -
#11305 removes the
groupfield from option descriptions. It is unused, does not have a clear meaning and often matches the first component of the option name. -
#11307 removes all code that sets the
Option.Decl.groupfield, which is unused and has no clearly documented meaning. -
#11325 adds
CoreM.toIO', the analogue ofCoreM.toIOdropping the state from the return type, and similarly forTermElabM.toIO'andMetaM.toIO'. -
#11333 adds infrastructure for parallel execution across Lean's tactic monads.
-
#11338 upstreams the
with_weak_namespacecommand from Mathlib:with_weak_namespace <id> <cmd>changes the current namespace to<id>for the duration of executing command<cmd>, without causing scoped things to go out of scope. This is in preparation for upstreaming thescoped[Foo.Bar]syntax from Mathlib, which will be useful now that we are addinggrindannotations in scopes. -
#11346 modifies the error message for type synthesis failure for the case where the type class in question is potentially derivable using a
derivingcommand. Also changes the error explanation for type class instance synthesis failure with an illustration of this pattern. -
#11347 adds a focused error explanation aimed at the case where someone tries to use Natural-Numbers-Game-style
inductionproofs directly in Lean, where such proofs are not syntactically valid. -
#11353 applies beta reduction to specialization keys, allowing us to reuse specializations in more situations.
-
#11379 sets
@[macro_inline]on the (trivial).ctorIdxfor inductive types with one constructor, to reduce the number of symbols generated by the compiler. -
#11385 lets implicit instance names avoid name clashes with private declarations. This fixes #10329.
-
#11408 adds a difference operation on
ExtDTreeMap/ExtTreeMap/TreeSetand proves several lemmas about it. -
#11422 uses a kernel-reduction optimized variant of
Mon.mulingrind. -
#11425 changes
Lean.Order.CCPOand.CompleteLatticeto carry a Prop. This avoids theCCPO IOinstance from beingnoncomputable. -
#11432 fixes a typo in the docstring of
#guard_mgs. -
#11453 fixes undefined behavior where
delete(instead ofdelete[]) is called on an object allocated withnew[]. -
#11456 refines several error messages, mostly involving invalid use of field notation, generalized field notation, and numeric projection. Provides a new error explanation for field notation.
-
#11463 fixes a panic in
getEqnsFor?when called on matchers generated from match expressions in theorem types. -
#11474 generalizes the
noConfusionconstructions to heterogeneous equalities (assuming propositional equalities between the indices). This lays ground work for better support for applying injection to heterogeneous equalities in grind. -
#11476 adds a
{givenInstance}`C`documentation role that adds an instance ofCto the document's local assumptions. -
#11482 gives suggestions based on the currently-available constants when projecting from an unknown type.
-
#11485 ensures that
Nats in.oleanfiles use a deterministic serialization in the case whereLEAN_USE_GMPis not set. -
#11490 prevents
tryswallowing heartbeat errors from nestedsimpcalls, and more generally ensures theisRuntimeflag is propagated bythrowNestedTacticEx. This prevents the behavior of proofs (especially those usingaesop) being affected by the current recursion depth or heartbeat limit. -
#11492 uses the helper functions withImplicitBinderInfos and mkArrowN in more places.
-
#11493 makes
Match.MatchEqsa leaf module, to be less restricted in which features we can use there. -
#11502 adds two benchmarks for elaborating match statements of many
Natliterals, one without and one with splitter generation. -
#11508 avoids generating hyps when not needed (i.e. if there is a catch-all so no completeness checking needed) during matching on values.
This tweak was made possible by #11220.
-
#11510 avoids running substCore twice in caseValues.
-
#11511 implements a linter that warns when a deprecated coercion is applied. It also warns when the
Optioncoercion or theSubarray-to-Arraycoercion is used inInitorStd. The linter is currently limited toCoeinstances;CoeFuninstances etc. are not considered. -
#11518 provides an additional hint when the type of an autobound implicit is required to have function type or equality type — this fails, and the existing error message does not address the fact that the source of the error is an unknown identifier that was automatically bound.
-
#11541 adds support for underscores as digit separators in String.toNat?, String.toInt?, and related parsing functions. This makes the string parsing functions consistent with Lean's numeric literal syntax, which already supports underscores for readability (e.g., 100_000_000).
-
#11554 adds
@[suggest_for]annotations to Lean, allowing lean to provide corrections for.everyor.somemethods in place of.allor.anymethods for most default-imported types (arrays, lists, strings, substrings, and subarrays, and vectors). -
#11555 scans the environment for viable replacements for a dotted identifier (like
.zero) and suggests concrete alternatives as replacements. -
#11562 makes the
noConfusionprinciples even more heterogeneous, by allowing not just indices but also parameters to differ. -
#11566 lets the compiler treat per-constructor
noConfusionlike the general one, and moves some more logic closer to no confusion generation. -
#11571 lets
whnfnot consultisNoConfusion, to speed up this hot path a bit. -
#11587 adjusts the new
metakeyword of the experimental module system not to implypartialfor general consistency. -
#11607 makes argument-less tactic invocations of
Std.Dotactics such asmintroemit a proper error message "mintroexpects at least one pattern" instead of claiming thatStd.Tactic.Doneeds to be imported. -
#11611 fixes a
noConfusioncompilation introduced by #11562. -
#11619 allows Lean to present suggestions based on
@[suggest_for]annotations for unknown identifiers without internal dots. (The annotations in #11554 only gave suggestion for dotted identifiers likeArray.every->Array.alland not for bare identifiers likeResult->Exceptorℕ->Nat.) -
#11620 ports Batteries.WF to Init.WFC for executable well-founded fixpoints. It introduces
csimptheorems to replace the recursors and non-executable definitions with executable definitions. -
#11621 causes Lean to search through
@[suggest_for]annotations on certain errors that look like unknown identifiers that got incorrectly autobound. This will correctly identify that a declaration of typeMaybe Stringshould beOption Stringinstead. -
#11624 fixes a SIGFPE crash on x86_64 when evaluating
INT_MIN / -1orINT_MIN % -1for signed integer types. -
#11637 declares the module system as no longer experimental and makes the
experimental.moduleoption a no-op, to be removed. -
#11644 makes
.ctorIdxnot an abbrev; we don't wantgrindto unfold it. -
#11645 fixes the docstring of
propagateForallPropUp. It was copy’n’pasta before. -
#11652 teaches
grindhow to reduce.ctorIdxapplied to constructors. It can also handle tasks likexs ≍ Vec.cons x xs' → xs.ctorIdx = 1
thanks to a
.ctorIdx.hinjtheorem (generated on demand). -
#11657 improves upon #11652 by keeping the kernel-reduction-optimized definition.
图书馆
-
#8406 添加
getElem_swapIfInBounds*形式的引理并弃用getElem_swap'。 -
#9302 修改
Option.instDecidableEq和Option.decidableEqNone这样后者就可以成为一个全局实例而不会导致 钻石。它还添加了Option.decidableNoneEq。 -
#10204 更改
ForIn、ForIn'和ForM的接口 类型类不采用Monad m参数。这是一个重大改变 对于大多数下游instance,现在需要假设[Monad m]。 -
#10945 添加了
Std.Tricho r,这是一个用于标识关系的类型类 他们作为三分法。这优于Std.Antisymm (¬ r · ·)所有情况(它相当于)。 -
#11038 引入了一个新的定点组合器,
WellFounded.extrinsicFix。终止证明(如果提供的话)可以 是从外部给出的,即从外部看该术语,并且 仅当人们打算正式验证该行为时才需要 固定点。然后将新的组合器应用于迭代器 API。toList或ForIn等消费者不再需要证明 底层迭代器是有限的。如果想确保终止 从本质上讲,有严格的终止变体可用 例如,it.ensureTermination.toList而不是it.toList。 -
#11112 在
DHashMap/HashMap/HashSet上添加交集运算 并提供了关于其行为的几个引理。 -
#11141 为切片和 MPL 提供多态
ForIn实例 使用for ... in对切片进行迭代的spec引理。它还 提供专门用于Subarray的版本。 -
#11165 提供
DTreeMap/TreeMap/TreeSet和TreeSet上的交集 提供了几个关于它的引理。 -
#11178 提供了更多关于
Subarray和ListSlice的引理 还添加了对这两种类型切片的子切片的支持。 -
#11180 重新定义了
String.take和要操作的变体String.Slice。虽然以前的函数返回一个子字符串 输入有时返回String有时返回Substring.Raw,他们现在统一返回String.Slice。 -
#11212 添加了对差分运算的支持
DHashMap/HashMap/HashSet并证明了有关它的几个引理。 -
#11218 将
String.offsetOfPos重命名为String.Pos.Raw.offsetOfPos与其他String.Pos.Raw操作保持一致。 -
#11222 实现
elabToSyntax用于创建作用域语法: 语法for an arbitrary elaboratorel:选项 Expr -> TermElabM Expr这样elabTerm s = el`。 -
#11223 添加了与
emptyWithCapacity/empty相关的缺失引理和toList/keys/values适用于DHashMap/HashMap/HashSet。 -
#11231 添加了几个相关的引理
getMin/getMin?/getMin!/getMinD并插入到空 (D)TreeMap/TreeSet 及其扩展变体。 -
#11232 弃用
String.toSubstring,转而使用String.toRawSubstring(参见#11154)。 -
#11235 在以下位置注册
Lean.Parser.Term.elabToSyntax的节点类型 为了支持Lean.Elab.Term.elabToSyntax功能,无需 为用户可访问的语法注册专用解析器。 -
#11237 修复了
UInt64.fromJson?引发的错误和USize.fromJson?使用缺失的s!。 -
#11240 将
String.ValidPos重命名为String.Pos、String.endValidPos至String.endPos和String.startValidPos至String.startPos。 -
#11241 提供交集运算
ExtDHashMap/ExtHashMap/ExtHashSet并证明了几个引理 它。 -
#11242 显着更改了
ToIterator类型的签名 类。获得的迭代器的状态不再是依值类型的并且 是outParam,而不是捆绑在类中。除其他外 好处是,simp现在可以在Slice.toList内部进行重写,并且Slice.toArray。缺点是我们失去了灵活性。例如,Subarray迭代器的前一个基于组合器的实现是 不再可行,因为状态是依值类型的。因此, 此 PR 提供了Subarray的手写迭代器,它没有 需要一种依值类型的状态并且比前一个状态更快。 -
#11243 将
ofArray添加到DHashMap/HashMap/HashSet并证明 simpl 引理允许将ofArray重写为ofList。 -
#11250 引入了一个函数
String.split,它基于String.Slice.split因此支持所有模式类型和 返回Std.Iter String.Slice。 -
#11255 减少使用字符串模式时的分配。在 特别的
startsWith、dropPrefix?、endsWith、dropSuffix?已优化。 -
#11263 修复了新
StringAPI 中的多个内存泄漏问题。 -
#11266 为
DHashMap/HashMap/HashSet添加BEq实例及其 扩展变体并证明与等价相关的引理 哈希图/扩展变体的相等。 -
#11267 重命名并集的同余引理
DHashMap/HashMap/HashSet/DTreeMap/TreeMap/TreeSet适合 位于Equiv命名空间中的约定。 -
#11276 清理
String.find周围的 API 并将其统一移动到 新位置类型String.ValidPos和String.Slice.Pos -
#11281 添加了一些对从未存在过的函数的弃用 这对于在#11180 之后迁移代码的人们仍然有帮助。
-
#11282 为
String.Slice.contains添加别名String.Slice.any。 -
#11285 将
p : Char -> Prop的Std.Slice.Pattern实例添加为 只要DecidablePred p,允许像"hello".dropWhile (· = 'h')。 -
#11286 添加函数
String.Slice.length,其内容如下 弃用字符串:切片上没有恒定时间长度函数。 如果您只需要知道,请使用s.positions.count或isEmpty切片是否为空。 -
#11289 重新定义
String.foldl、String.isNat以使用它们的String.Slice对应。 -
#11290 将
String.replaceStartEnd重命名为String.slice,String.replaceStart至String.sliceFrom,以及String.replaceEnd至String.sliceTo,与上的相应功能类似String.Slice。 -
#11299 为
Fin添加许多@[grind]注释,并更新 测试。 -
#11308 重新定义
String上的front和back以进行处理String.Slice并添加了新的String功能front?、back?、positions、chars、revPositions、revChars、byteIterator、revBytes、lines。 -
#11316 添加
grind_pattern Exists.choose_spec => P.choose。 -
#11317 添加
grind_pattern Subtype.property => self.val。 -
#11321 提供有关
Nat范围的专门引理,包括simp用于证明所有人属性的注释和归纳原理 范围。 -
#11327 添加两个引理来证明
a / c < b / c。 -
#11341 添加从
String到String.Slice的强制转换。 -
#11343 将
String.bytes重命名为String.toByteArray。 -
#11354 添加了简单的引理,表明从 a 中的某个位置进行搜索 字符串返回至少位于该位置的内容。
-
#11357 更新了
foldr、all、any和contains函数String根据String.Slice对应项进行定义。 -
#11358 添加了
String.Slice.toInt?和变体。 -
#11376 旨在提高
String.contains的性能, 使用Char或Char -> Bool类型的模式时的String.find等 通过将针移出迭代器状态,从而解决 编译器中缺少拆箱。 -
#11380 将
String.Slice.Pos.ofSlice重命名为String.Pos.ofToSlice遵守(尚未记录的)映射命名约定 职位到职位。然后它添加了几个新功能,以便 从字符串和切片构造切片的各种方法,现在有 用于沿此向前和向后映射位置的函数 建设。 -
#11384 为
grind添加必要的实例来进行推理String.Pos.Raw、String.Pos和String.Slice.Pos。 -
#11399 添加了对差分运算的支持
ExtDHashMap/ExtHashMap/ExtHashSet并证明了几个引理 它。 -
#11404 为
DTreeMap/TreeMap/TreeSet添加 BEq 实例及其 扩展变体并证明与等价相关的引理 哈希图/扩展变体的相等。 -
#11407 对
DTreeMap/TreeMap/TreeSet添加差分运算 并证明了关于它的几个引理。 -
#11421 向
DHashMap/HashMap/HashSet添加可判定的相等性,并且 他们的扩展变体。 -
#11439 对字符串 API 执行小型维护
-
#11448 以常量
DTreeMap移动Inhabited实例(并且 相关)查询,例如Const.get!,其中Inhabited实例 可以在证明密钥之前提供。 -
#11452 添加引理,说明如果 get 操作返回一个值, 那么查询的键必须包含在集合中。这些引理 为基于 HashMap 和 TreeMap 的集合添加了类似的 还为
Init.getElem添加了引理。 -
#11465 修复了文档和代码库中的各种拼写错误 评论。
-
#11503 将
Char -> Bool模式标记为字符串的默认实例 搜索。这意味着像" ".find (·.isWhitespace)这样的东西现在可以 详尽无误。 -
#11521 修复了初始化时触发的分段错误 同时调用了一个新的计时器和重置。
-
#11527 向
DTreeMap/TreeMap/TreeSet添加可判定的相等性,并且 他们的扩展变体。 -
#11528 在键列表中添加与
minKey?和min?相关的引理 所有DTreeMap以及由此派生的其他容器。 -
#11542 从
List.countP_eq_length_filter中删除@[grind =]并Array.countP_eq_size_filter,正如用户报告的那样,这是有问题的。 -
#11548 添加
Lean.ToJson和Lean.FromJson实例String.Slice。 -
#11565 添加了与
insert/insertIfNew和toList相关的引理DTreeMap/DHashMap派生容器。 -
#11574 添加了一个引理,将自然数转换为任何有序的 环是非负的。我们不能直接为
grind进行注释,但是 可能会将其添加到grind的 linarith 内部结构中。 -
#11578 重构了
get操作的用法HashMap/TreeMap/ExtHashMap/ExtTreeMap到getElem实例。 -
#11591 添加了有关
ReaderT.run、OptionT.run、StateT.run和ExceptT.run与MonadControl操作交互。 -
#11596 在
Int上添加@[suggest_for ℤ],在Rat,遵循@[suggest_for ℕ]在Nat上建立的模式 在#11554。 -
#11600 在基本操作上添加了一些关于
EStateM.run的引理。 -
#11625 将
@[expose]添加到decidable_of_bool,以便 在其他地方通过-decide进行证明,减少到decidable_of_bool继续 减少。 -
#11654 更新
grind文档字符串。仍然提到cutsat已更名为lia。 ItaLean 期间报告了此问题。
策略
-
#11226 finally removes the old
grindframeworkSearchM. It has been replaced with the newActionframework. -
#11244 fixes minor issues in
grind. In preparation for addinggrind -revert. -
#11247 fixes an issue in the
grindpreprocessor.simpmay introduce assigned (universe) metavariables (e.g., when performing zeta-reduction). -
#11248 implements the option
revert, which is set tofalseby default. To recover the oldgrindbehavior, you should usegrind +revert. Previously,grindused theRevSimpIntroidiom, i.e., it would revert all hypotheses and then re-introduce them while simplifying and applying eagercases. This idiom created several problems:-
Users reported that
grindwould include unnecessary parameters. See here. -
Unnecessary section variables were also being introduced. See the new test contributed by Sebastian Graf.
-
Finally, it prevented us from supporting arbitrary parameters as we do in
simp. Insimp, I implemented a mechanism that simulates local universe-polymorphic theorems, but this approach could not be used ingrindbecause there is no mechanism for reverting (and re-introducing) local universe-polymorphic theorems. Adding such a mechanism would require substantial work: I would need to modify the local context object. I considered maintaining a substitution from the original variables to the new ones, but this is also tricky, because the mapping would have to be stored in thegrindgoal objects, and it is not just a simple mapping. After reverting everything, I would need to keep a sequence of original variables that must be added to the mapping as we re-introduce them, but eager case splits complicate this quite a bit. The whole approach felt overly messy.
-
-
#11265 marks the automatically generated
sizeOftheorems asgrindtheorems. -
#11268 implements support for arbitrary
grindparameters. The feature is similar to the one available insimp, where a proof term is treated as a local universe-polymorphic lemma. This feature relies ongrind -revert(see #11248). For example, users can now write:def snd (p : α × β) : β := p.2 theorem snd_eq (a : α) (b : β) : snd (a, b) = b := rfl
-
#11273 修复了
grind中证明构造期间的错误。 -
#11295 修复了所使用的
ite和dite的传播规则中的错误 在grind中。该错误阻止了等式传播到 卫星解算器。以下是受此问题影响的示例。 -
#11315 修复了影响
grind -revert的问题。在此模式下,分配 假设中的元变量没有被实例化。这个问题是 影响 Mathlib 中的两个文件。 -
#11318 修复了
grind中的本地声明内部化 使用grind -revert时暴露。此错误正在影响grindMathlib 中的证明。 -
#11319 改进了当
n不是grind时对Fin n的支持 数字。 -
#11323 引入了新的
grind选项funCC(默认启用), 它将同余闭包扩展到函数值等式。当funCC已启用,grind跟踪 部分应用的等式 函数,允许推理步骤,例如:a : Nat → Nat f : (Nat → Nat) → (Nat → Nat) h : f a = a ⊢ (f a) m = a m
-
#11326 ensures that users can provide
grindproof parameters whose types are notforall-quantified. Examples:不透明 f : Nat → Nat 公理 le_f (a : Nat) : a ≤ f a
-
#11330 将
cutsat策略重命名为lia,以便更好地与 定理证明界的标准术语。 -
#11331 在
grind中添加了对LawfulOfScientific类的支持。 示例:open Lean Grind Std variable [LE α] [LT α] [LawfulOrderLT α] [Field α] [OfScientific α] [LawfulOfScientific α] [IsLinearOrder α] [OrderedRing α] example : (2 / 3 : α) ≤ (0.67 : α) := by grind example : (1.2 : α) ≤ (1.21 : α) := by grind example : (2 / 3 : α) ≤ (67 / 100 : α) := by grind example : (1.2345 : α) ≤ (1.2346 : α) := by grind example : (2.3 : α) ≤ (4.5 : α) := by grind example : (2.3 : α) ≤ (5/2 : α) := by grind -
#11332 添加标记文件的
grind_annotated "YYYY-MM-DD"命令 如手动注释的研磨。 -
#11334 为环约束添加显式归一化层
grind linarith模块。例如,它将用于清理 当环是域时的分母。 -
#11335 启用语法
use [ns Foo]和“仅实例化” Foo]inside agrind策略块,并具有激活的效果 所有研磨模式的范围都在该命名空间内。我们可以用它来 使用grind` 实现专门的策略,但仅受控子集 定理。 -
#11348 激活
grind_annotated命令Init.Data.List.Lemmas通过删除 TODO 注释并取消注释 命令。 -
#11350 为
grind实现帮助程序 simproc。它是 用于清理grind linarith中分母的基础设施。 -
#11365 在
try?中启用并行性。目前,我们更换了attempt_all级(有两个,一个用于内置策略,包括grind和simp_all,以及所有用户分机的第二个) 并行版本。我们(还没有?)改变first的行为 为基础的阶段。 -
#11373 使库建议扩展状态在以下情况下可用 从
module文件导入。 -
#11375 添加了对清理
grind linarith中分母的支持 当类型为Field时。 -
#11391 为
grind_pattern实施新的约束类型 命令。这些约束允许用户控制定理实例化 在grind中。 它需要手动update-stage0,因为更改会影响.olean格式,如果没有它,PR 将失败。 -
#11396 更改
set_library_suggestions以创建辅助 定义标记为@[library_suggestions],而不是存储Syntax直接在环境中扩展。这可以更好地 跨模块的库建议的持久性和一致性。 -
#11405 实现以下
grind_pattern约束:grind_pattern fax => f x where depth x < 2
-
#11409 implements support for the
grind_patternconstraintsis_valueandis_strict_value. -
#11410 fixes a kernel type mismatch error in grind's denominator cleanup feature. When generating proofs involving inverse numerals (like
2⁻¹), the proof context is compacted to only include variables actually used. This involves renaming variable indices - e.g., if original indices were{0: r, 1: 2⁻¹}and only2⁻¹is used, it gets renamed to index 0. -
#11412 fixes an issue where
grindwould fail after multiplenorm_castcalls with the error "unexpected metadata found during internalization". -
#11428 implements support for guards in
grind_pattern. The new feature provides additional control over theorem instantiation. For example, consider the following monotonicity theorem:不透明 f : Nat → Nat theorem fMono : x ≤ y → f x ≤ f y := ...
-
#11429 documents the
grind_patterncommand for manually selecting theorem instantiation patterns, including multi-patterns and the constraint system (=/=,=?=,size,depth,is_ground,is_value,is_strict_value,gen,max_insts,guard,check). -
#11462 adds
solve_by_elimas a fallback in thetry?tactic's simple tactics. Whenrflandassumptionboth fail butsolve_by_elimsucceeds (e.g., for goals requiring hypothesis chaining or backtracking),try?will now suggestsolve_by_elim. -
#11464 improves the error message when no library suggestions engine is registered to recommend importing
Lean.LibrarySuggestions.Defaultfor the built-in engine. -
#11466 removes the "first pass" behavior where
exact?andapply?would trysolve_by_elimon the original goal before doing library search. This simplifies thelibrarySearchAPI and focuses these tactics on their primary purpose: finding library lemmas. -
#11468 adds
+suggestionssupport tosolve_by_elim, following the pattern established bygrind +suggestionsandsimp_all +suggestions. -
#11469 adds
+grindand+try?options toexact?andapply?tactics. -
#11471 fixes an incorrect reducibility setting when using
grindinteractive mode. -
#11480 adds the
grindoptionreducible(default:true). When enabled, definitional equality tests expand only declarations marked as@[reducible]. Usegrind -reducibleto allow expansion of non-reducible declarations during definitional equality tests. This option affects only definitional equality; the canonicalizer and theorem pattern internalization always unfold reducible declarations regardless of this setting. -
#11481 fixes a bug in
grind?. The suggestion using thegrindinteractive mode was dropping the configuration options provided by the user. In the following account, the third suggestion was dropping the-reducibleoption. -
#11484 fixes a bug in the
grindpattern validation. The bug affected type classes that were propositions. -
#11487 adds a heterogeneous version of the constructor injectivity theorems. These theorems are useful for indexed families, and will be used in
grind. -
#11491 implements heterogeneous constructor injectivity in
grind. -
#11494 re-enables star-indexed lemmas as a fallback for
exact?andapply?. -
#11519 marks
Natpower and divisibility theorems forgrind. We use the newgrind_patternconstraints to control theorem instantiation. Examples:example {x m n : Nat} (h : x = 4 ^ (m + 1) * n) : x % 4 = 0 := by 磨 -
#11520 在
grind_pattern中实现约束not_value x命令。它是约束is_value的否定。 -
#11522 为
Nat运算符实现grind传播器 simproc 与它们相关,但没有任何理论求解器支持。 示例:example (a b : Nat) : a = 3 → b = 6 → a &&& b = 2 := by grind example (a b : Nat) : a = 3 → b = 6 → a ||| b = 7 := by grind example (a b : Nat) : a = 3 → b = 6 → a ^^^ b = 5 := by grind example (a b : Nat) : a = 3 → b = 6 → a <<< b = 192 := by grind example (a b : Nat) : a = 1135 → b = 6 → a >>> b = 17 := by grind
-
#11547 确保由
register_try?_tactic是内部实现细节,应该 对面向用户的 linter 不可见。 -
#11556 向
exact?和apply?添加了一个+all选项,用于收集所有 成功的引理而不是停在第一个完整的解决方案上。 -
#11573 修复了
grind拒绝点表示法术语,将其误认为 局部假设。 -
#11579 确保基本定理被正确处理为
grind参数。此外,grind [(thm)]和grind [thm]应为 以同样的方式处理。 -
#11580 添加了缺失的
Nat.cast缺失标准化规则grind。例子:example (n : Nat) : Nat.cast n = n := by grind
-
#11589 改进了
grind模式的索引。我们现在包括符号 发生在嵌套的地面图案中。这对于最大限度地减少 激活的 E 匹配定理的数量。 -
#11593 修复了
grind不显示弃用的问题 当在其参数列表中使用已弃用的引理时发出警告。 -
#11594 修复了
grind?以包含术语参数(例如[show P by tac])在其建议中。此前,这些被删除的原因是 术语参数存储在extraFacts中,并且不通过电子匹配进行跟踪 就像命名引理一样。 -
#11604 修复了
grind中如何处理不带参数的定理。 -
#11605 修复了
grind 中a^p术语的内部化器中的错误 利纳里斯。 -
#11609 改进了
grind中的大小写启发式。在这个公关中,我们做 不增加第一个案例中的案例拆分数量。这个想法是 利用非时间顺序回溯:如果第一个案例得到解决 使用不依赖于案例假设的证明,我们回溯 并直接关闭原来的目标。在这种情况下,案例分割 是“免费的”,它对证明没有贡献。如果不计算它,我们 当案例分割结果无关紧要时,允许进行更深入的探索。 新的启发式解决了 #11545 中的第二个示例 -
#11613 确保我们将环归一化器应用于等式 从
grind核心模块传播到grind lia。它还确保 我们在标准化时使用安全/托管多项式函数。 -
#11615 添加了
Int.subNatNat到grind的标准化规则。 -
#11628 为
Semiring添加了一些*规范化规则到grind。 -
#11629 在使用的模式标准化代码中添加了缺失条件 在
grind中。它应该忽略支持基础术语。 -
#11635 确保
grind中使用的模式标准化器确实违反 小工具Grind.genPattern所做的假设和Grind.getHEqPattern。 -
#11638 修复了
grind中的位向量文字内部化。修复 确保由BitVec.ofNat索引的定理被正确激活。 -
#11639 在
grind ring中添加了对BitVec.ofNat的支持。例子:example (x : BitVec 8) : (x - 16#8)*(x + 272#8) = x^2 := by grind
-
#11640 在
grind lia中添加了对BitVec.ofNat的支持。例子:example (x y : BitVec 8) : y < 254#8 → x > 2#8 + y → x > 1#8 + y := by grind
-
#11653 添加与
Semiring对应的传播规则 #11628 中引入的标准化规则。新规则仅适用于 非交换半环,因为grind对它们的支持有限。 规范化规则在 Mathlib 中引入了意外行为 因为它们中和了one_mul等参数:任何定理 instance associated with such a parameter is reduced toTrueby the 标准化器。 -
#11656 增加了对
Int.sign、Int.fdiv、Int.tdiv、Int.fmod、Int.tmod和Int.bmod至grind。这些操作只是 预处理掉。我们假设它们在实践中并不常见。 示例:example {x y : Int} : y = 0 → (x.fdiv y) = 0 := by grind example {x y : Int} : y = 0 → (x.tdiv y) = 0 := by grind example {x y : Int} : y = 0 → (x.fmod y) = x := by grind example {x y : Int} : y = 1 → (x.fdiv (2 - y)) = x := by grind example {x : Int} : x > 0 → x.sign = 1 := by grind example {x : Int} : x < 0 → x.sign = -1 := by grind example {x y : Int} : x.sign = 0 → x*y = 0 := by grind -
#11658 修复了参数文字内部化的错误
grind。即,类型为BitVec _或Fin _的文字。 -
#11659 生成模式时添加
MessageData.withNamingContext@[grind]的建议。它修复了期间报告的另一个问题 意大利Lean。 -
#11660 修复了
grind中的另一个定理激活问题。 -
#11663 修复了
grind模式验证器。它涵盖了以下情况: instance is not tagged with the implicit instance binder. This happens 在声明中,例如ZeroMemClass.zero_mem {S : Type} {M : outParam Type} {inst1 : Zero M} {inst2 : SetLike S M} [self : @ZeroMemClass S M inst1 inst2] (s : S) : 0 ∈ s
Compiler
-
#11082 防止(非
@[export])定义之间的符号冲突 来自不同的 Lean 封装。 -
#11185 修复了要考虑的
reduceArity编译器传递 过度应用数量减少的函数。 以前,此传递假设参数数量 应用程序中的参数数量始终相同 签名。这通常是正确的,因为编译器急切地引入 只要返回类型是函数类型,就会产生参数 返回类型不是函数类型的函数。然而,对于 依值类型 有时是函数类型,有时不是, 这个假设被打破,导致附加参数被打破 掉了。 -
#11210 修复了在工作时发现的 LCNF 简化器中的错误 第11078章在由
unsafeCast引起的某些情况下,简化器会 记录有关cases的错误信息,导致进一步的错误 线。 -
#11215 修复了正确跟踪标头嵌套级别的问题 在模块文档之间,但不在模块文档内。
-
#11217 修复了 #10982 中闭包分配器更改的影响。到目前为止 据我们所知 此错误仅在非默认构建配置中有意义地体现 没有mimalloc,例如:
cmake --preset release -DUSE_MIMALLOC=OFF -
#11310 使专用程序(正确地)跨域共享更多缓存键 调用,使我们产生更少的代码膨胀。
-
#11340 修复了遇到非投影时的错误编译 琐碎的结构类型。
-
#11362 加速 ElimDeadBranches 编译器通道的终止。
-
#11366 按升序对输入 ElimDeadBranches 的声明进行排序 尺寸。当我们处理大量数据时,这可以提高性能 迭代。
-
#11381 修复了封闭术语提取不尊重的错误 的隐式不变量 c 发射器首先具有封闭项 decls,然后是其他 decls,在一个 南卡罗来纳州。这个bug还没有出现 在野外被触发,但在即将推出的工作期间被发现 的修改 专家。
-
#11383 修复了未装箱的结构投影的编译 标记为
extern的参数,添加缺少的dec指令。这导致了 当此类函数用作闭包时,会泄漏单个分配或 在口译员中。 -
#11388 是 #11381 的后续,并强制执行排序不变量 EmitC 所需的闭项和常量正确通过 在将声明保存到环境中之前进行拓扑排序。
-
#11426 关闭#11356。
-
#11445 稍微改进了创建盒装所涉及的类型 声明。以前的类型 返回盒装时,用于返回的 vdecl 始终为
tobj标量。这还不是最 我们可以给出精确的注释。 -
#11451 将 LCNF 中的 lambda 提升器改编为 eta 合约,而不是 如果可能的话,拉姆达升力。这可以防止创建数百个 代码库中不必要的 lambda。
-
#11517 实现 Nat.mul 的常量折叠
-
#11525 使 LCNF 简化器消除所有替代项都是的情况
.unreach改为.unreach。.unreach -
#11530 引入了新的
tagged_return属性。它允许用户 标记extern声明以保证始终返回tagged返回值。与object或tobject不同,编译器不 为它们发出引用计数操作。在未来的信息中 此属性将用于更强大的分析以删除 尽可能进行引用计数。 -
#11576 删除旧的 ElimDeadBranches 通道并移动新通道 过去的 lambda 提升。
-
#11586 允许在 IR 类型系统中投影
tagged值。
Documentation
-
#11119 引入了对“未定义标识符”错误的澄清说明 当未定义的标识符位于语法位置时的消息 自动绑定通常可能适用,但是自动绑定在哪里 禁用。
lean.unknownIdentifier中做了相应的注释 错误解释。 -
#11364 为出现在 参考手册。
-
#11472 添加
mkSlice方法缺少的文档字符串。 -
#11550 查看将出现在 Lean 中的
Std.Do的文档字符串 参考手册并添加了缺失的内容。 -
#11575 修复了
cases策略文档字符串中的拼写错误。 -
#11595 在
tests/lean/run/中进行测试的文档-Dlinter.all=false,并解释了如何在以下情况下启用特定的 linter: 测试 linter 行为。
Server
Lake
-
#11198 修复了 Lake 中建议不正确的错误消息 Lakefile 语法。
-
#11216 确保
computeArtifact的text参数始终为 在 Lake 代码中提供,修复了哈希错误buildArtifactUnlessUpToDate正在处理中。 -
#11270 在 Lake 中添加模块解析过程以消除歧义 在多个包中定义的模块。
-
#11500 将工作空间索引添加到构建使用的包的名称中 目标。为了澄清不同用途之间的区别 包的名称,此 PR 还弃用了
Package.name以获得更多信息 特定于用途的变体(例如,Package.keyName、Package.prettyName、Package.origName)。
Other
-
#11328 修复了释放每个文档意外保留的内存的问题 某些精化工作负载上的语言服务器中的版本。的 问题肯定是从 4.18.0 开始就存在的。
-
#11437 添加了录制功能,使
shake可以更多 精确跟踪进口是否应仅为其保留attribute命令。 -
#11496 为
shake实现新的标志和注释,以用于 Mathlib:选项: --保持暗示 保留其他导入所隐含的现有导入,从而 技术上不需要 不再了
--保留前缀 如果将导入
X替换为更具体的导入X.Y...这意味着, 而是保留原始导入。更一般地说,更喜欢 插入import X即使 不是原始进口的一部分,只要它是原始进口的一部分 传递性导入关闭 当前模块的。--保持公开 保留所有
public导入以避免外部的重大更改 下游模块--add-public 如果新导入已在原始公开中,则将其添加为
public关闭该模块。 换句话说,公共导入不会从模块中删除 除非它们甚至没有被使用 在私有范围内,那些被删除的将被重新添加为 下游public模块,即使只在私有范围内需要。不像--keep-public,这可能 引入重大更改,但仍会限制插入的数量 进口。注释: 可以将以下注释添加到 Lean 文件中,以便 配置的行为
shake。仅子字符串shake:直接后跟指令 已检查,因此多个 指令可以混合在一行中,例如-- shake: keep-downstream, shake: keep-all,他们 可以被任意注释包围,例如-- shake: keep (元程序输出依赖)。-
module -- shake: keep-downstream: 在所有(当前)下游模块中保留此模块,添加新的 如果需要的话进口它。 -
module -- shake: keep-all: 按原样保留此模块中的所有现有导入。现在新进口 由于上游需要 仍可能添加更改。 -
import X -- shake: keep: 在当前模块中保留此特定导入。最常见的 用例是保留一个 下游模块需要公共导入才有意义 的输出 本模块中定义的元程序。例如,如果策略是 定义可以合成 运行时引用一个定理,shake无法检测到 这本身和 该定理的模块应该公开导入并注释为keep在策略的 模块。
public import X -- shake: keep (元程序输出依赖) ... elab \"my_tropic\" :策略=> 执行 ... mkConst ``f -- `f`,在 `X` 中定义,可能出现在输出中
这个策略
-
-
#11507 优化导入期间的文件系统访问,获得约 3% 的胜利 在 Linux 上,其他平台上可能有更多。