···44\p{These notes are the basis of my short course at the [ANU Logic Summer School]() 2025. \strong{THEY ARE NOT YET COMPLETE.}}
55\transclude{isa-0002}
66\transclude{isa-001B}
77+\transclude{isa-002N}
···11\date{2025-12-03T06:13:19Z}
22\author{liamoc}
33\title{\code{inductive} predicates}
44-\p{TODO}44+\p{With the \code{inductive} command, we define a predicate by specifying a collection of inference rules, and the inductive predicate is the smallest predicate closed under those rules.}
55+\p{In other words: An element satisfies the predicate exactly if it can be derived using the given rules.}
66+\p{From the given rules, Isabelle automatically generates an induction principle (\code{.induct}) which can be used with the \code{induct} method (see \ref{isa-0029}) and a cases theorem (\code{.cases}) for use with the [[isa-001L]] method. }
+8-1
trees/isa/isa-0029.tree
···11\date{2025-12-03T06:14:12Z}
22\author{liamoc}
33\taxon{Proof Method}
44+\import{shiki-macros}
55+\put\shiki/language{Isabelle Theory}
46\title{\code{induct} (for rule induction)}
55-\p{TODO}77+\p{You’ve already seen [how to use \code{induct}](isa-001P) for structural induction. Exactly the same \code{induct} method can also be used for rule induction, when your induction is over an \code{inductive}ly defined predicate, not over the structure of some \code{datatype}.}
88+\p{When you define a predicate \code{p} with the [\code{inductive} command](isa-0028), Isabelle automatically produces an induction rule named \code{p.induct}. This rule expresses how to perform induction over derivations of \code{p x}, one case for each introduction rule of the predicate.}
99+\p{Although you could apply the raw rule with \code{rule} or \code{erule}, it is almost always easier to use:}
1010+\shiki{apply (induct rule: p.induct)}
1111+\p{This behaves just like structural induction:
1212+The goal is split into one subgoal per introduction rule of the predicate, and recursive premises of the rules give rise to induction hypotheses, added to your assumptions.}
···11\date{2025-12-03T06:41:41Z}
22\title{Controlling backtracking, chaining methods with comma}
33\author{liamoc}
44-\p{TODO}44+\import{shiki-macros}
55+\put\shiki/language{Isabelle Theory}
66+\p{Some methods (like [\code{erule}](isa-0011) when there are multiple matching assumptions) are \em{nondeterministic}, producing multiple alternative proof states.}
77+\p{The \code{back} command interactively explores a different alternative branch produced by the previous step.}
88+\shiki{lemma "C ∧ D ⟹ A ∧ B ⟹ A"
99+apply (erule conjE) (* could apply to either assumption *)
1010+back
1111+apply assumption
1212+done}
1313+\p{This is useful for interactive exploration, but is \em{very brittle} and considered poor style.}
1414+\p{Instead, we can combine methods with the \em{comma} operator \code{,}: The command \code{apply (m1, m2)} first runs \code{m1}, and then runs \code{m2}, accepting only the nondeterministic branches where the second method \code{m2} succeeds. This avoids the need for back:}
1515+\shiki{lemma "C ∧ D ⟹ A ∧ B ⟹ A"
1616+apply (erule conjE, assumption)
1717+done}
+5-1
trees/isa/isa-002G.tree
···11\date{2025-12-03T06:42:16Z}
22\title{Repeating methods with \code{+}}
33\author{liamoc}
44-\p{TODO}
44+\import{shiki-macros}
55+\put\shiki/language{Isabelle Theory}
66+\p{For a method \code{m}:}
77+\shiki{apply (m)+}
88+\p{Repeatedly applies the \code{m} as many times as possible until it fails. It stops automatically when \code{m} can no longer make progress; and does not backtrack.}
···11\date{2025-12-03T06:48:06Z}
22\author{liamoc}
33+\import{shiki-macros}
44+\put\shiki/language{Isabelle Theory}
35\title{Generalising the induction hypothesis with \code{arbitrary}}
44-\p{TODO}66+\p{By default, [structural induction](isa-001P) \code{induct t} produces an induction hypothesis for the variables directly mentioned in \code{t}, and [rule induction](isa-0029) \code{induct rule: p.induct} produces a hypothesis for the variables directly mentioned by the eliminated \code{p} assumption.}
77+\p{Sometimes you need a stronger hypothesis that generalises across additional variables in the goal. The \code{arbitrary} option tells the \code{induct} method to generalise certain variables, so the induction hypothesis assumes the property holds for all values of those variables.}
88+99+\transclude{isa-002M}
···11+\date{2025-12-03T11:17:28Z}
22+\author{liamoc}
33+\taxon{Example}
44+\import{shiki-macros}
55+\parent{isa-002N}
66+\title{Even numbers as an \code{inductive}}
77+\put\shiki/language{Isabelle Theory}
88+\shiki{inductive even :: "nat ⇒ bool" where
99+ even0: "even 0"
1010+| evenSS: "even n ⟹ even (Suc (Suc n))"}
+17
trees/isa/isa-002L.tree
···11+\date{2025-12-03T11:17:28Z}
22+\author{liamoc}
33+\taxon{Exercise}
44+\import{shiki-macros}
55+\import{dt-macros}
66+\parent{isa-002N}
77+\title{Even numbers are multiples of two}
88+\put\shiki/language{Isabelle Theory}
99+\shiki{lemma "even n ⟹ ∃m. (m * 2 = n)"}
1010+\solnblock{
1111+ \shiki{apply (induct rule: even.induct)
1212+ apply simp
1313+apply (erule exE)
1414+apply (rule_tac x = ‹Suc m› in exI)
1515+apply simp
1616+done}}
1717+
+15
trees/isa/isa-002M.tree
···11+\date{2025-12-03T12:43:00Z}
22+\author{liamoc}
33+\import{shiki-macros}
44+\put\shiki/language{Isabelle Theory}
55+\taxon{Example}
66+\title{Inequality as an \code{inductive}}
77+\shiki{inductive myLE :: "nat ⇒ nat ⇒ bool" where
88+ base: "myLE 0 n"
99+| step: "myLE m n ⟹ myLE (Suc m) (n+1)"}
1010+\p{Proving that this implies the normal inequality relation requires the use of [variable generalising](isa-002I):}
1111+\shiki{lemma "myLE m n ⟹ m ≤ n"
1212+apply (induct m arbitrary: n)
1313+ apply simp
1414+apply (erule myLE.cases; simp)
1515+done}