All Projects → nikos912000 → chomsky-normal-form

nikos912000 / chomsky-normal-form

Licence: other
Convert a Context Free Grammar (CFG) to Chomsky Normal Form (CNF)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to chomsky-normal-form

fauton
An ecosystem of packages to work with automaton and parsers (dfa/nfa/e-nfa/regex/cfg/pda)
Stars: ✭ 36 (+111.76%)
Mutual labels:  cnf, cfg
bosphorus
Bosphorus, ANF simplifier and solver, and ANF-to-CNF converter
Stars: ✭ 45 (+164.71%)
Mutual labels:  cnf
left-recursion
Quick explanation of eliminating left recursion in Haskell parsers
Stars: ✭ 36 (+111.76%)
Mutual labels:  cfg
Cfg-Preset-By-Purp1e
该仓库已转移|CSGO Config Preset Abandoned, Visit Link →→→
Stars: ✭ 31 (+82.35%)
Mutual labels:  cfg
CSGO-Config-Presets
🎉​ Presets of Config files for many scenarios in CS:GO
Stars: ✭ 167 (+882.35%)
Mutual labels:  cfg
NatLang
NatLang is an English parser with an extensible grammar
Stars: ✭ 20 (+17.65%)
Mutual labels:  chomsky
ApexConfigs
Apex Legends configs for a competitve player
Stars: ✭ 52 (+205.88%)
Mutual labels:  cfg
klara
Automatic test case generation for python and static analysis library
Stars: ✭ 250 (+1370.59%)
Mutual labels:  cfg
minisat-rust
Experimental minisat SAT solver reimplementation in Rust
Stars: ✭ 68 (+300%)
Mutual labels:  cnf
asm2cfg
Python command-line tool and GDB extension to view and save x86, ARM and objdump assembly files as control-flow graph (CFG) pdf files
Stars: ✭ 42 (+147.06%)
Mutual labels:  cfg
evm cfg builder
EVM CFG recovery
Stars: ✭ 83 (+388.24%)
Mutual labels:  cfg
slime-sat-solver
A Free World Class High Performance SAT Solver
Stars: ✭ 15 (-11.76%)
Mutual labels:  cnf
upf-epc
4G/5G Mobile Core User Plane
Stars: ✭ 97 (+470.59%)
Mutual labels:  cnf
goconfig
.gitconfig syntax parser
Stars: ✭ 15 (-11.76%)
Mutual labels:  cfg
config-parser
A slim, fully managed C# library for reading/writing .ini, .conf, .cfg etc configuration files.
Stars: ✭ 67 (+294.12%)
Mutual labels:  cfg

Chomsky Normal Form (CNF) Converter

This script can be used to convert a Context Free Grammar (CFG) to Chomsky Normal Form (CNF).

The implementation is based on the theory provided in the book ''Elements of the Theory of Computation (2nd Edition)", by Harry Lewis and Christos H. Papadimitriou.

###Theory

According to the book, the right hand side of the rule in a CFG in Chomsky Normal Form must have length two.

So, there are 3 kind of rules that need to be removed/replaced:

  1. Long rules (eg. A->BCD)
  2. Empty rules (eg. A->e)
  3. Short rules (eg. A->a)

Input

User's input include:

  • Number of rules
  • Initial state
  • Rules, each on in a space-delimited form (A BC, for A->BC)

Example

Here 's an example indicating how to use the script:

Message User Input
Give number of rules 3
Give initial state S
Rule #1 S SS
Rule #2 S (S)
Rule #3 S e
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].