Turing Machine Simulator Theory of Computation Mesfer Alrizq

  • Slides: 47
Download presentation
Turing Machine Simulator Theory of Computation Mesfer Alrizq Naif Alrashidi 1

Turing Machine Simulator Theory of Computation Mesfer Alrizq Naif Alrashidi 1

Overview • Background • Introduction • Problem and Goals • Research • Design •

Overview • Background • Introduction • Problem and Goals • Research • Design • Testing Design • Implementation • Discussion and Conclusion 2

Turing Machines 3 • Ø Ø Ø What could it have? A tape: infinite

Turing Machines 3 • Ø Ø Ø What could it have? A tape: infinite length to the right; initially blanks The input string, And the transition table. • Ø Ø Ø From a state on a given symbol: We can go to a new state Write a new symbol on the tape The direction (L, R, S) in which head is moving after writing the new symbol [1]

Turing Machines • Computation of Turing Machines: we first define a configuration Ø uqv

Turing Machines • Computation of Turing Machines: we first define a configuration Ø uqv – means that the tape contains uv, the state is q, and the machine reads the first symbol of v • A TM M accepts w if: Ø It starts in the initial configuration, then goes through a sequence of configurations; the new config is yielded by the last config, and it gets to an accepting configuration. 4 • The language of a TM, (M) is the set of strings that M accepts/recognizes [1].

Turing Machines • Definition: Turing Recognizable Ø A language is Turing-recognizable if there is

Turing Machines • Definition: Turing Recognizable Ø A language is Turing-recognizable if there is some TM that recogizes it [1]. • Definition: Turing Decidable Ø A language is Turing-decidable if there is some TM that decides it [1]. 5

Overview • Background • Introduction • Problem and Goals • Research • Design •

Overview • Background • Introduction • Problem and Goals • Research • Design • Testing Design • Implementation • Discussion and Conclusion 6

INTRODUCTION AND MOTIVATION • This project is to implement a standard turing machine simulator

INTRODUCTION AND MOTIVATION • This project is to implement a standard turing machine simulator on a tape using Java Programming Language. • This simulator has the ability to show the user the tape head moving on a tape according to the tranisiton table that is given to the simulator in the form of a text file that is passed to the simulator. • In addition, it shows the output to the user of the input string in terms whether it is accepted or rejected and at which state the turing machine halts. 7

INTRODUCTION AND MOTIVATION • We have used three different kinds of Turing machines: Ø

INTRODUCTION AND MOTIVATION • We have used three different kinds of Turing machines: Ø L={a^i b^i c^i | i ≥ 0} Ø COPY Turing machine, Ø And turing machine that interchanges a’s and b’s. 8

Overview • Introduction • Problem and Goals • Research • Design • Testing Design

Overview • Introduction • Problem and Goals • Research • Design • Testing Design • Implementation • Discussion and Conclusion 9

PROBLEM AND GOALS • There currently is not efficient standard turing machine simulators that

PROBLEM AND GOALS • There currently is not efficient standard turing machine simulators that simulate the computation on a tape using Java Programming Language. • Project Goals: Ø Develop a turing machine simulator Ø Gain a better understanding of how turing machines work, how they are constructed Ø We should be able to implement a wide range of other programs in the field of theory of computation 10

Overview • Background • Introduction • Problem and Goals • Research • Design •

Overview • Background • Introduction • Problem and Goals • Research • Design • Testing Design • Implementation • Discussion and Conclusion 11

RESEARCH • In our research, we have found all we need to write the

RESEARCH • In our research, we have found all we need to write the simulator: Ø in our text book in Chapter 17 [2], Ø and also in the Turing Machine chapter in Languages and Machines book written by Sudkamp [3]. Ø After that, we spend some time on some tutorials that can help us to understand the rules of constructing any turing machine. Ø We have found some good research papers and other resources available on the web, which are related to what we are looking or using different approaches and techniques. 12

Overview • Background • Introduction • Problem and Goals • Research • Design •

Overview • Background • Introduction • Problem and Goals • Research • Design • Testing Design • Implementation • Discussion and Conclusion 13

DESIGN • Design Overview: • There are main components that will be taken into

DESIGN • Design Overview: • There are main components that will be taken into consideration: Ø what our system is, Ø the environment in which our system functions, Ø its advantages over older systems, Ø the potential users and how they take advantage of it. 14

DESIGN • Our simulator will be developed in Java Programming Langugae. • Therefore, the

DESIGN • Our simulator will be developed in Java Programming Langugae. • Therefore, the technological environment where the system will function is going to be Eclipse, which is an integrated development environment (IDE), in which java applications are mostly developed. • The advantage of our simulator over older systems is that it is going to be as general as possible, works for different types of turing machines. 15

DESIGN • Design Goals: • Good software design is going to lead to a

DESIGN • Design Goals: • Good software design is going to lead to a software that is: Ø Software should be correct if it works according to its specifications. Ø The software system is robust if it tolerates faulty data. Therefore, our system should give proper verification messages s a response if the data is invalid. Ø The software must be adaptable to any changes or shifting reuirements or specifications. We will make sure that our simulator is flexible enough in case we do changes throughout the programming stage of this project. 16

DESIGN Ø The software should be usable in terms of easy GUI to navigate

DESIGN Ø The software should be usable in terms of easy GUI to navigate and has good documentation. Ø The software should be Efficient in terms of a good use of processor and memory. Ø The software should be reliable, which means that it should consistently work according to its specifications. Ø The software should be reusable for any future improvements [4]. 17

DESIGN • Possible Approaches: Ø The possible approaches are in terms of Data, in

DESIGN • Possible Approaches: Ø The possible approaches are in terms of Data, in term of Programming Language, or Execution. • First in term of data: The data can be passed through either: Ø the command line Ø through a text file passed through an interactive interface. 18

DESIGN • Second in terms of Programming Language: Ø Implement the project using C#

DESIGN • Second in terms of Programming Language: Ø Implement the project using C# Programming Language. Ø Implement the project using Java Programming Lanuage. • Third in terms of Execution: Ø Executing the program through the command line. Ø Executing the program through a graphical user interface. 19

DESIGN • Design Flow: Ø The following flowchart diagram shows the design flow of

DESIGN • Design Flow: Ø The following flowchart diagram shows the design flow of our turing machine simulator: 20

Overview • Background • Introduction • Problem and Goals • Research • Design •

Overview • Background • Introduction • Problem and Goals • Research • Design • Testing Design • Implementation • Discussion and Conclusion 21

TESTING DESIGN • Testing Design Overview: Ø The design of tests is essential as

TESTING DESIGN • Testing Design Overview: Ø The design of tests is essential as it is a major part of each design of software. Ø Excellent design consists of stages which elaborate the design of tests from a lower level strategy to the high level test procedure. • Ø Ø Ø 22 Testing Design Stages: Test Strategy Test plans stage Test case design [5]

TESTING DESIGN • We are going to test our simulator by going through seven

TESTING DESIGN • We are going to test our simulator by going through seven major tests as follows: 1) Functionality Testing 2) Usability testing 3) Security testing 4) Component testing 5) Incremental testing 6) Non-functional testing 7) Black-box testing 23

TESTING DESIGN • Functionality Testing: Ø This test includes a test for all the

TESTING DESIGN • Functionality Testing: Ø This test includes a test for all the clickable items on the Graphical User Interface in order to make sure that there is no broken internal links within any GUI component. Ø we are going to test that the simulator is able to read the input data from the external text file. Ø Finally, we will test all the forms that are used to get information from the users such as the tested string including the validation on each filed for invalid inputs. 24

TESTING DESIGN • Usability testing: Ø First, we are going to test how the

TESTING DESIGN • Usability testing: Ø First, we are going to test how the user can navigate through the simulator’s GUI using buttons, boxes, and links to make sure that the user can navigate easily through the whole simulator GUI interface. Ø Second, we will test the GUI’s components in order to make sure that they are logical and understandable. 25

TESTING DESIGN • Security testing: Ø Here we are going to check for how

TESTING DESIGN • Security testing: Ø Here we are going to check for how the system reacts on all the invalid inputs. • Component testing: Ø This test strategy will be used to test every software part or component alone [6]. This test is also called unit testing. 26 • Incremental testing: Ø The incremental test is used when the systems part or components are integrated into the system one at a time; this test continued until the whole system is integrated [7].

TESTING DESIGN • Non-functional testing: Ø It tests for how secure the system is,

TESTING DESIGN • Non-functional testing: Ø It tests for how secure the system is, how fast the performance of the system is, and how responsive the system is for users entries [7]. • Black-box testing: Ø This test will be done to make sure that the whole system (simulator) is running properly. Moreover, this test checks for the validation messages on the whole system [7]. 27

TESTING DESIGN • It is essential to design test cases for two different kinds

TESTING DESIGN • It is essential to design test cases for two different kinds of testing: Ø The first kind is the positive testing: in which we verify that the simulator does what it should. Ø The other kind of testing is the negative testing: where we check for that the simulator does not do what it should not. 28

TESTING DESIGN • Test plans stage Ø We tested our plans against the Semester

TESTING DESIGN • Test plans stage Ø We tested our plans against the Semester Project Milestones on the course website. Ø For example, Tasks -Project Specification -Project Goals -Team Names -References 29 Deliverables Project proposal Deadline 02/15/16

TESTING DESIGN • Test Case Elements: Ø Each test case must have five main

TESTING DESIGN • Test Case Elements: Ø Each test case must have five main elements as follows: (i) Test Case ID: unique identifier of each test case. (ii) Define the features that need to be tested including what we need to do regarding the input values and the steps. (iii) Expected output: we determine the output values that we are supposed to get from the application. (iv) Actual output: we identify what you really get as an output from the application. (v) Test case result: here we should determine whether the test passes or fails [8] 30

TESTING DESIGN • Major Test Cases: Ø Test Case 1: (i) Test Case ID:

TESTING DESIGN • Major Test Cases: Ø Test Case 1: (i) Test Case ID: L = {a ^ i b ^ i c ^ i |i >=0}. (ii) We are going to test the above language using variety of strings including accepted and rejected strings. For example, aabbcc as an accepted string and aabb as a rejected string and so on for other strings. (iii) Expected output: the expected output values that we are supposed to get from the simulator according to each tested string are to decide whether the strings are part of the above language (accepted) or not (rejected). 31

TESTING DESIGN (iv) Actual output: for each string, we show the output of each

TESTING DESIGN (iv) Actual output: for each string, we show the output of each string whether it is accepted or rejected on the tape. (v) Test case result: we determine whether the test passes or fails according to the actual output in the previous step. 32

TESTING DESIGN Ø Test Case 2: (i) Test Case ID: COPY TM with input

TESTING DESIGN Ø Test Case 2: (i) Test Case ID: COPY TM with input alphabet (a, b) (ii) Try some strings to check if the turing machine produces a copy of the input string. For example, a computation that begins with the tape having the form Bu. B terminates with tape Bu. B. (iii) Expected output: decide whether the turing machines produces a copy of each string we try. (iv) Actual output: for each string, we show the output of each string whether the turing machines produces a copy of it on the tape. (v) Test case result: we determine whether the test passes or fails according to the actual output in the previous step. 33

TESTING DESIGN Ø Test Case 3: (i) Test Case ID: TM that interchanges a’s

TESTING DESIGN Ø Test Case 3: (i) Test Case ID: TM that interchanges a’s and b’s. (ii) Try some strings to see if the turing machine interchanges a’s and b’s. For example, a computation that begins with the tape having the string aabaabb terminates with tape bbabbaa. (iii) Expected output: decide whether the turing machines interchanges a’s and b’s of each string we try. (iv) Proper output: for each string, we show the output of each string whether the turing machines interchanges a’s and b’s of it on the tape. (v) Test case result: we determine whether the test passes or fails according to the proper output in the previous step. 34

Overview • Background • Introduction • Problem and Goals • Research • Design •

Overview • Background • Introduction • Problem and Goals • Research • Design • Testing Design • Implementation • Discussion and Conclusion 35

IMPLEMENTATION • we will explain about the programming language used, tools, and the system

IMPLEMENTATION • we will explain about the programming language used, tools, and the system requirements. • Project Scope: Ø Our project will be implementing a standard turing machine simulator that works through the transition table passed from a text file. The computation will be simulated on a tape. 36

IMPLEMENTATION • Tools Used: Ø The programming language that we used for achieving the

IMPLEMENTATION • Tools Used: Ø The programming language that we used for achieving the goals of this project is Java Programming Language. Ø We needed to install the packages that were needed for this project such as the SWING package, in which we can drag GUI components and provide a design that we finally liked. 37

IMPLEMENTATION • Data Design: Ø The data design is going to be through three

IMPLEMENTATION • Data Design: Ø The data design is going to be through three text files that have the tranisiton tables for each case. The three cases we are going to use in order to test our turing machine simulator are going to be as follows: 1) The first case is going to be: L = {a ^ i b ^ i c ^ i |i >=0} 2) The second case is going to be the turing machine COPY with input alphabet (a, b). 3) The third case is going to be the turing machine that interchanges a’s and b’s. 38

IMPLEMENTATION • Input Design: Ø For the inputs, there are two cases: 1) The

IMPLEMENTATION • Input Design: Ø For the inputs, there are two cases: 1) The transition table for each turing machine will be through feeding it to the simulator using text files that have the instructions of the transition table. 2) The input strings will be given to the simulator through text field that asks the user to enter the input string to be tested through the GUI interface. 39

IMPLEMENTATION • The turing machine that interchanges a’s and b’s transition table: 2 ab

IMPLEMENTATION • The turing machine that interchanges a’s and b’s transition table: 2 ab 0 B 1 BR 1 a 1 b. R 1 b 1 a. R 1 B 2 BL 2 a 2 a. L 2 b 2 b. L 40

IMPLEMENTATION • Output Design: Ø The output will be shown to the user through

IMPLEMENTATION • Output Design: Ø The output will be shown to the user through text area that shows whether the input string is accepted or rejected on the GUI interface of the simulator. Ø In addition, the input string movements on the tape will be shown to the user through the GUI interface as well. • User Interface Design: Ø During the implementation, we tried to design a friendly user interface to enhance the usability. We used a variety of the most major components in Java interfaces such as the buttons, text fields, combo boxes, lables, and some others. 41

IMPLEMENTATION • The major components of our GUI interface will be as follows: 1)

IMPLEMENTATION • The major components of our GUI interface will be as follows: 1) Text Field: the job of this text field is to allow the user to enter the input string to be tested. 2) Run Button: this is what the user clicks after entering the input string in order to run the input string on the tape and produce the output through the output text field whether the string is accepted or rejected. 3) Tape: this is where the input string is shown through movements on the tape according to the tranisiton table. There will be an arrow that shows the movement of the tape head on the tape pointing to the current cell. 42

IMPLEMENTATION 4) Output Text Area: the goal of this text area is to show

IMPLEMENTATION 4) Output Text Area: the goal of this text area is to show the output of the computation of the input string on the turing machine tape. The result of the computation whether the input string is accepted or rejected will be presented to the user on this text area. 5) j. Combo. Box: this is where the user selects the turing machine to be tested from a drop-down menu. There will be turing machine picture shows the selected machine in state diagram. 6) Machine Status: this label is to show the user in which state the computation halts. 7) Current State: this label is to show the user the current state that the computation halts at. 43

Overview • Background • Introduction • Problem and Goals • Research • Design •

Overview • Background • Introduction • Problem and Goals • Research • Design • Testing Design • Implementation • Discussion and Conclusion 44

DISCUSSION and CONCLUSION • We developed a new standard turing machine simulator using Java

DISCUSSION and CONCLUSION • We developed a new standard turing machine simulator using Java Programming Language. • Our project provides a simulator that works for any turing machine through the transition table on a tape. 45

References 1) 2) 3) 4) 5) 6) 7) 8) 46 https: //www. cs. rit.

References 1) 2) 3) 4) 5) 6) 7) 8) 46 https: //www. cs. rit. edu/~ib/Classes/CS 389_Fall 09/Slides/Ch 3 -1 -Turing. Machines. pdf Rich, E. (2008). Automata, Computability and Complexity THEORY AND APPll. CATIONS. N. p. : 2008 Pearson Education , Inc. Sudkamp, T. A. (1997). Languages and Machines An Introduction to the Thoery of Computer Science (second ed. ). California, CA: ADDISON-WESLEY. https: //avilay. wordpress. com/2012/09/01/what-is-good-software-design/ http: //www. qatutorial. com/? q=Test-Design-Documentation R. Craig and S. Jaskiel, Systematic Software Testing. Artech House, 2002. J. Watkins and S. Mills, Testing IT: An O-the-Shelf Software Testing Process, 2 nd Edition by John Watkins and Simon Mills Cambridge University Press, 2011. Mourza, Iana. "Test Documentation And Test Case Design". 2008. Presentation.

Questions 1) Define (i) a configuration of TM? (ii) the language of a TM?

Questions 1) Define (i) a configuration of TM? (ii) the language of a TM? When does a TM accept w? 2) Define Turing-recognizable and Turing-decidable? 3) Name the main components that should be taken into consideration when building a new system? 4) What are the seven design principles of good software design? 5) Draw the flowchart that shows the design flow of a TM simulator? 6) Name and define five software tests? 7) What are the test case elements? 47