regular programming for quantitative properties of data
play

regular programming for quantitative properties of data streams - PowerPoint PPT Presentation

regular programming for quantitative properties of data streams Rajeev Alur Dana Fisman Mukund Raghothaman ESOP 2016 University of Pennsylvania 0 data streams EOM P1 EOM P2 P2 P2 EOD P2 P1


  1. regular programming for quantitative properties of data streams Rajeev Alur Dana Fisman Mukund Raghothaman ESOP 2016 University of Pennsylvania 0

  2. data streams ∙ EOM ∙ P1 ∙ EOM ∙ P2 ∙ P2 ∙ P2 ∙ EOD ∙ P2 ∙ P1 ∙ EOM ∙ P2 ∙ P1 ∙ P2 ∙ P2 ∙ P2 ∙ P1 web-page requests ∙ P2 ∙ P2 ∙ EOD ∙ P2 ∙ P1 ∙ P1 ∙ EOM ∙ P2 ∙ P2 ∙ P2 ∙ P1 ∙ EOD ∙ P2 ∙ P2 ∙ P1 1 ∙ · · ·

  3. max count P1 count P2 data streams web-page requests ∙ What is the maximum number of daily requests for P2? ∙ What is the number of requests for P1 in an average month? iter - avg month - count P1 ∙ What is the total number of requests for P1? count P1 iter - sum day - count P1 ∙ What is the maximum of the total number of requests for P1 and P2? 2 iter - max ( day - count P2 )

  4. max count P1 count P2 data streams web-page requests ∙ What is the maximum number of daily requests for P2? ∙ What is the number of requests for P1 in an average month? ∙ What is the total number of requests for P1? count P1 iter - sum day - count P1 ∙ What is the maximum of the total number of requests for P1 and P2? 2 iter - max ( day - count P2 ) iter - avg ( month - count P1 )

  5. max count P1 count P2 data streams web-page requests ∙ What is the maximum number of daily requests for P2? ∙ What is the number of requests for P1 in an average month? ∙ What is the total number of requests for P1? ∙ What is the maximum of the total number of requests for P1 and P2? 2 iter - max ( day - count P2 ) iter - avg ( month - count P1 ) count P1 = iter - sum ( day - count P1 )

  6. data streams web-page requests ∙ What is the maximum number of daily requests for P2? ∙ What is the number of requests for P1 in an average month? ∙ What is the total number of requests for P1? ∙ What is the maximum of the total number of requests for P1 and P2? 2 iter - max ( day - count P2 ) iter - avg ( month - count P1 ) count P1 = iter - sum ( day - count P1 ) max ( count P1 , count P2 )

  7. quantitative regular expressions Languages Regular expressions Cost functions QREs 3 Σ ∗ → bool ≡ Σ ∗ → R ≡

  8. function combinators

  9. function combinators ∙ Analogue of basic regular expressions 5 basic expressions, a �→ d a �→ d ∙ If w = a , then output d , otherwise undefined ∙ P1 �→ 0 , P1 �→ 1 , EOD �→ 5 , …

  10. function combinators f else g f else g ∙ Analogue of regular expression union 6 ∙ If f ( w ) is defined, then output f ( w ) , otherwise output g ( w )

  11. function combinators op ∙ Analogue of regular expression intersection 7 ∙ f + g : Map w to f ( w ) + g ( w ) ∙ f − g : Map w to f ( w ) − g ( w ) ∙ max ( f , g ) : Map w to max ( f ( w ) , g ( w )) ∙ · · · ∙ op ( f 1 , f 2 , . . . , f k ) : Map w to op ( f 1 ( w ) , f 2 ( w ) , . . . , f k ( w ))

  12. concatenation split - plus f g , split - max f g , …, split - op f g f g Output max op 8 split - op ( f , g ) w 1 w 2

  13. concatenation , split - max f g , …, split - op f g f g Output max op 8 split - op ( f , g ) split - plus ( f , g ) w 1 w 2 +

  14. concatenation , …, split - op f g f g Output max op 8 split - op ( f , g ) split - plus ( f , g ) , split - max ( f , g ) w 1 w 2 +

  15. concatenation f g Output max op 8 split - op ( f , g ) split - plus ( f , g ) , split - max ( f , g ) , …, split - op ( f , g ) w 1 w 2 + · · ·

  16. iteration w k op 9 iter - op ( f ) w k − 1 w 1 w 2

  17. function combinators attempt 1 Conditional choice: f else g ∙ What about non-binary, non-commutative or non-associative operators? ∙ Are these operators “sufficient”? If we add more operators? 10 Basic functions: a �→ d Concatenation: split - op ( f , g ) Function iteration: iter - op ( f ) Cost operations: op ( f 1 , f 2 , . . . , f k )

  18. function combinators attempt 1 Conditional choice: f else g ∙ What about non-binary, non-commutative or non-associative operators? ∙ Are these operators “sufficient”? If we add more operators? 10 Basic functions: a �→ d Concatenation: split - op ( f , g ) Function iteration: iter - op ( f ) Cost operations: op ( f 1 , f 2 , . . . , f k )

  19. function combinators attempt 1 Conditional choice: f else g ∙ What about non-binary, non-commutative or non-associative operators? ∙ Are these operators “sufficient”? If we add more operators? 10 Basic functions: a �→ d Concatenation: split - op ( f , g ) Function iteration: iter - op ( f ) Cost operations: op ( f 1 , f 2 , . . . , f k )

  20. parse trees and computation trees ∙ Attempt 1 annotates the parse tree with cost operations to obtain the computation tree ∙ What if QREs map input streams to computation trees? 11 split - plus ( count P1 , Σ 5 �→ 0)

  21. parse trees and computation trees ∙ Attempt 1 annotates the parse tree with cost operations to obtain the computation tree ∙ What if QREs map input streams to computation trees? 11 split - plus ( count P1 , Σ 5 �→ 0) Σ 5

  22. P1 parse trees and computation trees P2 P2 P1 ∙ Attempt 1 annotates the parse tree with cost operations to obtain the computation tree ∙ What if QREs map input streams to computation trees? 11 split - plus ( count P1 , Σ 5 �→ 0) · Σ 5 ∗ Σ 5 · · ·

  23. 1 parse trees and computation trees 0 0 1 ∙ Attempt 1 annotates the parse tree with cost operations to obtain the computation tree ∙ What if QREs map input streams to computation trees? 11 split - plus ( count P1 , Σ 5 �→ 0) + + 0 Σ 5 · · ·

  24. 1 parse trees and computation trees 0 0 1 ∙ Attempt 1 annotates the parse tree with cost operations to obtain the computation tree ∙ What if QREs map input streams to computation trees? 11 split - plus ( count P1 , Σ 5 �→ 0) + + 0 Σ 5 · · ·

  25. quantitative regular expressions Key Insight QREs map input streams to terms over the cost domain ∙ Terms contain parameters ∙ Parameter substitution is also an operation 12 ∙ f ( aaab ) = 5 + p , where p is a parameter

  26. quantitative regular expressions Key Insight QREs map input streams to terms over the cost domain ∙ Terms contain parameters ∙ Parameter substitution is also an operation 12 ∙ f ( aaab ) = 5 + p , where p is a parameter

  27. function combinators substitution 13 Parameter subtitution, f [ p / g ] ∙ Say f ( w ) = t f , ∙ and g ( w ) = t g ∙ f [ p / g ]( w ) = t f [ p / t g ]

  28. function combinators concatenation, take 2 f g Output 14 split ( f → p g ) w 1 w 2

  29. function combinators concatenation, take 2 f g Output p 14 split ( f → p g ) w 1 w 2

  30. function combinators concatenation, take 2 f Output p ∙ g w p g w 15 Simulating split - plus ( f , g ) w 1 w 2 g ′ ∙ split - plus ( f , g ) = split ( f → p g ′ )

  31. function combinators concatenation, take 2 f Output p 15 Simulating split - plus ( f , g ) w 1 w 2 g ′ ∙ split - plus ( f , g ) = split ( f → p g ′ ) ∙ g ′ ( w ) = p + g ( w )

  32. function combinators iteration, take 2 w k op f f f f p p p 16 w k − 1 w 1 w 2

  33. function combinators iteration, take 2 w k op f f f f p p p 16 w k − 1 w 1 w 2

  34. quantitative regular expressions Conditional choice: f else g ∙ QREs map string to terms ∙ Structural operators decoupled from cost operators 17 Basic functions: a �→ d , regex �→ term Concatenation: split ( f → p g ) , split ( f ← p g ) Function iteration: iter → ( f ) , iter ← ( f ) Cost operations: op ( f 1 , f 2 , . . . , f k ) , f [ p / g ]

  35. quantitative regular expressions Conditional choice: f else g ∙ QREs map string to terms ∙ Structural operators decoupled from cost operators 17 Basic functions: a �→ d , regex �→ term Concatenation: split ( f → p g ) , split ( f ← p g ) Function iteration: iter → ( f ) , iter ← ( f ) Cost operations: op ( f 1 , f 2 , . . . , f k ) , f [ p / g ]

  36. quantitative regular expressions ∙ Was our choice of combinators ad-hoc? What functions can the formalism express? ∙ Given f and an input stream w , can we efficiently compute 18 f ( w ) ?

  37. expressiveness

  38. regular cost functions [lics 2013] Languages Finite automata Cost functions ? Regular languages have many appealing properties: many natural equi-expressive characterizations, robust closure properties, decidable analysis problems, practical utility 20 Σ ∗ → bool ≡ Σ ∗ → R ≡

  39. cost register automata [lics 2013] start ∙ Finite state space, finitely many registers ∙ Registers hold terms: Parameterized by set of operations ∙ Equivalent to MSO definable string-to-term transducers ∙ Closed under regular lookahead, input reversal, etc 21 d < 0/ bal := bal + d d ≥ 0/ bal := bal + d d ∈ R / bal := bal + d q 0 q 1 d = end m / bal := bal + 10 d = end m

  40. cost register automata Theorem QREs can express exactly the same functions as CRAs 22

  41. Taste of the completeness proof traversing states less than q i DReX expression 23 cras → qres ∙ Piggy-back on DFA to regular expression translation Construct R i ( q , q ′ ) : all strings from q to q ′ while only ∙ Construct f i ( q , q ′ , x ) : express final value of register x as a

Recommend


More recommend