• Keine Ergebnisse gefunden

Sets, Functions, Relations, and Fixpoints

N/A
N/A
Protected

Academic year: 2021

Aktie "Sets, Functions, Relations, and Fixpoints"

Copied!
88
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Chapter 5

Sets, Functions,

Relations, and Fixpoints

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 411

(2)

Sets, Functions, Relations

see IHT 6.1, 6.2, 6.3

� Finite Set Notation

� Set Comprehension

� Binding Operators

� Finiteness and Cardinality

� Function update, Range, Injective - Surjective

� Relations, Predicates

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 412

(3)

Overview

• Set notation

• Inductively defined sets

138

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 413

(4)

Set notation

139

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 414

(5)

Sets

Sets over type ’a:

’a set

140

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 415

(6)

Sets

Sets over type ’a:

’a set = ’a bool

140

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 416

(7)

Sets

Sets over type ’a:

’a set = ’a bool

{}, {e 1 , . . . ,e n }, {x. P x}

140

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 417

(8)

Sets

Sets over type ’a:

’a set = ’a bool

{}, {e 1 , . . . ,e n }, {x. P x}

e A, A B

140

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 418

(9)

Sets

Sets over type ’a:

’a set = ’a bool

{}, {e 1 , . . . ,e n }, {x. P x}

e A, A B

A B, A B, A - B, - A

140

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 419

(10)

Sets

Sets over type ’a:

’a set = ’a bool

{}, {e 1 , . . . ,e n }, {x. P x}

e A, A B

A B, A B, A - B, - A

• �

x ∈ A B x, x ∈ A B x

140

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 420

(11)

Sets

Sets over type ’a:

’a set = ’a bool

{}, {e 1 , . . . ,e n }, {x. P x}

e A, A B

A B, A B, A - B, - A

• �

x ∈ A B x, x ∈ A B x

{i..j}

140

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 421

(12)

Sets

Sets over type ’a:

’a set = ’a bool

{}, {e 1 , . . . ,e n }, {x. P x}

e A, A B

A B, A B, A - B, - A

• �

x ∈ A B x, x ∈ A B x

{i..j}

insert :: ’a ’a set ’a set

140

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 422

(13)

Sets

Sets over type ’a:

’a set = ’a bool

{}, {e 1 , . . . ,e n }, {x. P x}

e A, A B

A B, A B, A - B, - A

• �

x ∈ A B x, x ∈ A B x

{i..j}

insert :: ’a ’a set ’a set

• . . .

140

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 423

(14)

Proofs about sets

Natural deduction proofs:

• equalityI: [[ A B; B A ]] = ⇒ A = B

141

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 424

(15)

Proofs about sets

Natural deduction proofs:

• equalityI: [[ A B; B A ]] = ⇒ A = B

• subsetI: ( x. x A = ⇒ x B) = ⇒ A B

141

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 425

(16)

Proofs about sets

Natural deduction proofs:

• equalityI: [[ A B; B A ]] = ⇒ A = B

• subsetI: ( x. x A = ⇒ x B) = ⇒ A B

• . . . (see Tutorial)

141

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 426

(17)

Demo: proofs about sets

142

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 427

(18)

Bounded quantifiers

• ∀ x A. P x

143

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 428

(19)

Bounded quantifiers

• ∀ x A. P x ≡ ∀ x. x A −→ P x

143

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 429

(20)

Bounded quantifiers

• ∀ x A. P x ≡ ∀ x. x A −→ P x

• ∃ x A. P x

143

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 430

(21)

Bounded quantifiers

• ∀ x A. P x ≡ ∀ x. x A −→ P x

• ∃ x A. P x ≡ ∃ x. x A P x

143

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 431

(22)

Bounded quantifiers

• ∀ x A. P x ≡ ∀ x. x A −→ P x

• ∃ x A. P x ≡ ∃ x. x A P x

• ballI: ( x. x A = ⇒ P x) = ⇒ ∀ x A. P x

• bspec: [[∀ xA. P x; xA ]] = ⇒ P x

143

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 432

(23)

Bounded quantifiers

• ∀ x A. P x ≡ ∀ x. x A −→ P x

• ∃ x A. P x ≡ ∃ x. x A P x

• ballI: ( x. x A = ⇒ P x) = ⇒ ∀ x A. P x

• bspec: [[∀ xA. P x; xA ]] = ⇒ P x

• bexI: [[ P x; x A ]] = ⇒ ∃ x A. P x

• bexE: [[ ∃ x A. P x; x. [[ x A; P x ]] = ⇒ Q ]] = ⇒ Q

143

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 433

(24)

Inductively defined sets

144

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 434

(25)

Example: even numbers

Informally:

145

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 435

(26)

Example: even numbers

Informally:

• 0 is even

145

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 436

(27)

Example: even numbers

Informally:

• 0 is even

• If n is even, so is n + 2

145

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 437

(28)

Example: even numbers

Informally:

• 0 is even

• If n is even, so is n + 2

• These are the only even numbers

145

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 438

(29)

Example: even numbers

Informally:

• 0 is even

• If n is even, so is n + 2

• These are the only even numbers In Isabelle/HOL:

inductive set Ev :: nat set — The set of all even numbers

145

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 439

(30)

Example: even numbers

Informally:

• 0 is even

• If n is even, so is n + 2

• These are the only even numbers In Isabelle/HOL:

inductive set Ev :: nat set — The set of all even numbers

where

0 Ev |

n Ev = ⇒ n + 2 Ev

145

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 440

(31)

Format of inductive definitions

inductive set S :: τ set

146

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 441

(32)

Format of inductive definitions

inductive set S :: τ set

where

[[ a 1 ∈ S; . . . ; a n ∈ S; A 1 ; . . . ; A k ]] = ⇒ a S | ...

146

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 442

(33)

Format of inductive definitions

inductive set S :: τ set

where

[[ a 1 ∈ S; . . . ; a n ∈ S; A 1 ; . . . ; A k ]] = ⇒ a S | ...

where A 1 ; . . . ; A k are side conditions not involving S.

146

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 443

(34)

Proving properties of even numbers

Easy: 4 Ev

0 Ev = ⇒ 2 Ev = ⇒ 4 Ev

147

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 444

(35)

Proving properties of even numbers

Easy: 4 Ev

0 Ev = ⇒ 2 Ev = ⇒ 4 Ev Trickier: m Ev = ⇒ m+m Ev

147

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 445

(36)

Proving properties of even numbers

Easy: 4 Ev

0 Ev = ⇒ 2 Ev = ⇒ 4 Ev Trickier: m Ev = ⇒ m+m Ev

Idea: induction on the length of the derivation of m Ev

147

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 446

(37)

Proving properties of even numbers

Easy: 4 Ev

0 Ev = ⇒ 2 Ev = ⇒ 4 Ev Trickier: m Ev = ⇒ m+m Ev

Idea: induction on the length of the derivation of m Ev Better: induction on the structure of the derivation

147

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 447

(38)

Proving properties of even numbers

Easy: 4 Ev

0 Ev = ⇒ 2 Ev = ⇒ 4 Ev Trickier: m Ev = ⇒ m+m Ev

Idea: induction on the length of the derivation of m Ev Better: induction on the structure of the derivation Two cases: m Ev is proved by

• rule 0 Ev

147

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 448

(39)

Proving properties of even numbers

Easy: 4 Ev

0 Ev = ⇒ 2 Ev = ⇒ 4 Ev Trickier: m Ev = ⇒ m+m Ev

Idea: induction on the length of the derivation of m Ev Better: induction on the structure of the derivation Two cases: m Ev is proved by

• rule 0 Ev

= ⇒ m = 0 = ⇒ 0+0 Ev

147

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 449

(40)

Proving properties of even numbers

Easy: 4 Ev

0 Ev = ⇒ 2 Ev = ⇒ 4 Ev Trickier: m Ev = ⇒ m+m Ev

Idea: induction on the length of the derivation of m Ev Better: induction on the structure of the derivation Two cases: m Ev is proved by

• rule 0 Ev

= ⇒ m = 0 = ⇒ 0+0 Ev

• rule n Ev = ⇒ n+2 Ev

147

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 450

(41)

Proving properties of even numbers

Easy: 4 Ev

0 Ev = ⇒ 2 Ev = ⇒ 4 Ev Trickier: m Ev = ⇒ m+m Ev

Idea: induction on the length of the derivation of m Ev Better: induction on the structure of the derivation Two cases: m Ev is proved by

• rule 0 Ev

= ⇒ m = 0 = ⇒ 0+0 Ev

• rule n Ev = ⇒ n+2 Ev

= ⇒ m = n+2 and n+n Ev (ind. hyp.!)

147

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 451

(42)

Proving properties of even numbers

Easy: 4 Ev

0 Ev = ⇒ 2 Ev = ⇒ 4 Ev Trickier: m Ev = ⇒ m+m Ev

Idea: induction on the length of the derivation of m Ev Better: induction on the structure of the derivation Two cases: m Ev is proved by

• rule 0 Ev

= ⇒ m = 0 = ⇒ 0+0 Ev

• rule n Ev = ⇒ n+2 Ev

= ⇒ m = n+2 and n+n Ev (ind. hyp.!)

= ⇒ m+m = (n+2)+(n+2) = ((n+n)+2)+2 Ev

147

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 452

(43)

Rule induction for Ev

To prove

n Ev = ⇒ P n by rule induction on n Ev we must prove

148

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 453

(44)

Rule induction for Ev

To prove

n Ev = ⇒ P n by rule induction on n Ev we must prove

P 0

148

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 454

(45)

Rule induction for Ev

To prove

n Ev = ⇒ P n by rule induction on n Ev we must prove

P 0

P n = ⇒ P(n+2)

148

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 455

(46)

Rule induction for Ev

To prove

n Ev = ⇒ P n by rule induction on n Ev we must prove

P 0

P n = ⇒ P(n+2)

Rule Ev.induct:

[[ nEv; P 0;

n. P n = ⇒ P(n+2) ]] = ⇒ P n

148

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 456

(47)

Rule induction in general

Set S is defined inductively.

149

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 457

(48)

Rule induction in general

Set S is defined inductively.

To prove

x S = ⇒ P x by rule induction on x S

149

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 458

(49)

Rule induction in general

Set S is defined inductively.

To prove

x S = ⇒ P x by rule induction on x S

we must prove for every rule

[[ a 1 S; . . . ; a n S ]] = ⇒ a S

that P is preserved:

149

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 459

(50)

Rule induction in general

Set S is defined inductively.

To prove

x S = ⇒ P x by rule induction on x S

we must prove for every rule

[[ a 1 S; . . . ; a n S ]] = ⇒ a S

that P is preserved:

[[ P a 1 ; . . . ; P a n ]] = ⇒ P a

149

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 460

(51)

Rule induction in general

Set S is defined inductively.

To prove

x S = ⇒ P x by rule induction on x S

we must prove for every rule

[[ a 1 S; . . . ; a n S ]] = ⇒ a S

that P is preserved:

[[ P a 1 ; . . . ; P a n ]] = ⇒ P a

In Isabelle/HOL:

apply (induct rule: S.induct)

149

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 461

(52)

Demo: inductively defined sets

150

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 462

(53)

Inductive predicates

x SS x

151

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 463

(54)

Inductive predicates

x SS x Example:

inductive Ev :: nat bool

where

Ev 0 |

Ev n = ⇒ Ev (n + 2)

151

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 464

(55)

Inductive predicates

x SS x Example:

inductive Ev :: nat bool

where

Ev 0 |

Ev n = ⇒ Ev (n + 2) Comparison:

predicate: simpler syntax set: direct usage of etc

151

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 465

(56)

Inductive predicates

x SS x Example:

inductive Ev :: nat bool

where

Ev 0 |

Ev n = ⇒ Ev (n + 2) Comparison:

predicate: simpler syntax set: direct usage of etc

Inductive predicates can be of type τ 1 ⇒ ... τ n ⇒ bool

151

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 466

(57)

Automating it

152

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 467

(58)

simp and auto

simp rewriting and a bit of arithmetic

auto rewriting and a bit of arithmetic, logic & sets

153

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 468

(59)

simp and auto

simp rewriting and a bit of arithmetic

auto rewriting and a bit of arithmetic, logic & sets

• Show you where they got stuck

153

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 469

(60)

simp and auto

simp rewriting and a bit of arithmetic

auto rewriting and a bit of arithmetic, logic & sets

• Show you where they got stuck

• highly incomplete wrt logic

153

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 470

(61)

blast

• A complete (for FOL) tableaux calculus implementation

154

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 471

(62)

blast

• A complete (for FOL) tableaux calculus implementation

• Covers logic, sets, relations, . . .

154

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 472

(63)

blast

• A complete (for FOL) tableaux calculus implementation

• Covers logic, sets, relations, . . .

• Extensible with intro/elim rules

154

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 473

(64)

blast

• A complete (for FOL) tableaux calculus implementation

• Covers logic, sets, relations, . . .

• Extensible with intro/elim rules

• Almost no “=”

154

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 474

(65)

Demo: blast

155

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 475

(66)

Well founded relations

see IHT 6.4

� Well founded orderings: Induction

� Complete Lattices Fixpoints

� Knaster-Tarski Theorem

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 476

(67)

Fixpoints

Importance

� Inductive definitions of sets and relations

� Reminder: relations are sets in Isabelle/HOL

� E.g.: 0 ∈ even

� n ∈ even ==> n+2 ∈ even

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 477

(68)

Properties of Orderings and Functions

Definition 5.1. Monotone Function

Let D be a set with an ordering relation ≤ . A function f : D → D is called monotone, if x ≤ y −→ f (x ) ≤ f (y )

Remark

The inductive definition above induces a monotone function on sets with the subset relation as ordering:

� f_even :: nat set -> nat set

� f_even (A) = A ∪ { 0 } ∪ { n + 2 | n ∈ A }

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 478

(69)

Well-founded Orderings

� Partial-order ≤⊆ X × X well-founded iff

( ∀ Y ⊆ X : Y � = ∅ → ( ∃ y ∈ Y : y minimal in Y in respect of ≤ ))

� Quasi-order � well-founded iff strict part of � is well-founded.

� Initial segment: Y ⊆ X , left-closed i.e.

( ∀ y ∈ Y : ( ∀ x ∈ X : x � y → x ∈ Y ))

� Initial section of x: sec(x ) = { y : y < x }

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 479

(70)

Supremum

� Let (X , ≤ ) be a partial-order and Y ⊆ X

� S ⊆ X is a chain iff elements of S are linearly ordered through ≤ .

� y is an upper bound of Y iff

∀ y ∈ Y : y ≤ y

� Supremum: y is a supremum of Y iff y is an upper bound of Y and

∀ y ∈ X : ((y upper bound of Y ) → y ≤ y )

� Analog: lower bound, Infimum inf(Y )

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 480

(71)

CPO

� A Partial-order (D, � ) is a complete partial ordering (CPO) iff

∃ the smallest element ⊥ of D (with respect of �)

Each chain S has a supremum sup(S).

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 481

(72)

Example

Example 5.2. .

� ( P (X), ⊆ ) is CPO.

� (D, � ) is CPO with

D = X � Y : set of all the partial functions f with dom(f) ⊆ X and cod(f ) ⊆ Y .

Let f, g ∈ X � Y .

f � g iff dom(f) ⊆ dom(g ) ∧ ( ∀ x ∈ dom(f) : f (x) = g(x))

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 482

(73)

Monotonous, continuous

� (D, � ) , (E, � ) CPOs

� f : D → E monotonous iff

( ∀ d , d ∈ D : d � d → f (d ) � f (d ))

� f : D → E continuous iff f monotonous and

( ∀ S ⊆ D : S chain → f ( sup (S)) = sup (f (S)))

� X ⊆ D is admissible iff

( ∀ S ⊆ X : S chain → sup(S) ∈ X )

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 483

(74)

Fixpoint

� (D, � ) CPO, f : D → D

� d ∈ D fixpoint of f iff

f (d ) = d

� d ∈ D smallest fixpoint of f iff d fixpoint of f and ( ∀ d ∈ D : d fixpoint → d � d )

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 484

(75)

Fixpoint-Theorem

Theorem 5.3 (Fixpoint-Theorem:). (D, � ) CPO, f : D → D continuous, then f has a smallest fixpoint µf and

µf = sup{ f i ( ⊥ ) : i ∈ N}

Proof: (Sketch)

� sup { f i ( ⊥ ) : i ∈ N} fixpoint:

f (sup { f i ( ⊥ ) : i ∈ N} ) = sup { f i+1 ( ⊥ ) : i ∈ N}

(continuous)

= sup { sup { f i+1 ( ⊥ ) : i ∈ N} , ⊥}

= sup { f i ( ⊥ ) : i ∈ N}

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 485

(76)

Fixpoint-Theorem (Cont.)

Fixpoint-Theorem: (D, � ) CPO, f : D → D continuous, then f has a smallest fixpoint µf and

µf = sup { f i ( ⊥ ) : i ∈ N}

Proof: (Continuation)

� sup { f i ( ⊥ ) : i ∈ N} smallest fixpoint:

1. d

fixpoint of f 2. ⊥� d

3. f monotonous, d

FP: f ( ⊥ ) � f(d

) = d

4. Induction: ∀i ∈ N : f

i

(⊥) � f

i

(d

) = d

5. sup{f

i

( ⊥ ) : i ∈ N} � d

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 486

(77)

Induction over N

Induction’s principle:

( ∀ X ⊆ N : ((0 ∈ X ∧ ( ∀ x ∈ X : x ∈ X → x + 1 ∈ X ))) → X = N ) Correctness:

1. Let’s assume no, so ∃ X ⊆ N : N \ X � = ∅ 2. Let y be minimum in N \ X (with respect to <).

3. y � = 0

4. y − 1 ∈ X ∧ y �∈ X 5. Contradiction

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 487

(78)

Induction over N (Alternative)

Induction’s principle:

( ∀ X ⊆ N : ( ∀ x ∈ N : sec(x ) ⊆ X → x ∈ X ) → X = N ) Correctness:

1. Let’s assume no, so ∃ X ⊆ N : N \ X � = ∅ 2. Let y be minimum in N \ X (with respect to <).

3. sec(y ) ⊆ X , y �∈ X 4. Contradiction

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 488

(79)

Well-founded induction

Induction’s principle: Let (Z , ≤ ) be a well-founded partial order.

( ∀ X ⊆ Z : ( ∀ x ∈ Z : sec (x) ⊆ X → x ∈ X ) → X = Z ) Correctness:

1. Let’s assume no, so Z \ X � = ∅

2. Let z be a minimum in Z \ X (in respect of ≤ ).

3. sec(z ) ⊆ X , z �∈ X 4. Contradiction

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 489

(80)

FP-Induction: Proving properties of fixpoints

Induction’s principle: Let (D, � ) CPO, f : D → D continuous.

( ∀ X ⊆ D admissible : ( ⊥∈ X ∧ ( ∀ y : y ∈ X → f (y ) ∈ X )) → µf ∈ X ) Correctness: Let X ⊆ D admissible.

µf ∈ X ⇔ sup{ f i ( ⊥ ) : i ∈ N} ∈ X (FP-theorem)

⇐ ∀ i ∈ N : f i ( ⊥ ) ∈ X (X admissible )

⇐ ⊥∈ X ∧ ( ∀ n ∈ N : f n ( ⊥ ) ∈ X → f (f n ( ⊥ )) ∈ X ) (Induction N )

⇐ ⊥∈ X ∧ ( ∀ y ∈ X → f (y ) ∈ X ) (Ass.)

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 490

(81)

Problem

Exercise 5.4. Let (D, � ) CPO with

� X = Y = N

� D = X � Y : set all partial functions f with dom(f ) ⊆ X and cod(f ) ⊆ Y .

� Let f , g ∈ X � Y .

f � g iff dom(f ) ⊆ dom(g) ∧ ( ∀ x ∈ dom(f ) : f (x ) = g (x )) Consider

F : D → P ( N × N ) g �→

� { (0, 1) } g = ∅

{ (x , x · g(x − 1)) : x − 1 ∈ dom(g) } ∪ { (0, 1) } otherwise

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 491

(82)

Problem

Prove:

1. ∀ g ∈ D : F (g) ∈ D, i.e. F : D → D 2. F : D → D continuous

3. ∀ n ∈ N : µF (n) = n!

Note:

� µF can be understood as the semantics of a function’s definition function Fac(n : N ⊥ ) : N ⊥ = def

if n = 0 then 1 else n · Fac(n − 1)

� Keyword: ’ functions’ in Isabelle

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 492

(83)

Problem

Exercise 5.5. Prove: Let G = (V, E) be an infinite directed graph with

� G has finitely many roots (nodes without incoming edges).

� Each node has finite out-degree.

� Each node is reachable from a root.

There exists an infinite path that begins on a root.

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 493

(84)

Complete Lattices and Existence of Fixpoints

Definition 5.6. Complete Lattice

A partially ordered set (L, ≤ ) is a complete lattice if every subset A of L has both a greatest lower bound (the infimum, also called the meet) and a least upper bound (the supremum, also called the join) in (L, ≤ ). The meet is denoted by � A, and the join by � A.

Lemma 5.7. Complete lattices are non empty.

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

Consequence 5.9. The Knaster-Tarski theorem guarantees the existence of least and greatest fixpoints.

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 494

(85)

Proof of the Knaster-Tarski theorem

Reformulation

For a complete lattice (L, ≤ ) and a monotone function f : L → L on L, the set of all fixpoints of f is also a complete lattice (P, ≤ ), with:

� � P = �

{ x ∈ L | x ≤ f (x ) } as the greatest fixpoint of f

� � P = �

{ x ∈ L | f (x ) <= x } as the least fixpoint of f

Proof: We begin by showing that P has least and greatest elements.

Let D = { y ∈ L | y ≤ f (y ) } and x ∈ D. Then, because f is monotone, we have f (x) ≤ f (f (x )) , that is f (x ) ∈ D.

Now let u = � D. Then x ≤ u and f (x ) ≤ f (u), so x ≤ f (x) ≤ f (u).

Therefore f (u) is an upper bound of D, but u is the least upper bound, so u ≤ f (u), i.e. u ∈ D. Then f (u) ∈ D (from above) and f (u) ≤ u hence f (u) = u. Because every fixpoint is in D we have that u is the greatest fixpoint of f.

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 495

(86)

Proof of the Knaster-Tarski theorem (cont.)

The function f is monotone on the dual (complete) lattice (L op , ≥ ). As we have just proved, its greatest fixpoint there exists. It is the least one on L, so P has least and greatest elements, or more generally that every monotone function on a complete lattice has least and greatest fixpoints.

If a ∈ L and b ∈ L, a ≤ b, we’ll write [a, b] for the closed interval with bounds a and b : { x ∈ L | a ≤ x ≤ b }. The closed intervals are also complete lattices.

It remains to prove that P is complete lattice.

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 496

(87)

Proof of the Knaster-Tarski theorem (cont.)

Let W ⊂ P and w = � W . We construct a least upper bound of W in P. (The reasoning for the greatest lower bound is analogue.)

For every x ∈ W , we have x = f (x ) ≤ f (w) , i.e., f (w ) is an upper bound of W . Since w is the least upper bound of W , w ≤ f (w) . Furthermore, for y ∈ [w , � L], we have w ≤ f (w ) ≤ f (y ). Thus, f ([w, � L]) ⊂ [w , � L] , and we can consider f to be a monotone function on the complete lattice [w, � L]. Then,

v = �

{ x ∈ [w, � L] | f (x ) ≤ x } is the least fixpoint of f in [w, � L].

We show that v is the least upper bound of W in P.

a) v is in P.

b) v is an upper bound of W , because v ∈ [w, � L], i.e., w ≤ v . c) v is least. Let z be another upper bound of W in P. Then, w ≤ z, z ∈ [w, � L], z is fixpoint, hence v ≤ z

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 497

(88)

Lattices in Isabelle

Monotony and Fixpoints

� mono f ≡ ∀ AB. A ≤ B −→ f A ≤ f B (mono_def)

� Usually subset relation as ordering

� 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)

Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 498

Referenzen

ÄHNLICHE DOKUMENTE

A complete ordered is an ordered field K such that every nonempty subset of K which has an lower bound also has a greatest lower bound; recall Section 1.1 from the lecture.. a) Define

The (k, s)-SAT problem is the satisfiability problem restricted to instances where each clause has exactly k literals and every variable occurs at most s times.. The new upper bound

We consider in this work the problem of scheduling a set of jobs without preemption, where each job requires two resources: (1) a common resource, shared by all jobs, is required

The point of this is that when the light penetrates the layer of acrylic glass the light refraction on the surface of the photopaper is completely different from the effect when

We improve a lower bound of Heden, in a subcase, on the number of elements of the smallest occurring dimension in a vector space partition.. By geometric arguments we

subspace codes, network coding, constant dimension codes, subspace distance, integer linear programming, partial spreads.. The work was supported by the ICT COST Action IC1104

In this paper we give a linear algebraic proof of the known upper bound for the size of some special spherical s-distance sets.. This result generalizes Gerzon’s general upper bound

Cohomology Constructivism Relativization by internalization Internalizing higher direct images Flabby objects In the effective topos.. How not to