lean4-htt/tests/lean/run/10213.lean
Sebastian Ullrich 85341d02ac
feat: immediate noncomputable check (#12028)
This PR gives a simpler semantics to `noncomputable`, improving
predictability as well as preparing codegen to be moved into a separate
build step without breaking immediate generation of error messages.

Specifically, `noncomputable` is now needed whenever an axiom or another
`noncomputable` def is used by a def except for the following special
cases:
* uses inside proofs, types, type formers, and constructor arguments
corresponding to (fixed) inductive parameters are ignored
* uses of functions marked `@[extern]/@[implemented_by]/@[csimp]` are
ignored
* for applications of a function marked `@[macro_inline]`,
noncomputability of the inlining is instead inspected

# Breaking change

After this change, more `noncomputable` annotations than before may be
required in exchange for improved future stability.
2026-01-30 16:07:25 +00:00

21 lines
706 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-!
Tests that `@[csimp]` rejects constant replacements with concrete universe parameters
-/
noncomputable def funnyChoice (x : α) : α := Classical.choice ⟨x⟩
/--
error: invalid 'csimp' theorem, only constant replacement theorems (e.g., `@f = @g`) are currently supported.
-/
#guard_msgs in
@[csimp]
theorem bad_csimp : @funnyChoice.{0} = @id.{0} := rfl
/--
error: Tactic `native_decide` failed. Error: failed to compile definition, consider marking it as 'noncomputable' because it depends on 'funnyChoice', which is 'noncomputable'
-/
#guard_msgs in
example : False := by
have : funnyChoice 2 = funnyChoice 3 := rfl
have : funnyChoice 2 ≠ funnyChoice 3 := by native_decide
contradiction