




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Loris D’Antoni A DISSERTATION in Computer Science Presented to the Faculties of the University of Pennsylvania in Partial Fulfilment of the Requirements for the Degree of Doctor of Philosophy 2015
Supervisor of Dissertation
Rajeev Alur, Zisman Family Professor of Computer and Information Science
Graduate Group Chairperson
Lyle H. Ungar, Professor of Computer and Information Science
Dissertation Committee Chaired by Sampath Kannan, Henry Salvatori Professor of Computer and Information Science Benjamin C. Pierce, Henry Salvatori Professor of Computer and Information Science Val Tannen, Professor of Computer and Information Science Margus Veanes (External), Senior Researcher at Microsoft Research
ii
iv
Loris D’Antoni Dr. Rajeev Alur
Automata, the simplest model of computation, have proven to be an effective tool in reasoning about programs that operate over strings. Transducers augment automata to produce outputs and have been used to model string and tree transformations such as natural language translations. The success of these models is primarily due to their closure properties and decidable procedures, but good properties come at the price of limited expressiveness. Concretely, most models only support finite alphabets and can only represent small classes of languages and transformations. We focus on addressing these limitations and bridge the gap between the theory of au- tomata and transducers and complex real-world applications: Can we extend automata and transducer models to operate over structured and infinite alphabets? Can we design lan- guages that hide the complexity of these formalisms? Can we define executable models that can process the input efficiently? First, we introduce succinct models of transducers that can operate over large alpha- bets and design BEX, a language for analysing string coders. We use BEX to prove the correctness of UTF and BASE64 encoders and decoders. Next, we develop a theory of tree transducers over infinite alphabets and design FAST, a language for analysing tree-manipulating programs. We use FAST to detect vulnerabilities in HTML sanitizers, check whether augmented reality taggers conflict, and optimize and analyze functional programs that operate over lists and trees. Finally, we focus on laying the foundations of stream processing of hierarchical data such as XML files and program traces. We introduce two new efficient and executable models that can process the input in a left- to-right linear pass: symbolic visibly pushdown automata and streaming tree trans- ducers. Symbolic visibly pushdown automata are closed under Boolean operations and can specify and efficiently monitor complex properties for hierarchical structures over infinite alphabets. Streaming tree transducers can express and efficiently process complex XML transformations while enjoying decidable procedures.
v
Acknowledgements iii
Abstract iv
List of tables xii
List of figures xiii
1 Introduction 1 1.1 Preamble..................................... 1 1.2 Automata, languages, and program properties............... 2 1.3 Transducers, transformations, and programs................ 3 1.4 Limitations of existing models......................... 5 1.5 Contributions.................................. 6 1.5.1 Foundational results.......................... 6 1.5.2 Language design and implementation................ 7 1.5.3 Applications............................... 7 1.6 Acknowledgements............................... 8
xiv
“When you do things right, people won’t be sure you’ve done anything at all.”
— The cosmic entity, Futurama
Introduction 2
q 0
q 0
FIGURE 1.1: Examples of finite automata.
IH08, MSV00, BDM+06, Bec03, MBPS05]. We build on these models and identify novel ones that can be used to analyze many real-world programs.
Finite automata define sets of strings, also called languages. They are used in many applications, most notably in analysis of regular expressions and program monitor- ing [LG07]. Intuitively a finite automaton is a labeled graph with initial and final states (nodes). The labels of the edges are symbols over an input alphabet and each path through the graph corresponds to a string. The language defined by a particular au- tomaton is the set of all strings for which there is a path from an initial to a final state. For example, the automaton all_TG in Figure 1.1 accepts the language of all strings containing only the symbols T and G. Automata can capture computations. In particular, they can be seen as programs that map lists to Boolean values. Examples of such programs can be seen in Figure 1.2. In particular, the programs all_TG and all_AC (lines 11–20) can be modeled using the automata depicted in Fig. 1.1 that accept strings over the alphabet base = {A, T, G, C}. Similarly, the programs is_dna and is_empty (lines 4–10) can be captured by two automata accepting all strings and only the empty string respectively. What is the advantage of representing programs as automata? Unlike general purpose programs, finite automata enjoy many properties that can enable forms of program analysis. Automata can be complemented, intersected, determinized, and minimized, and it is decidable whether two automata accept the same languages. This opens a door of opportunities on what type of properties we can check for our programs in
Introduction 3
Figure 1.2. For example, we can prove that the programs all_TG and all_AC accept disjoint languages by checking that the intersection of their corresponding automata is equivalent to the empty language.
Although automata enjoy many useful properties, they can only model very limited classes of programs. Finite transducers extend finite automata to model partial func- tions from strings to strings, also called string transformations. This is done by adding an output component to transitions. A finite state transducer is a labeled graph with initial and final states (nodes), where each edge carries an input symbol and a sequence of output symbols. Each path corresponding to an input string also produces an out- put string by outputting sequences of characters at each transition. The concatenation of such sequences is the output corresponding to the traversed path. The transforma- tion defined by a transducer is the set of all input/output string pairs for which there is a path from an initial to a final state. For example, the transducer map_base in Fig- ure 1.3 defines the transformation that outputs the DNA sequence matching the input one (maps each base to the matching one, e.g. A to T). Transducers can be seen as programs that map lists into lists. Examples of such pro- grams can be seen in Figure 1.2. The programs map_base and filter_AC (lines 21–35) can be modeled using the transducers depicted in Figure 1.3. Again, what is the advantage of modeling programs using transducers? Finite trans- ducers also enjoy a variety of properties that enable powerful analysis. In particular, transducers are closed under sequential composition, and it is decidable whether two transducers define the same transformations. Also, given a transducer T , and two au- tomata I and O, it is decidable whether for every string accepted by the automaton I, the transducer T produces an output accepted by O. This problem is called regular type-checking. Consider the programs in Fig. 1.2. We can use the transducers’ clo- sure under sequential composition to automatically generate a transducer m_f_DNA that processes the input in a single pass without producing intermediate results (on the right Fig. 1.3). Similarly, we can build a transducer for the transformation f_m_f_DNA. We can then use type-checking to statically prove that for every list for which dnaseq returns true, the function f_m_f_DNA outputs a list in the language is_empty (i.e. the empty list).
Introduction 5
q 0
A/T
map_base
T/A
G/C C/G
q 0
A/A T/ε
G/ε C/C filter_AC
q 0
A/ε T/ A
G/C C/ε m_f_DNA FIGURE 1.3: Examples of finite state transducers.
Interesting programs can be modeled using finite automata and transducers. However, the capabilities of these formalisms are limited: they only operate over strings, they can only capture limited classes of languages and transformations (e.g. reverse in Fig. 1. cannot be modeled as a finite state transducer), and they are limited to finite alphabets. Many models and techniques have been proposed to attenuate these limitations. Au- tomata and transducers have been extended to trees [Eng75, Eng77, CDG+07], richer transducer models have been presented to handle more complex functions [AC10, AC11, EH01], there have been extensions to support infinite and structured alpha- bets [VHL+12, KF94], and a few programming languages were implemented to sim- plify programming in these models [PS12, MK08]. Although all these extensions have progressed towards addressing many of the limitations, there are simple domains that could potentially benefit from transducer-based analysis that cannot be modeled using existing models. The following limitations still exist:
Alphabet expressiveness: Although several extensions have been proposed, many tree and string transformations and XML languages over infinite domains cannot be expressed using existing models; Executable models: Most models proposed to capture larger classes of functions are not efficiently executable. In particular, they typically require multiple passes over the input. Usability: Automata and transducers are complex to use for an average user and the integration between programming languages and these models is still limited.
Introduction 6
The goal of this dissertation is to bridge part of the gap between practical applications and the theory of automata and transducers. Its contributions are divided between the following areas:
Foundational results: We define novel automata and transducer models that can express large classes of languages and transformations. For many of these models we provide strong theoretical guarantees and exactly characterize their expressive- ness. Implementation: We implement two programming languages, FAST and BEX, that have their semantics given in terms of automata and transducers. Using these seman- tics, programs written in FAST and BEX can be statically analyzed. We also de- velop the open-source automata library SVPAlib, for coding automata over infi- nite alphabets. Applications: We show how transducer-based languages are beneficial in proving prop- erties of real-world programs. We use BEX to prove the correctness of BASE 64 and UTF8 coders, and FAST to prove the absence of malicious outputs in HTML sanitizers, to check interference of augmented reality applications, to optimize functional language compilation, and to analyze functional programs over trees.
The rest of this chapter expands on each of these contributions in detail.
Automata are the pillars of computability and they are used in many domains thanks to their decidable procedures and closure properties. Our first contribution is to ex- tend existing automata and transducer models to capture richer classes of languages and transformations. For these extended versions we prove closure properties and provide upper bounds for several decision procedures. Chapter 2 introduces symbolic extended finite automata and transducers, which extend finite automata and trans- ducer with predicates to support infinite alphabets and the ability to process multiple adjacent symbols in a single transition. We prove negative properties for these models and show that for a restricted version, called Cartesian, checking equivalence is de- cidable. Chapter 3 defines symbolic tree transducers with regular look-ahead, which extend their classic counterpart with predicates to support infinite alphabets. We show that this model is closed under composition under the same assumptions that are nec- essary in the non-symbolic setting. Chapter 4 presents symbolic visibly pushdown