Prerequisites
Description
The error lean.dependsOnNoncomputable is thrown on definitions of a type whose elements contain no data at runtime. For example, def setoid : Setoid Nat := Classical.choice ⟨Setoid.trivial Nat⟩ fails, even though elements of Setoid Nat consist of a pair r : Nat → Nat → Prop which is a predicate and so is erased a runtime and a iseqv : Equivalence r which is a proof and so is also erased at runtime.
Context
I encountered this error after upgrading my Setoid theorems from an earlier version of Lean. See Zulip.
Steps to Reproduce
def prop : Prop := Classical.choice ⟨True⟩
def subtype : { p : Prop // p } := Classical.choice ⟨⟨True, trivial⟩⟩
def setoid : Setoid Nat := Classical.choice ⟨Setoid.trivial Nat⟩
def unit : Unit := Classical.choice ⟨()⟩
Expected behavior: prop, subtype, setoid, and unit will behave similarly, since their types do not contain any data at runtime
Actual behavior: only prop is fine, but the other three throw "error: Classical.choice not supported by code generator; consider marking definition as noncomputable"
Versions
I tested versions v4.31.0, v4.30.0, v.4.29.0, ..., v4.17.0
prop works on all the versions I tested
subtype fails on v4.21.0 and below but works on v4.22.0 up to v4.28.0 and fails on v4.29.0 and above
setoid fails on all the versions I tested
unit fails on all the versions I tested
Target: x86_64-w64-windows-gnu Windows
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
Prerequisites
https://github.com/leanprover/lean4/issues
Avoid dependencies to Mathlib or Batteries.
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
The error
lean.dependsOnNoncomputableis thrown on definitions of a type whose elements contain no data at runtime. For example,def setoid : Setoid Nat := Classical.choice ⟨Setoid.trivial Nat⟩fails, even though elements ofSetoid Natconsist of a pairr : Nat → Nat → Propwhich is a predicate and so is erased a runtime and aiseqv : Equivalence rwhich is a proof and so is also erased at runtime.Context
I encountered this error after upgrading my
Setoidtheorems from an earlier version of Lean. See Zulip.Steps to Reproduce
Expected behavior:
prop,subtype,setoid, andunitwill behave similarly, since their types do not contain any data at runtimeActual behavior: only
propis fine, but the other three throw "error:Classical.choicenot supported by code generator; consider marking definition asnoncomputable"Versions
I tested versions v4.31.0, v4.30.0, v.4.29.0, ..., v4.17.0
propworks on all the versions I testedsubtypefails on v4.21.0 and below but works on v4.22.0 up to v4.28.0 and fails on v4.29.0 and abovesetoidfails on all the versions I testedunitfails on all the versions I testedTarget: x86_64-w64-windows-gnu Windows
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.