Re: Beginner's questions



On Wed, 04 May 2005 08:00:24 -0700, Brian Hulley wrote:
>> Nevertheless, this is my code so far. Beware, I'm 100% newbie. :-)
>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>> digit(X) :- member(X, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]).
> The above clause is OK, since there is no built-in predicate digit/1.

Right. That one was pretty easy. :-)

>> not(member(c, [a, t, d, o, g, n, t])).
>> not(member(a, [t, d, o, g, n, t])).
>> not(member(t, [d, o, g, n, t])).
>> not(member(d, [o, g, n, t])).
>> not(member(o, [g, n, t])).
>> not(member(g, [n, t])).
>> not(member(n, [t])).
>> r0 = g+t.
>> t = r0 mod 10.
>> c0 = r0 // 10.
>> r1 = c0+o+n.
>> a = r1 mod 100.
>> c1 = r1 // 100.
>> c = c1+d+a.
> None of the above clauses can be asserted, because they conflict with
> Prolog's built-in predicates ie not/1 and =/2 which you can't redefine.

Oh, that's not what I'm trying to do. the "not(member(.." clauses are
supposed to explain to the interpreter, that c is not a member of the
list of a, t, d, o, g, n, and t. That is to say, c does not have the same
value as neither a, t, d, o, g, n, or t.
The rest is supposed to tell the intepreter that r0 equals the sum of g
and t, t equals r0 mod 10, etc..
I really appreciate all your suggestions, but could we stick with my
code? I know it's a piece of sh*te, but I think it'd help me understand.
The digit/1 things are all fine, so let's not worry any more about that.

The way I've understood prolog so far, what I define are a bunch of
truths, and prolog can the use these truths to deduce other truths.
"not(member(c, [a, t, d, o, g, n, t])" was supposed to say that c does not
hold the same value as any of the other constants whose value I'm trying
to find. From what I gather now, this is wrong for two reasons:
1. Prolog thinks I'm trying to redefine not/1. I'm not sure why, or how to
fix it.
2. The member/2 is also wrong, because it's not using the values of the
constants, but rather the constants themselves, which makes the statements
redundant, because of course c is not a. They might hold the same value,
but they're not the same constant. I'm not really sure how to fix this
either.

Thank for your help so far!

--
Salu2, Søren.
.



Relevant Pages

  • Re: Out of local stack? (SWI)
    ... that your clauses go from the most spécific case to the most général ... all the lines 'Ontimer" and see wich one is always choosen..... ... >>and standard Prolog is pretty simple minded. ...
    (comp.lang.prolog)
  • question about last call optimization
    ... I have a question about last call optimization using euclids algorithm ... Okay the prolog literature gives the procedure as: ... Now will prolog "last call optimize" this. ... What about if we switch the order of the clauses as such: ...
    (comp.lang.prolog)
  • Re: The Da Vinci Code.
    ... Prolog language which just don't stand up in practice. ... get experienced, you realize that most clauses *are*, in fact, ...
    (alt.usage.english)
  • Re: Resultion Method not suitable for non-classical Logics?
    ... But by taking all input clauses to be definite clauses, ... And the resolution that Prolog usually uses is input ... with methods found in resolution refutation. ... It doesn't work for Prolog and resolution refutation method. ...
    (sci.logic)
  • Re: question about last call optimization
    ... Okay the prolog literature gives the procedure as: ... > no alternative clauses. ... then you still have last-call optimization in some Prolog systems (e.g., ...
    (comp.lang.prolog)