Theory of Languages and Automata By: Mojtaba Khezrian
Review Alphabetic ……. {0,1} String ….. x=‘101010’ Length of String ….. |x| Language Union Intersection Concat
Review
G =(V,T,P,S) V= nonFinal symbol T= Alphabetic P= Rules Grammar G =(V,T,P,S) V= nonFinal symbol T= Alphabetic P= Rules S= Starting symbol
Language of Grammar
Language of Grammar
Language of Grammar
Language of Grammar
How to Write Grammar? First split the language to small parts then write the grammar of them. Finally join all of them.
1: Split like: A A A …. A A is the symbol of even length How to Write Grammar? 1: Split like: A A A …. A A is the symbol of even length
How to Write Grammar? 2: Split like: X A A is the symbol of even length X is the symbol of aa or ab or bb or ba
How to Write Grammar? 3: Split like: A B A,B is the symbol of even length
How to Write Grammar? 4: Split like: A X A is the symbol of even length X is the symbol of aa or ab or bb or ba
How to Write Grammar? Split like: X A A is the symbol of even length X is the symbol of a or b
How to Write Grammar? 1: Split like: b…a and a…b
How to Write Grammar? 2: Split like: b…a… and a…b…
How to Write Grammar? 3: Split like: AB
How to Write Grammar? 3: Split it to two languages: L1 and L2 L1: n,m are even L2: n,m are odd
How to Write Grammar?
Type of Grammar Type-3 Grammar (Regular Grammar) Type-2 Grammar (Context free Grammar) Type-1 Grammar (Context Sensitive Grammar) Type-0 Grammar
Type-3 Grammar (Regular Grammar) If it would be right-linear: Or left-linear:
Type-3 Grammar (Regular Grammar)
Type-2 Grammar (Context Free Grammar)
Type-1 Grammar (Context Sensetive Grammar)
Type-1 Grammar (Context Sensitive Grammar)
Type-0 Grammar
Type-0 Grammar
Type of Language Type-3 Language (Regular Language) Type-2 Language (Context Free Language) Type-1 Language (Context Sensitive Language) Type-0 Language
Type of Language Type-3 If there is a type-3 grammar for it Type-2 If there is a type-2 grammar and no type-3 grammar for it Type-1 If there is a type-1 grammar and no type-3 and type-2 grammar for it Type-0 If there is a type-0 grammar and no type-3 and type-2 and type-1 grammar for it
Type of Language
Type of Automata Automata for type-3 language (Finite Automata) Automata for type-2 language (Push-down Automata) Automata for type-1 language (Linear Bounded Automata) Automata for type-0 language (Turing Machine)
Type of Automata
Finite Machine
Finite Machine Accept: If at the end of string, machine is stated in one of final states. Reject: If at the end of string, machine is stated in one of non-final states or before end of string it’ll be stoped.
Finite Machine
Finite Machine
Example
Language of a Finite machine If A is the set of all strings that machine M accepts, we say that A is the language of machine M and write: L(M) = A. M recognizes A M accepts A.
Finite Machine
Finite Machine
Finite Machine
Example