Coder Social home page Coder Social logo

prolog-programs's Introduction

Logic Progamming with Prolog

Intro to logic progamming

Logic progamming deals with relations rather than functions.

Relations

A concrete view of a relation is as a table with n>= 0 columns and a possibly infinite set of rows.

Some basic relations are:

  • Rules

    Rules are written as in

        P if Q1 and Q2 and ...  and Qk. for k>=0.

    This is also called a Horn Clause.

  • Facts

    A fact is a special case of a rule, in which k = 0 and P holds without any condition, written simply as

        P.

    A fact is always true.

  • Append

    The append relation is specified by two rules. The first is a fact starting that triples of the form ([], Y, Y) are in relation append.

    append [] and Y to get Y.

    The second rule for append is shown for completeness. It uses the [H|T] for a list with Head H and tail T:

        append [H|X] and Y to get [H|Z]
            if append X and Y to get Z

Queries

Logic progamming is driven by queries about relation. The simplest queries ask whether a particular tuple belongs to a relation. The query asks whether the triple `([a,b],[c,d],[a,b,c,d]) belongs to relation append.

    append [a,b] and [c,d] to get [a,b,c,d]?
            Answer: yes

Intro to PROLOG

prolog-programs's People

Contributors

debasish-dutta avatar neeharika-sonowal 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.