Live data from Hacker News

Introduction to logic programming with Prolog

matchilling.com

61–70 of 93 posts

Re: Introduction to logic programming with Prolog

#61
post #24

For those looking to gentle introduction to logic programming, Tarski's World was a very good book. https://ggweb.gradegrinder.net/tarskisworld https://web.stanford.edu/group/cslipublications/cslipublicat... Might help, instead of jumping straight into Prolog.

oh you reminded me of a program we used in college named the same. It was about model theory and valid logic clauses (blurry memories)..

Re: Introduction to logic programming with Prolog

#62
post #55

I agree with what Sylvain Soliman said about this on Reddit: It's a nice tutorial for the 80's parts of the language: https://www.reddit.com/r/programming/comments/7hp2xw/introdu... In modern Prolog systems, you would use more declarative features such as constraints to model combinatorial tasks like map coloring. Make sure to check out modern Prolog features if you are interested in learning the language seriously!

are modern prolog just a layer on top of the old semantics or somehow an incompatible paradigm ?

A modern Prolog like SWI with CLPFD allows you to apply Prolog's semantics to arithmetic expressions in a way that you never were able to in classic Prolog. Instead of using `is/2`, you use `#=` and some other operators, Prolog can find solutions for expressions that would be very difficult to do in either classic Prolog or any other system.

Re: Introduction to logic programming with Prolog

#63
post #5

I find the section 5.3 from the paper "Out of the tar pit"[1] describes it very well: > It is for this reason that Prolog falls short of the ideals of logic programming. Specifically it is necessary to be concerned with the operational interpretation of the program whilst writing the axioms. I haven't heard of any approach that generalizes the goals of logic programming in a far better way. Is there any? (on specific…

Most programming languages fall short of some ideal. It doesn't mean you're not able to be productive or do interesting things.

Re: Introduction to logic programming with Prolog

#64

Earlier quoted context omitted.

The point of Prolog as a practical logic programming language really is that it is portable accross Prolog implementations based on ISO Prolog (and maybe prolog-commons API compatibility). If you're using a Prologish tool (a Java framework, say) that is not quite Prolog, then you're loosing the compatibility for very little gain IMHO. Applications domains I've used Prolog for: discrete planning, game logic, limited/r…

> The point of Prolog as a practical logic programming language really is that it is portable accross Prolog implementations based on ISO Prolog (and maybe prolog-commons API compatibility). If you're using a Prologish tool (a Java framework, say) that is not quite Prolog, then you're loosing the compatibility for very little gain IMHO. I feel like I might be missing something obvious, but I'm not getting what the "c…

I'm not disagreeing that if you're developing a Web app, embedding logical or constraint programming techniques into a JavaScript API could make sense. OTOH, there's an obvious way for data exchange between JavaScript and Prolog, in that JSON can be be parsed by using Prolog's embedded `op/2` predicate and operator-precedence parser for defining custom DSLs.

Re: Introduction to logic programming with Prolog

#65
post #55

I agree with what Sylvain Soliman said about this on Reddit: It's a nice tutorial for the 80's parts of the language: https://www.reddit.com/r/programming/comments/7hp2xw/introdu... In modern Prolog systems, you would use more declarative features such as constraints to model combinatorial tasks like map coloring. Make sure to check out modern Prolog features if you are interested in learning the language seriously!

are modern prolog just a layer on top of the old semantics or somehow an incompatible paradigm ?

The OP is likely speaking of "Constraint Logic Programming(CLP)".

The set of CLP languages is generally implemented as a superset or add-on package(s) to a Prolog implementation. For example, SICStus Prolog and SWI-Prolog have CLP modules, e.g.:

https://sicstus.sics.se/sicstus/docs/3.7.1/html/sicstus_32.h...

http://www.swi-prolog.org/pldoc/man?section=clp

and "Constraint Handling Rules(CHR):

http://www.swi-prolog.org/pldoc/man?section=chr

To the best of my knowledge the modules are written in Prolog. A look at those links will give you an idea of how CLP is used. There are modules available for CLP(X) where X is one of:

B = boolean,

Z = integers,

Q = rational numbers,

R = real(floating point) numbers,

FD = finite domains (see "CLP(FD) Constraint Logic Programming over Finite Domains" http://www.pathwayslms.com/swipltuts/clpfd/clpfd.html )

etc.

One can understand how constraining the domain of interest (reducing the search space) to say, the integers, might make search more efficient.

Re: Introduction to logic programming with Prolog

#67
post #42

Is anyone reading this aware of any work on logic programming in the large as in efforts that are harnessing the fact that answerset programming avoids committed choice and so enables us to write reliable tractable programs, but aims to make that possible in teams or in distributed settings?

I haven't encountered anything across answer set programming in the large as you put it. It is still pretty academic and mainly used for solving puzzle and optimization problems.

And yet declaring all business logic was once the way that all decisions would be encoded!

Re: Introduction to logic programming with Prolog

#68
post #66

How does Prolog relate to ML systems? It seems they work in a similar way. Input some learning data and then the system produces output based on these.

Eh, they are quite different under the hood. To put it real simple (and probably quite sloppy): Prolog determines the output by applying logic. ML uses mathematics to analyze the input and "guesses" the output, based on the training set.

As a corollary: Prolog will negate anything that can't be proven true from the rules you give it. A ML algorithm will always give you some answer, though the quality depends on the learning data.

Re: Introduction to logic programming with Prolog

#69

I've seen a few contalks about logic programming, read a few articles, and aside from the intellectual curiosity in itself I can see that it is very elegant in certain circumstances (although I lack the hands-on experience to feel what those circumstances are). Since doing a whole program in prolog isn't really practical for me, is there any way to use the logic programming paradigm in mainstream programming language…

Check out https://github.com/rvirding/erlog with Erlang/Elixir

It seems we have come full circle (the Erlang VM was originally written in Prolog)

Re: Introduction to logic programming with Prolog

#70
post #68
post #66

How does Prolog relate to ML systems? It seems they work in a similar way. Input some learning data and then the system produces output based on these.

Eh, they are quite different under the hood. To put it real simple (and probably quite sloppy): Prolog determines the output by applying logic. ML uses mathematics to analyze the input and "guesses" the output, based on the training set. As a corollary: Prolog will negate anything that can't be proven true from the rules you give it. A ML algorithm will always give you some answer, though the quality depends on the l…

Cool. Thanks! I am watching these trends from the outside and it's hard to keep up if you don't work directly with the tools.
Post reply on HN