### 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

Discriminant with Inequalities

Instances in locale declaration for Isabelle

How to interactively simplify a formula in a relational theory in Isabelle

Nonnegative Interval Integration

Widening the domain of a partial function

Automatically unfolding a record definition when accessor is used

Creating a datatype with inequalities in Isabelle

Isabelle Logic simple natural deduction test

Instantiating variables ending in a digit using where-attribute (Isabelle)

Using an existing definition in Isabelle/ Hol

Pending sort hypotheses

How can I use proved goals of locale interpretation to prove the remaining ones

Isabelle class obligation prove blue

Type declaration in Isabelle

Isabelle2016 and Proof General

Theory level obtain command