CDT314
Download
1 / 53

CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 2 - PowerPoint PPT Presentation


  • 119 Views
  • Uploaded on

CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 2 School of Innovation, Design and Engineering Mälardalen University 2011. Content Languages, Alphabets and Strings Strings & String Operations Languages & Language Operations Regular Expressions

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 ' CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 2' - alec-delaney


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
Cdt314 faber formal languages automata and models of computation lecture 2

CDT314

FABER

Formal Languages, Automata and Models of Computation

Lecture 2

School of Innovation, Design and Engineering Mälardalen University

2011


Cdt314 faber formal languages automata and models of computation lecture 2

  • Content

  • Languages, Alphabets and Strings

  • Strings & String Operations

  • Languages & Language Operations

  • Regular Expressions

  • Finite Automata, FA

  • Deterministic Finite Automata, DFA



Languages
Languages

  • defined over an alphabet:

A language is a set of strings

A String is a sequence of letters

  • An alphabet is a set of symbols


Alphabets and strings
Alphabets and Strings

  • We will use small alphabets:

Strings



String operations

=

w

a

a

a

L

x abba

1

2

n

=

v

b

b

b

y  bbbaaa

L

1

2

m

String Operations

Concatenation (sammanfogning)

xy abbabbbaaa


Cdt314 faber formal languages automata and models of computation lecture 2

Reverse (reversering)

Example:

Longest odd length palindrome in a natural language:

saippuakauppias

(Finnish: soap sailsman)


String length

Length:

String Length

Examples:


Recursive definition of length
Recursive Definition of Length

  • For any letter:

  • For any string :

  • Example:


Length of concatenation

=

=

u

aab

,

u

3

=

=

v

abaab

,

v

5

=

=

uv

aababaab

8

=

+

=

+

=

uv

u

v

3

5

8

Length of Concatenation

Example:


Proof of concatenation length
Proof of Concatenation Length

  • Claim:

  • Proof: By induction on the length

    • Induction basis:

    • From definition of length:


Cdt314 faber formal languages automata and models of computation lecture 2

for

  • Inductive step: we will prove

for


Inductive step
Inductive Step

  • Write , where

  • From definition of length:

  • From inductive hypothesis:

  • Thus:

END OF PROOF


Empty string
Empty String

  • A string with no letters:

  • (Also denoted as )

  • Observations:


Substring delstr ng
Substring (delsträng)

  • Substring of a string:

    • a subsequence of consecutive characters

  • String Substring


Prefix and suffix

prefix

suffix

Prefix and Suffix

  • Suffixes

Prefixes


Repetition

(String repeated n times)

Repetition

n

=

  • Example:

  • Definition:

w

ww...

w

}

n


The kleene star operation
The (Kleene* star) Operation

  • the set of all possible strings from alphabet

[* Kleene is pronounced "clay-knee“]

http://en.wikipedia.org/wiki/Kleene_star


Cdt314 faber formal languages automata and models of computation lecture 2

{

}

S

=

l

*

,

a

,

b

,

aa

,

ab

,

ba

,

bb

,

aaa

,

aab

,

K

The + (Kleene plus) Operation

:the set of all possible strings from the

alphabet except

{

}

S

=

a

,

b


Cdt314 faber formal languages automata and models of computation lecture 2

}

{

S

=

oj

,

fy

,

usch

{

S

=

l, oj, fy, usch, ojoj, fyfy,uschusch, ojfy, ojusch

*

}

+

+

S

S

K

Example

=

S

-

l

*

{

=

oj, fy, usch, ojoj, fyfy,uschusch, ojfy, ojusch

}

K



Language
Language

  • A language is any subset of

  • Example:

  • Languages:

{

}

S

=

a

,

b

{

}

S

=

l

*

,

a

,

b

,

aa

,

ab

,

ba

,

bb

,

aaa

,

K

{

}

l

{

}

a

,

aa

,

aab

l

{

,

abba

,

baba

,

aa

,

ab

,

aaaaaa

}


Example
Example

  • An infinite language


Operations on languages1

{

}

S

=

l

*

,

a

,

b

,

aa

,

ab

,

ba

,

bb

,

aaa

,

aab

,

K

Complement:

Operations on Languages

  • The usual set operations


Reverse
Reverse

Definition:

Examples:


Concatenation
Concatenation

  • Definition:

Example


Repeat
Repeat

  • Definition:

  • Special case:



Star closure kleene
Star-Closure (Kleene *)

  • Definition:

  • Example:


Positive closure
Positive Closure

  • Definition

+

1

2

=

L

L

U

L

U

L

{

}

=

-

l

L

*



Regular expressions recursive definition

Primitive regular expressions:

Given regular expressions and

are Regular Expressions

Regular Expressions: Recursive Definition


Examples

A regular expression:

Not a regular expression:

Examples


Cdt314 faber formal languages automata and models of computation lecture 2

Building Regular Expressions

  • Zero or more.

  • a* means "zero or more a's."

  • To say "zero or more ab's," that is,

  • {, ab, abab, ababab, ...}, you need to say (ab)*.

  • ab*denotes {a, ab, abb, abbb, abbbb, ...}.


Cdt314 faber formal languages automata and models of computation lecture 2

Building Regular Expressions

  • One or more.

  • Since a* means "zero or more a's", you can use aa* (or equivalently, a*a) to mean "one or more a's.“

  • Similarly, to describe "one or more ab's," that is,

  • {ab, abab, ababab, ...}, you can use ab(ab)*.


Cdt314 faber formal languages automata and models of computation lecture 2

Building Regular Expressions

  • Any string at all.

  • To describe any string at all (with = {a, b, c}), you can use (a+b+c)*.

  • Any nonempty string.

  • This can be written as any character from followed by any string at all: (a+b+c)(a+b+c)*.


Cdt314 faber formal languages automata and models of computation lecture 2

Building Regular Expressions

  • Any string not containing....

  • To describe any string at all that doesn't contain an a (with = {a, b, c}), you can use (b+c)*.

  • Any string containing exactly one...

  • To describe any string that contains exactly one a, put "any string not containing an a," on either side of the a, like this: (b+c)*a(b+c)*.


Languages of regular expressions
Languages of Regular Expressions

language of regular expression

Example


Definition
Definition

  • For primitive regular expressions:


Definition continued
Definition (continued)

  • For regular expressions and


Example2
Example

Regular expression:


Example3
Example

  • Regular expression


Example4
Example

  • Regular expression


Example5

{ all strings with at least

two consecutive 0 }

Example

  • Regular expression


Example6

= { all strings without

two consecutive 0 }

Example

  • Regular expression

  • (consists of repeating 1’s and 01’s).


Example7
Example

= { all strings without

two consecutive 0 }

Equivalent solution:

(In order not to get 00 in a string, after each 0 there must be an 1,

which means that strings of the form 1....101....1

are repeated. That is the first parenthesis. To take into account strings that end with 0, and those consisting of 1’s solely,

the rest of the expression is added.)


Equivalent regular expressions
Equivalent Regular Expressions

  • Regular expressions and

Definition:

are equivalent if


Example8

= { all strings without

two consecutive 0 }

Example

and

are equivalent

regular expressions.


Lennart salling s video resources
Lennart Salling’s Video Resources

  • http://www.math.uu.se/~salling/Lennart Salling

  • http://www.math.uu.se/~salling/AUTOMATA_DV/index.html

  • Introduktion: http://www2.math.uu.se/~salling/Movies/Intro%20to%20Automata.mov

  • Program, strings, integers and integerfunctions

  • http://www2.math.uu.se/~salling/Movies/StringsNumbersAndFunctions.mov

  • http://www.youtube.com/embed/EuhbL0MPryU Vad handlar kursen om?

  • http://www.youtube.com/embed/VM5SUcyY4sI?hl=en&fs=1 Kan alla problem lösas av program?

  • http://www.youtube.com/embed/acsUNSkzUgg?hl=en&fs=1 Vad har stora och små oändligheter med saken att göra?

  • http://www.youtube.com/embed/eQoP_kuNgXU?hl=sv&fs=1 Vad har språk och beräkningar med varandra att göra?

  • http://www.youtube.com/embed/-4K72wsQmPI?hl=sv&fs=1 Reguljära språk, vad är det?

  • http://www.youtube.com/embed/R2bHYnBXWFs?hl=sv&fs=1 Vilka automater är specialiserade på reguljära språk?

  • http://www.youtube.com/embed/2PNyEWl1AI0?hl=sv&fs=1 Varför icke-determinism?

  • http://www.youtube.com/embed/2abHjjS8Tqc?hl=sv&fs=1 Hur ser problem ut som inte kan lösas av program?

  • http://www.youtube.com/embed/WMN_wz-b3K0?hl=sv&fs=1

  • http://www.youtube.com/embed/y-zMnV3G9pg?hl=sv&fs=1 Hur kan man visa att ett problem inte kan lösas av program?


Lennart salling s video video resources
Lennart Salling’s Video Video Resources

  • http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Closure_properties/Closure_properties.mov

  • http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/FA_to_RegExpression/FA_to_RegExpression.mov

  • http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Famous_undecidable_and_decidable_problems/Famous_undecidable_and_decidable_problems.mov

  • http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Universal_Turing_machines/Universal_Turing_machines.mov

  • http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Turing_machines/Turing_machines.mov

  • http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Unrestricted_grammar/Unrestricted_grammar.mov

  • http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Pumping%20CFL/Pumping%20CFL.mov

  • http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/PDA/PDA.mov

  • http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/CFG/CFG.mov

  • http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Nonregularity/Nonregularity.mov

  • http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Reduction_of_number_of_states/Reduction_of_number_of_states.mov

  • http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/Closure_properties/Closure_properties.mov

  • http://www2.math.uu.se/~salling/AUTOMATA_DV/media/2011/FA_to_RegExpression/FA_to_RegExpression.mov


More video s 1
More Video’s 1

  • www.youtube.com/watch?v=MzDG34w0LLA&feature=player_embeddedSubsetConstruction

  • http://www.youtube.com/watch?v=acsUNSkzUgg&feature=relatedInfinities

  • http://www.youtube.com/watch?v=y-zMnV3G9pg&feature=relatedRice'sTheorem

  • http://www.youtube.com/watch?v=R2bHYnBXWFs&feature=related Finite Automata

  • http://www.youtube.com/watch?v=eQoP_kuNgXU&feature=related Strings and Languages

  • http://www.youtube.com/watch?v=-4K72wsQmPI&feature=relatedRegular Languages

  • http://www.youtube.com/watch?v=WMN_wz-b3K0&feature=related Accept and decide (TM)


More video s 2
More Video’s 2

  • http://www.youtube.com/watch?v=RYNN-tb9WxI&feature=related

  • Regular Expression to NFA

  • http://www.youtube.com/watch?v=shN_kHBFOUE&feature=related 2 - Convert Regular Expression to Finite-State Automaton

  • http://www.youtube.com/watch?v=dlH2pIndNrU&feature=related Convert Regular Expression to DFA

  • http://www.youtube.com/watch?v=5a_pO3NYJl0 Great Principles of Computing - Peter J. Denning

  • http://www.youtube.com/watch?v=60P7717-XOQ&feature=related Stephen Wolfram: Computing a theory of everything

  • http://www.youtube.com/watch?v=cCdbZqI1r7I&feature=related Computing Beyond Turing - Jeff Hawkins