RuMaxwell / study-automata

The core algorithm library for study-automata project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

The core algorithm library for study-automata project

License:MIT License


Languages

Language:JavaScript 96.8%Language:HTML 3.2%