SlideShare a Scribd company logo
1 of 9
Download to read offline
NAME ………………………………….AHSAN IFTIKHAR
ROLL NO………………………………..564
COURCE NAME ………………………Theory of automata
ASSIGNMENT TOPIC………………….SET theory and automata
SEMESTER………………………………….4th
EVENING
SUBMITED TO…………………………….SIR MOHSIN RAZA
DATE ……………………………………..11/07/2020
Q 1 : Define and explain the following terms ?
1) Context free gramer :” CFG stand for context free grammer it is formal
grammer which is used to generate all possibles patterns of strings in a
given FL CFG can be define by four tupels as G(v,t,p,s)”
G: is grammer which consist of a set of production rule it is use to generate the
string of a language
T: is a final set of terminal symbol .it is denoted by lower case letters
V: is final set of non –terminal symbols it is denoted by capital letter
P: is a set of production rule which is use to replacing non-terminal symbols (of
left side)in a string with other non terminal symbol (of right side) of product.
S: is the short symbol to derive the string.
2) Regular expression: “The language accepted by finite automata can be
easily described by simple expression called regular expression”
A regular expression can also be described as a sequience of pattern that
define a string . regular expression are used to match character combinater in
string.
3) Context free language : “a language which is generated by a CFG is
called a context free language “
CFL is the set of all strings of terminal that can be produced from the start
symbol using the production as substitution
4 ) Dterministic Finite Automata : DFA is the type of finite automata it is
used to define a language it is graphical method when we know the next
state then we call the deterministic finite automata it consist of five parts
for example L1 ={aaa}
Q: number of states
Q0: initial state
F: final state
∑: letters in alphabets
Transition movement
In above example we canot string and double letter at one state in dfa we
pas single character at one state
Difference between DFA and NFA is as follow
NFA : in above we cannot recognize exact path to
moving next state q1 and Q3 therefore we call it non deterministic finite
automata
DFA: in above example we recognize the next state easily
therefore we call it deterministic finoite automata we ha no confusion to
moving next state
Q 2(A) : Explain the following term:
a) Automata: is greek letter automata is a word formulated from automations
which means machines designing or replaving humain beings with machines it
is the plural of automation and it means something that work automatically
Kinds of automata:
1) Finite no temporary memory
2) Push down STAC
3) Turning machine Random access memory
Types of automata
1 Deterministic Finite Automata (DFA)
2 Non deterministic Finite Automata (NFA)
in NFA we cannaot recognize next statement
in DFA we recognize next statement easily
b) Set theory : a set is an un order collection of objects s={a,b,c}
A,b,c are element or member of set s elements in set need no relation to each
other
Example: S = {1,2,3,4,5,} B = {red,blue,green,pink}
In above example there is no relation in both set s and b
Q 2 (b) For the following relation between sets A and set B mention if they are
one to one /or onto :
A = {a,b,c} B = {1,2,3}
1) { (a,1),(b,1),(c,1) } this is not onto/one to one function .it is into
function
2) { (a,2),(b,2),(c,3) } this is not onto/one to one function it is also into
function
3) { (a,1),(a,2),(b,2),(c,3)} this is no function
4) { (a,2),(b,1),(c,2) } this is not onto /one to one function it is also into
function
Q 3(A) construct an example of DFA ? write down the steps to convert
FA to DFA
Draw a DFA that start with ab ab(a+b)*
Q0 : is initial state Q1 : is running state Q2 : is final state Q3: is reject state
Steps to convert FA into DFA :
1) Initialy Q= ϕ
2) Add Q0 of NFA to Q then find the transition from this start state .
3) In Q find the possible set of states for each input symbol if this set of state
is not in Q,
then add it to Q,
4) In DFA the final state will be all state which contain F (final state of
NFA)
Example :
Q 4 (b) : construct DFA for the following regular expression :(a/b)*
ab*
?
The full form of DFA is deterministic finite automata
In above diagram first we draw initial state and send “a” to next final state
and (a/b) means (a+b) sterik means we use loop in q0 and in final state we also
use loop
Q 4(a) consider the language S*,where S = {aa b}. how many words does
this language have of length 4?of length 5? What can be said in general ?
Consider the language S*
over S = {aa b} the words of the language having
length 4 are { baab,bbaa,bbbb,aaaa,aabb }there are five words of length 4 in
the language S
The language having length 5 are {
aabaa,aaaab,aabbb,baaaa,bbbbb,aabaa,bbbaa,aabbb,bbaab,baabb,bbaab,aabaa}
there are 12 words of length 5 in the language S
Q 4(b) construct a regular expression defining each of the following
language over the alphabets ∑ = { a b }:
1 ) all words in which a appears tripled, if at all.this means that every
clump of a,
s contains 3 or 6 or 9 or 12 ……a,
s .
ANS is (aaa+b)*
2) All strings that have exactly one double letter in them
ANS is (b*aab*+a*bba*)
3 ) All words that contain exactly two b,
s or exactly three b,
s, not more
ANS is ( a*ba*ba*) +( a*ba*ba*ba*)
Q-5(a): What is relationship between regular language and context free
grammer?Discuss them?Construct a language that can be generated by
CFG?
RELATIONSHIP BETWEEN REGULAR LANGUAGE AND CONTEXT
FREE GRAMMER:
Regular language is either right or left linear ,whereas context free grammer is
basically any combination of terminal and non-terminal . Hence you can see
regular language is a subset of context free grammer.
A regular language can be recoganized by a finite automata.A context free
grammer requires a stack. Basically regular language is a subset of context free
grammer, but we can not say every context free grammer is regule grammer.
Construct a language generated by CFG:
(a,b)*
{aacaa,bcb,abcba,abbcbba}
S aSa rule 1
S bSb rule 2
S c rule 3
Now if we derived a string abbcbba
S aSa
S abSba from rule 2
S abbSbba from rule 2
S abbcbba from rule 3
Q(5)b:consider the context free grammer
S ax x ax|bx|ϕ y bbb
(a+b)*bbb(a+b)*
S ax
S aax
S aabx
S aabbx
S aabbbx
S aabbbbx
S aabbbax
S aabbbaax
S aabbbbaabx
S aabbbbaabϕ

More Related Content

What's hot

Chomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel KhanChomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel KhanM Khan
 
Chapter 2 2 1 2
Chapter 2 2 1 2Chapter 2 2 1 2
Chapter 2 2 1 2bolovv
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Animesh Chaturvedi
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFAMaulik Togadiya
 
Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Srimatre K
 
REGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.AREGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.ADev Ashish
 
String Matching with Finite Automata,Aho corasick,
String Matching with Finite Automata,Aho corasick,String Matching with Finite Automata,Aho corasick,
String Matching with Finite Automata,Aho corasick,8neutron8
 
Nondeterministic Finite Automat
Nondeterministic Finite AutomatNondeterministic Finite Automat
Nondeterministic Finite AutomatAdel Al-Ofairi
 
SMU MCA SEM 1 FALL 2014 ASSIGNMENTS
SMU MCA SEM 1 FALL 2014 ASSIGNMENTSSMU MCA SEM 1 FALL 2014 ASSIGNMENTS
SMU MCA SEM 1 FALL 2014 ASSIGNMENTSsolved_assignments
 
Lecture: Context-Free Grammars
Lecture: Context-Free GrammarsLecture: Context-Free Grammars
Lecture: Context-Free GrammarsMarina Santini
 
Mat 222 week 1 dq 1 can't cancel terms (ash)
Mat 222 week 1 dq 1 can't cancel terms (ash)Mat 222 week 1 dq 1 can't cancel terms (ash)
Mat 222 week 1 dq 1 can't cancel terms (ash)jackfruits
 

What's hot (20)

Chomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel KhanChomsky by zeeshan khan and Raheel Khan
Chomsky by zeeshan khan and Raheel Khan
 
Chapter 2 2 1 2
Chapter 2 2 1 2Chapter 2 2 1 2
Chapter 2 2 1 2
 
Cs419 lec5 lexical analysis using dfa
Cs419 lec5   lexical analysis using dfaCs419 lec5   lexical analysis using dfa
Cs419 lec5 lexical analysis using dfa
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
Exploring radicals
Exploring radicalsExploring radicals
Exploring radicals
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5Formal Languages and Automata Theory unit 5
Formal Languages and Automata Theory unit 5
 
Sorting
SortingSorting
Sorting
 
REGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.AREGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.A
 
String Matching with Finite Automata,Aho corasick,
String Matching with Finite Automata,Aho corasick,String Matching with Finite Automata,Aho corasick,
String Matching with Finite Automata,Aho corasick,
 
Unit i
Unit iUnit i
Unit i
 
Nondeterministic Finite Automat
Nondeterministic Finite AutomatNondeterministic Finite Automat
Nondeterministic Finite Automat
 
+Azar
+Azar+Azar
+Azar
 
SMU MCA SEM 1 FALL 2014 ASSIGNMENTS
SMU MCA SEM 1 FALL 2014 ASSIGNMENTSSMU MCA SEM 1 FALL 2014 ASSIGNMENTS
SMU MCA SEM 1 FALL 2014 ASSIGNMENTS
 
finite automata
 finite automata finite automata
finite automata
 
Cs419 lec6 lexical analysis using nfa
Cs419 lec6   lexical analysis using nfaCs419 lec6   lexical analysis using nfa
Cs419 lec6 lexical analysis using nfa
 
2.3 CONTINUITY
2.3 CONTINUITY2.3 CONTINUITY
2.3 CONTINUITY
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
Lecture: Context-Free Grammars
Lecture: Context-Free GrammarsLecture: Context-Free Grammars
Lecture: Context-Free Grammars
 
Mat 222 week 1 dq 1 can't cancel terms (ash)
Mat 222 week 1 dq 1 can't cancel terms (ash)Mat 222 week 1 dq 1 can't cancel terms (ash)
Mat 222 week 1 dq 1 can't cancel terms (ash)
 

Similar to Atomata assignment 1 solution

4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...venkatapranaykumarGa
 
finite_automata.ppt
finite_automata.pptfinite_automata.ppt
finite_automata.pptAkhlasHashim
 
Lecture 17- F19.pdf
Lecture 17- F19.pdfLecture 17- F19.pdf
Lecture 17- F19.pdfAbrar11535
 
Theory of computing presentation
Theory of computing presentationTheory of computing presentation
Theory of computing presentationMd. Touhidur Rahman
 
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...parmeet834
 
Regular expression
Regular expressionRegular expression
Regular expressionRajon
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysisIffat Anjum
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular ExpressionsMatt Casto
 

Similar to Atomata assignment 1 solution (20)

4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
4-Regular expression to Deterministic Finite Automata (Direct method)-05-05-2...
 
Lec1.pptx
Lec1.pptxLec1.pptx
Lec1.pptx
 
Final fa part1
Final fa part1Final fa part1
Final fa part1
 
Automata theory
Automata theoryAutomata theory
Automata theory
 
Perl Presentation
Perl PresentationPerl Presentation
Perl Presentation
 
flat unit1
flat unit1flat unit1
flat unit1
 
finite_automata.ppt
finite_automata.pptfinite_automata.ppt
finite_automata.ppt
 
Lecture 17- F19.pdf
Lecture 17- F19.pdfLecture 17- F19.pdf
Lecture 17- F19.pdf
 
Lex analysis
Lex analysisLex analysis
Lex analysis
 
Lecture2 B
Lecture2 BLecture2 B
Lecture2 B
 
NLP_KASHK:Finite-State Automata
NLP_KASHK:Finite-State AutomataNLP_KASHK:Finite-State Automata
NLP_KASHK:Finite-State Automata
 
Theory of computing presentation
Theory of computing presentationTheory of computing presentation
Theory of computing presentation
 
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
 
Hwsoln03 toc
Hwsoln03 tocHwsoln03 toc
Hwsoln03 toc
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
UNIT_-_II.docx
UNIT_-_II.docxUNIT_-_II.docx
UNIT_-_II.docx
 
Lecture 03 lexical analysis
Lecture 03 lexical analysisLecture 03 lexical analysis
Lecture 03 lexical analysis
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular Expressions
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 

Recently uploaded

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 

Recently uploaded (20)

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 

Atomata assignment 1 solution

  • 1. NAME ………………………………….AHSAN IFTIKHAR ROLL NO………………………………..564 COURCE NAME ………………………Theory of automata ASSIGNMENT TOPIC………………….SET theory and automata SEMESTER………………………………….4th EVENING SUBMITED TO…………………………….SIR MOHSIN RAZA DATE ……………………………………..11/07/2020
  • 2. Q 1 : Define and explain the following terms ? 1) Context free gramer :” CFG stand for context free grammer it is formal grammer which is used to generate all possibles patterns of strings in a given FL CFG can be define by four tupels as G(v,t,p,s)” G: is grammer which consist of a set of production rule it is use to generate the string of a language T: is a final set of terminal symbol .it is denoted by lower case letters V: is final set of non –terminal symbols it is denoted by capital letter
  • 3. P: is a set of production rule which is use to replacing non-terminal symbols (of left side)in a string with other non terminal symbol (of right side) of product. S: is the short symbol to derive the string. 2) Regular expression: “The language accepted by finite automata can be easily described by simple expression called regular expression” A regular expression can also be described as a sequience of pattern that define a string . regular expression are used to match character combinater in string. 3) Context free language : “a language which is generated by a CFG is called a context free language “ CFL is the set of all strings of terminal that can be produced from the start symbol using the production as substitution 4 ) Dterministic Finite Automata : DFA is the type of finite automata it is used to define a language it is graphical method when we know the next state then we call the deterministic finite automata it consist of five parts for example L1 ={aaa} Q: number of states Q0: initial state F: final state ∑: letters in alphabets Transition movement
  • 4. In above example we canot string and double letter at one state in dfa we pas single character at one state Difference between DFA and NFA is as follow NFA : in above we cannot recognize exact path to moving next state q1 and Q3 therefore we call it non deterministic finite automata DFA: in above example we recognize the next state easily therefore we call it deterministic finoite automata we ha no confusion to moving next state
  • 5. Q 2(A) : Explain the following term: a) Automata: is greek letter automata is a word formulated from automations which means machines designing or replaving humain beings with machines it is the plural of automation and it means something that work automatically Kinds of automata: 1) Finite no temporary memory 2) Push down STAC 3) Turning machine Random access memory Types of automata 1 Deterministic Finite Automata (DFA) 2 Non deterministic Finite Automata (NFA) in NFA we cannaot recognize next statement in DFA we recognize next statement easily b) Set theory : a set is an un order collection of objects s={a,b,c} A,b,c are element or member of set s elements in set need no relation to each other Example: S = {1,2,3,4,5,} B = {red,blue,green,pink} In above example there is no relation in both set s and b Q 2 (b) For the following relation between sets A and set B mention if they are one to one /or onto : A = {a,b,c} B = {1,2,3} 1) { (a,1),(b,1),(c,1) } this is not onto/one to one function .it is into function
  • 6. 2) { (a,2),(b,2),(c,3) } this is not onto/one to one function it is also into function 3) { (a,1),(a,2),(b,2),(c,3)} this is no function 4) { (a,2),(b,1),(c,2) } this is not onto /one to one function it is also into function Q 3(A) construct an example of DFA ? write down the steps to convert FA to DFA Draw a DFA that start with ab ab(a+b)* Q0 : is initial state Q1 : is running state Q2 : is final state Q3: is reject state Steps to convert FA into DFA : 1) Initialy Q= ϕ 2) Add Q0 of NFA to Q then find the transition from this start state . 3) In Q find the possible set of states for each input symbol if this set of state is not in Q, then add it to Q, 4) In DFA the final state will be all state which contain F (final state of NFA) Example :
  • 7. Q 4 (b) : construct DFA for the following regular expression :(a/b)* ab* ? The full form of DFA is deterministic finite automata In above diagram first we draw initial state and send “a” to next final state and (a/b) means (a+b) sterik means we use loop in q0 and in final state we also use loop Q 4(a) consider the language S*,where S = {aa b}. how many words does this language have of length 4?of length 5? What can be said in general ? Consider the language S* over S = {aa b} the words of the language having length 4 are { baab,bbaa,bbbb,aaaa,aabb }there are five words of length 4 in the language S The language having length 5 are { aabaa,aaaab,aabbb,baaaa,bbbbb,aabaa,bbbaa,aabbb,bbaab,baabb,bbaab,aabaa} there are 12 words of length 5 in the language S Q 4(b) construct a regular expression defining each of the following language over the alphabets ∑ = { a b }:
  • 8. 1 ) all words in which a appears tripled, if at all.this means that every clump of a, s contains 3 or 6 or 9 or 12 ……a, s . ANS is (aaa+b)* 2) All strings that have exactly one double letter in them ANS is (b*aab*+a*bba*) 3 ) All words that contain exactly two b, s or exactly three b, s, not more ANS is ( a*ba*ba*) +( a*ba*ba*ba*) Q-5(a): What is relationship between regular language and context free grammer?Discuss them?Construct a language that can be generated by CFG? RELATIONSHIP BETWEEN REGULAR LANGUAGE AND CONTEXT FREE GRAMMER: Regular language is either right or left linear ,whereas context free grammer is basically any combination of terminal and non-terminal . Hence you can see regular language is a subset of context free grammer. A regular language can be recoganized by a finite automata.A context free grammer requires a stack. Basically regular language is a subset of context free grammer, but we can not say every context free grammer is regule grammer. Construct a language generated by CFG: (a,b)* {aacaa,bcb,abcba,abbcbba} S aSa rule 1 S bSb rule 2 S c rule 3 Now if we derived a string abbcbba S aSa S abSba from rule 2 S abbSbba from rule 2 S abbcbba from rule 3
  • 9. Q(5)b:consider the context free grammer S ax x ax|bx|ϕ y bbb (a+b)*bbb(a+b)* S ax S aax S aabx S aabbx S aabbbx S aabbbbx S aabbbax S aabbbaax S aabbbbaabx S aabbbbaabϕ