0% found this document useful (0 votes)
24 views23 pages

1-Automata Lec1

Jdjfksldlad

Uploaded by

berkeunver2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views23 pages

1-Automata Lec1

Jdjfksldlad

Uploaded by

berkeunver2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

FORMAL LANGUAGE AND

AUTOMATA THEORY
Lecture 1: Introduction
Why Study Automata?
• A survey of Stanford grads 5 years out asked which
of their courses did they use in their job.
• Basics like CS106 (Programming courses) took the
top spots, of course.
• But among optional courses, CS154 (Introduction to
Automata and Complexity Theory) stood
remarkably high.
• One of the most fundamental courses of Computer
Science.
• It is mainly about what kind of things can really
compute mechanically.
2
What is automata theory
• Automata theory is the study of abstract
computational devices
• Abstract devices are (simplified) models of
real computations
• Computations happen everywhere: On your
laptop, on your cell phone, in nature, …
• Why do we need abstract models?
Finite automata model protocols,
electronic circuits, …
Theory is used in model-checking

BATTERY

input: switch
output: light bulb
actions: flip switch
states: on, off
A simple “computer”

BATTERY start off on

input: switch
output: light bulb bulb is on if and only if
there was an odd number
actions: f for “flip switch” of flips
states: on, off
Another “computer”
1

BATTERY

inputs: switches 1 and 2


actions: 1 for “flip switch 1”
actions: 2 for “flip switch 2”
states: on, off
Another “computer”
1
1 start off off
1

2 2 2 2
BATTERY
1
2
off on
1

inputs: switches 1 and 2


actions: 1 for “flip switch 1” bulb is on if and only if
actions: 2 for “flip switch 2” both switches were flipped
an odd number of times
states: on, off
What kind of things can really
compute mechanically?
Question:
Do you know how a vending machine works? Can
you design one?

Vending machine room seen in


Hokkaido, Japan 2004
• How to design a vending machine?
→ Use a finite automaton!
• Assumptions (for simplicity):

– Only 5-dollar and 10-dollar coins are used.

– Only drinks all of 20 dollars are sold.


Only 5-dollar and 10-dollar coins are used.
Only drinks all of 20 dollars are sold.
Solution

Requiring “memory” called “states” for the design.

$10
$5 $15
$5

start $0 $5 $5 $10 $5

$10 $10 transition diagram


$10 $20
A gumball machine
machine takes $5 and $10 coins
a gumball costs $15
actions: +5, +10elease

一五
A gumball machine
machine takes $5 and $10 coins
a gumball costs $15
actions: +5, +10elease
一五 +10 +10

+5 +5 +5, +10
$0 $5 $10
+5, +10
A design problem
1 4

?
5
BATTERY

Can you design a circuit where the light is on if and only


if all the switches were flipped exactly the same number
of times?
A design problem
• Such devices are difficult to reason about,
because they can be designed in an infinite
number of ways
• By representing them as abstract
computational devices, or automata, we will
learn how to answer such questions
These devices can model many things
• They can describe the operation of any “small
computer”, like the control component of an
alarm clock or a microwave
• They are also used in lexical analyzers to recognize
well formed expressions in programming
languages:
ab1 is a legal name of a variable in C
5u= is not
Languages & Grammars
• Languages: “A language is a
Or “words” collection of sentences of finite
length all constructed from a
finite alphabet of symbols”
• Grammars: “A grammar can be
regarded as a device that
enumerates the sentences of a
language” - nothing more,
nothing less

• N. Chomsky, Information and


Control, Vol 2, 1959

Image source: Nowak et al. Nature, vol 417, 2002 17


Context-free grammars
• They are used to describe the syntax of
essentially every programming language.
– Not to forget their important role in describing
natural languages.

18
Some devices we will see

finite automata Devices with a finite amount of memory.


Used to model “small” computers.

push-down Devices with infinite memory that can be


automata accessed in a restricted way.
Used to model parsers, etc.

Turing Machines Devices with infinite memory.


Used to model any computer.
Turing Machines

– This is a general model of a computer, capturing


anything we could ever hope to compute
– Surprisingly, there are many things that we cannot
compute, for example:
Write a program that, given the code of another
program in C, tells if this program ever outputs
the word “hello”

– It seems that you should be able to tell just by looking


at the program, but it is impossible to do!
Problems
• Examples of problems we will consider
– Given a word s, does it contain the subword
“fool”?
– Given a number n, is it divisible by 7?
– Given a pair of words s and t, are they the same?
– Given an expression with brackets, e.g. (()()),
does every left bracket match with a subsequent
right bracket?
• All of these have “yes/no” answers.
Some highlights of the course
• Finite automata
– Automata are closely related to the task of searching
for patterns in text
find (ab)*(ab) in abracadabra

• Grammars
– Grammars describe the meaning of sentences in
English, and the meaning of programs in Java
– We will see how to extract the meaning out of a
program
Theory of computations layers

Undecidable

Turing Machine
CFL

FSM

You might also like