From: Ken Tilton
Subject: OT Why Am I doing this?
Date: 
Message-ID: <DjLTi.37$Aj.32@newsfe12.lga>
My Algebra model sees the world as either unary or binary, so 1+2+3 
cannot be (+ 1 2 3). Instead, I follow the associative thing and encode 
the infix as (+ (+ 1 2) 3).

Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (- (- 
42)?

Extra credit: which do you think is mathematically more honest?

I'll try googling sign+associative

tia,kzo

-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker

From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <RoLTi.39$Aj.22@newsfe12.lga>
Ken Tilton wrote:
> My Algebra model sees the world as either unary or binary, so 1+2+3 
> cannot be (+ 1 2 3). Instead, I follow the associative thing and encode 
> the infix as (+ (+ 1 2) 3).
> 
> Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (- (- 
> 42)?

Ah, we found a clue: -- (read "minus minus") is illegal as a standalone 
expression.... game over?

> I'll try googling sign+associative

no luck.

kt

-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker
From: Vagif Verdi
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <1193265076.433602.93380@e34g2000pro.googlegroups.com>
Kenny, your algebra web site says "Free download arrives: September 1,
2007"

Was that changed to September 1, 2008 ?
From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <6oQTi.2664$xV3.1858@newsfe12.lga>
Vagif Verdi wrote:
> Kenny, your algebra web site says "Free download arrives: September 1,
> 2007"
> 
> Was that changed to September 1, 2008 ?
> 

Actually, that would be par for the course, eh? I am /not/ laughing at 
the Stix folks, if you have been following that thread.

I have a rough alpha out to True Friends, and when it stabilizes I plan 
to roll out something to the general public, possibly even for sale for 
like $10* just to sort out the riffraff. December 1? Might even ship 
with the Stix fonts. :)

kzo

* The download is free, you just have to pay $10 to run it. 
PWUAHAHAHAHAHAHAHA. k

-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker
From: Mark Tarver
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <1193250469.137495.231510@q3g2000prf.googlegroups.com>
On 24 Oct, 18:30, Ken Tilton <···········@optonline.net> wrote:
> My Algebra model sees the world as either unary or binary, so 1+2+3
> cannot be (+ 1 2 3). Instead, I follow the associative thing and encode
> the infix as (+ (+ 1 2) 3).
>
> Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (- (-
> 42)?
>
> Extra credit: which do you think is mathematically more honest?
>
> I'll try googling sign+associative
>
> tia,kzo
>
> --http://www.theoryyalgebra.com/
>
> "Career highlights? I had two. I got an intentional walk
> from Sandy Koufax and I got out of a rundown against the Mets."."
>                                                    - Bob Uecker

>From memory.

Strictly speaking -42 represents the overloading of the minus
operator.  In ML, -4 gets you an error whereas 1-5 gets you ~4.  ML
thus uses a different sign for the unary vs the binary operator.

In Qi, -4 etc. is fine, but (- 4) gives you a closure because its
treated as a partial application of a binary function.

In Lisp -4 and (- 4) give -4.

How you should represent -x in your program is really a function of
your intent, but a reasonable view is that -x is just shorthand for (0
- x)  which is how I might deal with it myself.  If you follow this
line then you end up with a convention on the lines of Qi.

Mark
From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <SXMTi.2640$xV3.1547@newsfe12.lga>
Mark Tarver wrote:
> On 24 Oct, 18:30, Ken Tilton <···········@optonline.net> wrote:
> 
>>My Algebra model sees the world as either unary or binary, so 1+2+3
>>cannot be (+ 1 2 3). Instead, I follow the associative thing and encode
>>the infix as (+ (+ 1 2) 3).
>>
>>Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (- (-
>>42)?
>>
>>Extra credit: which do you think is mathematically more honest?
>>
>>I'll try googling sign+associative
>>
>>tia,kzo
>>
>>--http://www.theoryyalgebra.com/
>>
>>"Career highlights? I had two. I got an intentional walk
>>from Sandy Koufax and I got out of a rundown against the Mets."."
>>                                                   - Bob Uecker
> 
> 
>>From memory.
> 
> Strictly speaking -42 represents the overloading of the minus
> operator.  In ML, -4 gets you an error whereas 1-5 gets you ~4.  ML
> thus uses a different sign for the unary vs the binary operator.
> 
> In Qi, -4 etc. is fine, but (- 4) gives you a closure because its
> treated as a partial application of a binary function.
> 
> In Lisp -4 and (- 4) give -4.
> 
> How you should represent -x in your program is really a function of
> your intent, but a reasonable view is that -x is just shorthand for (0
> - x)  which is how I might deal with it myself.  If you follow this
> line then you end up with a convention on the lines of Qi.

But...but...my only question was what to do with --x! Well, lessee if I 
can extrapolate:

if -x is (- 0 x), then --x is (- 0 (- 0 x)) and my imagined alternative 
of ((- -) x) cannot even be translated to a subtraction with zero as the 
minuend, nice support for the clue that -- (read, "minus minus") is 
illegal standalone.

kt


-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker
From: Mark Tarver
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <1193258180.691319.95840@y27g2000pre.googlegroups.com>
On 24 Oct, 20:22, Ken Tilton <···········@optonline.net> wrote:
> Mark Tarver wrote:
> > On 24 Oct, 18:30, Ken Tilton <···········@optonline.net> wrote:
>
> >>My Algebra model sees the world as either unary or binary, so 1+2+3
> >>cannot be (+ 1 2 3). Instead, I follow the associative thing and encode
> >>the infix as (+ (+ 1 2) 3).
>
> >>Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (- (-
> >>42)?
>
> >>Extra credit: which do you think is mathematically more honest?
>
> >>I'll try googling sign+associative
>
> >>tia,kzo
>
> >>--http://www.theoryyalgebra.com/
>
> >>"Career highlights? I had two. I got an intentional walk
> >>from Sandy Koufax and I got out of a rundown against the Mets."."
> >>                                                   - Bob Uecker
>
> >>From memory.
>
> > Strictly speaking -42 represents the overloading of the minus
> > operator.  In ML, -4 gets you an error whereas 1-5 gets you ~4.  ML
> > thus uses a different sign for the unary vs the binary operator.
>
> > In Qi, -4 etc. is fine, but (- 4) gives you a closure because its
> > treated as a partial application of a binary function.
>
> > In Lisp -4 and (- 4) give -4.
>
> > How you should represent -x in your program is really a function of
> > your intent, but a reasonable view is that -x is just shorthand for (0
> > - x)  which is how I might deal with it myself.  If you follow this
> > line then you end up with a convention on the lines of Qi.
>
> But...but...my only question was what to do with --x! Well, lessee if I
> can extrapolate:
>
> if -x is (- 0 x), then --x is (- 0 (- 0 x)) and my imagined alternative
> of ((- -) x) cannot even be translated to a subtraction with zero as the
> minuend, nice support for the clue that -- (read, "minus minus") is
> illegal standalone.
>
> kt
>
> --http://www.theoryyalgebra.com/
>
> "Career highlights? I had two. I got an intentional walk
> from Sandy Koufax and I got out of a rundown against the Mets."."
>                                                    - Bob Uecker- Hide quoted text -
>
> - Show quoted text -

I think --7 makes perfect sense as 7 and evaluated by the equation
-x = 0 - x and typed in then 7 is the result.  In ML you can have
~(~7) which works out as 7.  Nothing wrong in that.

Lisp, and by contagion Qi, don't support --7 = 7.  Instead --7 comes
out as a symbol.  I expect that the Lisp designers saw little point in
catering for explicit double negatives which just take up more space
compared to writing the absolute value.  But -x is really just a
shorthand.

((- -) 7) doesn't really scan.  In Qi you'd get a type error with
this.

I think you should allow double negatives and not treat them as
outcasts.  Presumably in your algebra program, you maintain an
internal representation of the algebra problem as a list structure of
some kind in a canonical syntax (fully parened etc).  So you can
always have the computer maintain the longhand form internally whilst
giving the user the freedom to employ the conventional shorthands.

Mark
From: Leandro Rios
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <472092c2$0$1348$834e42db@reader.greatnowhere.com>
Ken Tilton escribi�:
> 
> 
> But...but...my only question was what to do with --x! Well, lessee if I 
> can extrapolate:
> 
> if -x is (- 0 x), then --x is (- 0 (- 0 x)) and my imagined alternative 
> of ((- -) x) cannot even be translated to a subtraction with zero as the 
> minuend, nice support for the clue that -- (read, "minus minus") is 
> illegal standalone.
> 
> kt
> 

What if we think that -x is (* -1 x)?  That way --x would be (* -1 (* -1 
x)) => x, which makes sense.

(defun unary-minus (x)
   (typecase x
     (function #'(lambda (y) (* -1 (funcall x y))))
     (t (* -1 x))))

CL-USER> (unary-minus 1)
-1

CL-USER> (unary-minus #'unary-minus)
#<CLOSURE (LAMBDA (Y)) {1003A7A709}>

CL-USER> (funcall (unary-minus #'unary-minus) 1)
1

CL-USER> (funcall (unary-minus #'unary-minus) 0.0)
0.0

CL-USER> (unary-minus 0.0)
-0.0

Is this what you want?

Leandro
From: Frank Goenninger DG1SBG
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <lztzofmx1t.fsf@pcsde001.de.goenninger.net>
Ken Tilton <···········@optonline.net> writes:

> Mark Tarver wrote:
>> On 24 Oct, 18:30, Ken Tilton <···········@optonline.net> wrote:
>>
>>>My Algebra model sees the world as either unary or binary, so 1+2+3
>>>cannot be (+ 1 2 3). Instead, I follow the associative thing and encode
>>>the infix as (+ (+ 1 2) 3).
>>>
>>>Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (- (-
>>>42)?
>>>
>>>Extra credit: which do you think is mathematically more honest?
>>>
>>>I'll try googling sign+associative
>>>
>>>tia,kzo
>>>
>>>--http://www.theoryyalgebra.com/
>>>
>>>"Career highlights? I had two. I got an intentional walk
>>>from Sandy Koufax and I got out of a rundown against the Mets."."
>>>                                                   - Bob Uecker
>>
>>
>>>From memory.
>>
>> Strictly speaking -42 represents the overloading of the minus
>> operator.  In ML, -4 gets you an error whereas 1-5 gets you ~4.  ML
>> thus uses a different sign for the unary vs the binary operator.
>>
>> In Qi, -4 etc. is fine, but (- 4) gives you a closure because its
>> treated as a partial application of a binary function.
>>
>> In Lisp -4 and (- 4) give -4.
>>
>> How you should represent -x in your program is really a function of
>> your intent, but a reasonable view is that -x is just shorthand for (0
>> - x)  which is how I might deal with it myself.  If you follow this
>> line then you end up with a convention on the lines of Qi.
>
> But...but...my only question was what to do with --x!

Hm -  I read your post as "How do we do  '- -42' ?" - And I tried

CL-USER 1 > (- -42)
42

which I interprete as operator minus applied to the number -42. Now,
what was you point, Kenny?

Frank

-- 

  Frank Goenninger

  frgo(at)mac(dot)com

  "Don't ask me! I haven't been reading comp.lang.lisp long enough to 
  really know ..."
From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <nC1Ui.17$Dx2.13@newsfe12.lga>
Frank Goenninger DG1SBG wrote:
> Ken Tilton <···········@optonline.net> writes:
> 
> 
>>Mark Tarver wrote:
>>
>>>On 24 Oct, 18:30, Ken Tilton <···········@optonline.net> wrote:
>>>
>>>
>>>>My Algebra model sees the world as either unary or binary, so 1+2+3
>>>>cannot be (+ 1 2 3). Instead, I follow the associative thing and encode
>>>>the infix as (+ (+ 1 2) 3).
>>>>
>>>>Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (- (-
>>>>42)?
>>>>
>>>>Extra credit: which do you think is mathematically more honest?
>>>>
>>>>I'll try googling sign+associative
>>>>
>>>>tia,kzo
>>>>
>>>>--http://www.theoryyalgebra.com/
>>>>
>>>>"Career highlights? I had two. I got an intentional walk
>>>
>>>>from Sandy Koufax and I got out of a rundown against the Mets."."
>>>
>>>>                                                  - Bob Uecker
>>>
>>>
>>>>From memory.
>>>
>>>Strictly speaking -42 represents the overloading of the minus
>>>operator.  In ML, -4 gets you an error whereas 1-5 gets you ~4.  ML
>>>thus uses a different sign for the unary vs the binary operator.
>>>
>>>In Qi, -4 etc. is fine, but (- 4) gives you a closure because its
>>>treated as a partial application of a binary function.
>>>
>>>In Lisp -4 and (- 4) give -4.
>>>
>>>How you should represent -x in your program is really a function of
>>>your intent, but a reasonable view is that -x is just shorthand for (0
>>>- x)  which is how I might deal with it myself.  If you follow this
>>>line then you end up with a convention on the lines of Qi.
>>
>>But...but...my only question was what to do with --x!
> 
> 
> Hm -  I read your post as "How do we do  '- -42' ?" - And I tried
> 
> CL-USER 1 > (- -42)
> 42
> 
> which I interprete as operator minus applied to the number -42. Now,
> what was you point, Kenny?

Completely lost, with all answers going in the wrong direction and being 
unresponsive.

xyz associates left to right, so the /data internal to my program/ which 
consists only of unary and binary operators looks like (* (* x y) z). I 
am using parenspeak merely to convey the tree structure.

But I have been structuring consecutive signs entered by the student 
differently: --x gets encoded internally (- (- x)).

I now realize how stupid am I. I retract the whole thread. Signs are 
unary operators, but for some reason (I'll ask for it in the next 
thread), I have elected to have a "signed" binary operator where the 
sign is the first operand and the signee is the second operand. Ewwwww!

I mean, the question still stands, but i think it has a new answer: I am 
  articially representing a unary operation as binary. The unary tree of 
chained signs would descend to the right: (- (- (+ (- 42)))), so even 
tho I have gone weird making + or - the first operand to a binary signed 
operation, the right descent should be preserved. Two minuses make a 
positve, but two wrongs etc etc.

I think this arose where I had to deal with early exercises in signed 
numbers such as: -1 * 2 * -3 * +4 * -5 and I wanted to collect signs by 
reordering using the commutative rule, with the -s and explicit +s being 
treated as factors, treating signs as products as someone suggested. 
Indeed, I did start out with signs as products, but decided that was a 
lie (especially as it created problems in coding). So maybe I simply 
erred by making only a partial fix, making a sign a different but still 
binary operator so I could (I thought) collect signs more easily. Mebbe 
I should have followed Tilton's Law* and been honest: it is a unary 
operator in math, it should be a unary op in my code.

Great, another massive refactoring. There goes the weekend. :)

kt

-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker
From: Chris Russell
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <1193333826.298098.279580@v3g2000hsg.googlegroups.com>
On 25 Oct, 15:19, Ken Tilton <···········@optonline.net> wrote:

> xyz associates left to right, so the /data internal to my program/ which
> consists only of unary and binary operators looks like (* (* x y) z). I
> am using parenspeak merely to convey the tree structure.
>
> But I have been structuring consecutive signs entered by the student
> differently: --x gets encoded internally (- (- x)).
>
> I now realize how stupid am I. I retract the whole thread. Signs are
> unary operators, but for some reason (I'll ask for it in the next
> thread), I have elected to have a "signed" binary operator where the
> sign is the first operand and the signee is the second operand. Ewwwww!

While you're refactoring, have you thought about stealing from formal
mathematics?
In ring and group theory - is always a unary, self-inversing, operator
and a-b is just considered as a convenient notation for a+(-b).
Similarly a/b is just shorthand for a*(b^-1). So a- -b = a+ --b= a+b
From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <5B4Ui.1412$yU7.635@newsfe12.lga>
Chris Russell wrote:
> On 25 Oct, 15:19, Ken Tilton <···········@optonline.net> wrote:
> 
> 
>>xyz associates left to right, so the /data internal to my program/ which
>>consists only of unary and binary operators looks like (* (* x y) z). I
>>am using parenspeak merely to convey the tree structure.
>>
>>But I have been structuring consecutive signs entered by the student
>>differently: --x gets encoded internally (- (- x)).
>>
>>I now realize how stupid am I. I retract the whole thread. Signs are
>>unary operators, but for some reason (I'll ask for it in the next
>>thread), I have elected to have a "signed" binary operator where the
>>sign is the first operand and the signee is the second operand. Ewwwww!
> 
> 
> While you're refactoring, have you thought about stealing from formal
> mathematics?
> In ring and group theory - is always a unary, self-inversing, operator
> and a-b is just considered as a convenient notation for a+(-b).

That is what I did in the C version and it was a disaster because my 
internal representation was then too far away from the external (model 
vs view) and keeping them straight ended up all over the code. So this 
time I actually have subtraction, since that is what the student sees. A 
big issue here is that this is an educational application and so the 
application has to talk to the user in detail about the math expressions 
-- cannot annotate 4-2 -> 2 as "here we add -2 to 4...".

kt

-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker
From: Chris Russell
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <1193355036.235361.99310@o38g2000hse.googlegroups.com>
On 25 Oct, 18:43, Ken Tilton <···········@optonline.net> wrote:
> Chris Russell wrote:
> > On 25 Oct, 15:19, Ken Tilton <···········@optonline.net> wrote:
>
> >>xyz associates left to right, so the /data internal to my program/ which
> >>consists only of unary and binary operators looks like (* (* x y) z). I
> >>am using parenspeak merely to convey the tree structure.
>
> >>But I have been structuring consecutive signs entered by the student
> >>differently: --x gets encoded internally (- (- x)).
>
> >>I now realize how stupid am I. I retract the whole thread. Signs are
> >>unary operators, but for some reason (I'll ask for it in the next
> >>thread), I have elected to have a "signed" binary operator where the
> >>sign is the first operand and the signee is the second operand. Ewwwww!
>
> > While you're refactoring, have you thought about stealing from formal
> > mathematics?
> > In ring and group theory - is always a unary, self-inversing, operator
> > and a-b is just considered as a convenient notation for a+(-b).
>
> That is what I did in the C version and it was a disaster because my
> internal representation was then too far away from the external (model
> vs view) and keeping them straight ended up all over the code. So this
> time I actually have subtraction, since that is what the student sees. A
> big issue here is that this is an educational application and so the
> application has to talk to the user in detail about the math expressions
> -- cannot annotate 4-2 -> 2 as "here we add -2 to 4...".
>
> kt
>
> --http://www.theoryyalgebra.com/
>
> "Career highlights? I had two. I got an intentional walk
> from Sandy Koufax and I got out of a rundown against the Mets."."
>                                                    - Bob Uecker

This can't be kept straight with a custom pretty printer that filters
all the output?
(format nil "We ~:[add~;subtract~] ~r ~:[to~;from~] blah." (minusp -5)
(abs -5) (minusp -5))
You're going to have to handle some of these cases this way anyway,
where the added/subtracted term is generated internally by your
simplifier, and conceptually organising your code as:

Parse Math input
----------
Normal Algebra
----------
Math/Natural language output

Seems cleaner, and like it would leave you with less edge cases to
worry about than threading the concept of special case negative
numbers (and everything else) throughout your app.
From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <tdaUi.412$Dx2.329@newsfe12.lga>
Chris Russell wrote:
> On 25 Oct, 18:43, Ken Tilton <···········@optonline.net> wrote:
> 
>>Chris Russell wrote:
>>
>>>On 25 Oct, 15:19, Ken Tilton <···········@optonline.net> wrote:
>>
>>>>xyz associates left to right, so the /data internal to my program/ which
>>>>consists only of unary and binary operators looks like (* (* x y) z). I
>>>>am using parenspeak merely to convey the tree structure.
>>
>>>>But I have been structuring consecutive signs entered by the student
>>>>differently: --x gets encoded internally (- (- x)).
>>
>>>>I now realize how stupid am I. I retract the whole thread. Signs are
>>>>unary operators, but for some reason (I'll ask for it in the next
>>>>thread), I have elected to have a "signed" binary operator where the
>>>>sign is the first operand and the signee is the second operand. Ewwwww!
>>
>>>While you're refactoring, have you thought about stealing from formal
>>>mathematics?
>>>In ring and group theory - is always a unary, self-inversing, operator
>>>and a-b is just considered as a convenient notation for a+(-b).
>>
>>That is what I did in the C version and it was a disaster because my
>>internal representation was then too far away from the external (model
>>vs view) and keeping them straight ended up all over the code. So this
>>time I actually have subtraction, since that is what the student sees. A
>>big issue here is that this is an educational application and so the
>>application has to talk to the user in detail about the math expressions
>>-- cannot annotate 4-2 -> 2 as "here we add -2 to 4...".
>>
>>kt
>>
>>--http://www.theoryyalgebra.com/
>>
>>"Career highlights? I had two. I got an intentional walk
>>from Sandy Koufax and I got out of a rundown against the Mets."."
>>                                                   - Bob Uecker
> 
> 
> This can't be kept straight with a custom pretty printer that filters
> all the output?
> (format nil "We ~:[add~;subtract~] ~r ~:[to~;from~] blah." (minusp -5)
> (abs -5) (minusp -5))

What if the problem is in fact 4 + -2? Now we are hinting, "What's the 
matter with you, can't you even subtract two from four? How did you get 
into Algebra?!"

> You're going to have to handle some of these cases this way anyway,
> where the added/subtracted term is generated internally by your
> simplifier, and conceptually organising your code as:
> 
> Parse Math input
> ----------
> Normal Algebra
> ----------
> Math/Natural language output
> 
> Seems cleaner, 

What part of "I spent eight years with that approach and it sucked" did 
you not understand? :)

> ...and like it would leave you with less edge cases to
> worry about than threading the concept of special case negative
> numbers (and everything else) throughout your app.
> 

We might not be understanding each other. I have no special cases, I 
parse their work sans interpretation or translation into isomorphic data 
structures, then do clever things with that data, with no exceptions 
where I have to check, was this a subtraction in its original form?

  This thread is about, gosh, what is the structure isomorphic to --4 in 
its mathematical abstractitude? We know 3-2-1 is (3-2)-1 mathematically, 
so ((- 3 2) 1) is a nice representation of that for the math engine. And 
I had gone with (- (- 4)) for --4 (which is right, it seems) but the 
thread started because I scared myself with a false commandment "Thine 
trees shalt always descend to the left". Rubbish, thine trees shalt 
always reflect what they are modelling. I confused myself with an 
exception to the above isomorphic claim by treating a sign as a binary 
operation on (1) a sign and (2) any valid math expression, which gets 
back to my policy this time around of staying isomorphic (and I have 
been contemplating making signs unary since this all started).

kt

-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker
From: Frank Goenninger DG1SBG
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <lzlk9qz9pz.fsf@de.goenninger.net>
Ken Tilton <···········@optonline.net> writes:

>  This thread is about, gosh, what is the structure isomorphic to --4
> in its mathematical abstractitude? We know 3-2-1 is (3-2)-1
> mathematically, so ((- 3 2) 1) is a nice representation of that for
> the math engine. And I had gone with (- (- 4)) for --4 (which is
> right, it seems) but the thread started because I scared myself with a
> false commandment "Thine trees shalt always descend to the
> left". Rubbish, thine trees shalt always reflect what they are
> modelling.

Right. So why not model 

x - -4

as 

"Variable x minus the number -4. This means substracting a negative
number. We calculate this as adding the absolute value of the number
-4, which equals to 4. So we get 

x + 4."

as it *should* be interpreted by the kids in any case? Translating
that into a data representation then would for me look like

(- x y) with y being bound to -4. This requires recognizing the token
-4 as a number.

Parsing 

-4^2

then is

"We see the power operator here. This binds stronger than the minus
sign. Hence we get 

- 4^2

which is the number -16."

Representing this is, of course, requires analyzing the token "-4^2"
as a two-step operation itself. So, it ends up into a the requirement
of having a two-phase analysis approach: Operators/operations and
tokens.

Of course you all know this yourself. So, I just wrote this to check
if I understood your problem and your coding approach correctly - I
will have to deal with something similar down my own project...

Frank

-- 

  Frank Goenninger

  frgo(at)mac(dot)com

  "Don't ask me! I haven't been reading comp.lang.lisp long enough to 
  really know ..."
From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <FCkUi.3277$uk.2311@newsfe21.lga>
Frank Goenninger DG1SBG wrote:
> Ken Tilton <···········@optonline.net> writes:
> 
> 
>> This thread is about, gosh, what is the structure isomorphic to --4
>>in its mathematical abstractitude? We know 3-2-1 is (3-2)-1
>>mathematically, so ((- 3 2) 1) is a nice representation of that for
>>the math engine. And I had gone with (- (- 4)) for --4 (which is
>>right, it seems) but the thread started because I scared myself with a
>>false commandment "Thine trees shalt always descend to the
>>left". Rubbish, thine trees shalt always reflect what they are
>>modelling.
> 
> 
> Right. So why not model 
> 
> x - -4
> 
> as 
> 
> "Variable x minus the number -4. This means substracting a negative
> number. We calculate this as adding the absolute value of the number
> -4, which equals to 4. So we get 
> 
> x + 4."

OK, so -4 is atomic, in the class <number> (using anglys to denote 
class). Super.

> 
> as it *should* be interpreted by the kids in any case? Translating
> that into a data representation then would for me look like
> 
> (- x y) with y being bound to -4. This requires recognizing the token
> -4 as a number.
> 
> Parsing 
> 
> -4^2
> 
> then is
> 
> "We see the power operator here. This binds stronger than the minus
> sign. Hence we get 
> 
> - 4^2
> 
> which is the number -16."

OK, so now the minus sign is separate from the four, and -4 is either 
(a) of class <minus-sign> a subclass of <sign> a subclass of <operator> 
and has  a slot <operands> populate by 4, a <number>, or (b) the 
silliness I have, the operator signed applied to two operands, a minus 
sign and a number 4.

What happened to atomic -4?

> 
> Representing this is, of course, requires analyzing the token "-4^2"
> as a two-step operation itself. So, it ends up into a the requirement
> of having a two-phase analysis approach: Operators/operations and
> token

So they hit - and I have a sign instance, then they hit 4 and the minus 
instance goes away and I have a number instance (value -4) and then they 
hit the ^ key to start an exponent and I suddenly have three instances 
(-, 4, and a ^ awaiting its exponent), then they hit backspace and 
whoops there it is, back to one instance, -4 <number>?

Methinks the components of -4 and -4^2 need to be the same in re the 
minus sign and the 4, God does not play change-class with the universe.

> 
> Of course you all know this yourself. So, I just wrote this to check
> if I understood your problem and your coding approach correctly - I
> will have to deal with something similar down my own project...

The code will tell you if you have taken a wrong turn, it will be hard 
to write.

kt

-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker
From: John Thingstad
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <op.t0s23vuyut4oq5@pandora.alfanett.no>
P� Fri, 26 Oct 2007 13:57:59 +0200, skrev Ken Tilton  
<···········@optonline.net>:

>
> Methinks the components of -4 and -4^2 need to be the same in re the  
> minus sign and the 4, God does not play change-class with the universe.
>

Are you using something as heavy as a class hirarchy to display tokens?
Surly the buildt in types are adequate. You could just transform (- 4) to  
-4 AFTER the tokeniser has run in a seperate thansform stage. You will  
probaly need some expand - collect stage later anyhow to simplify the  
expression anyway right. You are right that the expression should be read  
as (- 4) so -2^2 would evaluate to someting like (- (power 2 2)) but the  
you woud transform constant expressions into numbers right so you still  
end up with -4.

-- 
Sendt med Operas revolusjonerende e-postprogram: http://www.opera.com/mail/
From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <%omUi.272$4W7.230@newsfe19.lga>
John Thingstad wrote:
> P� Fri, 26 Oct 2007 13:57:59 +0200, skrev Ken Tilton  
> <···········@optonline.net>:
> 
>>
>> Methinks the components of -4 and -4^2 need to be the same in re the  
>> minus sign and the 4, God does not play change-class with the universe.
>>
> 
> Are you using something as heavy as a class hirarchy to display tokens?

...and 43 slots in a minus sign instance. About nine to support Cells, 
about eighteen for rendering... I do have to do clever things when they 
mouseover a minus sign, you know:

    http://www.theoryyalgebra.com/demo-23.html

> Surly the buildt in types are adequate.

Please don't call me Shirley.

> You could just transform (- 4) 
> to  -4 AFTER the tokeniser has run in a seperate thansform stage.

Ewww, separate stages, now we're doomed, internal once removed from 
view, trying to connect back -- I did mention I spent eight years on 
that approach, yes?

kt

-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker
From: John Thingstad
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <op.t0s6azxgut4oq5@pandora.alfanett.no>
P� Fri, 26 Oct 2007 15:59:58 +0200, skrev Ken Tilton  
<···········@optonline.net>:

>
>
> John Thingstad wrote:
>> P� Fri, 26 Oct 2007 13:57:59 +0200, skrev Ken Tilton   
>> <···········@optonline.net>:
>>
>>>
>>> Methinks the components of -4 and -4^2 need to be the same in re the   
>>> minus sign and the 4, God does not play change-class with the universe.
>>>
>>  Are you using something as heavy as a class hirarchy to display tokens?
>
> ...and 43 slots in a minus sign instance. About nine to support Cells,  
> about eighteen for rendering... I do have to do clever things when they  
> mouseover a minus sign, you know:
>
>     http://www.theoryyalgebra.com/demo-23.html
>
>> Surly the buildt in types are adequate.
>
> Please don't call me Shirley.
>
>> You could just transform (- 4) to  -4 AFTER the tokeniser has run in a  
>> seperate thansform stage.
>
> Ewww, separate stages, now we're doomed, internal once removed from  
> view, trying to connect back -- I did mention I spent eight years on  
> that approach, yes?
>
> kt
>

Well I am mostly just curious. I wrote a AI framework that constructed  
Frameworks, Deduction trees, First order logic and Horn logic some 6 years  
ago. The processing of Boolean algebra is not significatly different from  
regular algebra. It has a regular function interface, so I don't know how  
you connect it to the GUI.
I don't really know enough about your program as to assertain it's quality  
or structure. But as they say "There are many ways to skin a cat".

-- 
Sendt med Operas revolusjonerende e-postprogram: http://www.opera.com/mail/
From: Frank Goenninger DG1SBG
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <lzsl3xd8ij.fsf@de.goenninger.net>
Ken Tilton <···········@optonline.net> writes:

> Frank Goenninger DG1SBG wrote:
>> Ken Tilton <···········@optonline.net> writes:
>>
>>
>>> This thread is about, gosh, what is the structure isomorphic to --4
>>>in its mathematical abstractitude? We know 3-2-1 is (3-2)-1
>>>mathematically, so ((- 3 2) 1) is a nice representation of that for
>>>the math engine. And I had gone with (- (- 4)) for --4 (which is
>>>right, it seems) but the thread started because I scared myself with a
>>>false commandment "Thine trees shalt always descend to the
>>>left". Rubbish, thine trees shalt always reflect what they are
>>>modelling.
>>
>>
>> Right. So why not model 
>>
>> x - -4
>>
>> as 
>>
>> "Variable x minus the number -4. This means substracting a negative
>> number. We calculate this as adding the absolute value of the number
>> -4, which equals to 4. So we get 
>>
>> x + 4."
>
> OK, so -4 is atomic, in the class <number> (using anglys to denote
> class). Super.
>
>>
>> as it *should* be interpreted by the kids in any case? Translating
>> that into a data representation then would for me look like
>>
>> (- x y) with y being bound to -4. This requires recognizing the token
>> -4 as a number.
>>
>> Parsing 
>>
>> -4^2
>>
>> then is
>>
>> "We see the power operator here. This binds stronger than the minus
>> sign. Hence we get 
>>
>> - 4^2
>>
>> which is the number -16."
>
> OK, so now the minus sign is separate from the four, and -4 is either
> (a) of class <minus-sign> a subclass of <sign> a subclass of
> <operator> and has  a slot <operands> populate by 4, a <number>, or
> (b) the silliness I have, the operator signed applied to two operands,
> a minus sign and a number 4.
>
> What happened to atomic -4?

Hmm - maybe a data-flow driven change? ;-)

Let's see:

(defmd user-input ()
  (changed :cell :ephemeral)
  token-list 
  :token-list (c-in nil)
  :changed (c-in nil))

(defmd token ()
  token-content
  token-type

  :token-type (c? (analyze-token (^token-content)))
  :token-content (c-in nil))

(defobserver changed ((self user-input))
  (when new-value
     (^rescan)))

(defmethod rescan ((self user-input))

  ... parse user input from left to right. 
  During this process tokens are re-generated according to algebra
  rules. This is means deleting and creating tokens afresh - maybe
  even for every single change of user input. Result will be that each
  token is assigned a class depending on content analysis.
  "-4" will be seen as a number. etc.

  (values))

(defmethod analyze-token ((self token))
  
  ... analyze content and assign type/class value.

  (values))

> So they hit - and I have a sign instance, then they hit 4 and the
> minus instance goes away and I have a number instance (value -4) and
> then they hit the ^ key to start an exponent and I suddenly have three
> instances (-, 4, and a ^ awaiting its exponent), then they hit
> backspace and whoops there it is, back to one instance, -4 <number>?
>
> Methinks the components of -4 and -4^2 need to be the same in re the
> minus sign and the 4, God does not play change-class with the
> universe.

No? Who knows? Seriously: This is your requirement! Deal with it! ;-)

>
>>
>> Of course you all know this yourself. So, I just wrote this to check
>> if I understood your problem and your coding approach correctly - I
>> will have to deal with something similar down my own project...
>
> The code will tell you if you have taken a wrong turn, it will be hard
> to write.

My sketch above of course is just a showing off of the underlying idea
but as you're the Cells Master of The Universe this is, I know it, a
matter of hours for you ...  

>
> kt

Frank

-- 

  Frank Goenninger

  http://www.goenninger.net
  frgo(at)mac(dot)com

  "Don't ask me! I haven't been reading comp.lang.lisp long enough to 
  really know ..."
From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <47rUi.245$Tw.233@newsfe14.lga>
Frank Goenninger DG1SBG wrote:
> Ken Tilton <···········@optonline.net> writes:
> 
> 
>>Frank Goenninger DG1SBG wrote:
>>
>>>Ken Tilton <···········@optonline.net> writes:
>>>
>>>
>>>
>>>>This thread is about, gosh, what is the structure isomorphic to --4
>>>>in its mathematical abstractitude? We know 3-2-1 is (3-2)-1
>>>>mathematically, so ((- 3 2) 1) is a nice representation of that for
>>>>the math engine. And I had gone with (- (- 4)) for --4 (which is
>>>>right, it seems) but the thread started because I scared myself with a
>>>>false commandment "Thine trees shalt always descend to the
>>>>left". Rubbish, thine trees shalt always reflect what they are
>>>>modelling.
>>>
>>>
>>>Right. So why not model 
>>>
>>>x - -4
>>>
>>>as 
>>>
>>>"Variable x minus the number -4. This means substracting a negative
>>>number. We calculate this as adding the absolute value of the number
>>>-4, which equals to 4. So we get 
>>>
>>>x + 4."
>>
>>OK, so -4 is atomic, in the class <number> (using anglys to denote
>>class). Super.
>>
>>
>>>as it *should* be interpreted by the kids in any case? Translating
>>>that into a data representation then would for me look like
>>>
>>>(- x y) with y being bound to -4. This requires recognizing the token
>>>-4 as a number.
>>>
>>>Parsing 
>>>
>>>-4^2
>>>
>>>then is
>>>
>>>"We see the power operator here. This binds stronger than the minus
>>>sign. Hence we get 
>>>
>>>- 4^2
>>>
>>>which is the number -16."
>>
>>OK, so now the minus sign is separate from the four, and -4 is either
>>(a) of class <minus-sign> a subclass of <sign> a subclass of
>><operator> and has  a slot <operands> populate by 4, a <number>, or
>>(b) the silliness I have, the operator signed applied to two operands,
>>a minus sign and a number 4.
>>
>>What happened to atomic -4?
> 
> 
> Hmm - maybe a data-flow driven change? ;-)
> 
> Let's see:
> 
> (defmd user-input ()
>   (changed :cell :ephemeral)
>   token-list 
>   :token-list (c-in nil)
>   :changed (c-in nil))
> 
> (defmd token ()
>   token-content
>   token-type
> 
>   :token-type (c? (analyze-token (^token-content)))
>   :token-content (c-in nil))
> 
> (defobserver changed ((self user-input))
>   (when new-value
>      (^rescan)))
> 
> (defmethod rescan ((self user-input))
> 
>   ... parse user input from left to right. 
>   During this process tokens are re-generated according to algebra
>   rules. This is means deleting and creating tokens afresh - maybe
>   even for every single change of user input. Result will be that each
>   token is assigned a class depending on content analysis.
>   "-4" will be seen as a number. etc.
> 
>   (values))
> 
> (defmethod analyze-token ((self token))
>   
>   ... analyze content and assign type/class value.
> 
>   (values))
> 
> 
>>So they hit - and I have a sign instance, then they hit 4 and the
>>minus instance goes away and I have a number instance (value -4) and
>>then they hit the ^ key to start an exponent and I suddenly have three
>>instances (-, 4, and a ^ awaiting its exponent), then they hit
>>backspace and whoops there it is, back to one instance, -4 <number>?
>>
>>Methinks the components of -4 and -4^2 need to be the same in re the
>>minus sign and the 4, God does not play change-class with the
>>universe.
> 
> 
> No? Who knows? Seriously: This is your requirement! Deal with it! ;-)

No, if we started from -1*-2*-2 we need to let them mouse-over the - in 
the -4 in the next step and hilite that along with all the minuses in 
the prior step and say something brilliant about combining signs, and if 
they move the mouse over the four do the same with just the 1 2 and 2.


> 
> 
>>>Of course you all know this yourself. So, I just wrote this to check
>>>if I understood your problem and your coding approach correctly - I
>>>will have to deal with something similar down my own project...
>>
>>The code will tell you if you have taken a wrong turn, it will be hard
>>to write.
> 
> 
> My sketch above of course is just a showing off of the underlying idea
> but as you're the Cells Master of The Universe this is, I know it, a
> matter of hours for you ...  

Yes, if we wanted to play change-class with the universe, we would 
implement it in Cells. Actually, there is some evidence that the 
universe /is/ implemented in cells: gravity slows down time. The more 
data there is interacting, the longer it takes His CPU to propagate 
change. Time being merely an abstraction from change...

kt

-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker
From: Frank Goenninger DG1SBG
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <lzmyu5d5hj.fsf@de.goenninger.net>
Ken Tilton <···········@optonline.net> writes:

> Frank Goenninger DG1SBG wrote:
>> Ken Tilton <···········@optonline.net> writes:
>>
>>
>>>Frank Goenninger DG1SBG wrote:
>>>
>>>>Ken Tilton <···········@optonline.net> writes:
>>>>
>>>>
>>>>
>>>>>This thread is about, gosh, what is the structure isomorphic to --4
>>>>>in its mathematical abstractitude? We know 3-2-1 is (3-2)-1
>>>>>mathematically, so ((- 3 2) 1) is a nice representation of that for
>>>>>the math engine. And I had gone with (- (- 4)) for --4 (which is
>>>>>right, it seems) but the thread started because I scared myself with a
>>>>>false commandment "Thine trees shalt always descend to the
>>>>>left". Rubbish, thine trees shalt always reflect what they are
>>>>>modelling.
>>>>
>>>>
>>>> Right. So why not model 
>>>>
>>>>x - -4
>>>>
>>>> as 
>>>>
>>>>"Variable x minus the number -4. This means substracting a negative
>>>>number. We calculate this as adding the absolute value of the number
>>>> -4, which equals to 4. So we get 
>>>>
>>>>x + 4."
>>>
>>>OK, so -4 is atomic, in the class <number> (using anglys to denote
>>>class). Super.
>>>
>>>
>>>>as it *should* be interpreted by the kids in any case? Translating
>>>>that into a data representation then would for me look like
>>>>
>>>>(- x y) with y being bound to -4. This requires recognizing the token
>>>>-4 as a number.
>>>>
>>>> Parsing 
>>>>
>>>>-4^2
>>>>
>>>>then is
>>>>
>>>>"We see the power operator here. This binds stronger than the minus
>>>> sign. Hence we get 
>>>>
>>>>- 4^2
>>>>
>>>>which is the number -16."
>>>
>>>OK, so now the minus sign is separate from the four, and -4 is either
>>>(a) of class <minus-sign> a subclass of <sign> a subclass of
>>><operator> and has  a slot <operands> populate by 4, a <number>, or
>>>(b) the silliness I have, the operator signed applied to two operands,
>>>a minus sign and a number 4.
>>>
>>>What happened to atomic -4?
>>
>>
>> Hmm - maybe a data-flow driven change? ;-)
>>
>> Let's see:
>>
>> (defmd user-input ()
>>   (changed :cell :ephemeral)
>>   token-list   :token-list (c-in nil)
>>   :changed (c-in nil))
>>
>> (defmd token ()
>>   token-content
>>   token-type
>>
>>   :token-type (c? (analyze-token (^token-content)))
>>   :token-content (c-in nil))
>>
>> (defobserver changed ((self user-input))
>>   (when new-value
>>      (^rescan)))
>>
>> (defmethod rescan ((self user-input))
>>
>>   ... parse user input from left to right.   During this process
>> tokens are re-generated according to algebra
>>   rules. This is means deleting and creating tokens afresh - maybe
>>   even for every single change of user input. Result will be that each
>>   token is assigned a class depending on content analysis.
>>   "-4" will be seen as a number. etc.
>>
>>   (values))
>>
>> (defmethod analyze-token ((self token))
>>     ... analyze content and assign type/class value.
>>
>>   (values))
>>
>>
>>>So they hit - and I have a sign instance, then they hit 4 and the
>>>minus instance goes away and I have a number instance (value -4) and
>>>then they hit the ^ key to start an exponent and I suddenly have three
>>>instances (-, 4, and a ^ awaiting its exponent), then they hit
>>>backspace and whoops there it is, back to one instance, -4 <number>?
>>>
>>>Methinks the components of -4 and -4^2 need to be the same in re the
>>>minus sign and the 4, God does not play change-class with the
>>>universe.
>>
>>
>> No? Who knows? Seriously: This is your requirement! Deal with it! ;-)
>
> No, if we started from -1*-2*-2 we need to let them mouse-over the -
> in the -4 in the next step and hilite that along with all the minuses
> in the prior step and say something brilliant about combining signs,
> and if they move the mouse over the four do the same with just the 1 2
> and 2.

Then why not have generations of tokens. This really smells like an
old problem of mine:

instance1 and instance2 get combined into instance3. Well, easy
enough. But hey, we have to know how we arrived at instance3. So:
create a relation to the previous generation of instances:

instance1 / gen 1    -----
                         |
                       instance 3 / gen 2
                         |
instance2 / gen 1    -----

So on a mouse-over oon instance3 you can see where this comes
from. Gen 1 items are on line 1 in the display, Gen 2 items in line
2. 

And so you highlight instances 1 and 2 by traversing the
relations. 

I don't think you can get the functionality without keeping track
between transformations.

>> My sketch above of course is just a showing off of the underlying idea
>> but as you're the Cells Master of The Universe this is, I know it, a
>> matter of hours for you ...  
>
> Yes, if we wanted to play change-class with the universe, we would
> implement it in Cells. Actually, there is some evidence that the
> universe /is/ implemented in cells: gravity slows down time. The more
> data there is interacting, the longer it takes His CPU to propagate
> change. Time being merely an abstraction from change...

Hehe, yes, true.

Frank

-- 

  Frank Goenninger

  frgo(at)mac(dot)com

  "Don't ask me! I haven't been reading comp.lang.lisp long enough to 
  really know ..."
From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <0BsUi.259$Tw.239@newsfe14.lga>
Frank Goenninger DG1SBG wrote:
> I don't think you can get the functionality without keeping track
> between transformations.

Right, so -4 can never be atomic, because in the next generation I might 
need to point back to just the minus... is it time to bring up again the 
eight years I spent on version one?

kt

-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker
From: Frank Goenninger DG1SBG
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <lzir4sdf44.fsf@de.goenninger.net>
Ken Tilton <···········@optonline.net> writes:

> Frank Goenninger DG1SBG wrote:
>> I don't think you can get the functionality without keeping track
>> between transformations.
>
> Right, so -4 can never be atomic, because in the next generation I
> might need to point back to just the minus...

I'd consider the -4 atomic in the sense of a mathematical element of a
"term" but being itself a token consisting of token elements "-" and
"4". 

Now you have a fine-grained way of then linking/relating token
elements in generation n to token elememts in generation n-1. 

> is it time to bring up
> again the eight years I spent on version one?

Hehe - I said it before (the bit with "Deal with it" ;-). But no, I
don't think it's time to bring up that eight years again. I certainly
realize your requirement as stated is quite challenging but I imagine
the outlined Cells approach (even when having too much Cells and very
fine-grained dependency scheme between keystroke and semantic analysis
slows down user feedback) is not going to take eight years to
implement and to optimize.


-- 

  Frank Goenninger

  http://www.goenninger.net
  frgo(at)mac(dot)com

  "Don't ask me! I haven't been reading comp.lang.lisp long enough to 
  really know ..."
From: Kent M Pitman
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <uprz3sdmn.fsf@nhplace.com>
Mark Tarver <··········@ukonline.co.uk> writes:

> How you should represent -x in your program is really a function of
> your intent, but a reasonable view is that -x is just shorthand for (0
> - x)  which is how I might deal with it myself.  If you follow this
> line then you end up with a convention on the lines of Qi.

While I don't have a specific reference handy, I believe IEEE floating 
point dictates that negated x is not the same as subtracting x from 0.
In particular, -0.0 is not the same as 0 - 0.0.  

This isn't the per se reference, but it has a nice table at the bottom
which captures my understanding of at last the -0.0 issue:
  http://steve.hollasch.net/cgindex/coding/ieeefloat.html

Independent of IEEE, there's also an interesting table of identities
involving negative zeros at
  http://en.wikipedia.org/wiki/%E2%88%920_(number)#Properties_and_handling
So since algebra likes to preserve properties that would be true if the
variables were given values, I'd say the transformation from -x to (0 - x)
is not a very good one on abstract grounds. Unless you disagree that these
are good properties, in which case maybe you want to chime in on the wikipedia
page.
From: Kent M Pitman
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <u8x5s3twd.fsf@nhplace.com>
Ken Tilton <···········@optonline.net> writes:

> My Algebra model sees the world as either unary or binary, so 1+2+3
> cannot be (+ 1 2 3). Instead, I follow the associative thing and
> encode the infix as (+ (+ 1 2) 3).
> 
> Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (-
> (-
> 42)?

- and + are overloaded, not generic.

 (- x) 

is not the degenerate case of 

 (- x y)

In fact, it's not even shorthand for

 (- 0 x)

because of the issue that

 (- 0.0)

must return -0.0, not 0.0 (if a representation for -0.0 is available).

Consequently, the reason you encode --42 as (- (- 42)) is the same reason
you encode f(f(x)) as (f (f x)).

> Extra credit: which do you think is mathematically more honest?

--x is mathematically more honest as (- (- x)).

Now whether --3 is better as (- -3) or (- (- 3)), and whether -3 is better
as (- 3) or -3, that's harder to say.

> I'll try googling sign+associative

I'll just note that your choice of search keyword biases the answer.

Why not google for minus+overloaded or 
mathematicians+of+yesteryear+weren%27t+programmers and see if the
answer is the same.  The virtue of traditional math notation isn't
that it's good, it's that it's widely taught.
From: Kaz Kylheku
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <1193264428.189223.48320@e34g2000pro.googlegroups.com>
On Oct 24, 10:30 am, Ken Tilton <···········@optonline.net> wrote:
> Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (- (-
> 42)?

Because the parentheses balance?
From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <dpQTi.2665$xV3.2342@newsfe12.lga>
Kaz Kylheku wrote:
> On Oct 24, 10:30 am, Ken Tilton <···········@optonline.net> wrote:
> 
>>Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (- (-
>>42)?
> 
> 
> Because the parentheses balance?
> 

Sorry, that should have been ((- -) 42). Might be another message from 
God that I cannot even type the alternative.

kt

-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker
From: Christophe
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <1193318879.786008.185010@o38g2000hse.googlegroups.com>
On 24 oct, 19:30, Ken Tilton <···········@optonline.net> wrote:
> My Algebra model sees the world as either unary or binary, so 1+2+3
> cannot be (+ 1 2 3). Instead, I follow the associative thing and encode
> the infix as (+ (+ 1 2) 3).
>
> Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (- (-
> 42)?
>
> Extra credit: which do you think is mathematically more honest?
>
> I'll try googling sign+associative
>
> tia,kzo
>
> --http://www.theoryyalgebra.com/
>
> "Career highlights? I had two. I got an intentional walk
> from Sandy Koufax and I got out of a rundown against the Mets."."
>                                                    - Bob Uecker

Hello,

http://en.wikipedia.org/wiki/Polish_notation  :  just sentential
logical.


Best Regards.
From: .
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <47209be4$0$32564$4c368faf@roadrunner.com>
On Wed, 24 Oct 2007 13:30:53 -0400, Ken Tilton wrote:

> My Algebra model sees the world as either unary or binary, so 1+2+3
> cannot be (+ 1 2 3). Instead, I follow the associative thing and encode
> the infix as (+ (+ 1 2) 3).
> 
> Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (- (-
> 42)?
> 
> Extra credit: which do you think is mathematically more honest?
> 
> I'll try googling sign+associative
> 
> tia,kzo

Because if you did (--) you might as well do (---) and (----) and (-----) 
and you wouldn't be able to finish until you had a n-negation operator 
for every natural number n? 
From: John Thingstad
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <op.t0rk5femut4oq5@pandora.alfanett.no>
P� Wed, 24 Oct 2007 19:30:53 +0200, skrev Ken Tilton  
<···········@optonline.net>:

> My Algebra model sees the world as either unary or binary, so 1+2+3  
> cannot be (+ 1 2 3). Instead, I follow the associative thing and encode  
> the infix as (+ (+ 1 2) 3).
>
> Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (- (-  
> 42)?
>
> Extra credit: which do you think is mathematically more honest?
>
> I'll try googling sign+associative
>
> tia,kzo
>

Well the way I see it in math -4 is negative number.
It is not the operator unary - applied to 4.
Thus you need only the binary - operator for values.
You can of cource write -a but unary minus only really makes sense for  
variables.
Thus --4 is a error.
Mathematica sees it the same way.
When I write --4 it sais "-4 is not a variable with a value so it's value  
cannot be changed".

-- 
Sendt med Operas revolusjonerende e-postprogram: http://www.opera.com/mail/
From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <0b6Ui.1423$yU7.767@newsfe12.lga>
John Thingstad wrote:
> P� Wed, 24 Oct 2007 19:30:53 +0200, skrev Ken Tilton  
> <···········@optonline.net>:
> 
>> My Algebra model sees the world as either unary or binary, so 1+2+3  
>> cannot be (+ 1 2 3). Instead, I follow the associative thing and 
>> encode  the infix as (+ (+ 1 2) 3).
>>
>> Can anyone tell me why I am encoding --42 as (- (- 42)) instead of (- 
>> (-  42)?
>>
>> Extra credit: which do you think is mathematically more honest?
>>
>> I'll try googling sign+associative
>>
>> tia,kzo
>>
> 
> Well the way I see it in math -4 is negative number.

But -4^2 is -16, so...?

> It is not the operator unary - applied to 4.
> Thus you need only the binary - operator for values.
> You can of cource write -a but unary minus only really makes sense for  
> variables.
> Thus --4 is a error.

Checking one algebra book, you might be right, I see they have -(-4), 
which happens to support my having signed signs descend to the right.

> Mathematica sees it the same way.
> When I write --4 it sais "-4 is not a variable with a value so it's 
> value  cannot be changed".
> 

what does it say to -4^2 or however you write that?

kt

-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker
From: John Thingstad
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <op.t0rui7oeut4oq5@pandora.alfanett.no>
P� Thu, 25 Oct 2007 21:31:49 +0200, skrev Ken Tilton  
<···········@optonline.net>:

> Checking one algebra book, you might be right, I see they have -(-4),  
> which happens to support my having signed signs descend to the right.
>
>> Mathematica sees it the same way.
>> When I write --4 it sais "-4 is not a variable with a value so it's  
>> value  cannot be changed".
>>

err.. my bad. Mathematica has a operator -- defined as in C.

a = 3
--a
--> 2

-(-4) --> 4

>
> what does it say to -4^2 or however you write that?
>

Power operator binds stronger than unary minus.

-4^2 --> -16

-- 
Sendt med Operas revolusjonerende e-postprogram: http://www.opera.com/mail/
From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <Pd9Ui.6946$qt4.5753@newsfe12.lga>
John Thingstad wrote:
> P� Thu, 25 Oct 2007 21:31:49 +0200, skrev Ken Tilton  
> <···········@optonline.net>:
> 
>> Checking one algebra book, you might be right, I see they have -(-4),  
>> which happens to support my having signed signs descend to the right.
>>
>>> Mathematica sees it the same way.
>>> When I write --4 it sais "-4 is not a variable with a value so it's  
>>> value  cannot be changed".
>>>
> 
> err.. my bad. Mathematica has a operator -- defined as in C.
> 
> a = 3
> --a
> --> 2

The kids will love that. :)

> 
> -(-4) --> 4
> 
>>
>> what does it say to -4^2 or however you write that?
>>
> 
> Power operator binds stronger than unary minus.

I know. My point was, what happened to:

> Well the way I see it in math -4 is negative number.
> It is not the operator unary - applied to 4.

Does -4 start out as a negative number and then suddenly become a unary 
minus applied to 4 when the exponentiation operator comes along to vie 
for 4's attention?

btw, I myself am outraged that -4^2 -> 16, it implies there are no such 
things as negative numbers. But I bored everyone with that thread already.

kt

-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker
From: Martin Rubey
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <9q8x5rgjp3.fsf@aquin.mat.univie.ac.at>
Dear Kenny,

Just curious: did you ever consider to simply embed your program in a mature
CAS like axiom or Maxima, which both provide access to the underlying common
lisp?  (As far as I know, both can be used with more or less any common lisp
you like.)  I find it a bit strange to have yet another attempt to implement
mathematics in common lisp.

(axiom is in fact modified BSD, since I gather you dislike GPL.)

> Well the way I see it in math -4 is negative number.
> It is not the operator unary - applied to 4.

For what it's worth, I'd see "-", depending on context

* as part of the syntax denoting a negative number
* as a unary operator in a group (written additive)
* as a binary operator in such a group, but that's only for convenience.

Restricting oneself to one of these points of view will lead to trouble sooner
or later.  (Probably later, as many CAS show.)

Martin
From: Ken Tilton
Subject: Re: OT Why Am I doing this?
Date: 
Message-ID: <%e6Ui.1426$yU7.232@newsfe12.lga>
Martin Rubey wrote:
> Dear Kenny,
> 
> Just curious: did you ever consider to simply embed your program in a mature
> CAS like axiom or Maxima, which both provide access to the underlying common
> lisp?

Yes, and perhaps down the road I will find a way to leverage some 
existing engine, but recall that this is an intense educational 
application that goes way beyond other algebra tutors and needs to get 
its hand on all the transformations and operands as they sail about.

Note that obviously the algebra per se (at this level) is trivial, the 
hard part is all that other stuff to support the teaching.


>  (As far as I know, both can be used with more or less any common lisp
> you like.)  I find it a bit strange to have yet another attempt to implement
> mathematics in common lisp.

I am not, really. I will do a year or two of Algebra and then have 
enough money to open a bar, do what I really want, tend bar.

kt


-- 
http://www.theoryyalgebra.com/

"Career highlights? I had two. I got an intentional walk
from Sandy Koufax and I got out of a rundown against the Mets."."
                                                   - Bob Uecker