Skip to content

noncomputable error on definitions without data #14084

Description

@plp127

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-mediumWe may work on this issue if we find the timebugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions