Visibly Pushdown Languages Philippe Giabbanelli CMPT 894 – Spring 2008.

Slides:



Advertisements
Similar presentations
Model Checking From Tools to Theory University of Pennsylvania
Advertisements

Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
Chapter 5 Pushdown Automata
Natural Language Processing - Formal Language - (formal) Language (formal) Grammar.
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Closure Properties of CFL's
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
Pushdown Automata Chapter 12. Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely.
Pushdown Automata Part II: PDAs and CFG Chapter 12.
The Language Theory of Bounded Context-Switching Gennaro Parlato (U. of Illinois, U.S.A.) Joint work with: Salvatore La Torre (U. of Salerno, Italy) P.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 4 Updated by Marek Perkowski.
Validating Streaming XML Documents Luc Segoufin & Victor Vianu Presented by Harel Paz.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
A temporal logic for calls and returns P. Madhusudan University of Pennsylvania Joint work with Rajeev Alur and Kousha Etessami Talk at HCES 2004, Philadelphia.
1 Foundations of Software Design Lecture 23: Finite Automata and Context-Free Grammars Marti Hearst Fall 2002.
Normal forms for Context-Free Grammars
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
Regular Model Checking Ahmed Bouajjani,Benget Jonsson, Marcus Nillson and Tayssir Touili Moran Ben Tulila
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
A summary of our activities about WSI Philippe Giabbanelli CMPT 894 – Spring 2008.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
Languages of nested trees Swarat Chaudhuri University of Pennsylvania (with Rajeev Alur and P. Madhusudan)
CS/IT 138 THEORY OF COMPUTATION Chapter 1 Introduction to the Theory of Computation.
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Pushdown Automata (PDAs)
Grammars CPSC 5135.
Pushdown Automata Part I: PDAs Chapter Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2)
CS 461 – Sept. 19 Last word on finite automata… –Scanning tokens in a compiler –How do we implement a “state” ? Chapter 2 introduces the 2 nd model of.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
Theory of Computation, Feodor F. Dragan, Kent State University 1 TheoryofComputation Spring, 2015 (Feodor F. Dragan) Department of Computer Science Kent.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Algorithmic Software Verification Rajeev Alur University of Pennsylvania ARO Review, May 2005.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
PushDown Automata. What is a stack? A stack is a Last In First Out data structure where I only have access to the last element inserted in the stack.
CS 203: Introduction to Formal Languages and Automata
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
11 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 7 School of Innovation, Design and Engineering Mälardalen University 2012.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
Overview of Previous Lesson(s) Over View  A token is a pair consisting of a token name and an optional attribute value.  A pattern is a description.
Algorithms for hard problems Automata and tree automata Juris Viksna, 2015.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
1 Chapter Pushdown Automata. 2 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations.
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz
Natural Language Processing - Formal Language -
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Chapter 7 PUSHDOWN AUTOMATA.
Course 2 Introduction to Formal Languages and Automata Theory (part 2)
Jaya Krishna, M.Tech, Assistant Professor
Pushdown automata The Chinese University of Hong Kong Fall 2011
Presentation transcript:

Visibly Pushdown Languages Philippe Giabbanelli CMPT 894 – Spring 2008

1 Why a special subclass? Formal definition of the class and what it can model This presentation is about a subclass of context-free languages. First of all, we will see what we use this subclass for, or in other words why we have the need for a definition of a particuliar subclass. Can we have some more general? Once we define it, we present the usual theoretical tools associated with a class (closures, determinization, characterisation). How to characterize the class (automaton, grammar)

Subset of Context-Free Formalism Characterizations Extensions 2 How can we describe a non-concurrent programming language like C? Pushdown automata are used in program analysis, compiler optimization and model checking when the question can be modelled as a decision problem over pushdown automata. sequential computations + nested (sometimes recursive) calls Could be described by a regular language. Involves the stack. An automaton with a stack is a pushdown automaton, and it models context free languages. ∙ Dead code (i.e. code that will never get executed) ∙ Accessing unitialized variables ∙ Bounds on stack size Regular properties Context-free property Checking context-free properties for pushdown automata is undecidable.

Subset of Context-Free Formalism Characterizations Extensions 3 Checking context-free properties for pushdown automata is undecidable. So what? It’s undecidable but we still do it? Not exactly. It’s undecidable in the general case, but some things are duable. Let see why bounds on stack size is duable. Why we need to check bounds on stack size: interrupt-driven software In real time applications, there are external events and we must be fast to answer (i.e. to handle them). Each source of event will emit an interrupt and a handler will take care of it, if you are in the interrupt-processing mode (i.e. if we are ready to take care of external events). When we call a handler, we place the return address on the stack so that we can resume normal execution. If the interrupt handlers are interrupting each other indefinitively, then we have an unbounded stack (overflow) thus we crash. It’s mine! It came to me! No! Mine! Liar! Give it to me! No! Mine! CRASH

Subset of Context-Free Formalism Characterizations Extensions 4 Checking context-free properties for pushdown automata is undecidable. Let see why bounds on stack size is duable. The problems of bounds on stack size are the followings: ∙ Given a program p and a constant K, will the stack never exceed a size of K? (i.e. never grows beyond K). ∙ Given a program p, what is the highest integer K so that the stack will never exceed its size? If there is an execution where the stack can be unbounded, we get K = ∞. Depending on which class of program we look at, we can have polynomial algorithms for those problems. Stack Boundedness Problem. Exact maximum stack size problem.

Subset of Context-Free Formalism Characterizations Extensions 5 In general, checking a context-free property on a pushdown automata is undecidable. However, there are cases under some restrictions where we can do it. So, what class of properties can be checked on pushdown models? The whole regular class. A bit of context-free… A class « in between » has been defined: visibly pushdown languages (VPL). Regular languages are closed under union and intersection. Context-Free Languages are closed under union but not intersection. VPL are closed under union and intersection. In other words, VPL is a subset of deterministic context-free languages.

Subset of Context-Free Formalism Characterizations Extensions 6 A comparable work has been done on the language of parenthesis: a production of the context-free grammar produces a pair. If we think of this pair of parentheses from the point of view of modeling a program, it can stand for a function call ( and a return ). Knuth showed that this language is closed under union and intersection. This idea of parenthesis was developped by balanced grammars that allow a rule to produce different parantheses, and regular languages. Both balanced grammars and parenthesis languages are a subset of visibly pushdown languages (VPL). One difference with VPL is that a function call might not return, hence we allow unmatched paranthesis.

Subset of Context-Free Formalism Characterizations Extensions 7 Definition of a Visibly Pushdown Automaton To define it, think of the way C uses the stacks (in low level like MIPS). If you read a call, you push something on the stack. If you return, you pop the stack. Otherwise, you are neither calling or returning: it’s just a local action that does not need to use the stack. The stack has a bottom ┴. We have an alphabet Σ c for the calls, Σ r for return, Σ l for local actions. The automatons over words of has: ∙ Set of states Q, initial states Q in and final states Q F ∙ Γ the stack alphabet with the special symbol ┴ ∙ Transitions of 3 types: Q x Σ c x Q x (Γ \ ┴) Q x Σ r x Q x Γ Q x Σ l x Q (q, a, q’, γ) : read a, push γ, transfer control to q’ (q, a, q’, γ) : read a, pop γ, transfer control to q’ (q, a, q’) : read a, transfer control to q’ (nothing with the stack)

Subset of Context-Free Formalism Characterizations Extensions 8 Definition of a Visibly Pushdown Automaton An execution of a Visibly Pushdown Automaton (V PA ) over a sequence of words is called a run. It is represented by (q 0, σ 0 ), …, (q k, σ k ) with the states q and the top of the stack σ. A word is accepted if there is a run on it leading to a final state. (note that we are just asking to end up on a final state: there might still be things on the stack, and we do not care to have it empty or not) A language is a visibly pushdown language (V PL ) if its words are accepted by a V PA.

Subset of Context-Free Formalism Characterizations Extensions 9 Modeling formal verification problems Let say that we have a program where variables have finite types (for example booleans…) with calls of procedures. We create a V PA where a symbol is associated to all transitions of the program, mapping the calls to Σ c, the returns to Σ r and otherwise to Σ l. P is a generator for the langage L(P). The specification is given by the V PL S over the same alphabet and is satisfied if L(P) is a subset of S. All regular properties can be verified this way, plus some non-regular: ∙ Partial Correctness. If we had the property p before a call and if we return, then we have q. ∙ Total Correctness. If we had the property p before a call and we will return, then we have q. ∙ Access control. A call is only allowed if we are in a special function (i.e. P i can be invoked iff P j is in the current stack). ∙ Interrupt Stack Limit. We have property p if bounded stack. Property pProperty q PjPj PiPi ≤ K

Subset of Context-Free Formalism Characterizations Extensions Closure Properties Let L 1 and L 2 be visibly pushdown languages on the same alphabet. For the union, we assume that they are disjoint. We can take the union of states and transitions. For the intersection, the states are created by product. When one automaton pushes γ 1 and the other pushes γ 2, then we push (γ 1, γ 2 ). For the renaiming (i.e. changing each word by a function f), we can apply f to all transitions. Thus, a transition on a becomes on f(a). For the concatenation, we guess the split in a non deterministic way. For the Kleene star, whenever on a final state, we guess to go back to an initial state and we treat the stack as empty (through renaiming). A non deterministic automaton can be determinized with O(2^n²) states.

Subset of Context-Free Formalism Characterizations Extensions 11 Decision Problems Inclusion problem: Given two visibly pushdown automata, is the language generated by one a subset of the language generated by the other? → Take the complement of an automaton, its intersection with the other one and check for emptiness. Universality problem: Given a visibly pushdown automaton M, does it accept all strings? → Let’s take a simple visibly pushdown automaton with one step, accepting all strings. We test if its language is included in the one generated by M. Those problems were not decidable for Pushdown Automata. Here, we ‘can’ do them but it is EXPTIME-complete.

Subset of Context-Free Formalism Characterizations Extensions 12 Regular Tree Languages We have already met trees when speaking of Context Free Languages. Simply by deriving (i.e. looking at the grammar). Here, we will define formally the trees so that we can create them on a string and determined by the language itself rather than the grammar.

Subset of Context-Free Formalism Characterizations Extensions 13 Regular Tree Languages An Σ-labelled binary tree is given by T = (V, λ) where V is a set of 0 and 1’s identifying a node and λ : V → Σ a labelling function. ε Root of the tree 0 1 The identity of the sons is taken from the one of the father and adding 0 or 1 (ε, 0)(ε, 1) (0, 00)(0, 01) T Σ is the set of all possible Σ-labeled trees. We will define a function η that, given a word, produces a tree.

Subset of Context-Free Formalism Characterizations Extensions 14 Regular Tree Languages An Σ-labelled binary tree is given by T = (V, λ) where V is a set of 0 and 1’s identifying a node and λ : V → Σ a labelling function. We will define a function η that, given a word, produces a tree. ∙ For the empty word, we produce the empty tree. ∙ If the word begins by a call: If there is a matching return, let the word be cw 1 rw 2. c η(w 1 ) Otherwise, let the word be cw’. c ∙ If the word begins by a local action of a return: η(rw 2 ) η(w’) a

Subset of Context-Free Formalism Characterizations Extensions 15 Regular Tree Languages An Σ-labelled binary tree is given by T = (V, λ) where V is a set of 0 and 1’s identifying a node and λ : V → Σ a labelling function. We will define a function η that, given a word, produces a tree. ∙ As you notice, a call and its matching return are next to each other. ∙ The tree encoding helps keeping track of the stack. ∙ The trees produced by η are called stack-trees. ∙ The set of stack-trees is the set of trees produced by η on any non- empty word, thus STree = η(Σ+). Those stack-trees can be used as automata.

Subset of Context-Free Formalism Characterizations Extensions 16 Regular Tree Languages An Σ-labelled binary tree is given by T = (V, λ) where V is a set of 0 and 1’s identifying a node and λ : V → Σ a labelling function. We will define a function η that, given a word, produces a tree. Those stack-trees can be used as automata. ∙ A set Q of states and Q in of initial states. ∙ Four types of transitions corresponding to four different nodes: Δ 01 if a node has both left (0) and right children (1) Δ 0 if a node has only a left children Δ 1 if a node has only a right children Δ Ø if a node has no children (i.e. is a leaf) Those automata capture the class of Visibly Pushdown Languages.

Subset of Context-Free Formalism Characterizations Extensions 17 Characterizations by a grammar We have expressed formally a Visibly Pushdown Language and we showed that it could be described by a stack-tree automaton. When we deal with a context-free language, after defining it formally and showing a pushdown automaton, we characterize it by its grammar. V → w non-terminalwhatever you want A Visibly Pushdown Grammar is restricted on the right hand side by the following three possibilities: ∙ X → ε ∙ X → aY aYbZ The non-terminals are in two sets V 0 when a call is matched by a return V 1 when a call is unmatched

Subset of Context-Free Formalism Characterizations Extensions 18 Characterizations by a grammar Given the grammar, how do we build the automaton? A Visibly Pushdown Grammar is restricted on the right hand side by the following three possibilities: ∙ X → ε ∙ X → aY aYbZ ∙ The non-terminals are the states. ∙ For each production X → aY we have a transition (X, a, Y) if a is a local action, (X, a, Y, $) if a is a call and (X, a, ┴, Y) + (X, a, $, Y) if a is a return. ∙ For each production X → aYbZ we have a transition (X, a, Y, (b, Z)).

Subset of Context-Free Formalism Characterizations Extensions 19 Extensions to Infinite Words When a word is infinite, how do we say that we accept it? ∙ An execution (or run) is defined in the same manner by a succession of states and top of the stack. We denote it by ρ. ∙ inf(p) is the states that occur through an infinite execution. ∙ Büchi acceptance condition for a word would be that the final states have to be met at some point : inf(p) ∩ F ≠ Ø. ∙ Muller acceptance condition for a word is that we have to meet only a subset of the final states. If F is the set of possible subets, then inf(p) must belong to F. For infinite words, we use ω. Hence we have the class ω-VPL, and a ω- VPA. Depending to which acceptance condition we use, we can speak of a Muller ω-VPA. We have the same closure properties, but a non-deterministic ω-VPA cannot be determinized (proof by showing a counter-example). A ω-VPL is characterized by infinite stack-trees.

Applications In XML we have. Many things are represented with a XML format. That looks pretty much like balanced parenthesis, or calls and returns! We want to know which documents support some queries. We can use a Visibly Pushdown Automaton to check that! Games are useful to model to model a system and its specifications. Most models use finite graphs, but when we take into consideration the calls then we need to keep track of the stack. It is decidable to check if a visibly pushdown game graph G satisfies requirements expressed in VPL. 20

T H A N K Y O U Articles used for this presentation Visibly Pushdown Languages (Rajeev Alur and P. Madhusudan, 36th ACM Symposium on Theory of Computing, 2004 ) Visibly Pushdown Games (C. Löding, P. Madhusudan, and O. Serre. FSTTCS 2004: Foundations of Software Technology and Theoretical Computer Science, 24th International Conference, Springer, 2004.) Stack Size Analysis for Interrupt-Driven Programs (Chatterjee & Ma & Majumdar & Zhao & Henzinger & Palsberg, Elsevier 2004) D U E T O P O PU L AR D EM A ND S,I D ON O T