On Oct 12, 1:04 pm, William Elliot <
ma...@panix.com> wrote:
> On Thu, 11 Oct 2012, Graham Cooper wrote:
> > equals(X,Y) <- subset(X,Y) ^ subset(Y,X).
>
> What does <- mean? -> ?
Yes!
( subset(X,Y) ^ subset(Y,X) ) -> equals(X,Y)
is just prefix form of
xCy & yCx -> x=y
>
> > ?- male(X).
> > X = tom
> > X = harry
> > X = tim
>
> What does ? mean?
It's a question mark.
Capital terms are variables.
To enter a set you type:
male(tom).
male(harry).
male(tim).
To enter a query you type:
?- male(tom).
or
?- male(X).
>
> > ?- first(male(X)).
>
> As male should return a logical value
> and first returns what? A logical value or an object?
predicates are strings, so they can see their sub arguments of their
arguments.
e.g.
vertical( point(X,Y) , point(X,Z) ).
is a predicate that returns TRUE if it's arguments are predicates, the
first being a point and the second being another point directly above
or below the first point.
?- vertical( point(1,2) , point(1,5) ).
ANSWER: TRUE
?- vertical( point(1,3), point(X,8) ).
ANSWER: P=1
>
> > X = tom
>
> Do you mean first(X,Y,Z) = X?
Essentially, but PROLOG only gives 1 answer at a time so (X,Y,Z) is
actually an entire relational TABLE, not part of the language.
first() is my addition to PROLOG to add database functionality
without resorting to 3GL commands.
I have not implements first() yet though. It will make PROLOG a full
DBMS if I can do it!
>
> > DEFINE SUBSET
>
> > subs(A,X,Y) <-
> > last(e(A,X)) ^
> > e(A,Y).
>
> Meaningless.
if the last element A of set X
is also an element of set Y
then X is a subset of Y
regarding that element.
>
>
>
>
>
>
>
>
>
> > subs(A,X,Y) <-
> > e(A,X) ^
> > e(A,Y) ^
> > next(e(A,X)) ^
> > subs(A,X,Y).
>
> > subset(X,Y) <-
> > first(e(A,X)) ^
> > subs(A,X,Y).
>
> > DEFINE EQUALITY
>
> > equals(X,Y) <-
> > subset(X,Y) ^
> > subset(Y,X).
>
> You're repeating yourself.
>
> > OR
>
> > equals(X,Y) <- subset(X,Y) ^ subset(Y,X).
>
> There's suppost to be a difference?
It's a concise Defn of set equality,
subset is not the same as propersubset.
>
> > TRACE
>
> > ?- subset(rower,male). % ARE ALL ROWERS MALE?
>
> > subset(X,Y) <-
> > first(e(A,X)) ^
> > subs(A,X,Y).
>
> Incomprehensible.
You ask PROLOG the question,
rower C male ?
and it looks for the matching head of the given definitions.
HEAD <- TAIL1 ^ TAIL2 ^ TAIL3
This is only for finite sets but it's trivial to run on systems like
PROLOG.
Look up HORN CLAUSE and it's suitability for proof by resolution.
Herc