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

Categories

HOME
xamarin
json.net
plot
iterator
react-router
rsyslog
razor
frameworks
pivotal-cloud-foundry
gorm
remote-access
fallback
carthage
django-admin
google-cloud-speech
visual-composer
immutable.js
autocad-plugin
zapier
dcevm
extjs5
lcd
su
selectedindexchanged
windows-error-reporting
maxmind
log4js-node
jaxb2
procdump
google-api-nodejs-client
http-digest
main
automake
ws-security
ensembles
gzipstream
jsch
taffy
dotcover
dds
fancybox-2
font-size
arrow-keys
nbconvert
mcafee
gridpane
google-web-starter-kit
impresspages
ios9.1
interrupted-exception
unity3d-gui
dia
google-style-guide
angularjs-ng-click
openexr
mesa
comexception
mechanize-ruby
bundles
message-driven-bean
floating-point-precision
page-layout
oam
django-nonrel
random-seed
flashvars
angularjs-controller
dmoz
dice
jspinclude
qtkit
netbeans-6.9
ohm
spring-portlet-mvc
punbb
php-parser
coredump
psi
hamachi
disclosure
mysql-error-1005
asp.net-mvc-areas
sproutcore-2
uimenucontroller
yagni
zend-decorators
signal-handling

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App