Live data from Hacker News

Introduction to logic programming with Prolog

matchilling.com

31–40 of 93 posts

Re: Introduction to logic programming with Prolog

#31
post #28
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…

What you're looking for is called answer set programming. It has pretty much replaced logic programming as a research focus, and a number of implementations exist.

The Wikipedia article for ASP is a very nice introduction: https://en.wikipedia.org/wiki/Answer_set_programming

Re: Introduction to logic programming with Prolog

#32
post #19

I try to introduce my boy (12) in programming trough Scratch but still no big success. However, we solved recently two math homework exercises with Prolog (logic) and MetaPost (geometry) which caused some effect, so I'm thinking to deepen in that languages or may be switch to Logo as intermediate lisp like solution.

That is the best way to introduce computers to a kid: "let it do the hard work for you". Logo used to be very popular for kids here in the '80s. I learnt Logo when i was 7, then i "progressed" over the years to Basic, C, Pascal, C++, Java, C#, Python and now, after about 28 years, Lisp. And now I realize Logo is close to Lisp in many ways and a far more powerful language than some of the ones I "progressed" to.

Yes, my kid was impressed about solving the problem just by describing it.

Re: Introduction to logic programming with Prolog

#33
post #32

Earlier quoted context omitted.

That is the best way to introduce computers to a kid: "let it do the hard work for you". Logo used to be very popular for kids here in the '80s. I learnt Logo when i was 7, then i "progressed" over the years to Basic, C, Pascal, C++, Java, C#, Python and now, after about 28 years, Lisp. And now I realize Logo is close to Lisp in many ways and a far more powerful language than some of the ones I "progressed" to.

Yes, my kid was impressed about solving the problem just by describing it.

Exactly in the same way my mind was blown the first time I tried Prolog!

Re: Introduction to logic programming with Prolog

#34
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…

Ah, that's a problem with many facets. It is not that we can't come up with a logic language that is more declarative, it is just that telling the program everything about the universe is so damn dull. For example, ordering of your body predicates will often be based on what you think intuitively their sizes of solutions are going to be e.g. `plus(A,B,C), solution(C,X).` You know that plus is injective, so you put it…

I made an online Datalog IDE with Lua extensions (Turing complete): http://ysangkok.github.io/mitre-datalog.js/wrapper.html

Re: Introduction to logic programming with Prolog

#35

When writing a Prolog program a while ago I stumbled across an old mailing list where someone posted the following joke. Q. "How many Prolog Programmers does it take to change a lightbulb?" A. No.

Can't resist, I will add https://en.wikipedia.org/wiki/Answer_set_programming programming on this.

Q. How many Answerset programmers does it take to change a lightbulb? A. {1}, {1,2}, {1,2,3}, {2,1}, {2,1,3}, {2,3,1}

Re: Introduction to logic programming with Prolog

#36
post #4

I hated it in university and hate it until this very moment. I get what this language is doing and why it is great for special usecases. But I can absolutly can not read code written in Prolog. Staring at 3 lines of code and not knowing what the hell it does, gives me nightmares till today. You can write a quicksort in a few lines. You can traverse over a tree very easily. But understanding these few lines takes me m…

Some problems are harder to express in Prolog (than in conventional imperative logic), but then there are some problems that are far, far easier to solve in Prolog.

Re: Introduction to logic programming with Prolog

#37
post #26
post #4

I hated it in university and hate it until this very moment. I get what this language is doing and why it is great for special usecases. But I can absolutly can not read code written in Prolog. Staring at 3 lines of code and not knowing what the hell it does, gives me nightmares till today. You can write a quicksort in a few lines. You can traverse over a tree very easily. But understanding these few lines takes me m…

I love Prolog, to the point of having taken part in the Portuguese university national logic championship back in the 90's. On our degree, we had three logic programming classes, starting from logic programming as pure math all the way to deep Prolog exercises.

I didn't know there were Logic championships using Prolog!

P.S: Vocé é Portuguese, lisper e tambén fá de Prolog? You impress me more each day, pjmlp!

Re: Introduction to logic programming with Prolog

#38
post #19

I try to introduce my boy (12) in programming trough Scratch but still no big success. However, we solved recently two math homework exercises with Prolog (logic) and MetaPost (geometry) which caused some effect, so I'm thinking to deepen in that languages or may be switch to Logo as intermediate lisp like solution.

That is the best way to introduce computers to a kid: "let it do the hard work for you". Logo used to be very popular for kids here in the '80s. I learnt Logo when i was 7, then i "progressed" over the years to Basic, C, Pascal, C++, Java, C#, Python and now, after about 28 years, Lisp. And now I realize Logo is close to Lisp in many ways and a far more powerful language than some of the ones I "progressed" to.

It's always been interesting to me how Logo, a Lisp dialect, was so successful as a language for teaching children to program, but so many people still go around with the idea that Lisp is really hard to wrap your head around.

Re: Introduction to logic programming with Prolog

#40
post #4

I hated it in university and hate it until this very moment. I get what this language is doing and why it is great for special usecases. But I can absolutly can not read code written in Prolog. Staring at 3 lines of code and not knowing what the hell it does, gives me nightmares till today. You can write a quicksort in a few lines. You can traverse over a tree very easily. But understanding these few lines takes me m…

> You can write a quicksort in a few lines. You can traverse over a tree very easily. But understanding these few lines takes me more time than writing it in C, Java, PHP etc

I'm still only a beginner at Prolog, but that's what I enjoy about it: it's an entirely different way of tackling problems that really stretches my brain, not just new syntax on the same old paradigm that I already know.

Post reply on HN