Giter Club home page Giter Club logo

chomsky-normal-form's Introduction

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

chomsky-normal-form's People

Contributors

nikos912000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.