formal languages n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Formal languages PowerPoint Presentation
Download Presentation
Formal languages

Loading in 2 Seconds...

play fullscreen
1 / 9

Formal languages - PowerPoint PPT Presentation


  • 80 Views
  • Uploaded on

Formal languages. regular expressions regular languages finite state machines. Formal languages. A string is a (perhaps empty) sequence of symbols. e denotes the empty string. A language is a (perhaps empty) set of strings. Æ denotes the empty set.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Formal languages' - bonner


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
formal languages
Formal languages
  • regular expressions
  • regular languages
  • finite state machines

CSE 467/567

formal languages1
Formal languages

A string is a (perhaps empty) sequence of symbols.

e denotes the empty string.

A language is a (perhaps empty) set of strings.

Æ denotes the empty set.

There are many different classes of languages. Main ones in Chomsky hierarchy are regular, context free, context sensitive and unrestricted.

CSE 467/567

sets and set operations
Sets and set operations

Examples:

Æ is the empty set, a set with no members

{a, b, c} is a set with three members

Operations:

Suppose A={a, b, c} and B={1, 2}, then

A·B={a1, a2, b1, b2, c1, c2}

A´B={(a,1),(a,2),(b,1),(b,2),(c,1),(c,2)}

AÈB={a, b, c, 1, 2}

A*={e, a, b, c, aa, ab, ac, ba, bb, bc, aaa, aab, aac, …}

CSE 467/567

regular languages
Regular languages

The class of regular languages over an alphabet å can be defined recursively:

base case 1: Æ is a regular language

base case 2: {e} is a regular language

base case 3: for each symbol a in å, {a} is a regular language

recursive cases: If S and T are regular languages, then so are:

{st| s is in S and t is in T}, the concatenation of S and T

{x| x is in S or x is in T}, the disjunction of S and T

S*, the Kleene closure of S

Nothing else is a regular language.

CSE 467/567

finite state automata
Finite state automata

Formally a 5-tuple (Q, å,q0,F,d) where

Q is a finite set of states

å is a finite input alphabet of symbols

q0 Î Q is the initial state

F Í Q is a set of final states

d: Q´åQ

CSE 467/567

examples
Examples

FSA (5-tuple and diagram) accepting each of the following (assume å={a,b,c,…z}):

{a}

{fred, wilma}

{ball, bell, bill, boll, bull}

{e, a}

{e, a, b, c, aa, ab, ac, ba, bb, bc, ca, cb, cc, aaa, …}

CSE 467/567

re s outside of perl
RE’s outside of Perl?

Can always directly implement the DFA.

  • switch on state, switch on symbol
  • table-driven method (put d in an array)

Example!

CSE 467/567

construction of fa
Construction of FA

Base cases

  • Æ is a regular language
  • {e} is a regular language
  • for each symbol a in å, {a} is a regular language

Recursive cases

If S and T are regular languages, then so are:

  • {st| s is in S and t is in T}, the concatenation of S and T
  • {x| x is in S or x is in T}, the disjunction of S and T
  • S*, the Kleene closure of S

CSE 467/567

nfa vs dfa
NFA vs. DFA

Accept same set of languages.

Simulation of NFA through search:

depth-first (stack regime for next node)

breadth-first (queue regime)

Can mechanically convert NFA to DFA, with possible exponential increase in number of states.

CSE 467/567