G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1....

115
G52MAL Machines and Their Languages Lecture 1 Administrative Details and Introduction Henrik Nilsson University of Nottingham G52MALMachines and Their LanguagesLecture 1 – p.1/37

Transcript of G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1....

Page 1: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

G52MAL

Machines and Their LanguagesLecture 1

Administrative Details and Introduction

Henrik Nilsson

University of Nottingham

G52MALMachines and Their LanguagesLecture 1 – p.1/37

Page 2: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Finding People and Information

• Henrik NilssonRoom A08

• Moodle

• Main module web page:www.cs.nott.ac.uk/~nhn/G52MAL

G52MALMachines and Their LanguagesLecture 1 – p.2/37

Page 3: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Aims of the Course

G52MALMachines and Their LanguagesLecture 1 – p.3/37

Page 4: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Aims of the Course

• To familiarize you with key Computer Scienceconcepts in central areas like

- Automata Theory

- Formal Languages

- Models of Computation

- Complexity Theory

G52MALMachines and Their LanguagesLecture 1 – p.3/37

Page 5: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Aims of the Course

• To familiarize you with key Computer Scienceconcepts in central areas like

- Automata Theory

- Formal Languages

- Models of Computation

- Complexity Theory

• To equip you with tools with wide applicabilityin the fields of CS and IT.

G52MALMachines and Their LanguagesLecture 1 – p.3/37

Page 6: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Organization (1)

• Lectures:

- Two 1 h lectures per week.

- Detailed but somewhat tentative scheduleavailable on the module web page.

G52MALMachines and Their LanguagesLecture 1 – p.4/37

Page 7: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Organization (1)

• Lectures:

- Two 1 h lectures per week.

- Detailed but somewhat tentative scheduleavailable on the module web page.

• Coursework:

- 4 Bi-weekly problem sets.

- Made available via the module web page.

- Best 3 counts.

- Deadlines: 5/2, 19/2, 4/3, 16/3 (Wed.!).

G52MALMachines and Their LanguagesLecture 1 – p.4/37

Page 8: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Organization (2)

• Assessment:

- Coursework, 25 %

- 2 hour written examination, 75 %

G52MALMachines and Their LanguagesLecture 1 – p.5/37

Page 9: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Organization (2)

• Assessment:

- Coursework, 25 %

- 2 hour written examination, 75 %

• However, resits are by 100 % writtenexamination (standard School policy)

G52MALMachines and Their LanguagesLecture 1 – p.5/37

Page 10: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Literature (1)

• Main reference: Hopcroft, Motwani, & Ullman.Introduction to Automata Theory, Languages,and Computation, 2nd edition, AddisonWesley, 2001. (Or 3rd edition, 2006.)

G52MALMachines and Their LanguagesLecture 1 – p.6/37

Page 11: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Literature (1)

• Main reference: Hopcroft, Motwani, & Ullman.Introduction to Automata Theory, Languages,and Computation, 2nd edition, AddisonWesley, 2001. (Or 3rd edition, 2006.)

• Alternative/complement: Linz. An Introductionto Formal Languages and Automata, 4thedition, Jones & Bartlett Publishers, 2006.

G52MALMachines and Their LanguagesLecture 1 – p.6/37

Page 12: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Literature (1)

• Main reference: Hopcroft, Motwani, & Ullman.Introduction to Automata Theory, Languages,and Computation, 2nd edition, AddisonWesley, 2001. (Or 3rd edition, 2006.)

• Alternative/complement: Linz. An Introductionto Formal Languages and Automata, 4thedition, Jones & Bartlett Publishers, 2006.

• Dr. Thorsten Altenkirch’s and my G52MALlecture notes.(Available via the G52MAL module page.)

G52MALMachines and Their LanguagesLecture 1 – p.6/37

Page 13: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Literature (2)

• Supplementary material; e.g., slides, sampleprogram code.(Available via the G52MAL module page.)

G52MALMachines and Their LanguagesLecture 1 – p.7/37

Page 14: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Literature (2)

• Supplementary material; e.g., slides, sampleprogram code.(Available via the G52MAL module page.)

• Your own notes from the lectures!

G52MALMachines and Their LanguagesLecture 1 – p.7/37

Page 15: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Literature (3)

G52MALMachines and Their LanguagesLecture 1 – p.8/37

Page 16: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Content

G52MALMachines and Their LanguagesLecture 1 – p.9/37

Page 17: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Content

1. Mathematical models of computation, such as:

- Finite automata

- Pushdown automata

- Turing machines

G52MALMachines and Their LanguagesLecture 1 – p.9/37

Page 18: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Content

1. Mathematical models of computation, such as:

- Finite automata

- Pushdown automata

- Turing machines

2. How to specify formal languages?

- Regular expressions

- Context free grammars

- Context sensitive grammars

G52MALMachines and Their LanguagesLecture 1 – p.9/37

Page 19: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Content

1. Mathematical models of computation, such as:

- Finite automata

- Pushdown automata

- Turing machines

2. How to specify formal languages?

- Regular expressions

- Context free grammars

- Context sensitive grammars

3. The relation between 1 and 2.

G52MALMachines and Their LanguagesLecture 1 – p.9/37

Page 20: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Content

1. Mathematical models of computation, such as:

- Finite automata

- Pushdown automata

- Turing machines

2. How to specify formal languages?

- Regular expressions

- Context free grammars

- Context sensitive grammars

3. The relation between 1 and 2.

4. Applications: Scanning and Parsing

G52MALMachines and Their LanguagesLecture 1 – p.9/37

Page 21: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (1)

Formal languages and automata have lots ofapplications in CS and IT. Some examples:

G52MALMachines and Their LanguagesLecture 1 – p.10/37

Page 22: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (1)

Formal languages and automata have lots ofapplications in CS and IT. Some examples:

• Specification of programming languages

G52MALMachines and Their LanguagesLecture 1 – p.10/37

Page 23: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (1)

Formal languages and automata have lots ofapplications in CS and IT. Some examples:

• Specification of programming languages

• Implementation of programming languageprocessors(G52MAL feeds into G53CMP)

G52MALMachines and Their LanguagesLecture 1 – p.10/37

Page 24: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (1)

Formal languages and automata have lots ofapplications in CS and IT. Some examples:

• Specification of programming languages

• Implementation of programming languageprocessors(G52MAL feeds into G53CMP)

• XML and DTDs (Document Type Definition)

G52MALMachines and Their LanguagesLecture 1 – p.10/37

Page 25: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (1)

Formal languages and automata have lots ofapplications in CS and IT. Some examples:

• Specification of programming languages

• Implementation of programming languageprocessors(G52MAL feeds into G53CMP)

• XML and DTDs (Document Type Definition)

• Finding words and patterns in large bodies oftext, e.g. in web pages.

G52MALMachines and Their LanguagesLecture 1 – p.10/37

Page 26: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (1)

Formal languages and automata have lots ofapplications in CS and IT. Some examples:

• Specification of programming languages

• Implementation of programming languageprocessors(G52MAL feeds into G53CMP)

• XML and DTDs (Document Type Definition)

• Finding words and patterns in large bodies oftext, e.g. in web pages.

• Verification of systems with finite number ofstates, e.g. communication protocols.

G52MALMachines and Their LanguagesLecture 1 – p.10/37

Page 27: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (2)

As a concrete example, a job opening from sometime ago:

The Strats team at Standard Chartered ishiring a developer for a 1 year contractingrole in London.The role is to develop and extend ourparsing and validation library for FpML,using the FpML Haskell library to parseand build financial product data into ourinternal Haskell data types.

https://donsbot.wordpress.com/2015/01/28/G52MALMachines and Their LanguagesLecture 1 – p.11/37

Page 28: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (3)

Automata are essential for the study of the limitsof computation. Deep theoretical questionswith big practical implications. Two key issues:

G52MALMachines and Their LanguagesLecture 1 – p.12/37

Page 29: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (3)

Automata are essential for the study of the limitsof computation. Deep theoretical questionswith big practical implications. Two key issues:

• What can a computer do at all ?

G52MALMachines and Their LanguagesLecture 1 – p.12/37

Page 30: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (3)

Automata are essential for the study of the limitsof computation. Deep theoretical questionswith big practical implications. Two key issues:

• What can a computer do at all ?Decidability

G52MALMachines and Their LanguagesLecture 1 – p.12/37

Page 31: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (3)

Automata are essential for the study of the limitsof computation. Deep theoretical questionswith big practical implications. Two key issues:

• What can a computer do at all ?Decidability

• What can a computer do efficiently ?

G52MALMachines and Their LanguagesLecture 1 – p.12/37

Page 32: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (3)

Automata are essential for the study of the limitsof computation. Deep theoretical questionswith big practical implications. Two key issues:

• What can a computer do at all ?Decidability

• What can a computer do efficiently ?Time and space Complexity

G52MALMachines and Their LanguagesLecture 1 – p.12/37

Page 33: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (4)

G52MALMachines and Their LanguagesLecture 1 – p.13/37

Page 34: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (4)

• Imagine you’re the lead developer for a newweb browser. It obviously needs the capabilityto run JavaScript.

G52MALMachines and Their LanguagesLecture 1 – p.13/37

Page 35: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (4)

• Imagine you’re the lead developer for a newweb browser. It obviously needs the capabilityto run JavaScript.

• To make your product stand out from thecompetition, your boss proposes youimplement a termination check: anynon-terminating JavaScript programs canthen be rejected, without being run.

G52MALMachines and Their LanguagesLecture 1 – p.13/37

Page 36: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (4)

• Imagine you’re the lead developer for a newweb browser. It obviously needs the capabilityto run JavaScript.

• To make your product stand out from thecompetition, your boss proposes youimplement a termination check: anynon-terminating JavaScript programs canthen be rejected, without being run.

• If you succeed, your salary will be doubled.But if you fail, you’d have to look for a new job.

G52MALMachines and Their LanguagesLecture 1 – p.13/37

Page 37: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Why Study All This? (4)

• Imagine you’re the lead developer for a newweb browser. It obviously needs the capabilityto run JavaScript.

• To make your product stand out from thecompetition, your boss proposes youimplement a termination check: anynon-terminating JavaScript programs canthen be rejected, without being run.

• If you succeed, your salary will be doubled.But if you fail, you’d have to look for a new job.

• Should you accept?G52MALMachines and Their LanguagesLecture 1 – p.13/37

Page 38: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Example: The Halting Problem (1)

Consider the following program. Does itterminate for all values of n ≥ 1?

while (n > 1) {

if even(n) {

n = n / 2;

} else {

n = n * 3 + 1;

}

}

G52MALMachines and Their LanguagesLecture 1 – p.14/37

Page 39: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Example: The Halting Problem (2)

Not as easy to answer as it might first seem.

G52MALMachines and Their LanguagesLecture 1 – p.15/37

Page 40: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Example: The Halting Problem (2)

Not as easy to answer as it might first seem.

Say we start with n = 7, for example:

7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5,16, 8, 4, 2, 1

G52MALMachines and Their LanguagesLecture 1 – p.15/37

Page 41: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Example: The Halting Problem (2)

Not as easy to answer as it might first seem.

Say we start with n = 7, for example:

7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5,16, 8, 4, 2, 1

The sequence involved is known as thehailstone sequence and Collatz conjecturesays that the number 1 will always be reached.

G52MALMachines and Their LanguagesLecture 1 – p.15/37

Page 42: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Example: The Halting Problem (2)

Not as easy to answer as it might first seem.

Say we start with n = 7, for example:

7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5,16, 8, 4, 2, 1

The sequence involved is known as thehailstone sequence and Collatz conjecturesays that the number 1 will always be reached.

In fact, for all numbers that have been tried(up to 260!), it does terminate . . .

G52MALMachines and Their LanguagesLecture 1 – p.15/37

Page 43: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Example: The Halting Problem (2)

Not as easy to answer as it might first seem.

Say we start with n = 7, for example:

7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5,16, 8, 4, 2, 1

The sequence involved is known as thehailstone sequence and Collatz conjecturesays that the number 1 will always be reached.

In fact, for all numbers that have been tried(up to 260!), it does terminate . . .

. . . but so far, no proof! (See e.g. Wikipedia.)G52MALMachines and Their LanguagesLecture 1 – p.15/37

Page 44: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Example: The Halting Problem (3)

The following important decidability result shouldthen perhaps not come as a total surprise:

G52MALMachines and Their LanguagesLecture 1 – p.16/37

Page 45: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Example: The Halting Problem (3)

The following important decidability result shouldthen perhaps not come as a total surprise:

It is impossible to write a program thatdecides if another, arbitrary, programterminates (halts) or not.

G52MALMachines and Their LanguagesLecture 1 – p.16/37

Page 46: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Example: The Halting Problem (3)

The following important decidability result shouldthen perhaps not come as a total surprise:

It is impossible to write a program thatdecides if another, arbitrary, programterminates (halts) or not.

What might be surprising is that it is possible toprove such a result. This was first done by theBritish mathematician Alan Turing using TuringMachines.

G52MALMachines and Their LanguagesLecture 1 – p.16/37

Page 47: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Alan Turing (1)

Alan Turing (1912–1954):

G52MALMachines and Their LanguagesLecture 1 – p.17/37

Page 48: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Alan Turing (1)

Alan Turing (1912–1954):

• Introduced an abstract model of computation,Turing Machines, to give a precice definitionof what problems that can be solved by acomputer.

G52MALMachines and Their LanguagesLecture 1 – p.17/37

Page 49: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Alan Turing (1)

Alan Turing (1912–1954):

• Introduced an abstract model of computation,Turing Machines, to give a precice definitionof what problems that can be solved by acomputer.

• Instrumental in the success of British codebreaking efforts during WWII.

G52MALMachines and Their LanguagesLecture 1 – p.17/37

Page 50: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Alan Turing (2)

G52MALMachines and Their LanguagesLecture 1 – p.18/37

Page 51: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Noam Chomsky (1)

Noam Chomsky (1928–):

G52MALMachines and Their LanguagesLecture 1 – p.19/37

Page 52: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Noam Chomsky (1)

Noam Chomsky (1928–):

• American linguist who introduced ContextFree Grammars in an attempt to describenatural languages formally.

G52MALMachines and Their LanguagesLecture 1 – p.19/37

Page 53: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Noam Chomsky (1)

Noam Chomsky (1928–):

• American linguist who introduced ContextFree Grammars in an attempt to describenatural languages formally.

• Also introduced the Chomsky Hierarchywhich classifies grammars and languagesand their descriptive power.

G52MALMachines and Their LanguagesLecture 1 – p.19/37

Page 54: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Noam Chomsky (2)

G52MALMachines and Their LanguagesLecture 1 – p.20/37

Page 55: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

The Chomsky Hierarchy

languages

finite automata

pushdown automata

Type 2 or context free

Type 3 orregular languages

Type 1 or context sensitive languages

Decidable languagesTuring machines

Type 0 or recursively enumerable languages

All languages

G52MALMachines and Their LanguagesLecture 1 – p.21/37

Page 56: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages

The terms language and word are used in astrict technical sense in this course:

G52MALMachines and Their LanguagesLecture 1 – p.22/37

Page 57: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages

The terms language and word are used in astrict technical sense in this course:

• A language is a (possibly infinite) set ofwords.

G52MALMachines and Their LanguagesLecture 1 – p.22/37

Page 58: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages

The terms language and word are used in astrict technical sense in this course:

• A language is a (possibly infinite) set ofwords.

• A word is a finite sequence (or string) ofsymbols.

G52MALMachines and Their LanguagesLecture 1 – p.22/37

Page 59: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages

The terms language and word are used in astrict technical sense in this course:

• A language is a (possibly infinite) set ofwords.

• A word is a finite sequence (or string) ofsymbols.

ǫ denotes the empty word, the sequence of zerosymbols.

G52MALMachines and Their LanguagesLecture 1 – p.22/37

Page 60: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages

The terms language and word are used in astrict technical sense in this course:

• A language is a (possibly infinite) set ofwords.

• A word is a finite sequence (or string) ofsymbols.

ǫ denotes the empty word, the sequence of zerosymbols.

The term string is often used interchangeablywith the term word.

G52MALMachines and Their LanguagesLecture 1 – p.22/37

Page 61: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Symbols and Alphabets

What is a symbol, then?

G52MALMachines and Their LanguagesLecture 1 – p.23/37

Page 62: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Symbols and Alphabets

What is a symbol, then?

Anything, but it has to come from an alphabet Σwhich is a finite set.

G52MALMachines and Their LanguagesLecture 1 – p.23/37

Page 63: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Symbols and Alphabets

What is a symbol, then?

Anything, but it has to come from an alphabet Σwhich is a finite set.

A common (and important) instance isΣ = {0, 1}.

G52MALMachines and Their LanguagesLecture 1 – p.23/37

Page 64: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Symbols and Alphabets

What is a symbol, then?

Anything, but it has to come from an alphabet Σwhich is a finite set.

A common (and important) instance isΣ = {0, 1}.

ǫ, the empty word, is never a symbol of analphabet.

G52MALMachines and Their LanguagesLecture 1 – p.23/37

Page 65: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages: Examples

alphabet Σ = {a, b}

words ?

G52MALMachines and Their LanguagesLecture 1 – p.24/37

Page 66: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages: Examples

alphabet Σ = {a, b}

words ǫ, a, b, aa, ab, ba, bb,

G52MALMachines and Their LanguagesLecture 1 – p.24/37

Page 67: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages: Examples

alphabet Σ = {a, b}

words ǫ, a, b, aa, ab, ba, bb,

aaa, aab, aba, abb, baa, bab, . . .

G52MALMachines and Their LanguagesLecture 1 – p.24/37

Page 68: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages: Examples

alphabet Σ = {a, b}

words ǫ, a, b, aa, ab, ba, bb,

aaa, aab, aba, abb, baa, bab, . . .

languages ?

G52MALMachines and Their LanguagesLecture 1 – p.24/37

Page 69: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages: Examples

alphabet Σ = {a, b}

words ǫ, a, b, aa, ab, ba, bb,

aaa, aab, aba, abb, baa, bab, . . .

languages ∅, {ǫ}, {a}, {b}, {a, aa},

G52MALMachines and Their LanguagesLecture 1 – p.24/37

Page 70: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages: Examples

alphabet Σ = {a, b}

words ǫ, a, b, aa, ab, ba, bb,

aaa, aab, aba, abb, baa, bab, . . .

languages ∅, {ǫ}, {a}, {b}, {a, aa},

{ǫ, a, aa, aaa},

G52MALMachines and Their LanguagesLecture 1 – p.24/37

Page 71: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages: Examples

alphabet Σ = {a, b}

words ǫ, a, b, aa, ab, ba, bb,

aaa, aab, aba, abb, baa, bab, . . .

languages ∅, {ǫ}, {a}, {b}, {a, aa},

{ǫ, a, aa, aaa},

{an|n ≥ 0},

G52MALMachines and Their LanguagesLecture 1 – p.24/37

Page 72: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages: Examples

alphabet Σ = {a, b}

words ǫ, a, b, aa, ab, ba, bb,

aaa, aab, aba, abb, baa, bab, . . .

languages ∅, {ǫ}, {a}, {b}, {a, aa},

{ǫ, a, aa, aaa},

{an|n ≥ 0},

{anbn|n ≥ 0, n even}

G52MALMachines and Their LanguagesLecture 1 – p.24/37

Page 73: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages: Examples

alphabet Σ = {a, b}

words ǫ, a, b, aa, ab, ba, bb,

aaa, aab, aba, abb, baa, bab, . . .

languages ∅, {ǫ}, {a}, {b}, {a, aa},

{ǫ, a, aa, aaa},

{an|n ≥ 0},

{anbn|n ≥ 0, n even}

Note the distinction between ǫ, ∅, and {ǫ}!

G52MALMachines and Their LanguagesLecture 1 – p.24/37

Page 74: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Exercises

• Is the set of natural numbers, N, a possiblealphabet? Why/why not?

G52MALMachines and Their LanguagesLecture 1 – p.25/37

Page 75: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Exercises

• Is the set of natural numbers, N, a possiblealphabet? Why/why not?

• What about the set of all natural numberssmaller than some given number n?

G52MALMachines and Their LanguagesLecture 1 – p.25/37

Page 76: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Exercises

• Is the set of natural numbers, N, a possiblealphabet? Why/why not?

• What about the set of all natural numberssmaller than some given number n?

• Suggest an alphabet of a handful of drinkingredients. What are the symbols of youralphabet, and how many are they?

G52MALMachines and Their LanguagesLecture 1 – p.25/37

Page 77: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Exercises

• Is the set of natural numbers, N, a possiblealphabet? Why/why not?

• What about the set of all natural numberssmaller than some given number n?

• Suggest an alphabet of a handful of drinkingredients. What are the symbols of youralphabet, and how many are they?

• List some words over your alphabet?

G52MALMachines and Their LanguagesLecture 1 – p.25/37

Page 78: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Exercises

• Is the set of natural numbers, N, a possiblealphabet? Why/why not?

• What about the set of all natural numberssmaller than some given number n?

• Suggest an alphabet of a handful of drinkingredients. What are the symbols of youralphabet, and how many are they?

• List some words over your alphabet?

• What might an interesting language over youralphabet be? Does your language include allpossible words over your alphabet?

G52MALMachines and Their LanguagesLecture 1 – p.25/37

Page 79: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

All Words Over an Alphabet (1)

Given an alphabet Σ we define the set Σ∗ as setof words (or sequences) over Σ:

• The empty word ǫ ∈ Σ∗.

• given a symbol x ∈ Σ and a word w ∈ Σ∗,xw ∈ Σ∗.

• These are all elements in Σ∗.

This is called an inductive definition.

G52MALMachines and Their LanguagesLecture 1 – p.26/37

Page 80: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

All Words Over an Alphabet (1)

Given an alphabet Σ we define the set Σ∗ as setof words (or sequences) over Σ:

• The empty word ǫ ∈ Σ∗.

• given a symbol x ∈ Σ and a word w ∈ Σ∗,xw ∈ Σ∗.

• These are all elements in Σ∗.

This is called an inductive definition.

Is Σ∗ always infinite?

G52MALMachines and Their LanguagesLecture 1 – p.26/37

Page 81: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

All Words Over an Alphabet (1)

Given an alphabet Σ we define the set Σ∗ as setof words (or sequences) over Σ:

• The empty word ǫ ∈ Σ∗.

• given a symbol x ∈ Σ and a word w ∈ Σ∗,xw ∈ Σ∗.

• These are all elements in Σ∗.

This is called an inductive definition.

Is Σ∗ always infinite? Always non-empty?

G52MALMachines and Their LanguagesLecture 1 – p.26/37

Page 82: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

All Words over an Alphabet (2)

Example: Given Σ = {0, 1}, some elements of Σ∗

are

• ǫ (the empty word)

• 0, 1

• 00, 10, 01, 11

• 000, 100, 010, 110, 001, 101, 011, 111

• . . .

G52MALMachines and Their LanguagesLecture 1 – p.27/37

Page 83: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

All Words over an Alphabet (2)

Example: Given Σ = {0, 1}, some elements of Σ∗

are

• ǫ (the empty word)

• 0, 1

• 00, 10, 01, 11

• 000, 100, 010, 110, 001, 101, 011, 111

• . . .

We are just applying the inductive definition.

G52MALMachines and Their LanguagesLecture 1 – p.27/37

Page 84: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

All Words over an Alphabet (2)

Example: Given Σ = {0, 1}, some elements of Σ∗

are

• ǫ (the empty word)

• 0, 1

• 00, 10, 01, 11

• 000, 100, 010, 110, 001, 101, 011, 111

• . . .

We are just applying the inductive definition.

Note: although there are infinitely many words inΣ∗ (when Σ 6= ∅), each word has a finite length!

G52MALMachines and Their LanguagesLecture 1 – p.27/37

Page 85: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Concatenation of Words (1)

An important operation on Σ∗ is concatenation:

given w, v ∈ Σ∗, their concatenationwv ∈ Σ∗.

For example, concatenation of ab and ba yieldsabba.

G52MALMachines and Their LanguagesLecture 1 – p.28/37

Page 86: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Concatenation of Words (1)

An important operation on Σ∗ is concatenation:

given w, v ∈ Σ∗, their concatenationwv ∈ Σ∗.

For example, concatenation of ab and ba yieldsabba.

This operation can be defined by primitiverecursion:

ǫv = v

(xw)v = x(wv)

G52MALMachines and Their LanguagesLecture 1 – p.28/37

Page 87: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Concatenation of Words (2)

Concatenation is associative and has unit ǫ:

u(vw) = (uv)w

ǫu = u = uǫ

where u, v, w are words.

G52MALMachines and Their LanguagesLecture 1 – p.29/37

Page 88: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages Revisited

The notion of a language L of a set of words overan alphabet Σ can now be made precise:

G52MALMachines and Their LanguagesLecture 1 – p.30/37

Page 89: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages Revisited

The notion of a language L of a set of words overan alphabet Σ can now be made precise:

• L ⊆ Σ∗,

G52MALMachines and Their LanguagesLecture 1 – p.30/37

Page 90: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Languages Revisited

The notion of a language L of a set of words overan alphabet Σ can now be made precise:

• L ⊆ Σ∗, or equivalently

• L ∈ P(Σ∗).

G52MALMachines and Their LanguagesLecture 1 – p.30/37

Page 91: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Examples of Languages (1)

Some examples of languages:

G52MALMachines and Their LanguagesLecture 1 – p.31/37

Page 92: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Examples of Languages (1)

Some examples of languages:

• The set {0010, 00000000, ǫ} is a language overΣ = {0, 1}.

G52MALMachines and Their LanguagesLecture 1 – p.31/37

Page 93: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Examples of Languages (1)

Some examples of languages:

• The set {0010, 00000000, ǫ} is a language overΣ = {0, 1}.This is an example of a finite language.

G52MALMachines and Their LanguagesLecture 1 – p.31/37

Page 94: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Examples of Languages (1)

Some examples of languages:

• The set {0010, 00000000, ǫ} is a language overΣ = {0, 1}.This is an example of a finite language.

• The set of words with odd length overΣ = {1}. (Finite or infinite?)

G52MALMachines and Their LanguagesLecture 1 – p.31/37

Page 95: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Examples of Languages (1)

Some examples of languages:

• The set {0010, 00000000, ǫ} is a language overΣ = {0, 1}.This is an example of a finite language.

• The set of words with odd length overΣ = {1}. (Finite or infinite?)

• The set of words that contain the samenumber of 0s and 1s is a language overΣ = {0, 1}. (Finite or infinite?)

G52MALMachines and Their LanguagesLecture 1 – p.31/37

Page 96: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Examples of Languages (2)

• The set of palindromes (words that read thesame forwards and backwards, like abba) is alanguage for any alphabet.

G52MALMachines and Their LanguagesLecture 1 – p.32/37

Page 97: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Examples of Languages (2)

• The set of palindromes (words that read thesame forwards and backwards, like abba) is alanguage for any alphabet.

• The set of correct Java programs. This is alanguage over the set of UNICODEcharacters.

G52MALMachines and Their LanguagesLecture 1 – p.32/37

Page 98: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Examples of Languages (2)

• The set of palindromes (words that read thesame forwards and backwards, like abba) is alanguage for any alphabet.

• The set of correct Java programs. This is alanguage over the set of UNICODEcharacters.

• The set of programs that, if executedsuccessfully on a Windows machine, printsthe text “Hello World!” in a window. This is alanguage over Σ = {0, 1}.

G52MALMachines and Their LanguagesLecture 1 – p.32/37

Page 99: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Concatenation of Languages (1)

Concatenation of words is extended tolanguages by:

MN = {uv |u ∈ M ∧ v ∈ N}

Example:

M = {ǫ, a, aa}

N = {b, c}

MN =

=

=

G52MALMachines and Their LanguagesLecture 1 – p.33/37

Page 100: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Concatenation of Languages (1)

Concatenation of words is extended tolanguages by:

MN = {uv |u ∈ M ∧ v ∈ N}

Example:

M = {ǫ, a, aa}

N = {b, c}

MN = {uv |u ∈ {ǫ, a, aa} ∧ v ∈ {b, c}}

=

=

G52MALMachines and Their LanguagesLecture 1 – p.33/37

Page 101: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Concatenation of Languages (1)

Concatenation of words is extended tolanguages by:

MN = {uv |u ∈ M ∧ v ∈ N}

Example:

M = {ǫ, a, aa}

N = {b, c}

MN = {uv |u ∈ {ǫ, a, aa} ∧ v ∈ {b, c}}

= {ǫb, ǫc, ab, ac, aab, aac}

=

G52MALMachines and Their LanguagesLecture 1 – p.33/37

Page 102: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Concatenation of Languages (1)

Concatenation of words is extended tolanguages by:

MN = {uv |u ∈ M ∧ v ∈ N}

Example:

M = {ǫ, a, aa}

N = {b, c}

MN = {uv |u ∈ {ǫ, a, aa} ∧ v ∈ {b, c}}

= {ǫb, ǫc, ab, ac, aab, aac}

= {b, c, ab, ac, aab, aac}

G52MALMachines and Their LanguagesLecture 1 – p.33/37

Page 103: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Concatenation of Languages (2)

• Concatenation of languages is associative:

L(MN) = (LM)N

• Concatenation of languages has zero ∅:

L∅ = ∅ = ∅L

• Concatenation of languages has unit {ǫ}:

L{ǫ} = L = {ǫ}L

G52MALMachines and Their LanguagesLecture 1 – p.34/37

Page 104: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Concatenation of Languages (3)

• Concatenation distributes through set union:

L(M ∪N) = LM ∪ LN

(L ∪M)N = LN ∪MN

G52MALMachines and Their LanguagesLecture 1 – p.35/37

Page 105: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Concatenation of Languages (3)

• Concatenation distributes through set union:

L(M ∪N) = LM ∪ LN

(L ∪M)N = LN ∪MN

But not through intersection! L(M ∩N) 6= LM ∩ LN

Counterexample: L = {ǫ, a}, M = {ǫ}, N = {a}:

L(M ∩N) = L∅ = ∅

LM ∩ LN = {ǫ, a} ∩ {a, aa} = {a}

G52MALMachines and Their LanguagesLecture 1 – p.35/37

Page 106: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Concatenation of Languages (4)

• Exponent notation is used to denote iteratedconcatenation:

- L1 = L

- L2 = LL

- L3 = LLL

- . . .

• By definition: L0 = {ǫ} (for any language, incl. ∅)

L∗ =∞⋃

n=0

Ln

G52MALMachines and Their LanguagesLecture 1 – p.36/37

Page 107: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Language Membership

Fundamental question for a language L: w ∈ L?

G52MALMachines and Their LanguagesLecture 1 – p.37/37

Page 108: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Language Membership

Fundamental question for a language L: w ∈ L?

• L finite:

G52MALMachines and Their LanguagesLecture 1 – p.37/37

Page 109: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Language Membership

Fundamental question for a language L: w ∈ L?

• L finite: ?

G52MALMachines and Their LanguagesLecture 1 – p.37/37

Page 110: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Language Membership

Fundamental question for a language L: w ∈ L?

• L finite: Easy! (Enumerate L and check)

G52MALMachines and Their LanguagesLecture 1 – p.37/37

Page 111: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Language Membership

Fundamental question for a language L: w ∈ L?

• L finite: Easy! (Enumerate L and check)

• L infinite:

G52MALMachines and Their LanguagesLecture 1 – p.37/37

Page 112: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Language Membership

Fundamental question for a language L: w ∈ L?

• L finite: Easy! (Enumerate L and check)

• L infinite: ?

G52MALMachines and Their LanguagesLecture 1 – p.37/37

Page 113: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Language Membership

Fundamental question for a language L: w ∈ L?

• L finite: Easy! (Enumerate L and check)

• L infinite: ?

We need:

• A finite (and preferably concise) formaldescription of L.

G52MALMachines and Their LanguagesLecture 1 – p.37/37

Page 114: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Language Membership

Fundamental question for a language L: w ∈ L?

• L finite: Easy! (Enumerate L and check)

• L infinite: ?

We need:

• A finite (and preferably concise) formaldescription of L.

• An algorithmic method to decide if w ∈ L

given a suitable description.

G52MALMachines and Their LanguagesLecture 1 – p.37/37

Page 115: G52MAL Machines and Their Languages Lecture 1psznhn/G52MAL/LectureNotes/lecture01.pdf · 2016. 1. 26. · An Introduction to Formal Languages and Automata, 4th edition, Jones & Bartlett

Language Membership

Fundamental question for a language L: w ∈ L?

• L finite: Easy! (Enumerate L and check)

• L infinite: ?

We need:

• A finite (and preferably concise) formaldescription of L.

• An algorithmic method to decide if w ∈ L

given a suitable description.

Various approaches to achieve this will be key atheme throughout the module.

G52MALMachines and Their LanguagesLecture 1 – p.37/37