Lean 语言参考

Lean 4.26.0 (2025-12-13)🔗

For this release, 264 changes landed. In addition to the 84 feature additions and 73 fixes listed below there were 10 refactoring changes, 7 documentation improvements, 13 performance improvements, 8 improvements to the test suite and 69 other changes.

Highlights🔗

Dependencies by Semantic Version🔗

#10959 enables Lake users to require Reservoir dependencies by a semantic version range. On a lake update, Lake will fetch the package's version information from Reservoir and select the newest version of the package that satisfies the range.

Grind🔗

Grind Pattern🔗

#11189 implements grind_pattern constraints. They are useful for controlling theorem instantiation in grind. As an example, consider the following two theorems:

theorem extract_empty {start stop : Nat} :
    (#[] : 数组 α).extract start stop = #[] := …

theorem extract_extract {as : Array α} {i j k l : Nat} :
    (as.extract i j).extract k l = as.extract (i + k) (min (i + l) j) := …

If both are used for theorem instantiation, an unbounded number of instances is generated as soon as we add the term #[].extract i j to the grind context.

We can now prevent this by adding a grind_pattern constraint to extract_extract:

grind_pattern extract_extract => (as.extract i j).extract k l 其中
  作为 =/= #[]

With this constraint, only one instance is generated, as expected:

/-- 跟踪:[grind.ematch.instance] extract_empty:#[].extract i j = #[] -/
#guard_msgs (drop error, trace) in
set_option trace.grind.ematch.instance true in
example (as : Array Nat) (h : #[].extract i j = as) : False := by
  仅研磨 [= extract_empty, usr extract_extract]

Grind Lint🔗

#11157 implements the #grind_lint command, a diagnostic tool for analyzing the behavior of theorems annotated for theorem instantiation. The command helps identify problematic theorems that produce excessive or unbounded instance generation during E-matching, which can lead to performance issues. The main entry point is:

#grind_lint 检查

which analyzes all theorems marked with the @[grind] attribute. For each theorem, it creates an artificial goal and runs grind, collecting statistics about the number of instances produced. Results are summarized using info messages, and detailed breakdowns are shown for lemmas exceeding a configurable threshold. Additional subcommands are provided for targeted inspection and control:

  • #grind_lint inspect thm: analyzes one or more specific theorems in detail

  • #grind_lint mute thm: excludes a theorem from instantiation during analysis

  • #grind_lint skip thm: omits a theorem from being analyzed by #grind_lint check

#11167 implements support for #grind_lint check in module <module>.

Grind Interactive Mode🔗

Interactive mode gained several new features:

  • · t_1 ... t_n tactic combinator, which allows for more concise scripts generated by finish? (#10975),

  • configurability within the grind interactive mode with set_config tactic (#10990),

  • controlling finish and finish? with configuration options (#10997) and parameters (#11012),

  • anchor support for restricting search space in grind only (#11003),

  • cases_next, a tactic to perform the next case-split (#11148),

  • have <ident>? : <prop> tactic, where the proposition is proved using the default grind search strategy; useful for inspecting or querying the current grind state (#10919).

User Extensions in try?🔗

#11149 adds a user-extension mechanism for the try? tactic. You can either use the @[try_suggestion] attribute on a declaration with signature MVarId -> Try.Info -> MetaM (Array (TSyntax `tactic)) to produce suggestions, or the register_try?_tactic <stx> command with a fixed piece of syntax. User-extensions are only tried after the built-in try strategies have been tried and failed.

Match Compilation🔗

This release includes several performance optimizations in match compilation of large match statements (PRs #10763, #11072 and #10823).

Library Suggestions🔗

  • #10920/#11029 adds support for grind +suggestions, calling the currently configured premise selection algorithm and including the results as parameters to grind.

  • #11032 implements simp? +suggestions, which uses the configured library suggestion engine to add relevant theorems to the simp call.

  • #11030 adds a library suggestion engine for local theorems.

Library Highlights🔗

  • #11019 introduces slices of lists that are available via slice notation (e.g., xs[1...5]).

  • #10933 adds the basic infrastructure to perform termination proofs about String.ValidPos and String.Slice.Pos.

Breaking Changes🔗

  • #10625 implements zero cost BaseIO by erasing the IO.RealWorld parameter from argument lists and structures. This is a major breaking change for FFI.

Language🔗

  • #10763 improves match compilation: Branch on variables in the order suggested by the first remaining alternative, and do not branch when the first remaining alternative does not require it. This fixes https://github.com/leanprover/lean4/issues/10749. With set_option backwards.match.rowMajor false the old behavior can be turned on.

  • #10823 lets the match compilation procedure use sparse case analysis when the patterns only match on some but not all constructors of an inductive type. This way, less code is produce. Before, code handling each of the other cases was then optimized and commoned-up by later compilation pipeline, but that is wasteful to do.

  • #10826 fixes the location of the “deprecated constant” and similar error messages on field notation (e.f, (e).f, e |>. f). Fixes #10821.

  • #10851 lets match compilation use exfalso as soon as no alternatives are left. This way, the compiler does not have to look at subsequent case splits.

  • #10865 makes the spec Std.Do.Spec.forIn'_list and friends more universe polymorphic.

  • #10872 improves the performance of mvcgen by an optimized implementation for try (mpure_intro; trivial). This tactic sequence is used to eagerly discharge VCs and in the process instantiates schematic variables.

  • #10926 topologically sorts abstracted vars in Meta.Closure.mkValueTypeClosure if MVars are being abstracted. Fixes #10705

  • #10931 strips the Expr.mdata that WF.Fix uses to associate goal with recursive calls from the goal presented to the tactics. Fixes #10895.

  • #10944 runs enableRealizationsForConst on sizeOf declarations. Fixes #10573.

  • #10980 tries to preserve names of pattern variables in match alternatives in decreasing_by, by telescoping into the concrete alternative rather than the type of the matcher's alt. Fixes #10976.

  • #11011 extracts some refactorings from #10763, including dropping dead code and not failing in inaccessibleAsCtor, which leadas to (slightly) better error messages, and also on the grounds that the failing alternative may actually be unreachable.

  • #11024 lets Bool have .ctorIdx like any other inductive.

  • #11068 removes the verifyEnum functions from the bv_decide frontend. These functions looked at the implementation of matchers to see if they really do the matching that they claim to do. This breaks that abstraction barrier, and should not be necessary, as only functions with a MatcherInfo env entry are considered here, which should all play nicely.

  • #11072 adds “sparse casesOn” constructions. They are similar to .casesOn, but have arms only for some constructors and a catch-all (providing t.ctorIdx ≠ 42 assumptions). The compiler has native support for these constructors and now (because of the similarity) also the per-constructor elimination principles.

  • #11094 makes workspaceSymbol benchmarks modules, so that they are less sensitive to additions of private symbols in the standard library.

  • #11095 makes use of hasIndepIndices. That function was unused since commit 54f6517ca36b237b40e02aac62ea36dbd4179758, but it seems it should be used.

  • #11107 tests the missing cases error.

  • #11122 fixes a problem for structures with diamond inheritance: rather than copying docstrings (which are not available unless .server.olean is loaded), we link to them. Adds tests.

  • #11125 adds a filter for premise selectors to ensure deprecated theorems are not returned.

  • #11132 adds support for grind +suggestions and simp_all? +suggestions in try?. It outputs grind only [X, Y, Z] or simp_all only [X, Y, Z] suggestions (rather than just +suggestions).

  • #11146 fixes a bug in #11125. Added a test this time ...

  • #11150 adds a new, inactive and unused doElem_elab attribute that will allow users to register custom elaborators for doElems in the form of the new type DoElab. The old do elaborator is active by default but can be switched off by disabling the new option backward.do.legacy.

  • #11161 adds getEntry/getEntry?/getEntry!/getEntryD operation on DTreeMap.

  • #11184 modifies the error message that is returned when more than one synthetic metavariable can't be resolved.

  • #11190 avoids running into an “unknown free variable” when printing the “Failed to compile pattern matching” error. Fixes #11186.

  • #11191 makes sure that inside a realizeConst the maxHeartbeat option is effective.

Library🔗

  • #9515 adds a missing lemma for the List API.

  • #10739 adds two missing NeZero instances for n^0 where n : Nat and n : Int.

  • #10743 renames theorems that use sorted in their name to instead use pairwise.

  • #10765 extends the all/any functions from hash sets to hash maps and dependent hash maps and verifies them.

  • #10769 adds a find? consumer in analogy to List.find? and variants thereof.

  • #10776 adds iterators and slices for DTreeMap/TreeMap/TreeSet based on zippers and provides basic lemmas about them.

  • #10820 shows that the iterators returned by String.Slice.split and String.Slice.splitInclusive are finite as long as the forward matcher iterator for the pattern is finite (which we already know for all of our patterns).

  • #10852 renames String.Range to Lean.Syntax.Range, to reflect that it is not part of the standard library.

  • #10853 renames String.endPos to String.rawEndPos, as in a future release the name String.endPos will be taken by the function that is currently called String.endValidPos.

  • #10854 fixes the IPv4 address encoding from libuv to lean

  • #10865 makes the spec Std.Do.Spec.forIn'_list and friends more universe polymorphic.

  • #10896 adds union operations on DTreeMap/TreeMap/TreeSet and their raw variants and provides lemmas about union operations.

  • #10933 adds the basic infrastructure to perform termination proofs about String.ValidPos and String.Slice.Pos.

  • #10941 removes a redundant instance requirement from Std.instIrreflLtOfIsPreorderOfLawfulOrderLT.

  • #10946 adds union operation on ExtDHashMap/ExtHashMap/ExtHashSet and provides lemmas about union operations.

  • #10952 replaces Iter(M).size with the Iter(M).count. While the former used a special IteratorSize type class, the latter relies on IteratorLoop. The IteratorSize class is deprecated. The PR also renames lemmas about ranges by replacing _Rcc with _rcc, _Rco with _roo (and so on) in names, in order to be more consistent with the naming convention.

  • #10966 fixes some mis-stated lemmas which should have been about the .Raw variants of maps.

  • #10986 defines String.Slice.replace and redefines String.replace to use the Slice version.

  • #10993 allows grind to work extensionally on extensional maps/sets.

  • #11006 removes the duplicate lemmas Std.Do.SPred.{and_pure,or_pure,imp_pure,entails_pure_intro}.

  • #11008 inlines several Decidable instances for performance reasons.

  • #11017 establishes String.ofList and String.toList as the preferred method for converting between strings and lists of characters and deprecates the alternatives String.mk, List.asString and String.data.

  • #11019 introduces slices of lists that are available via slice notation (e.g., xs[1...5]).

  • #11021 adds more theory about Splits for strings and deduces the first user-facing String lemma, String.toList_map.

  • #11058 changes Nat.ble by joining the two Nat.ble Nat.zero _ cases into one, allowing decide (0 <= x) = true and decide (0 < succ x) = true to be solvable by rfl.

  • #11060 adds list min and max operations to complement min? and max? ones in the same vein as head? and head.

  • #11070 adds union operation on ExtDHashMap/ExtHashMap/ExtHashSet and provides lemmas about union operations.

  • #11076 adds getEntry/getEntry?/getEntry!/getEntryD operation on DHashMap.

  • #11100 adds theorem Int.ediv_pow {a b : Int} {n : Nat} (hab : b ∣ a) : (a / b) ^ n = a ^ n / b ^ n and related lemmas.

  • #11102 adds some annotations missing in the Array bootstrapping files.

  • #11113 adds some small missing lemmas.

  • #11123 adds theorems about folds over flatMaps, for List/Array/Vector.

  • #11127 removes all uses of String.Iterator from core, preferring String.ValidPos instead.

  • #11138 adds a csimp lemma for faster runtime evaluation of Int.pow in terms of Nat.pow.

  • #11139 replaces #11138, which just added a @[csimp] lemma for Int.pow, this time actually replacing the definition. This means we not only get fast runtime behaviour, but take advantage of the special kernel support for Nat.pow.

  • #11150 adds a new, inactive and unused doElem_elab attribute that will allow users to register custom elaborators for doElems in the form of the new type DoElab. The old do elaborator is active by default but can be switched off by disabling the new option backward.do.legacy.

  • #11152 renames String.Iterator to String.Legacy.Iterator.

  • #11154 renames Substring to Substring.Raw.

  • #11159 adds lemmas about the sizes of ranges of Ints, analogous to the Nat lemmas in Init.Data.Range.Polymorphic.NatLemmas. See also https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Reasonning.20about.20PRange.20sizes.20.28with.20.60Int.60.29/with/546466339.

Tactics🔗

  • #10848 fixes an issue where adding a missing case name after the pipe in induction would not remove the now-obsolete error message.

  • #10858 improves the done tactic in grind interactive mode. It now displays the grind state diagnostics for all unsolved subgoals.

  • #10859 fixes auto-completion for set_option in grind interactive mode.

  • #10862 implements the show_term combinator in grind interactive mode.

  • #10874 uses the correct context for elaborating the grind state filter.

  • #10877 fixes theory propagation issue in grind order.

  • #10881 fixes a proof instability source in grind.

  • #10887 uses the new TermInfo.isDisplayableTerm when hovering over cases tactic anchors in the grind interactive mode.

  • #10890 adds a +lax configuration option for grind, causing it to ignore parameters referring to non-existent theorems, or to theorems for which we can't generate a pattern. This allows throwing large sets of theorems (e.g. from a premise selection enginre) into grind to see what happens.

  • #10899 ensures the generated instantiate tactic instantiates the theorems using the same order used by finish?

  • #10916 implements parameter optimization for the generated instantiate tactics produced by finish?. We use a simple parameter optimizer that takes two sets as input: the lower and upper bounds. The lower bound consists of the theorems actually used in the proof term, while the upper bound includes all the theorems instantiated in a particular theorem instantiation step. The lower bound is often sufficient to replay the proof, but in some cases, additional theorems must be included because a theorem instantiation may contribute to the proof by providing terms and many not be present in the final proof term.

  • #10919 implements the have <ident>? : <prop> tactic for the grind interactive mode. The proposition is proved using the default grind search strategy. This tactic is also useful for inspecting or querying the current grind state.

  • #10920 adds support for grind +premises, calling the currently configured premise selection algorithm and including the results as parameters to grind. (Recall that there is not currently a default premise selector provided by Lean4: you need a downstream premise selector to make use of this.)

  • #10936 fixes issues in grind => finish? that were preventing generated grind tactic scripts from being successfully replayed.

  • #10937 fixes a missing counter reset at the cases tactic in grind interactive mode.

  • #10938 ensures solver grind tactics (e.g., ac, ring, lia, etc) process pending facts after making progress.

  • #10939 fixes another instance of the “default parameter value in constructor” footgun, which was affecting the cases tactic in the grind interactive mode.

  • #10948 ensures that finish? produces partial tactic scripts containing sorrys. We may add an option to disable this feature in the future. It is enabled by default because it provides a useful way to debug grind failures.

  • #10949 ensures that solver propagation steps are necessary in the generated tactic script to close the goal.

  • #10950 adds the mbtc tactic to the grind interactive mode. It implements model-based theory combination. It also ensures finish? is capable of generating it.

  • #10951 fixes a bug in the cutsat incremental model construction. The model was not being reset when new (unsatisfied) equalities were asserted.

  • #10955 fixes a regression in the grind order module introduced by

  • #10956 fixes a bug in the equality propagation procedure in grind.order. Specifically, it affects the procedure that asserts equalities in the grind core state that are implied by (ring) inequalities in the grind.order module.

  • #10960 fixes a bug in the grind linarith model/counterexample construction.

  • #10961 adds support for scientific literals for Rat in grind. grind does not yet add support for this kind of literal in arbitrary fields.

  • #10962 fixes a spurious warning message in grind.

  • #10964 adds a propagator for a^(n+m) and removes its normalizer. This change was motivated by issue #10661

  • #10965 ensures that model-based theory combination in grind cutsat considers nonlinear terms. Nonlinear multiplications such as x * y are treated as uninterpreted symbols in cutsat.

  • #10971 adds a LawfulOfScientific class, providing compatibility with a Lean.Grind.Field structure.

  • #10975 adds the combinator · t_1 ... t_n to the grind interactive mode. The finish? tactic now generates scripts using this combinator to conform to Mathlib coding standards. The new format is also more compact. Example:

    /--
    信息:试试这个:
      [申请] ⏎
        仅实例化 [= mem_indices_of_mem, insert, = getElem_def]
        仅实例化 [= getElem?_neg, = getElem?_pos]
        案例#f590
        · 案例#ffdf
          · 仅实例化
            仅实例化 [= Array.getElem_set]
          · 仅实例化
            仅实例化 [size, = HashMap.mem_insert, = HashMap.getElem_insert, = Array.getElem_push]
        · 仅实例化 [= mem_indices_of_mem, = getElem_def]
          仅实例化 [usr getElem_indices_lt]
          仅实例化[大小]
          案例#ffdf
          · 仅实例化[=_ WF]
            仅实例化 [= getElem?_neg, = getElem?_pos, = Array.getElem_set]
            仅实例化 [WF']
          · 仅实例化
            仅实例化 [= HashMap.mem_insert, = HashMap.getElem_insert, = Array.getElem_push]
    -/
    #guard_msgs in
    example (m : IndexMap α β) (a a' : α) (b : β) (h : a' ∈ m.insert a b) :
        (m.insert a b)[a'] = if h' : a' == a then b else m[a'] := by
      研磨=>完成?
    
  • #10978 implements the following grind improvements:

    1. set_option can now be used to set grind configuration options in the interactive mode.

    2. Fixes a bug in the repeated theorem instantiation detection.

    3. Adds the macro use [...] as a shorthand for instantiate only [...].

  • #10990 adds the set_config tactic for setting grind configuration options. It uses the same syntax used for setting configuration options in the grind main tactic.

  • #10991 renames cutsat in configuration options and trace messages to lia.

  • #10992 ensures that grind +premises silently drops warnings and errors about bad suggestions.

  • #10997 adds support for configuration options at finish and finish?.

  • #11003 adds support for specifying anchors to restrict the search space in grind when using grind only. Anchors can limit which case splits are performed and which local lemmas are instantiated.

  • #11012 ensures the grind tactics finish and finish? can take parameters.

  • #11026 fixes a non-termination and missing propagation bug in grind order. It also registers relevant case-splits for arithmetic.

  • #11028 ensures that grind? +premises removes +premises from the "Try this" suggestion.

  • #11029 changes the terminology used from "premise selection" to "library suggestions". This will be more understandable to users (we don't assume anyone is familiar with the premise selection literature), and avoids a conflict with the existing use of "premise" in Lean terminology (e.g. "major premise" in induction, as well as generally the synonym for "hypothesis"/"argument").

  • #11030 adds a library suggestion engine for local theorems. To be useful, I still need to write more combinators to re-rank and combine suggestions from multiple engines.

  • #11032 implements simp? +suggestions, which uses the configured library suggestion engine to add relevant theorems to the simp call. simp +suggestions without the ? prints a message requiring adding the ?.

  • #11034 adds a new suggestion to finish?. It now generates the grind tactic script as before, and a finish only tactic. Example:

    /--
    信息:尝试这些:
      [申请] ⏎
        仅实例化 [findIdx, insert, = mem_indices_of_mem]
        仅实例化 [= getElem?_neg, = getElem?_pos]
        案例#1bba
        · 仅实例化[findIdx]
        · 仅实例化
          仅实例化 [= HashMap.mem_insert, = HashMap.getElem_insert]
      [apply]仅完成[findIdx, insert, = mem_indices_of_mem, = getElem?_neg, = getElem?_pos, = HashMap.mem_insert,
        = HashMap.getElem_insert,#1bba]
    -/
    example (m : IndexMap α β) (a : α) (b : β) :
        (m.insert a b).findIdx a = if h : a ∈ m then m.findIdx a else m.size := by
      研磨=>完成?
    
  • #11039 fixes the grind invalid universe level regression reported in #11036

  • #11040 fixes a panic that occurred during the processing of generalized E-matching patterns in grind.

  • #11047 implements (nested term) equality propagation in grind order. That is, it propagates implied equalities from grind order back to the grind core. Examples:

    open Lean Grind Std
    
    
  • #11049grind order 中实现 Nat 的相等传播。 grind order 支持环的偏移相等,但它有一个 Nat 适配器。例子:

    example (a b : Nat) (f : Nat → Int) : a ≤ b + 1 → b + 1 ≤ a → f (1 + a) = f (1 + b + 1) := by
      grind -offset -mbtc -lia -linarith (splits := 0)
    
  • #11050 修复了 grind orderNat 的等式传播。

  • #11051 删除了 grind offset 模块,因为它(现在)已被纳入 由 grind order 提供。

  • #11057 使用新的 grind => finish? 实现 grind? 基础设施。

  • #11061 修复了类型检查时内核中的深度递归问题 由 grind 生成的证明项。

  • #11071 确保用于实现的 denote 函数 grind 中的反射证明术语是缩写。这个改变 无需 withAbstractAtoms 小工具。

  • #11075 更新 simp? +suggestions,以便在名称不明确时 (由于命名空间)使用所有替代方案,而不是出错。

  • #11077 修复了 grind? 生成的锚点值

  • #11080 修复了 grind ring 中相等传播期间的恐慌 模块。如果已达到最大步数,则多项式 可能没有完全简化。

  • #11084 修复了构造证明时发生的堆栈溢出 grind 中的术语。

  • #11087 使 grind 能够在 SumPSum 上进行 bash。

  • #11092 确保在证明中使用 grind ac 表示函数 反射标记为 abbrev

  • #11098 更新 suggestions策略,因此打印的消息包括 可悬停类型信息(并在 相关)。

  • #11099 改进了对 grind 中的 Universe 元变量的支持。

  • #11101 修复了本地 Function.Injective f 的初始化问题 假设。

  • #11126 确保将 injection 应用于 由于前向依赖性而无法清除的假设。

  • #11133 修复了构造函数应用程序的不等式传播 grind。等价类代表可能不同 构造函数应用程序,但我们必须确保它们具有相同的类型。 在此 PR 之前引起恐慌的示例:

    example (a b : List Nat)
        : a ≍ ([] : List Int) → b ≍ ([1] : List Int) → a = b ∨ p → p := by
      grind
    
    
  • #11135 ensures that checkExp is used in grind lia (formerly known as grind cutsat) and grind ring to prevent stack overflows.

  • #11136 adds support for try? to use induction; it will only perform induction on inductive types defined in the current namespace and/or module; so in particular for now it will not induct on built-in inductives such as Nat or List.

  • #11137 fixes a stackoverflow during proof construction in grind.

  • #11145 fixes a bug in isMatchCondCandidate used in grind. The missing condition was causing a "not internalized term" grind internal error.

  • #11147 refactors the implementation of the symmetric equality congruence rule used in grind.

  • #11148 addst the cases_next tactic to the grind interactive mode.

  • #11149 adds a user-extension mechanism for the try? tactic. You can either use the @[try_suggestion] attribute on a declaration with signature MVarId -> Try.Info -> MetaM (Array (TSyntax `tactic)) to produce suggestions, or the register_try?_tactic <stx> command with a fixed piece of syntax. User-extensions are only tried after the built-in try strategies have been tried and failed.

  • #11157 implements the #grind_lint command, a diagnostic tool for analyzing the behavior of theorems annotated for theorem instantiation. The command helps identify problematic theorems that produce excessive or unbounded instance generation during E-matching, which can lead to performance issues. The main entry point is:

    #grind_lint 检查
    

    which analyzes all theorems marked with the @[grind] attribute. For each theorem, it creates an artificial goal and runs grind, collecting statistics about the number of instances produced. Results are summarized using info messages, and detailed breakdowns are shown for lemmas exceeding a configurable threshold. Additional subcommands are provided for targeted inspection and control:

    • #grind_lint inspect thm: analyzes one or more specific theorems in detail

    • #grind_lint mute thm: excludes a theorem from instantiation during analysis

    • #grind_lint skip thm: omits a theorem from being analyzed by #grind_lint check

  • #11166 implements the following improvements to the #grind_lint command:

    1. More informative messages when the number of instances exceeds the minimum threshold.

    2. A code action for #grind_lint inspect that inserts set_option trace.grind.ematch.instance true whenever the number of instances exceeds the minimum threshold.

    3. Displaying doc strings for grind configuration options in #grind_lint.

    4. Improve doc strings for #grind_lint inspect and #grind_lint check.

  • #11167 implements support for #grind_lint check in module <module>. Mathlib does not use namespaces, so we need to restrict the #grind_lint search space using module (prefix) names. Example:

    /--
    信息:实例化 `Array.filterMap_some` 会触发 100 多个额外的 `grind` 定理实例化
    ---
    信息:Array.filterMap_some
    [thm] 实例
      [thm] Array.filterMap_filterMap ↦ 94
      [thm] Array.size_filterMap_le ↦ 5
      [thm] Array.filterMap_some ↦ 1
    ---
    信息:实例化 `Array.range_succ` 触发 22 个额外的 `grind` 定理实例化
    -/
    #guard_msgs in
    #grind_lint 检查模块 Init.Data.Array 中的 (min := 20)
    
  • #11168 changes the default library suggestions (e.g. for grind +suggestions or `simp_all? +suggestions) to include the theorems from the current file in addition to the output of Sine Qua Non.

  • #11170 adds tactic and term mode macros for (typed \qed) which expand to try?. The term mode version captures any produced suggestions and prepends by.

  • #11171 ensures that tactics using library suggestions set the caller field, so the premise selection engine has access to this. We'll later use this to filter out some modules for grind, which we know have already been fully annotated.

  • #11172 removes simp_all? +suggestions from try? for now. It's really slow out in Mathlib; too often the suggestions cause simp to loop. Until we have the ability for try? to move past a timeing-out tactic (or maybe even until we have parallelism), it needs to be removed.

  • #11174 modifies the try? framework, so each subsidiary tactic runs with a separate maxHeartbeats budget.

  • #11187 adds syntax for specifying grind_pattern constraints and extends the EMatchTheorem object.

  • #11189 implements grind_pattern constraints. They are useful for controlling theorem instantiation in grind. As an example, consider the following two theorems:

    theorem extract_empty {start stop : Nat} :
        (#[] : 数组 α).extract start stop = #[] := …
    
    
  • #11193 使用新的 grind_pattern 约束来修复以下情况: 将生成无限数量的定理实例 标准库中的某些定理。

  • #11194 grind 参数冗余警告消息。现在它检查 grind 定理实例化约束也是如此。

  • #11197 使用新的 finish? 基础设施实现 try?。它 还删除了现已过时的旧跟踪基础设施。 示例:

    /--
    info: Try these:
      [apply] grind
      [apply] grind only [findIdx, insert, = mem_indices_of_mem, = getElem?_neg, = getElem?_pos, = HashMap.mem_insert,
        = HashMap.getElem_insert, #1bba]
      [apply] grind only [findIdx, insert, = mem_indices_of_mem, = getElem?_neg, = getElem?_pos, = HashMap.mem_insert,
        = HashMap.getElem_insert]
      [apply] grind =>
        instantiate only [findIdx, insert, = mem_indices_of_mem]
        instantiate only [= getElem?_neg, = getElem?_pos]
        cases #1bba
        · instantiate only [findIdx]
        · instantiate only
          instantiate only [= HashMap.mem_insert, = HashMap.getElem_insert]
    -/
    #guard_msgs in
    example (m : IndexMap α β) (a : α) (b : β) :
        (m.insert a b).findIdx a = if h : a ∈ m then m.findIdx a else m.size := by
      try?
    
  • #11203 修复了新的 Action 框架中的一些小问题 grind。目标是最终删除旧的 SearchM 基础设施。 grind 使用的主要 solve 函数现在基于 在 Action 框架上。 PR 还删除了 SearchM 中的死代码。

  • #11204#grind_list check 生成“试试这个:”建议 #grind_list inspect 命令,因为这通常是下一步 处理有问题的案件。我们还修复了其中一个的研磨模式 定理,作为测试工作流程的一部分。更多内容敬请关注。

编译器🔗

  • #10625 通过擦除 IO.RealWorld 实现零成本 BaseIO 来自参数列表和结构的参数。这是一个重大突破 更改为 FFI

  • #10727 通过添加 00 将名称修改修复为明确/单射 必要时进行消歧。此外,反函数, 添加了 Lean.Name.unmangle,可用于解开 损坏的标识符。添加此 unmangler 是为了演示 单射性,而且还允许分解标识符,例如用于调试 目的。

  • #10856 在 ElimDeadBranches 中执行更多加宽,试图 提高局部精度较高的情况下的性能。

  • #10864 通过打开一个 形状的链接循环:

    Environment -> Compiler -> Meta -> Environment

  • #10982 更改闭包分配器以使用通用分配器 而不是小物体。 这是因为用户可能会创建大量的闭包 封闭变量又 将闭包的大小提高到超出小对象阈值。

  • #11000 修复了由基于 Lean 的 IO.waitAny 引起的内存泄漏 通过恢复来实现。

  • #11010 使急切的 lambda 提升启发式更可预测 阻止它升起 任何类型的内联函数,而不仅仅是 @[inline]。它还适应 描述的文档字符串 到底发生了什么。

  • #11020 改进了对多个分支情况的检测 相同值的时间 代码生成器。以前这只会考虑重复分支 关于函数参数,现在开始 任意值。

  • #11042 修复了 UInt 上过于急切的常量折叠的情况,其中 编译器会错误地 假设 0 - x = x

  • #11043 修复了 Nat 上过度不断折叠的情况,其中 编译器会错误地假设 0 - x = x (另请参见#11042 UInt 上有同样的错误)。

  • #11044 强制常量文件夹 API 的用户提供以下证明: 它们的代数性质, 因此希望将来能够避免诸如 #11042 和 #11043 之类的错误。

  • #11056 修复了 ST.Ref.ptrEq,使其按照文档中所述进行操作。这修复了 两个错误:

    1. 最近的IO.RealWorld消除PR忽略了这个功能 (据我所知,这是唯一的一个), 导致其返回值通常是错误的。

    2. ptrEq 的实现以前总是考虑两个 带指针的不同单元格 等效值与指针相等。然而,该函数应该是 检查是否有两个 Ref 是同一个单元格,而不是所包含的元素是否相同。

  • #11151 修复了 Verso 的 Markdown 渲染中的一些细节 文档字符串,并添加测试以确保它们正确。还添加了测试 Verso 文档字符串元数据。

文档🔗

  • #11179 删除了大多数情况,其中错误消息解释说它是 “可能是由于元变量”,给出了更多解释和提示。

服务器🔗

  • #10787 改进了服务器日志记录机制以允许过滤日志 通过 LSP 方法输出。

  • #10805 将字段 isDisplayableTerm 添加到 TermInfo 和所有实用程序 创建 TermInfo 的函数可以设置为强制语言 服务器在悬停弹出窗口中呈现术语。

Lake🔗

  • #10861 修复了 input_dir 跟踪,以便也递归通过 子目录。 input_dirfilter 将应用于每个 目录树中的文件(目录的路径名不会 检查)。

  • #10883 修复了 Lake 缓存的错误,其中修订版本存储在 路径不正确。修订版本存储在 <rev>/<pkg>.jsonl 而不是 正确的 <pkg>/<rev>.jsonl

  • #10959 使 Lake 用户能够通过 语义版本范围。在 lake update 上,Lake 将获取 从 Reservoir 中获取软件包的版本信息并选择最新的 满足该范围的包的版本。

  • #11062 将 Lake 的调试构建类型更改为使用 -O0 而不是 -Og 编译C代码时。 -Og 发现调试不足 编译的Lean代码——相关代码仍然被优化掉。

  • #11063 更改了 lake newmathmath-lax 模板 lake init 使用当前 Mathlib 对应的版本 Lean 工具链。因此,lake +x.y.z new <pkg> math 将使用 Mathlib 适用于 Lean x.y.z。另一方面,此类封装上的 lake update 将 不再自动更新 Mathlib。用户需要更改 Mathlib 更新前配置文件中的修订版。

  • #11117 修复了 Lake 忽略 moreLinkObjsmoreLinkLibs 的错误 在 lean_exe 上。

  • #11118 添加 Job.sync 作为声明同步的标准方式 工作。

  • #11169 将 Lake 中的所有模块构建密钥更改为其范围 包。这使得可以在不同的环境中构建具有相同名称的模块 包(以前只对可执行文件有很好的支持) 根)。

其他🔗

  • #11074 添加了 .claude/claude.md,包含基本开发说明 让 Claude Code 在此存储库中运行。