About: dependsOnNoncomputable
This error indicates that the specified definition depends on one or more definitions that do not
contain executable code and is therefore required to be marked as noncomputable. Such
definitions can be type-checked but do not contain code that can be executed by Lean.
If you intended for the definition named in the error message to be noncomputable, marking it as
noncomputable will resolve this error. If you did not, inspect the noncomputable
definitions on which it depends: they may be noncomputable because they failed to compile, are
axioms, or were themselves marked as noncomputable. Making all of your
definition's noncomputable dependencies computable will also resolve this error. See the manual
section on Modifiers for more information about noncomputable
definitions.
Examples
Necessarily Noncomputable Function Not Appropriately Marked
In this example, transformIfZero depends on the axiom transform. Because transform is an
axiom, it does not contain any executable code; although the value transform 0 has type Nat,
there is no way to compute its value. Thus, transformIfZero must be marked noncomputable because
its execution would depend on this axiom.
Noncomputable Dependency Can Be Made Computable
The original definition of getOrDefault is noncomputable due to its use of Classical.choice.
Unlike in the preceding example, however, it is possible to implement a similar but computable
version of getOrDefault (using the Inhabited type class), allowing endsOrDefault to be
computable. (The differences between Inhabited and Nonempty are described in the documentation
of inhabited types in the manual section on Basic Classes.)
Noncomputable Instance in Namespace
The Classical namespace contains Decidable instances that are not computable. These are a common
source of noncomputable dependencies that do not explicitly appear in the source code of a
definition. In the above example, for instance, a Decidable instance for the proposition
∃ x, f x = y is synthesized using a Classical decidability instance; therefore, fromImage must
be marked noncomputable.