Gorgias port
Moderator: Paulo Moura
-
- Logtalk developer
- Posts: 533
- Joined: Sat May 05, 2007 8:35 am
- Location: Portugal
- Contact:
Gorgias port
Hi!
I've made a quick Logtalk port of Gorgias, a general argumentation framework that combines the ideas of preference reasoning and abduction. The original Prolog version is available from the URL:
http://www2.cs.ucy.ac.cy/~nkd/gorgias/
The Logtalk port can be downloaded using the URL:
http://logtalk.org/files/ports/gorgias/ ... -2.tar.bz2
Your feedback is appreciated. Note that this is just a quick port, with much room for improvement. It may also contain bugs not present in the original code. Enjoy,
Paulo
I've made a quick Logtalk port of Gorgias, a general argumentation framework that combines the ideas of preference reasoning and abduction. The original Prolog version is available from the URL:
http://www2.cs.ucy.ac.cy/~nkd/gorgias/
The Logtalk port can be downloaded using the URL:
http://logtalk.org/files/ports/gorgias/ ... -2.tar.bz2
Your feedback is appreciated. Note that this is just a quick port, with much room for improvement. It may also contain bugs not present in the original code. Enjoy,
Paulo
-
- Posts: 48
- Joined: Tue May 15, 2007 4:53 pm
Hi,
It looks like there is a problem with the complement predicate, it looks like the rules :
complement(A, B) :- ^^complement(A, B)
doesn't work when added to one of the examples.
This is what i did :
i first tried to run tweety.lgt as it is by default, and when i try to prove :
tweety::prove([fly(tweety)], D).
it returns No like it should.
But if i add to this file these two lines (there is no meaning to it, it is just for the test) :
complement(a, b).
complement(A, B) :- ^^ complement(A, B).
and i try to prove :
tweety::prove([fly(tweety)], D).
it give me a solution because the complement/2 declared in gorgias.lgt are not used !
Maybe there is a problem with the ^^ functor and the categories ?
Thanks :)
It looks like there is a problem with the complement predicate, it looks like the rules :
complement(A, B) :- ^^complement(A, B)
doesn't work when added to one of the examples.
This is what i did :
i first tried to run tweety.lgt as it is by default, and when i try to prove :
tweety::prove([fly(tweety)], D).
it returns No like it should.
But if i add to this file these two lines (there is no meaning to it, it is just for the test) :
complement(a, b).
complement(A, B) :- ^^ complement(A, B).
and i try to prove :
tweety::prove([fly(tweety)], D).
it give me a solution because the complement/2 declared in gorgias.lgt are not used !
Maybe there is a problem with the ^^ functor and the categories ?
Thanks :)
-
- Logtalk developer
- Posts: 533
- Joined: Sat May 05, 2007 8:35 am
- Location: Portugal
- Contact:
My mistake, sorry. The ^^/2 operator (aka super call) would work if gorgias was an ancestor object, not a category. In this case, you need to use the alias/3 directive. E.g.:Victor NOEL wrote:It looks like there is a problem with the complement predicate, it looks like the rules :
complement(A, B) :- ^^complement(A, B)
doesn't work when added to one of the examples.
This is what i did :
i first tried to run tweety.lgt as it is by default, and when i try to prove :
tweety::prove([fly(tweety)], D).
it returns No like it should.
But if i add to this file these two lines (there is no meaning to it, it is just for the test) :
complement(a, b).
complement(A, B) :- ^^ complement(A, B).
and i try to prove :
tweety::prove([fly(tweety)], D).
it give me a solution because the complement/2 declared in gorgias.lgt are not used !
Maybe there is a problem with the ^^ functor and the categories ?
Code: Select all
:- object(tweety,
imports(gorgias)).
:- initialization(::init).
:- alias(gorgias, complement/2, default_complement/2).
rule(r1(X), fly(X), [bird(X)]).
rule(r2(X), neg(fly(X)), [penguin(X)]).
rule(f1, bird(tweety), []).
rule(f2, penguin(tweety), []).
rule(pr1(X), prefer(r2(X), r1(X)), []).
complement(a, b).
complement(A, B) :-
::default_complement(A, B).
:- end_object.
I've already updated the Gorgias port. You may download it using the URL:
http://logtalk.org/files/ports/gorgias/ ... -3.tar.bz2
All the best,
Paulo
Paulo Moura
Logtalk developer
Logtalk developer
-
- Posts: 48
- Joined: Tue May 15, 2007 4:53 pm
Re: Gorgias port
Hello 
I am trying to look at gorgias again, and of course, I plan to use it with logtalk
While doing tests I noticed two things :
1) the imports in gorgias.lgt should be changed to extends (since lgt 2.31.0)
2) if there is no abducible/2 defined in the theory that imports category gorgias, there is an error !
I don't really know how to handle that, I just know that there is somewhere in resolver.lgt a predicate that try to see if abducible/2 is true for a specific predicate.
Thanks you.

I am trying to look at gorgias again, and of course, I plan to use it with logtalk

While doing tests I noticed two things :
1) the imports in gorgias.lgt should be changed to extends (since lgt 2.31.0)
2) if there is no abducible/2 defined in the theory that imports category gorgias, there is an error !
I don't really know how to handle that, I just know that there is somewhere in resolver.lgt a predicate that try to see if abducible/2 is true for a specific predicate.
Thanks you.
-
- Logtalk developer
- Posts: 533
- Joined: Sat May 05, 2007 8:35 am
- Location: Portugal
- Contact:
Re: Gorgias port
Good to knowVictor NOEL wrote: I am trying to look at gorgias again, and of course, I plan to use it with logtalk![]()

Correct. The change was a consequence of the extended category functionality introduced in version 2.31.0.Victor NOEL wrote: While doing tests I noticed two things :
1) the imports in gorgias.lgt should be changed to extends (since lgt 2.31.0)
A possible solution would be to add the following clause to the "gorgias" category:Victor NOEL wrote: 2) if there is no abducible/2 defined in the theory that imports category gorgias, there is an error !
I don't really know how to handle that, I just know that there is somewhere in resolver.lgt a predicate that try to see if abducible/2 is true for a specific predicate.
Code: Select all
abducible(_, _) :- fail.
Happy logtalking!
Paulo
Paulo Moura
Logtalk developer
Logtalk developer
-
- Posts: 48
- Joined: Tue May 15, 2007 4:53 pm
Re: Gorgias port
Ok, I was thinking about something like that but I wasn't sure it was the best way to resolve itPaulo Moura wrote: A possible solution would be to add the following clause to the "gorgias" category:This clause would act as a catch-all rule when the theory does not define itself the predicate abducible/2.Code: Select all
abducible(_, _) :- fail.

I will :]Paulo Moura wrote: Happy logtalking!
Paulo
Victor
-
- Posts: 48
- Joined: Tue May 15, 2007 4:53 pm
Re: Gorgias port
Hello,
In fact, I can't add abducible(_,_) :- fail. to gorgias.lgt because gorgias.lgt is a category and can't have dynamic (abducible) predicates declared in it
So I tried to adopt the trick detailed in http://logtalk.org/manuals/userman/categories.html :
using a predicate abducible_/2 defined in the category and used by the category and let abducible/2 be dynamic :
abducible_(_,_) :- fail.
abducible_(A, B) :- ::abducible(A, B).
But the problem is here again with abducible/2, and I can't see how to do it differently .. If you have an idea it would be good
In fact, I can't add abducible(_,_) :- fail. to gorgias.lgt because gorgias.lgt is a category and can't have dynamic (abducible) predicates declared in it

So I tried to adopt the trick detailed in http://logtalk.org/manuals/userman/categories.html :
using a predicate abducible_/2 defined in the category and used by the category and let abducible/2 be dynamic :
abducible_(_,_) :- fail.
abducible_(A, B) :- ::abducible(A, B).
But the problem is here again with abducible/2, and I can't see how to do it differently .. If you have an idea it would be good

-
- Logtalk developer
- Posts: 533
- Joined: Sat May 05, 2007 8:35 am
- Location: Portugal
- Contact:
Re: Gorgias port
Hi!
You have found a bug. A simpler way to reproduce it is as follows:
After compiling and loading the code above, sending the message test/1 to the object results in an error:
The correct answer to the message would be an error as the predicate d/1 is declared and dynamic. I'm teaching classes all afternoon. I will look into fixing the problem later at night. Thanks for reporting the problem.
Cheers,
Paulo
You have found a bug. A simpler way to reproduce it is as follows:
Code: Select all
:- category(ctg).
:- public(test/1).
:- private(d/1).
:- dynamic(d/1).
test(X) :-
::d(X).
:- end_category.
:- object(obj,
imports(ctg)).
:- end_object.
Code: Select all
?- {bug}.
<<< loading source file bug...
>>> compiling source file bug...
compiling category ctg... compiled
compiling object obj... compiled
>>> bug source file compiled
% bug.pl compiled 0.00 sec, 4,188 bytes
<<< bug source file loaded
(0 warnings)
true.
?- obj::test(X).
ERROR: Undefined procedure: d/1
Cheers,
Paulo
Paulo Moura
Logtalk developer
Logtalk developer
-
- Posts: 48
- Joined: Tue May 15, 2007 4:53 pm
Re: Gorgias port
Oh ok 
I will wait for a fix, thanks you for the fast repy

I will wait for a fix, thanks you for the fast repy

-
- Logtalk developer
- Posts: 533
- Joined: Sat May 05, 2007 8:35 am
- Location: Portugal
- Contact:
Re: Gorgias port
Typo above. The correct answer to the me message would be a failure, of course, not an error.Paulo Moura wrote: The correct answer to the message would be an error as the predicate d/1 is declared and dynamic. I'm teaching classes all afternoon. I will look into fixing the problem later at night. Thanks for reporting the problem.
Cheers,
Paulo
Paulo Moura
Logtalk developer
Logtalk developer
-
- Logtalk developer
- Posts: 533
- Joined: Sat May 05, 2007 8:35 am
- Location: Portugal
- Contact:
Re: Gorgias port
Fixed in the current development version (r4185):Victor NOEL wrote: I will wait for a fix, thanks you for the fast repy![]()
http://trac.logtalk.org/ticket/5
Please check and report back any remaining problems.
Cheers,
Paulo
Paulo Moura
Logtalk developer
Logtalk developer
-
- Posts: 48
- Joined: Tue May 15, 2007 4:53 pm
Re: Gorgias port
Looks like all is working great now (I just applied r4185 to lgt 2.31.4).
I am modifying a little gorgias to better handle all the dynamic predicates, next I will take a look at all the union operation that needed to be sorted to see if it can be better handled.
After that I will post here a better version maybe with little documentation
I am modifying a little gorgias to better handle all the dynamic predicates, next I will take a look at all the union operation that needed to be sorted to see if it can be better handled.
After that I will post here a better version maybe with little documentation

-
- Posts: 48
- Joined: Tue May 15, 2007 4:53 pm
Re: Gorgias port
Another question :
Is there a reason why there is no set operation on unordered set like in the lists.pl from swi-prolog ? Or maybe there is but I couldn't see it
Because lists order is important for gorgias (or at least for me about how I can understand the semantic of the results it give me
so I don't want to use ordered sets but unordered sets !
Is there a reason why there is no set operation on unordered set like in the lists.pl from swi-prolog ? Or maybe there is but I couldn't see it

Because lists order is important for gorgias (or at least for me about how I can understand the semantic of the results it give me

-
- Posts: 48
- Joined: Tue May 15, 2007 4:53 pm
Re: Gorgias port
And a second one 
I am trying to use the threaded/1 predicate to do and-parallelism but when I use the :
:- threaded.
directive in the gorgias category, I get this error :
ERROR! domain_error(object_directive, threaded/0)
in directive: :-threaded
above line: 25
ERROR: Unknown error term: error(domain_error(object_directive, threaded/0), directive(threaded))
I guess category can not be threaded but how I can do to use threaded/1 predicate in category without declare it as threaded ?
Edit :
I add a question :
I am trying to parallelize the prove/2 predicate of gorgias.lgt :
resolve/2 gives us multiple Query/Delta0 and I would like to run extend each one in a thread.
I thought about running extend in a threaded_call/1 and after running threaded_exit/1, but I can' find a way to do it, (mostly because there is so much variables ...

I am trying to use the threaded/1 predicate to do and-parallelism but when I use the :
:- threaded.
directive in the gorgias category, I get this error :
ERROR! domain_error(object_directive, threaded/0)
in directive: :-threaded
above line: 25
ERROR: Unknown error term: error(domain_error(object_directive, threaded/0), directive(threaded))
I guess category can not be threaded but how I can do to use threaded/1 predicate in category without declare it as threaded ?
Edit :
I add a question :
I am trying to parallelize the prove/2 predicate of gorgias.lgt :
resolve/2 gives us multiple Query/Delta0 and I would like to run extend each one in a thread.
I thought about running extend in a threaded_call/1 and after running threaded_exit/1, but I can' find a way to do it, (mostly because there is so much variables ...

-
- Logtalk developer
- Posts: 533
- Joined: Sat May 05, 2007 8:35 am
- Location: Portugal
- Contact:
Re: Gorgias port
You can use any of the multi-threading predicates, including threaded/1, from a category. You just ned to use the directive threaded/0 in all objects importing the category.Victor NOEL wrote:And a second one
I am trying to use the threaded/1 predicate to do and-parallelism but when I use the :
:- threaded.
directive in the gorgias category, I get this error :
ERROR! domain_error(object_directive, threaded/0)
in directive: :-threaded
above line: 25
ERROR: Unknown error term: error(domain_error(object_directive, threaded/0), directive(threaded))
I guess category can not be threaded but how I can do to use threaded/1 predicate in category without declare it as threaded ?
Take a look to the multi-threading examples in the current Logtalk development version, especially to the "primes" example. If you chose to use the latest development version of Logtalk to take advantage of the multi-threading features, be sure to use the latest development versions of SWI-Prolog or YAP. There is at the moment an incompatibility with the development version of XSB that I hope to be solved soon.Victor NOEL wrote: Edit :
I add a question :
I am trying to parallelize the prove/2 predicate of gorgias.lgt :
resolve/2 gives us multiple Query/Delta0 and I would like to run extend each one in a thread.
I thought about running extend in a threaded_call/1 and after running threaded_exit/1, but I can' find a way to do it, (mostly because there is so much variables ...
Cheers,
Paulo
Paulo Moura
Logtalk developer
Logtalk developer