NFA to DFA conversion in C

Page 1

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056

Volume: 10 Issue: 01 | Jan 2023 www.irjet.net p-ISSN: 2395-0072

NFA to DFA conversion in C

1,2,3,4,5 Student, Dept. of Artificial Intelligence & Data Science,Vishwakarma Institute of Technology, Maharashtra, India ***

Abstract - Automata Theory is an enthralling domain in computer science in which we develop abstract models of the logic or the computation that runs in the background of any machine.DFAs and NFAs play a tremendous role in designing, analyzing the dynamic behavior of these models.Each DFA is an NFA,but each NFA is not a DFA.However each NFA can be translated or made equivalent to a DFA .There are a few methods already available for converting aNFAintoitsequivalentDFA.Our aim through this paper is to design an efficient algorithm for NFA to DFA conversion in C language.

Key Words: NFA, DFA, conversion

1. INTRODUCTION

Inautomatatheory,amachinecanbetermedasDFAifon reading the input and the source state the obtained transitiondoesnotcontaintwodistinctpathsforthesame input.OntheotherhandamachinecanbetermedasNFAif there exists two paths for the same input. The ‘5 tupple definition’ of DFA and NFA are the same except the transitionfunction:-

DFA- δ: Q ×Σ → Q NFA- δ: Q ×Σ →2Q

The conversion of NFA to DFA in C is implemented in the samewayasitisdonemanually.Followingarethestepsto convertaNFAtoDFAmanually:-

1.ConstructaNFAforthegivenstatement.

2.Generateit’stransitiontableaccordingly.

3.FromthetransitiontableofNFAgeneratethetransition tableofDFA.

4.ConstructtheDFAformthetransitiontableofDFA.

Eg:-NFA-DFAwhichacceptsstringscontaining{a.b}withab attheend.

1.NFA:- a,b a b

Q0 Q1 Q2 Q2

2.TransitiontableofNFA:State a b Q0 Q0,Q1 Q0 Q1 - Q2 Q2

3.TransitiontableofDFA:State a b Q0 Q0,Q1 Q0 Q0,Q1 Q0,Q1 Q0,Q2 Q0,Q2 Q0,Q1 Q0

3.DFA:b a a b a Q0,Q2 b

Q0 Q0, Q1

3. LITERATURE REVIEW

[1].A paper by M. Davoudi-Monfared1, R. shafiezadehgarousi,E.S.Haghi1,S.Zeinali1andS.Mohebali illustrates the NFA to DFA conversion in C++.It uses data structureslikearrayandlinkedlistandotherOOPconcepts likeclasses,functions,graftedlist,etc.

[2].HoNgocVinhandNguyenThiThuHatogethercompiled apaperinwhichtheyhavedepictedtheconversionofNFA to DFA using the concept of bounded words.In this paper,concepts of bounded words on an alphabet A,languagesandmonoidmorphismareintroduced.

[3].GhafoorhascontributedtoapaperinCSESpring18which uses the Gallier’s algorithm for NFA to DFA conversion.It usesthevariousdatastructuresinC++likevectors,parser classes,etc.ThefinaloutputobtainedistheDFAtuplewhich isactuallyrepresentedintheformofstrings.

2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal

©
| Page362
Janhavi Gangurde1, Komal Thakare2, Aarti Ghuge3 , Shivam More4 Rohan Waware5

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056 Volume: 10 Issue: 01 | Jan 2023 www.irjet.net p-ISSN: 2395-0072

[4].ApaperentitledANewMethodforTranslatingNFAinto DFA Cheng Yuanbin School of Mathematics & Computer Science,JianghanUniversity,Wuhan,China.Inthisalgorithm ofNFAtoDFAconversionwhenwehavetheepisiloncaseit notrequiredtoinputtheepisilonItcandirectlyconverta NFAtoDFA.

[5].‘NFAtoDFAtransformationforfinitelanguages’apaper contributedbyKaiSalomaa&ShengYuhasbeenpublished in the International Workshop on Implementing Automata.This paper has majorly focused on the upper boundofthenumberofstatesinDFAthatistranslatedintoa NFA.

[6]. Galina Jirásková and Ivana Krajňáková together contributed to a paper named “NFA-to-DFA Trade-Off for Regular Operations” in the International Conference on DescriptionalComplexityofFormalSystems.Inthistypeof conversiontheNFAisrepresentedintheformofoperandsof aRegularExpressionandthenitisconvertedintotheDFA.

[7]. M Jing, W SHI, C YU contributed to a paper entitled “Subset:-AnimprovedconversionAlgorithmforNFAtoDFA” in the American Journal of Engineering and Technology whichstatedtheuseofsubsetconversionalgorithmasan efficient method for NFA to DFA conversion and thus is applicabletostringmatching.

[8].“Deterministicvs.NonDeterministicFiniteAutomatain AutomataProcessing”isapapercompiledbyFASiddique,TJ TracyII,NBrunelle.Thispaperperformsanempiricalstudy ontheconversionofanyoptimizedNFAtoaminimizedDFA.

[9].NFAtoDFAConversionofSubregularLanguageFamilies is a paper compiled by H Bordihn, M Holzer, M Kutrib.It provides another algorithm for the efficient conversion of anyNFAtoitsoptimumDFA.

4. METHODOLOGY

A.)ProposedSystem:-

Our crucial goal for this project is to achieve an efficient algorithmforNFAtoDFAconversion.Andtoimplementitin thebestpossiblewaywehaveuseddatastructurespresent intheClanguagesothatitisassimpletoconvertaNFAto DFA programmatically as it is manually. Therefore this algorithmiseasytointerpretforstudentwhoarebeginners inTheory ofComputation.Inthissystem,initiallywehave declaredstructuresforstoringtheNFAstatesandit’srelated information.Later for accessing,traversing,adding,deleting thestateswehaveusedtheconceptofqueuewithlinkedlist.

B.)Flowchart:-

NFAtoDFAconversioninCisdevelopedusingthebasicC conceptslikestructures,queues,linkedlists,dynamicmemory

allocation,etc.Theflowoftheprogramissuchthatinitially whenweruntheprogramweneedtoinputthetotalnumber ofstatespresentinourNFA.Anextremelyimportantpoint over here is that the variables in the language are representedas0or1.EventuallyevenifourNFAcontains languagecomprisingof{a,b}itwillstillberepresentedas0 or1.Oncewehaveinputtedthetotalnumberofstates,then for every state we need to mention the total number of transitionsfromthatstateonagiveninputeither1or0.Also at the end of each state the program enquires if that particularstateisafinalstateornot.Afterprovidingallthe informationoftheNFAitgeneratesthetransitiontableofit’s corresponding DFA.It also specifies the final state of DFA.Theprogramthengetsterminatedsuccessfully.

Hereisthedetailedflowchartofthesame.

Start

Input the total no. of states present in NFA

For each state input the total no. of transitions.

For each state input the transition occurred on input 0

For each state input the transition occurred on input 1

DFA transition table is generated Stop

C.)Algorithm:-

1.Start 2.Inputthetotalno.ofstatespresentinNFA 3.Foreachstateinputthetotalno.oftransitions. 4.Foreachstateinputthetransitionoccurredon input0 5.Foreachstateinputthetransitionoccurredon input1 6.DFAtransitiontableisgeneratedalongwiththefinal state.

7.Stop

©
| Page363
2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056

Volume: 10 Issue: 01 | Jan 2023 www.irjet.net p-ISSN: 2395-0072

5. RESULTS AND DISCUSSIONS

For the purpose of converting a NFA to DFA there exists many different methods like bitmasking,subset conversion,boundedwords,etc.Ouraimthroughthispaperis tostudytheseexistingmethodsanddeliveramoreefficient algorithm for the NFA to DFA conversion.NFA to DFA conversion in C using data structures is the most efficient algorithmasitfunctionsthesamewayasweconvertaNFA to DFA manually.On taking the transition table of NFA as inputthetransitiontableof DFAissuccessfullygenerated alongwiththementioningofthefinalstate.Followingarethe snapshotsoftheoutput.

1.

Thegivensnapshotdepictstheinputprovidedsuchasthe total number of states ,number of transitions ,transition statesobtainedonthegiveninput,checkingifthestateisa finalstate,etc

2.

5. CONCLUSION

TheproposedsystemconvertsthegivenNFAtoDFAbased on the transition table of NFA it generates the transition tableofDFAandthustheDFAisgenerated.Thisalgorithm can be used in various areas where the NFA to DFA conversionisrequired.

6. FUTURE SCOPE

NFAisusedinthemakingofregularexpressions.DFAhasa widerangeof applicationsincludingLexical Analyzers for parsers, Elevators, thermostats, Train track switches, security properties, grep etc. With these tremendous applications NFA to DFA conversion of these models is requiredfrequently.HenceNFAtoDFAconversioninCisthe mostefficientandreliablealgorithm.

7. ACKNOWLEDGEMENT

Wewouldliketoexpressoursinceregratitudetoourguide Dr.KuldeepVayadandeSirforgivingustheopportunityto work on this proposed system entitled “NFA to DFA conversioninC”.Throughthissystemwewereabletogetin depthknowledgeaboutfiniteautomata,automatonsandits applicationsaswell.

8. REFERENCES

[1].KuldeepVayadande,AdityaBodhankar,AjinkyaMahajan, DikshaPrasad,ShivaniMahajan,AishwaryaPujariandRiya Dhakalkar, “Classification of Depression on social media usingDistantSupervision”,ITMWebConf.Volume50,2022.

[2].Kuldeep Vayadande, Rahebar Shaikh, Suraj Rothe, SangamPatil,TanujBawareandSameerNaik,”BlockchainBased Land Record SysteM”, ITM Web Conf. Volume 50, 2022.

[3].KuldeepVayadande,KirtiAgarwal,AadeshKabra,Ketan GangwalandAtharvKinage,”CryptographyusingAutomata Theory”,ITMWebConf.Volume50,2022

[4].SamruddhiMumbare,KunalShivam,PriyankaLokhande, Samruddhi Zaware, Varad Deshpande and Kuldeep Vayadande,”SoftwareControllerusingHandGestures”,ITM WebConf.Volume50,2022

[5].Preetham,H.D.,andKuldeepBabanVayadande."Online CrimeReportingSystemUsingPythonDjango."

[6].Vayadande,KuldeepB.,etal."SimulationandTestingof Deterministic Finite Automata Machine." International JournalofComputerSciencesandEngineering10.1(2022): 13-17.

Thegivensnapshotdepictsthegeneratedtransitiontableof DFA.Herethestate‘Q0Q1Q2’istheobtainedfinalstate.

[7].Vayadande, Kuldeep, et al. "Modulo Calculator Using TkinterLibrary."EasyChairPreprint7578(2022).

© 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page364

[8].VAYADANDE, KULDEEP. "Simulating Derivations of Context-FreeGrammar."(2022).

[9].Vayadande,Kuldeep,RamMandhana,KaustubhParalkar, Dhananjay Pawal, Siddhant Deshpande, and Vishal Sonkusale."PatternMatchinginFileSystem."International JournalofComputerApplications975:8887.

[10].Vayadande, Kuldeep, Ritesh Pokarne, Mahalakshmi Phaldesai, Tanushri Bhuruk, Tanmay Patil, and Prachi Kumar."SimulationOfConway’sGameOfLifeUsingCellular Automata."SIMULATION9,no.01(2022).

[11].Gurav, Rohit, Sakshi Suryawanshi, Parth Narkhede, Sankalp Patil, Sejal Hukare, and Kuldeep Vayadande. "UniversalTuringmachinesimulator."InternationalJournal ofAdvanceResearch,IdeasandInnovationsinTechnology, ISSN(2022).

[12].Vayadande, Kuldeep B., Parth Sheth, Arvind Shelke, VaishnaviPatil,SrushtiShevate,andChinmayeeSawakare. "Simulation and Testing of Deterministic Finite Automata Machine." International Journal of Computer Sciences and Engineering10,no.1(2022):13-17.

[13].Vayadande, Kuldeep, Ram Mandhana, Kaustubh Paralkar,DhananjayPawal,SiddhantDeshpande,andVishal Sonkusale."PatternMatchinginFileSystem."International JournalofComputerApplications975:8887.

[14].Vayadande,KuldeepB.,andSurendraYadav."AReview paper on Detection of Moving Object in Dynamic Background." International Journal of Computer Sciences andEngineering6,no.9(2018):877-880.

[15].Vayadande, Kuldeep, Neha Bhavar, Sayee Chauhan, SushrutKulkarni,AbhijitThorat,andYashAnnapure.Spell CheckerModelforStringComparisoninAutomata.No.7375. EasyChair,2022.

[16].Vayadande,Kuldeep,HarshwardhanMore,OmkarMore, Shubham Mulay, Atharva Pathak, and Vishwam Talnikar. "PacMan:GameDevelopmentusingPDAandOOP."(2022).

[17].Preetham,H.D.,andKuldeepBabanVayadande."Online CrimeReportingSystemUsingPythonDjango."

[18].Vayadande, Kuldeep. "Harshwardhan More, Omkar More, Shubham Mulay, Atahrv Pathak, Vishwam Talanikar,“Pac Man: Game Development using PDA and OOP”." International Research Journal of Engineering and Technology(IRJET),e-ISSN(2022):2395-0056.

[19].Ingale, Varad, Kuldeep Vayadande, Vivek Verma, Abhishek Yeole, Sahil Zawar, and Zoya Jamadar. "Lexical analyzer using DFA." International Journal of Advance Research, Ideas and Innovations in Technology, www. IJARIIT.com.

[20]. Manjramkar, Devang, Adwait Gharpure, Aayush Gore, Ishan Gujarathi, and Dhananjay Deore. "A Review PaperonDocumenttextsearchbasedonnondeterministic automata."(2022).

[21]. Chandra, Arunav, Aashay Bongulwar, Aayush Jadhav, Rishikesh Ahire, Amogh Dumbre, Sumaan Ali, Anveshika Kamble, Rohit Arole, Bijin Jiby, and Sukhpreet Bhatti.SurveyonRandomlyGeneratingEnglishSentences. No.7655.EasyChair,2022.

[22]. A paper by M. Davoudi-Monfared1, R. shafiezadehgarousi,E.S.Haghi1,S.Zeinali1andS.Mohebali illustratestheNFAtoDFAconversioninC++.[1]Itusesdata structureslikearrayandlinkedlistandotherOOPconcepts likeclasses,functions,graftedlist,etc[1].

[23]. Ho Ngoc Vinh and Nguyen Thi Thu Ha together compiled a paper in which they have depicted the conversion of NFA to DFA using the concept of bounded words [2]In this paper,concepts of bounded words on an alphabet A,languages and monoid morphism are introduced.[2]

[24].Ghafoor has contributed to a paper in CSESpring18 which uses the Gallier’s algorithm for NFA to DFA conversion[3].

[25]. Hopcroft J, Motwani R, Ullman, Addison-Wesley, “Introduction to Automata Theory, Languages and Computation”,SecondEdition,ISBN81-7808-347-7.

[26]. John C. Martin,” Introduction to Languages and The TheoryofComputation”,FourthEdition,McGrawHill,ISBN 978-0-07-319146-1.

[27]. The C Programming Language. 2nd EditionBook by BrianKernighanandDennisRitchie

[28]. M Jing, W SHI, C YU contributed to a paper entitled “Subset:-AnimprovedconversionAlgorithmforNFAtoDFA” in the American Journal of Engineering and Technology whichstatedtheuseofsubsetconversionalgorithmasan efficient method for NFA to DFA conversion and thus is applicabletostringmatching.

[29].“Deterministicvs.NonDeterministicFiniteAutomatain AutomataProcessing”isapapercompiledbyFASiddique,TJ TracyII,NBrunelle.Thispaperperformsanempiricalstudy ontheconversionofanyoptimizedNFAtoaminimizedDFA.

[30]. Galina Jirásková and Ivana Krajňáková together contributed to a paper named “NFA-to-DFA Trade-Off for Regular Operations” in the International Conference on DescriptionalComplexityofFormalSystems.Inthistypeof conversiontheNFAisrepresentedintheformofoperandsof aRegularExpressionandthenitisconvertedintotheDFA

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395-0056 Volume: 10 Issue: 01 | Jan 2023 www.irjet.net p-ISSN: 2395-0072 © 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page365

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.