Giter Site home page Giter Site logo

pyautomata-git's Introduction

Pyautomata

Pyautomata is a python project made to simulate the execution of a Deterministic Finite Automata (DFA). This repository includes the core library and a GUI made with PySimpleGUI. At the root of this repository there is a main.py file to run the project completely integrated.

Installation

To install this program, run the following commands on Linux:

git clone https://github.com/aiwaverse/pyautomata-git
cd pytautomata-git
pip install -r requirements.txt

Tkinter is required for this project, it's included on Windows, and can be installed on other operational systems, often the package is named python3-tk or python3-tkinter

On other operational systems, to install the instructions are the same:

  1. Clone this repository
  2. Enter the folder
  3. Use pip to install the requirements on requirements.txt

File format

This program requires a DFA file, the expected format is:

<M>=({<q0>,...,<qn>},{<s1>,...,<sn>},Prog,<ini>,{<f0>,...,<fn>})
Prog
(<q0>,<s1>)=<q1>
...
(<qn>,<sn>)=<q0>

Where:

  • <M> is the automata name.
  • {<q0>,...,<qn>} are the automata states.
  • {<s1>,...,<sn>} are the alphabet symbols.
  • <ini> is the initial state.
  • {<f0>,...,<fn>} are the final (accepting) states.
  • (<qn>,<sn>)=<q0> is a transiction, each line contains one, and together they make the program function of the Automata.

It is of extreme importance that the file has the exact same formatting, specially containing no spaces on the file.

The program can also verify a file of word pairs, with the following expected format:

<w0>,<w2>
<w2>,<w3>

Where wn is a word in the language of the automata.

Usage

The program can be run directly with Python:

python main.py

First Screen

You must them browse and submit the file where the automata is defined: Defined Automata

You may now test for individual words, where the result will appear in a new window, alongside the path the program used to aprove the words, or, if it was rejected, the reason why.

Word Accepted

You can also verify using a file of word pairs, where the result will be all pairs that had both words accepted.

Final program

Pairs

It can also be used inside other Python codes:

import pyautomata

p = pyautomata.AutomataParser(file_name="automata.txt")
description, function_program = p.parse()
aut = pyautomata.Automata(function_program, **description)
print(aut.check_word("aab")) # will print the result

License

MIT

pyautomata-git's People

Contributors

aiwaverse avatar

Watchers

James Cloos avatar Jonathan Mendes avatar  avatar Alexandre Crestani avatar

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.