Coder Social home page Coder Social logo

mateusjunges / afd Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 1.0 3 KB

Implementation of and AFD (Deterministic Finit Automaton) for the Formal Languages and Compilers grade - Computer Engineering @ UEPG

Python 100.00%
python afd automaton compilers formal-languages

afd's Introduction

Deterministic Finite Automaton

The algorithm developed verify the validity of a string in an AFD. As parameters, the function receives the AFD definition - name, final and goal states, initial state, the transition function and the alphabet sigma.

It works basically reading each character of the given string. First, we check if the character is present in the alphabet. If yes, we iterate through the transition functions and check if any of the functions take us to the next state. Keep doing it until we finish the whole string.

If the last state is a goal state, the function returns True, and that string is valid with the defined AFD. Otherwise, returns False, and the string is not valid with the AFD.

The AFD definition should be in a text file. This file may contain:

  • The AFD name
  • The number of states
  • The initial state
  • A line with the goal states, comma separated
  • N lines with the transition functions. Each line is defined with a initial state, one input character and the next state, all separated with a comma. Example: 0,a,1.

This is a valid AFD definition file:

example_AFD
6
0
ab
2,4
0,a,1
1,b,2
2,a,3
3,a,4

afd's People

Watchers

 avatar  avatar  avatar

Forkers

computacao-uepg

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.