• Nem Talált Eredményt

LászlóKabódi Languagesandautomata

N/A
N/A
Protected

Academic year: 2022

Ossza meg "LászlóKabódi Languagesandautomata"

Copied!
24
0
0

Teljes szövegt

(1)

Languages and automata

László Kabódi

(2)

Denitions

Nondeterministic Finite Automata

I Similar to the Deterministic Finite Automata I The dierence is in the transition function

I There can be multiple transitions for a state and a letter I There can beεtransitions (changing state without reading

from the input)

I The automaton accepts a word if there is an accepting calculation

László Kabódi

(3)

Examples

Example

I Σ ={0,1}

I Create a nondeterministic nite automaton for the language, where the words end with 01

(4)

Examples

Solution

I L={w|w ends with 01}

A 0 B 1 C

0,1

László Kabódi

(5)

Examples

Example II

I Σ ={0,1}

I Create a nondeterministic nite automaton for the language, where the words contain 11 or 101

(6)

Examples

Solution II

I L={w|w contains 11 or 101}

A B C D

0,1

1 0,ε 1

0,1

László Kabódi

(7)

Examples

Example III

I Σ ={0,1}

I Create a nondeterministic nite automaton for the language, where the words contain 00 and 010

(8)

Examples

Solution III

I L={w|w contains 00 and 010} I state D: we already saw 010, we need 00 I state H: we already saw 00, we need 010

A

B C D E

F

G H I J

0,1 0

1 0 0

0 0, 1

0

0 0 1

0

0, 1

0, 1

László Kabódi

(9)

Concatenation

Proof for concatenation

I w ∈L1L2 if and only if w =w1w2 where w1 ∈L1 andw2∈L2 I If L1 andL2 are regular thenL1L2 is also regular

I If L1 andL2 are regular languages, there are M1 andM2 nite automata for them

I From all the accepting states ofM1 create εtransitions to the initial state of M2

I The initial state of the new automaton is the initial state ofM1 I The accepting states of the new automaton are the accepting

state ofM2

(10)

Concatenation

Example

I Σ ={a,b}

I L1 =words that start with a I L2 =words that end with b

László Kabódi

(11)

Concatenation

Example

I L1 =words that start with a

A a B

a,b

I L2 =words that end with b

C b D

a,b

(12)

Concatenation

Example

I L1 =words that start with a I L2 =words that end with b I L1L2 =?

I L2L1 =?

László Kabódi

(13)

Concatenation

Solution

I L1L2 =words that start with a and end with b

A a B C D

a,b ε

a,b b I L2L1 =words that contain ba

C b D A B

a,b

ε

a,b a

(14)

Transitive closure

Transitive closure

I w ∈L1 if and only ifw ∈

S

i=0Li1

I Ln1 means L1 concatenated to itself n times.

I L01

I If L1 is regular then L1 is also regular.

László Kabódi

(15)

Transitive closure

Proof for transitive closure

I If L1 is regular, there is a nite automaton M1 for it I Create εtransitions from the accepting states to the initial

state

I Set the initial state to be also an accepting state while leaving the original accepting states accepting

I If the initial state has transitions go into it, then we create a new initial state, that will be an accepting state and the epsilon transitions go to that one

(16)

Union

Alternative proof for union

I If L1 andL2 are regular languages, there are M1 andM2 nite automata for them

I Create a new initial state

I Create twoεtransitions from this new initial state to the original initial states of M1 andM2

I The accepting states stay the same

László Kabódi

(17)

Complement

Complement of a language

I L= Σ\L

I In other words the complement of a language contains the words that are not in the original language

I w ∈L⇔w ∈/L

I If Lis regular, thenLis regular, because it can be created with

\ using two regular languages

I Or we can create an automaton from the automaton for Lby swapping accepting and not accepting states, if the initial state has no transition that goes back to it

(18)

Complement

Example

I L1,L2,L3⊆ {0,1} I L1 andL3 are regular I is L2 regular if

I L3=L1L2? I L3=L1L2?

László Kabódi

(19)

Complement

Solution

I L3 =L1∩L2: not necessarily, if L3=L1=∅thenL2 can be not regular

I L3 =L1∪L2: not necessarily, if L3=L1= Σ thenL2 can be not regular

(20)

Determinization algorithm (without ε )

I How can we create a deterministic nite automaton from a nondeterministic one?

I The idea is to simulate all possible computations of the nondeterministic automaton

I The states are all the possible subsets of the nondeterministic automaton's states

I The transitions are the unions of the transitions from the original states

László Kabódi

(21)

Example I

A B C

0, 1

0 1

(22)

Solution I

A AB AC

1 0

0 1

0 1

László Kabódi

(23)

Example II

A

C

B

a a,b

a,c

a,c

b

b

a,b c c

(24)

Solution II

A

B

BC

AC

C AB

ABC a

b

c a, c

b

a, b c a, b, c

a, c

a b

b

c

a, b

c

László Kabódi

Hivatkozások

KAPCSOLÓDÓ DOKUMENTUMOK

1 See e.g.. As a consequence it is impossible to know initial data for a problem exactly and so if solutions depend on the initial data in an uncontrollable way the model cannot

If the Turing machine have a time complexity f (n) then it stops in nite steps fot all inputs4. So it

I check is the input consists of word pairs, if not stop and reject I otherwise it tries all the 1 element index lists then 2 element. index lists and

We only nish a derivation with a deduction rule created form an accepting

The Maastricht Treaty (1992) Article 109j states that the Commission and the EMI shall report to the Council on the fulfillment of the obligations of the Member

Lady Macbeth is Shakespeare's most uncontrolled and uncontrollable transvestite hero ine, changing her gender with astonishing rapiditv - a protean Mercury who (and

• ε ik DM notes the topography factor in relation i, i + 1 of the section from petrol station k to the destination... It is 0 in case of empty vehicle. When it

For a given direction θ, for each initial energy e i ∈ E I we can calculate endpoint ε i θ of the corresponding rays. The propagation of rays in a homogeneous medium with a fixed