Isabelle/HOL Syntax
This is one of the most important sections of the Wiki. Here you'll find the basic reserved words used in Isabelle/HOL, how should they be called, in which context, their meaning and hopefully some example code. If you're uploading/updating content, please try to adapt to the schema used for all the words to improve readability.
Keywords
theory
theory name
theory MyTheory
imports
imports package
Indicates what external modules (i.g. theories, packages) to import. Since Isabelle/HOL doesn't actually know a lot about functions and complex data types, you need to import them. If you create some handy theory and put it in a THY file (or just happen to have a file with a bunch of handy functions) and now you would like to use that to proof some other stuff, you can import it using this statement. Since most of the time, you need to work with some common data structures such as lists, there are already modules that come with Isabelle/HOL that deal with it. The most common one is the Main package. That comes with the structures and functions that are used the most when using Isabelle/HOL.
Params
package: the name of the package/theory/module that you want to import. Works pretty much like importing stuff in other programming languages like Python, Java, C, etc…
theory Bar
imports Main
begin
...
end
begin ... end
begin
…
end
theory Foo
imports Main
begin
...
end
definition
definition name :: “domain” where “fun_def”
Params
name: can be an arbitrary string that identifies the function.
domain: specifies the datatypes expected by the function
fun_def: is the actual definition of the function.
definition swap :: "('a * 'b) => ('b * 'a)"
where
"swap pair = (snd pair, fst pair)"
primrec
primrec name :: “domain” where “fun_def_1 | fun_def_2 | … | fun_def_n”
Params
name: can be an arbitrary string that identifies the function.
domain: specifies the datatypes expected by the function
fun_def_i: are the actual definitions of the function. There can be several of them (like for Fibonacci or Ackermann) They have to be separated by a vertical bar '|'.
primrec listSwap :: "('a * 'b) list => ('b * 'a) list"
where
"listSwap [] = []" |
"listSwap(x#xs) = (swap(x))#(listSwap(xs))"
value
value “some_val”
value "(1 # 2 # 3 # [])"
(*Assume you have a function definition called myMap :: "('a => 'b) => ('a list) => ('b list)"*)
value "myMap ((op +)1) ((1::nat) # 3 # [])"
Symbols from Libraries
Cons
Cons firstElem listTale
value "Cons 0 (Cons 1 (Cons 2 (Cons 3 Nil)))"
(*Equivalent expression using the abbreviations*)
value "0 # 1 # 2 # 3 # []"
Template
TERM
Syntax definition of the term with its parameters parameters
put some simple example code here.
Hopefully an example that isn't already in the documentation so we can have more examples.