1 / 28

Lecture 4: NFAs in Foundations of Computation

This lecture covers topics such as induction review, DFAs, NFAs, delta and delta hat, strings accepted, languages accepted. It also discusses common mistakes in homework and the application of the Pigeon Hole Principle.

andrewo
Download Presentation

Lecture 4: NFAs in Foundations 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. Lecture 4NFAs CSCE 355 Foundations of Computation Topics: • Induction review • DFAs again • NFAs • Delta, delta hat • Strings accepted, languages accepted Sept 8, 2008

  2. Induction Revisited

  3. Induction HW

  4. Common Mistakes in HW

  5. Induction Pseudo Pop Quiz

  6. Review DFA • Delta hat • Path determined by input • DFA accepting a string • Language accepted by DFA

  7. Pigeon Hole Principle application

  8. Homework from Email

  9. DFA Simulation in Ruby • # !/usr/bin/ruby • #MMM 9/5/2008 • # Simulation/Implementation of a DFA in Ruby • # the DFA M=(Q, Sigma, delta, q0, F) • numstates = 4 # Q = [0, 1, 2, 3] • alphabet = ['a', 'b'] # Sigma = {a, b} • # delta implemented as function • q0 = 0 # Start state is state 0 • acceptingState = Array.new(4, 0) • acceptingState[1] = 1 # F = { 1 }

  10. def delta(state, inputChar) case when state == 0 case when inputChar == 'a' then return 1; when inputChar == 'b' then return 3 end when state == 1 case when inputChar == 'a' then return 2 when inputChar == 'b' then return 0 end . . . else return 999 end

  11. # Start Simulation state = 0 print "alphabet = #{alphabet}\n" print "acceptingState = #{acceptingState}\n" # print "Enter the input string: " line = gets puts "line=#{line}" inp = line.chomp.split(//)

  12. # foreach x in inp inp.each { |x| break x if x =="\n" ###break x if x =='X' nextstate = delta(state, x) print "delta(=#{state}, char=#{x}) = #{nextstate}\n" state = nextstate } if acceptingState[state] == 1 then puts "Accept" else puts "Reject" end

  13. Example 2.4

  14. Exercise 2.2.4

  15. DFA that accepts Union

  16. Nondeterministic Finite Automata

More Related