An Interactive Approach To Formal Languages And

2y ago
39 Views
4 Downloads
2.54 MB
70 Pages
Last View : 6d ago
Last Download : 3m ago
Upload by : Mariam Herr
Transcription

An Interactive Approach to FormalLanguages and Automata with JFLAPSusan H. RodgerDuke UniversityNSF CCLI ShowcaseMarch 9, 2007Supported by NSF Grant DUE 0442513.

Outline Overview of JFLAP Examples and Demo–––––L-SystemsTuring Machine Building BlocksMoore and Mealy MachinesPumping LemmaBatch Testing Mode JFLAP’s use in Teaching JFLAP Study

Formal Languages and AutomataTheory Traditionally taught– Pencil and paper exercises– No immediate feedback– More mathematical than most CS courses– Less hands-on than most CS courses

Why study finite automata? Application: Compiler Compiler identifies your syntax errors Can write a big DFA to identify all words ina Java program– integers, doubles, boolean– keywords, variable names– arithmetic operators, punctuation symbols

Why Develop Tools for Automata?TextualTabularVisualInteractive

Why Develop Tools for Automata?Examined 10 Automata textbooks One had software with book Only 6 had pictures of PDA, 2 or 3 states Only 6 had pictures of Turing machines,three of those switched representation Only 2 had picture of CFG to NPDA None had picture of parse tree forunrestricted grammar

Overview of JFLAP Java Formal Languages and AutomataPackage Instructional tool to learn concepts ofFormal Languages and Automata Theory Topics:––––Regular LanguagesContext-Free LanguagesRecursively Enumerable LanguagesLsystems

Thanks to Students - Worked onJFLAP and Automata Theory Tools NPDA - 1990, C , Dan Caugherty FLAP - 1991, C , Mark LoSacco, Greg Badros JFLAP - 1996-1999, Java versionEric Gramond, Ted Hung, Magda and Octavian Procopiuc Pâté, JeLLRap, LsysAnna Bilska, Jason Salemme, Lenore Ramm, AlexKarweit, Robyn Geer JFLAP 4.0 – 2003, Thomas Finley, Ryan Cavalcante JFLAP 6.0 – 2005-2006 Stephen Reading, Bart Bressler,Jinghui Lim

JFLAP – Regular Languages Create––––DFA and NFAMoore and Mealyregular grammarregular expression Conversions– NFA to DFA to minimal DFA– NFA ÅÆ regular expression– NFA ÅÆ regular grammar

JFLAP – Regular languages(more) Simulate DFA andNFA– Step with Closure orStep by State– Fast Run– Multiple Run Combine two DFACompare EquivalenceBrute Force ParserPumping Lemma

JFLAP – Context-free Languages Create– Nondeterministic PDA– Context-free grammar– Pumping Lemma Transform–––––PDA Æ CFGCFG Æ PDA (LL & SLR parser)CFG Æ CNFCFG Æ Parse table (LL and SLR)CFG Æ Brute Force Parser

JFLAP – RecursivelyEnumerable Languages Create––––Turing Machine (1-Tape)Turing Machine (multi-tape)Building BlocksUnrestricted grammar Parsing– Unrestricted grammar withbrute force parser

Finite Automata Editingand Simulation The most basic feature of JFLAP hasalways been the creation of automata, andsimulation of input on automata. Here we demonstrate the creation andsimulation on a simple NFA.

FA Edit & SimulationStart up JFLAP When we start upJFLAP we have achoice of structures. The first of these isthe Finite Automata!

FA Edit & SimulationStart Editing! We start with anempty automatoneditor window.

FA Edit & SimulationCreate States We create somestates .

FA Edit & SimulationCreate Transitions We create sometransitions .

FA Edit & SimulationInitial and Final State We set an initialand final state. Now we cansimulate input onthis automaton!

FA Edit & SimulationInput to Simulate. When we say wewant to simulateinput on thisautomaton, a dialogasks us for theinput.

FA Edit & SimulationStart Simulation! When simulationstarts, we have aconfiguration on theinitial state with allinput remaining to beprocessed.

FA Edit & SimulationAfter One Step This is anondeterministic FA,and on this input wehave multipleconfigurations afterwe “Step.”

FA Edit & SimulationAfter Two Steps The previousconfigurations on q1 andq2 are rejected, and areshown in red. The remaininguncolored configurationspaths are not rejected,and are still open.

FA Edit & SimulationAfter Three Steps Yet another step.

FA Edit & SimulationAfter Four Steps One of the finalconfigurations hasbeen accepted!

FA Edit & SimulationTraceback One can then see atraceback to see thesuccession ofconfigurations that ledto the acceptingconfiguration.

FA Multiple Run Select MultipleRun One can thenenter manystrings andreceiveacceptance info.

L-Systems L-Systems may be usedto model biologicalsystems and createfractals. Similar to Chomskygrammars, except allvariables are replaced ineach derivation step, notjust one! Commonly, strings fromsuccessive derivations areinterpreted as strings ofrender commands and aredisplayed graphically.

L-Systems This L-System rendersas a tree that growslarger with eachsuccessive derivationstep.

L-Systems L-systems may also bestochastic. The T Tg rule adds gto the derivation, whichdraws a line segment. We add anotherrewriting rule for T,T T. With two rewritingrules for T, the rulechosen is random,leading to unevengrowth!

L-SystemsThe same stochastic L-system, rendered3 different times all at the 9th derivation.

Students like L-systems

Turing Machine Building Blocks First, a problem. f(w) number of a’s in w, Examples:– f(aabab) 111– f(bbbaab) 11 {a,b}

Turing Machine Building Blocks Building Block– Build a Turing machine with a specific purpose– Name it and save it– Use it as a BlackBox in another Turing machine Special Symbols !xignore read or writematches all symbols except for x

Simple Building Blocks start R – move right R blnk – move right once, keep movingright until reach a blank

Simple Building Blocks (cont) R not a – move right once, keep movinguntil not an “a” a - write “a” and stay put

Create & Combine Building Blocks New ButtonsLoad BBBB transition Conditional – if the current symbol is b, moveto the next block (tape head not moving) Move to the next block – use – Ignore read, ignore write, stay put

Problem again: Count number of a’s F(abbaabb) 111

Building Block Run Choices

abbabStep bybuildingblock

abbab

abbab

abbab

abbab

abbab

abbab Skipa fewstepsto

Mealy Machines Similar to finite automata– No final states– Produce an output on their transitions– deterministic

Example – Vending Machine Dispenses candy once enough money has beeninserted– Money – n(nickel), d(dime) q(quarter)– Candy bars – 20 cents– Returns the appropriate amount of change – the numberof nickels– C4 means “candy and 4 nickels” From Carroll and Long’s Theory of FiniteAutomata book

MealyVendingMachineExample

Moore Machine Similar to Mealy Machine– No final state– Output is produce by states, not transitions

Example – Halve a Binary Number

Regular Pumping Lemma

Pick anExample

JFLAPPumplemmaGameUser entersin steps 1and 3

Context-Free Pumping Lemma

Similar CFL pump lemma game

CFL pump lemma (cont) Last step showsthe contradiction In CFL – thereare lots of casesto consider

Batch Testing Mode Selectseveralfiles fortesting Thenselectinput file

Batch Testing Mode (cont)

Using JFLAP in Teaching

Using JFLAP during Lecture Use JFLAP to build examples of automataor grammars Use JFLAP to demo proofs Load a JFLAP example and students workin pairs to determine what it does, or fix it ifit is not correct.

Example: JFLAP during Lecture Ask students to write on paper an NPDA forpalindromes of even length Build one of their solutions using JFLAP– Shows students how to use JFLAP Run input strings on the NPDA– Shows the nondeterminism

Example 2: JFLAP during Lecture Brute Force Parser– Give a grammar with a lambdaproduction and unit production– Run it in JFLAP, see how longit takes (LONG) Is aabbab in L?– Transform the grammar toremove the lambda and unitproductions– Run new grammar in JFLAP,runs much faster!

Parse Tree Results First Grammar – 1863 nodes generated Second Grammar – 40 nodes generated Parse tree is the same.

With JFLAP, Exploring Conceptstoo tedious for paper Load a Universal Turing Machine and run it See the exponential growth in an NFA orNPDA Convert an NPDA to a CFG– Large grammar with useless rules– Run both on the same input and compare– Transform grammar (remove useless rules)

JFLAP’s use Outside of Class Homework problems– Turn in JFLAP files– OR turn in on paper, check answers in JFLAP Recreate examples from class Work additional problems– Receive immediate feedback

Ordering of Problems in Homework Order questions so they are incremental inthe usage of JFLAP1. Load a DFA. What is the language?Students only enter input strings.2. Load a DFA that is not correct. What iswrong? Fix it.Students only modifying a small part.3. Build a DFA for a specific language.Last, students build from scratch.

JFLAP Study Study of JFLAP’s effectiveness in learning– Runs 2005-2007– Pretest/Posttest– Interviews Supported by National Science Foundation,grant NSF DUE 0442513

FourteenParticipants DukeUNC-Chapel HillEmoryWinston-Salem State UniversityUnited States Naval AcademyRensselaer Polytechnic InstituteUC DavisVirginia State UniversityNorfolk State UniversityUniversity of HoustonFayetteville State UniversityUniversity of RichmondSan Jose State UniversityRochester Institute of Technology

JFLAP’s Use Around the World JFLAP web page has over 110,000 hitssince 1996 Google Search– JFLAP appears on over 20,000 web pages– Note: search only public web pages JFLAP been downloaded in over 160countries

Questions? JFLAP is free! www.jflap.org JFLAP book (Jones & Bartlett, 2006)– Use as supplement to a textbook

Formal Languages and Automata Theory Topics: – Regular Languages – Context-Free Languages – Recursively Enumerable Languages – Lsystems. Thanks to Students - Worked on JFLAP and Automata Theory

Related Documents:

2. Lubin-Tate spaces 45 2.1. The height of a formal A-module 46 2.2. Lubin-Tate spaces via formal group laws 49 2.3. Lazard's theorem for formal A-modules 52 2.4. Proof of the lemma of Lazard and Drinfeld 60 2.5. Consequences for formal A-modules 66 2.6. Proof of representability of Lubin-Tate spaces 76 3. Formal schemes 82 3.1. Formal .

CUSTOMIZATION OF ANY INTERACTIVE SOFTWARE BY INTERACTIVE, CUSTOMER OR ANY THIRD PARTY EVEN IF SUCH CUSTOMIZATION AND/OR MODIFICATION IS DONE USING INTERACTIVE TOOLS, TRAINING OR METHODS DOCUMENTED BY INTERACTIVE. Interactive Intelligence Inc. 7601 Interactive Wa

work/products (Beading, Candles, Carving, Food Products, Soap, Weaving, etc.) ⃝I understand that if my work contains Indigenous visual representation that it is a reflection of the Indigenous culture of my native region. ⃝To the best of my knowledge, my work/products fall within Craft Council standards and expectations with respect to

Formal Proof of correctness of data is “highly recommended” for SIL 3/4 Data Preparation Techniques (Table A.11) 13. Klaus Reichl - Formal Methods for Verification and Validation in Railway CENELEC on Formal Methods apply formal methods to requirements and high-level designs where most of

A formal method is expected to support the proof of correctness of the final implementation of the software with respect to its specification. The formal methods notation is used for formal specification of a software system: – As a process: translation of a non-mathematical description into a formal language

Formal Methods: Analogy with Engineering Math (ctd.) Formal methods: same idea, applied to computational systems The applied math of Computer Science is formal logic So the models are formal descriptions in some logical system E.g., a program reinterpreted as a mathematical formula rather than instructions to a machine And calculation is mechanized by automated deduction:

Theory of Computation I: Introduction to Formal Languages and Automata Noah Singer April 8, 2018 1 Formal language theory De nition 1.1 (Formal language). A formal language is any set of strings drawn from an alphabet . We use "to denote the \empty string"; that is, the st

formal methods or to be told to use a particular formal method, such as a specification language or theorem prover based on formal logic. Rather we must recognize that many of the methods used in industry are semi-formal or formal. For these method