Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Evaluation of a subset of clauses
Another newbie question for you...

In my program I have to extract/create some clauses, and prove goals
against this 'fresh' set of clauses. For this purpose I extended the
classic 'Vanilla' meta-interpreter


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


obtaining (Prg is obviously a list of clauses)


sub_solve(true, Prg).

sub_solve( (G1, G2), Prg) :-
sub_solve(G1, Prg),
sub_solve(G2, Prg).

sub_solve(Goal, Prg) :-
member(Clause, Prg),
sub_unify(Goal, Clause, Rest),
sub_solve(Rest, Prg).

sub_unify(Goal, (A :- B), Rest) :-
Goal =.. L1,
A =.. L2,
are_equal(L1, L2),
Rest = B.

are_equal([],[]).

are_equal([H1 | L1], [H2 | L2]) :-
H1 = H2,
are_equal(L1, L2).


Is this correct? Thanks in advance.

Report this thread to moderator Post Follow-up to this message
Old Post
Eddie Jobson
04-08-05 01:58 PM


Re: Evaluation of a subset of clauses
Eddie Jobson wrote:

> sub_solve(true, Prg).
>
> sub_solve( (G1, G2), Prg) :-
>    sub_solve(G1, Prg),
>    sub_solve(G2, Prg).
>
> sub_solve(Goal, Prg) :-
>    member(Clause, Prg),
>    sub_unify(Goal, Clause, Rest),
>    sub_solve(Rest, Prg).
>
> sub_unify(Goal, (A :- B), Rest) :-
>    Goal =.. L1,
>    A =.. L2,
>    are_equal(L1, L2),
>    Rest = B.
>
> are_equal([],[]).
>
> are_equal([H1 | L1], [H2 | L2]) :-
>    H1 = H2,
>    are_equal(L1, L2).
>
>
> Is this correct? Thanks in advance.

Prolog uses a renamed clause at each resolution step.
The built-in clause/2 does such renaming for you.
But member/2 doesn't, so you must do it yourself;
just before calling sub_unify would be a good place.

Why can't you define sub_unify as follows ...


sub_unify(Goal, (Goal :- Body), Body).

?

Cheers

Bart Demoen

Report this thread to moderator Post Follow-up to this message
Old Post
Bart Demoen
04-08-05 09:00 PM


Re: Evaluation of a subset of clauses
Bart Demoen <bmd@cs.kuleuven.ac.be> wrote in message news:<1112967918.654404
@seven.kulnet.kuleuven.ac.be>...

> Prolog uses a renamed clause at each resolution step.
> The built-in clause/2 does such renaming for you.
> But member/2 doesn't, so you must do it yourself;
> just before calling sub_unify would be a good place.

Sorry Bart, I don't understand what I've to do :-(
Can you give me more hints, please?

Report this thread to moderator Post Follow-up to this message
Old Post
Eddie Jobson
04-08-05 09:00 PM


Re: Evaluation of a subset of clauses
Eddie Jobson wrote:
> Bart Demoen <bmd@cs.kuleuven.ac.be> wrote in message news:<1112967918.6544
04@seven.kulnet.kuleuven.ac.be>...
>
> 
>
>
> Sorry Bart, I don't understand what I've to do :-(
> Can you give me more hints, please?

Read about resolution.
Read about copy_term/2.

Think about the query ?- f(1), f(2).
when the program consists of only one clause: f(X).
Should the query succeed ? Does it with your metainterpreter ? What is
required to make it succeed ?

Cheers

Bart Demoen

Report this thread to moderator Post Follow-up to this message
Old Post
Bart Demoen
04-09-05 01:58 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Prolog archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:05 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.