Scope-Bounded Pushdown Languages Salvatore La Torre Università degli Studi di Salerno joint work with Margherita Napoli Università degli Studi di Salerno Gennaro Parlato University of Southampton Multi-stack Pushdown Automata (MPA) • n stacks sharing a finite control – states: s, , , ..........., 1 2 n – transitions : • push one symbol onto stack i • pop one symbol from stack i • internal move: stacks stay unchanged, only control location is altered • input is from a one-way read-only tape • model of concurrency – captures the control flow of concurrent programs with shared memory and recursive procedure calls Visible alphabets • Alphabet is partitioned into: – calls (cause a push operation) – returns (cause a pop operation) – internals (stacks are not used) • For n >1 stacks, alphabet is also partitioned according to stacks – the stack to operate is uniquely identified by the input symbol (it is visible in the input) What visibility gains for MPA? • Stack usage is synchronized with the input – parallel simulation of multiple runs, cross product construction, subset-like constructions • 1-stack (VPL): – intersection and determinization – universality, inclusion and equality • n-stacks (MVPL): – just intersection – emptiness is undecidable: the runs of MPA are visible! – checking for emptiness of MVPL equals to decide reachability for MPA Theme of the talk • The formal language theory of visibly nstack languages of k-scoped words (SMVPL) Visible alphabet (retns) --st1: a, a’ st2: b, b’ internal: e matching relation (matching call/retn) a e b a a’ a’ b a b’ e b’ a’ scope of matching relation over S: max number of S-contexts between matching call/retn word is 3-scoped – scope is 2 for GREEN and 3 for RED A few observations.... • Interest for restrictions of MPA mainly comes from verification – bugs of concurrent programs are likely to occur within few context-switches [Musuvathi-Qadeer, PLDI ‘07] – efficient sequentializations of multithreaded programs [Lal-Reps,CAV’08] • Robust automata theories are useful tools for other domains – Automata-theoretic approach to verification (modelchecking) – Pattern matching problems –… • K-scoped visibly languages indeed form a robust class… k-scoped MVPA • Closure under Boolean operations • Det./nondet. models are equivalent • Decidable emptiness [La Torre-Napoli, CONCUR’11], inclusion, equality, and universality • Logical characterization (MSO with matching relations) • Parikh theorem • Sequentializable: computations can be simulated with one stack (rearranging order of inputs) • Decidable temporal logic model-checking [La Torre-Napoli,TCS’12] [Atig-Bouajjani-Kumar-Saivasan, ATVA’12] More related work • Visibly pushdown languages [Alur-Madhusudan J. ACM'09] [Melhorn ICALP'80] Restricted MPAs: • Emptiness/reachability/closure properties [Carotenuto et al. DLT’07] [Atig et al. DLT’08] [Seth,CAV’10] [LaTorre et al. LATIN'10] [LaTorre et al. MFCS'14] • Model-checking [Atig, FSTTCS’10] [Bollig et al. MFCS’11] [Bollig et al. LICS’13] [Bansal-Demri, CSR’13] • MSO of multiply nested words [Madhusudan-Parlato POPL'11] [Cyriac et al. CONCUR'12] • ............ Rest of the talk • Determinization construction • Brief comparison with the known MPA classes of languages • Conclusions MVPL are nondeterministic • L = {(ab)i cjdi-j xjyi-j | i,j>0} is inherently nondeterministic for MPA [La Torre-Madhusudan-Parlato, LICS’07] – j is arbitrary and needs to be the same for both stacks – a guess is needed when pushing both stacks • L is not SMVPL – For any j, (ab)k cjdk-j xjyk-j is (k+1)-scoped a b a b a b ……… a b c………… d x………… y Determinization of SMPA • Summaries of computations for SMPA – Linear interfaces – Switching masks • PDA computing linear interfaces – linear interface automaton (LIA) • Simulation of SMPA by deterministic composition of deterministic LIAs (using switching masks) View of runs by stacks Input word (contexts) w = g1 r1 g2 b1 r2 b2 r3 b3 r4 g3 Run (without stacks) q1 g1 q2 q1 r1 q3 g2 q4 g1 b1 q2 q5 q2 q10 q4 g3 q6 b2 r1 r2 g2 q3 r2 q11 q7 r3 q8 b3 q9 r4 q3 q4 b1 q5 q6 q6 b2 q7 q8 q8 b3 q9 q5 r3 q7 r4 q10 q9 stack 1 q10 stack 2 stack 3 g3 q11 Linear Interface (LI) • k-LI for a stack S just summarizes starting and ending control states for k consecutive contexts of S in a run (starting from stack S empty) q1 q3 q10 g1 g2 g3 q2 q4 q11 q2 q5 q7 q9 r1 r2 r3 r4 3-LI for stack 1 stack 1 stack 2 q3 q4 q6 q6 q8 q8 q10 b1 q5 b2 q7 b3 q9 2-LI for stack 2 stack 3 Switching Mask (SM) • a tuple of LI, one for each stack • a function Nxt that links contexts of LI’s stack 2 stack 1 q1 q3 q10 g1 g2 g3 q2 q4 q11 q2 q5 q7 Switching mask q 9 r1 r2 r3 r4 stack 3 q3 q4 q6 q6 q8 q8 q10 b1 b2 b3 Nxt function given by purple arrows q5 q7 q9 Simulating MPA with SMs (1) • Control state (h, M) h: current stack M: switching mask • Move within a context: just update LI of stack h • Es: q1 g1 q2 q2 r1 q3 q4 b1 q55 M: q3 g2 q4 h=3 MPA transition from q5 to p5 on stack-3 symbol q1 q2 q3 q4 q2 q3 q4 (h is not changed) p5 Simulating MPA with SMs (2) • Context-switch 1 (accumulated stack content needed): add a new context to an existing LI • Es: h=3, and MPA moves from q5 to p5 on a stack-2 symbol M: q1 q3 g1 g2 q2 q2 r1 q3 q4 q2 q3 q4 q5 p5 b1 q5 q4 then h=2 and the SM is q1 q2 q3 q4 q5 Simulating MPA with SMs (3) • Context-switch 2 (accumulated stack content no longer needed): start a new LI • Es: h=3, and MPS moves from q5 to p5 on a stack-2 symbol M: q1 q3 g1 g2 q2 q2 r1 q3 q4 p5 q4 b1 q5 q4 then h=2 and the SM is q1 q2 q3 q4 q5 q5 PDA accumulating LIs Given a PDA P over an alphabet , symbols ,# a k linear interface automaton (k-LIA) for P is a PDA s.t. • input is over {,#} w11#w12#........#w1i1 w21#w22#........#w2i2 .... • control states are h-LIs of P for hk • on , simulates P on the last state of the LI • on #, a new context is appended to the current LI (provided that it is a h-LI with hk-1) • on , a new LI is started and stack is reset (a bottom-of-the-stack symbol is pushed onto the stack to avoid the use of previously pushed symbols) (k)-LIs suffice for SMPA Theorem. By restricting to k-scoped inputs, h-LIs with hk suffice to simulate the behavior of an MPA with switching masks Thus, for each stack of an SMPA, we can restrict to k-LIAs Determinization of SMPA (1) For an SMPA A • construct the LIA Ah for each stack h • construct Dh by determinizing each Ah as in [Alur-Madhusudan, STOC’04] • construct the deterministic SMPA D (equiv. to A) – cross product of the Dh‘s – parallel simulation of A with all the generated SMs (subset construction) Determinization of SMPS (2) • a state of D is of the form (h, Q1,...,Qn, ) where – h is the current stack – Q1,...,Qn is a state of the cross product – is a set of switching masks • within a context of stack h, D simulates Dh (the Q the size of Dand is all the switching masks in h–component gets updated accordingly) • exp in the size of A and • 2exp in the number of stacks • on context-switching from stack h to stack i (a and thei bound call/return of stack is read),kD simulates in parallel – Dh on either # or – Di on the input symbol Comparisons CSL OMVPL [BCCC96] [MCP07] [ABH08] RMVPL SMVPL [LPM10] VPL TMVPL [AM04] [LNP14] PMVPL [LMP07] CFL Decision Problems VPL CFL RMVPL SMVPL TMVPL PMVPL OMVPL CSL Conclusions • SMVPL form a robust theory of visibly languages (the largest among those closed under determinization) • Sequentialization is nice for analysis purposes – Computations of MPA can be analyzed via computations of PDA – used in software verification • Scope-bounded words meaningfully extends to – words – Describe infinite on-going interaction among different threads Theory on infinite words? • Little it is known on MPS over –words • visibly pushdown Büchi automata [Alur-Madhusudan,J. ACM, 2009] - the model is not determinizable • emptiness for k-scoped Büchi MPA is PSPACEcomplete [La Torre-Napoli,TCS’12] • closure under union and intersection are simple