Git Product home page Git Product logo

first-order-logic-inference-engine's Introduction

First-Order-Logic-Inference-Engine

This implements a FOL Inference engine using backward chaining and resolution on a KB of statements in CNF Form.

The knowledge bases which you will create to handle each case will contain sentences with the following defined operators:

  • NOT X is represented as ~X
  • X OR Y is represented as X | Y

Format for input.txt:

<NQ = NUMBER OF QUERIES>

<QUERY 1>

<NS = NUMBER OF GIVEN SENTENCES IN THE KNOWLEDGE BASE>

<SENTENCE 1>

where

  • Each query will be a single literal of the form Predicate(Constant) or ~Predicate(Constant).
  • Variables are all single lowercase letters.
  • All predicates (such as Sibling) and constants (such as John) are case-sensitive alphabetical strings that begin with an uppercase letter.
  • Each predicate takes at least one argument. Predicates will take at most 100 arguments. A given predicate name will not appear with different number of arguments.
  • There will be at most 100 queries and 1000 sentences in the knowledge base.
  • See the sample input below for spacing patterns.

Format for output.txt:

For each query, determine if that query can be inferred from the knowledge base or not, one query per line:

<ANSWER 1>

where

  • Each answer would either be TRUE if we can prove that the corresponding query sentence is true given the knowledge base, or FALSE if we cannot.

Loops in the KB inference has been handled with terminating after a certain number of iterations. This was done to restrict inferring same Knowledge again and again. In such case, the query evaluates to a FALSE.

Example of Input--

2

Ancestor(Liz,Billy)

Ancestor(Liz,Joe)

6

Mother(Liz,Charley)

Father(Charley,Billy)

~Mother(x,y) | Parent(x,y)

~Father(x,y) | Parent(x,y)

~Parent(x,y) | Ancestor(x,y)

~Parent(x,y) | ~Ancestor(y,z) | Ancestor(x,z)

Example of Output--

TRUE

FALSE

first-order-logic-inference-engine's People

Contributors

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