cs3102 theory of computation
play

CS3102 Theory of Computation 0,1 Some 0s 0 0 start Warm up: 1 - PowerPoint PPT Presentation

CS3102 Theory of Computation 0,1 Some 0s 0 0 start Warm up: 1 1 No 0s This automaton computes infinite AND: = 0,1 has no 0s} Show how to compute infinite NAND: = { 0,1 | has


  1. CS3102 Theory of Computation 0,1 Some 0s 0 0 start Warm up: 1 1 No 0s This automaton computes infinite AND: 𝐡𝑂𝐸 = 𝑦 ∈ 0,1 βˆ— 𝑦 has no 0s} Show how to compute infinite NAND: 𝑂𝐡𝑂𝐸 = {𝑦 ∈ 0,1 βˆ— |𝑦 has a 0}

  2. Infinite NAND Automaton β€’ Observation: 𝐡𝑂𝐸 𝑑 = 𝑂𝐡𝑂𝐸 β€’ NAND should do the opposite 0,1 Some 0s 0 of NAND 0 start β€’ Switch final states and non- final states! 1 1 No 0s 2

  3. AND to NAND β€’ AND: – 𝑅 = 𝑑𝑒𝑏𝑠𝑒, 𝑂𝑝0𝑑, 𝑇𝑝𝑛𝑓0𝑑 0,1 – π‘Ÿ 0 = 𝑑𝑒𝑏𝑠𝑒 Some 0s 0 – 𝐺 = {𝑑𝑒𝑏𝑠𝑒, 𝑂𝑝0𝑑} – πœ€ defined as the arrows 0 start β€’ NAND: – 𝑅, π‘Ÿ 0 , πœ€ don’t change – 𝐺 = 𝑅 βˆ’ 𝐺 1 1 β€’ In general, If we can compute a language 𝑀 No 0s with a FSA, we can compute 𝑀 𝑑 as well 3

  4. Logistics β€’ Exercise 4 (partially) released – First part is on creating finite automata – The rest released today, due Friday (March 6) β€’ Quiz will be released Thursday, due Tuesday 4

  5. Last Time β€’ Languages and decision problems – A different way of thinking about functions β€’ Introducing Finite State Automata – DFA: Deterministic finite state automaton – Language of a FSA: The set of strings for which that automaton returns 1 5

  6. FSA are strictly more powerful than NAND circuits β€’ How can we show this? – Show that there is at least one function we can do with FSA but not NAND-CIRC β€’ Done! (infinite XOR) – Show anything we can do with NAND-CIRC can also be done with FSA β€’ How? β€’ We need to be able to compute any finite function 6

  7. Computing any finite function with NAND-CIRC β€’ Summary: – "Manually Precompute" the output for every (finitely- many) possible input – When we receive the actual input, do a "lookup" β€’ Our proof before: – Make a variable to represent each possible input, assigning its value to match the correct output – Use LOOKUP to return the proper variable for the given input 7

  8. Straightline Code for f Input Output 000 0 001 0 010 1 011 0 100 1 101 1 110 0 111 0 8

  9. Computing finite functions with FSA β€’ Summary: – "Manually Precompute" the output for every (finitely-many) possible input – When we receive the actual input, do a "lookup" β€’ Same idea, but with Automata: – Make a state for every possible input, determining whether or not it is final depending on the correct output – Do a "binary tree traversal" with the given input to navigate to its correct output 9

  10. Input Output FSA for 𝑔 000 0 001 0 β€œβ€ 010 1 1 011 0 0 100 1 0 1 101 1 1 0 1 0 110 0 00 01 10 10 111 0 0 0 1 1 0 0 000 001 010 011 100 101 110 111 0,1 0,1 trash 10 0,1

  11. Regular Expressions Name Decision Problem Function Language 𝑐 ∈ Ξ£ βˆ— 𝑐 matches the pattern} Regex Does this string 𝑔 𝑐 = α‰Š 0 the string matches the string doesn β€² t match this 1 pattern? β€’ A way of describing a language β€’ Give a β€œpattern” of the strings, every string matching that pattern is in the language β€’ Examples: – (𝑏|𝑐)𝑑 matches : 𝑏𝑑 and 𝑐𝑑 – 𝑏|𝑐 βˆ— 𝑑 matches : 𝑑 , 𝑏𝑑 , 𝑐𝑑 , 𝑏𝑏𝑑 , 𝑏𝑐𝑑 , 𝑐𝑏𝑑 , 𝑐𝑐𝑑 , … 11

  12. β€œPieces” of a Regex β€’ Empty String: – Matches just the string of length 0 Note: The compents here are the – Notation: 𝜁 or β€œβ€ minimal necessary. In practice, regexes β€’ Literal Character have other components as well, those are just β€œsyntactic sugar”. – Matches a specific string of length 1 – Example: the regex 𝑏 will match just the string 𝑏 β€’ Alternation/Union – Matches strings that match at least one of the two parts – Example: the regex 𝑏|𝑐 will match 𝑏 and 𝑐 β€’ Concatenation – Matches strings that can be dividing into 2 parts to match the things concatenated – Example: the regex 𝑏 𝑐 𝑑 will match the strings 𝑏𝑑 and 𝑐𝑑 β€’ Kleene Star – Matches strings that are 0 or more copies of the thing starred – Example: 𝑏 𝑐 𝑑 βˆ— will match 𝑏 , 𝑐 , or either followed by any number of 𝑑 ’s 12

  13. 13

  14. Regex for UVA computing IDs β€’ A UVA computing id is formatted as: – 2-3 letters – A digit – 1-3 letters 14

  15. AND as a Regex β€’ 𝐡𝑂𝐸 = 𝑦 ∈ 0,1 βˆ— 𝑦 has no 0s} 15

  16. NAND as a Regex β€’ 𝑂𝐡𝑂𝐸 = {𝑦 ∈ 0,1 βˆ— |𝑦 has a 0} 16

  17. XOR as a Regex β€’ π‘Œπ‘ƒπ‘† = {𝑦 ∈ 0,1 βˆ— |𝑦 has an odd number of 1s} 17

  18. FSA = Regex β€’ Finite state Automata and Regular Expressions are equivalent models of computing β€’ Any language I can represent as a FSA I can also represent as a Regex (and vice versa) β€’ How would I show this? 18

  19. Showing FSA ≀ Regex β€’ Show how to convert any FSA into a Regex for the same language β€’ We’re going to skip this: – It’s tedious, and people virtually never go this direction in practice, but you can do it (see textbook theorem 9.12) 19

  20. Showing Regex ≀ FSA β€’ Show how to convert any regex into a FSA for the same language β€’ Idea: show how to build each β€œpiece” of a regex using FSA 20

  21. β€œPieces” of a Regex β€’ Empty String: – Matches just the string of length 0 – Notation: 𝜁 or β€œβ€ β€’ Literal Character – Matches a specific string of length 1 – Example: the regex 𝑏 will match just the string 𝑏 β€’ Alternation/Union – Matches strings that match at least one of the two parts – Example: the regex 𝑏|𝑐 will match 𝑏 and 𝑐 β€’ Concatenation – Matches strings that can be dividing into 2 parts to match the things concatenated – Example: the regex 𝑏 𝑐 𝑑 will match the strings 𝑏𝑑 and 𝑐𝑑 β€’ Kleene Star – Matches strings that are 0 or more copies of the thing starred – Example: 𝑏 𝑐 𝑑 βˆ— will match 𝑏 , 𝑐 , or either followed by any number of 𝑑 ’s 21

  22. FSA for the empty string 22

  23. FSA for a literal character 23

  24. FSA for Alternation/Union β€’ Tricky… β€’ What does it need to do? 24

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend