Giter VIP home page Giter VIP logo

zhaw-pushdown-automata-upn's Introduction

Push down automata UPN

To enable compound expressions to be written without parentheses, the Polish mathematician Jan Lukasiewicz designed a notation that lists the operators after the numbers and variables (and not in between). The notation is called Reverse Polish Notation1.

Instead of 3 + 4, one writes 3 4 +. This allows compound expressions to be written without parentheses and interpreted unambiguously. Another example: For (3+4)∗(6-2) one writes 3 4 + 6 2 - ∗. So first 3+4 is calculated, then 6 - 2 and finally the two factors are multiplied together. The result of the calculation is 28.

You can imagine that the numbers are written one after the other into the cellar or onto the stack. If an operator is read in (or comes as input), the two uppermost numbers are taken from the stack, calculated with each other and the result is put back on the stack.

PDA UPN validation

img.png

Note: Z is a number, O is an operator

flowchart LR
    START[ ] -- Start --> Q0((QO))
    Q0 -- Z,$/$ --> Q1(((Q1)))
    Q1 -- Z,$/Z$ --> Q2((Q2))
    Q2 -- Z,Z/ZZ<br/>O,Z/ε --> Q2
    Q2 -- ε,$/$ --> Q1

    style START fill:#FFFFFF00, stroke:#FFFFFF00;  

PDA UPN calculation

img_1.png

Note: Z is a number, O is an operator

flowchart LR
    START[ ] -- Start --> Q0(((Q0)))
    Q0 -- Z,$/#Z$ --> Q0
    Q0 -- Z,#/Z# --> Q1((Q1))
    Q1 -- Z,Z/ZZ --> Q1
    Q1 -- O,Z/ε --> Q2((Q2))
    Q2 -- ε,Z/Z --> Q1
    Q2 -- ε,#/ε --> Q3
    Q3((Q3)) -- ε,Z/#Z --> Q0

    style START fill:#FFFFFF00, stroke:#FFFFFF00;  

zhaw-pushdown-automata-upn's People

Contributors

boostvolt avatar miweinho avatar

Stargazers

 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.