### isabelle

#### Error when trying to evaluate `coprime`

I want to use the coprime function that is defined in Isabelle's GCD and play a bit around with it. Why does value "coprime Suc(Suc 0) Suc(Suc(Suc (Suc 0)))" return the error Type unification failed: No type arity fun :: gcd Type error in application: incompatible operand type Operator: coprime :: ??'a ⇒ ??'a ⇒ bool Operand: Suc :: nat ⇒ nat Coercion Inference: Local coercion insertion on the operand failed: No type arity fun :: gcd Now trying to infer coercions globally. Coercion inference failed: weak unification of subtype constraints fails Clash of types "_ ⇒ _" and "nat" instead of false ? (This is also the case for value "coprime 0 0".) A minimal MWE w.r.t the answer: (*<*) theory T imports Main "~~/src/HOL/Number_Theory/Number_Theory" begin (*>*) value "coprime 2 (4 :: nat))" (*<*) end (*>*)

There are a number of issues here. It should be value "coprime (Suc(Suc 0)) (Suc(Suc(Suc (Suc 0))))". Function application binds strongest and associates to the left, so what you wrote would be interpreted as coprime applied to Suc, Suc 0, and some other arguments, which is a type error. coprime 0 0 works out fine in my version of Isabelle; it outputs the somewhat confusing "equal_class.equal (gcd 0 0) 1" :: "bool". The reason for this is that there is nothing in that term to indicate that the 0 is a natural number, and evaluation of polymorphic constants tends to be problematic. Even something like 2 ≠ 4 will not evaluate to True in general because this depends on what type 2 and 4 have. If you write coprime 0 (0::nat), everything works as expected. Additionally, it would be more convenient to write value "coprime 2 (4 :: nat) instead of using the successor notation.

### Related Links

When would you use `presume` in an Isar proof?

how to create an object logic via thf

What Isabelle library to reuse for expressing that some function is a linear order (on some set)

Isabelle: how to print result of 1 + 2?

Inductive Set with Non-fixed Parameters

What Kind of Type Definitions are Legal in Local Contexts?

Isabelle: Sledgehammer finds a proof but it fails

How to hide defined constants

Inductive predicates for a fixed tuple parameter

proof (rule disjE) for nested disjunction

Canonical way to get a more specific lemma

Can I define multiple names for a theorem?

How do I remove duplicate subgoals in Isabelle?

Why won't Isabelle simplify the body of my “if _ then _ else” construct?

What rule does 'apply (rule)' or 'proof' use?

How to get a typedef type to inherit operators from its mother type for type classes