lecture 4
play

Lecture 4 Signal Flow Graphs and recurrence relations Plan - PowerPoint PPT Presentation

Lecture 4 Signal Flow Graphs and recurrence relations Plan Fibonaccis rabbits and sustainable rabbit farming Signal Flow Graphs Generating functions IH Q[x] Operational semantics Solving sustainable rabbit farming


  1. Lecture 4 Signal Flow Graphs and recurrence relations

  2. Plan • Fibonacci’s rabbits and sustainable rabbit farming • Signal Flow Graphs • Generating functions • IH Q[x] • Operational semantics • Solving sustainable rabbit farming

  3. Fibonacci 1 (C 1170 - C 1250) 2 3 A certain man had one pair of rabbits together in a certain enclosed place, and one wishes to know how many are created from the pair in one 5 year when it is the nature of them in a single month to bear another pair, 8 and in the second month those born to bear also. 13 21 You can indeed see in the margin how we operated, namely that we added the first number to the second, namely the 1 to the 2, and the 34 second to the third, and the third to the fourth, and the fourth to the fifth, 55 and thus one after another until we added the tenth to the eleventh, namely the 144 to the 233, and we had the above written sum of rabbits, 89 namely 377, and thus you can in order find it for an unending number of 144 months. 233 377 (extract from Liber Abaci, chapter 12, translated from Latin by Lawrence Sigler)

  4. The Fibonacci sequence 1, 2, 3, 5, 8… in modern presentations often given as 1, 1, 2, 3, 5, … or 0, 1, 1, 2, 3, … is an example of a recurrence relation . All three satisfy F n+2 = F n+1 + F n

  5. Coding Fibonacci Natural to generalise Fibonacci’s rabbit breeding to function of type ffib: int list -> int list # ffib [1;0;0;0;0;0;0;0];; - : int list = [1; 2; 3; 5; 8; 13; 21; 34] # ffib [1;1;1;1;1;1;1;1];; - : int list = [1; 3; 6; 11; 19; 32; 53; 87] # ffib [1;1;-3;1;-2;-4;1];; - : int list = [1; 3; 2; 3; 4; 1; 2]

  6. Sustainable rabbit farming problem • Suppose we want a sustainable rabbit farm, keeping four pairs of rabbits at all times • is it possible? • if so, how many pairs of rabbits must we add/ remove and in which months? • More generally, can we obtain a solution for any (possibly variable) number of rabbits in each month?

  7. Achieving sustainable rabbit breeding ffib: int list -> int list To obtain solution, one could try to compute the inverse bfib: int list -> int list bfib [4;4;4;4;4;4;4;4;4;4;4;4];;

  8. Plan • Fibonacci’s rabbits and sustainable rabbit farming • Signal Flow Graphs • Generating functions • IH Q[x] • Operational semantics • Solving sustainable rabbit farming

  9. Claude Shannon, The theory and design of linear differential equation machines , report to National Defence Research Council, January 1942 • This report deals with the general theory of machines constructed from the following five types of mechanical elements. • Integrators • Adders or differential gears • Gear boxes • Shaft junctions • Shafts

  10. Example execution 1 3 2 6 2 2 11 1 3 x 1 3 5 15 5 0 1 3 0 5 1 3 Input Output x x 2 1 1 0 0 3 1 0 3 11 The circuit defines a function of type int list -> int list note: if I keep pumping in zeros, then eventually all registers will get zeroed out and the output will stabilise at zero —- is this the case for every circuit?

  11. Feedback! 1 1 0 1 0 1 0 1 0 1 0 1 x . . . . . . 0 1 1 1 1 1 . . .

  12. Example - Fibonacci x 0 1 1 1 2 0 0 3 0 0 0 x 5 0 0 8 0 1 2 3 x x 5 0 0 8 1 0 2 1 3 2 5 3 5 8

  13. A little optimisation 1 x x = x x x These always hold the same value x x ALGEBRAIC MANIPULATION, DIRECTLY ON THE CIRCUIT DIAGRAM!

  14. A little optimisation 2 x x x = x x

  15. Behaviours = linear subspaces ffib: int list -> int list • Behaviours are closed under • (pointwise) addition • (pointwise) scalar multiplication

  16. Plan • Fibonacci’s rabbits and sustainable rabbit farming • Signal Flow Graphs • Generating functions • IH Q[x] • Operational semantics • Solving sustainable rabbit farming

  17. Polynomial Zoo • Ring of polynomials Q [x] • → Field of polynomial fractions Q (x) • Ring of formal power series Q [[x]] • → Field of Laurent power series Q ((x)) • injective ring hom. Q [x] → Q [[x]] • → (injective) field hom. Q (x) → Q ((x))

  18. Generatingfunctionology (see famous book by H. Wilf) Spec F 1 = 2 F n +2 = F n +1 + F n F 0 = 1 ∞ X F ( x ) = F n x n Define n =0 ∞ ∞ ∞ ∞ ∞ X X F n +2 x n = F n +1 x n + X X X F ( x ) = F n +2 x n − F n +1 x n F n x n n =0 n =0 n =0 n =0 n =0 ∞ ∞ F ( x ) = F ( x ) − 2 x − 1 − F ( x ) − 1 F n x n = F ( x ) − 2 x − 1 X X x 2 ( F n +2 x n ) = x 2 x n =0 n =2 1 + x ∞ ∞ F n x n = F ( x ) − 1 X X x ( F n +1 x n ) = F ( x ) = 1 − x − x 2 n =0 n =1

  19. Obtaining the coefficients k(x) → k((x)) 1 + x 1 + 2 x + 3 x 2 + 5 x 3 + 8 x 4 + . . . F ( x ) = 7! 1 − x − x 2 (1, 2, 3, 5, 8, …) Moral of the story so far : polynomial fractions are useful for reasoning about recurrence relations

  20. Plan • Fibonacci’s rabbits and sustainable rabbit farming • Signal Flow Graphs • Generating functions • IH Q[x] • Operational semantics • Solving sustainable rabbit farming

  21. Interacting Hopf Monoids (Bonchi, S., Zanasi, ’13, ’14) = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = (p ≠ 0) = = p p p p = = ( cf. ZX-calculus, Coecke and Duncan ’08, Baez and Erbele ‘14)

  22. Generalising (slightly) • It is straightforward to generalise from Z to arbitrary PID R • We can build the theory H R by adding enough scalars to the graphical syntax together with equations r 1 = 1 r 1 +r 2 = r 2 r 1 r 2 r 2 r 1 = = 0 • The equations of IH R are the same as before Theorem. IH R ≅ LinRel ff( R )

  23. Equations for Q [x] x = x = x x x = x x = x

  24. Polynomial fractions with diagrammatic syntax 1 + x F ( x ) = 1 − x − x 2 x = 1-x-x2 1+x x x

  25. Example 1-x-x2 1+x As linear relation over Q (x) is the space generated by (1, (1+x)/(1-x-x 2 )) As linear relation over Q ((x)) is the space generated by (1,0,0,… , 1,2,3,5,8,…)

  26. Plan • Fibonacci’s rabbits and sustainable rabbit farming • Signal Flow Graphs • Generating functions • IH Q[x] • Operational semantics • Solving sustainable rabbit farming

  27. Operational semantics Bonchi, S., Zanasi, Full abstraction for signal flow graphs , POPL ‘15 l k k k l k k l − − → − → k − − → k − → − − → − → x x k k kl l k + l 0 l k k + l k k kl l 0 − − → − → − − → − → − − − → − → k k x x k k l k k l u 1 u 2 s 0 t 0 u s 0 v w t 0 s t s t − − → − − → − → − → v 1 v 2 v k k l − → − − → w s 0 ; t 0 s 0 ⊕ t 0 k l k u 1 u 2 u s ; t s ⊕ t − − − − → − → v 1 v 2 Important point : all executions start with all registers initialised with 0!

  28. Example := := 1 0 1 2 x x x x 1 1 1 2 1 0 0 1 0 3 x x 1 3 2 1 …

  29. Signal flow graphs as string diagrams • Easy - get rid of directions on the wires! x x x x

  30. Realisability and Full Abstraction • Realisability Every diagram can be put in a form where the direction of signal flow is consistent • Full abstraction Operational equality (in terms of behaviour, given by operational semantics) coincides with denotational equality (the denoted linear relation) on diagrams with consistent signal flow

  31. Plan • Fibonacci’s rabbits and sustainable rabbit farming • Signal Flow Graphs • Generating functions • IH Q[x] • Operational semantics • Solving sustainable rabbit farming

  32. 1-x-x2 1+x x = x x x = x Which we know can be directed from left to right x x

  33. 1-x-x2 1+x x = x x Which can be directed from right to left x -1 -1 x x

  34. Solving sustainable rabbit farming # rfib [4;4;4;4;4;4;4;4;4;4;4;4;4];; - : int list = [4; -4; 0; -4; 0; -4; 0; -4; 0; -4; 0; -4; 0]

  35. Bibliography • Bonchi, S., Zanasi - Interacting Bialgebras are Frobenius, FoSSaCS ’14 • Bonchi, S., Zanasi - Interacting Hopf Algebras, J Pure Applied Algebra 221:144–184, 2017 • Bonchi, S., Zanasi - The Calculus of Signal Flow Diagrams I: Linear Relations on Streams, Inf Comput 252:2–29, 2017 • Bonchi, S., Zanasi - A categorical semantics of signal flow graphs, CONCUR 2013 • Bonchi, S., Zanasi - Full abstraction for signal flow graphs, PoPL 2016 • Zanasi - Interacting Hopf Algebras: The theory of linear systems, PhD Thesis, ENS Lyon, 2015 • Bonchi, S., Zanasi - Lawvere Theories as composed PROPs, CMCS 2016 • Fong, Rapisarda, S. - A categorical approach to open and interconnected dynamical systems, LiCS 2016 • Bonchi, Gadducci, Kissinger, S. - Rewriting modulo symmetric monoidal structure, LiCS 2016 • Bonchi, Gadducci, Kissinger, S. - Confluence of Graph Rewriting with Interfaces, ESOP 2017 graphicallinearalgebra.net

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend