GithubHelp home page GithubHelp logo

study-automata's Introduction

study-automata: core algorithm

This is the core algorithm library for study-automata application.

The software is bound for teachers and students to use as a reference for the acquisition of automata theory. It would include these and maybe more features:

Authors

Languages

  • Chinese
  • English (future)

Features

  • Automata simulation (produce result, and step-by-step demonstration)

    • DFA simulator
    • NFA simulator
    • PDA simulator
    • Regex (Regular expressions) calculator
    • CFG calculator
  • Automata conversion

    • DFAs <= NFAs
    • DFAs <= ε-NFAs
    • DPDAs <= PDAs
  • Automata-Grammar conversion

    • D/NFAs <=> Regexes
    • DPDAs <=> CFG
  • Simulate the Pumping Lemma

Developer's tips for using this library

We use ESLint coding standard. It includes using let/const instead of var, using function statement instead of function expression, using lambda expression instead of function expression, using class instead of prototype, using 2 spaces to indent, using single-quote to quote a string, using LF to end a line, and so on.

Examples

For convenience, all automata will use integers for states and letters/symbols of an automata.

1. How to represent a DFA in JSON?

{
    "Q": [0, 1, 2],
    "S": [0, 1],
    "D": [
        ["0 0", 1],
        ["0 1", 0],
        ["1 0", 2],
        ["1 1", 0],
        ["2 0", 2],
        ["2 1", 0]
    ],
    "q0": 0,
    "F": [2]
}

Description: This DFA's language accept strings that end with "00", where

  • "Q" is the states (q0, q1, ...),
  • "S" is the alphabet (Σ),
  • "D" is the transfer diagram (δ),
  • "q0" is the entry state,
  • "F" is the final states.

This will be parsed into an instance of DFA class, and the transfer diagram will be passed directly to construct a new Map instance.

2. How to represent other automata?

{
    "Q": [0, 1, 2],
    "S": [0, 1, 2],
    "D": [
        ["0 null", [1, 2]],
        ["0 0", null],
        ["0 1", [1]],
        ["0 2", [2]],
        ["1 null", null],
        ["1 0", [0]],
        ["1 1", [2]],
        ["1 2", [0, 1]],
        ["2 null", null],
        ["2 0", null],
        ["2 1", null],
        ["2 2", null]
    ],
    "q0": 0,
    "F": [2]
}

Description: This ε-NFA's language is equal to regex ((ε+b)c*(ε+(a+c)))*(ε+b)+c. In the transfer diagram, we use null to represent null string (ε) and null set (Φ).

// A DPDA

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.