Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Python implementation of a Deterministic Finite Automaton (DFA) with interactive testing. Verify input string acceptance and explore language processing concepts

NotificationsYou must be signed in to change notification settings

rezamardaniDev/finite-acceptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

This Python script implements a Finite Automaton class capable of handling Deterministic Finite Automata (DFA). TheFiniteAutomaton class is defined with methods to check if the automaton is a DFA and to determine if a given input string is accepted.

Usage

FiniteAutomaton Class

TheFiniteAutomaton class is initialized with the following parameters:

  • states: Set of states in the automaton.
  • alphabet: Set of symbols in the input alphabet.
  • transitions: Dictionary representing the transitions between states based on input symbols.
  • start_state: The initial state of the automaton.
  • final_states: Set of final/accepting states.

Methods

  1. is_dfa(): Checks if the automaton is a Deterministic Finite Automaton (DFA).

  2. accept_input(input_string): Accepts an input string and determines if it is accepted by the automaton. Returns a tuple of acceptance status and the sequence of visited states.

Reading Transition File

The script includes a functionread_transition_file(file_path) to read transition information from a file and convert it into a dictionary used by theFiniteAutomaton class.

Example

To use the script, create an instance of theFiniteAutomaton class with the necessary parameters, and interactively test input strings.

python main.pyThe script prompts the user to enter a string and outputs whether the string is accepted or not, along with the sequence of visited states.File Structuremain.py: The main Python script containing the FiniteAutomaton class and themain()functionfor interactive testing.transitions.txt: Example file containing transition information.Feel free to modify the automaton parameters and transition file to suit your specific use case.

About

Python implementation of a Deterministic Finite Automaton (DFA) with interactive testing. Verify input string acceptance and explore language processing concepts

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp