12.07.2015 Views

Tutorial on Isabelle/HOL

Tutorial on Isabelle/HOL

Tutorial on Isabelle/HOL

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.8 The Definiti<strong>on</strong>al Approach 252.7.2 C<strong>on</strong>stant Definiti<strong>on</strong>sN<strong>on</strong>recursive definiti<strong>on</strong>s can be made with the definiti<strong>on</strong> command, forexample nand and xor gates (based <strong>on</strong> type gate above):definiti<strong>on</strong> nand :: gate where "nand A B ≡ ¬(A ∧ B)"definiti<strong>on</strong> xor :: gate where "xor A B ≡ A ∧ ¬B ∨ ¬A ∧ B"The symbol ≡ is a special form of equality that must be used in c<strong>on</strong>stantdefiniti<strong>on</strong>s. Pattern-matching is not allowed: each definiti<strong>on</strong> must be of theform f x 1 . . . x n ≡ t. Secti<strong>on</strong> 3.1.6 explains how definiti<strong>on</strong>s are used in proofs.The default name of each definiti<strong>on</strong> is f _def, where f is the name of thedefined c<strong>on</strong>stant.!!A comm<strong>on</strong> mistake when writing definiti<strong>on</strong>s is to introduce extra free variables<strong>on</strong> the right-hand side. C<strong>on</strong>sider the following, flawed definiti<strong>on</strong> (where dvdmeans “divides”):"prime p ≡ 1 < p ∧ (m dvd p −→ m = 1 ∨ m = p)"<strong>Isabelle</strong> rejects this “definiti<strong>on</strong>” because of the extra m <strong>on</strong> the right-hand side, whichwould introduce an inc<strong>on</strong>sistency (why?). The correct versi<strong>on</strong> is"prime p ≡ 1 < p ∧ (∀ m. m dvd p −→ m = 1 ∨ m = p)"2.8 The Definiti<strong>on</strong>al ApproachAs we pointed out at the beginning of the chapter, asserting arbitrary axiomssuch as f (n) = f (n) + 1 can easily lead to c<strong>on</strong>tradicti<strong>on</strong>s. In order toavoid this danger, we advocate the definiti<strong>on</strong>al rather than the axiomatic approach:introduce new c<strong>on</strong>cepts by definiti<strong>on</strong>s. However, <strong>Isabelle</strong>/<strong>HOL</strong> seemsto support many richer definiti<strong>on</strong>al c<strong>on</strong>structs, such as primrec. The pointis that <strong>Isabelle</strong> reduces such c<strong>on</strong>structs to first principles. For example, eachprimrec functi<strong>on</strong> definiti<strong>on</strong> is turned into a proper (n<strong>on</strong>recursive!) definiti<strong>on</strong>from which the user-supplied recursi<strong>on</strong> equati<strong>on</strong>s are automatically proved.This process is hidden from the user, who does not have to understand thedetails. Other commands described later, like fun and inductive, work similarly.This strict adherence to the definiti<strong>on</strong>al approach reduces the risk ofsoundness errors.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!