Top Banner
Automata and Formal Languages Peter Wood Motivation and Background Automata Grammars Regular Expressions Example of Research Conclusion Automata and Formal Languages Peter Wood Department of Computer Science and Information Systems Birkbeck, University of London [email protected]
56

Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London [email protected]. Automata and

Jul 19, 2018

Download

Documents

dinhnhan
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Automata and Formal Languages

Peter Wood

Department of Computer Science and Information SystemsBirkbeck, University of London

[email protected]

Page 2: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Outline

Motivation and Background

Automata

Grammars

Regular Expressions

Example of Research

Conclusion

Page 3: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Doing Research

I analysing problems/languagesI computability/solvability/decidability

— is there an algorithm?I computational complexity

— is it practical?I expressive power

— are there things that cannot be expressed?I formal languages provide well-studied models

Page 4: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Formal Languages

I given a finite alphabet (set) of symbols Σ— e.g., Σ = {0,1}

I a string is a sequence (concatenation) of symbols— e.g., 0101

I all finite strings over Σ are denoted by Σ∗

— e.g., Σ∗ = {ε,0,1,00,01,10,11, . . .}I language L over Σ is just a subset of Σ∗

— e.g., L1: strings with an even number of 1’s— e.g., L0: strings representing valid Java programs(over an alphabet of all legal symbols in Java)

I are there finite representations for infinite languages?

I yes, grammars (generative) and automata(recognition)

Page 5: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Formal Languages

I given a finite alphabet (set) of symbols Σ— e.g., Σ = {0,1}

I a string is a sequence (concatenation) of symbols— e.g., 0101

I all finite strings over Σ are denoted by Σ∗

— e.g., Σ∗ = {ε,0,1,00,01,10,11, . . .}I language L over Σ is just a subset of Σ∗

— e.g., L1: strings with an even number of 1’s— e.g., L0: strings representing valid Java programs(over an alphabet of all legal symbols in Java)

I are there finite representations for infinite languages?I yes, grammars (generative) and automata

(recognition)

Page 6: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Automata

I device (machine) for recognising (accepting) alanguage

I provide models of computationI automaton comprises states and transitions between

statesI automaton is given a string as inputI automaton M accepts a string w by halting in an

accept/final state, when given w as inputI language L(M) accepted by automaton M is the set

of all strings which M accepts

Page 7: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Types of Automata

I finite state automatonI deterministicI nondeterministic

I pushdown automatonI linear-bounded automatonI Turing machine

Page 8: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Example of a Finite State Automaton

I L1 (strings with an even number of 1’s) can berecognised by the following FSA

I 2 states seven and soddI 4 transitionsI seven is both the initial and final state

seven sodd

10 0

1

I FSA recognises 011:

011

Page 9: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Example of a Finite State Automaton

I L1 (strings with an even number of 1’s) can berecognised by the following FSA

I 2 states seven and soddI 4 transitionsI seven is both the initial and final state

sevenseven sodd

10 0

1

I FSA recognises 011:

011

Page 10: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Example of a Finite State Automaton

I L1 (strings with an even number of 1’s) can berecognised by the following FSA

I 2 states seven and soddI 4 transitionsI seven is both the initial and final state

sevenseven sodd

10 0

1

I FSA recognises 011: 0

11

Page 11: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Example of a Finite State Automaton

I L1 (strings with an even number of 1’s) can berecognised by the following FSA

I 2 states seven and soddI 4 transitionsI seven is both the initial and final state

soddseven sodd

10 0

1

I FSA recognises 011: 01

1

Page 12: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Example of a Finite State Automaton

I L1 (strings with an even number of 1’s) can berecognised by the following FSA

I 2 states seven and soddI 4 transitionsI seven is both the initial and final state

sevenseven sodd

10 0

1

I FSA recognises 011: 011

Page 13: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Grammars

I grammars generate languages using:I symbols from alphabet Σ (called terminals)I set N of nonterminals (one designated as starting)I set P of productions, each of the form

U → V

where U and V are (loosely) strings over Σ ∪ NI a string (sequence of terminals) w is generated by G

if there is a derivation of w using G, starting from thestarting nonterminal of G

I language generated by grammar G, denoted L(G), isthe set of strings which can be derived using G

Page 14: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Grammar Example

I L1 (strings with an even number of 1’s) can begenerated by a grammar with productions

S → ε

S → 0SS → 1TT → 0TT → 1S

where S is the starting nonterminal

I a derivation of 01010 is given by

S ⇒ 0S

⇒ 01T ⇒ 010T ⇒ 0101S ⇒ 01010S ⇒ 01010

Page 15: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Grammar Example

I L1 (strings with an even number of 1’s) can begenerated by a grammar with productions

S → ε

S → 0SS → 1TT → 0TT → 1S

where S is the starting nonterminalI a derivation of 01010 is given by

S ⇒ 0S

⇒ 01T ⇒ 010T ⇒ 0101S ⇒ 01010S ⇒ 01010

Page 16: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Grammar Example

I L1 (strings with an even number of 1’s) can begenerated by a grammar with productions

S → ε

S → 0SS → 1TT → 0TT → 1S

where S is the starting nonterminalI a derivation of 01010 is given by

S ⇒ 0S ⇒ 01T

⇒ 010T ⇒ 0101S ⇒ 01010S ⇒ 01010

Page 17: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Grammar Example

I L1 (strings with an even number of 1’s) can begenerated by a grammar with productions

S → ε

S → 0SS → 1TT → 0TT → 1S

where S is the starting nonterminalI a derivation of 01010 is given by

S ⇒ 0S ⇒ 01T ⇒ 010T

⇒ 0101S ⇒ 01010S ⇒ 01010

Page 18: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Grammar Example

I L1 (strings with an even number of 1’s) can begenerated by a grammar with productions

S → ε

S → 0SS → 1TT → 0TT → 1S

where S is the starting nonterminalI a derivation of 01010 is given by

S ⇒ 0S ⇒ 01T ⇒ 010T ⇒ 0101S

⇒ 01010S ⇒ 01010

Page 19: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Grammar Example

I L1 (strings with an even number of 1’s) can begenerated by a grammar with productions

S → ε

S → 0SS → 1TT → 0TT → 1S

where S is the starting nonterminalI a derivation of 01010 is given by

S ⇒ 0S ⇒ 01T ⇒ 010T ⇒ 0101S ⇒ 01010S

⇒ 01010

Page 20: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Grammar Example

I L1 (strings with an even number of 1’s) can begenerated by a grammar with productions

S → ε

S → 0SS → 1TT → 0TT → 1S

where S is the starting nonterminalI a derivation of 01010 is given by

S ⇒ 0S ⇒ 01T ⇒ 010T ⇒ 0101S ⇒ 01010S ⇒ 01010

Page 21: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Uses of Grammars

I to specify syntax of programming languagesI in natural language understandingI in pattern recognitionI to specify schemas (types) for tree-structured data,

e.g., XML, JSONI in data compressionI . . .

Page 22: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Hierarchy of Grammars and Languages

I restrictions on productions give different types ofgrammars

I regular (type 3)I context-free (type 2)I context-sensitive (type 1)I phrase-structure (type 0)

I for context-free, e.g., left side must be singlenonterminal

I no restrictions for phrase-structureI language is of type i iff there is a grammar of type i

which generates it

Page 23: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Examples of Language Hierarchy

I varying expressive powerI regular ⊂ context-free ⊂ context-sensitive ⊂

phrase-structure

I L1 (strings over {0,1} with an even number of 1’s) isregular

I L2 = {0n1n | n ≥ 0} is context-free, but not regularI L3 = {ww | w ∈ {0,1}∗} is context-sensitive, but not

context-freeI there exists a phrase-structure (recursive) language

which is not context-sensitive

Page 24: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Examples of Language Hierarchy

I varying expressive powerI regular ⊂ context-free ⊂ context-sensitive ⊂

phrase-structureI L1 (strings over {0,1} with an even number of 1’s) is

regular

I L2 = {0n1n | n ≥ 0} is context-free, but not regularI L3 = {ww | w ∈ {0,1}∗} is context-sensitive, but not

context-freeI there exists a phrase-structure (recursive) language

which is not context-sensitive

Page 25: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Examples of Language Hierarchy

I varying expressive powerI regular ⊂ context-free ⊂ context-sensitive ⊂

phrase-structureI L1 (strings over {0,1} with an even number of 1’s) is

regularI L2 = {0n1n | n ≥ 0} is context-free, but not regular

I L3 = {ww | w ∈ {0,1}∗} is context-sensitive, but notcontext-free

I there exists a phrase-structure (recursive) languagewhich is not context-sensitive

Page 26: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Examples of Language Hierarchy

I varying expressive powerI regular ⊂ context-free ⊂ context-sensitive ⊂

phrase-structureI L1 (strings over {0,1} with an even number of 1’s) is

regularI L2 = {0n1n | n ≥ 0} is context-free, but not regularI L3 = {ww | w ∈ {0,1}∗} is context-sensitive, but not

context-free

I there exists a phrase-structure (recursive) languagewhich is not context-sensitive

Page 27: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Examples of Language Hierarchy

I varying expressive powerI regular ⊂ context-free ⊂ context-sensitive ⊂

phrase-structureI L1 (strings over {0,1} with an even number of 1’s) is

regularI L2 = {0n1n | n ≥ 0} is context-free, but not regularI L3 = {ww | w ∈ {0,1}∗} is context-sensitive, but not

context-freeI there exists a phrase-structure (recursive) language

which is not context-sensitive

Page 28: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Complexity of Grammar Problems

Problem Type3 2 1 0

Is w ∈ L(G)? P P PSPACE UIs L(G) empty? P P U UIs L(G1) ≡ L(G2)? PSPACE U U U

I P: decidable in polynomial timeI PSPACE: decidable in polynomial space (and

complete for PSPACE: at least as hard asNP-complete)

I U: undecidableI so type of grammar has significant effect on

complexity

Page 29: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Relationships between Languages andAutomata

A language is

regularcontext-free

context-sensitivephrase-structure

iff

acceptedby

finite-statepushdown

linear-boundedTuring machine

Page 30: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Regular Expressions

I algebraic notation for denoting regular languagesI use ◦ (concatenation), ∪ (union) and ∗ (closure)

operatorsI L1 denoted by RE 0∗ ∪ (0∗ ◦ 1 ◦ 0∗ ◦ 1 ◦ 0∗)∗

I given RE R, the set of strings it denotes is L(R)

I pattern matching in textI query languages for XML or RDF

Page 31: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Using Regular Expressions to Query GraphsGraphs (networks) are widely used for representing data

I social networksI transportation and other networksI geographical informationI semistructured data (e.g., XML and JSON)I (hyper)document structureI semantic associations in criminal investigationsI bibliographic citation analysisI pathways in biological processesI knowledge representation (e.g. semantic web)I program analysisI workflow systemsI data provenanceI . . .

Page 32: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Using Regular Expressions to Query Graphs

I (my PhD thesis!)I usually regular expressions used for string searchI consider data represented by a directed graph of

labelled nodes and labelled edgesI regular expressions can express paths we are

interested inI sequence of edge labels rather than sequence of

symbols (characters)I a query using regular expression R can ask for all

nodes connected by a path whose concatenation ofedge labels is in L(R)

Page 33: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Graph G (where nodes represent people and places):

a

b

c

SA

CT

UK

citizenOf

bornIn

livesIn

bornIn

locatedIn

Page 34: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Regular expression

R = citizenOf ∪ ((bornIn ∪ livesIn) ◦ locatedIn∗)

asks for paths of edges between a person x and a placey such that

I x is a citizenOf y , orI x is bornIn or livesIn y , orI x is bornIn or livesIn a place that is locatedIn y

Page 35: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Regular path query evaluation

I REGULAR PATH PROBLEM

Given graph G, pair of nodes x and y and regularexpression R, is there a path from x to y satisfyingR?

I algorithm:I construct a nondeterministic finite automaton (NFA)

M accepting L(R)I assume M has initial state s0 and final state sfI consider G as an NFA with initial state x and final

state yI form the “intersection” (or “product”) I of G and MI check if there is a path from (x , s0) to (y , sf )

I Each step can be done in PTIME, so REGULAR PATH

PROBLEM has PTIME complexity

Page 36: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

NFA M for R = citizenOf ∪ ((bornIn ∪ livesIn) ◦locatedIn∗)

s0

sf

s1

bornIn

livesIn

citizenOf ε

locatedIn

Page 37: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Intersection of G and M

a, s0

b, s0

c, s0

SA, s1

CT , s1

UK , s1

SA, sf

CT , sf

UK , sf

citizenOf

bornIn

livesIn

bornIn

locatedIn

ε

ε

ε

Page 38: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Intersection of G and M

a, s0 SA, sfa, s0

b, s0

c, s0

SA, s1

CT , s1

UK , s1

SA, sf

CT , sf

UK , sf

citizenOf

bornIn

livesIn

bornIn

locatedIn

ε

ε

ε

Page 39: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Intersection of G and M

b, s0

SA, sfa, s0

b, s0

c, s0

SA, s1

CT , s1

UK , s1

SA, sf

CT , sf

UK , sf

citizenOf

bornIn

livesIn

bornIn

locatedIn

ε

ε

ε

Page 40: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Intersection of G and M

b, s0 CT , sf

a, s0

b, s0

c, s0

SA, s1

CT , s1

UK , s1

SA, sf

CT , sf

UK , sf

citizenOf

bornIn

livesIn

bornIn

locatedIn

ε

ε

ε

Page 41: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Intersection of G and M

b, s0

UK , sf

a, s0

b, s0

c, s0

SA, s1

CT , s1

UK , s1

SA, sf

CT , sf

UK , sf

citizenOf

bornIn

livesIn

bornIn

locatedIn

ε

ε

ε

Page 42: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Intersection of G and M

c, s0 UK , sf

a, s0

b, s0

c, s0

SA, s1

CT , s1

UK , s1

SA, sf

CT , sf

UK , sf

citizenOf

bornIn

livesIn

bornIn

locatedIn

ε

ε

ε

Page 43: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Regular simple path queries

I path p is simple if no node is repeated on pI REGULAR SIMPLE PATH PROBLEM

Given graph G, pair of nodes x and y and regularexpression R, is there a simple path from x to ysatisfying R?

I REGULAR SIMPLE PATH PROBLEM is NP-complete[Mendelzon & Wood (1989)]

I there can be a path from x to y satisfying R but nosimple path satisfying R, e.g., R = (c ◦ d)∗

a bc

d

Page 44: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Regular simple path queries

I path p is simple if no node is repeated on pI REGULAR SIMPLE PATH PROBLEM

Given graph G, pair of nodes x and y and regularexpression R, is there a simple path from x to ysatisfying R?

I REGULAR SIMPLE PATH PROBLEM is NP-complete[Mendelzon & Wood (1989)]

I there can be a path from x to y satisfying R but nosimple path satisfying R, e.g., R = (c ◦ d)∗

a bc

d

Page 45: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Regular simple path queries

I path p is simple if no node is repeated on pI REGULAR SIMPLE PATH PROBLEM

Given graph G, pair of nodes x and y and regularexpression R, is there a simple path from x to ysatisfying R?

I REGULAR SIMPLE PATH PROBLEM is NP-complete[Mendelzon & Wood (1989)]

I there can be a path from x to y satisfying R but nosimple path satisfying R, e.g., R = (c ◦ d)∗

a bc

d

Page 46: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Approaches to deal with this problem

I what causes the problem?

I the presence of cyclesI obvious first step is to consider graphs without

cycles—DAGsI then might look at restricted forms of REs—we

looked at those corresponding to languages closedunder abbreviations

I then one might consider a combination of graphs andREs—we looked at graphs whose cycle structuredoes not conflict with the RE

I finally showed that conflict-freedom is ageneralisation:

I no RE conflicts with any DAGI an RE closed under abbreviations never conflicts

with any graph

Page 47: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Approaches to deal with this problem

I what causes the problem?I the presence of cycles

I obvious first step is to consider graphs withoutcycles—DAGs

I then might look at restricted forms of REs—welooked at those corresponding to languages closedunder abbreviations

I then one might consider a combination of graphs andREs—we looked at graphs whose cycle structuredoes not conflict with the RE

I finally showed that conflict-freedom is ageneralisation:

I no RE conflicts with any DAGI an RE closed under abbreviations never conflicts

with any graph

Page 48: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Approaches to deal with this problem

I what causes the problem?I the presence of cyclesI obvious first step is to consider graphs without

cycles—DAGs

I then might look at restricted forms of REs—welooked at those corresponding to languages closedunder abbreviations

I then one might consider a combination of graphs andREs—we looked at graphs whose cycle structuredoes not conflict with the RE

I finally showed that conflict-freedom is ageneralisation:

I no RE conflicts with any DAGI an RE closed under abbreviations never conflicts

with any graph

Page 49: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Approaches to deal with this problem

I what causes the problem?I the presence of cyclesI obvious first step is to consider graphs without

cycles—DAGsI then might look at restricted forms of REs—we

looked at those corresponding to languages closedunder abbreviations

I then one might consider a combination of graphs andREs—we looked at graphs whose cycle structuredoes not conflict with the RE

I finally showed that conflict-freedom is ageneralisation:

I no RE conflicts with any DAGI an RE closed under abbreviations never conflicts

with any graph

Page 50: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Approaches to deal with this problem

I what causes the problem?I the presence of cyclesI obvious first step is to consider graphs without

cycles—DAGsI then might look at restricted forms of REs—we

looked at those corresponding to languages closedunder abbreviations

I then one might consider a combination of graphs andREs—we looked at graphs whose cycle structuredoes not conflict with the RE

I finally showed that conflict-freedom is ageneralisation:

I no RE conflicts with any DAGI an RE closed under abbreviations never conflicts

with any graph

Page 51: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Approaches to deal with this problem

I what causes the problem?I the presence of cyclesI obvious first step is to consider graphs without

cycles—DAGsI then might look at restricted forms of REs—we

looked at those corresponding to languages closedunder abbreviations

I then one might consider a combination of graphs andREs—we looked at graphs whose cycle structuredoes not conflict with the RE

I finally showed that conflict-freedom is ageneralisation:

I no RE conflicts with any DAGI an RE closed under abbreviations never conflicts

with any graph

Page 52: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Other approaches

I in general, may also run experiments to measureactual running times

I may also develop approximation algorithmsI can sometimes find a PTIME algorithm with a

performance guarantee (e.g. for TSP, finds a tour atmost twice the optimal distance)

I other times this problem itself is NP-hardI use heuristic approaches

Page 53: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Other approaches

I in general, may also run experiments to measureactual running times

I may also develop approximation algorithmsI can sometimes find a PTIME algorithm with a

performance guarantee (e.g. for TSP, finds a tour atmost twice the optimal distance)

I other times this problem itself is NP-hard

I use heuristic approaches

Page 54: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Other approaches

I in general, may also run experiments to measureactual running times

I may also develop approximation algorithmsI can sometimes find a PTIME algorithm with a

performance guarantee (e.g. for TSP, finds a tour atmost twice the optimal distance)

I other times this problem itself is NP-hardI use heuristic approaches

Page 55: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

Conclusion

I is my system/language more powerful than others?I is my system/language more efficient than others?I expressive power or computational complexity can

be studied by relating them toI formal language theory: languages, grammars,

automata, . . .I tradeoff between expressive power and

computational complexityI consider restrictions of difficult problems or giving up

exact solutions

Page 56: Automata and Formal Languages - Home - Department of ...ptw/research-methods.pdf · Automata and Formal Languages ... Birkbeck, University of London ptw@dcs.bbk.ac.uk. Automata and

Automata andFormal

Languages

Peter Wood

Motivation andBackground

Automata

Grammars

RegularExpressions

Example ofResearch

Conclusion

References

I Aho, Hopcroft and Ullman, “The Design and Analysisof Computer Algorithms,” Addison-Wesley, 1974

I Garey and Johnson, “Computers and Intractability: AGuide to the Theory of NP-Completeness,” W. H.Freeman and Company, 1979

I Lewis and Papadimitriou, “Elements of the Theory ofComputation,” Prentice-Hall, 1981

I Mendelzon and Wood, “Finding Regular SimplePaths in Graph Databases,” SIAM J. Computing, Vol.24. No. 6, 1995, pp. 1235–1258

I Sipser, “Introduction to the Theory of Computation,”PWS Publishing Company, 1997