Git Product home page Git Product logo

natural_logic_interpreter's Introduction

Natural_Logic_Interpreter

Description

NLI automatically interprets and validates nested natural logical arguments (logical arguments expressed in natural language) based on rules of inference and propositional logic. The program uses "divide and conquer" algorithms implemented by recursive functions to go through nested logical arguments and to be able to define and validate them accordingly.

Inspiration

"Translating sentences in English (or other natural languages) into logical expressions is a crucial task in mathematics, logic programming, artificial intelligence, software engineering, and many other disciplines."

I came across this paragraph while studying "Discrete Mathematics and It's Applications"; therefore, I got inspired to automate this task using computers.

Examples

We can establish these logical arguments:

(I go to school) AND ((I study) AND (I exercise))

IF (I exercise) THEN (I'm healthy)

IF (I'm healthy) THEN (NOT I'm sick)

(I study) OR (I'm sick)

(NOT it rains today)

(I study) AND ((I go to gym) OR (I drink a coffee))

(it rains today) OR ((I exercise) AND (I study))

IF (I'm healthy) THEN (I'm happy) OR (I'm fit)

Then we can validate any proposition we want based on them:

(I'm sick) -----> False

IF (I exercise) THEN (I'm healthy) -----> True

(it rains today) OR ((I exercise) AND (I study)) -----> True

(It rains today) OR (I'm healthy) -----> True

(I drink a coffee) AND ((I'm happy) OR (I'm fit)) -----> None

We can also see all the conclusions that were able to be drawn by the program:

(It rains today) ---> None

(I go to gym) OR (I drink a coffee) ---> None

(I'm happy) ---> None

(I drink a coffee) AND ((I'm happy) OR (I'm fit)) ---> None

(It rains today) OR (I'm healthy) ---> True

(I study) AND ((I go to gym) OR (I drink a coffee)) ---> True

IF (I'm healthy) THEN (NOT I'm sick) ---> True

IF (I'm healthy) THEN (I'm happy) OR (I'm fit) ---> True

(I'm fit) ---> None

(I study) OR (I'm sick) ---> True

(I go to school) AND ((I study) AND (I exercise)) ---> True

(I go to school) ---> True

(it rains today) OR ((I exercise) AND (I study)) ---> True

(I exercise) AND (I study) ---> True

(I'm healthy) ---> True

IF (I exercise) THEN (I'm healthy) ---> True

(I go to gym) ---> None

(I'm happy) OR (I'm fit) ---> None

(I study) AND (I exercise) ---> True

(I drink a coffee) ---> None

(I exercise) ---> True

(it rains today) ---> False

(I'm sick) ---> False

(I study) ---> True

Dependencies

Python 3.5

Install and Usage

Download or clone the repo and click on the executable python file called "NLI" to enter an interactive command line interface.

Syntax Conventions

This is how various expressions should be entered in this program:

Simple expressions: (expression)

AND arguments: (expression1) AND (expression2)

OR arguments: (expression1) OR (expression2)

NOT arguments: (NOT expression)

Conditional arguments: IF (expression1) THEN (expression2)

Current Known Bugs and Limitations

The regex that is written to recognize the type of arguments sometimes fails to do so when the depth or length of main logical arguments becomes large. However, there has not been any known issues when working with arguments similar to the ones seen in the Examples section.

In addition, NOT operation for now cannot be used in the following ways:

These need to be implemented using De Morgan's Law

NOT (expression1) AND (expression2)

NOT (Expression1) OR (expression2)

The author is working on these issues.

Contributing

This field of study is huge and this program is not complete by any means. There is a lot that can be done to add on its capabilities. Please feel free to contribute and build on top of it. Should you have any questions in order to start email me at: [email protected].

Author

Parham Pourdavood

natural_logic_interpreter's People

Contributors

parhamp avatar

Watchers

 avatar  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.