0

Isabelle doesn't let me write just fun f :: "nat list => nat"; I have to add at least one defining equation, e.g. where "f [] = 5". But since it's fine to leave some constructors undefined, why can't I simply leave all constructors undefined? Then, a fun f without a where would be a handy alternative to the consts f declaration.

John Wickerson
  • 1,204
  • 12
  • 23

1 Answers1

2

Firstly, I do not see why fun f without where is a handy alternative to consts f. You have the latter at your disposal (but also have to specify a type), use it if you must. Moreover, consts is more primitive than commands like definition, fun, and -- in my opinion -- shouldn't be used in production code.

As for your comment on leaving constructors undefined inside a function declaration. The wording "undefined" is misleading here, since, e.g., after

fun f :: "'a list => nat"
where
  "f [] = 0"

you can prove that

lemma "f (x#xs) = undefined"
  by (cases "x#xs" rule: f.elims) simp

and thus f (x#xs) is, in some sense, defined to be the value undefined. In contrast, after

consts f :: "'a list => nat"

you cannot proof anything about f. You just told the system that there is a constant f of a certain type, but without saying anything further about it.

chris
  • 4,988
  • 20
  • 36
  • Thanks Chris. I hadn't realised the distinction between being defined as 'undefined' and not being defined, so thanks for clarifying that. My comment about 'a handy alternative' stemmed simply from the idea that when working in a 'top-down' way, it's handy to declare a function without having to immediately define it. – John Wickerson Feb 10 '15 at 14:44