Git Product home page Git Product logo

fla-cfg-to-lmd's Introduction

FLA-CFG-TO-LMD

Let's consider a simple example of converting a CFG to an LBA. Suppose we have the following CFG:

CFG:

S → aSb | ε

This CFG generates strings of the form "a^n b^n" where 'n' is the same number of 'a's and 'b's. Now, let's convert this CFG to an LBA.

Linearly Bounded Automaton (LBA):

  • Tape Alphabet: {a, b, $ } (including the end-of-tape marker $)
  • State Set: {q0, q1, q_accept, q_reject}
  • Transition Rules:
    1. (q0, a) → (q0, a, R) (Move right when reading 'a' in state q0)
    2. (q0, b) → (q1, $, L) (Move left when reading 'b' in state q0, replace 'b' with $)
    3. (q0, $) → (q_accept, $, R) (Accept when reaching the end of the string in state q0)
    4. (q1, a) → (q_reject, a, R) (Reject if 'a' is encountered after 'b' in state q1)
    5. (q1, b) → (q1, b, L) (Move left when reading 'b' in state q1)
    6. (q1, $) → (q0, $, R) (Move right when reaching the end-of-tape marker in state q1, replace $ with 'a')

Acceptance Criteria:

  • Accept if the LBA reaches the state q_accept.
  • Reject if the LBA reaches the state q_reject.

Now, let's walk through an example derivation and simulate the LBA for the input "aaabbb":

LBA Simulation Steps:

  1. Initial Configuration: q0 aaabbb$ (Start in state q0 with the input string on the tape)
  2. Apply Transition 1: q0 aabbb$ (Move right, read 'a')
  3. Apply Transition 1: q0 abbb$ (Move right, read 'a')
  4. Apply Transition 1: q0 bbb$ (Move right, read 'a')
  5. Apply Transition 2: q1 $bb$ (Move left, replace 'b' with $)
  6. Apply Transition 5: q1 $b$ (Move left, read 'b')
  7. Apply Transition 5: q1 $b$ (Move left, read 'b')
  8. Apply Transition 5: q1 $b$ (Move left, read 'b')
  9. Apply Transition 3: q_accept $b$ (Move right, reach end of the string, accept)

The LBA successfully accepts the input "aaabbb" according to the language generated by the CFG.

fla-cfg-to-lmd's People

Contributors

codelinechef avatar

Stargazers

Vivan V Sharma avatar

Watchers

 avatar

Forkers

vivansharma15

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.