Docsity

Automata - Computability - Lecture Slide, Slides of Computer Science

Partial preview of the text

Download Automata - Computability - Lecture Slide and more Slides Computer Science in PDF only on Docsity!

Strings, Languages, Automata

Agenda

Today  Strings  Languages  Deterministic Finite Automata For next time:  Read up to 1.  Check out ABCEZ in lecture 2-4 directory.  HW 1

Vending Machine Example

Soda vend(){

int total = 0, coin; while (total != 45){ receive(coin); if ((coin==10 && total==40) ||(coin==25 && total>=25)) reject(coin); else total += coin; } return new Soda();

}

Vending Machine Example

Why was this over-kill?

Vending Machine Example

Vending Machine Example

Input: DQQD

About to put in a dime

Vending Machine Example

Input: DQQD

About to put in a quarter

Vending Machine Example

Input: DQQD

About to put in a dime

Vending Machine Example

What made this example simpler than the

Java pseudocode?

Vending Machine Example

1. Only needed two coin types “D” and

“Q” – symbols/letters in alphabet

2. Only needed 7 possible current total

amounts – states/nodes/vertices

3. Much cleaner and aesthetically

pleasing than Java lingo

Now generalize and abstractify…

Alphabets, Strings, Languages

A1: S = { D, Q }

A2:

Good: QDD, DQD, DDQ, QQQQDD, etc.

Bad: Q, D, DD, etc.

Ugly: DDD …now you’re screwed!

A3: e signifies trying to get something for

nothing (putting no money in at all).

Alphabets, Strings, Languages

DEF: The length of a string is the

number of symbols that it contains

(repetitions allowed).

Absolute values are used to denote

length.

EG: Lengths of the above good (QDD,

DQD, DDQ, QQQQDD) are: 3, 3, 3, 6

Q: What’s the length of e?

Alphabets, Strings, Languages

DEF: The concatenation of two strings is the

string resulting from putting them together

from left to right. Given strings u and v,

denote the concatenation by u  v, or just

uv.

EG: ire  land = ireland, QQ  DD = QQDD,

DDD  u is still bad, no-matter what u is!

Q1: Why the last claim?

Q2: What’s the Java equivalent of concatenation?

Q3: Find a formula for | u  v |.

Alphabets, Strings, Languages

A1: You are still screwed no matter what

combination of coins you put in.

A2: The + operator on strings.

A3: | u  v | = | u |+| v |