Search code examples
isabelletheorem-proving

undefined in Isabelle/HOL


I was trying to prove this lemma in Isabelle/HOL.

lemma "(0::nat) ≠ undefined"

But nitpick finds counterexamples to both this and it's negation

lemma "(0::nat) = undefined"

How is this possible? I looked up how undefined is defined and it's an axiom:

axiomatization undefined :: 'a

But it's still classical logic, right? So either "(0::nat) = undefined" or "(0::nat) ≠ undefined" should be true.


Background:

I have a function of type:

type_synonym myfun = "nat ⇒ nat"

and I impose constraints on its image and domain in a locale. When I tried to take a specific function and show that it fulfills all conditions in the locale I got problems since some of the conditions only hold for values that are not undefined.

Thank you in advance :)


Solution

  • By axiomatisation, each type has one designated value that is undefined. This is not some separate value that lives outside the normal range of that type, i.e. undefined :: nat is a natural number, but you do not know which natural number it is, and in fact you will not be able to prove any non-trivial property about undefined. A trivial property in this context is one that holds for all values of the type.

    Therefore, the statement undefined ≠ (0 :: nat) is not provable in Isabelle/HOL, and neither is its negation (bugs and inconsistencies aside).

    For undefined :: bool in particular, we know that undefined = True ∨ undefined = False, but again, you will not be able to prove undefined = True or undefined = False.

    For the unit type (the one-element type consisting only of the value () :: unit), however, you can prove undefined = (), since this is a trivial property.

    As for your original problem, it sounds as if you have to change the way you model undefinedness in your application. Since you did not give any details about what you are doing, it is not really possible to give any specific advice about what to do. But trying to prove anything about undefined is not going to work.