cs 3240 – chuck allison. a model of computation a very simple, manual computer (we draw...

20
CS 3240 – Chuck Allison

Upload: ella-jennings

Post on 21-Dec-2015

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

CS 3240 – Chuck Allison

Page 2: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

A model of computation A very simple, manual computer (we

draw pictures!)

Our machines: automata 1) Finite automata (“finite-state

machines”) 2) Push-down automata 3) Turing Machines

2CS 3240 - Introduction

Page 3: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

Meaningless sets of stringsWe study their syntax properties

Not interested in semantics

Example: The language over the alphabet* {a, b}

with a run of a ’s followed by an equal-length run of b ’s

anbn = {ab, aabb, aaabbb, …}

3CS 3240 - Introduction

* An alphabet is a finite set of symbols.

Page 4: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

Length operatorIf x = abaa, then |x| = 4

Concatenation If y = bab then xy = abaabab

Replication (concatenation with self) a3 = aaa x2 = abaaabaa

Note: the empty string is denoted by λ xλ = λx = x, x0 = λ

4CS 3240 - Introduction

Page 5: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

Also called “Kleene closure” or “Kleene star” (roughly pronounced “CLAY-nee”)

The set of all possible concatenations of elements of a set, taken zero or more times

Example: Alphabet, Σ = {a, b} Σ* = {λ, a, b, aa, ab, ba, bb, aaa, aab, …} Always an infinite set Always includes λ

5CS 3240 - Introduction

“Proper order”

Page 6: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

Languages are just sets of strings You can therefore do set operations on them:

union, intersection, difference, cartesian product Let L = {a, bb}, M = {aa, b}

L ∪ M = {a, b, aa, bb} L ∩ M = ∅ (in this case) L - M = L, M – L = M (in this case) LM = {ab, aaa, bbb, bbaa}, ML = {ba, aaa,

bbb, aabb} L0 = {λ}, L1 = L, L2 = {aa, abb, bba, bbbb}

6CS 3240 - Introduction

Page 7: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

Complement: L ’ = ∑* - L = {λ, b, aa, ab, ba, aaa, …}

Star Closure: L* = {λ, a, aa, bb, aaa, abb, bba, aaaa,

…} Positive Closure (one or more):

L+ = {a, aa, bb, aaa, abb, bba, aaaa, …} Just missing λ Equivalent to LL* = L*L

7CS 3240 - Introduction

Page 8: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

A set of rules for generating strings (“sentences”) in a language A symbol on the left of the rule can be

replaced by the string on the rightA recursive rule is necessary to

generate an infinite languageSee next 3 slides

8CS 3240 - Introduction

Page 9: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

<S> => the <NP> <VP><NP> => <N> | <ADJ> <NP><VP> => <V> | <V> <ADV><N> => dog | cat | professor |

student | rat<V> => ran | ate | slept | drank<ADJ> => red | slow | dead<ADV> => quickly | happily | well

9CS 3240 - Introduction

Start with <S> (the “start symbol”)

Page 10: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

<S> => the <NP> <VP>=> the <ADJ> <NP> <VP>=> the <ADJ> <ADJ> <NP> <VP>=> the slow dead <N> <VP>=> the slow dead student <VP>=> the slow dead student <V>

<ADV>=> the slow dead student drank

happily10CS 3240 - Introduction

Page 11: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

S => aSb | λ

S => aSb => aaSbb => aaaSbbb => aaabbb

11CS 3240 - Introduction

Page 12: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

A finite automaton is a finite-state machine It reads an input string 1 letter at a time Different inputs place the machine in different

states Machines that emit output as they move

from state-to-state are called transducers aka “Mealy Machines”

Machines that just answer “yes” or “no” (depending on the state they finish in) are called accepters

12CS 3240 - Introduction

Page 13: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

Figure 01.04: CS 3240 - Introduction 13

Page 14: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

14CS 3240 - Introduction

Page 15: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

15CS 3240 - Introduction

A machine with output(aka “transducer” or “Mealy machine”)

Page 16: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

Adds two bit strings according to the rules of arithmetic

Traverses digits right-to-leftThe output is either a 0 or 1 (duh)

but we also have to track whether we carry or not

leads to two states (carry vs. no-carry)See next two slides

CS 3240 - Introduction 16

Page 17: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

Figure 01.07:

Page 18: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

Figure 01.09:

Page 19: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

CS 3240 - Introduction 19

Frontpad

Rearpad

closed open

Front

Neither

Front,Rear,Both

Rear,Neither,Both

Page 20: CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state

Language Machine Grammar

Regular Finite Automaton Regular Expression,Regular Grammar

Context-Free Pushdown Automaton

Context-Free Grammar

Recursively Enumerable

Turing Machine Unrestricted Phrase-Structure Grammar

20CS 3240 - Introduction