Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

*neat* AXIOM OF EXTENSIONALITY

0 views
Skip to first unread message

Graham Cooper

unread,
Oct 11, 2012, 10:17:16 PM10/11/12
to
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
equals(X,Y) <- subset(X,Y) ^ subset(Y,X).


********
REVISION
********

?- male(X).
X = tom
X = harry
X = tim


?- first(male(X)).
X = tom

*************
DEFINE SUBSET
*************

subs(A,X,Y) <-
last(e(A,X)) ^
e(A,Y).

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).

OR

-----------------------------------------

equals(X,Y) <- subset(X,Y) ^ subset(Y,X).

-----------------------------------------


*****
TRACE
*****

?- subset(rower,male). % ARE ALL ROWERS MALE?

subset(X,Y) <-
first(e(A,X)) ^
subs(A,X,Y).

subset(rower,male) <-
first(e(A,rower)) ^ % A = tom
subs(tom,rower,male).

-----------------------

RECURSIVE LOOP

subs(A,X,Y) <-
e(A,X) ^
e(A,Y) ^
next(e(A,X)) ^
subs(A,X,Y).

subs(tom,rower,male) <-
e(tom,rower) ^
e(tom,male) ^
next(e(tim,rower)) ^
subs(tim,rower,male).

-----------------------

RECURSIVE STOP

subs(A,X,Y) <-
last(e(A,X)) ^
e(A,Y).

subs(tim,rower,male) <-
last(e(tim,rower)) ^
e(tim,male).

TRUE!

ROWER C MALE

All Rowers are male!

-----------------------

Herc

William Elliot

unread,
Oct 11, 2012, 11:04:54 PM10/11/12
to
On Thu, 11 Oct 2012, Graham Cooper wrote:

> equals(X,Y) <- subset(X,Y) ^ subset(Y,X).

What does <- mean? -> ?

> ?- male(X).
> X = tom
> X = harry
> X = tim
>
What does ? mean?

> ?- first(male(X)).

As male should return a logical value
and first returns what? A logical value or an object?

> X = tom

Do you mean first(X,Y,Z) = X?

> DEFINE SUBSET
>
> subs(A,X,Y) <-
> last(e(A,X)) ^
> e(A,Y).

Meaningless.

> 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?

> TRACE
>
> ?- subset(rower,male). % ARE ALL ROWERS MALE?
>
> subset(X,Y) <-
> first(e(A,X)) ^
> subs(A,X,Y).

Incomprehensible.

Graham Cooper

unread,
Oct 12, 2012, 1:34:51 AM10/12/12
to
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

Graham Cooper

unread,
Oct 12, 2012, 2:25:16 AM10/12/12
to
> > > ?-  first(male(X)).
>
> > > X = tom
>
> > Do you mean first(X,Y,Z) = X?
>


PROLOG returns 1 tuple at a time, SQL returns the entire TABLE or
QUERY.

These are not sets, these are relations because there is more than 1
field.

likes( mary, john) .
likes( john, smokes ).
likes( george, john) .

This is a TABLE

LIKES
mary john <<< first row
john smokes
george john <<< last row


first, last, next, prev, delete, write, search

are standard commands in MS ACCESS, PHP, ORACLE etc..

Currently PROLOG has a very convoluted method to do database actions.
It converts the relations into lists of lists and you do the recursion
on that!

If you find my function FIRST(male(X)) incomprehensible, you should
see the code PROLOG uses currently to do that!

No wonder everyone *sighs* at the mention of PROLOG! They tacked LISP
onto it to do all the work!

Herc
0 new messages