Recursive Functions on Lazy Lists via Domains and Topologies - - PowerPoint PPT Presentation

recursive functions on lazy lists via domains and
SMART_READER_LITE
LIVE PREVIEW

Recursive Functions on Lazy Lists via Domains and Topologies - - PowerPoint PPT Presentation

Recursive Functions on Lazy Lists via Domains and Topologies Andreas Lochbihler Johannes H olzl Institute of Information Security Institut f ur Informatik ETH Zurich, Switzerland TU M unchen, Germany ITP 2014 Running example:


slide-1
SLIDE 1

Recursive Functions on Lazy Lists via Domains and Topologies

Andreas Lochbihler

Institute of Information Security ETH Zurich, Switzerland

Johannes H¨

  • lzl

Institut f¨ ur Informatik TU M¨ unchen, Germany

ITP 2014

slide-2
SLIDE 2

Running example: filtering lazy lists

Task: Given a codatatype define a recursive function and prove properties.

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 2 / 11

slide-3
SLIDE 3

Running example: filtering lazy lists

Task: Given a codatatype α llist = [ ] | α · α llist define a recursive function lfilter P [ ] = [ ] lfilter P (x · xs) = (if P x then x · lfilter P xs else lfilter P xs) and prove properties. lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 2 / 11

slide-4
SLIDE 4

Running example: filtering lazy lists

Task: Given a codatatype α llist = [ ] | α · α llist finite and infinite lists define a recursive function lfilter P [ ] = [ ] lfilter P (x · xs) = (if P x then x · lfilter P xs else lfilter P xs) and prove properties. lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 2 / 11

slide-5
SLIDE 5

Running example: filtering lazy lists

Task: Given a codatatype α llist = [ ] | α · α llist finite and infinite lists define a recursive function lfilter P [ ] = [ ] lfilter P (x · xs) = (if P x then x · lfilter P xs else lfilter P xs) and prove properties. lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs Usual definition principles

  • well-founded recursion
  • guarded/primitive corecursion

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 2 / 11

slide-6
SLIDE 6

Running example: filtering lazy lists

Task: Given a codatatype α llist = [ ] | α · α llist finite and infinite lists define a recursive function lfilter P [ ] = [ ] lfilter P (x · xs) = (if P x then x · lfilter P xs else lfilter P xs) and prove properties. lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs Usual definition principles

  • well-founded recursion
  • guarded/primitive corecursion

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 2 / 11

slide-7
SLIDE 7

Running example: filtering lazy lists

Task: Given a codatatype α llist = [ ] | α · α llist finite and infinite lists define a recursive function lfilter P [ ] = [ ] lfilter P (x · xs) = (if P x then x · lfilter P xs else lfilter P xs) and prove properties. lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs Usual definition principles

  • well-founded recursion
  • guarded/primitive corecursion

guarded

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 2 / 11

slide-8
SLIDE 8

Running example: filtering lazy lists

Task: Given a codatatype α llist = [ ] | α · α llist finite and infinite lists define a recursive function lfilter P [ ] = [ ] lfilter P (x · xs) = (if P x then x · lfilter P xs else lfilter P xs) and prove properties. lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs Usual definition principles

  • well-founded recursion
  • guarded/primitive corecursion

guarded unguarded

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 2 / 11

slide-9
SLIDE 9

Running example: filtering lazy lists

Task: Given a codatatype α llist = [ ] | α · α llist finite and infinite lists define a recursive function lfilter P [ ] = [ ] lfilter P (x · xs) = (if P x then x · lfilter P xs else lfilter P xs) and prove properties. lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs Usual definition principles

  • well-founded recursion
  • guarded/primitive corecursion

guarded unguarded lfilter is underspecified: lfilter (≤ 0) (1 · [1, 1, 1, . . .]) = lfilter (≤ 0) [1, 1, 1, . . .]

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 2 / 11

slide-10
SLIDE 10

Beyond well-founded and guarded corecursion

lfilter P [ ] = [ ] lfilter P (x · xs) = (if P x then x · lfilter P xs else lfilter P xs) lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs Previous approaches:

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 3 / 11

slide-11
SLIDE 11

Beyond well-founded and guarded corecursion

lfilter P [ ] = [ ] lfilter P (x · xs) = (if P x then x · lfilter P xs else lfilter P xs) lfinite xs ∨ (∀n. ∃x ∈ lset (ldrop n xs). P x ∧ Q x) − → lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs Previous approaches: Partiality leave unspecified for infinite lists w/o satisfying elements close to specification properties need preconditions no proof principles

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 3 / 11

slide-12
SLIDE 12

Beyond well-founded and guarded corecursion

lfilter P [ ] = [ ] lfilter P (x · xs) = (if P x then x · lfilter P xs else lfilter P xs) lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs Previous approaches: Partiality leave unspecified for infinite lists w/o satisfying elements close to specification properties need preconditions no proof principles Search function check whether there are more elements

  • if ¬ find P xs then [ ] else

total function, no preconditions additional lemmas about search function necessary ad hoc solution

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 3 / 11

slide-13
SLIDE 13

Two views on lfilter

lfilter :: (α ⇒ bool) ⇒ α llist ⇒ α llist

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 4 / 11

slide-14
SLIDE 14

Two views on lfilter

lfilter :: (α ⇒ bool) ⇒ α llist ⇒ α llist

  • 1. produces a list corecursively
  • lfilter :: β ⇒ α llist
  • find chain-complete partial
  • rder on α llist
  • take the least fixpoint for lfilter

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 4 / 11

slide-15
SLIDE 15

Two views on lfilter

lfilter :: (α ⇒ bool) ⇒ α llist ⇒ α llist

  • 1. produces a list corecursively
  • lfilter :: β ⇒ α llist
  • find chain-complete partial
  • rder on α llist
  • take the least fixpoint for lfilter

proof principles domain theory fixpoint induction structural induction

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 4 / 11

slide-16
SLIDE 16

Two views on lfilter

lfilter :: (α ⇒ bool) ⇒ α llist ⇒ α llist

  • 1. produces a list corecursively
  • lfilter :: β ⇒ α llist
  • find chain-complete partial
  • rder on α llist
  • take the least fixpoint for lfilter
  • 2. consumes a list recursively
  • lfilter :: α llist ⇒ β
  • find topology on α llist
  • define lfilter on finite lists

by well-founded recursion

  • take the limit for infinite lists

proof principles domain theory fixpoint induction structural induction

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 4 / 11

slide-17
SLIDE 17

Two views on lfilter

lfilter :: (α ⇒ bool) ⇒ α llist ⇒ α llist

  • 1. produces a list corecursively
  • lfilter :: β ⇒ α llist
  • find chain-complete partial
  • rder on α llist
  • take the least fixpoint for lfilter
  • 2. consumes a list recursively
  • lfilter :: α llist ⇒ β
  • find topology on α llist
  • define lfilter on finite lists

by well-founded recursion

  • take the limit for infinite lists

proof principles domain theory fixpoint induction structural induction topology convergence on closed sets uniqueness of limits

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 4 / 11

slide-18
SLIDE 18

Proof principles pay off

Isabelle proofs of lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs

Paulson’s Structural induction Fixpoint induction Continuous extension

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 5 / 11

slide-19
SLIDE 19

The producer view: least fixpoints

  • prefix order ⊑ defined coinductively
  • least upper bound Y defined by primitive corecursion

(⊑, ) forms a chain-complete partial order (CCPO) with ⊥ = [ ]

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 6 / 11

slide-20
SLIDE 20

The producer view: least fixpoints

  • prefix order ⊑ defined coinductively
  • least upper bound Y defined by primitive corecursion

(⊑, ) forms a chain-complete partial order (CCPO) with ⊥ = [ ]

  • . . .

A A

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 6 / 11

slide-21
SLIDE 21

The producer view: least fixpoints

  • prefix order ⊑ defined coinductively
  • least upper bound Y defined by primitive corecursion

(⊑, ) forms a chain-complete partial order (CCPO) with ⊥ = [ ]

  • . . .

A A ⊑ ⊑ ⊑ ⊑ ⊑ ⊑

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 6 / 11

slide-22
SLIDE 22

The producer view: least fixpoints

  • prefix order ⊑ defined coinductively
  • least upper bound Y defined by primitive corecursion

(⊑, ) forms a chain-complete partial order (CCPO) with ⊥ = [ ]

  • . . .

A A ⊑ ⊑ ⊑ ⊑ ⊑ ⊑

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 6 / 11

slide-23
SLIDE 23

The producer view: least fixpoints

  • prefix order ⊑ defined coinductively
  • least upper bound Y defined by primitive corecursion

(⊑, ) forms a chain-complete partial order (CCPO) with ⊥ = [ ]

  • . . .

A A ⊑ ⊑ ⊑ ⊑ ⊑ ⊑

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 6 / 11

slide-24
SLIDE 24

The producer view: least fixpoints

  • prefix order ⊑ defined coinductively
  • least upper bound Y defined by primitive corecursion

(⊑, ) forms a chain-complete partial order (CCPO) with ⊥ = [ ]

  • . . .

A A ⊑ ⊑ ⊑ ⊑ ⊑ ⊑

  • lift (⊑, ) point-wise to function space β ⇒ α llist

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 6 / 11

slide-25
SLIDE 25

The producer view: least fixpoints

  • prefix order ⊑ defined coinductively
  • least upper bound Y defined by primitive corecursion

(⊑, ) forms a chain-complete partial order (CCPO) with ⊥ = [ ]

  • . . .

A A ⊑ ⊑ ⊑ ⊑ ⊑ ⊑

  • lift (⊑, ) point-wise to function space β ⇒ α llist

Knaster-Tarski theorem: If f on a ccpo is monotone, then f has a least fixpoint.

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 6 / 11

slide-26
SLIDE 26

The producer view: least fixpoints

  • prefix order ⊑ defined coinductively
  • least upper bound Y defined by primitive corecursion

(⊑, ) forms a chain-complete partial order (CCPO) with ⊥ = [ ]

  • . . .

A A ⊑ ⊑ ⊑ ⊑ ⊑ ⊑

  • lift (⊑, ) point-wise to function space β ⇒ α llist

Knaster-Tarski theorem: If f on a ccpo is monotone, then f has a least fixpoint. partial-function (llist) lfilter :: (α ⇒ bool) ⇒ α llist ⇒ α llist where lfilter P xs = (case xs of [ ] ⇒ [ ] | x · xs ⇒ if P x then x · lfilter P xs else lfilter P xs)

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 6 / 11

slide-27
SLIDE 27

The producer view: least fixpoints

  • prefix order ⊑ defined coinductively
  • least upper bound Y defined by primitive corecursion

(⊑, ) forms a chain-complete partial order (CCPO) with ⊥ = [ ]

  • . . .

A A ⊑ ⊑ ⊑ ⊑ ⊑ ⊑

  • lift (⊑, ) point-wise to function space β ⇒ α llist

Knaster-Tarski theorem: If f on a ccpo is monotone, then f has a least fixpoint. partial-function (llist) lfilter :: (α ⇒ bool) ⇒ α llist ⇒ α llist where lfilter P xs = (case xs of [ ] ⇒ [ ] | x · xs ⇒ if P x then x · lfilter P xs else lfilter P xs) Light-weight domain theory [ ] represents “undefined”, no additional values in α llist full function space ⇒, no continuity restrictions less automation less expressive (no nested or higher-order recursion)

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 6 / 11

slide-28
SLIDE 28

The producer view: induction proofs

  • structural induction

adm Q Q [ ] ∀x xs. lfinite xs ∧ Q xs − → Q (x · xs) Q xs

  • fixpoint induction rule generated for lfilter

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 7 / 11

slide-29
SLIDE 29

The producer view: induction proofs

  • structural induction

adm Q Q [ ] ∀x xs. lfinite xs ∧ Q xs − → Q (x · xs) Q xs

  • fixpoint induction rule generated for lfilter

Induction is sound only for admissible statements Q

  • . . .

⊑ ⊑ ⊑ ⊑ ⊑

A A

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 7 / 11

slide-30
SLIDE 30

The producer view: induction proofs

  • structural induction

adm Q Q [ ] ∀x xs. lfinite xs ∧ Q xs − → Q (x · xs) Q xs

  • fixpoint induction rule generated for lfilter

Induction is sound only for admissible statements Q

  • . . .

⊑ ⊑ ⊑ ⊑ ⊑

A A Q       Q ( )

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 7 / 11

slide-31
SLIDE 31

The producer view: induction proofs

  • structural induction

adm Q Q [ ] ∀x xs. lfinite xs ∧ Q xs − → Q (x · xs) Q xs

  • fixpoint induction rule generated for lfilter

Induction is sound only for admissible statements Q

  • . . .

⊑ ⊑ ⊑ ⊑ ⊑

A A Q       Q ( ) lemma lfilter P (lfilter Q xs ) = lfilter (λx. P x ∧ Q x) xs by(induction xs) simp all

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 7 / 11

slide-32
SLIDE 32

The producer view: induction proofs

  • structural induction

adm Q Q [ ] ∀x xs. lfinite xs ∧ Q xs − → Q (x · xs) Q xs

  • fixpoint induction rule generated for lfilter

Induction is sound only for admissible statements Q

  • . . .

⊑ ⊑ ⊑ ⊑ ⊑

A A Q       Q ( ) proof automation via syntactic decomposition rules for admissibility adm (λxs. lfilter P (lfilter Q xs ) = lfilter (λx. P x ∧ Q x) xs )

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 7 / 11

slide-33
SLIDE 33

The producer view: induction proofs

  • structural induction

adm Q Q [ ] ∀x xs. lfinite xs ∧ Q xs − → Q (x · xs) Q xs

  • fixpoint induction rule generated for lfilter

Induction is sound only for admissible statements Q

  • . . .

⊑ ⊑ ⊑ ⊑ ⊑

A A Q       Q ( ) proof automation via syntactic decomposition rules for admissibility adm (λxs. lfilter P (lfilter Q xs ) = lfilter (λx. P x ∧ Q x) xs ) continuous contexts atomic predicate

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 7 / 11

slide-34
SLIDE 34

The consumer view: continuous extensions

datatype α list = [] | α · α list

  • 1. Define filter recursively

filter :: (α ⇒ bool) ⇒ α list ⇒ α list

  • n finite lists.

infinite finite fi l t e r P

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 8 / 11

slide-35
SLIDE 35

The consumer view: continuous extensions

datatype α list = [] | α · α list

  • 1. Define filter recursively

filter :: (α ⇒ bool) ⇒ α list ⇒ α list

  • n finite lists.

lfilter P xs = Lim (filter P) xs

  • 2. Take the limit.

infinite finite fi l t e r P

Lim

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 8 / 11

slide-36
SLIDE 36

The consumer view: continuous extensions

datatype α list = [] | α · α list

  • 1. Define filter recursively

filter :: (α ⇒ bool) ⇒ α list ⇒ α list

  • n finite lists.

lfilter P xs = Lim (filter P) xs

  • 2. Take the limit.

infinite finite fi l t e r P

Lim

introduce CCPO topology define the open sets S A

  • . . .

⊑ ⊑ ⊑ ⊑ ⊑

A

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 8 / 11

slide-37
SLIDE 37

The consumer view: continuous extensions

datatype α list = [] | α · α list

  • 1. Define filter recursively

filter :: (α ⇒ bool) ⇒ α list ⇒ α list

  • n finite lists.

lfilter P xs = Lim (filter P) xs

  • 2. Take the limit.

infinite finite fi l t e r P

Lim

introduce CCPO topology define the open sets

  • pen S

A

  • . . .

⊑ ⊑ ⊑ ⊑ ⊑

A non-empty overlap

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 8 / 11

slide-38
SLIDE 38

The consumer view: continuous extensions

datatype α list = [] | α · α list

  • 1. Define filter recursively

filter :: (α ⇒ bool) ⇒ α list ⇒ α list

  • n finite lists.

lfilter P xs = Lim (filter P) xs

  • 2. Take the limit.

infinite finite fi l t e r P

Lim

introduce CCPO topology define the open sets

  • pen S

A

  • . . .

⊑ ⊑ ⊑ ⊑ ⊑

A non-empty overlap Properties of a CCPO topology limits are unique finite elements are discrete, i.e., open {xs}

  • not the Scott topology!

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 8 / 11

slide-39
SLIDE 39

The consumer view: proving

  • 1. Prove that filter P is continuous!

follows from monotonicity of filter

  • 2. Proof rule convergence on a closed set (specialised for α llist):

closed {xs | Q xs} ∀ys. lfinite ys ∧ ys ⊑ xs − → Q ys Q xs lemma lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs by (rule converge closed[of xs]) (auto intro!: closed eq isCont lfilter )

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 9 / 11

slide-40
SLIDE 40

The consumer view: proving

  • 1. Prove that filter P is continuous!

follows from monotonicity of filter

  • 2. Proof rule convergence on a closed set (specialised for α llist):

closed {xs | Q xs} ∀ys. lfinite ys ∧ ys ⊑ xs − → Q ys Q xs lemma lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs by (rule converge closed[of xs]) (auto intro!: closed eq isCont lfilter ) decomposition rules for closedness

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 9 / 11

slide-41
SLIDE 41

Summary

Comparison least fixpoint continuous extension ccpo

  • n result type
  • n parameter type

monotonicity

  • f the functional
  • f the function

proof principles structural induction = convergence on a closed set fixpoint induction Available in the AFP entry Coinductive

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 10 / 11

slide-42
SLIDE 42

Summary

Comparison least fixpoint continuous extension ccpo

  • n result type
  • n parameter type

monotonicity

  • f the functional
  • f the function

proof principles structural induction = convergence on a closed set fixpoint induction Available in the AFP entry Coinductive Which codatatypes can be turned into useful ccpos? extended naturals enat = 0 | eSuc enat n-ary trees α tree = Leaf | Node α (α tree) (α tree)

  • finite

truncations streams α stream = Stream α (α stream) no finite elements

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 10 / 11

slide-43
SLIDE 43

Two views on lfilter

lfilter :: (α ⇒ bool) ⇒ α llist ⇒ α llist

  • 1. produces a list corecursively
  • lfilter :: β ⇒ α llist
  • find chain-complete partial
  • rder on α llist
  • take the least fixpoint for lfilter
  • 2. consumes a list recursively
  • lfilter :: α llist ⇒ β
  • find topology on α llist
  • define lfilter on finite lists

by well-founded recursion

  • take the limit for infinite lists

proof principles domain theory fixpoint induction structural induction topology convergence on closed sets uniqueness of limits

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 4 / 11

Proof principles pay off

Isabelle proofs of lfilter P (lfilter Q xs) = lfilter (λx. P x ∧ Q x) xs

Paulson’s Structural induction Fixpoint induction Continuous extension

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 5 / 11

The consumer view: continuous extensions

datatype α list = [] | α · α list

  • 1. Define filter recursively

filter :: (α ⇒ bool) ⇒ α list ⇒ α list

  • n finite lists.

lfilter P xs = Lim (filter P) xs

  • 2. Take the limit.

infinite finite filter P

Lim

introduce CCPO topology define the open sets

  • pen S

A

  • . . .

⊑ ⊑ ⊑ ⊑ ⊑

A non-empty overlap

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 8 / 11

The producer view: least fixpoints

  • prefix order ⊑ defined coinductively
  • least upper bound Y defined by primitive corecursion

(⊑, ) forms a chain-complete partial order (CCPO) with ⊥ = [ ]

  • . . .

A A ⊑ ⊑ ⊑ ⊑ ⊑ ⊑

  • lift (⊑, ) point-wise to function space β ⇒ α llist

Knaster-Tarski theorem: If f on a ccpo is monotone, then f has a least fixpoint. partial-function (llist) lfilter :: (α ⇒ bool) ⇒ α llist ⇒ α llist where lfilter P xs = (case xs of [ ] ⇒ [ ] | x · xs ⇒ if P x then x · lfilter P xs else lfilter P xs)

Lochbihler (ETHZ), H¨

  • lzl (TUM)

Recursive functions on lazy lists ITP 2014 6 / 11