Chapter 6
Inductive Definitions and Fixed Points
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 282
Overview of Chapter
6. Inductive Definitions and Fixed Points 6.1 Inductively defined sets and predicates 6.2 Fixed point theory for inductive definitions 6.3 Specifying and verifying transition systems
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 283
6. Inductive Definitions and Fixed Points 6.0
Introduction
Constructs for defining types and functions
Isabelle/HOL provides two core constructs for conservative extensions:
1. Constant definitions 2. Type definitions
Based on the core construct, there are further constructs:
• Recursive function definitions (primrec,fun,function)
• Recursive datatype definitions (datatype)
• Co-/inductively defined sets(inductive_set,coinductive_set)
• Co-/inductively defined predicates(inductive,coinductive)
6. Inductive Definitions and Fixed Points 6.0
Motivation
Goals
• Learn about inductive definitions:
{important concept in computer science!
E.g., to define operational semantics.
• Learn the underlying fixed point theory:
{fundamental theory in computer science!
• Learn how to apply it to transition systems
{central modeling concept for operational behavior!
6. Inductive Definitions and Fixed Points 6.1 Inductively defined sets and predicates
Section 6.1
Inductively defined sets and predicates
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 286
6. Inductive Definitions and Fixed Points 6.1 Inductively defined sets and predicates
Introductory example
Informally:
• 0 is even
• If n is even, so is n + 2
• These are the only even numbers In Isabelle/HOL:
-- The set of all even numbers
inductive_set even :: "nat set" where zero [intro!] "0 ∈ even" |
step [intro!] "n ∈ even =⇒ n + 2 ∈ even"
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 287
6. Inductive Definitions and Fixed Points 6.1 Inductively defined sets and predicates
Format of inductive definitions
inductive_set S :: "τ set" where
"~ a1∈S;. . .;an∈S;A1;. . .;Ak =⇒ a ∈S" | . . . |
. . . where
• A1, . . . ,Ak are side conditions not involvingSand
• a is a term build froma1, . . . ,an.
The rules can be given names and attributes as seen in definition ofeven.
6. Inductive Definitions and Fixed Points 6.1 Inductively defined sets and predicates
Embedding inductive definitions into HOL
Conservative theory extension From an inductive definition, Isabelle
• generates adefinitionusing a fixed point operator and
• proves theorems about it that can be used as proof rules
The theory underlying the fixed point definition is explained in Subsect. 2.
Generated rules
Rules
Generated rules include
• the introduction rules of the definition, e.g.,
0∈even (even.zero)
n∈even=⇒ n+2∈even (even.step)
• an elimination rule for case analysis and
• an induction rule.
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 290
Proving simple properties of inductive sets
Example 1:
Lemma: 4∈even
Proof: 0∈even=⇒2∈even=⇒4∈even Discussion:
• Simple: Useeven.zeroand apply ruleeven.stepfinitely many times.
• Works because there is no free variable
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 291
6. Inductive Definitions and Fixed Points 6.1 Inductively defined sets and predicates
Proving properties of inductive sets
Example 2:
Lemma:m ∈even=⇒ ∃k.2∗k =m Proof: Idea:
• For rules of the forma ∈S: Show that property holds fora
• For rules of the form~a1∈S;. . .;an ∈S;. . . =⇒ a0∈S: Show that assuminga1∈S;. . .;an∈S;. . . and property holds for terms a1, . . . ,an, it holds for terma0
Applied toeven, we have to show:
• ∃k.2∗k =0: trivial
• Assumingn∈evenand∃k.2∗k =n, show∃k.2∗k =n+2 : simple arithmetic
6. Inductive Definitions and Fixed Points 6.1 Inductively defined sets and predicates
Rule induction for even
To proven∈even =⇒P nby rule induction, one has to show:
• P0
• P n =⇒ P (n+2)
Isabelle provides the ruleeven.induct:
~n∈even; P0;^
n.P n=⇒P(n+2)=⇒ P n
6. Inductive Definitions and Fixed Points 6.1 Inductively defined sets and predicates
Rule induction vs. natural/structural induction
Remarks:
• Rule induction uses the induction steps of the inductive definition and not of the underlying datatype! It differs from natural/structural
induction.
• In the context of partial recursive functions, a similar proof technique is often called computational or fixed point induction.
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 294
6. Inductive Definitions and Fixed Points 6.1 Inductively defined sets and predicates
Rule induction in general
LetS be an inductively defined set.
To prove x ∈S =⇒ P x by rule induction onx ∈S, we must prove for every rule:
~a1∈S;. . .;an ∈S=⇒ a ∈S thatP is preserved:
~P a1;. . .; P an=⇒ P a In Isabelle/HOL: apply (induct rule: S.induct)
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 295
6. Inductive Definitions and Fixed Points 6.1 Inductively defined sets and predicates
Inductive predicates
Isabelle/HOL also supports the inductive definition of predicates:
X ∈S { S x
Example:
inductive even:: "nat ⇒ bool" where
"even 0" |
"even n =⇒ even (n+2)
Comparison:
• predicate: simpler syntax
• set: direct usage of set operation, like∪, etc.
6. Inductive Definitions and Fixed Points 6.1 Inductively defined sets and predicates
Further aspects
• Rule inversion and inductive cases (see IHT 7.1.5)
• Mutual inductive definitions (see IHT 7.1.6)
• Parameters in inductive definitions (see IHT 7.2)
Section 6.2
Fixed point theory for inductive definitions
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 298
Motivation
Introduction:
Inductive definitions can be considered as:
• Constant definition: define exactly one set (semantic interpretation)
• Axiom system: except all sets that satisfy the rules (axiomatic interpretation)
• Derivation system: show that an element is in a set by applying the rules (derivational interpretation)
Isabelle/HOL is based on the semantic interpretation. In addition, it allows to use the rules as part of the derivation system.
Remark
The interpretations have advantages and disadvantages/problems.
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 299
6. Inductive Definitions and Fixed Points 6.2 Fixed point theory for inductive definitions
Illustrating the problems
Problem of semantic interpretation:
We have to assign a set to any well-formed inductive definition.
Example:
Which set should be assigned tofooset:
inductive_set fooset :: "nat set" where
"n ∈ fooset =⇒ n+1 ∈ fooset "
Problem of derivational interpretation
The rules of the definition are too weak. E.g., we cannot prove:
3<even
6. Inductive Definitions and Fixed Points 6.2 Fixed point theory for inductive definitions
“Looseness” of rules
Problem of axiomatic interpretation:
There are usually many sets satisfying the rules of an inductive definition.
Example:
The following seteven2satisfies the rules ofeven: definition even2 :: "nat set" where
"even2 ≡ { n. n , 1 }"
lemma "0 ∈ even2"
lemma "n ∈ even2 =⇒ n+2 ∈ even2"
6. Inductive Definitions and Fixed Points 6.2 Fixed point theory for inductive definitions
Semantics of inductive definition
Definition
Letf ::T ⇒T be a function. A valuex is called afixed pointoff ifx =f x.
Semantics approach for inductive definitions Three steps:
• Transform inductive definitionID into “normalized form”
• “Extract” a fixed point equation for a functionFID ::nat set ⇒nat set
• Take the least fixed point
Assumption
For every (well-formed) inductive definition, the least fixed point exists.
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 302
6. Inductive Definitions and Fixed Points 6.2 Fixed point theory for inductive definitions
Transformation to “normalized form”
A “normalized” inductive definition has exactly one implication of the form:
inductive_set S :: "nat set" where
"m ∈ (FS S) =⇒ m ∈ S"
Example:
inductive_set even :: "nat set" where
"0 ∈ even" |
"n ∈ even =⇒ n+2 ∈ even"
has the normalized form:
inductive_set even :: "nat set" where
"m ∈ {m. m=0 ∨ (∃n. n ∈ even ∧ m=n+2)} =⇒ m ∈ even"
That is, the functionFeven is
Feven nset = {m. m=0 ∨ (∃n. n ∈ nset ∧ m=n+2)}
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 303
6. Inductive Definitions and Fixed Points 6.2 Fixed point theory for inductive definitions
Fixed point equation and existence of fixed points
Fixed point equation for a “normalized” inductive definition:
FS S = S
Existence of fixed points:
Unique least and greatest fixed points exist if 1. FS is monotone, i.e.,FS S ⊆S for allS.
2. Domain (and range) ofFS is a complete lattice (Knaster-Tarski theorem)
Prerequisites are satisfied for inductive definitions, because
1. In inductive definitions, occurrence ofx ∈Smust bepositive, and this allows to prove monotonicity.
2. Set of sets are a complete lattice with⊆as ordering.
6. Inductive Definitions and Fixed Points 6.2 Fixed point theory for inductive definitions
Supremum and infimum
Definition (Supremum/infimum)
Let(L,≤)be partially ordered set andA ⊆L.
• Supremum:y ∈L is called asupremumofA if yis an upper bound ofA, i.e.,b ≤y for allb ∈A and
∀y0∈L : ((y0upper bound ofA)−→y ≤y0)
• Infimum:analogously defined, greatest lower bound
Complete lattices
Definition (Complete lattice)
A partially ordered set(L,≤)is acomplete latticeif every subsetA ofL has both an infimum (alo called the meet) and a supremum (also called the join) inL.
The meet is denoted byVA, the join byWA.
Lemma
Complete lattices are non empty.
Lemma
LetP(S)be the power set of a set S.
(P(S),⊆)is a complete lattice.
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 306
Existence and structure of fixed points
Theorem (Knaster-Tarski)
Let(L,≤)be a complete lattice and let F :L →L be a monotone function.
Then the set of fixed points of F in L is also a complete lattice.
Corollary (Knaster-Tarski)
F has a (unique) least and greatest fixed point.
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 307
6. Inductive Definitions and Fixed Points 6.2 Fixed point theory for inductive definitions
Proof of Knaster-Tarski Corollary
We prove:
The set of all fixed pointsP ofF,P ⊆L, has the following properties:
1. WP=W
{y ∈L |y ≤F(y)} 2. (WP)∈P
3. VP=V
{y ∈L |F(y)≤y } 4. (VP)∈P
That is,(WP)is the greatest and(VP)∈Pthe least fixed point.
Proof:
We show the first two properties. The proof of the third and forth property are analogous.
6. Inductive Definitions and Fixed Points 6.2 Fixed point theory for inductive definitions
Proof of Knaster-Tarski Corollary (2)
Show: WP =W{y ∈L |y ≤F(y)}and(WP)∈P LetD ={y ∈L |y ≤F(y)}andu =WD. We show:
u ∈P andu =WP, i.e.,uis the greatest fixed point ofF.
For allx ∈D, alsoF(x)∈D, because F is monotone andF(x)≤F(F(x)). F(u)is an upper bound ofD, because forx ∈D,x ≤uandF(x)≤F(u), i.e.,x ≤F(x)≤F(u).
Asuis least upper bound,u≤F(u). Thus,u∈D.
As shown above,u∈D impliesF(u)∈D, thusF(u)≤u.
In summary,F(u) =u, i.e.,uis a fixed point,u∈P.
BecauseP ⊆D,WP≤WD, henceu≤WP ≤u, i.e.,u=WP.
6. Inductive Definitions and Fixed Points 6.2 Fixed point theory for inductive definitions
Lattices in Isabelle/HOL
Remark
Isabelle/HOL handles:
• lattices in Chapter 5 of theory Main
• complete lattices in Chapter 8 of theory Main
• inductive definitions and Knaster-Tarski in Chapter 9
The natural numbers are introduced in Chapter 15, using an inductive definition!
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 310
6. Inductive Definitions and Fixed Points 6.2 Fixed point theory for inductive definitions
Some related definitions and lemmas in Isabelle/HOL
mono f ≡ ∀A B. A ≤B −→f A ≤f B (mono_def) whereA, B are often sets and≤is⊆
lfp f ≡ Inf {u|f u≤u} (lfp_def)
mono f =⇒ lfp f =f (lfp f) (lfp_unfold)
~mono f;f (inf (lfp f)P) ≤ P =⇒ lfp f ≤P (lfp_induct)
gfp f ≡ Sup{u| u≤f u} (gfp_def)
mono f =⇒ gfp f =f(gfp f) (gfp_unfold)
~mono f; X ≤f (sup X (gfp f)) =⇒ X ≤gfp f (coinduct)
©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 311