User Tools

Site Tools


start

This is an old revision of the document!


Isabelle/HOL and Proof General Reference

This site is intended to help getting started with using Isabelle/HOL and the Proof General. This page in particular is the quick cheat sheet and can be used as a reference.

Please use the FAQ - Ask Questions page to post and view questions and the Exam Questions page to collect possible questions for the exams. The Goals of the Exercises page summarizes what you should have learned by doing them.

For best practices in Isabelle/HOL, see the corresponding page.

Please also check out and add stuff concerning the Editor, Isabelle/HOL Syntax and useful External References. Last but not least, you can post and check out Example Code.

Help us to improve the Wiki by checking and complementing existing content, as well as creating wanted pages!

Shortcuts

We denote CTRL + $key by C-$key and ALT + $key by M-$key.

General Emacs

  • C-x C-f – open a file
  • C-x C-s – save the current file
  • C-k – delete the rest of the line
  • C-a – jump to the beginning of the current line
  • C-e – jump to the end of the current line

Proof General

Press C-c C-☐ to control the proof buffer (i.e. processing the theory), with one of:

  • b – process as far as possible
  • c – cancel: interrupt a running calculation
  • fsearch in the available theorems (e.g. name: mp)
  • n – next: process the next line in Isabelle
  • p – show the current state of a proof (for instance, in place of an error message currently being shown)
  • r – retract: go back to the beginning
  • u – undo: push back the processed part of the text by one line
  • v – enter a command whose result is send to the response panel (see below for some examples)
  • RETURN – go here: evaluate up to where the cursor is

Advanced Tools

  • C-c C-a C-qquickcheck (see below)
  • C-c C-a rrefute (see below)
  • C-c C-a C-nnitpick (see below)
  • C-c C-a C-ssledgehammer (see below)
  • [Options → C-x/C-c/C-v Cut and Paste (CUA)] – enable standard hotkeys for copy and paste
  • [Isabelle → Show Me → Methods] – Prints a list of all available methods
  • [Isabelle → Settings → Display] – show hidden symbols such as types or parentheses for debugging. (in theory mode)
  • [Isabelle → Help → Isabelle Documentation] – documentation
  • [Proof-General → Quick Options → Display → Use Three Panes] – check to have a more comfortable setup (in theory mode)
  • [Proof-General → Advanced → Customize → Faces → Proof Locked Face] – change the color of the “locked” region of proofs (e.g. Khaki: #F0E68C)

Syntax

Every Isabelle/HOL theory looks like this:

theory Name imports Main
begin

  ...
  
$definitions

  ...

end

Formulae

Basic logical formula are written in the usual way. See below for the ASCII encodings of common symbols:

Logics
ASCII /\ \/ \not --> <-> or = ALL EX
Meta
ASCII !! ==> == [| |]
Math
ASCII = ~= < > \le \ge
Sets
ASCII \in \notin \subset \subseteq \inter \union

Find more symbols via [Tokens → List Shortcuts]. If you know LaTeX, try using commands you know from there.

Functions

Heuristic: try ML! Major differences:

  • Function definition with primrec, fun and function
  • List constructor is #, not ::.
  • Types and expressions have to be enclosed in double quotes

Definitions

  • Constants
    • definition $ident where “$ident == $expression” – assigns the value of $expression to identifier $ident
  • Theorems
    • lemma ($name :)? “$formula” – states $formula as lemma, assigns it a name (if given) and creates a proof goal
    • theorem ($name :)? “$formula” – states $formula as theorem, assigns it a name (if given) and creates a proof goal
  • Datatypes
    • datatype
    • type_synonym
  • Functions
    • primrec – used for primitive recursive functions (nothing to prove, but heavy constraints)
    • fun – used for more general functions, but have to prove termination (e.g. via well-founded order)
    • function – used for arbitrary function definitions; have to prove all kinds of stuff
  • (Co)Inductive Stuff

Proofs

Apply method $method with parameters $params by entering apply ($method $params). If you have no parameters, you can just write apply $method. For example, a (very simple) proof can look like this:

  lemma "[| A; A --> B |] ==> B"
  apply (frule mp)
  apply assumption+
  done

Methods

Basic Methods

Name Parameters All goals Safe New Goals Variants
assumption x
cases an expression x x case_tac
drule a rule x drule(k), drule_tac
erule a rule x erule(k), erule_tac
fold a definition (or equation) x x
frule a rule x x frule(k), frule_tac
induct a variable x induct_tac
insert a theorem x x cut_tac
rename_tac list of identifiers
rotate_tac an integer x
rule a rule x rule(k), rule_tac
split a splitting rule ? x
subgoal_tac a formula x
subst a definition (or equation) x x subst (asm)
thin_tac a formula
unfold a definition (or equation) x x ?

Automated Methods

Name Classical Simp All goals Safe Splits Finishes Strength Weakness
arith x x linear arithmetics exponentially slow for many operators
auto x x x x
blast x x x logics, sets; fast
clarify x x
clarsimp x x x
force x x x x
metis x x x logics no sets
safe x x x x
simp x x x
simp_all x x x x

Note that safety of automated proof methods can be sabotaged by adding unsafe rules to rule sets used.

There are many more methods. You can print them by issuing the command print_methods, key combination C-c C-a h m or via [Isabelle → Show Me → Methods].

Method Combinators

Symbol Semantics Example
 + Applies the method as often as applicable, but at least once. assumption+
(_,_) Applies all the methods in sequence and fails if any one is not applicable. (rule mp, simp)
[n] Applies the method only to the first n subgoals. auto[5]

The sequencing of methods has the additional effect that backtracking is used to make the whole sequence work. As many methods could be applied in different ways, e.g. by matching the premise with a different assumption, failure of one step of the sequence just leads to trying another possibility for one of the steps before.

Theorem Modification

Attributes (also: directives) can be used to obtain new, more specific theorems from already proven, more general ones. In other words, they allow you to adapt theorems to your current needs. There are two major uses:

  1. $thm [$attr1, $attr2, …] – can be used in any place where you would put a theorem or rule. Instead of $thm itself, the result of applying the given attributes from left to right is used.
  2. lemmas $name = $thm [$attr1, $attr2, …] – assigns a new name to the modified theorem, enabling later (re)use.
  3. (lemma|theorem) $name [$attr1, $attr2, …] : $formula – applies the given attributes from left to right after the proof is finished, assigning the result to the given name.
Attribute Semantics
of $t1 $t2 … Replaces variables with the given terms in order. Use _ for keeping the variable. (Example)
where $v1=$t1 and $v2=$t2 … Replaces the specified variables in a theorem with the given terms. (Example)
THEN $rule Applies the given rule to a theorem and returns the conclusion. (Example)
OF $thm1 $thm2 Generates a new instance of a rule using the given theorems. (Example)
simplified Applies simp to a theorem and returns the result. (Example)
rotated $k Rotates the given theorem's assumptions by $k to the left. If no value is given, $k=1 is assumed. (Example)
symmetric Equivalent to THEN sym. (Example)

Other attributes perform some action with a theorem. They probably only make sense in lemma/theorem definitions or together with lemmas (see above):

Attribute Action
iff Enables both simplifier and classical reasoner to use this theorem. Only use with equivalences whose right-hand side is “simpler” than left-hand side.
rule_format Lifts a top-level implication into Pure logic, i.e. enables reasoners to use the theorem as rule.
simp Allows the simplifier to use this theorem.

There are many more attributes. You can print them by issuing the command print_attributes, key combination C-c C-a h a or via [Isabelle → Show Me → Attributes].

Finishers

Command Semantics
done finishes the proof if no more subgoals left
by $method tries to finish the rest of the proof with the given method followed by assumption+
sorry forces an unfinished proof to be considered successful (i.e. lemma/theorem is usable!)
oops aborts the proof and drops the lemma/theorem

Rules

  • conjI, conjE, conjunct1, conjunct2
  • disjI1, disjI2, disjE
  • impI, impE, mp
  • iffI, iffE
  • allI, spec, bspec
  • exI, exE, bexI
  • notI, notE
  • FalseE
  • classical
  • contrapos_(pp|np|pn|nn)
  • Basically any theorem!

Assorted gimmicks

  • thm $name – command that shows theorem with name $name
  • value $expr – command that evaluates the specified expression and prints the result
  • prefer $k – command that moves subgoal number $k to the top of the list
  • defer – command that moves the current subgoal to the bottom of the list
  • quickcheck – command that tries to find a counterexample to the current subgoal. Useful to check wether an unsafe rule did harm. Note: it might not find a counterexample even if the goal can not be proven!
  • refute and nitpick – similar to quickcheck but try to find counterexample models, not only variable assignments. Can handle more constructs.
  • sledgehammer – command that invokes fully automated theorem provers both locally and on remote clusters. Tries to find a (minimal) set of theorems needed to solve the current goal.
  • lfp $function – a function that yields the least fixpoint of the given function
  • undefined – a distinguished value for any type
  • f(x := y) – the function update: the result of this expression is the function f updated such that it now returns y for parameter x; the other values do not change.
  • {x. P x} – the set of values fulfilling predicate P. For instance, {x::nat. x dvd 125} is the set of (natural) divisors of .
start.1336636492.txt.gz · Last modified: 2012/05/10 09:54 by 131.246.92.39