propagators an introduction
play

Propagators: An Introduction George Wilson Data61/CSIRO - PowerPoint PPT Presentation

Propagators: An Introduction George Wilson Data61/CSIRO george.wilson@data61.csiro.au 14th November 2017 What? Why? R 2 R 3 V 1 Beginnings as early as the 1970s at MIT R 1 Guy L. Steele Jr. Gerald J. Sussman Richard Stallman


  1. Propagators: An Introduction George Wilson Data61/CSIRO george.wilson@data61.csiro.au 14th November 2017

  2. What? Why?

  3. R 2 R 3 V 1 Beginnings as early as the 1970’s at MIT R 1 • Guy L. Steele Jr. • Gerald J. Sussman • Richard Stallman V out R gain More recently: R 1 • Alexey Radul V 2 R 2 R 3

  4. (define (map f xs) (cond ((null? xs) ’()) (else (cons (f (car xs)) (map f (cdr xs)))))))

  5. {} And then • Edward Kmett {1} {2} {3} {4} {1,2} {1,3} {2,3} {1,4} {2,4} {3,4} {1,2,3} {1,2,4} {1,3,4} {2,3,4} {1,2,3,4} x ≤ y = ⇒ f ( x ) ≤ f ( y )

  6. They’re related to many areas of research, including: • Logic programming (particularly Datalog) • Constraint solvers • Conflict-Free Replicated Datatypes • LVars • Programming language theory • And spreadsheets! They have advantages: • are extremely expressive • lend themselves to parallel and distributed evaluation • allow different strategies of problem-solving to cooperate

  7. Propagators

  8. The propagator model is a model of computation We model computations as propagator networks

  9. The propagator model is a model of computation We model computations as propagator networks A propagator network comprises • cells • propagators • connections between cells and propagators

  10. 3

  11. toUpper

  12. toUpper

  13. 'q' toUpper

  14. 'q' toUpper 'Q'

  15. +

  16. 3 +

  17. 3 + 4

  18. 3 + 7 4

  19. z ← x + y

  20. z = x + y

  21. 7 = x + 4

  22. 7 = 3 + 4

  23. z = x + y

  24. z ← x + y x ← z − y y ← z − x

  25. - + -

  26. - + 4 -

  27. - + 7 4 -

  28. - 3 + 7 4 -

  29. Propagators let us express bidirectional relationships!

  30. ° F = ° C × 9 5 + 32 C F × + 9/5 32

  31. ° F = ° C × 9 5 + 32 C F × + 24.0 9/5 32

  32. ° F = ° C × 9 5 + 32 C F × + 24.0 43.2 9/5 32

  33. ° F = ° C × 9 5 + 32 C F × + 24.0 43.2 75.2 9/5 32

  34. ° F = ° C × 9 5 + 32 ° C = ( ° F − 32) ÷ 9 5 C F × + 9/5 32 ÷ -

  35. ° F = ° C × 9 5 + 32 ° C = ( ° F − 32) ÷ 9 5 C F × + 75.2 9/5 32 ÷ -

  36. ° F = ° C × 9 5 + 32 ° C = ( ° F − 32) ÷ 9 5 C F × + 43.2 75.2 9/5 32 ÷ -

  37. ° F = ° C × 9 5 + 32 ° C = ( ° F − 32) ÷ 9 5 C F × + 24.0 43.2 75.2 9/5 32 ÷ -

  38. ° F = ° C × 9 5 + 32 ° C = ( ° F − 32) ÷ 9 5 C F × + 9/5 32 ÷ -

  39. ° F = ° C × 9 5 + 32 ° C = ( ° F − 32) ÷ 9 5 C F × + 43.2 9/5 32 ÷ -

  40. ° F = ° C × 9 5 + 32 ° C = ( ° F − 32) ÷ 9 5 C F × + 24.0 43.2 75.2 9/5 32 ÷ -

  41. C F × + 9/5 32 ÷ - + 3.0 - -

  42. C F × + 75.2 9/5 32 ÷ - + 3.0 - -

  43. C F × + 43.2 75.2 9/5 32 ÷ - + 3.0 - -

  44. C F × + 24.0 43.2 75.2 9/5 32 ÷ - + 3.0 - -

  45. C F × + 24.0 43.2 75.2 9/5 32 ÷ - + 3.0 - 21.0 -

  46. We can combine networks into larger networks!

  47. ?

  48. Cells accumulate information about a value

  49. Cells accumulate information in a bounded join-semilattice

  50. Cells accumulate information in a bounded join-semilattice A bounded join-semilattice is: • A partially ordered set • with a least element • such that any subset of elements has a least upper bound

  51. Cells accumulate information in a bounded join-semilattice A bounded join-semilattice is: • A partially ordered set • with a least element • such that any subset of elements has a least upper bound “Least upper bound” is denoted as ∨ and is usually pronounced “join”

  52. {} {1} {2} {3} {4} {1,2} {1,3} {2,3} {1,4} {2,4} {3,4} {1,2,3} {1,2,4} {1,3,4} {2,3,4} {1,2,3,4}

  53. {} More information {1} {2} {3} {4} {1,2} {1,3} {2,3} {1,4} {2,4} {3,4} {1,2,3} {1,2,4} {1,3,4} {2,3,4} Less information {1,2,3,4}

  54. More information Less information

  55. More information Less information

  56. More information Less information

  57. More information Less information

  58. More information Less information

  59. More information Less information

  60. More information Less information

  61. More information Less information

  62. More information Less information

  63. More information Less information

  64. ∨ has useful algebraic properties. It is: • A monoid • that’s commutative • and idempotent

  65. Left identity ǫ ∨ x = x Right identity x ∨ ǫ = x Associativity ( x ∨ y ) ∨ z = x ∨ ( y ∨ z ) Commutative x ∨ y = y ∨ x Idempotent x ∨ x = x

  66. class BoundedJoinSemilattice a where bottom :: a (\/) :: a -> a -> a

  67. class BoundedJoinSemilattice a where bottom :: a (\/) :: a -> a -> a data SudokuVal = One | Two | Three | Four deriving ( Eq , Ord , Show )

  68. class BoundedJoinSemilattice a where bottom :: a (\/) :: a -> a -> a data SudokuVal = One | Two | Three | Four deriving ( Eq , Ord , Show ) newtype SudokuSet = S ( Set SudokuVal )

  69. class BoundedJoinSemilattice a where bottom :: a (\/) :: a -> a -> a data SudokuVal = One | Two | Three | Four deriving ( Eq , Ord , Show ) newtype SudokuSet = S ( Set SudokuVal ) instance BoundedJoinSemilattice SudokuSet where bottom = S ( Set .fromList [ One , Two , Three , Four ]) S a \/ S b = S ( Set .intersection a b)

  70. We don’t write values directly to cells Instead we join information in

  71. We don’t write values directly to cells Instead we join information in This makes our propagators monotone , meaning that as the input cells gain information, the output cells gain information (or don’t change)

  72. We don’t write values directly to cells Instead we join information in This makes our propagators monotone , meaning that as the input cells gain information, the output cells gain information (or don’t change) A function f : A → B where A and B are partially ordered sets is monotone if and only if, for all x, y ∈ A. x ≤ y = ⇒ f ( x ) ≤ f ( y )

  73. All our lattices so far have been fininte {} {1} {2} {3} {4} {1,2} {1,3} {2,3} {1,4} {2,4} {3,4} {1,2,3} {1,2,4} {1,3,4} {2,3,4} {1,2,3,4}

  74. Thanks to these properties: • the bounded join-semilattice laws • the finiteness of our lattice • the monotonicity of our propagators our propagator networks will yield with a deterministic answer, in finite time, regardless of parallelism and distribution

  75. Thanks to these properties: • the bounded join-semilattice laws • the finiteness of our lattice • the monotonicity of our propagators our propagator networks will yield with a deterministic answer, in finite time, regardless of parallelism and distribution Bounded join-semilattices are already popular in the distributed systems world See: Conflict Free Replicated Datatypes

  76. Thanks to these properties: • the bounded join-semilattice laws • the finiteness of our lattice • the monotonicity of our propagators our propagator networks will yield with a deterministic answer, in finite time, regardless of parallelism and distribution Bounded join-semilattices are already popular in the distributed systems world See: Conflict Free Replicated Datatypes We can relax these constraints in a few different directions

  77. Our lattices only need the ascending chain condition Contradiction ... -2 -1 0 1 2 ... Unknown

  78. ?

  79. - 3 + 4 -

  80. data Perhaps a = Unknown | Known a | Contradiction

  81. data Perhaps a = Unknown | Known a | Contradiction instance Eq a => BoundedJoinSemiLattice ( Perhaps a) where bottom = Unknown (\/) Unknown x = x (\/) x Unknown = x (\/) Contradiction _ = Contradiction (\/) _ Contradiction = Contradiction (\/) ( Known a) ( Known b) = if a == b then Known a else Contradiction

  82. Contradiction ... -2 -1 0 1 2 ... Unknown

  83. More information Contradiction ... -2 -1 0 1 2 ... Unknown Less information

  84. - Known 3 + Unknown Known 4 -

  85. - Known 3 + Known 7 Known 4 -

  86. Known 3 Known 4 + Unknown + Known 6 Known 6

Recommend


More recommend