33
uages. nguage is set of finite length strings on the symbo i.e. a subset of * b c a c d f g g g) this point, we don’t care how the language is nerated or represented. So initially the comments ply to all kinds of languages gular -regular push-down automata languages Petri net languages … A symbol can be made up of a vector of variable values, e.g. 1a3de0 or 010010. These are examples of a single symbol. Languages can be manipulated as follows:

Languages. A Language is set of finite length strings on the symbol set

Embed Size (px)

DESCRIPTION

Languages. A Language is set of finite length strings on the symbol set. i.e. a subset of. (a b c a c d f g g g) At this point, we don’t care how the language is generated or represented. So initially the comments apply to all kinds of languages regular. -regular - PowerPoint PPT Presentation

Citation preview

Page 1: Languages. A  Language  is set of finite length strings on the symbol set

Languages.A Language is set of finite length strings on the symbol set i.e. a subset of *

(a b c a c d f g g g)At this point, we don’t care how the language is generated or represented. So initially the comments apply to all kinds of languagesregular• -regularpush-down automata languagesPetri net languages …A symbol can be made up of a vector of variable values, e.g. 1a3de0 or 010010. These are examples of a single symbol.Languages can be manipulated as follows:

Page 2: Languages. A  Language  is set of finite length strings on the symbol set

Examples of Languages

• Alphabet = {a, b, c}. Language includes all the strings, in which all occurrences of a appear before all occurrences of b:, a, b, c, ab, ac, acb, cab, aacaabbbccb, …Strings not in the language:ba, aacabbaccc, …

• Binary variables x, y. x = y = {0,1},

= x y = {00, 01, 10, 11}. Language includes all the strings appearing as input/output combinations of the given circuit (reset to 0):(00), (10), (00)(00)(00), (00)(10)(11),…Strings not in the language:(01), (11), (00)(01), …

DFFx y

Page 3: Languages. A  Language  is set of finite length strings on the symbol set

1 2 1 2{ | or }L L L L Intersection -

1 2 1 2{ | }L L L L Complement -

*{ | }L L Catenation -

1 2 1 2{ | }L L L L

• Union

Page 4: Languages. A  Language  is set of finite length strings on the symbol set

Lowering and RaisingGiven a Language L

over the alphabet X Y

projection is defined as –

{{ }|{( )} }i i iX X YX

L L Given a Language L over the alphabet X lifting to the alphabet X Y

is defined as - {{( )} |{ } }i i

X XYL L

Page 5: Languages. A  Language  is set of finite length strings on the symbol set

Examples of Projection and Lifting

• Binary variables x, y, z. x = y = z = {0,1}.

xyz = x y z = {000, 001, 010, 011, 100, 101, 110, 111}. Language includes all the strings that can appear as input/output combinations of the given circuit (reset to 0): ,(000), (110)(001)(100),…

Projecting to alphabet xz :(00), (10)(01)(10),…

Lifting to alphabet xyzu = xyz u :(000-), (110-)(001-)(100-),… = (0000), (0001),

(1100)(0010)(1000), (1100)(0010)(1001), (1100)(0011)(1000),…

DFFx zy

Page 6: Languages. A  Language  is set of finite length strings on the symbol set

Given a Language L over the alphabet X Y

the restriction to X is defined as - {{ ( )} |{ } }X i iX

L p L

where if

( ) otherwisei i

X i

Xp

Given a Language L over X and an alphabet Y disjoint from X, the expansion of L is defined as the language Y

L over

X Y such that -

*{{ }|{ } , }i i i i i iYL x x L Y

Page 7: Languages. A  Language  is set of finite length strings on the symbol set

Regular Expressions.Regular Expressions over alphabet

{} is a regular expression is a regular expression

|i i are regular expressionIf r and s are regular expressions then r+s, r s, and *r are regular expressions.The language associated with a regular expression is called a regular language.Theorem: The complement of a regular language is a regular language

Page 8: Languages. A  Language  is set of finite length strings on the symbol set

Examples of Regular Expressions

• Regular expression a + b stands for {a,b}

• Regular expression ab stands for {ab}

• Regular expression a* stands for {,a, aa, aaa, aaaa, …}

• Alphabet = {a, b, c}. Language includes all the strings, in which all occurrences of a appear before all occurrences of b:

(a+c)*(b+c)*

• Alphabet = x y = {00, 01, 10, 11}. Language includes all the strings appearing as input/output combinations of the given circuit (reset to 0):

( (00)*(10)(11)*(01) )*

DFFx y 0 1

0010

11

01

Page 9: Languages. A  Language  is set of finite length strings on the symbol set

Classes of LanguagesA language is prefix closed if

*, ,[ ]L L A language over

I O is I-progressive if

*, , [ ]i I o O L io L A language over

I O is I-Moore if

, ( ) , ( ' ')

[ [ ' ' ( ' ) ]]

L io i o

io L i o L i o L

Page 10: Languages. A  Language  is set of finite length strings on the symbol set

Examples of Languages

• Prefix-closed language includes, with its every string, all the prefixes of this string.

Example 1: Language a*b* is prefix closed

Example 2: Language a*b is not prefix closed

• I-progressive language includes the strings, which, for each input symbol, have some output symbol

Example 1: Language ( (00)*(10)(11)*(01) )* is I-progressive

Example 2: Language ( (00)*(10)(01) )* is not I-progressive

0 1

0010

11

01

0 1

0010

01

Page 11: Languages. A  Language  is set of finite length strings on the symbol set

Classes of LanguagesA language

*( )L I Oover

I O is prefix closed if

*( ) , ,[ ]I O i o I O i o L L A language

*( )L I Oover I O is IO-progressive if

*( ) , , ,[ ]I O i I o O L i o L

Page 12: Languages. A  Language  is set of finite length strings on the symbol set

Composition of LanguagesGiven disjoint alphabets I,U,O and languages L1 over

I U and L2 over

U O, their synchronous composition is

1 2[( ) ( ) ]O I I O

L L .Given disjoint alphabets I,U,O and languages L1 over

I U and L2 over

U O, their parallel composition is

1 2[( ) ( ) ]O I I O

L L

.

Page 13: Languages. A  Language  is set of finite length strings on the symbol set

Synchronous Composition

• Spec is defined over IO

• Fixed is defined over IVUO

• Unknown should be over UV

• The solution to the equation

F X S

is

More specifically

SFX I O

VU

Fixed

Unknown

F

X

Specification

S

),(),(][ ),(),,,(

VUUVOISOUVIFX

SFX

Page 14: Languages. A  Language  is set of finite length strings on the symbol set

“While synchronous product often is thought to be a simple – even uninteresting – type of coordination, it can be shown that, through the use of non-determinism, this conceptually simple coordination serves to model the most general‘asynchronous’ coordination, i.e. where processes progress at arbitrary rates relative to one another. In fact the ‘interleaving’ model, the most common model for asynchrony in the software community, can be viewed as a special case of this synchronous product” – Kurshan, 1994.

Uses non-determinism and self loops with null transitions at each state to model parallel with synchronous.

Page 15: Languages. A  Language  is set of finite length strings on the symbol set

Finite AutomataA finite automaton (FA) is

( , , , , )F S r Q where S is a set of states, is an input alphabet, ( , ) : 2Ss S

is a transition relation, r is the initial state, and Q S is the set of accepting states.

Page 16: Languages. A  Language  is set of finite length strings on the symbol set

An input sequence *

1( ... )nw w w leads from r to s’ if there exists a sequence of states,

0 1( ... ')nr s s s s such that 1 ( , )i i is s w for all i = 0, ... ,n-1.

w is in the language of F ( )( )w FL

if and only if w leads from r to 's Qi.e. ( , )r w Q where ( , )r w

denotes the set of states that can be reached from r under the input sequence w.

Page 17: Languages. A  Language  is set of finite length strings on the symbol set

Examples of Finite Automata

Example 1: Language a*b* is prefix closed

Example 2: Language a*b is not prefix closed

X Y

a

bX Y

a

b

b

Page 18: Languages. A  Language  is set of finite length strings on the symbol set

Theorem: A languages is regular if and only if it is the language of a finite automaton

Theorem: The set of all languages for deterministic FA is the same as for non-deterministic FA.(we will show how this can be done using the so-called subset construction.)

Page 19: Languages. A  Language  is set of finite length strings on the symbol set

Operations on FA.projection ( X

F ): convert F over X Vinto F’ over X by replacing each edge (xv s s’) by the edge (x s s’)

lifting ( VF ): convert F over X into F’ over X V

by replacing each edge (x s s’) by ( ')Vx s s where V

stands for any v V

.

Page 20: Languages. A  Language  is set of finite length strings on the symbol set

Examples of Projection and Lifting

0 1

000 010100

110

111001 011101

Projection y

0 1

00 10

10

11

01 11 0 1

000- 010-100-

110-

111-001- 011-101-

Lifting u

DFFx zy

u

Note: Automaton after projection is non-deterministic

Page 21: Languages. A  Language  is set of finite length strings on the symbol set

restriction (X

F ): convert F over X V

to F’ over V, by changing every edge (v s s’) where v V

into ( )'s s

expansion ( VF ): Change F over X into F’ over X V

by adding for each state, a self-loop for all v, i.e. add an edge

( )V s s where V stands for any v V

Page 22: Languages. A  Language  is set of finite length strings on the symbol set

Operations on FA.Product Given FAs 1 2 and F F both over , the product is

1 2 1 2 1 2 1 2( , , , ( ), )F F F S S r r Q Q

where 1 2 1 1 2( , ) ( , ) ( , )s s s s

ComplementationIf F is deterministic, then ( , , , , )F S r Q S Q .

If F is non-deterministic, the only known way for complementation is to determinize it first. This is done by the sub-set construction.

Page 23: Languages. A  Language  is set of finite length strings on the symbol set

Example of Product of Automata

Page 24: Languages. A  Language  is set of finite length strings on the symbol set

CompositionSynchronous Composition. Given two automata 1F

and 2F over alphabets I U and U O

their synchronous composition is

1 2 1 2( ) ( )O I

F F F F

i.e. the product of the two automata when they are made to have the same alphabet.

Parallel Composition. Given two automata 1F and

2F on alphabets I U and U O

their synchronous composition is 1 2 1 2( ) ( )O I

F F F F i.e. the product of the two automata when they are made to have the same alphabet.

Page 25: Languages. A  Language  is set of finite length strings on the symbol set

Subset ConstructionGiven NFA

( , , , , )F S r Q we create a DFA F’ with the same language as F:

' (2 , , ',{ }, ')SF r Q where ' { ' 2 | , '}S

q QQ s q s

and ˆ ' ˆ'( ', ) { | , ( , )}s ss s s s

s’

Theorem: F and F’ have the same language.Proof: ( , ) '({ }, )q r w q r w

Page 26: Languages. A  Language  is set of finite length strings on the symbol set

Interpretation of Subset Construction

• Non-deterministic automaton (NDA) can transit into several states under the same input

• We can think of these transitions happening at the same time• It means that the NDA can be in several states at the same time

– If string s has driven an NDA into a subset of states containing at least one accepting state, s is accepted

• Non-determinism is useful to compactly represent languages, but manipulation of NDAs is hard

• Determinization consists in constructing a DA equivalent to the given NDA• Determinization procedure performs subset construction

– The idea of subset construction is to transform (unfold) the NDA, which can be in a subset of states, into a DA, which can only be in one state, by associating each subset of states of the NDA with one state of the DA

Page 27: Languages. A  Language  is set of finite length strings on the symbol set

Example of Subset Construction

0 1

00 10

10

11

01 11

Page 28: Languages. A  Language  is set of finite length strings on the symbol set

Finite State Machines as Automata

A FSM is ( , , , , )M S I O T rwhere I is the set of input symbols, O the set of output symbols, r the initial state, and T(s,i,s’,o) is the transition relation. A transition (s,i,s’,o) from state s to s’ with output o can happen on input i can if and only if

( , , ', ) ( , , ', )s i s o T s i s o

If ( , ) ( ', )[( , , ', ) ]s i s o s i s o T

then M is complete, otherwise partial.

Page 29: Languages. A  Language  is set of finite length strings on the symbol set

It is deterministic if for all (s,i) there is at most one (s’,o) such that ( , , ', )s i s o F

It is pseudo-non-deterministic if for all (s,i,o) there is at most one s’ such that ( , , ', )s i s o F

A FSM is of Moore type if

( , , ', ) ' '[( , ', ', ) ]s i s o T i n s i n o T

i.e. i’ can determine the next state but not the output.

Page 30: Languages. A  Language  is set of finite length strings on the symbol set

Examples of FSMs

0 1

0/0 1/0

1/0

1/1

0/1

DFFx zy

0 1

00/0 01/010/0

11/0

11/100/1 01/110/1

Deterministic FSM

Non-Deterministic FSMCircuit

0 1

0/0 1/0

1/1

1/1

0/1

Pseudo-Non-Deterministic FSM

Page 31: Languages. A  Language  is set of finite length strings on the symbol set

Converting an FSM to an automatonAn FSM M can be converted into an automaton F by the following: ( ,( ), , , )F S I O r S where ( , ) { ' | ( , , ', ) }s io s s i s o T

Note that Q = S, i.e. all states are acceptingThe resulting automaton is typically not complete, since there are io combinations for which a next state is not defined. We can complete it by augmenting to include a transition to a new non-accepting state DCN.

DCN

s

f

f

Page 32: Languages. A  Language  is set of finite length strings on the symbol set

Converting FSM into Automaton

0 1

00/0 01/010/0

11/0

11/100/1 01/110/1

FSM

0 1

000 010100

110

111001 011101

Incomplete Automaton

Complete Automaton

0 1

000 010100

110

111001 011101

001 011101111

000 010100110

3

- - -

Page 33: Languages. A  Language  is set of finite length strings on the symbol set

FSMs as AutomataThe language of an FSM is defined to be the language of the associated automatonA pseudo non-deterministic FSM is one whose automaton is deterministic. The language of an FSM is prefix closed. The language of an FSM is I-progressive

Conversion M Fis done by grouping i/o on edges to (io) and making all states accepting.

Conversion F Mcan be done only if the language is prefix closed and I-progressive. In this case, delete all non-accepting states (prefix), and change edges from (io) to i/o.