https://isabelle.in.tum.de/documentation.html
Comments: (* .... *)
Launch editor: isabelle jedit
An example isabelle project: https://github.com/WasmCert/WasmCert-Isabelle/
Has HOL, FOL, ZFC
User plugin location: ~/.isabelle/Isabelle2024/jedit
Structured Isar proofs: https://courses.grainger.illinois.edu/cs576/sp2015/doc/isar-overview.pdf
sledgehammer
tactic
metis
tactic: for using proof discovered by
sledgehammer
??An example proof: https://github.com/hwayne/lets-prove-leftpad/tree/master/isabelle
type_synonym
: For type aliases
type_synonym 'a infmatrix = "nat ⇒ nat ⇒ 'a"
type_synonym mem = "(mem_rep × nat option)"
(nat ⇒ nat ⇒ 'a::zero)
is like
Zero a => nat -> nat -> a)
in Haskell
::
here indicates a type class constraint`~=`: not equal to
Isar: a proof language
∧ a b ⟦ A1; A2 ⟧
means a
,
b
are parameters and A1
, A2
are
assumptions
Default associativity of addition is left (unlike coq? where it is right)
Variable used in class
has to be
'a
??
α
Eisbach: a collection of tools for defining new proof methods
method
commandMatrices (extractable): https://www.isa-afp.org/browser_info/current/AFP/Jordan_Normal_Form/document.pdf
Isabelle Archive of Formal Proofs (Isabelle AFP)
Explicitly open or close a block: {
and
}
next
Inner and outer syntax
typedecl
: declare a type but without its
definition
typedecl 'a set
axiomatization
Inner syntax: the HOL syntax (when using Isabelle/HOL)
Outer syntax: the theory language
begin
, end
, theory
,
etcLike in Coq, theorem
and lemma
have the
same effect.
hide_const
: hide a constant to avoid namespace
pollution ??
hide_const f
: hides f
completelyhide_const (open) f
: hides f
, but it is
still accessible like A.f
hide_class
, hide_fact
,
hide_type
Stuff available from Main
: https://isabelle.in.tum.de/dist/Isabelle2024/doc/main.pdf
Coq analogues:
Isabelle | Coq |
---|---|
Isar | Ltac |
locale | Section |
Proof methods | Tactics |
==> |
-> (implication) |
=> |
-> (arrow) |
value |
Compute |
sorry |
admit |
oops |
give_up |
x:xs |
x # xs |
auto
is 'overeager'
Functionality of auto
includes that of
simp
simp
acts on current sub-goal only
simp_all
and auto
acts on all
sub-goals
simp add: name
allows simp
to simplfiy
name
as well
Example of a case split:
simp split: nat.split
Like in ssreflect, by proof-method
is short for
apply proof-method; done
blast
: a complete proof procedure for first order
logic
metis
: for using proofs discovered via
sledgehammer
metis
allows Isabelle to
independently verify the proof as it doesn't trust third party solvers
used by sledgehammer
fastforce
: ??
Backchain (backward reasoning): Use rule
with
apply
apply (rule name)
method_setup
: for creating custom proof methods
Default names:
f
is f_def
Let_def
case_name_unfold
case_prod_unfold
class_name_def
monoid_prod_def
notation
Associate a mixfix notation with a predefined definition.
Example from the isabelle tutorial:
definition xor :: "bool => bool => bool" (infixl "[+]" 60)
where "A [+] B = (A ∧ ¬B) ∨ (¬A ∧ B)"
notation (xsymbols) xor (infixl "±" 60)
where xsymbols
is an optional argument?? called the
'print mode specification' which is used when pretty-printing.
abbreviation
Kind of like a more complex form of notation
.
print__abbrevs
: print all abbreviations in the current
contextclass group = monoid +
fixes inverse :: ‹'a ⇒ 'a› (‹(_÷)› [1000] 999)
assumes invl: ‹x÷ ⊗ x = 𝟭›
*<*
and
*>*
oops
is often made to render as ...
via
latex macros—
Markup commands:
—
Anti-quotations
Use value
to compute. Like Compute
of
Coq.
datatype onat = Zero | Succ onat
fun oadd :: "onat ⇒ onat ⇒ onat" where
"oadd Zero n = n" |
"oadd (Succ m) n = Succ (oadd m n)"
value "oadd Zero (Succ Zero)"
(*
"Succ Zero"
:: "onat"
*)
https://isabelle.in.tum.de/dist/doc/jedit.pdf
[|
, |]
to make ⟦
,
⟧
& tab
, or \<and> tab
for
∧
"
to choose ‹ .. ›
C-e Up
: superscriptC-e Down
: subscriptC-e Left
: italicC-e Right
: boldM-S-Ret
Examples of 'cartouches' (ie, the special symbols, I guess):
\<open> |
‹ |
\<one> |
𝟭 |
Other editors:
isabelle vscode
(WIP as of Jan 2025)
https://isabelle.in.tum.de/doc/classes.pdf
Example:
record tg =
tg_mut :: mut
tg_t :: t
A way of having modularity
Part of the isar proof language
Locales are like Section
-s in Coq ???
sublocale
Like contexts 'that have been made persistent'
fixes x ∷ τ (mx)
: declare local var x
of type τ
and a mixfix annotation mx
constrains x ∷ τ
: introduce a type constraint
τ
on local var x
for
inside a fixes
clause instead.assumes
: introduce local assumptions
defines
: add definition of a previously declared
name
https://www21.in.tum.de/%7Ekuncar/documents/huffman-kuncar-cpp2013.pdf
Via Quotient and Lifting packages
setup-lifting
, lift-definition
Coercion functions:
Rep
(to an arbitrary
element in the equivalence class)Abs
quotient_type
: Generates a new type with
Rep
and Abs
functions when given a raw type
and an equivalence relation
quotient_definition
: Create a function on abstract
type given function on raw type and the quotient type
descending
, lifting
bundle
unbundle
include
includes
including
A class instance can be defined in more than one way, apparently.
theory Example
imports Main
begin
class semigroup =
fixes sgop :: ‹'a ⇒ 'a ⇒ 'a› (infixl ‹⊗› 70)
assumes assoc : ‹(x ⊗ y) ⊗ z = x ⊗ (y ⊗ z)›
class monoid = semigroup +
fixes unit :: ‹'a› (‹𝟭›)
assumes unitl : ‹unit ⊗ x = x›
and unitr : ‹x ⊗ unit = x›
instantiation prod :: (semigroup, semigroup) semigroup
begin
definition sgop_prod :: "'a × 'b ⇒ 'a × 'b ⇒ 'a × 'b" where
"sgop_prod x y =
(case x of (a1, b1) ⇒
(case y of (a2, b2) ⇒ (a1 ⊗ a2, b1 ⊗ b2)))"
instance proof
fix p q r :: ‹'a::semigroup × 'b::semigroup›
show ‹(p ⊗ q) ⊗ r = p ⊗ (q ⊗ r)›
unfolding sgop_prod_def
unfolding case_prod_unfold
by (simp add: assoc)
qed
end
The instance for pair semigroup could also have been done (outside of prove mode??) like:
instance
apply (standard)
apply (simp add: sgop_prod_def)
apply (simp add: case_prod_unfold)
apply (simp add: assoc)
done
datatype
declarations are at least as capable as
the 'old datatypes'.datatype_compat
to make new datatypes
compatible with old datatype machineryFrom https://isabelle.in.tum.de/library/Doc/Datatypes/Datatypes.html:
'
datatype_compat
command registers new-style datatypes as old-style datatypes and invokes the old-style plugins'
Use (nonexhaustive)
annotation to say that a function is
not total. For example:
primrec (nonexhaustive) last :: "'a list ⇒ 'a" where
"last (x # xs) = (if xs = [] then x else last xs)"
https://isabelle.in.tum.de/doc/codegen.pdf