Computation Theory 2020-2021

1y ago
20 Views
2 Downloads
2.85 MB
169 Pages
Last View : 29d ago
Last Download : 3m ago
Upload by : Jacoby Zeller
Transcription

Computation Theory 2020-2021 الدراسات االولية / البكلوريوس / الفصل االول أستاذ المادة ا . م . وجدان عبد االمير حسن

Lec.1Advanced insect physiologyDr.May I.Younis

Formal Definition of grammarComputation Theory2nd Class/1st SemLecture 1 م وجدان عبد االمير حسن . ا

ComputationTheoryFirst Lecture

* Set:A set is a collection of objects withoutrepetition. Each object in a set is called anelement of the set for example D denotes theset of daysD {Sun., Mon., Tue., Wed., thru., Fri., Sat.}D {X X is a day of a week}T {0,1,2,3,4,5,6,7,8,9}

If an element X is an element of a set AThen we write X A and if X is not anelement of A we write X A thusMonday DMay D We say a set A is a subset of set Bwritten A С B{1, 2, 4} С {1, 2, 4, 5, 3}{1, 2, 6} {1, 2, 3 ,4 ,5 } Two sets A and B are sided equal writtenA B iff A and B contain the sameelements.

The Basic operation on sets are Unary operation ex. Complement. Binary operation ex. Union ( ), intersection ( ) anddifference.Aˉ {X X A} consist of all elements in the universe are not inA.A B {X X A or X B}A B {X X A and X B}A\B {X X A and X B}A2 the power set of A, is the set of all subset of A.

A graph denoted G (V, E), consist of a finite set ofvertices (or node) V and a set of pairs of vertices Ecalled edges. Example:134V {1, 3, 4}E {(1, 3), (3, 4)}

A directed graph (dgraph), also denoted G (V, E) consist of afinite set of vertices V and a set of ordered pairs of vertices Ecalled arcs.Example: The digraph G (V,E) where V {V,W,X} andE {(V,W),(V,X),(X,V), (W,X)}VWX

Products of SetsLet A1, A2 be two sets then the product of A1 and A2consist of all the pair (a1, a2) where a1 is in A1 and a2 is inA2.A1*A2 {(a1,a2) a1 A1 and a2 A2 }Example:If A1 {0, 1} and A2 {x, y, z}ThenA1*A2 {(0,x),(0,y),(0,z),(1,x),(1,y),(1,z)}

concatenation of string:The concatenation of two strings is the stringformed by writing the first followed by thesecond with no intervening space. Theconcatenation of x,y over denoted by xy.abcb is string .If X a1 a2 a3 a4 .an and Y b1 b2 b3 b4 .bnXY a1 a2 a3 a4 .an b1b2b3b4 .bnYX b1 b2 b3 b4 .bn a1 a2 a3 a4 .an

Language: A formal language is a set of string ofsymbols from some an alphabet.Closure: concatenation of Σ with itself for alllength of string.ExampleΣ {a, b, c}Σ 0 {ϵ}Σ 1 {a, b, c}Σ 2 {aa,ab,ac,ba,bb,bc,ca,cb,cc}Σ 3 {abc,aaa,aba,aab,baa,bba }Σ Σ 1υ Σ 2 υ Σ 3 υ Σ 4 Σ * Σ 0 υ Σ 1υ Σ 2 υ Σ 3 υ Σ 4

Σ Σ υ {ϵ}Σ Σ*- {ϵ}

Thanks forlistening

Formal Definition of grammarComputation Theory2nd Class/1st SemLecture 2 م وجدان عبد االمير حسن . ا

ComputationTheoryFinite State System

Finite State Systems:The finite automaton is a mathematical model ofsystem, with discrete inputs and outputs. The system canbe in any one of a finite number of configuration or states.The state of the system summarizes the information inputsthat are needed to determine the behavior of the system onsubsequent inputs.In computer science we find many examples of finite statesystems:1- Switching circuit, such as the control unit of a computer.2- The design of several common types of computeralgorithms and programs. For example the lexical analysisand text editors.

Basic definitions:A finite automaton (FA) consists of a finite set of statesand a set of transitions from state to state that occur on inputsymbols chosen from an alphabet Σ.for each input symbol there is exactly one transition out ofeach state(possibly back to the state itself).One state, usually denoted q0, is the initial state in which theautomaton starts. Some states are design as final or acceptingstates.A directed graph, called a transition diagram is associatedwith a FA as follows. The vertices of the graph correspond tothe states of the FA.

Basic definitions:If there is a transition from state q to state p oninput a, then there is an arc labeled a from state q to statep in the transition diagram. The FA accept a string x if thesequence of transitions correspond to the symbols of xleads from the start state to an accepting state.Example:q1q0letter a.zletter a.z0.9transition diagram of identifier

Deterministic Finite Automaton (DFA):Correspond It is an acceptor for any state and inputcharacter has at most one transition state that the acceptorchange to. If no transition state is specified the input stringis rejected.A DFA is a 5-tuple M (Q, Σ, δ, q0, F) WhereQ is a set of state.Σ is an input alphabet.δ is a transition functionδ Q * Σ Qq0 q0 Є Q is the initial state (the initial state is markedwith an incoming arrowor-

F is a set of final states F С Q(The final states are depicted using double circlesor Accepted string δ (q0, w) p Є F w acceptedElse w rejectThe language accepted by M, designated L (M),Language of Automata: L (M) :{ w: δ (q0, w) p, p Є F}Example1: Design a DFA that accepted the set of allstrings with an even number of 0's and 1’sL {11,1111,111111,11111111, .00,0000,000000,00000000, .0011,1100,001111,111100,110000,000011, .0101,1010,010111, . }

Solution: 1-transition Diagramq111q00 00 0q2q311Q {q0, q1, q2, q3}Σ {0, 1}F {q0}2-transition functionSuppose the string (110101) is input to Mδ(q0,110101) δ(δ(qo,1),10101) δ(δ(q1,1),0101) 𝜹(δ(q0,0),101) δ(δ(q2,1),01) ( δ(δ(q3,0),1) δ(q1,1) q0 ЄF The string is accepted.- The path o this stringq01q11q00q2 1q30q11q0

3-transition tableInput01- q0q2q1q1q3q0q2q0q3q3q1q2State

Example2: Design a DFA that accepted the set of all strings that beginand end with the same double letter, either of the form 00.00,11.11, Σ {0, 1}.L {0000,00000,000000,0000000, 00100,001100,0011111100,001111000, 1111,11111,111111,11111111, 11011,110011,1100000011, 110000111 }100q1q200q30q4q01q51q601q7q811

Example3: Design a DFA that accepted the set of all strings that have number of b'sdivisible by 3, Ɛ {a, b}.L {bbb,bbbbbb,bbbbbbbbb,abbb,abbba,aabbb,aabbbbbba, }bq0baq1baq2a

Example4: Design a DFA that accepted the set of all strings thathave total number of 0's divisible by 3, Ɛ {0, 1}Example5: Design a DFA that accepted the set of all stringsthat ending with double letter Ɛ {a, b}Example6: Design a DFA that accepted the set of all stringsthat ending in 00.Example7: Design a DFA that accepted the set of all stringsthat all zero must be 3 consecutive 0’sExample8: Design a DFA that accepted the set of all stringsthat does not contain 3 consecutive 1's.

Thanks forlistening

Formal Definition of grammarComputation Theory2nd Class/1st SemLecture 3 م وجدان عبد االمير حسن . ا

ComputationTheoryFinite State SystemNon Deterministic Finite Automata(NFA)

Non Deterministic Finite Automaton (NFA):It is the FA that allows one or more transition from a state on thesame input symbol.NFA is a 5-tuple M (Q, Σ, δ, q0, F) WhereWhere Q, Σ and F have the same meaning as for a DFA, but δ is amap fromQ * Σ to 2Q.(2Q is the power set of Q, the set of all subset of Q)-Transition diagramq0aaaaq1

Non Deterministic Finite Automaton (NFA):-Transition TableΣQ-Transition Functionδ ({q0, q1}, a) δ (q0, a) υ δ (q1, a)

Example1: NFA accept all string with either two consecutive 0's ortwo consecutive 1’s?0,1q00,10q30q41q11Q {q0, q1, q2, q3, q4}Σ {0, 1}F {q2,q4}q20,1Transition Diagram

Σ01-q0{q0,q3]{q0,q1}q1 {q2} q2{q2}{q2}q3{q4} q4{q4}{q4}QTransition Table-Transition FunctionSuppose (01001) input to machineδ (q0,01001) δ(δ(q0,0),1001) δ({q0,q3},1001) δ(δ(q0,1) υ δ(q3,1),001) δ({q0,q1},001) δ(δ(q0,0) υ δ(q1,0),01) δ({q0,q3},01) δ(δ(q0,0) υδ(q3,0),1) δ({q0,q3,q4},1) δ(q0,1) υ δ(q3,1) υ δ(q4,1) {q0,q1,q4}-An input string is accepted by NFA if there exists a sequence of transitionfor the given string that leads from the initial state to some final state{W Є Σ* δ (q0, w) F Ø}{q0, q1, q4} {q2,q4} Ø

The equivalence of DFA's and NFA'sFor every NFA can construct an equivalent DFA (one which accepts the samelanguage).DefinitionLet L be a set accepted by a non deterministic finite automata. Then there existsdeterministic finite automata that accept L.1101NFAAB0CDX1A2 {C,X},{A,B,C},{A,B,x},{B,C,x},{A, C, X}, {A, B, C, X}}δ ({A}, 0) Øδ ({A}, 1) {A,B}δ ({A,B}, 0) {A,C}δ ({A,B}, 1) {A,B}δ ({A,C}, 0) Øδ ({A, C}, 1) {A, B, X}δ ({A, B, X}, 0) {A, C}δ ({A, B, X}, 1) {A, B}

11{A,B}1{A,B,X}{A}0010{A,C}0{Ø}0,1

aExample 2:SaAabBsol :bbNFACaδ ({S}, a) {A}δ ({S}, b) {B}Sδ ({A}, a) {A,C}δ({A}, b) Øabδ ({B}, a) ØaØδ ({B}, b) {B,C}bδ({A,C}, b) Ø{B,C}δ ({B,C}, a) Øδ ({B,C}, b) {B,C}baabbBδ ({A,C}, a) {A,C}ADFA{A,C}

HW:- Convert the following NFA to the DFAaAabaCbBbbaDa

Thanks forlistening

Formal Definition of grammarComputation Theory2nd Class/1st SemLecture 4 م وجدان عبد االمير حسن . ا

ComputationTheoryFinite State SystemNon Deterministic Finite Automata withϵ - moves

Finite Automata with ϵ - movesTransition of NFA may be extended to include empty input ϵ.NFA accepts a siring w if there is some path labeled w from theinitial state to a final state.Of course, edges labeled ϵ may be included in the path, althoughthe ϵ's do not appear explicitly in w.Example:Consider an NFA with ϵ-moves which accepts the languageconsisting of any number (including zero) of 0's followed by anynumber of 1's followed by any number of 2’s.q00ϵq11ϵq22

DefinitionNondeterministic finite automata with ϵ -moves to be 5-tuple (Q, Ɛ, δ,q0, F) the transition function map Q*(Ɛ υ {ϵ}) to 1}q1Ø{q1}Ø{q2} q2ØØ{q2}ØTransitiontableThe transition function δ can be extended to a function δ that mapQ * Ɛ * to 2Q .- We use ϵ-closure (q) to denote the set of all P such that there is a pathfrom q to P labeled ϵ.ϵ-closure (q0) {q0, q1, q2}

Equivalence of NFA's with and without ϵ -movesTheorem: If L is accepted by NFA with ϵ-transition, then L is accepted by an NFAwithout ϵ-transitions.M (Q, Ɛ, δ, q0, F) be an NFA with ϵ-transitionMˉ (Q, Ɛ, δˉ, q0, Fˉ) whereF υ {q0} if ϵ-closure (q0) contains a state of FFˉ {Fotherwise

- δ (q0, ϵ) ϵ-closure (q0)- δ (q0, 0) ϵ-closure (δ (δ (q0, ϵ), 0)) ϵ-closure (δ ({q0, q1, q2}, 0)) ϵ-closure (δ (q0, 0) υ δ (q1, 0)υ δ (q2, 0)) ϵ-closure ({q0} υ Ø υ Ø) ϵ-closure (q0) {q0, q1, q2}

Example1 :- Construct DFA equivalent the following NFA with ϵq0q1ϵ0δ (q0,δ (q1,δ (q2,δ (q0,q2ϵ1ϵ) ϵ-closure (q0) {q0, q1, q2}ϵ) ϵ-closure (q1) {q1, q2}ϵ) ϵ-closure (q2) {q2}0) ϵ-closure (δ (δ (q0, ϵ), 0)) ϵ-closure (δ ({q0, q1, q2}, 0)) ϵ-closure (δ (q0, 0) υ δ (q1, 0) υ δ (q2, 0)) ϵ-closure ({q0} υ Ø υ Ø) ϵ-closure (q0) {q0, q1, q2}δ (q0, 1) ϵ-closure (δ (δ (q0, ϵ), 1)) ϵ-closure (δ ({q0, q1, q2}, 1)) ϵ-closure (δ (q0, 1) υ δ (q1, 1) υ δ (q2, 1)) ϵ-closure (Ø υ {q1} υ Ø) ϵ-closure (q1) {q1, q2}2

δ (q0, 2) ϵ-closure (δ (δ (q0, ϵ), 2)) ϵ-closure (δ ({q0, q1, q2}, 2)) ϵ-closure (δ (q0, 2) υ δ (q1, 2) υ δ (q2, 2)) ϵ-closure (Ø υ Ø υ {q2}) ϵ-closure (q2) {q2}δ (q1, 0) ϵ-closure (δ (δ (q1, ϵ), 0)) ϵ-closure (δ ({q1, q2}, 0)) ϵ-closure (δ (q1, 0) υ δ (q2, 0)) ϵ-closure (Ø υ Ø) ϵ-closure (Ø) {Ø}δ (q1, 1) δ (q1, 2) δ (q2, 0) δ (q2, 1) δ (q2, 2)

012- q0{q0,q1,q2}{q1,q2}{q2} q1Ø{q1,q2}{q2} q2ØØ{q2}01q00,12q11,20,1,2NFA with out ϵq2

NFA without ϵ to DFA012 -q0{q0,q1,q2}{q1,q2}{q2} {q0,q1,q2}{q0,q1,q2}{q1,q2}{q2} {q1,q2}Ø{q1,q2}{q2} {q2}ØØ{q2}00{q0,q1,q2}22{q0}21DFA1{q2}2{q1,q2}1

Thanks forlistening

Formal Definition of grammarComputation Theory2nd Class/1st SemLecture 5 م وجدان عبد االمير حسن . ا

ComputationTheoryRegular Expression

Regular Expression:- The languages accepted by finite automata are easily described bysimple expressions called Regular Expressions.- Let Σ be an alphabet. The regular expressions over Σ and the setsthat they denote are defined recursively as follows1- Ø is a regular expression and denotes the empty set {}.2- ϵ is a regular expression and denotes the set { ϵ }3- For each a in Σ, a is regular expression and denotes the set {a}.4- If r and s are regular expressions denoting the language R and S,respectively then (r s), (rs), and (r*) are regular expressions denotethe sets RυS, RS and R* respectively.

Regular Expression:- In writing regular expressions we can omit many parentheses if weassume that * has higher precedence than concatenation or , andthat concatenation has higher precedence than , for example((0(1*)) 0) may be written 01* 0.We may abbreviate the expression rr* by r .r* {ϵ,r, rr, rrr, rrrr, }r {r, rr, rrr, rrrr, }rr* r(ϵ,r, rr, rrr, rrrr, ) r,rr,rrr,rrrr, r 𝑖𝐿 σ 𝑖 0 𝐿𝑖𝐿 σ 𝑖 1 𝐿𝐿0 ϵ

Language Exampleexample1:Let L1 {10, 1} and L2 {011, 11}L1L2 {10011, 1011, 111}L1 L2 {10, 1, 011, 11}L1* {ϵ, 10, 1, 1010, 11, }L1 {10, 1, 1010, 11, }example2:L1 {01, 0}, L2 {ϵ, 0, 10}L1L2 {01, 010, 0110, 0, 00}L2L1 {01, 0, 001, 00, 1001, 100}L1ϵ L1 {01, 0}L1* {ϵ, 01,0,0101,00,010,001, }

Examples of Regular Expression 00 is a regular expression representing {00}.L {00}q00q10q2FA (0 1) * is a regular expression denotes all strings of 0's and1's.L {ϵ, 0, 1, 00, 11, 01, 10, }0,1q2q0

0* 1* is a regular expression denotes all strings of 0's and 1's0* {ϵ, 0, 00, 000, }1* {ϵ, 1, 11, 111, }L 0* 1* {ϵ ,0, 1, 00, 11, 000, 111, } 0*1*2* is a regular expression denotes the language of any numberof 0's followed by any number of 1's followed by any number of2’s. (0 1)*011 is a regular expression denotes the language of mixedgroup of 0's and 1's ended by 011. ((0 1)* 00 (0 1) * is a regular expression denotes the language ofall string of 0's and 1’s with at least two consecutive 0’s.

Finite Language L that contains all the strings of a's of b's of lengthexactly three L {aaa, aab, aba, abb, bab, bba, bbb,baa}. Thefirst letter of each word in L is either a or b, the second letter ofeach word in L is either is either a or b, the third letter of eachword in L is either a or b so we may write L ((a b)(a b)(a b)). a(a b)*b is a regular expression denotes the language of all wordsthat begin with a and end with b . (a b)*aa(a b)* is a regular expression denotes the language allwords over the alphabet Σ {a,b} with at least two consecutive a's (a b)*abb is a regular expression denotes the language of allstring of a's and b's ending in abb.

The language defined by the regular expression a*b* is the set ofall the string of a's and b's L { ϵ, a, b, aa, bb, ab, aaa, aab, abb,bbb, aaaa, }. Language of expressions a*b* (ab)*Since the language defined by the expression on the right containsthe word abab, which the language defined by the expression onthe left does not. Consider the language T defined over the alphabet Σ {a, b, c} ,T {a, c, ab, cb, abb, cbb, abbb, cbbb, abbbb, cbbbb, abbbbb,cbbbbb, }.All the words in T begin with an a or c and then are followed bysome number of b’s.Symbolical we may write this as T ((a c) b*).

(b ba)* is a regular expression denotes the language of all string ofa's and b's beginning with b and not having two consecutive a’s. (a b)*(aa bb)(a b) * is a regular expression denotes the languageof all words over the alphabet Σ {a,b} with at least two.consecutive a’s or two consecutive b’s The language defined by the regular expression ab*a is the set ofall string of a’s and b's that have at least two letters, that beginand end with a’sb* {ϵ,b,bb,bbb,bbbb, }L {aa, aba, abba, abbba, abbbba, }

Thanks forlistening

Formal Definition of grammarComputation Theory2nd Class/1st SemLecture 6 م وجدان عبد االمير حسن . ا

ComputationTheoryEquivalence of finite automata andregular expression

Equivalence of finite automata and regular expression:Non DeterministicFiniteautomata(NFA)NFA with ϵ-Deterministic FiniteAutomata(DFA)transitionRegular Expression(RE)

TheoremLet r be a regular expression. Then there exists an NFA with ϵ-transitionsthat accepts L(r).Case 0 (zero operation)qfq0q0(b) r Ø(a) r ϵq0a(C) r aqf

Regular Expression:Case 1 (one or more operators)r1r r1 r2q1M1f1ϵϵf0q0ϵq2M2r2f2ϵM1 (Q1, Σ1,𝛿1,q1,f1)M2 (Q2, Σ2,𝛿2,q2,f2) let q0 be a new initial state and f0 anew final stateM (Q1 Q2 {q0,f0}, Σ1 Σ2, 𝛿,q0,f0}

Case 2r r1r2M1q1ϵf1q2M2f2M (Q1 𝑄2, Σ1 Σ2, 𝛿,q1,f2}Case 3r r1*ϵq0ϵq1M1f1ϵM (Q1 {𝑞0, 𝑓𝑜}, Σ 1,𝛿,q0,f0}ϵf0

Case 3r r1 ϵq0ϵq1M1f1M (Q1 {𝑞0, 𝑓𝑜}, Σ1,𝛿,q0,f0}ϵf0

Example1Construct an NFA with ϵ for the following regular expressionRE 01* 1r r1 r2r2 1q11q2r1 01*q30q5q41q6ϵq7ϵq51ϵq6ϵq81*

Example1:Construct an NFA with ϵ for the following regular expression RE 01* 1ϵ0q3q4ϵ1q1q21q5q6ϵr1 01*q8ϵr2 11q1ϵϵq7q2ϵq0qfϵϵq30q4ϵq7ϵ1q5RE 01* 1ϵq6ϵϵq8

Example2Construct an NFA with ϵ for the following regular expressionRE (ba q10

Example3Construct an NFA with ϵ for the following regular expressionRE (01 10) ϵϵq131q14ϵq17ϵ1q15ϵq16ϵq18

Thanks forlistening

Computation Theory2nd Class/1st SemLecture 7 م وجدان عبد االمير حسن . ا

ComputationTheoryFinite Automata with output

Finite Automata with outputOne limitation of the finite automata as we havedefined it is that its output limited to a binarysignal: "accept/don’t accept”. Models in whichthe output is chosen from other alphabet havebeen considered.There are two distinct approaches; the outputmay be associated with the state(called a Mooremachine)or with the transition (called MealyMachine).

Moore machineA Moore machine is a six-tuple(Q,Σ, Δ, δ, λ, 𝑞0)where Q,𝜮, 𝜹and q0 are as in the DFA. 𝜟 is the output alphabet and λis a mapping from Q to Δ giving the output associated witheach state.The output of M in response to input a1a2 an , n 0,isλ (q0) λ (q1) λ (q2) λ (qn),where q0,q1,q2, qn is thesequence of states such that δ(qi-1,ai) qi for 1 i n.Note that any Moore machine gives output λ (q0) inresponse to input Є.

Example:y1y3z1q1z2z1z2q3y2q2z1z2Moore machineQ {q1,q2,q3,q4}𝛥 {y1,y2,y3}𝛴 {z1,z2}q0 q1z2q4y1𝝀 𝒒𝟏 y3𝜆(q2) y1𝜆(q3) y2𝜆(q4) y1z1

Example:y1y3z1q1q2z2z1z2q3z2z1z1q4z2y2y1The behavior of the Moore machine can be expressed in the formof the transition tabley3y1y2y1- q1q2q3q4z1q2q3q2q4z2q4q2q1q3outputinputstate

Example1Draw a transition diagram of a Moore machine to determine the remainder(mod3)For each binary string treated as binary integer.01234567890001101110010111011110001001(0 mod 3) 0(1 mod 3) 1(2 mod 3) 2(3 mod 3) 0(4 mod 3) 1(5 mod 3) 2(6 mod 3) 0(7 mod 3) 1(8 mod 3) 2(9 mod 3) 0011q0002q11Moore machineq201

Mealy machineA Mealy machine is a six-tuple(Q,Σ, Δ, δ, λ, 𝑞0) where all is in theMoore machine, except that λ maps Q * 𝛴 to Δ .That is λ(q,a) gives the output associated with the transitionfrom state q on input a. The output of M in response to inputa1a2a3a4 an is λ(q0,a1), λ(q1,a2), λ(q2,a3) λ(qn-1,an) , whereq0,q1,q2, qn is the sequence of states such that δ(qi-1,ai) qifor 1 i n.Note that this sequence has length n rather than length n 1 asfor the Moore machine and on input Є a Mealy machine givesoutput Є.

Example:Consider the language(0 1)* (00 11) for all strings of 0’s and 1’s whoselast two symbols are the 0p1inputinput0p0p0p00nyn1p1p1p11nnyδ tableλ table

Equivalence of Moore and Mealy machines:Theorem If M1 (Q,Σ, Δ, δ, λ, 𝑞0) is a Moore machine, thenthere is a Mealy machine M2 equivalent to M1.Proof: Let M2 (Q,𝛴, 𝛥, 𝛿, 𝜆 , 𝑞0) and define 𝝀 (q,a) to be𝝀(𝜹(q,a)) for all states q and input symbols a. Then M1 andM2 enter the same sequence of states on the same input,and with each transition M2 emits the output that M1associates with the state entered.

Example1: Convert the following Moore machine to mealy machine.01q010q12q2Moore machine100𝝀 (q,a) 𝝀(𝜹(q,a))1Σ {0,1}Δ {0,1,2}𝜆 (q0,0) 𝜆(𝛿(q0,0)) 𝜆 (q0) 0𝜆 (q0,1) 𝜆(𝛿(q0,1)) 𝜆 (q1) 1𝜆 (q1,0) 𝜆(𝛿(q1,0)) 𝜆 (q2) 2𝜆 (q1,1) 𝜆(𝛿(q1,1)) 𝜆 (q0) 0𝜆 (q2,0) 𝜆(𝛿(q2,0)) 𝜆 (q1) 1𝜆 (q2,1) 𝜆(𝛿(q2,1)) 𝜆 (q2) 20/21/1q1q00/01/0q20/11/2Mealy machine

Equivalence of Moore and Mealy machines:Theorem let M1 (Q,Σ, Δ, δ, λ, 𝑞0) be a Mealy machine, thenthere is a Moore machine M2 equivalent to M1.

Thanks forlistening

Formal Definition of grammarComputation Theory2nd Class/1st SemLecture 8 م وجدان عبد االمير حسن . ا

ComputationTheoryKleene's Theorem

Kleene's theoremAny language that can be defined by1-Regular Expression2-Finite Automata3-Transition GraphPart1:-Every language that can be defined by afinite automata can also be defined by a transitiongraph.Every finite automata is itself a transition graph.therefore, any language that has been defined by afinite automata has already been defined by atransition graph.

Part2:-Every language that can be defined by atransition graph can also be defined by a regularexpression.This means that we present a procedure that starsout with a transition graph and ends with a regularexpression that defined the same language.First want to simply T so that it has only one startbЄq3Єabaaq5q4

Another simplification we can make in TG is that itcan be modified to have a unique final state withoutchanging the language it accepts.bq8aaababbecomesЄaaabaq9q8qfЄq9It should be clear that the addition of these two new statesdoes not affect the language that TG(transition graph)accepts. Any word accepted by old TG is also accepted bythe new TG, and any word rejected by the old TG is alsorejected by the new TG.

Pass operation:- If three states in arrow connected by edges labeled withregular expression, we can eliminate the middleman and go directly fromone outer state to the other by a new edge labeled with a regularexpression that is the concatenation of the two previous labels.r1r3q2q1q3We can replace this withq1r1r3q3r2q1r1q2r3becomesq1r1r2*r3q3q3

Example:-TG which accepts all words that begin and end with �q1q4bbq3Єa baaq0aa bbq2Єq4q1bbq3Є

Example:-TG which accepts all words that begin and end withdouble lettersa bq0aa bbaaq4q1bbЄq3a bq0aaaa bbq1q4bb(aa bb)(a b)*aaq0q4(aa bb)(a b)*bb(aa bb)(a b)*aa (aa bb)(a b)*bbq0q4Re (aa bb)(a b)*aa (aa bb)(a b)*bb (aa bb)(a b)* (aa bb)

homework:-The following TG which accepts all words with aneven number of a’s and even number of b’saa,bbaa,bbab,baq2ab,baWhat is the regular expression of the above diagram ?aa,bbq0aa,bbab,baϵq2ϵab,ba

aa bbq0aa bbab baϵq2ϵab baaa bbq0ϵϵ(ab ba)(aa bb)*(ab ba)

(aa bb) (ab ba)(aa bb)*(ab ba)q0ϵϵ[(aa bb) (ab ba)(aa bb)*(ab ba)]*q0RE [(aa bb) (ab ba)(aa bb)*(ab ba)]*

Part 3:- Every language that can be defined by aregular expression can also be defined by a finiteautomata.If there is an FA called FA1 that accepts the languagedefined by regular expression r1 and there is an FAcalled FA2 that accepts the language defined by theregular expression r2, then there is an FA called FA3that accepts the language defined by regularexpression (r1 r2).

Example:Find FA1 FA2bFA1aax2x1ba,bax3FA2by1abFA1 the machine that accepts only strings with a double a in themFA2 the machine that accepts all words that end in the letter bab-Z1 [x1,y1]z2 [x2,y1]Z3 [x1,y2]Z2 [x2,y1]Z4 [x3,y1]Z3 [x1,y2] Z3 [x1,y2]Z2 [x2,y1]Z3 [x1,y2] Z4 [x3,y1]Z4 [x3,y1]Z5 [x3,y2] Z5 [x3,y2]Z4 [x3,y1]Z5 [x3,y2]az1baabbbz2z3z4abaz5FA1 FA2y2

-If there is an FA called FA1 that accepts thelanguage defined by regular expression r1 and thereis an FA called FA2 that accepts the language definedby the regular expression r2, then there is an FAcalled FA3 that accepts the language defined byregular expression (r1.r2).

Example:Find FA1.FA2baaFA1x2x1ba,bax3y1FA2by2abFA1 the machine that accepts only strings with a double a in themFA2 the machine that accepts all words that end in the letter basolutionb-Z1 [x1]z2 [x2]Z1 [x1]Z2 [x2]Z3 [x3,y1]Z1 [x1]Z3 [x3,y1]Z3 [x3,y1]Z4 [x3,y1,y2]Z3 [x3,y1]Z4 [x3,y1,y2] Z4 [x3,y1,y2]baz1babz2abz3z4aFA1.FA2

Thanks forlistening

Formal Definition of grammarComputation Theory2nd Class/1st SemLecture 9 م وجدان عبد االمير حسن . ا

ComputationTheoryGrammar

The formal definition of GrammarG (V,T,P,S) WhereV is a Finite set of Variable(non-terminal)(represented by upper caseletters)T is a Finite set of terminal (represent by lower case letter)P is a Finite set of productionS is called the start symbol (non-terminal)Example:G ({S,A,B},{a,b},P,S} consist of productionS 𝑨 𝑩A aA aPB bB bS 𝐴 aS 𝐵 bS 𝐴 aA aaS B bB bbS 𝐴 aA aaA aaaS B bB bbB bbbS 𝐴 aA aaA aaaA aaaa S B bB bbB 𝑏𝑏𝑏𝐵 bbbbL(G) { an n 1} υ {bn n 1}

Derivation:- is used to generate(determine)sentence of thegiven language,(and it is sequence of application the rule toproduce the finished string of terminal from S.Notations denotes derivation𝛼 𝛽G: 𝛼 drives 𝛽 by one application of some production*𝛼 𝛽G: 𝛼 drives 𝛽 by zero or more applicationi𝛼 𝛽G: 𝛼 drives 𝛽 by exactly i step

Definition :- The language generated by G [denotedL(G)] is {w w in T* and S *G w} that is, a string is inL(G) if:1) The string consists solely of terminals.2) The string can be derived from S.Example:ConsiderthefollowinggrammarG {{S},{a},P,S} where P consist ofS aS aS aaaSolution:S aS aS aaS aS aaS aaanL(G) { a n 1}

Leftmost and rightmost derivations:If at each step in a derivation a production is applied tothe left most variable, then the derivation is said to beleftmost.Similarity a derivation in which rightmost variable isreplaced at each step is said to be rightmost.Example:Consider the grammar G ({S,A},{a,b},P,S), where Pconsist ofS aAS aA SbA SS bathe word aabbaaLeftmost derivationS aAS aSbAS aabAS aabbaS aabbaaRightmost derivationS aAS aAa aSbAa aSbbaa aabbaa

Derivation Trees:If is useful to display derivations as trees. Thesepictures, called derivation(or generation orproduction or syntax)trees.Leaf: a vertex which has no sons, usually representa terminal.Interior vertex: a vertex which has one or moresons usually 𝑉.Yield of the derivation tree: if we read the labelof the leaves from left to right, we have asentential form, we call this string the yield.

Example:Consider the grammar G ({S,A},{a,b},P,S}, where P consist ofS aAS aA SbA SS baDraw the derivation tree of the string(aabbaa)S aAS aSbAS aabAS aabbaS aabbaaSaRoot(non terminal)SASabaAba

Example:Consider the grammar G ({E},{id,(,),*, },P,E}, where P consist ofE E E E*E (E) idDraw the derivation tree of the string( (id id)*id )E E*E (E)*E (E E)*E (id E)*E (id id)*E (id id)*idE Root(non terminal)E*(E)E EididEidterminal

Thanks forlistening

Formal Definition of grammarComputation Theory2nd Class/1st SemLecture 10 م وجدان عبد االمير حسن . ا

ComputationTheoryType of Grammar

A phrase Structure Grammar(PSG)Is a 4 tuple (V,T,P,S) WhereV :Finite set of non-terminals.T :is a Finite set of terminals such that V T .P :is a Finite set of production of the form 𝛼 𝛽,where 𝛼 the string on the left hand side of theproduction, is such that 𝜶 (𝑽 𝑻) and 𝛽 thestring on the right hand side of the production, issuch 𝜷 (𝑽 𝑻) *.S V is symbol designed as the start symbol of thegrammar.

Example1:Consider the PSG,G1 ({S,A,B},{a,b},P,S) with productionS 𝐴S 𝐵A aAA aB bBB bThe above productions can be abbreviatedS 𝐴 𝐵A aA a pB bB bL(G1) {an n 1} {bn n 1}

Example2:Consider the PSG,G2 {{S,B,C},{a,b,c},P,S} with productionS 𝑎S𝐵𝐶 𝑎𝐵𝐶CB BCaB abpbB bbbC bccC ccIn this example the left side of the production are not all singlenon terminal.* 𝑎𝑎𝑏𝑏𝑐𝑐S S aBC abC abcS aSBC aaBCBC aabCBC aabBCC aabbCC aabbcC aabbccL(G2) {an bnnc n 1}

Some time ,it ma be that two different grammar Gand G generate the same language L(G) L(G ).In this case the grammars are said to be equivalent .An example of a grammar equivalent to G1 is G3with productionsS aA bB a bA aA apB bB bPSG is also known as unrestricted grammar.

Context Sensitive Grammar(CSG)Suppose a restriction is placed on productions𝜶 𝜷 𝜶 𝜷 that 𝛽 𝑏𝑒 𝑎𝑡 𝑙𝑒𝑎𝑠𝑡 𝑎𝑠 𝑙𝑜𝑛𝑔 𝑎𝑠 𝛼 .Then the resulting grammar is called ContextSensitive grammar(CSG)and the language a ContextSensitive language(CSL).The term “Context-Sensitive” comes from a normalform for these grammar, where each production is ofthe form 𝛼1𝐴𝛼2 𝛼1B𝛼2, with B 𝜖, they permitreplacement of variable A by string B only in the"context"𝛼1𝛼2.

Example:Consider the CSG,G ({S,B},{x,y,z},P,S} with productionS 𝐁𝐲𝐳B x xBcpcy yccz yzz* xxxyyyzzzS S Byz xyzS Byz xBcyz xxcyz xxycz xxyyzzS Byz xBcyz xxBccyz xxxccyz xxxcycz xxxyccz xxxycyzz xxxyyczz xxxyyyzzzL(G) {xn yn zn n 1}

Context Free Grammar(CFG)A limiting to the left-hand sides of each production𝛼 𝛽 in a CSG to be a single nonterminal A B where A 𝑽 𝒂𝒏𝒅 𝑩 𝑽 𝑻 .Example1: Consider a grammar G ({S},{a,b},P,S)and Pis the following setS aSb ab pS abS aSb aabbS aSb aaSbb aaabbbS aSb aaSbb aaaSbbb aaaabbbbL(G) {an bn n 1}

Example2: Consider a grammar G ({S},{a,b},P,S)and Pis the following setS aSb 𝝐 𝑷S 𝜖S aSb abS aSb aaSbb aabbS aSb aaSbb aaaSbbb aaabbbS aSb aaSbb aaaSbbb aaaaSbbbb aaaabbbbL(G) {an bn n 0}

Example3: Consider a grammar G ({S},{a,b},P,S)and Pis the following setS aB bAA aS a bAA PB bS b aBB* abbaS S aB abS abbA abba* bababaS S bA baS babA babaS bababA bababa* baabbaS S bA baS baaB baabS baabbA baabba The language L(G) is the set of all words in Tconsisting of equal number of a’s and b’s.

Example 4: Consider a grammarG ({S,A},{a,b,c,d},P,S)and P is the following setS aSd aAd pA bAc bcS aSd aaAdd aabcddS aSd aaAdd aabAcaa aabb

In computer science we find many examples of finite state systems:-1- Switching circuit, such as the control unit of a computer. . Theory Finite State System Non Deterministic Finite Automata (NFA) Non Deterministic Finite Automaton (NFA): . Let L be a set accepted by a non deterministic finite automata. Then there exists

Related Documents:

CS663 Theory of Computation 1 Introduction 1.1 What is Theory of Computation? Theory of Computation is to study the fundamental capabilities and limitations of computers. It is all about bounds. It contains three areas. Automata theory: Models of computation. Seeking a precise but concise definition of a computer. FA!PDA!LBA!TM.

Intro to Theory Computation Notes New Beginnings, Summer 2018 David Lu August 26, 2018 Contents 1 Theory of Computation 2 2 Alphabets 2 . theory of computation class at PSU (CS311) is primarily a class about abstract machines. The graduate theory of computation class (CS581) is concerned more with diving in to the .

these works focus on traffic offloading rather than computation offloading, and computation offloading decisions have to con-sider the delay and energy consumption of both computation execution and data transmission. In this paper, we propose a Peer-Assisted Computation Offloading (PACO) framework to enable computation offload-

L00: Introduction to Theory of Computation (Pre Lecture) Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2021 Dantam (Mines CSCI-561) L00: Introduction to Theory of Computation (Pre Lecture) Fall 2021 1/33

F14 CSE550 45 Combinatorial Algorithms and Intractability S14 CSE 555 46 Advanced Theory of Computation S14 CSE591/MAT591 40 Combinatorial Design Theory F13 CSE 355 82 Intro Theory of Computation F13 CSE 552 32 Randomized and Approximation Algorithms S13 CSE 555 30 Advanced Theory of Computation S1

Class Notes on Theory of Computation [BCT II/I] Chapter 1: Review of Set Theory Compiled By : Hari Prasad Pokhrel [hpokhrel24@gmail.com] Page 1 of 20 Chapter 1: Introduction Introduction Purpose of the Theory of Computation: Develop formal mathematical models of computation that reflect real-world computers.

theory of computation: – Automata and Languages – Computability Theory – Complexity Theory This course is about the fundamental capabilities and limitations of computers/ computation 9/5/19 Theory of Computation - Fall'19 Lorenzo De Stefani 2

Lecture notes on Automata Theory and Computability(subject code: 15CS54) - Module -1: By Prof B I Khodanpur, DSCE Module - 1: Syllabus:- Why study the theory of computation(ch-1) Languages and strings(ch-2) A Language Hierarchy(ch-3) Computation(ch-4) Finite State Machines(ch-5 from 5.1 to 5.10) Why study the theory of computation(ch-1)