Login Register






Logic programming with Prolog filter_list
Author
Message
RE: Logic programming with Prolog #11
First of all excellent work as usual and there is nothing new so from next time when you make a tutorial then please include the following words by default just the way some packages are automatically included in Java (ex. java.lang )

Code:
Excellent thread, great tutorial. You are heavenly and your tutorial is very well explained, great effort by you. Thank you for taking the time to write this. Thank you for everything! :smiling:.

Hope you understood mam Wink

Spoiler:
Having a little fun learning :lol:, Please don't mind!


I have read it completely and have done some quick tests. Having a bit problem with lists though but I would study a bit more online then I will ask you Confusedmiling:

The two links that you have provided has some problems because at the end of the links ')' is also include in the links which is giving a wrong page. Please include a space before them.

Here copy and paste :-

Quote:(https://en.wikipedia.org/wiki/Watson_computer )

(benchmark: http://www.stups.uni-duesseldorf.de/ProB..._Prolog%3F )

Homework :-

Code:
factorial(0,1). factorial(N,F) :- N>0, N2 is N-1, factorial(N2,F1), F is N*F1.

Output :-

Spoiler:
[Image: prolog_hw_deque.png]
[Image: OilyCostlyEwe.gif]

Reply

RE: Logic programming with Prolog #12
First of all excellent work as usual and there is nothing new so from next time when you make a tutorial then please include the following words by default just the way some packages are automatically included in Java (ex. java.lang )

Code:
Excellent thread, great tutorial. You are heavenly and your tutorial is very well explained, great effort by you. Thank you for taking the time to write this. Thank you for everything! :smiling:.

Hope you understood mam Wink

Spoiler:
Having a little fun learning :lol:, Please don't mind!


I have read it completely and have done some quick tests. Having a bit problem with lists though but I would study a bit more online then I will ask you Confusedmiling:

The two links that you have provided has some problems because at the end of the links ')' is also include in the links which is giving a wrong page. Please include a space before them.

Here copy and paste :-

Quote:(https://en.wikipedia.org/wiki/Watson_computer )

(benchmark: http://www.stups.uni-duesseldorf.de/ProB..._Prolog%3F )

Homework :-

Code:
factorial(0,1). factorial(N,F) :- N>0, N2 is N-1, factorial(N2,F1), F is N*F1.

Output :-

Spoiler:
[Image: prolog_hw_deque.png]
[Image: OilyCostlyEwe.gif]

Reply

RE: Logic programming with Prolog #13
@Psycho_Coder: Thanks for the hint. I corrected the links (but not with adding space, I used the url tag)
The homework is correct.

@Everyone: Thank you for your feedback.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Logic programming with Prolog #14
@Psycho_Coder: Thanks for the hint. I corrected the links (but not with adding space, I used the url tag)
The homework is correct.

@Everyone: Thank you for your feedback.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Logic programming with Prolog #15
Sorry for Digging an old thread but I require some assistance.


In my college we are being taught Prolog now for the AI course. Now I am having some major problems with it. I installed SWI-Prolog.

Now I am having some problems regarding this :-

Example :-

When i did a factorial program like this :

Code:
factorial(0,1). factorial(N,F) :- N>0, N2 is N-1, factorial(N2,F1), F is N*F1.

and then compiled and called the clause as factorial(5, A).

I got the correct output. Its fine and understood but in our college its being taught somewhat different.

They are using something called :- predicates, clauses or domains or stuffs like this, and its more like declaration or mentioning the properties from before. I am quite unable to grasp this thing.

I googled and found this : http://ins.nafsadh.com/2009/12/29/prolog-factorial-n/

Logic is same but he has used predicates and clauses as well. I copy pasted the code and saved it as .pl but to my surprise I am getting errors during compilation.

Now can you please explain what is wrong with this. Doing it the way you said is pretty much more readable.

I am very very new to Prolog. Other than this tutorial I read very little about it. I will soon try to grasp it well. But if I can't even compile the codes then I will never be able to learn.


Also when you said that :-
"Know one language and you know all of them", Prolog will prove that wrong.

Seriously its a harsh truth, I know the program logic and I have concept still I am unable to code. I know propositional logic well enough. I tried those (examples like you did here with man clara animal etc., family tree problems) and I am able to use them with Prolog but when it come to these math problems or palindrome or armstrong etc etc, in getting shit.

I don't know why the heck we should be learn Prolog. AI systems can be coded in any programming languages like Java, Python, C++, C, Scala, Ruby etc. etc..

Please tell me what I am doing wrong ?
[Image: OilyCostlyEwe.gif]

Reply

RE: Logic programming with Prolog #16
They probably use a different Prolog implementation for that snippet. I haven't seen anything like declaring the predicates beforehand. What happens if you just remove the predicate declaration?
What errors do you get?

Quote:I don't know why the heck we should be learn Prolog. AI systems can be coded in any programming languages like Java, Python, C++, C, Scala, Ruby etc. etc..

That's like saying: I don't know why we should learn functional programming. We can use imperative programming for the same problems.
It is just another paradigm and imho it is worth knowing, because it teaches you another way to think about problem solving.
In certain areas the declarative logic approach is more suitable, e.g., for expert systems, or semantic web (ontologies). This kind of thinking is also useful if you get into constraint programming. See it as a way to teach and stretch your mind, not only as a way to learn a tool. You actually learn the basics for a lot of tools that use this or a similar approach.

The amazing thing about Prolog is really how simple it is. Not simple as in simple to program stuff with it, but simple as a language, seeing that it is just based on one algorithm to do all of this. A professor of mine once created a Prolog interpreter during one lecture using Haskell (1.5 hours).
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Logic programming with Prolog #17
(08-06-2014, 02:52 PM)Deque Wrote: They probably use a different Prolog implementation for that snippet. I haven't seen anything like declaring the predicates beforehand. What happens if you just remove the predicate declaration?
What errors do you get?

Quote:I don't know why the heck we should be learn Prolog. AI systems can be coded in any programming languages like Java, Python, C++, C, Scala, Ruby etc. etc..

That's like saying: I don't know why we should learn functional programming. We can use imperative programming for the same problems.
It is just another paradigm and imho it is worth knowing, because it teaches you another way to think about problem solving.
In certain areas the declarativ logic approach is more suitable, e.g., for expert systems, or semantic web (ontologies). This kind of thinking is also useful if you get into constraint programming. See it as a way to teach and stretch your mind, not only as a way to learn a tool. You actually learn the basics for a lot of tools that use this or a similar approach.

The amazing thing about Prolog is really how simple it is. Not simple as in simple to program stuff with it, but simple as a language, seeing that it is just based on one algorithm to do all of this. A professor of mine once created a Prolog interpreter during one lecture using Haskell (1.5 hours).


In college they used TProlog or Turbo Prolog (I am feeling so ashamed to tell). I have asked my professor to let us code in SWI-Prolog, he said okay let me see. Oh Well!

If we remove the predicates and clauses, then its simple and I mentioned that I am more or less able to do so.

Yes you're right. I got overwhelmed due to my incapability to fix myself into this paradigm. Sorry!

I will work a bit more. I will probably disturb you a bit more later. (Hope you don't mind)
[Image: OilyCostlyEwe.gif]

Reply

RE: Logic programming with Prolog #18
Ohh come on!
She even does AI programming tutorials...
Now I am sure...she is not a human, she is an android. :troll:

Congratulations for making and sharing that @Deque .
MASTERING OTHERS IS STRENGTH, MASTERING YOURSELF IS TRUE POWER.

[Image: qJweLN6.jpg]

Reply

RE: Logic programming with Prolog #19
(08-06-2014, 04:56 PM)L0aD1nG Wrote: Ohh come on!
She even does AI programming tutorials...
Now I am sure...she is not a human, she is an android. :troll:

Congratulations for making and sharing that @Deque .

If She is an Android I wonder who had programmed such intelligence in her. The grammers and the rule derivation mechanisms.

[Image: meme-funny-768x1024-300x225.jpg]
[Image: OilyCostlyEwe.gif]

Reply

RE: Logic programming with Prolog #20
(08-07-2014, 11:10 AM)Psycho_Coder Wrote:
(08-06-2014, 04:56 PM)L0aD1nG Wrote: Ohh come on!
She even does AI programming tutorials...
Now I am sure...she is not a human, she is an android. :troll:

Congratulations for making and sharing that @Deque .

If She is an Android I wonder who had programmed such intelligence in her. The grammers and the rule derivation mechanisms.

[Image: meme-funny-768x1024-300x225.jpg]

Well dude that guy would probably be...

[Image: b1jfgoz.jpg]

I am quit sure for this.
MASTERING OTHERS IS STRENGTH, MASTERING YOURSELF IS TRUE POWER.

[Image: qJweLN6.jpg]

Reply