Joshua Arulanandham Room 576, Maths-Physics building Email: [email protected] Office hours...

16
Joshua Arulanandham oom 576, Maths-Physics building Email: [email protected] Office hours Tuesdays: 2:30-4:30 pm Thursdays: 2:30-4:30 pm

Transcript of Joshua Arulanandham Room 576, Maths-Physics building Email: [email protected] Office hours...

Joshua ArulanandhamRoom 576, Maths-Physics building

Email: [email protected]

Office hours Tuesdays: 2:30-4:30 pmThursdays: 2:30-4:30 pm

Machines with moods

Finite State Automata

“Machines”, eh?

In this context, “machines” do not refer to ones which cogs, gears, shafts, etc. but to “thought-operated machines”—which help us do orderly thinking.

However, these thought-operated machines can be realized in the form of real machines (with or without cogs!).

The simplest kind of “machines”

Input Output

Down light goes ON

Up light goes OFF

Output depends on input--- it’s easy!

1

0

1

0

1

I1 I2 I3 I4 Output

0 0 0 0 0

0 0 0 1 0

0 0 1 0 0

More sophisticated machines

push

light goes ON (“erect” mood)

OFF (“depressed” mood)

Output depends also on the machine’s “mood”---like human beings!

mood = memory state

More sophisticated machines

COKE vending machine

50 c50 c 50 c

mmm

one more to go

Eject

A vending machine doesn’t blindly match an input (coin) with an output (coke). It can “remember” (in the form of “states”) information gleaned from previous inputs.

But, surely there’s a problem …

Using “states” to remember is a good idea, but don’t we have to keep adding newer and newer states as the input gets longer and longer? Wouldn’t we have to glean more and more information as the input grows longer?

A riddle

A machine of finite size01111001 ……….

INPUT sequence of arbitrary length

OUTPUT pronouncing whether or not the (whole) sequence has a certain property

0 / 1

NO, not if we are referring to simple “input-output machines”, for these simply can’t accommodate (in “one go”) an input sequence larger than the number of input switches they have. (Note: We can’t type the input “piece-by-piece”, little by little, since these machines can’t remember any information gleaned from the previous parts of the input! All they can do is to throw an output that “matches” the whole input.)

Could this exist?

Yes, (for some cases) if we use machines with moods.

odd

1

1

0

Riddle solved

0

A machine of finite size01111001 ……….

checks if # of 1’s in the sequence is even or odd

even

EVEN: Print “Even”Read next characterIf it’s ‘0’ goto EVENIf it’s ‘1’ goto ODD

ODD: Print “Odd”Read next characterIf it’s ‘0’ goto ODDIf it’s ‘1’ goto EVEN

These “machines” can be mechanically realized in the form of computer programs, mechanical gadgets or hardware memory devices.

even odd

1

1

0 0

Riddle solved

Why is this interesting?

01111001 ………. 0/1even odd

10 0

Because, in many cases, we can afford to leave out a lot of information about the input; in fact, the machine remembers only a constant number of things about (an arbitrarily long) input.

Examples

Examples of problems that can be solved by “remembering” only a finite/constant/fixed amount of information about the input

Black Box(fixed size)

3 3 5 3 3 3. . .

YES

NO

{3, 5, 9}

Have you seen a ‘9’ so far?

Yes

93

5

3

5

9No

Examples

5big=5

big=9

big=3

3 / 5

3 / 5 / 9

9

3

9

5

big=?

3

9

Black Box(fixed size)

3 3 5 3 3 3. . .{3, 5, 9}

Which is the biggest no. flashed (so far)?

9

5

3

Examples

Black Box(fixed size)

3 3 5 3 3 3. . .

YES

NO

{3, 5, 9}

Is number of 3’s = number of 9’s? (so far)

Because the machine may have to remember so much that its “memory” (of fixed size) might overflow.

It can’t be done!

Examples

Black Box(fixed size)

A > B{ 00, 11, 01, 10 }

Compare binary numbers A and B

A = B

A < B

LSB

LSBA<B

A>B

01

A=B

00 / 11

10

01 10

00 / 11 / 01

00 / 11 / 10

0 0 1 1 0 0. . .

1 0 0 1 1 0. . .

A

B

Examples

Black Box(fixed size)

YES

NO[ [ [ ] [ ]. . .{ [ , ] }

Is the sequence of parentheses “balanced”?

Because the machine will have to “keep count” of the individual symbols, which is not possible with fixed-sized memory.

It can’t be done!