Skip to content

Releases: leanprover/lean4

v4.12.0-rc1

03 Sep 03:01
e9e858a
Compare
Choose a tag to compare
v4.12.0-rc1 Pre-release
Pre-release
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

02 Sep 01:15
ec3042d
Compare
Choose a tag to compare

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. The omit command can be used to omit included variables.

    See breaking changes below.

    PRs: #4883, 1242ff, #5000, #5036, #5138, 0edf1b.

  • 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 the termination_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 to true by default.
  • omega tactic

    • #4612 normalizes the order that constraints appear in error messages.
    • #4695 prevents pushing casts into multiplications unless it produces a non-trivial linear combination.
    • #4989 fixes a regression.
  • 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 which Decidable instances it unfolded, if it get stuck on Eq.rec it gives a hint about avoiding tactics when defining Decidable instances, and if it gets stuck on Classical.choice it gives hints about classical instances being in scope. During this process, it processes Decidable.recs and matches to pin blame on a non-reducing instance.
  • @[ext] attribute

    • #4543 and #4762 make @[ext] realize ext_iff theorems from user ext theorems. Fixes the attribute so that @[local ext] and @[scoped ext] are usable. The @[ext (iff := false)] option can be used to turn off ext_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.
  • #eval command

    • #4810 introduces a safer #eval command that prevents evaluation of terms that contain sorry. 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.)
  • #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 term t (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

    • 7253ef and a04f3c improve the construction of the BEq deriving handler.
    • 86af04 makes BEq deriving handler work when there are dependently typed fields.
    • #4826 refactors the DecidableEq deriving handle to use termination_by structural.
  • 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 as exact.
    • #4807 introduces Lean.Meta.PProdN module for packing and projecting nested PProds.
    • #5170 fixes Syntax.unsetTrailing. A consequence of this is that "go to definition" now works on the last module name in an import block (issue #4958).

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...
Read more

v4.11.0-rc3

29 Aug 05:05
Compare
Choose a tag to compare
v4.11.0-rc3 Pre-release
Pre-release

This is v4.11.0-rc2, plus cherry-picked commits from #5000, #5036, #5138, and #5170.

v4.11.0-rc2

12 Aug 03:37
Compare
Choose a tag to compare
v4.11.0-rc2 Pre-release
Pre-release
chore: adapt stdlib to new `variable` behavior

v4.11.0-rc1

05 Aug 01:57
Compare
Choose a tag to compare
v4.11.0-rc1 Pre-release
Pre-release

What's Changed

Read more

v4.10.0

31 Jul 06:28
Compare
Choose a tag to compare

Language features, tactics, and metaprograms

  • split tactic:

    • #4401 improves the strategy split uses to generalize discriminants of matches and adds trace.split.failure trace class for diagnosing issues.
  • rw tactic:

    • #4385 prevents the tactic from claiming pre-existing goals are new subgoals.
    • dac1da adds configuration for ordering new goals, like for apply.
  • simp tactic:

    • #4430 adds dsimprocs for if expressions (ite and dite).
    • #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 including rfl-theorems in proof terms.
  • 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.
  • #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 and def declarations.
    • #4493 and #4482 fix a discrepancy in the elaborators for theorem, def, and example,
      making Prop-valued examples and other definition commands elaborate like theorems.
    • 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 expression e.
      By default, neither proofs or types are reduced.
    • #4489 fixes an elaboration bug in #check_tactic.
    • #4505 adds support for open _root_.<namespace>.
  • Options

    • #4576 adds the debug.byAsSorry option. Setting set_option debug.byAsSorry true causes all by ... terms to elaborate as sorry.
    • 7b56eb and d8e719 add the debug.skipKernelTC option. Setting set_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.
  • #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 constructor Tree.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.
  • Other fixes or improvements

    • #4416 sorts the ouput of #print axioms for determinism.
    • #4528 fixes error message range for the cdot focusing tactic.

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 of pp.deepTerms to false. Together, these keep excessively large or deep terms from overwhelming the Infoview.

Library

  • #4560 splits GetElem class into GetElem and GetElem?.
    This enables removing Decidable instance arguments from GetElem.getElem? and GetElem.getElem!, improving their rewritability.
    See the docstrings for these classes for more information.
  • Array
    • #4389 makes Array.toArrayAux_eq be a simp lemma.
    • #4399 improves robustness of the proof for Array.reverse_data.
  • List
    • #4469 and #4475 improve the organization of the List API.
    • #4470 improves the List.set and List.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 use as.length + 1 instead of as.length.succ.
    • #4524 fixes the statement of List.filter_congr.
    • #4525 changes binder explicitness in List.bind_map.
    • #4550 adds maximum?_eq_some_iff' and minimum?_eq_some_iff?.
  • #4400 switches the normal forms for indexing List and Array to xs[n] and xs[n]?.
  • HashMap
    • #4372 fixes linearity in HashMap.insert and HashMap.erase, leading to a 40% speedup in a replace-heavy workload.
  • Option
    • #4403 generalizes type of Option.forM from Unit to PUnit.
    • #4504 remove simp attribute from Option.elim and instead adds it to individal reduction lemmas, making unfolding less aggressive.
  • Nat
    • #4242 adds missing theorems for n + 1 and n - 1 normal forms.
    • #4486 makes Nat.min_assoc be a simp lemma.
    • #4522 moves @[simp] from Nat.pred_le to Nat.sub_one_le.
    • #4532 changes various Nat.succ n to n + 1.
  • Int
    • #3850 adds complete div/mod simprocs for Int.
      *...
Read more

v4.10.0-rc2

09 Jul 15:27
Compare
Choose a tag to compare
v4.10.0-rc2 Pre-release
Pre-release
fix: calculate error suppression per snapshot (#4657)

Generalizes #3556 to not suppressing errors in tactic steps either when
the parse error is in a later step, as otherwise changes to the end of a
proof would affect (correctness or effectiveness of) incrementality of
preceding steps.

Fixes #4623, in combination with #4643

v4.9.1

09 Jul 22:56
Compare
Choose a tag to compare

Bugfixes for incremental compilation. Otherwise identical to v4.9.0.

v4.10.0-rc1

30 Jun 23:57
Compare
Choose a tag to compare
v4.10.0-rc1 Pre-release
Pre-release
update RELEASES.md and CMakeLists.txt for release branch

v4.9.0

01 Jul 00:21
Compare
Choose a tag to compare

Language features, tactics, and metaprograms

  • Definition transparency
    • #4053 adds the seal and unseal commands, which make definitions locally be irreducible or semireducible.
    • #4061 marks functions defined by well-founded recursion with @[irreducible] by default,
      which should prevent the expensive and often unfruitful unfolding of such definitions (see breaking changes below).
  • Incrementality
    • #3940 extends incremental elaboration into various steps inside of declarations:
      definition headers, bodies, and tactics.
      Recording 2024-05-10.
    • 250994 and 67338b add @[incremental] attribute to mark an elaborator as supporting incremental elaboration.
    • #4259 improves resilience by ensuring incremental commands and tactics are reached only in supported ways.
    • #4268 adds special handling for := by so that stray tokens in tactic blocks do not inhibit incrementality.
    • #4308 adds incremental have tactic.
    • #4340 fixes incorrect info tree reuse.
    • #4364 adds incrementality for careful command macros such as set_option in theorem, theorem foo.bar, and lemma.
    • #4395 adds conservative fix for whitespace handling to avoid incremental reuse leading to goals in front of the text cursor being shown.
    • #4407 fixes non-incremental commands in macros blocking further incremental reporting.
    • #4436 fixes incremental reporting when there are nested tactics in terms.
  • Functional induction
    • #4135 ensures that the names used for functional induction are reserved.
    • #4327 adds support for structural recursion on reflexive types.
      For example,
      inductive Many (α : Type u) where
        | none : Many α
        | more : α → (Unit → Many α) → Many α
      
      def Many.map {α β : Type u} (f : α → β) : Many α → Many β
        | .none => .none
        | .more x xs => .more (f x) (fun _ => (xs ()).map f)
      
      #check Many.map.induct
      /-
      Many.map.induct {α β : Type u} (f : α → β) (motive : Many α → Prop)
        (case1 : motive Many.none)
        (case2 : ∀ (x : α) (xs : Unit → Many α), motive (xs ()) → motive (Many.more x xs)) :
        ∀ (a : Many α), motive a
      -/
      
  • #3903 makes the Lean frontend normalize all line endings to LF before processing.
    This lets Lean be insensitive to CRLF vs LF line endings, improving the cross-platform experience and making Lake hashes be faithful to what Lean processes.
  • #4130 makes the tactic framework be able to recover from runtime errors (for example, deterministic timeouts or maximum recursion depth errors).
  • split tactic
    • #4211 fixes split at h when h has forward dependencies.
    • #4349 allows split for if-expressions to work on non-propositional goals.
  • apply tactic
    • #3929 makes error message for apply show implicit arguments in unification errors as needed.
      Modifies MessageData type (see breaking changes below).
  • cases tactic
    • #4224 adds support for unification of offsets such as x + 20000 = 20001 in cases tactic.
  • omega tactic
    • #4073 lets omega fall back to using classical Decidable instances when setting up contradiction proofs.
    • #4141 and #4184 fix bugs.
    • #4264 improves omega error message if no facts found in local context.
    • #4358 improves expression matching in omega by using match_expr.
  • simp tactic
    • #4176 makes names of erased lemmas clickable.

    • #4208 adds a pretty printer for discrimination tree keys.

    • #4202 adds Simp.Config.index configuration option,
      which controls whether to use the full discrimination tree when selecting candidate simp lemmas.
      When index := false, only the head function is taken into account, like in Lean 3.
      This feature can help users diagnose tricky simp failures or issues in code from libraries
      developed using Lean 3 and then ported to Lean 4.

      In the following example, it will report that foo is a problematic theorem.

      opaque f : Nat → Nat → Nat
      
      @[simp] theorem foo : f x (x, y).2 = y := by sorry
      
      example : f a b ≤ b := by
        set_option diagnostics true in
        simp (config := { index := false })
      /-
      [simp] theorems with bad keys
        foo, key: f _ (@Prod.mk ℕ ℕ _ _).2
      -/

      With the information above, users can annotate theorems such as foo using no_index for problematic subterms. Example:

      opaque f : Nat → Nat → Nat
      
      @[simp] theorem foo : f x (no_index (x, y).2) = y := by sorry
      
      example : f a b ≤ b := by
        simp -- `foo` is still applied with `index := true`
    • #4274 prevents internal match equational theorems from appearing in simp trace.

    • #4177 and #4359 make simp continue even if a simp lemma does not elaborate, if the tactic state is in recovery mode.

    • #4341 fixes panic when applying @[simp] to malformed theorem syntax.

    • #4345 fixes simp so that it does not use the forward version of a user-specified backward theorem.

    • #4352 adds missing dsimp simplifications for fixed parameters of generated congruence theorems.

    • #4362 improves trace messages for simp so that constants are hoverable.

  • Elaboration
    • #4046 makes subst notation (he ▸ h) try rewriting in both directions even when there is no expected type available.
    • #3328 adds support for identifiers in autoparams (for example, rfl in (h : x = y := by exact rfl)).
    • #4096 changes how the type in let and have is elaborated, requiring that any tactics in the type be evaluated before proceeding, improving performance.
    • #4215 ensures the expression tree elaborator commits to the computed "max type" for the entire arithmetic expression.
    • #4267 cases signature elaboration errors to show even if there are parse errors in the body.
    • #4368 improves error messages when numeric literals fail to synthesize an OfNat instance,
      including special messages warning when the expected type of the numeral can be a proposition.
  • Metaprogramming
    • #4167 adds Lean.MVarId.revertAll to revert all free variables.
    • #4169 adds Lean.MVarId.ensureNoMVar to ensure the goal's target contains no expression metavariables.
    • #4180 adds cleanupAnnotations parameter to forallTelescope methods.
    • #4307 adds support for parser aliases in syntax quotations.
  • Work toward implementing grind tactic
    • 0a515e and #4164 add grind_norm and grind_norm_proc attributes and @[grind_norm] theorems.
    • #4170, #4221, and #4249 create grind preprocessor and core module.
    • #4235 and d6709e add special cases tactic to grind along with @[grind_cases] attribute to mark types that this cases tactic should automatically apply to.
    • #4243 adds special injection? tactic to grind.
  • Other fixes or improvements
    • #4065 fixes a bug in the Nat.reduceLeDiff simproc.
    • #3969 makes deprecation warnings activate even for general...
Read more