Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Simulating PROLOG inside PROLOG!
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Graham Cooper  
View profile  
 More options Nov 18 2012, 5:51 pm
Newsgroups: sci.logic, sci.math, comp.ai.philosophy, comp.lang.prolog
From: Graham Cooper <grahamcoop...@gmail.com>
Date: Sun, 18 Nov 2012 14:51:27 -0800 (PST)
Local: Sun, Nov 18 2012 5:51 pm
Subject: Simulating PROLOG inside PROLOG!
Imagine if you could cut down on all the PROLOG RULES

f(a,b,c)  :-  g(a,b) , h(b,c).

and just use SINGLE FACTS!

if(  g(a,b)&h(b,c)  ,  f(a,b,c)).

This would greatly simplify tracing the program run and give you more
control over the facts and implications you manipulate!

-----LOG13.PRO----

less(0,X).
iif( less(X,Y) , less(Y,Z) , less(X,Z)).   %TRANSITIVE RULE
t(less(X,Y)) :- less(X,Y).

t(R) :- if(L,R), t(L).
t(N) :- iif(E,W,N) , t(E), t(W).

less(1,2).
less(2,3).
less(3,4).

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

You might recognize MODUS PONENS

t(R) <- if(L,R) & t(L)

but what is:

t(N) <- iif(E,W,N)  &  t(E)  &  t(W)

This will reduce a fact N(ORTH)
given E(AST) and W(EST) are true!

and (E&W -> N)

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

This is basically all a prolog rule application does but it might have
several more directions!

================

@ log13.

?- less(1,2).
YES

?- less(1,3).
NO

?- t(less(1,3)).
YES

?- t(less(1,4))
YES

?- t(less(2,4))
YES
-----------------

This is PROLOG using a DOUBLE MODUS PONENS RULE
(instead of it's built in TAIL FOLLOWING SYSTEM directly)

===============

E & W & (E&W)->N
--> N

===============

NEXT WEEK!

MODUS PONENS CONSTRUCTS A PROOF!

proof( R , [R|DED] ) <- if(L,R)  &  proof( L , DED )

Herc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alan Smaill  
View profile  
 More options Nov 18 2012, 6:30 pm
Newsgroups: sci.logic, sci.math, comp.ai.philosophy, comp.lang.prolog
From: Alan Smaill <sma...@SPAMinf.ed.ac.uk>
Date: Sun, 18 Nov 2012 23:28:44 +0000
Local: Sun, Nov 18 2012 6:28 pm
Subject: Re: Simulating PROLOG inside PROLOG!

Graham Cooper <grahamcoop...@gmail.com> writes:
> Imagine if you could cut down on all the PROLOG RULES

> f(a,b,c)  :-  g(a,b) , h(b,c).

> and just use SINGLE FACTS!

> if(  g(a,b)&h(b,c)  ,  f(a,b,c)).

> This would greatly simplify tracing the program run and give you more
> control over the facts and implications you manipulate!

ever heard of clause/2  from the Prolog standard?

> Herc

--
Alan Smaill

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Cooper  
View profile  
 More options Nov 18 2012, 6:30 pm
Newsgroups: sci.logic, sci.math, comp.ai.philosophy, comp.lang.prolog
From: Graham Cooper <grahamcoop...@gmail.com>
Date: Sun, 18 Nov 2012 15:30:16 -0800 (PST)
Local: Sun, Nov 18 2012 6:30 pm
Subject: Re: Simulating PROLOG inside PROLOG!

> -----LOG13.PRO----

> less(0,X).
> iif( less(X,Y) , less(Y,Z) , less(X,Z)).   %TRANSITIVE RULE

This is the PROLOG RULE being emulated by the above INFERENCE RULE (a
PROLOG FACT)

less(X,Z) :- less(X,Y), less(Y,Z).

less(1,2).
less(2,3).
less(3,4).

Herc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Cooper  
View profile  
 More options Nov 18 2012, 6:41 pm
Newsgroups: sci.logic, sci.math, comp.ai.philosophy, comp.lang.prolog
From: Graham Cooper <grahamcoop...@gmail.com>
Date: Sun, 18 Nov 2012 15:41:42 -0800 (PST)
Local: Sun, Nov 18 2012 6:41 pm
Subject: Re: Simulating PROLOG inside PROLOG!
On Nov 19, 9:30 am, Alan Smaill <sma...@SPAMinf.ed.ac.uk> wrote:

> Graham Cooper <grahamcoop...@gmail.com> writes:
> > Imagine if you could cut down on all the PROLOG RULES

> > f(a,b,c)  :-  g(a,b) , h(b,c).

> > and just use SINGLE FACTS!

> > if(  g(a,b)&h(b,c)  ,  f(a,b,c)).

> > This would greatly simplify tracing the program run and give you more
> > control over the facts and implications you manipulate!

> ever heard of clause/2  from the Prolog standard?

It looks like it traces the subgoals being invoked.

You could just enter TRACE mode.

or 'compile'  the deductions into a list for printing.

t(R)  <-  if(L,R) & t(L).
proof( R , [R|DED] ) <- if(L,R)  &  proof( L , DED )

this would be like putting clause around t(..) or mp(..) to see the
steps taken.

seems there's neater ways to do all these added functions with unify
on atomic predicates.

PROLOG was cut short by only displaying 1 result, then resorting to
LISP coding to show the rest!

mProlog has tabular output of all answers and much of the 3GL add ons
can be done with atomic predicates and recursion.

www.microPROLOG.com

[owns tom X]?

[owns tom       X         ]
[owns tom       house]
[owns tom       car      ]
[owns tom       cat      ]

Herc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jan Burse  
View profile  
 More options Nov 19 2012, 4:31 am
Newsgroups: comp.lang.prolog
From: Jan Burse <janbu...@fastmail.fm>
Date: Mon, 19 Nov 2012 10:31:38 +0100
Local: Mon, Nov 19 2012 4:31 am
Subject: Re: Simulating PROLOG inside PROLOG!
Graham Cooper schrieb:

> It looks like it traces the subgoals being invoked.

> You could just enter TRACE mode.

> or 'compile'  the deductions into a list for printing.

> t(R)  <-  if(L,R) & t(L).
> proof( R , [R|DED] ) <- if(L,R)  &  proof( L , DED )

> this would be like putting clause around t(..) or mp(..) to see the
> steps taken.

Actually clause/2 doesn't help per se in tracing. It is
only a reflective system predicate to query the clauses
of a dynamic predicate.

But it can be used to build a meta interpreter:

   solve(true) :- !.
   solve((A,B)) :- !, solve(A), solve(B).
   solve(H) :- clause(H,B), solve(B).

And from this also debuggers etc.. can be built. Including
solvers that return a kind of proof tree as your proof/2
suggests. And much more.

But it wont be very efficient since a call to clause/2 is
usually slower than a native clause invokation, although
clause/2 might also offer multi-argument indexing. Here is
a little test whether it has multi-argument indexing:

    :- dynamic r/2.

    r(a, b).
    r(a, c).
    r(d, c).
    r(d, e).

In SWI-Prolog (6.3.4) and Jekejeke Prolog (0.9.6) we have:

    ?- clause(r(X, c),true).
    X = a ;
    X = d
    ?-

So it detects determinism, since after showing the solution
X = d it directly returns to the top level as it didn't find
more choice points. In GNU Prolog (1.4.1) on the other hand
we have:

    ?- clause(r(X,c),true).
    X = a ? ;
    X = d ? ;
    no
    ?- (X=a;X=d).
    X = a ? ;
    X = d
    yes

With multi-argument indexing in clause/2 determinism can also
transpire through the last rule of solve/1 and make solve/1
behave as the original program concerning determinism.

The clause/2 system predicate is for example documented here:

    http://www.swi-prolog.org/pldoc/man?predicate=clause%2F2

Bye


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alan Smaill  
View profile  
 More options Nov 19 2012, 6:55 am
Newsgroups: sci.logic, sci.math, comp.ai.philosophy, comp.lang.prolog
From: Alan Smaill <sma...@SPAMinf.ed.ac.uk>
Date: Mon, 19 Nov 2012 11:53:31 +0000
Local: Mon, Nov 19 2012 6:53 am
Subject: Re: Simulating PROLOG inside PROLOG!

No, it doesn't;
it gives what you were talking about,
a unit clause corresponding to each normal Prolog program clause.

> Herc

--
Alan Smaill

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Cooper  
View profile  
 More options Nov 19 2012, 6:34 pm
Newsgroups: sci.logic, sci.math, comp.ai.philosophy, comp.lang.prolog
From: Graham Cooper <grahamcoop...@gmail.com>
Date: Mon, 19 Nov 2012 15:34:24 -0800 (PST)
Local: Mon, Nov 19 2012 6:34 pm
Subject: Re: Simulating PROLOG inside PROLOG!
On Nov 19, 9:55 pm, Alan Smaill <sma...@SPAMinf.ed.ac.uk> wrote:

but it still uses the UNIFY process to resolve the body/tail.

RULE:     HEAD    ..........   BODY
................less(X,Z)  :-  less(X,Y), less(Y,Z).

clause(  less(X,Z) ,   less(X,Y),less(Y,Z) ).

----------

FORMAL SYSTEM EMULATING RULES (with 1 or 2 tail segments in body)

if(L,R).                     // 1 tail segment  emulated
rule( N , E, W ).      // 2 tail segments emulated

rule( less(X,Z) ,  less(X,Y) ,  less(Y,Z) ).

----------

FORMAL SYSTEM 2 and only 2 RULES

t(R) :- if(L,R), t(L).

t(N) :- if(N,E,W), t(E), t(W)

---------

Now you have full control how the predicates are solved and the trace
is extremely simple.

Herc
--

something like this...

or(1,1).
or(1,0).
or(0,1).
if(1,1).
if(0,1).
if(0,0).
and(1,1).
iff(1,1).
iff(0,0).
xor(1,0).
xor(0,1).

not(or(0,0)).
not(if(1,0)).
not(and(1,0)).
not(and(0,1)).
not(and(0,0)).
not(iff(1,0)).
not(iff(0,1)).
not(xor(1,1)).
not(xor(0,0)).

iif( X      , Y      , or(X,Y)       ).
iif( not(X) , not(Y) , not(or(X,Y))  ).
iif( not(X) , Y      , or(X,Y)       ).
iif( X      , not(Y) , or(X,Y)       ).

iif( X      , Y      , and(X,Y)      ).
iif( not(X) , not(Y) , not(and(X,Y)) ).
iif( not(X) , Y      , not(and(X,Y)) ).
iif( X      , not(Y) , not(and(X,Y)) ).

iif( X      , Y      , if(X,Y)       ).
iif( not(X) , not(Y) , if(X,Y)       ).
iif( not(X) , Y      , if(X,Y)       ).
iif( X      , not(Y) , not(if(X,Y))  ).

iif( X      , Y      , iff(X,Y)      ).
iif( not(X) , not(Y) , iff(X,Y)      ).
iif( not(X) , Y      , not(iff(X,Y)) ).
iif( X      , not(Y) , not(iff(X,Y)) ).

iif( if(A,B) , if(B,C) , if(A,C) ).

if( not(not(X))      , X                  ).
if( not(and(X,Y))    , or(not(X),not(Y))  ).
if( not(or(X,Y))     , and(not(X),not(Y)) ).

t(R) :- if(L,R), t(L).
t(N) :- iif(E,W,N) , t(E), t(W).

proof( R , [R|DED] ) :- if(L,R) , proof( L , DED ).

-------

Then a BINARY TREE MODUS PONENS CONSTRUCTION
with E&W->N
instead of the simple MODUS PONENS  L->R
proof method above...

should solve all mathematics!  If you don't mind exponential time
delays!

Herc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »