Giter Site home page Giter Site logo

benjaminphi5 / propositional-logic-parser Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 7 KB

A parser that checks human readable equaltions, builds a structure form them, can query them for true/false values and can print them out

Standard ML 100.00%

propositional-logic-parser's Introduction

Propositional-Logic-Parser

A parser that checks human readable equations, builds a structure form them, can query them for true/false values and can print them out in human readable form.

The challenge for me was implementing it in a functional style in ML.

It takes in input such as inputString "!a&b|c<->!d"; Turns this into its abstract syntax tree: > val it = [Prop (Iff (Or (And (Not (Lit "a"), Lit "b"), Lit "c"), Not (Lit "d")))]: builder list

And then can for example, convert it back to a string, convert it to NNF etc:

> outputProposition it;

proposition: (!a & b) | c <-> !d

val it = (): ?.unit

In NNF:

> convertToNNF (inputString "!a&b|c<->!d"); val it = And (Or (Not (Or (And (Not ..., Lit "b"), Lit "c")), Not (Lit "d")), Or (Not (Not (Lit "d")), Or (And (Not (Lit "a"), Lit "b"), Lit "c"))): prop > printout it; `proposition: (!((!a & b) | c) | !d) & (!d | (!a & b) | c)` val it = (): ?.unit

If you were to implement an incorrect function, that has say unbalanced/incorrectly placed brackets or an incorrect symbol, you would get and exception:

> inputString "(a&)(b"; Exception- malformedInput raised

propositional-logic-parser's People

Contributors

benjaminphi5 avatar

Watchers

James Cloos avatar

Forkers

ervindot

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.