• Keine Ergebnisse gefunden

Inductive Definitions and Fixed Points

N/A
N/A
Protected

Academic year: 2022

Aktie "Inductive Definitions and Fixed Points"

Copied!
8
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

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!

(2)

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

"~ a1S;. . .;anS;A1;. . .;Ak =⇒ aS" | . . . |

. . . 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.

(3)

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=⇒2even=⇒4even 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~a1S;. . .;anS;. . . =⇒ a0S: Show that assuminga1S;. . .;anS;. . . and property holds for terms a1, . . . ,an, it holds for terma0

Applied toeven, we have to show:

k.2∗k =0: trivial

Assumingn∈evenandk.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

(4)

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:

~a1S;. . .;anS=⇒ aS 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)

(5)

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)

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 allbA and

y0L : ((y0upper bound ofA)−→yy0)

Infimum:analogously defined, greatest lower bound

(7)

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

{yL |yF(y)} 2. (WP)∈P

3. VP=V

{yL |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{yL |yF(y)}and(WP)∈P LetD ={yL |yF(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,xuandF(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≤WPu, i.e.,u=WP.

(8)

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 Af B (mono_def) whereA, B are often sets and≤is

lfp f ≡ Inf {u|f uu} (lfp_def)

mono f =⇒ lfp f =f (lfp f) (lfp_unfold)

~mono f;f (inf (lfp f)P) ≤ P =⇒ lfp fP (lfp_induct)

gfp f ≡ Sup{u| uf u} (gfp_def)

mono f =⇒ gfp f =f(gfp f) (gfp_unfold)

~mono f; X ≤f (sup X (gfp f)) =⇒ Xgfp f (coinduct)

©Arnd Poetzsch-Heffter et al. TU Kaiserslautern 311

Referenzen

ÄHNLICHE DOKUMENTE

Note that Propositions 1.3.5 and 1.3.7 and Corollary 1.3.6 hold for any countable strict inductive limit of an increasing sequence of locally convex

The application of the GMBA mountain definition and bioclimatic layer revealed that of the 0.5 Billion people who are living within the global mountain terrain or within &lt; 4 km

On the other hand, if 5£ is the collection of all X positive operator forms s/(X.x), then FID(^) is nothing but a variant of the well-known theory IDi (cf. Buchholz, Feferman,

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

Inductive Definitions and Fixed Points 6.3 Specifying and verifying transition systems. Modeling approach

Monoidal categories I – definitions, examples and graphical calculus We have seen Feynman diagrams for categories, but they are a 1

In principle, resource efficiency can result in net economic benefits – which we describe as ‘economically attractive resource efficiency’ – or net economic costs (such as where

To edit mining pool data, the user may choose mining pool and / or altcoin available for moni- toring from corresponding dropdown lists, edit altcoin wallet or altcoin wallet