Professional Documents
Culture Documents
Alur
Alur
Rajeev Alur
University of Pennsylvania
Languages vs Functions
A language L is a subset of S*
A numerical function maps strings in S* to N (or integers Z)
A string-to-string transformation maps S* to G*
C / x:=x+2 C / x:=x+1
S
x:=0
x x
M
M S
C / x:=x+2 C / x:=x+1
S
x:=0
x x
M / x:=0
M / x:=0 S
C / x:=x+2
y:=y+1 C / x:=x+1
S / x:=y
x,y:=0
x x
M / y:=x
M / y:=x S
Filling out a survey gives discounted cost for all the coffees
during that month
CRA Example
C / y:=y+1
x:=Infty
y:=0 min(x,y)
M / x:=min(x,y); y:=0
String Transducers
Interpretation []:
Set D of cost values
Mapping operators to functions over D
Input w= C C M C C C M
Value = 2 + + + + +
Infty 0 1 1 0 1 1 1
Regular String-to-tree Transformations
Recent proposals:
Streaming String Transducers (POPL 2011)
Streaming Tree Transducers (ICALP 2012)
Properties of Regular Cost Functions
String Transducers
Weighted Automata:
Nondeterministic automata with edges labeled with costs
Single-valued:
Each string has at most one accepting path
Cost of a string:
Sum of costs of transitions along the accepting path
Example: When you fill out a survey, each coffee during that
month gets the discounted cost.
Locally nondeterministic, but globally single-valued
Example: S = {C,S}
f(w)= if w contains S then |w| else 2|w|
f1(Ci)=i and f2(Ci)=2i are necessary and sufficient
String Transducers
a / x := x
x := e
output x
b / x := xb
Streaming String Transducer: Reverse
a / x := ax
x := e
output x
b / x := bx
Streaming String Transducer: Regular Look Ahead
b / x:=bx; y:=yb
x,y := e
output x output y
a / x:=ax
a a
a a
Functional Equivalence;
Given SSTs S and S’ over same input/output alphabets,
check whether they define the same transductions.
Closure properties
1. Sequential composition: f1(f2(w))
2. Regular conditional choice: if w in L then f1(w) else f2(w)
SST Applications
Opportunities
BEK: Transducer-based tool for analyzing string sanitizers
FlashFill: Learning string transformations from examples
Algorithmic Verification of List-processing Programs
function delete
input ref curr; head tail
input data v;
output ref result;
output bool flag := 0; 3 8 2
local ref prev;
while (curr != nil) & (curr.data = v) {
curr := curr.next;
flag := 1;
}
result := curr;
prev:= curr;
if (curr != nil) then {
curr := curr.next;
prev.next := nil;
while (curr != nil) {
if (curr.data = v) then {
curr := curr.next;
flag := 1;
}
else {
prev.next := curr; Decidable Analysis:
prev := curr; 1. Assertion checks
curr := curr.next; 2. Pre/post condition
prev.next := nil;
} 3. Full functional correctness
}
Talk Outline
Weighted Automata:
Nondeterministic automata with edges labeled with costs
C / y:=y+1
x:=Infty
min(x,y)
y:=0
M / x:=min(x,y); y:=0
From WA to CRA(min,+c):
Generalizes subset construction for determinization
For every state q of WA, CRA maintains a register xq
xq = min of costs of all paths to q on input read so far
Update on a: xq := min { xp + c | p –(a,c)-> q is edge in WA}
Input w: w1 # w2 # … # wn
a/1 b/1
Each wi in {a,b}*
# ai = Number of a’s in wi
bi = Number of b’s in wi
b,# a,#
Cost(w) = minj { a1+…+aj+bj+1+…+bn}
Probabilistic models
Markov chains / MDPs with regular rewards
Regular Functions
Definition parameterized by allowed operations
Based on MSO-definable graph transformations / transducers
Emerging theory
Some results, new connections
Many open problems and unexplored directions
Acknowledgements and References
Streaming String Transducers
(with P. Cerny; POPL’11, FSTTCS’10)
Transducers over Infinite Strings
(with E. Filiot, A. Trivedi; LICS’12)
Streaming Tree Transducers
(with L. D’Antoni; ICALP’12)
Regular Functions and Cost Register Automata
(with L. D’Antoni, J. Deshmukh, M. Raghothaman, Y. Yuan; LICS’13)
Decision problems for Additive Cost Regular Functions
(with M. Raghothaman; ICALP’13)
Infinite-String to Infinite-Term Regular Transformations
(with A. Durand, A. Trivedi; LICS’13)
Min-cost problems for Discounted Sum Regular Functions
(with S. Kannan, K. Tian, Y. Yuan; LATA’13)