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
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:
Institute of Information Security ETH Zurich, Switzerland
Institut f¨ ur Informatik TU M¨ unchen, Germany
ITP 2014
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 2 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 2 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 2 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 2 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 2 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 2 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 2 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 2 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 3 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 3 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 3 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 4 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 4 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 4 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 4 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 4 / 11
Paulson’s Structural induction Fixpoint induction Continuous extension
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 5 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 6 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 6 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 6 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 6 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 6 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 6 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 6 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 6 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 6 / 11
adm Q Q [ ] ∀x xs. lfinite xs ∧ Q xs − → Q (x · xs) Q xs
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 7 / 11
adm Q Q [ ] ∀x xs. lfinite xs ∧ Q xs − → Q (x · xs) Q xs
Induction is sound only for admissible statements Q
⊑ ⊑ ⊑ ⊑ ⊑
A A
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 7 / 11
adm Q Q [ ] ∀x xs. lfinite xs ∧ Q xs − → Q (x · xs) Q xs
Induction is sound only for admissible statements Q
⊑ ⊑ ⊑ ⊑ ⊑
A A Q Q ( )
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 7 / 11
adm Q Q [ ] ∀x xs. lfinite xs ∧ Q xs − → Q (x · xs) Q xs
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¨
Recursive functions on lazy lists ITP 2014 7 / 11
adm Q Q [ ] ∀x xs. lfinite xs ∧ Q xs − → Q (x · xs) Q xs
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¨
Recursive functions on lazy lists ITP 2014 7 / 11
adm Q Q [ ] ∀x xs. lfinite xs ∧ Q xs − → Q (x · xs) Q xs
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¨
Recursive functions on lazy lists ITP 2014 7 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 8 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 8 / 11
⊑ ⊑ ⊑ ⊑ ⊑
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 8 / 11
⊑ ⊑ ⊑ ⊑ ⊑
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 8 / 11
⊑ ⊑ ⊑ ⊑ ⊑
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 8 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 9 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 9 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 10 / 11
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 10 / 11
Two views on lfilter
lfilter :: (α ⇒ bool) ⇒ α llist ⇒ α llist
by well-founded recursion
proof principles domain theory fixpoint induction structural induction topology convergence on closed sets uniqueness of limits
Lochbihler (ETHZ), H¨
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¨
Recursive functions on lazy lists ITP 2014 5 / 11
The consumer view: continuous extensions
datatype α list = [] | α · α list
filter :: (α ⇒ bool) ⇒ α list ⇒ α list
lfilter P xs = Lim (filter P) xs
infinite finite filter P
Lim
introduce CCPO topology define the open sets
A
⊑ ⊑ ⊑ ⊑ ⊑
A non-empty overlap
Lochbihler (ETHZ), H¨
Recursive functions on lazy lists ITP 2014 8 / 11
The producer view: least fixpoints
(⊑, ) forms a chain-complete partial order (CCPO) with ⊥ = [ ]
A A ⊑ ⊑ ⊑ ⊑ ⊑ ⊑
⊒
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¨
Recursive functions on lazy lists ITP 2014 6 / 11