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

Categories

HOME
cakephp
log4j
client
minimum-spanning-tree
react-virtualized
appx
tizen-web-app
dxl
jxls
sql-server-2016
retrofit
acquia
webrequest
applepay
kibana-4
gnupg
midi
offline
messages
circuit
django-admin
serilog
nhibernate-envers
immutable.js
object-detection
accessor
excel-2007
buildbot
underflow
facebook-access-token
virtualdub
info.plist
maxmind
windowbuilder
google-cloud-endpoints-v2
twilio-api
code-contracts
typed.js
catch-all
pim
android-nestedscrollview
atl
http-digest
io-redirection
mesos-chronos
email-templates
nomethoderror
import-from-excel
angular-resource
google-datalayer
termination
domain-model
rdfs
r-forge
akka-cluster
epson
flutterwave
lync-client-sdk
dynamics-sl
yt-project
color-picker
grails-tomcat-plugin
removechild
google-web-starter-kit
fuzzy-search
multiple-regression
moveit
make-install
dlna
tform
pyke
phpcas
uid
unity-networking
separator
teamcity-8.0
collapse
tmuxinator
spidermonkey
pundit
computer-algebra-systems
kcachegrind
mono-embedding
cisco-ios
website-monitoring
asp.net-dynamic-data
file-copying
codeigniter-routing
google-reader
hippomocks
marmalade
poller
dealloc
concurrent-collections
page-layout
rabl
xamlparseexception
flashvars
jelly
factory-method
venn-diagram
datawindow
newtonscript
ticoredatasync
assembly-loading
mod-auth
infobox
winbugs14
w3wp.exe
zend-translate
gallio
gamequery
routedevent
zend-decorators
post-build
msdev
mdac

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App