Menu

#280 Inconsistencies in noun/verb

open
nobody
Lisp Core (456)
5
2006-07-06
2003-03-28
No

-- nounify(diff) displays as derivative when display2d is
true, and diff when display2d is false.

-- In some cases, the noun form is spelled differently
from the verb form. This can be handy, though it is
confusing. For example, "IF" has a convenient noun
form, COND, so you can write COND(a,b,c) without
getting an error ("unable to evaluate predicate").
However, though the noun form of DIFF displays as
DERIVATIVE, when Maxima reads in DERIVATIVE, it in
fact uses the verb form DIFF. Example:

if(1<2,a,b) => a Verb form
nounify("IF") => COND (%cond)
(nounify("IF"))(a,b) Noun form
cond(1<2,a,b) => cond(1<2,a,b) Noun form
part(_,0) => cond Noun form

diff(x^2,x) => 2*x Verb form
nounify('diff) => DERIVATIVE (%derivative)
(nounify('diff))(x^2,x) Noun form
derivative(x^2,x) => 2*x Verb form
part(_,0) => diff Verb form

-- apply_nouns is documented, but nowhere defined

-- Noun/verb behavior of operators like "+" and "IF" is
messed up:

-- ev( (' "+")(x,x), nouns) returns +(x,x) instead of 2*x.
This is because (' "+")(x,y) gives ((&+) x y). It should
give the same thing as (nounify("+"))(x,y), namely ((%
mplus simp) x y).

-- Similarly for "IF".

-- I haven't tested thoroughly, but there seem to be
similar confusions for "DO"/MDO, ":"/SETQ, etc.

Discussion

  • Stavros Macrakis

    Logged In: YES
    user_id=588346

    I spoke too soon about the "convenience" of COND.

    verbify(COND) and verbify(nounify(COND)) give %COND rather
    than MCOND as they should, so COND(a,b,c) doesn't get an
    error because it has nothing to do with IF/MCOND.

     
  • Stavros Macrakis

    Logged In: YES
    user_id=588346

    The semantics of noun/verb are pretty unclear.

    In the case of trig functions, verbs return floating-point
    results: (verbify('sin))(0) => 0.0; but not for elementary
    arithmetic: (verbify('"+"))(0,4) => 4.

    In the case of trig functions, nouns simplify: (nounify('sin))(%
    pi) => 0; but not for elementary arithmetic: (nounify('"+"))
    (4,5) => PLUS(4,5).

     
  • Stavros Macrakis

    Logged In: YES
    user_id=588346

    In general, the noun/verb forms for infix operators are
    screwed up:

    I was going to write up a detailed analysis, but it is too much
    of a mess. Here is a transcript showing some of the peculiar
    cases:

    (C17) ?print([">",verbify(">"),nounify(">")]);

    ((MLIST SIMP) &> MGREATERP %GREATERP)
    (D17) [>, ">", GREATERP]
    (C18) string(%);
    (D18) [">",?MGREATERP,GREATERP]
    (C19) is(nounify(">")=GREATERP);
    (D19) FALSE
    (C20) is(nounify(">")=greaterp);
    (D20) FALSE
    (C21) ?print(["+",verbify("+"),nounify("+")]);

    ((MLIST SIMP) &+ MPLUS %PLUS)
    (D21) [+, "+", PLUS]
    (C22) string(%);
    (D22) ["+",?MPLUS,PLUS]
    (C23) ["+"(a,b),'"+"(a,b),?MPLUS(a,b),PLUS(a,b)];
    (D23) [b + a, PLUS(a, b), b + a, PLUS(a, b)]
    (C24) map(op,%);
    (D24) [+, PLUS, +, PLUS]
    (C25) ?print(%);

    ((MLIST SIMP) &+ %PLUS &+ $PLUS)
    (D25) [+, PLUS, +, PLUS]
    (C26)

     
  • Robert Dodier

    Robert Dodier - 2004-11-25

    Logged In: YES
    user_id=501686

    Description of "apply_nouns" has been struck from
    doc/info/Simplification.texi.

     
  • Robert Dodier

    Robert Dodier - 2006-07-06
    • labels: --> Lisp Core
     

Log in to post a comment.