Fix-Points of Recursive Functions

Fix-Points of Recursive Functions

Domain Theory I Domain Theory I Wolfgang Schreiner Research Institute for Symb olic Computation RISCLinz Johannes Kepler University A Linz Austria WolfgangSchreinerriscunilinzacat httpwwwriscunilinzacatp eopleschreine Wolfgang Schreiner RISCLinz Domain Theory I Semantics of Lo ops B Bo oleanexpression C Command C j while B do C j Cwhile B do C s BBs Cwhile B do CCCs s Problem meaning of a syntax phrase may b e dened only in terms of its proper subparts Cwhile B do C w where w Store Store ? ? sBBs w CCs s w = Recursion in syntax exchanged for recursion in function notation Wolfgang Schreiner Domain Theory I Recursive Function Denitions Function Denition q = nn equals zero one [] q (n plus one) Possible Function Graphs fzero oneg = fzero one one two g fzero one one six two six g fzero one one k two k g Several functions satisfy sp ecication which one shall we cho ose Wolfgang Schreiner Domain Theory I Least Fixed Point Semantics Theory that establishes meaning of recursive sp ecications Guarantees that every sp ecication has a function satisfying it Provides means for cho osing the b est function out of the set of p ossibilities Ensures that the selected function cor resp onds to the conventional op erational treatment of recursion Argument is mapp ed to dened answer i simplication of the sp ecication yields a result in a nite numb er of recursive invo cations Wolfgang Schreiner Domain Theory I The Factorial Function facn n equals zero one n times facn minus one Only one function satises sp ecication graphfactorial fzero one one one two two three six i i! g Wolfgang Schreiner Domain Theory I Simplication facthree three equals zero one three times facthree minus one three times facthree minus one three times factwo three times two equals zero one two times factwo minus one three times two times facone three times two times one equals zero one one times facone minus one three times two times one times faczero three times two times one times zero equals zero one zero times faczero minus one three times two times one times one six Wolfgang Schreiner Domain Theory I Partial Functions Answer is produced in a nite numb er of unfolding steps Idea place limit on numb er of unfoldings and investigate resulting graphs zero fg one fzero oneg two fzero one one oneg i + 1 fzero one one one i i!g Graph at stage i denes function fac i Consistency with each other graph(fac ) graph(fac ) i i+1 Consistency with ultimate solution graph(fac ) graph(factorial ) i Consequently S 1 graph(fac ) graph(factorial ) i i=0 Wolfgang Schreiner Domain Theory I Partial Functions Any result is computed in a nite numb er of unfoldings (a b) graph(factorial ) (a b) graph(fac ) for some i i Consequently S 1 graph(factorial ) graph(fac ) i i=0 Thus S 1 graph(factorial ) = graph(fac ) i i=0 Factorial function can b e totally understo o d in terms of the nite subfunctions fac i Wolfgang Schreiner Domain Theory I Partial Functions Representations of subfunctions fac n 0 fac n n equals zero one i+1 n times fac n minus one i Each denition is nonrecursive Recursive sp ecication can b e understo o d in terms of a family of nonrecursive ones Common format can b e extracted Functional F F Nat Nat Nat Nat ? ? F f n n equals zero one n times f n minus one Each subfunction is an instance of the func tional Wolfgang Schreiner Domain Theory I Functional and Fixed Point Partial functions i fac Ffac F i+1 i := (n) Function graph S 1 i graph(factorial ) = graph(F ()) i=0 Fixed p oint property graphFfactorial graphfactorial Ffactorial factorial The function factorial is a xed p oint of the functional F Wolfgang Schreiner Domain Theory I q Function Q = q nn equals zero one [] q (n plus one) 0 Q (n) 0 graphQ fg 1 Q nn equals zero one [] (n)(n plus one) nn equals zero one [] 1 graphQ fzero oneg 2 1 Q QQ nn equals zero one [] ((n plus one) equals zero one [] ) 2 graphQ fzero oneg Wolfgang Schreiner Domain Theory I q Function Convergence has o ccured i graphQ fzero oneg i 1 Resulting graph S i 1 graph(Q ()) = f(zero one)g i=0 Fix p oint property Q(qlimit) = qlimit Still many solutions p ossible graphq k f zero one one k i k g Least xed p oint property graphqlimit graphq k The function qlimit is the least xed p oint of the functional Q Wolfgang Schreiner Domain Theory I Recursive Sp ecications The meaning of a recursive sp ecication f = F (f ) is taken to b e xF the least xed p oint of the functional denoted by F S 1 i graph(x F ) = graph(F ()) i=0 The domain D of F must b e a p ointed cp o partial ordering on D every chain in D has a least upp er b ound in D D has a least element F must b e continuous Preserves limits of chains Semantic domains are cp os and their op er ations are continuous Pointed cp os are created from primitive domains and union domains by lifting Wolfgang Schreiner Domain Theory I Factorial Function F f n n equals zero one n times fn minus one Simplication rule x F Fx F x Fthree F x Fthree f n n equals zero one n times fn minus onex Fthree n n equals zero one n times x Fn minus onethree three equals zero one three times x Fthree minus one three times x Ftwo three times F x Ftwo three times two times x Ftwo Fixed p oint property justies rec unfolding Wolfgang Schreiner Domain Theory I Double Recursion g n n equals zero one gn minus one plus gn minus one minus one 0 graphF fg 1 graphF fzero oneg 1 graphF fzero one one oneg 2 graphF fzero one one one two oneg i+1 graphF fzero one i oneg x F n one Stepwise construction of graph yields insight Wolfgang Schreiner Domain Theory I Simultaneous Denitions f g Nat Nat ? f x x equals zero gzero fgx minus one plus two g y y equals zero zero y times fy minus one T Nat Nat ? F T T T T F fg 0 F fg fg 1 F fg fzero zerog 2 F fzerozerog fzero zerog 5 F fzerozero one two two twog fzero zero one zero two four three sixg i 5 F F i 5 xF fg Wolfgang Schreiner Domain Theory I While Lo ops Cwhile B do C xf s BBs f CCs s Function Store Store ? ? Example Cwhile A do AA BB x F where F f s test s f adjust s s test BA adjust CAA BB Partial function graphs Each pair in graph shows store prior to lo op entry and after lo op exit i+1 Each graph F () contains those pairs whose input stores nish processing in at most i iterations Wolfgang Schreiner Domain Theory I Example 0 graphF fg 1 graphF f f Azero Bzero g f Azero Bzero g f Azero Bfour g f Azero Bfour g g 2 graphF f f Azero Bzero g f Azero Bzero g f Azero Bfour g f Azero Bfour g f Aone Bzero g f Azero Bone g f Aone Bfour g f Azero Bve g g Wolfgang Schreiner Domain Theory I While Lo ops Representation by nite subfunctions F Cwhile B do C f s sBBs s sBBs BBCCs CCs s sBBs BBCCs BBCCCCs CCCCs CCs s g F f Cdiverge Cif B then diverge else skip Cif B then C if B then diverge else skip else skip Cif B then C if B then C if B then diverge else skip else skip else skip g Lo op iteration can b e understo o d by sequence of noniterating programs Wolfgang Schreiner Domain Theory I Reasoning ab out Least Fixed Points Fixed Point Induction Principle To prove P (x F ) it suces to prove P () P (d) P (F (d)) for arbitrary d D for p ointed cp o D continuous functional F : D D and inclusive predicate P : D B Inclusiveness of predicates If predicate holds for every element of chain it also holds for its least upp er b ound All universally quantied combinations of conjunctionsdisjunctions that use only v over functional expressions are inclusive Mainly useful for showing equivalences of pro gram constructs Wolfgang Schreiner Domain Theory I Reasoning ab out Least Fixed Points Crep eat C until B xf s 0 0 0 0 let s CCs in BBs s f s ? CC while B do C = Crep eat C until B Pro of P (f g ) = sf (C[[C]]s) = (g s) P holds obviously Prove P (F (f ) G(g )) s B Bs f CCs s F = (f 0 0 s let s CCs in BBs G = (f 0 0 s f s a F f CC Gg b s = 0 0 i CCs = F f let s in BBs 0 0 s g s Gg ii CCs = s = F f s B Bs 0 0 0 f CCs s BBs s f CCs 0 0 0 0 0 BBs s f g s Gg s 0 0 0 Wolfgang Schreiner .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    21 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us