Git Product home page Git Product logo

vut-flp-project2's Introduction

Functional and Logic Programming - Logic Project

Turing Machine

Author: Dominik Harmim [email protected]

Build

Using the command make, the project is compiled using the swipl compiler and a program flp20-log is created.

Run

After the compilation (see the section above), it can be run as follows:

$ ./flp20-log < input-file > output-file

input-file is the name of an input file with a Turing machine and with an initial tape in a specified format. output-file is the name of the output file where a sequence of tapes used during the computation is going to be stored.

Description

The program simulates a given nondeterministic Turing machine. An input specification of the machine and an initial tape are first parsed and their format is validated. In case the format is invalid, an error message is printed to the standard output and the program is terminated. Otherwise, all the given rules are added to the program as dynamic predicates and the simulation with the initial tape is started. Prolog tries to find a sequence of tapes that leads to the final state according to the stored rules. The simulation fails if there is no such sequence that leads to the final state. If the simulation succeeds, the sequence of tapes used during the computation is printed to the standard output.

Tests

In the directory tests, there are some testing input files (.in extension) and corresponding outputs (.out extension). There is a description of these files (# denotes the blank symbol):

  • invalid-format - invalid format of an input file (there are some illegal characters). Running time: 0.014s.
  • abnormal-termination - abnormal termination of a Turing machine (there is no final state). Running time: 0.020s.
  • ref - a reference example. Running time: 0.013s.
  • ab - accepts the following language (a|b)^n###.... Running time: 0.116s.
  • an-bn - modifies the tape from the format #a^n###... to the format #b^n###.... Running time: 3.863s.
  • a2n-abn - modifies the tape from the format #a^(2n)###... to the format #(ab)^n###.... Running time: 1.039s.
  • anbncn - accepts the following language #a^nb^nc^n###... (the global stack limit likely needs to be increase). Running time: 29.203s.

vut-flp-project2's People

Contributors

harmim avatar

Watchers

 avatar  avatar  avatar

Forkers

see-quick

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.