1 / 20

Theory of Computation

CS 3240 – Chuck Allison. Theory of Computation. Abstract Machines Section 1.2. 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. Formal Languages.

shiela
Télécharger la présentation

Theory of Computation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 3240 – Chuck Allison Theory of Computation

  2. Abstract MachinesSection 1.2 • 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 CS 3240 - Introduction

  3. Formal Languages • Meaningless sets of strings • We study their syntaxproperties • 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, …} * An alphabet is a finite set of symbols. CS 3240 - Introduction

  4. Operations on Strings • Length operator If 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 = λ CS 3240 - Introduction

  5. Star ClosureThe * Operator • 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 λ “Proper order” CS 3240 - Introduction

  6. Operations on Languages • 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} CS 3240 - Introduction

  7. More Operations on Languages • 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 CS 3240 - Introduction

  8. Grammars • 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 right • A recursiverule is necessary to generate an infinite language • See next 3 slides CS 3240 - Introduction

  9. A Simple English Sentence Grammar • <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 Start with <S> (the “start symbol”) CS 3240 - Introduction

  10. Generating (“Deriving”) a Sentence • <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 happily CS 3240 - Introduction

  11. A Grammar for anbn, n ≥ 0 • S => aSb | λ • S => aSb => aaSbb => aaaSbbb => aaabbb CS 3240 - Introduction

  12. Finite Automata • 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 CS 3240 - Introduction

  13. General Automata Model Figure 01.04: CS 3240 - Introduction

  14. An Accepter for a*bb* CS 3240 - Introduction

  15. An Incrementer TransducerSection 1.3 A machine with output (aka “transducer” or “Mealy machine”) CS 3240 - Introduction

  16. A Binary Adder • Adds two bit strings according to the rules of arithmetic • Traverses digits right-to-left • The 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

  17. Figure 01.07:

  18. Figure 01.09:

  19. Frontpad Rearpad Front,Rear,Both Rear,Neither,Both Front closed open Neither Automatic Door Application CS 3240 - Introduction

  20. Scope of Course CS 3240 - Introduction

More Related