MathPiper Lesson 5: Tree pattern matching and transformation rules

20 views
Skip to first unread message

Ted Kosan

unread,
May 20, 2016, 1:35:40 AM5/20/16
to mathf...@googlegroups.com
This lesson covers the fundamentals of how a CAS that is based on
transformation rules works. When I first learned how a CAS like this
worked, I was amazed because I had never even suspected that a
computer language which was based on transformation rules was
possible. Programming with transformation rules caused me to rethink
everything I thought I knew about computer programming, and I think
this lesson will have the same effect for those who study it.

Here is the link to the lesson:

http://patternmatics.org/temp_1/mathfuture/lesson5/

There is no assignment for this lesson other than updating to
MathPiperIDE version .900 if you would like to experiment with the
above worksheet. My plan is for the next lesson to be devoted to
explaining how step-by-step elementary algebra equation solving works.

If anyone has questions, comments, or bug reports, please submit them
to the Math Future group.

Ted

Joseph Austin

unread,
May 20, 2016, 9:44:37 PM5/20/16
to mathf...@googlegroups.com

On May 20, 2016, at 1:35 AM, Ted Kosan <ted....@gmail.com> wrote:

If anyone has questions, comments, or bug reports, please submit them
to the Math Future group.

In MATCHING TREE PARTS USING PROPERTIES
I'm getting unexpected results for negative integers.

Consider the expression:

In> tree8 := '((1* -2 + x) == 3*(4 - -5/x))

the subexpression -5/x is interpreted as -(5/x) rather than (-5)/x

and pattern n_Integer highlights only the 2 and 5, not -2 and -5.

I would admit that programming languages, and even conventional math notation,  tend to obscure the differences among  subtraction, negation, and negative numbers,
but I would expect a CAS for math class to be more rigorous than a popular programming language.

Certainly, internal to the computer, there is as much a distinction between negative and positive integers as between lowercase and uppercase letters.

In a similar vein, 
I also tried Pattern: n_Negative?_Integer? 
the result is the error that Negative? is not a declared function (predicate).
Similarly, Natural? is not a declared predicate.

Agreed, the lesson did not say these functions were included,
but again, it's for "math".
The fundamental problem is that these are basically "primitive" properties in which terms other properties are defined.

Of course, it may be that these concepts can be defined and handled within MathPiper, and I just haven't come to the relevant parts of the lessons yet!


Joe Austin








Ted Kosan

unread,
May 20, 2016, 10:23:50 PM5/20/16
to mathf...@googlegroups.com
Joe wrote:

> I'm getting unexpected results for negative integers.
>
> Consider the expression:
>
> In> tree8 := '((1* -2 + x) == 3*(4 - -5/x))
>
> the subexpression -5/x is interpreted as -(5/x) rather than (-5)/x
>
> and pattern n_Integer highlights only the 2 and 5, not -2 and -5.
>
> I would admit that programming languages, and even conventional math
> notation, tend to obscure the differences among subtraction, negation, and
> negative numbers,
> but I would expect a CAS for math class to be more rigorous than a popular
> programming language.

Wolfram Alpha also appears to parse -5/x as -(5/x).

MathPiper patterns match on a combination of tree structure and
semantics. The typical way to match negative integers is to include
the unary - operator in the pattern:

ViewTreeParts('((1* -2 + x) == 3*(4 - -5/x)), Pattern:(- n_Integer?),
ArcsAutoHighlight:False, Scale:1.5, FontSize:20);



> I also tried Pattern: n_Negative?_Integer?
> the result is the error that Negative? is not a declared function
> (predicate).
> Similarly, Natural? is not a declared predicate.
>
> Agreed, the lesson did not say these functions were included,
> but again, it's for "math".
> The fundamental problem is that these are basically "primitive" properties
> in which terms other properties are defined.
>
> Of course, it may be that these concepts can be defined and handled within
> MathPiper, and I just haven't come to the relevant parts of the lessons yet!

A list of all the predicate procedures that are currently defined in
MathPiper can be found in the "Programming Procedures -> Predicates"
node in the MathPiperDocs plugin. Additional predicate procedures can
be defined as needed :-)

Ted

kirby urner

unread,
May 20, 2016, 10:50:55 PM5/20/16
to mathf...@googlegroups.com
On Fri, May 20, 2016 at 6:44 PM, Joseph Austin <drtec...@gmail.com> wrote:

On May 20, 2016, at 1:35 AM, Ted Kosan <ted....@gmail.com> wrote:

If anyone has questions, comments, or bug reports, please submit them
to the Math Future group.

In MATCHING TREE PARTS USING PROPERTIES
I'm getting unexpected results for negative integers.

Consider the expression:

In> tree8 := '((1* -2 + x) == 3*(4 - -5/x))

the subexpression -5/x is interpreted as -(5/x) rather than (-5)/x

and pattern n_Integer highlights only the 2 and 5, not -2 and -5.

I would admit that programming languages, and even conventional math notation,  tend to obscure the differences among  subtraction, negation, and negative numbers,

I'd interject to second your observation, that subtraction, negation and negative numbers get confused.

Is -3 the application of a unary operator to the positive number 3, or is -3 in itself the name of a number?

I recall from elementary school how we were taught to put the "minus sign" prefix in the upper left once negative numbers where introduced, then in more adult books that goes away.

The + sign doesn't do anything i.e +3 = 3 and +++++3 = 3.  But with the negative operator, one needs to count how many, as an odd number of negative signs with make a difference whereas an even number of them will not.

- - - 3 = - 3.

- - 3 = 3.

The division symbol is similar in the 2/3 may be read as an operation to be performed, or as the name of a number in canonical lowest terms. 1/1/1/1/2 is what number?  Again, an even or odd number of divisions makes the difference.

Kirby


Joseph Austin

unread,
May 21, 2016, 3:18:45 PM5/21/16
to mathf...@googlegroups.com

On May 20, 2016, at 10:23 PM, Ted Kosan <ted....@gmail.com> wrote:

Wolfram Alpha also appears to parse -5/x as -(5/x).

It's difficult to argue with "success", but I'm not in universal agreement with Wolfram.
I also understand that parsing infix operator expressions with general precedence and a mixture of left and right ordering is non-trivial;  I'm looking forward to seeing how you do it.

Since you are making a point of keeping "rationals" rational,
e.g. you define / with higher precedence than * and don't approximate with decimals,
I might have supposed you would also want to keep integers integral and not confound them with Naturals. :-)
(BTW, it seems that even so, a "rational" like 3/4 will be interpreted as division of integers, not as an atomic number.)

Where I'm headed with this is the hierarchy of numbers:
Naturals, Integers, Rationals, Reals, Complex, ???, and on to "units" numbers, Vectors, Tensors, etc.
I expect to have more to say about this;
I am just looking forward to being able to "say" it in MathPiper!

And besides numbers, we need to be able to talk about Groups.

Joe Austin







Ted Kosan

unread,
May 21, 2016, 6:15:49 PM5/21/16
to mathf...@googlegroups.com
foo

Ted Kosan

unread,
May 21, 2016, 6:18:25 PM5/21/16
to mathf...@googlegroups.com
Joe wrote:

> It's difficult to argue with "success", but I'm
> not in universal agreement with Wolfram.

Are you aware of a definitive interpretation in
mathematics for what the precedence rules are for
all of the arithmetic operators? My understanding
is there are different interpretations
(https://en.wikipedia.org/wiki/Order_of_operations).

In Patternatics I am thinking of putting in place
a student right to have all mathematical
expressions that are given to them in homework and
on tests to be provided in fully parenthesized
form to eliminate all chances of ambiguity.




> I also understand that parsing infix operator
> expressions with general precedence and a
> mixture of left and right ordering is non-trivial;
> I'm looking forward to seeing how you do it.

In MathPiper, the arities, precedences, and
associativities of all operators are configurable
using MathPiper code. The following section of the file
src/org/mathpiper/scripts4/a_initialization/stdopers/stdopers.mpw
is where these properties of the arithmetic
operators are defined in the MathPiper library:

%mathpiper

    Infix("+",70);
    OperatorSpacesSet("+", "Infix", " ", " ");
    
    Infix("-",70);
    OperatorSpacesSet("-", "Infix", " ", " ");
    RightPrecedenceSet("-",40);
    
    Infix("/",30);
    OperatorSpacesSet("/", "Infix", "", "");
    
    Infix("*",40);
    OperatorSpacesSet("*", "Infix", "", "");
    
    Infix("^",20);
    LeftPrecedenceSet("^",19); 
    RightAssociativeSet("^");
    OperatorSpacesSet("^", "Infix", "", "");
    
    Prefix("+",50);
    OperatorSpacesSet("+", "Prefix", " ", "");
    
    Prefix("-",50);
    OperatorSpacesSet("-", "Prefix", " ", "");
    RightPrecedenceSet("-",40);
    
%/mathpiper




> Since you are making a point of keeping
> "rationals" rational, e.g. you define / with
> higher precedence than * and don't approximate
> with decimals, I might have supposed you would
> also want to keep integers integral and not
> confound them with Naturals. :-) (BTW, it seems
> that even so, a "rational" like 3/4 will be
> interpreted as division of integers, not as an
> atomic number.)

The word "interpreted" you used here is the key to
understanding how a CAS which is based on
transformation rules works. When an expression
such as '((1* -2 + x) == 3*(4 - -5/x)) is parsed,
the ' "Hold" operator prevents it from being
evaluated. This means that the tree that is placed
into memory is a "dead" tree that does not have
any interpretation associated with it beyond the
structural relationships which exist between the
operators and their operands.

The interpretations that MathPiper provides for
operators and operands are defined in the global
transformation rules that are stored in the
rulebase. Evaluating a tree consists of
recursively applying these rules/interpretations
until the tree has been completely interpreted.

Most procedures in MathPiper, including the
"Integer?" procedure, have all of their arguments
evaluated before they receive them. This is why
the "Integer?" procedure will normally return
"True" when -2 is passed to it:

In> Integer?(-2)
Result: True


When evaluation of the "Integer?" procedure's
argument is prevented by using the ' "Hold"
operator, what is passed to this procedure is an
uninterpreted tree that it does not interpret as
being an integer:

In> Integer?( '(-2) )
Result: False


The structural difference between the evaluated
version of -2 and the unevaluated version of -2
can be seen by using the "Show TreeView",
"ViewList", or "UnparseLisp" procedures. Since
this is a simple tree, lets use "UnparseLisp".
Notice that the evaluated version of -2 returns a
number in atom form while the unevaluated version
returns a tree consisting of the "-" operator and
its operand "2":

// Evaluated.
In> UnparseLisp(-2)
Side Effects:
-2

// Unevaluated.
In> UnparseLisp( '(-2) )
Side Effects:
(- 2)


MathPiper has tracing procedures that can be used
to view the sequence of rules that are applied to
a tree while it is being evaluated. Lets use the
"TraceExcept" procedure to see if we can identify
the global transformation rule that transforms -2
from a dead tree into a number atom.

%mathpiper

TraceExcept("") -2;

%/mathpiper

    %mathpiper
      Result: -2
      
      Side Effects:
      
      Enter<**** user rulebase>{(-,  -2);
          Arg(arg1 -> 2);
      
          Enter<builtin>{(Number?, Number?(x));
              Arg(parameter1 -> 2);
          Leave<builtin>}(Number?(x) -> True,    Local variables: x -> 2, arg1 -> 2, );
          **** Rule in function (-) matched: Precedence: 55, Rule Type: org.mathpiper.lisp.rulebases.PatternRule, Arity: 1, Parameters: arg1<hold=false>, Predicates: (Pattern) Number?(x), True,     Variables: x,     Types: Variable: _; ,    Body: SubtractN(0, x)
      
          Enter<builtin>{(SubtractN, SubtractN(0,x));
              Arg(parameter1 -> 0);
              Arg(parameter2 -> 2);
          Leave<builtin>}(SubtractN(0,x) -> -2,    Local variables: x -> 2, arg1 -> 2, );
      Leave<**** user rulebase>}( -2 -> -2,    Local variables: x -> 2, arg1 -> 2, );
      
.   %/mathpiper_trace


The line in the above output that starts with
"**** Rule in function (-) matched: Precedence:
55" indicates that the global transformation rule
that performed the transformation is in the
section of the rulebase that holds the definitions
for the "-" operator. It also indicates that this rule
has precedence 55.


In the "MathPiperDocs" plugin, if the documentation
for the "-" operator is opened, and the "View
source code" link at the bottom of the page is
selected, a copy of the worksheet that holds the
global rule definitions for the "-" operator are
brought up in the editor. The following
transformation rule is the one that transforms the
dead tree (- 2) into the number atom -2:

%mathpiper

55 # (- (x_Number?)) <-- SubtractN(0,x);

%/mathpiper




> Where I'm headed with this is the hierarchy of
> numbers: Naturals, Integers, Rationals, Reals,
> Complex, ???, and on to "units" numbers, Vectors,
> Tensors, etc. I expect to have more to say about
> this; I am just looking forward to being able to
> "say" it in MathPiper!
> 
> And besides numbers, we need to be able to talk
> about Groups.

If you locate the documentation for the "Complex"
procedure in the "MathPiperDocs" plugin, and select
the "View source code" link that is at the bottom
of the page, the worksheet that defines the
transformation rules for complex numbers will be
brought up in the editor. These rules may give you
some ideas on how to handle the other mathematical
objects you listed.

Ted


kirby urner

unread,
May 21, 2016, 7:29:17 PM5/21/16
to mathf...@googlegroups.com
On Sat, May 21, 2016 at 3:18 PM, Ted Kosan <ted....@gmail.com> wrote:
Joe wrote:

> It's difficult to argue with "success", but I'm
> not in universal agreement with Wolfram.

Are you aware of a definitive interpretation in
mathematics for what the precedence rules are for
all of the arithmetic operators? My understanding
is there are different interpretations
(https://en.wikipedia.org/wiki/Order_of_operations).

In a language such as J, the successor to APL, we have so many operators that trying to maintain precedence by ordering is simply too much overhead. 

Precedence

Math traditionally gives multiplication precedence over addition. In math class (or a skill testing question from a cereal box contest), if you were asked what 2 + 3 * 4 was, you would know the answer was 14.

This is not too confusing if there are only a few functions and only a few levels of precedence (division | multiplication | addition and subtraction). But it gets awkward in languages such as C which have many functions and many levels of precedence.

With the large number of verbs in J it would have been difficult to define the precedence, let alone trying to remember it when reading or writing. Moreover, being able to name things means you would also have to figure out what to do with the sentence:

   2 plus 3 times 4

In a break with traditional math and in contrast to most other programming languages, J has no verb precedence. It will take you a little while to stop doing the multiplication first, but the overall simplification is worthwhile.

Remember: there is no verb precedence.

http://www.jsoftware.com/primer/precedence.htm

At that point a grand simplification is needed and order comes down to strict right to left processing (not left to right), though with some interesting grammatical twists. 

http://www.4dsolutions.net/ocn/Jlang.html

The language is crafted such that one may chain up a lot of verbs as a pipeline, and store that, but only put something "in the pipe" (an "argument" -- multi-dimensional array) when its time to actually run the process. 

Not a concept unique to J, just the many single-symbol operators make it pithy in the extreme.  A single line substitutes for what might be literally hundreds of lines in another language (just as Turing Complete as verbosity is not a consideration when it comes to Turing Completeness -- though it is when modeling human interactions, i.e. "taking too long" is a sign of creeping AI).

Kirby


Joseph Austin

unread,
May 21, 2016, 7:48:40 PM5/21/16
to mathf...@googlegroups.com

On May 21, 2016, at 6:18 PM, Ted Kosan <ted....@gmail.com> wrote:

Are you aware of a definitive interpretation in
mathematics for what the precedence rules are for
all of the arithmetic operators? My understanding
is there are different interpretations

I had quite a debate on that a while back, on interpretations of one of my granddaughters homework problems.
I agree with you, that there's no universal convention.

For computer purposes, we sometimes need to make a decision,
or sequentialize something that is not sequential in math,
such as order of addition of the sum of a set of numbers,
and then begin to believe that there's no other "right" way of doing it.

---
Right now, I'm thinking about how to add "unary" operators and "signs" to the system.
It occurs to me that we need a separate symbol for "sign" vs. "subtract",
e.g. $- for "negative" and $+ for "positive", and why not $/ for "reciprocal" while we are at it?

And I need a way to test an operator tree for number of arguments, 
to distinguish a binary operator from a unary operator from a tertiary operator such as "if" or "while",
then make substitutions and transformations dependent on that.

I'm still working my way thru Lesson 5, and your latest email, so maybe I just haven't gotten to that yet.

Joe Austin

Joseph Austin

unread,
May 22, 2016, 4:03:51 PM5/22/16
to mathf...@googlegroups.com

On May 21, 2016, at 7:29 PM, kirby urner <kirby...@gmail.com> wrote:

In a language such as J, the successor to APL, we have so many operators that trying to maintain precedence by ordering is simply too much overhead.  

Agreed.  Precedence is only necessary to disambiguate otherwise ambiguous notations, such as traditional infix-operator expressions with omitted parentheses.
Or more accurately, precedence is a "convention" to allow removing parentheses, as are other conventions intended to simplify the syntax of expressions by making common practice implicit.

Of course we must train new practitioners to use the "shortcuts" that professionals routinely use.

But might it be better to defer that until the "professional" level courses,
and teach the beginners using unambiguous, intuitive notations?

Relative to Ted's approach, if an aim of teaching Algebra is to train students to rearrange equations,
perhaps we should use trees rather than linear text to represent expressions.
And I would agree, if we must linearize, do so unambiguously, e.g. with full parenthesization.

Joe






Ted Kosan

unread,
May 23, 2016, 2:28:14 AM5/23/16
to mathf...@googlegroups.com
Joe wrote:

> Right now, I'm thinking about how to add "unary" operators and "signs" to
> the system.
> It occurs to me that we need a separate symbol for "sign" vs. "subtract",
> e.g. $- for "negative" and $+ for "positive", and why not $/ for
> "reciprocal" while we are at it?

This kind of experimenting is what Yacas (which MathPiper is forked
from) was specifically designed to support. The main difficulty is
developing a system which will enable people to create operators that
don't use the same symbols that other people use. The Yacas developers
already used most of the single character operators in the ASCII range
for the standard library, so we are mostly left with using operators
that are two or more characters long if we stick with ASCII.

MathPiper has Unicode support, so people can use Unicode characters
for operators. However, there is still a good chance that people will
use Unicode operator symbols that other people are also using.

I have thought about the possibility of giving MathPiper the ability
to use icons as operators. This would enable people to draw their own
custom operators, and we may be able to have them registered with the
MathPiper project to prevent conflicts. I think students of all ages
would learn quite a bit from creating their own custom operators and
then writing transformation rules for them.



> And I need a way to test an operator tree for number of arguments,
> to distinguish a binary operator from a unary operator from a tertiary
> operator such as "if" or "while",
> then make substitutions and transformations dependent on that.

The transformation rules already test for the number of arguments of
an operator as part of the pattern matching process :-)

Joseph Austin

unread,
May 23, 2016, 5:23:48 PM5/23/16
to mathf...@googlegroups.com

On May 23, 2016, at 2:28 AM, Ted Kosan <ted....@gmail.com> wrote:

I have thought about the possibility of giving MathPiper the ability
to use icons as operators. This would enable people to draw their own
custom operators, and we may be able to have them registered with the
MathPiper project to prevent conflicts. I think students of all ages
would learn quite a bit from creating their own custom operators and
then writing transformation rules for them.

I like the "icon" idea.
One of my other interests is music, and I designed a custom notehead font to allow creating a kind of musical "score" as text. I used the free system FontStruct, but it has some limitations.

So of course, one could design a custom font for the "private use" ranges of Unicode characters.
And distribute it, on the web at least, using @font-face.
I've not used it, but I've just discovered that there is software designed to create private characters:

The usual way of handling conflicting extensions of programming systems is local libraries,
Given that we are creating text transformation systems, it should not be difficult to add the capability to "translate" operator symbols of one library to another set of symbols in the event two libraries conflict.

One challenge we would  have is that different authors will prefer different symbols for the same mathematical operators.
For example, consider symbols for the exp, root, log, and trig functions. E.g.

But what I'd really like to have is a way to create and edit trees, graphs, and geometric figures.
Can Geogebra do that?


Joe

Joseph Austin

unread,
May 23, 2016, 5:37:34 PM5/23/16
to mathf...@googlegroups.com
Ted, I can see I have a lot to learn about MathPiper.
Do you expect to cover all these topics in the Lessons?
I suppose I should at least finish the lessons before diving deeper,
but it's nice to know what sorts of things are "down there."
Joe

> On May 21, 2016, at 6:18 PM, Ted Kosan <ted....@gmail.com> wrote:
>
<anip>

Ted Kosan

unread,
May 24, 2016, 11:56:42 AM5/24/16
to mathf...@googlegroups.com
Joe wrote:

> I can see I have a lot to learn about MathPiper.
> Do you expect to cover all these topics in the Lessons?

My primary goal for these lessons is to explain the fundamentals of
how step-by-step equation solving works. The information in the
lessons on how a transformation-rule based CAS works is the minimum
knowledge needed to accomplish this goal. However, after the lessons
have been completed I would be more than happy to help you learn how
MathPiper works at a deeper level.

Ted

kirby urner

unread,
May 24, 2016, 12:29:49 PM5/24/16
to mathf...@googlegroups.com

I've been thinking a lot about equation solving, operator precedence
and so on, thanks to this ongoing MathPiper thread.  Joe keeps
reminding me of the difference "time" makes and indeed in the delta
calculus we frequently see a "dt". 

Yet Euclidean geometry as taught in K-12 is so distinctly time-free as
a topic.  Those perpendicular bisectors just don't need any dt dimension.

Adding more movement (animation) is where vectors come in, though
again, mathematically speaking, no time dimension need enter in with
them, either.  I've suggested a ray-tracer (such as POV-ray) which
handles perspective, as a great tool for mastering "still life" geometry
(stereographic maybe, but not moving).  Then change the content just
a little and render a next frame, change a little, next frame and so on,
and voila, you've got a movie.  Showing a figure spinning on an axis
is a logical first movie to make.  Translating and resizing (scaling)
also figure in, as the action develops.

I did not go to the code school (<guild />) this Monday, as has been
my wont. Per a blog post of this morning, I attended to other business
while recovering from a steep mountain terrain (Mountain tribe business). 

These blogs are more on-line journals that account for things that I'm
working on.  Lots of the 4D stuff is chronicled there.  The code school
is where I've been doing my CAS / MathPiper homework most concertedly,
while sharing with other geeks present.  I went to Portland State instead,
the mothership from whence the code school is sourced.

Physics is a related / overlapping namespace.  "Pure math" gets a long
way with no time dimension whatsoever.  As a philo guy, I'd attribute that
to Neoplatonism as an influence but lay readers might not know what
that means. 

We think of the icosahedron (see MAA logo) as eternal, meaning Platonic
meaning well nigh immortal.  Even without humans to imagine it, the
Platonics exist forever and ever, we think.  Where?  In some Platonic
Realm of course.  Language boils down to tautologies at some point.

With the bitcoin model, you have these one-way functions that hash
strings to give a unique fingerprint.  Altering the string even just a
little will change the sig a whole lot i.e. butterfly effects matter and
you could say we're in a branch of Chaos Math (fractals a denizen
of this World). 

So all these CPUs and GPUs scream through a space by trial and
error, hoping to reverse-solve a simple hash.  The system calibrates
the space of the answers (the possible answer key) to force a 10
minute solution on average, if that makes sense (I'd think adding
a bit would double the time so how does one do a merely linear
adjustment here again?).

That's a sense of "solve" which equations will not short cut, though
algorithms that search efficiently at least avoid testing the same wrong
answer one might think (maybe not?).  Not all problem solving techniques
get around "brute force" at some level.  Even mathematical proofs
will resort to such methods.

Where mathematics meets physics is it takes real energy to run
those bitcoin miners.  New currency goes to those identities entitled
by the solver to receive an apportionment of the bitcoin payout.   Why
would people have any motivation to run bitcoin miners, advancing the
blockchain forward, if it weren't for the payoff?  When the new currency
stops coming in, a fee-for-service is tacked on (that's already a feature).

That's just how bitcoin works whereas the blockchain technology in
general is more about creating a cheat-proof transaction system for
whatever purpose.  Bitcoin is a special case implementation of the
blockchain technology.

Kirby

kirby urner

unread,
May 24, 2016, 12:47:19 PM5/24/16
to mathf...@googlegroups.com
On Tue, May 24, 2016 at 9:29 AM, kirby urner <kirby...@gmail.com> wrote:
 
With the bitcoin model, you have these one-way functions that hash
strings to give a unique fingerprint.  Altering the string even just a
little will change the sig a whole lot i.e. butterfly effects matter and
you could say we're in a branch of Chaos Math (fractals a denizen
of this World). 

So all these CPUs and GPUs scream through a space by trial and
error, hoping to reverse-solve a simple hash.  The system calibrates
the space of the answers (the possible answer key) to force a 10
minute solution on average, if that makes sense (I'd think adding
a bit would double the time so how does one do a merely linear
adjustment here again?).

To answer my own question, one way is to just let the blocks grow
bigger, in terms of how many transactions they contain.  Imagine letting
the solution time drop to mere seconds, given the computing power out
there, but taking nine minutes and thirty seconds to fill a block, then
stamping it with the hash problem and getting the winner by some
millisecond stopwatch.

The first bit miner to get the hash problem gets to commit that block
to the chain with its signature.  Other images will update accordingly
but might compete as occasionally other machines win the contest
at just about the same time.  This is where "forking occurs" and the
solution is to simply wait, as the fork with the longest chain emerges
quite quickly, in two or three iterations, at which point the bags along
the shorter forks get emptied, those transactions returning to the pool,
ready for re-bagging.

Until you know for sure your transaction has made it to the blockchain
(a growing chain of bags, crytographically sewn together) as a part
of a solved and agreed upon block, it's a security risk to do more
transactions highly dependent on the order.  Some of your moves
may not make it to the stack in time rendering proposed transactions
invalid. 

Running too far ahead into the future involves making increasingly risky
assumptions about what gets honored in what order.  Scams occur when
"time dependency" can be gamed in certain ways, and what the blockchain
makes difficult is precisely this control over the narrative to that micro-
degree.  There's a lot of chance involved, by design.  Like in ordinary
gambling.  All transactions in a given block have that block's shared time
stamp, and after a few generations (each about 10 minutes long), history
advances in a way the servers can verify.  Having an agreed upon shared
history that's incorruptible without detection is what the blockchain is all
about.

Kirby


 


Joseph Austin

unread,
May 24, 2016, 8:46:24 PM5/24/16
to mathf...@googlegroups.com
OK.
When I learned algebra in math, we did everything by performing the same "operation" on both sides of an equation,
per the axioms.
When I learned algebra again in physics, we took a "short cut" and just moved stuff from one side to the other,
but "going thru the looking glass" as it were meant we had to flip signs and reciprocals.
I'm assuming that now you are going to show us how to do it with tree rearranging.

What I'm nervous about is that a "tree" is being represented as a "string",
which requires some kind of convention to identify the "root" and the order of the leaves,
which is a very iffy convention if you have to mix operators with different numbers of operands and order of evaluation.

And the semantics seems to be getting lost in a lot of obscure and unfamiliar syntax,
and I'm suspicious it's even a bit inconsistent.

On top of which, there seems to be an ambiguity between notation for "use" and "mention",
and it's not always clear which is which.
We have:
* variables and operators in the original formula understood as names (mention)
* underscore_variables representing positions or types in rules for purpose of matching (meta-mention?)
* variables and operators understood as representation of values to be evaluated (use).

As I recall, LISP/SCHEME had an "eval" operation, and one might need to explicitly call it to get an evaluation.
I'm thinking perhaps ALL "evaluations" ought to be explicit and specify whether the "evaluation" being performed is
symbolic arrangement and substitution or numerical calculation.
By moving the evaluation into explicit functions, you could perhaps eliminate the apostrophe-"Hold" notation
and avoid some confusion.

Also, could we insist that all "tree" representations were fully parenthesized and "normalized", and that this form would be the result of performing an explicit "Parse" operation (which might at first just be "magic" as far as the student is concerned)
which would apply all the standard math conventions for precedence and order of evaluation.
And BTW, "Parse" would presumably also tag each token with it's type, e.g. operator or number or variable, and which kind if known or knowable. [Then each "atom" might be a (type,name,value) triple.] But perhaps I'm getting ahead of myself.

But don't we at least need a clear break between a conventional "formula" and a "tree" representation of that formula?
I'll go thru the lesson again, but I didn't recall that break was explicit or complete.

What I'm expecting to see are "rules" of the form:
"find this tree and turn it into that tree",
or more generally, "find these subtrees and turn them into those subtrees".

Now I realize there is a challenge to describing "this tree" and "that tree".

I know in principle how to do it in LISP, i.e. operationally via recursive functions,
but that approach IMHO is totally non-intuitive and obscures more than it illuminates.
I want to see something that looks like pictures of two trees!

Which brings us back to the representation of trees and the convention for interpretation of those representations.

Joe
> --
> You received this message because you are subscribed to the Google Groups "MathFuture" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to mathfuture+...@googlegroups.com.
> To post to this group, send email to mathf...@googlegroups.com.
> Visit this group at https://groups.google.com/group/mathfuture.
> For more options, visit https://groups.google.com/d/optout.

Ted Kosan

unread,
May 25, 2016, 4:35:38 AM5/25/16
to mathf...@googlegroups.com
Joe wrote:

> When I learned algebra in math, we did everything by performing the same "operation" on both sides of an equation,
> per the axioms.
> When I learned algebra again in physics, we took a "short cut" and just moved stuff from one side to the other,
> but "going thru the looking glass" as it were meant we had to flip signs and reciprocals.
> I'm assuming that now you are going to show us how to do it with tree rearranging.

What the AI researchers (who discovered the techniques I am going to explain in the next lesson) found out is that there are the laws of elementary algebra which everyone is taught, and then there are the rules and meta-level rules of elementary algebra which no one is taught because almost nobody knows about them.

We will be doing tree manipulations in the next lesson. However, it is knowing which rules to apply to which part of a tree at each step (and why) when solving an equation that is the critical information that the AI researchers discovered.




> What I'm nervous about is that a "tree" is being represented as a "string",
> which requires some kind of convention to identify the "root" and the order of the leaves,
> which is a very iffy convention if you have to mix operators with different numbers of operands and order of evaluation.

This ambiguous string representation problem should make all people who teach mathematics nervous because actual math needs to be done on an unambiguous representation such as a tree, but most math is taught using strings. What is even worse is most students are never told that the string form of mathematical expressions are just shorthand for trees. I think a significant part of the problem that numerous people have with learning mathematics is due to the fact that it is taught using ambiguous strings.

The way I plan to fix this problem in Patternmatics is to always make the fully parenthesized string form version or the tree version of any mathematical expression available whenever needed.




> And the semantics seems to be getting lost in a lot of obscure and unfamiliar syntax,
> and I'm suspicious it's even a bit inconsistent.

MathPiper is a term rewriting system, and more information about these systems can be found at the following websites:

https://en.wikipedia.org/wiki/Rewriting#Term_rewriting_systems

http://mathworld.wolfram.com/TermRewritingSystem.html





> On top of which, there seems to be an ambiguity between notation for "use" and "mention",
> and it's not always clear which is which.
> We have:
> * variables and operators in the original formula understood as names (mention)
> * underscore_variables representing positions or types in rules for purpose of matching (meta-mention?)
> * variables and operators  understood as representation of  values to be evaluated (use).

Ambiguity between notation for "use" and "mention" is indeed a problem for languages such as MathPiper and Lisp that use the same language for working with object-level expressions and meta-level expressions. Systems that use different languages at the meta-level and the object level don't have this ambiguity problem. However, a drawback of two-language systems like this is needing to learn two programming languages instead of just one to use them.

For educational purposes I have decided that using a single language and then trying hard to differentiate meta-level expressions from object level expressions is the way to go. This is why I created the "ObjectToMeta" and "MetaToObject" procedures:

In> objectLevel := '(y == m*x + b)
Result: y == m*x + b

In> metaLevel := ObjectToMeta(objectLevel)
Result: _y ==$ _m *$ _x +$ _b

In> MetaToObject(metaLevel)
Result: y == m*x + b




> As I recall, LISP/SCHEME had an "eval" operation, and one might need to explicitly call it to get an evaluation.
> I'm thinking perhaps ALL "evaluations" ought to be explicit and specify whether the "evaluation" being performed is
> symbolic arrangement and substitution or numerical calculation.
> By moving the evaluation into explicit functions, you could perhaps eliminate the apostrophe-"Hold" notation
> and avoid some confusion.

I think the need to use "Hold" notation can be reduced by placing evaluations into functions when feasible, and I have been thinking about moving MathPiper in this direction for a number of years now. The /: and /:: local rules operators would be very useful for localizing evaluations.




> Also, could we insist that all "tree" representations were fully parenthesized and "normalized",
> and that this form would be the result of performing an explicit "Parse" operation (which might
> at first just be "magic" as far as the student is concerned)

For very young students I think starting with trees and working only with trees for a while may be a good idea. Eventually one can show them that a tree can be unparsed into numerous forms of strings:

In> tree := '(1 + 2*3/4)
Result: 1 + 2*3/4

In> UnparseMathPiper(tree)
Result: "1 + 2*3/4"


In> UnparseLisp(tree)
Result: 1 + 2*3/4
Side Effects:
(+
   1
   (*
      2
      (/
         3
         4)))


In> UnparseMath2D(tree)
Result: True
Side Effects:

        3
1 + 2 * -
        4



In> UnparseLatex(tree)
Result: "$1 + 2 * \frac{3}{4} $"


After the students have played with unparsing trees for a while, they can then be shown how to parse strings back into trees.




> And BTW, "Parse" would presumably also tag each token with it's type, e.g. operator or
> number or variable, and which kind if known or knowable.  [Then each "atom" might be
> a (type,name,value) triple.]  But perhaps I'm getting ahead of myself.

Have you programmed in Java at all? You might find looking through the Java source code of MathPiper's implementation to be interesting.




> But don't we at least need a clear break between a conventional "formula" and a
> "tree" representation of that formula?
> I'll go thru the lesson again, but I didn't recall that break was explicit or complete.

Can you explain in more detail what you mean by a clear break between a conventional formula and a tree representation of that formula?




> What I'm expecting to see are "rules" of the form:
> "find this tree and turn it into that tree",
> or more generally, "find these subtrees and turn them into those subtrees".
>
> Now I realize there is a challenge to describing "this tree" and "that tree".

Describing "these subtrees" is what the "pattern" part of a MathPiper transformation rule does, and describing "that tree" is what the "replacement_tree" part of the rule does:

pattern <- replacement_tree




> I know in principle how to do it in LISP, i.e. operationally via recursive functions,
> but that approach IMHO is totally non-intuitive and obscures more than it illuminates.

In MathPiper, the logic that tries to match transformation rules to subtrees in an expression is built into the interpreter.




> I want to see something that looks like pictures of two trees!

Okay, I will give you a preview of the next lesson because it will be full of trees :-)

The following video shows an earlier version of the "Manipulate" procedure I have been working on, but it should be close enough to the current version of "Manipulate" to understand how to use it:

https://www.youtube.com/edit?o=U&video_id=kYtsQ_PczlY


The following code will launch the tree manipulation application (Note: the "Autostep" button will identify the next step to take if you get stuck at any step):

In> Manipulate('(-20 == -4*x - 6*x))



Running the following code show all of the steps that need to be taken to solve the given equation:

Show(StepsView(SolveSteps('(-20 == -4*_x - 6*_x), _x), ShowTree:True))

Currently the "what" of each step is provided but not the "why" because I am still working on the "why" explanations.

Ted

Joseph Austin

unread,
May 25, 2016, 8:37:45 PM5/25/16
to mathf...@googlegroups.com

On May 25, 2016, at 4:35 AM, Ted Kosan <ted....@gmail.com> wrote:

Can you explain in more detail what you mean by a clear break between a conventional formula and a tree representation of that formula?

A tree representation would be syntactically or visually discernible as a tree.
i.e., the hierarchy of nodes would be explicitly represented, not just conventionally understood.
and would be a different "type" of expression from a "formula".

Perhaps an analogy would be notations for designating numbers in different bases, using distinctive prefixes or suffixes.

For example, using your example:
conventional formula:
formula := "1 + 2*3/4"

tree representation:
tree := "
(+
   1
   (*
      2
      (/
         3
         4)))
"

Or consider the quadratic equation formula:
linear formula:
quadFormula := "(-b+(b^2-4*a*c)^(1/2))/(2*a)"

tree representation (an attempt inspired by your convention, which could also be drawn at graphic tree).
quadTree := "
/
.+
..-
...b
..^
...-
....^
.....b
....*
.....4
.....*
......a
......c
.../
....1
....2
.*
..2
..a
"

I have included ... to indicate indent level, which makes parens unnecessary.
In actual syntax, the dots would be replaced by tabs.
Alternatively, a fully-parenthesized form of the formula would also be a "tree representation".

BTW, I would advocate for a "reciprocal" notation /2 == "1/2", analogous to "-2" for signed number "0-2".
which could simplify the square root expression.
But I'd also like to see explicit binary operators for root and log (the inverses of ^ ).
Of course we do have a symbol for root but it's not available on most keyboards or supported in most programming languages.
   
----
If I understand where you are going with this, I'm in agreement with the approach.
I'm just suggesting that we maintain a distinction between "algebra" and "arithmetic".
The "arithmetic" phase includes substitution of values for variables and arithmetic evaluation of expressions.
The "algebra" phase stops once the formula tree is transformed to isolate the unknown,
or, in the case of a proof, reduced to an identity.

Another area often lacking is math instruction is what is commonly called "word problems",
which I understand to include the task of converting a statement of quantitative relationships into a formula.
This involves the process of representing quantities with variables and functional relationships with operators,
and also includes choice of units of measurement and understanding of scaling, i.e. the consequence of making one measurement in inches and another in feet or centimeters.
I believe that, if "solving word problems" where treated as including formula creation and algebraic formula manipulation,
not just arithmetic, (a) students might actually learn to solve them and (b) the "I never use algebra" lament would disappear.
---
I've finished Lesson 5; looking forward to diving in to your preview.



Joseph Austin

unread,
May 25, 2016, 8:48:17 PM5/25/16
to mathf...@googlegroups.com

On May 25, 2016, at 4:35 AM, Ted Kosan <ted....@gmail.com> wrote:

Have you programmed in Java at all? You might find looking through the Java source code of MathPiper's implementation to be interesting.

I was educated and later worked in predominantly IBM, then Microsoft environments.

I came to Unix, Java, etc. late in my career.
but I have actually written a significant Java program, and also a Javascript/HTML Canvas program,
(they produce an alternative form of music notation that prints as text or displays as a webpage).

I'd be interested to see the source code,
but more interested to see what I could do with MathPiper.

Joe


Joseph Austin

unread,
May 26, 2016, 12:50:22 PM5/26/16
to mathf...@googlegroups.com

On May 25, 2016, at 4:35 AM, Ted Kosan <ted....@gmail.com> wrote:

The following video shows an earlier version of the "Manipulate" procedure I have been working on, but it should be close enough to the current version of "Manipulate" to understand how to use it:

https://www.youtube.com/edit?o=U&video_id=kYtsQ_PczlY

Link broken? YouTube couldn't find the video.

Joe

Ted Kosan

unread,
May 26, 2016, 12:55:34 PM5/26/16
to mathf...@googlegroups.com
Joe,

Try this link:
Ted



Joseph Austin

unread,
May 26, 2016, 5:59:46 PM5/26/16
to mathf...@googlegroups.com

On May 26, 2016, at 12:55 PM, Ted Kosan <ted....@gmail.com> wrote:

Joe,

Try this link:
Ted

OK, that one works better, but I'm getting no audio on my mac.

Some questions:

1. In the formula
In> Manipulate('(-20 == -4*x - 6*x))

I would have expected the "-4" to be parsed as a negative coefficient 
instead of as unary minus of the product.
Of course, they evaluate to the same thing.

2. In  Manipulate, rule 11:
q_  * q_ + q_ <-- (r + 1) * q

Shouldn't it have an r_ in the LHS, as:
r_  * q_ + q_ <-- (r + 1) * q

3. In general, I'm not sure why there are not underscore variables  q_, r_ etc. on all the RHS of the Manipulate rules (as for example, on Rule 17 Distribute).
Aren't all the RHS terms also trees?

4. The significance of the color code in the Manipulate rules is not clear.
I gather that the blue represents operators, or tree roots.
But what is the significance of the yellow?

Comments:
5. I recognize rules 7 and 8 as the "physics algebra" rules,
that take the place of the axiom-based operations on "both sides".

6a. I can see that you have introduced additional rules to handle multiple occurrences of the unknown. I'm assuming these are sufficient for formulas linear in the unknowns, but not for non-linear, as there are no rules for powers, roots, and logs. Perhaps not even ratio and proportion: x/y = u/v ?
(In my classes, I had never gone beyond one linear occurrence of the unknown.)

6b.  It takes some contortions to un-distribute "ax - bx" to (a-b)x.
I was able to do so by converting to (ax + (-b)x),
but I'm uneasy in general with the idea of converting subtraction of a term to sign of a factor. [That's not what I would like to teach students to do;
I"m not sure it generalizes beyond integers.]
Is there a reason for not having rules for - and /,
or alternatively, generalized rules for addop and mulop
that include both + -  and * / respectively?

7. In general, I like the tree-manipulation system.

8. But I'm always looking for improvements:
I realize it would be a presentation challenge,
but could the rules be displayed in tree form (as in the left pane)
rather than in linear form?

9. An alternative "tree" format is "outline" form, something like this:

('(-20 == -4*x - 6*x))

== ..
    |
    -20
    |
    - .
      |
      * ..
      |  |
      |  -4
      |  |
      |  x
      |    
      * .. 
         |
         6
         |
         x   

Joe

      




kirby urner

unread,
May 26, 2016, 6:45:03 PM5/26/16
to mathf...@googlegroups.com
On Thu, May 26, 2016 at 2:59 PM, Joseph Austin <drtec...@gmail.com> wrote:

On May 26, 2016, at 12:55 PM, Ted Kosan <ted....@gmail.com> wrote:

Joe,

Try this link:
Ted

OK, that one works better, but I'm getting no audio on my mac.



No audio for me either however just seeing the video is enlightening.


Kirby



Ted Kosan

unread,
May 26, 2016, 8:16:58 PM5/26/16
to mathf...@googlegroups.com
Joe wrote:

> OK, that one works better, but I'm getting no audio on my mac.

I should have mentioned that this is a test video which does not have any sound.




> 1. In the formula
> In> Manipulate('(-20 == -4*x - 6*x))
>
> I would have expected the "-4" to be parsed as a negative coefficient
> instead of as unary minus of the product.
> Of course, they evaluate to the same thing.

I used to expect this too, but unary minus has a lower precedence than the "*" operator does. The Khan Academy math parser also parses -4*x as the unary minus of the product. This can be seen by entering "-20 = -4*x - 6*x" into the following expression structure tool:

http://patternmatics.org/test/expression_structure.html

When I started working with expression trees, they cleared up various misconceptions I had about how mathematical expressions were structured.



> 2. In  Manipulate, rule 11:
> q_  * q_ + q_ <-- (r + 1) * q
>
> Shouldn't it have an r_ in the LHS, as:
> r_  * q_ + q_ <-- (r + 1) * q

Yes, this is a bug! However, the rule was specified correctly as r_  * q_ + q_, and the bug was in the LaTeX that displayed the rule




> 3. In general, I'm not sure why there are not underscore variables  q_, r_ etc. on all the
> RHS of the Manipulate rules (as for example, on Rule 17 Distribute).
> Aren't all the RHS terms also trees?

In MathPiper's transformation rules, if the pattern on the left side of the <- or <-- operators matches, the subtree that matched each underscore variable in the pattern is assigned to the variable part of the underscore variable. For example if '(1 + 2) matched the pattern variable q_, then '(1 + 2) will be assigned to a local variable named "q" in the "replacement_tree" part of the rule. These local variables are in the scope of the replacement tree which is on the right side of the <- or <-- operators, and they are also in the scope of the post predicate code.




> 4. The significance of the color code in the Manipulate rules is not clear.
> I gather that the blue represents operators, or tree roots.
> But what is the significance of the yellow?

The parts of the patterns that are in orange serve to highlight the syntactic effect that the rule will achieve. For example, in rule 10 "Eliminate Unknown 1", both copies of the pattern variable "s_" should contain the unknown, and applying the rule will replace the matched subtree that has two copies of the unknown with a subtree that only has a single copy of the unknown. As I am looking at this color scheme, I think it may be helpful to apply the highlighting to the right side of the rules to.




> 6a. I can see that you have introduced additional rules to handle multiple occurrences
> of the unknown. I'm assuming these are sufficient for formulas linear in the unknowns,
> but not for non-linear, as there are no rules for powers, roots, and logs. Perhaps not
> even ratio and proportion: x/y = u/v ?

The equation solver and the manipulator are a work in progress, and I wanted to get the tree visualization tools and the explanation system working before I added support for more advanced mathematics.




> (In my classes, I had never gone beyond one linear occurrence of the unknown.)

What was the reason for never gone beyond one linear occurrence of the unknown?




> 6b.  It takes some contortions to un-distribute "ax - bx" to (a-b)x.
> I was able to do so by converting to (ax + (-b)x),
> but I'm uneasy in general with the idea of converting subtraction of a term to sign of a factor.
> [That's not what I would like to teach students to do;
> I"m not sure it generalizes beyond integers.]
> Is there a reason for not having rules for - and /,
> or alternatively, generalized rules for addop and mulop
> that include both + -  and * / respectively?

There is a trade-off between the number of rules provided and the visual complexity of the rules as a whole. The greater the number of rules that are provided, the more choices the user has for applying manipulations. However, the greater the number of rules that are provided, the more rules the user needs to look through.

The current set of rules is designed to minimize visual complexity. However, the system is able to support multiple sets of rules and other ones can be optimized for other purposes.




> 8. But I'm always looking for improvements:
> I realize it would be a presentation challenge,
> but could the rules be displayed in tree form (as in the left pane)
> rather than in linear form?

Providing tree forms for the rules is on my todo list. An issue related to this is in some manipulation systems instead of manipulating the tree to match the rules, the rules are manipulated to match the tree.




> 9. An alternative "tree" format is "outline" form, something like this:
>
> ('(-20 == -4*x - 6*x))
>
> == ..
>     |
>     -20
>     |
>     - .
>       |
>       * ..
>       |  |
>       |  -4
>       |  |
>       |  x
>       |    
>       * ..
>          |
>          6
>          |
>          x  

This format looks interesting, and I think an unparser can be written for it.

Ted

Joseph Austin

unread,
May 26, 2016, 9:41:12 PM5/26/16
to mathf...@googlegroups.com
On May 26, 2016, at 8:16 PM, Ted Kosan <ted....@gmail.com> wrote:

Joe wrote:

> OK, that one works better, but I'm getting no audio on my mac.

I should have mentioned that this is a test video which does not have any sound.
I understood it pretty well without sound.




> 1. In the formula
> In> Manipulate('(-20 == -4*x - 6*x))
>
> I would have expected the "-4" to be parsed as a negative coefficient
> instead of as unary minus of the product.
> Of course, they evaluate to the same thing.

I used to expect this too, but unary minus has a lower precedence than the "*" operator does. The Khan Academy math parser also parses -4*x as the unary minus of the product. This can be seen by entering "-20 = -4*x - 6*x" into the following expression structure tool:

http://patternmatics.org/test/expression_structure.html

When I started working with expression trees, they cleared up various misconceptions I had about how mathematical expressions were structured.

In some programming languages, such as C++, unary minus has precedence over multiply.  It's a question of how you define precedence to the parser.
Since seeing MathPiper, I've come to the opinion that there negative sign is a third meaning for "-" with higher precedence.




> 2. In  Manipulate, rule 11:
> q_  * q_ + q_ <-- (r + 1) * q
>
> Shouldn't it have an r_ in the LHS, as:
> r_  * q_ + q_ <-- (r + 1) * q

Yes, this is a bug! However, the rule was specified correctly as r_  * q_ + q_, and the bug was in the LaTeX that displayed the rule



> 3. In general, I'm not sure why there are not underscore variables  q_, r_ etc. on all the
> RHS of the Manipulate rules (as for example, on Rule 17 Distribute).
> Aren't all the RHS terms also trees?

In MathPiper's transformation rules, if the pattern on the left side of the <- or <-- operators matches, the subtree that matched each underscore variable in the pattern is assigned to the variable part of the underscore variable. For example if '(1 + 2) matched the pattern variable q_, then '(1 + 2) will be assigned to a local variable named "q" in the "replacement_tree" part of the rule. These local variables are in the scope of the replacement tree which is on the right side of the <- or <-- operators, and they are also in the scope of the post predicate code.

But the Distribution rules does have underscore variables on both sides.
My concern is not how it works, but the syntax.
I don't see a rationale for NOT using the same underscore variables in the RHS, since they have the same tree-values on both sides.  It's just inconsistent and confusing syntax.



> 4. The significance of the color code in the Manipulate rules is not clear.
> I gather that the blue represents operators, or tree roots.
> But what is the significance of the yellow?

The parts of the patterns that are in orange serve to highlight the syntactic effect that the rule will achieve. For example, in rule 10 "Eliminate Unknown 1", both copies of the pattern variable "s_" should contain the unknown, and applying the rule will replace the matched subtree that has two copies of the unknown with a subtree that only has a single copy of the unknown. As I am looking at this color scheme, I think it may be helpful to apply the highlighting to the right side of the rules to.

Perhaps you can give "rules" for which parts of the rule to highlight.
Certainly cardinality changes should be highlighted.
I'd consider highlighting CHANGED operators, not necessarily ALL operators.


> 6a. I can see that you have introduced additional rules to handle multiple occurrences
> of the unknown. I'm assuming these are sufficient for formulas linear in the unknowns,
> but not for non-linear, as there are no rules for powers, roots, and logs. Perhaps not
> even ratio and proportion: x/y = u/v ?

The equation solver and the manipulator are a work in progress, and I wanted to get the tree visualization tools and the explanation system working before I added support for more advanced mathematics.

As Einstein said, 
“Everything should be made as simple as possible, but not simpler."

> (In my classes, I had never gone beyond one linear occurrence of the unknown.)

What was the reason for never gone beyond one linear occurrence of the unknown?
I was teaching a data structures programming class, not a math class.
I just wanted an example of a tree problem.

But I also covered arithmetic expression parsing in my compiler design class,
in which we turned a conventional expression into a tree, making all implicit operations and order explicit.

> 6b.  It takes some contortions to un-distribute "ax - bx" to (a-b)x.
> I was able to do so by converting to (ax + (-b)x),
> but I'm uneasy in general with the idea of converting subtraction of a term to sign of a factor.
> [That's not what I would like to teach students to do;
> I"m not sure it generalizes beyond integers.]
> Is there a reason for not having rules for - and /,
> or alternatively, generalized rules for addop and mulop
> that include both + -  and * / respectively?

There is a trade-off between the number of rules provided and the visual complexity of the rules as a whole. The greater the number of rules that are provided, the more choices the user has for applying manipulations. However, the greater the number of rules that are provided, the more rules the user needs to look through.

Not really. The "rules" should express the semantics of the axioms.
We need a rule-set necessary and sufficient to express the semantics of all the axioms.
What may be missing from the usual theory of fields is the notion of expressions.  I think we want to say the field axioms apply to all 
expressions in the way they apply to numbers.
Are there "axioms" expressing the notions of "variables" and "expressions"?
There must be some concept of this in logic theory.

Is that the part of Algebra that is not generally taught?

In my prior comment
> or alternatively, generalized rules for addop and mulop
> that include both + -  and * / respectively?
I'm thinking I might have said "sum-op" and "product-op" to attempt to generalize beyond "add" and "multiply".

The current set of rules is designed to minimize visual complexity. However, the system is able to support multiple sets of rules and other ones can be optimized for other purposes. 

Again, I would hope the extent of the rule set is determined by the axioms,
not by "visual complexity."



> 8. But I'm always looking for improvements:
> I realize it would be a presentation challenge,
> but could the rules be displayed in tree form (as in the left pane)
> rather than in linear form?

Providing tree forms for the rules is on my todo list.
 
I suppose the question is, how do you plan to teach it?
If the object is to trains students to think of algebraic expressions as syntactic trees, then ought we not teach them using tree-visualization vs. using text strings?

[I'm having a similar debate in music:
If music is sound, why do we teach students to play from visual scores
instead of imitating heard sounds, aka "play by ear"?]



An issue related to this is in some manipulation systems instead of manipulating the tree to match the rules, the rules are manipulated to match the tree.
I'd have to see an example.






> 9. An alternative "tree" format is "outline" form, something like this:
>
> ('(-20 == -4*x - 6*x))
>
> == ..
>     |
>     -20
>     |
>     - .
>       |
>       * ..
>       |  |
>       |  -4
>       |  |
>       |  x
>       |    
>       * ..
>          |
>          6
>          |
>          x  

This format looks interesting, and I think an unparser can be written for it.
Do you mean: could be written in MathPiper?  

We know that, in general, parsers can be written for all expressions that can be written in C++ syntax, for example.

But more critical is an "editor"--a way to create trees on a computer/tablet.
And again, the student needs to know how to "think" of the problem in tree form. Why multiply? Why add?  When is a quantitative relationship a "product" or ratio and when is it a "sum" or difference?  When is it a "sum of products" and when is it a "product of sums"?  Etc.

And can we think of "n-ary" sums or products, and not just "binary"?
The tree form is straight-forward, just add more leaves.

But here is where the inverse operations show their distinctiveness:
we can't have "n-ary" differences and ratios, but we can have n-ary sums of positive and negative terms, and n-ary  products of whole and reciprocal factors.

Ted

Joseph Austin

unread,
May 27, 2016, 9:13:47 AM5/27/16
to mathf...@googlegroups.com

> On May 26, 2016, at 9:41 PM, Joseph Austin <drtec...@gmail.com> wrote:

> > 6b. It takes some contortions to un-distribute "ax - bx" to (a-b)x.
> > I was able to do so by converting to (ax + (-b)x),
> > but I'm uneasy in general with the idea of converting subtraction of a term to sign of a factor.
> > [That's not what I would like to teach students to do;
> > I"m not sure it generalizes beyond integers.]
> > Is there a reason for not having rules for - and /,
> > or alternatively, generalized rules for addop and mulop
> > that include both + - and * / respectively?
>
> [Ted] There is a trade-off between the number of rules provided and the visual complexity of the rules as a whole. The greater the number of rules that are provided, the more choices the user has for applying manipulations. However, the greater the number of rules that are provided, the more rules the user needs to look through.

Ted,
On further reflection, I withdraw this comment.
Surely what we want to do is aim for sums of products,
with products in the form (coefficient * variable).

I re-did the solution of
(-20 == -4*x - 6*x)
and got to the expression:
x * (-1 * 4 + -1 * 6) = -20

Now I want to apply rule 7:
q_ op r_ = s_ <-- q = s antiop r
but it won't do it.
[q_ = x; op = *, r = the + subtree; s = -20, antiop = / ]
---
re rule coloring:
I'm thinking it would be good to use a distinctive color for the op at the top of the subtree being transformed. In this example, the "=" would have the "root" color and the "op" and "antiop" would have a contrasting color.

Joe

Joseph Austin

unread,
May 27, 2016, 10:27:44 AM5/27/16
to mathf...@googlegroups.com
Ted,
Is it possible to apply the Manipulate rules in reverse?

For example, I was trying to derive:

(x+a)*(x-a) == x*x - a*a

Starting with (x+a)*(x-a)= 0, I got as far as:

x*x + (-1 +1) * a * x + -1 * a*a = 0


Now I want to do: q + -1*r <-- q - r
that is, rule 2 in reverse.

Also, to reduce the middle term, I would need rules expressing the identity relations, e.g. q-q = 0; r/r = 1; q+0=0; q*1=1; q*0=0;
These are no doubt included within the Eval function,
but shouldn't they be explicitly available for the student to apply?

In principle, we might even want to derive the "arithmetic" from the Peano postulates!

Ted Kosan

unread,
May 28, 2016, 3:46:31 AM5/28/16
to mathf...@googlegroups.com
Joe wrote:

> Since seeing MathPiper, I've come to the opinion that there negative sign is
> a third meaning for "-" with higher precedence.

I think this is a useful observation, and it may be helpful to create
some educational materials that discuss this issue.



> But the Distribution rules does have underscore variables on both sides.

Ah, I did not notice the underscores on the right side of the
Distribution rule when I looked after reading your previous email.
These are more typos in the LaTeX.



> My concern is not how it works, but the syntax.
> I don't see a rationale for NOT using the same underscore variables
> in the RHS, since they have the same tree-values on both sides. It's
> just inconsistent and confusing syntax.

This apparent inconsistency used to bother me too. The syntax of
MathPiper rules was inspired by Mathematica's rule syntax:

https://reference.wolfram.com/language/tutorial/Introduction-Patterns.html

When I first forked MathPiper from Yacas, the "_" character was an
operator. When I encountered the need to differentiate meta-level
syntax from object level syntax, I decided to make the underscore
character just a character that can be used in names, and then I
changed the evaluator so it treated any name that contained one or
more underscore characters as a constant.

The rules are the only part of MathPiper that treat variables that
have an underscore character to their immediate right as a pattern
variable. Technically the "q" in "q_" is the pattern variable, and the
underscore indicates the fact that it is a pattern variable and not a
literal.

The reason why names with an underscore to their immediate right are
not used on the right side of a rule is because names which have
underscores to their immediate right are constants that always
evaluate to themselves.



> Perhaps you can give "rules" for which parts of the rule to highlight.
> Certainly cardinality changes should be highlighted.
> I'd consider highlighting CHANGED operators, not necessarily ALL operators.

These appear to be good suggestions.



>> Providing tree forms for the rules is on my todo list.
>
> I suppose the question is, how do you plan to teach it?
> If the object is to train students to think of algebraic expressions
> as syntactic trees, then ought we not teach them using tree-visualization
> vs. using text strings?

One of the main purposes of the expression structure application is to
teach students the relationship between strings that contain
mathematical expressions and the trees they are parsed into. I am in
the process of building the capabilities of this app into MathPiper.



> [I'm having a similar debate in music:
> If music is sound, why do we teach students to play from visual scores
> instead of imitating heard sounds, aka "play by ear"?]

The following information on the limitations of standard music
notation seem related to what you mention here:

http://www.woodpecker.com/writing/essays/guitarnotation.html



>> This format looks interesting, and I think an unparser can be written for it.
>
> Do you mean: could be written in MathPiper?

Yes, I meant that I think an unparser could be written in MathPiper. I
said "I think" because most unparsers in MathPiper are implemented
using rules. For example, in the "UnparseC" procedure the following
rule unparses a while loop subtree into a string:

120 # UnparseC( While(pred_) body_, p_ ) <--
"while(" ~ UnparseC(pred,UnparseCMaxPrec()) ~ ")"
~ CIndent() ~ NlIndented()
~ UnparseCStatement(body) ~ CUndent();



> But more critical is an "editor"--a way to create trees on a computer/tablet.
> And again, the student needs to know how to "think" of the problem in tree
> form. Why multiply? Why add? When is a quantitative relationship a "product"
> or ratio and when is it a "sum" or difference? When is it a "sum of products"
> and when is it a "product of sums"? Etc.
>
> And can we think of "n-ary" sums or products, and not just "binary"?
> The tree form is straight-forward, just add more leaves.
>
> But here is where the inverse operations show their distinctiveness:
> we can't have "n-ary" differences and ratios, but we can have n-ary
> sums of positive and negative terms, and n-ary products of whole and
> reciprocal factors.

In an earlier email you wrote:

> But what I'd really like to have is a way to create and edit trees, graphs, and geometric figures.
> Can Geogebra do that?

I think I can see were you are going with a tree/graph editor and
teaching students how to think of problems in tree form. I don't think
GeoGebra can edit trees and graphs. However, if we can find a
Java-based open source tree and graph editor you like I may be able to
add it to MathPiperIDE as a plugin. Jung and JGraphX are two that come
to mind:

https://www.google.com/search?q=jung+graph&hs=ita&channel=fs&source=lnms&tbm=isch&sa=X

https://www.google.com/search?q=jgraphx&espv=2&biw=1920&bih=945&source=lnms&tbm=isch&sa=X

Do either of these two look like they would work for what you have in mind?

Ted

Ted Kosan

unread,
May 28, 2016, 3:59:28 AM5/28/16
to mathf...@googlegroups.com
Joe wrote:

> I re-did the solution of
> (-20 == -4*x - 6*x)
> and got to the expression:
> x * (-1 * 4 + -1 * 6) = -20
>
> Now I want to apply rule 7:
> q_ op r_ = s_ <-- q = s antiop r
> but it won't do it.
> [q_ = x; op = *, r = the + subtree; s = -20, antiop = / ]

I just tried it, and it worked for me:

["x*( -1*4 + -1*6) == (-20)", "", "0"],
["x == (-20)/( -1*4 + -1*6)", "Otherside 1 [=]", "0"],

What node did you select before applying the rule? For the otherside
rules it is the "=" node that is selected.



> re rule coloring:
> I'm thinking it would be good to use a distinctive color for the op at the
> top of the subtree being transformed. In this example, the "=" would
> have the "root" color and the "op" and "antiop" would have a contrasting color.

I think this is a good idea too. Currently the "=" operators are
highlighted in green. I will try highlighting all of the dominant
nodes in the patterns in green to see how this works.

Ted

Ted Kosan

unread,
May 28, 2016, 5:28:40 AM5/28/16
to mathf...@googlegroups.com
Joe wrote:

> Is it possible to apply the Manipulate rules in reverse?
>
> For example, I was trying to derive:
>
> (x+a)*(x-a) == x*x - a*a
>
> Starting with (x+a)*(x-a)= 0, I  got as far as:
>
> x*x + (-1 +1) * a * x + -1 * a*a = 0
>
>
> Now I want to do:  q + -1*r <-- q - r
> that is, rule 2 in reverse.
>
> Also, to reduce the middle term, I would need rules expressing the identity relations, e.g.  q-q = 0; r/r = 1; q+0=0; q*1=1; q*0=0;
> These are no doubt included within the Eval function,
> but shouldn't they be explicitly available for the student to apply?

Wow, you are picking this manipulation system up quick! It appears you are at a point where you can start adding rules to the manipulator yourself. The following worksheet contains the latest version of the rules "Manipulate" (and the step-by-step solver) use (including fixes for the typos you identified and including highlighting of dominant operators in green):

http://patternmatics.org/temp_1/mathfuture/rules/solve_and_manipulate_rules_joe_v.01.html

Do the following to use these rules:

1) Run "Manipulate" once to initialize it.

2) Evaluate these rules.

3) Run "Manipulate" again, and it will use these rules instead of the version of the rules that are in the library. Just reevalute these rules after editing them and the next use of "Manipulate" will use the changes.


I added a rule named "Define q_ - r_" that is the reverse of rule 2. It is rule 19. If you want to add more rules, I recommend that you use "Define q_ - r_" as a template and modify it. Just keep increasing the ManualSequence number for each new rule you make.

In these rules, "Head" is the rule's pattern, "Guard" is the post predicate, and "Body" is the replacement tree. The rule descriptions are a work in progress.

I am interested to see what manipulation rules you come up with!




> In principle, we might even want to derive the "arithmetic" from the Peano postulates!

Here is a fold from a worksheet I use to experiment with Peano arithmetic:

%mathpiper,title="Peano arithmetic."

//Define rulebases for a function named 's'.
// The 's' stands for successor.
RulebaseHoldArguments("s",["x"]);


Retract("+$", All);
Retract("-$", All);
Retract("*$", All);


// Define rules for the +$, -$, and *$ operators.
x_ +$ 0 <-- x;
x_ +$ s(y_) <-- s(x +$ y);

x_ -$ 0 <-- x;
s(x_) -$ s(y_) <-- x -$ y;

x_ *$ 0 <-- 0;
x_ *$ s(y_) <-- x *$ y +$ x;


//Examples which use the new rules.
Echo("2 + 2 = ", s(s(0)) +$ s(s(0)) );

Echo("5 - 2 = ", s(s(s(s(s(0))))) -$ s(s(0)));

Echo("2 * 3 = ", s(s(0)) *$ s(s(s(0))) );

Echo("3 * 3 * 3 = ", s(s(s(0))) *$ s(s(s(0))) *$ s(s(s(0))) );

%/mathpiper

    %output,sequence="10",timestamp="2016-05-28 05:20:32.622",preserve="false"
      Result: True
     
      Side Effects:
      2 + 2 = s(s(s(s(0))))
      5 - 2 = s(s(s(0)))
      2 * 3 = s(s(s(s(s(s(0))))))
      3 * 3 * 3 = s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(0)))))))))))))))))))))))))))
     
.   %/output


Ted

Bradford Hansen-Smith

unread,
May 28, 2016, 8:43:47 AM5/28/16
to mathf...@googlegroups.com
Ted, thank you for the Harvey Reid reference.
http://www.woodpecker.com/writing/essays/guitarnotation.html

He  speaks clearly to the problem I encounter with the 2-D concept and use of the circle and then folding circles as multi-dimensional beyond the flat linear thinking in math language, and now in programing technology. We do not understand the difference between spatial experience and a 2-D description that represents the abstraction of spatial experience.

--
You received this message because you are subscribed to the Google Groups "MathFuture" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathfuture+...@googlegroups.com.
To post to this group, send email to mathf...@googlegroups.com.
Visit this group at https://groups.google.com/group/mathfuture.
For more options, visit https://groups.google.com/d/optout.



--
Bradford Hansen-Smith
www.wholemovement.com

Joseph Austin

unread,
May 28, 2016, 2:53:38 PM5/28/16
to mathf...@googlegroups.com

On May 28, 2016, at 3:46 AM, Ted Kosan <ted....@gmail.com> wrote:

I think I can see were you are going with a tree/graph editor and
teaching students how to think of problems in tree form. I don't think
GeoGebra can edit trees and graphs. However, if we can find a
Java-based open source tree and graph editor you like I may be able to
add it to MathPiperIDE as a plugin. Jung and JGraphX are two that come
to mind:

https://www.google.com/search?q=jung+graph&hs=ita&channel=fs&source=lnms&tbm=isch&sa=X

https://www.google.com/search?q=jgraphx&espv=2&biw=1920&bih=945&source=lnms&tbm=isch&sa=X

Do either of these two look like they would work for what you have in mind?

I'll have a look at jung for starters.
Joe

Joseph Austin

unread,
May 28, 2016, 2:57:25 PM5/28/16
to mathf...@googlegroups.com

> On May 28, 2016, at 3:59 AM, Ted Kosan <ted....@gmail.com> wrote:
>
> Joe wrote:
>
>> I re-did the solution of
>> (-20 == -4*x - 6*x)
>> and got to the expression:
>> x * (-1 * 4 + -1 * 6) = -20
>>
>> Now I want to apply rule 7:
>> q_ op r_ = s_ <-- q = s antiop r
>> but it won't do it.
>> [q_ = x; op = *, r = the + subtree; s = -20, antiop = / ]
>
> I just tried it, and it worked for me:
>
> ["x*( -1*4 + -1*6) == (-20)", "", "0"],
> ["x == (-20)/( -1*4 + -1*6)", "Otherside 1 [=]", "0"],
>
> What node did you select before applying the rule? For the otherside
> rules it is the "=" node that is selected.

I think I may have encountered a glitch.
In subsequent attempts things worked OK for me too.
>
>
>
>> re rule coloring:
>> I'm thinking it would be good to use a distinctive color for the op at the
>> top of the subtree being transformed. In this example, the "=" would
>> have the "root" color and the "op" and "antiop" would have a contrasting color.
>
> I think this is a good idea too. Currently the "=" operators are
> highlighted in green. I will try highlighting all of the dominant
> nodes in the patterns in green to see how this works.
>
> Ted
>

Ted Kosan

unread,
May 28, 2016, 3:32:18 PM5/28/16
to mathf...@googlegroups.com
Joe wrote:

> I think I may have encountered a glitch.
> In subsequent attempts things worked OK for me too.

Hmmm... If you encounter further glitches go ahead and use the "Show
Steps" button save the steps you took to arrive at the step that has a
glitch. Hopefully, this will enable us to reproduce the glitch.

Ted

Joseph Austin

unread,
May 28, 2016, 3:40:59 PM5/28/16
to mathf...@googlegroups.com

On May 28, 2016, at 5:28 AM, Ted Kosan <ted....@gmail.com> wrote:

Wow, you are picking this manipulation system up quick! It appears you are at a point where you can start adding rules to the manipulator yourself. 

HOMEWORK?!  But I asked for it.
It may take me a while to work thru all this.

I've found an interesting site for the algebra axioms:

Note that, in spite of the statement in the legend that a b c are real,
there is nothing in the axioms that is not satisfied by the rationals,
nor any way to create irrationals from the axioms via closure on the Naturals.

But note that the syllabus following goes beyond the axioms presented,
to include not only reals but complex.  I'm not actually convinced that "reals" can exist apart from complex, in that if you add power and root to the function set, you must include complex for complete closure.

SO: even this is not a complete set of axioms sufficient for the "algebra" of polynomial equations, and what is an algebra course without polynomials?
Even though most algebra courses never get past quadratics.

[I'm proposing to replace these axioms with an alternative set using - and / as the "primitive" operators.]

I have long suspected "math teachers" of "bait and switch"--
the first week of class, we present a set of axioms that are supposedly the formal foundation of the course,
then before the second test, we have introduced a lot of new concepts not supported by the axioms.  
I first became aware of this in Advanced Calculus,
but now I see it goes all the way back to elementary school.
* subtraction introduced without negative numbers
* division introduced without rationals
* word problems introduced without algebra
* and as here, power and root introduced without complex and "vectors"
* trig introduced without the complex sphere 
(even though every schoolboy, and surely anyone who played video games on a primitive computer, realizes that the tan function "continues" around "behind the top of the paper" at + infinity and continues again from the bottom - infinity. (It's not the tan function that is discontinuous, it's the cartesian grid.)

Joe



Joseph Austin

unread,
May 28, 2016, 4:59:53 PM5/28/16
to mathf...@googlegroups.com
On May 28, 2016, at 8:43 AM, Bradford Hansen-Smith <wholem...@gmail.com> wrote:

Ted, thank you for the Harvey Reid reference. 
http://www.woodpecker.com/writing/essays/guitarnotation.html

He  speaks clearly to the problem I encounter with the 2-D concept and use of the circle and then folding circles as multi-dimensional beyond the flat linear thinking in math language, and now in programing technology. We do not understand the difference between spatial experience and a 2-D description that represents the abstraction of spatial experience.

Speaking of music, I once tried a 3x4 major/minor thirds factorization of the "circle of fifths" and Euler "tone network" into a torus. 

As for guitar, there is a tableture notation that uses staff lines for strings and number-"noteheads" for frets, one of many ways to project a 3D space onto a 2D page.


Joseph Austin

unread,
May 30, 2016, 9:29:42 AM5/30/16
to mathf...@googlegroups.com
> SHOW STEPS:
["(-20) == -4*x - (6*x)", "", "0"],
[" -4*x - (6*x) == (-20)", "Commute =", "0"],
[" -4*x + (-1)*(6*x) == (-20)", "Undefine q_ - r_", "1"],
["(-1)*(4*x) + (-1)*(6*x) == (-20)", "Undefine -q_", "11"],
["((-1)*4)*x + (-1)*(6*x) == (-20)", "Closer (q_, r_) [* *]", "11"],
["((-1)*4)*x + ((-1)*6)*x == (-20)", "Closer (q_, r_) [* *]", "12"],
["((-1)*4 + (-1)*6)*x == (-20)", "Eliminate Unknown 1", "1"],

At this point, nothing happens trying to apply rule 8 to =

So I commute the *

["(-20) == -4*x - (6*x)", "", "0"],
[" -4*x - (6*x) == (-20)", "Commute =", "0"],
[" -4*x + (-1)*(6*x) == (-20)", "Undefine q_ - r_", "1"],
["(-1)*(4*x) + (-1)*(6*x) == (-20)", "Undefine -q_", "11"],
["((-1)*4)*x + (-1)*(6*x) == (-20)", "Closer (q_, r_) [* *]", "11"],
["((-1)*4)*x + ((-1)*6)*x == (-20)", "Closer (q_, r_) [* *]", "12"],
["((-1)*4 + (-1)*6)*x == (-20)", "Eliminate Unknown 1", "1"],
["x*((-1)*4 + (-1)*6) == (-20)", "Commute *", "1"],

and try rule 7 to =
still won't go!
That is, clicking Apply does nothing.
The apply button lights while clicked, then unlights and the tree stays shaded yellow.


(This was with the original .900, before attempting your new ruleset.)

Joe



Joseph Austin

unread,
May 30, 2016, 9:30:45 AM5/30/16
to mathf...@googlegroups.com
Even doing the arithmetic didn't help:

["(-20) == -4*x - (6*x)", "", "0"],
[" -4*x - (6*x) == (-20)", "Commute =", "0"],
[" -4*x + (-1)*(6*x) == (-20)", "Undefine q_ - r_", "1"],
["(-1)*(4*x) + (-1)*(6*x) == (-20)", "Undefine -q_", "11"],
["((-1)*4)*x + (-1)*(6*x) == (-20)", "Closer (q_, r_) [* *]", "11"],
["((-1)*4)*x + ((-1)*6)*x == (-20)", "Closer (q_, r_) [* *]", "12"],
["((-1)*4 + (-1)*6)*x == (-20)", "Eliminate Unknown 1", "1"],
["x*((-1)*4 + (-1)*6) == (-20)", "Commute *", "1"],
["x*(-10) == (-20)", "Arithmetic", "12"],

Still, neither 7 nor 8 will go.

Joseph Austin

unread,
May 30, 2016, 9:39:36 AM5/30/16
to mathf...@googlegroups.com
Same problem with the new rules.

["(-20) == -4*x - (6*x)", "", "0"],
["(-20) == -4*x + (-1)*(6*x)", "Undefine q_ - r_", "2"],
["(-20) == (-1)*(4*x) + (-1)*(6*x)", "Undefine -q_", "21"],
["(-20) == ((-1)*4)*x + (-1)*(6*x)", "Closer (q_, r_) [* *]", "21"],
["(-20) == ((-1)*4)*x + ((-1)*6)*x", "Closer (q_, r_) [* *]", "22"],
["(-20) == ((-1)*4 + (-1)*6)*x", "Eliminate Unknown 1", "2"],
["((-1)*4 + (-1)*6)*x == (-20)", "Commute =", "0"],

Joseph Austin

unread,
May 30, 2016, 11:02:04 AM5/30/16
to mathf...@googlegroups.com
Another glitch, using new rules on: 

In> Manipulate ('((x_+a)*(x-a)==0));

["(x + a)*(x - a) == 0", "", "0"],
["(x + a)*(x + (-1)*a) == 0", "Undefine q_ - r_", "12"],
["(x + a)*x + (x + a)*((-1)*a) == 0", "Distribute", "1"],
["x*(x + a) + (x + a)*((-1)*a) == 0", "Commute *", "11"],
["(x*x + x*a) + (x + a)*((-1)*a) == 0", "Distribute", "11"],
["x*x + (x*a + (x + a)*((-1)*a)) == 0", "Closer (r_, s_) [+ +]", "1"],
["x*x + (x*a + ((-1)*a)*(x + a)) == 0", "Commute *", "122"],
["x*x + (x*(1*a) + ((-1)*a)*(x + a)) == 0", "Make Coefficient Explicit", "1212"],
["x*x + (x*(a*1) + ((-1)*a)*(x + a)) == 0", "Commute *", "1212"],
["x*x + (x*(a*1) + (((-1)*a)*x + ((-1)*a)*a)) == 0", "Distribute", "122"],
["x*x + ((x*(a*1) + ((-1)*a)*x) + ((-1)*a)*a) == 0", "Closer (q_, r_) [+ +]", "12"],
["x*x + (((a*1)*x + ((-1)*a)*x) + ((-1)*a)*a) == 0", "Commute *", "1211"],
["x*x + (((1*a)*x + ((-1)*a)*x) + ((-1)*a)*a) == 0", "Commute *", "12111"],
["x*x + (((1*a)*x + ((-1)*a)*x) + (-1)*(a*a)) == 0", "Closer (r_, s_) [* *]", "122"],


Trying to apply rule 10 to + at: 1 2 1
Nothing happens.

Joe

Joseph Austin

unread,
May 30, 2016, 11:41:20 AM5/30/16
to mathf...@googlegroups.com

On May 25, 2016, at 4:35 AM, Ted Kosan <ted....@gmail.com> wrote:
Joe Wrote:
 What I'm nervous about is that a "tree" is being represented as a "string",
> which requires some kind of convention to identify the "root" and the order of the leaves,
> which is a very iffy convention if you have to mix operators with different numbers of operands and order of evaluation.


Have you considered the LISP list notation for trees?
Essentially it's a parenthesized prefix notation:
Parenthesized list with operator as the first element and remaining operands following.

One advantage is the syntax is similar regardless of number of operands:
(unary_op opnd)
(binary_op opnd1 opnd2)
(ternary_op opnd1 opnd1 opnd3)
(n_ary op  opnd1 ... opndN)

This form is readily translated to an "indented hierarchy" representation of a tree.

Furthermore, the prefix-form tree representation clearly distinguishes the tree used for formal manipluation from the convenional format, so students are not confused as to which they are working with.  [If we are successful, future generations of students would abandon infix-form representations altogether!]

Finally, the n-ary form can represent sequences of associative binary operators as s single n-ary operator, e.g.:

a polynomial:
(+  (* a x x) (* b x y ) (* c y y) (* d x) (* e y) f )

or the gas law:
(== (* P V) (* n R T)) 

This n-ary convention is a "reasonable" abbreviation in that it avoids forcing an explicit order on order-insensitive associative operators. (Of course, an implementation could adopt a reasonable convention, or leave it "undefined" to allow freedom for auto-optimization or  "lazy" evaluation.)

Joe Austin

Ted Kosan

unread,
May 30, 2016, 1:00:19 PM5/30/16
to mathf...@googlegroups.com
Joe,

The traces you provided enabled me to locate a subtle bug in the
manipulation system. I fixed the bug and made a new distribution of
MathPiperIDE, which is version .901. When you get a chance, please try
testing this new version to see if it still contains the problems you
identified.

Thanks,

Ted

Joseph Austin

unread,
May 30, 2016, 4:45:44 PM5/30/16
to mathf...@googlegroups.com
TESTS SUCCESSFUL with 901 version.

I discovered one of my tests had a problem in the Manipulate:

In> Manipulate ('((x_+a)*(x-a)==0));

I had "x_" for one variable and plain "x" for the other.
They both looked the same in the tree display,
but Manipulate must have known the difference.

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

.901 rules

In> Manipulate('(-20 == -4*x - 6*x))

["(-20) == -4*x - (6*x)", "", "0"],
["(-20) == (-1)*(4*x) - (6*x)", "Undefine -q_", "21"],
["(-20) == (-1)*(4*x) + (-1)*(6*x)", "Undefine q_ - r_", "2"],
["(-20) == (-1)*(4*x) - (6*x)", "Undo Step", ""],
["(-20) == (-1)*(4*x) + (-1)*(6*x)", "Undefine q_ - r_", "2"],
["(-20) == ((-1)*4)*x + (-1)*(6*x)", "Closer (q_, r_) [* *]", "21"],
["(-20) == ((-1)*4)*x + ((-1)*6)*x", "Closer (q_, r_) [* *]", "22"],
["(-20) == ((-1)*4 + (-1)*6)*x", "Eliminate Unknown 1", "2"],
["((-1)*4 + (-1)*6)*x == (-20)", "Commute =", "0"],
["x == (-20)/((-1)*4 + (-1)*6)", "Otherside 2 [=]", "0"],

TEST SUCCESSFUL



.901 rules

In> Manipulate ('((x+a)*(x-a)==0));

["(x + a)*(x - a) == 0", "", "0"],
["(x + a)*(x + (-1)*a) == 0", "Undefine q_ - r_", "12"],
["(x + 1*a)*(x + (-1)*a) == 0", "Make Coefficient Explicit", "112"],
["(x + 1*a)*x + (x + 1*a)*((-1)*a) == 0", "Distribute", "1"],
["x*(x + 1*a) + (x + 1*a)*((-1)*a) == 0", "Commute *", "11"],
["(x*x + x*(1*a)) + (x + 1*a)*((-1)*a) == 0", "Distribute", "11"],
["(x*x + x*(1*a)) + ((-1)*a)*(x + 1*a) == 0", "Commute *", "12"],
["(x*x + x*(1*a)) + (((-1)*a)*x + ((-1)*a)*(1*a)) == 0", "Distribute", "12"],
["(x*x + (1*a)*x) + (((-1)*a)*x + ((-1)*a)*(1*a)) == 0", "Commute *", "112"],
["x*x + ((1*a)*x + (((-1)*a)*x + ((-1)*a)*(1*a))) == 0", "Closer (r_, s_) [+ +]", "1"],
["x*x + (((1*a)*x + ((-1)*a)*x) + ((-1)*a)*(1*a)) == 0", "Closer (q_, r_) [+ +]", "12"],
["x*x + ((1*a + (-1)*a)*x + ((-1)*a)*(1*a)) == 0", "Eliminate Unknown 1", "121"],
["x*x + (((1 + (-1))*a)*x + ((-1)*a)*(1*a)) == 0", "Eliminate Unknown 1", "1211"],
["x*x + (((1 + (-1))*a)*x + (-1)*(a*(1*a))) == 0", "Closer (r_, s_) [* *]", "122"],
["x*x + (((1 + (-1))*a)*x + (-1)*((a*1)*a)) == 0", "Closer (q_, r_) [* *]", "1222"],
["x*x + (((1 + (-1))*a)*x + (-1)*((1*a)*a)) == 0", "Commute *", "12221"],
["x*x + (((1 + (-1))*a)*x + (-1)*(1*(a*a))) == 0", "Closer (r_, s_) [* *]", "1222"],
["x*x + (((1 + (-1))*a)*x + ((-1)*1)*(a*a)) == 0", "Closer (q_, r_) [* *]", "122"],

The "algebra" is done; From here it's arithmetic.
TEST SUCCESSFUL

But it seems like a long way around just to do a cross-multiply and collect terms!


Joe

Joseph Austin

unread,
May 30, 2016, 6:16:52 PM5/30/16
to mathf...@googlegroups.com
On May 28, 2016, at 5:28 AM, Ted Kosan <ted....@gmail.com> wrote:

 If you want to add more rules, I recommend that you use "Define q_ - r_" as a template and modify it. Just keep increasing the ManualSequence number for each new rule you make.

In these rules, "Head" is the rule's pattern, "Guard" is the post predicate, and "Body" is the replacement tree. The rule descriptions are a work in progress.

I am interested to see what manipulation rules you come up with!

It may not be the most efficient path, but I did it!


    ruleName := "Identity q_ + 0";
    rule := [];
    rule["RuleName"] := ruleName;
    rule["Head"] := '( q_ +$ 0 );
    rule["Body"] := ''( q );
    rule["DescriptionObjectLevel"] := ''("Eliminate additive identity.");
    rule["DescriptionMetaLevel"] := "";
    rule["ManualSequence"] := 20;
    rule["HeadLatex"] :=  "q\\_ \\textcolor{green}{+} 0";
    rule["BodyLatex"] := "q";
    ?rulebaseElementaryAlgebra[ruleName] := rule;

    ruleName := "Identity q_ * 1";
    rule := [];
    rule["RuleName"] := ruleName;
    rule["Head"] := '( q_ *$ 1 );
    rule["Body"] := ''( q );
    rule["DescriptionObjectLevel"] := ''("Eliminate Multiplicative identity.");
    rule["DescriptionMetaLevel"] := "";
    rule["ManualSequence"] := 21;
    rule["HeadLatex"] :=  "q\\_ \\textcolor{green}{*} 1";
    rule["BodyLatex"] := "q";
    ?rulebaseElementaryAlgebra[ruleName] := rule;
    
    ruleName := "Identity q_ * 0";
    rule := [];
    rule["RuleName"] := ruleName;
    rule["Head"] := '( q_ *$ 0 );
    rule["Body"] := ''( 0 );
    rule["DescriptionObjectLevel"] := ''("Multiply by Zero");
    rule["DescriptionMetaLevel"] := "";
    rule["ManualSequence"] := 22;
    rule["HeadLatex"] :=  "q\\_ \\textcolor{green}{*} 0";
    rule["BodyLatex"] := "0";
    ?rulebaseElementaryAlgebra[ruleName] := rule;

In> Manipulate ('((x+a)*(x-a)));

["(x + a)*(x - a)", "", "0"],
["(x + a)*(x + (-1)*a)", "Undefine q_ - r_", "2"],
["(x + a)*x + (x + a)*((-1)*a)", "Distribute", "0"],
["x*(x + a) + (x + a)*((-1)*a)", "Commute *", "1"],
["(x*x + x*a) + (x + a)*((-1)*a)", "Distribute", "1"],
["x*x + (x*a + (x + a)*((-1)*a))", "Closer (r_, s_) [+ +]", "0"],
["x*x + (x*a + ((-1)*a)*(x + a))", "Commute *", "22"],
["x*x + (x*a + (((-1)*a)*x + ((-1)*a)*a))", "Distribute", "22"],
["x*x + (x*a + (((-1)*a)*x + (-1)*(a*a)))", "Closer (r_, s_) [* *]", "222"],
["x*x + ((x*a + ((-1)*a)*x) + (-1)*(a*a))", "Closer (q_, r_) [+ +]", "2"],
["x*x + (((1*x)*a + ((-1)*a)*x) + (-1)*(a*a))", "Make Coefficient Explicit", "2111"],
["x*x + ((1*(x*a) + ((-1)*a)*x) + (-1)*(a*a))", "Closer (r_, s_) [* *]", "211"],
["x*x + ((1*(a*x) + ((-1)*a)*x) + (-1)*(a*a))", "Commute *", "2112"],
["x*x + (((1*a)*x + ((-1)*a)*x) + (-1)*(a*a))", "Closer (q_, r_) [* *]", "211"],
["x*x + ((1*a + (-1)*a)*x + (-1)*(a*a))", "Eliminate Unknown 1", "21"],
["x*x + ((a*1 + (-1)*a)*x + (-1)*(a*a))", "Commute *", "2111"],
["x*x + ((a + (-1)*a)*x + (-1)*(a*a))", "Identity q_ * 1", "2111"],
["x*x + ((a - a)*x + (-1)*(a*a))", "Define q_ - r_", "211"],
["x*x + ((a - a)*x - (a*a))", "Define q_ - r_", "2"],
["x*x + ((1*a - a)*x - (a*a))", "Make Coefficient Explicit", "2111"],
["x*x + ((1*a + (-1)*a)*x - (a*a))", "Undefine q_ - r_", "211"],
["x*x + (((1 + (-1))*a)*x - (a*a))", "Eliminate Unknown 1", "211"],
["x*x + ((0*a)*x - (a*a))", "Arithmetic", "2111"],
["x*x + ((a*0)*x - (a*a))", "Commute *", "211"],
["x*x + (0*x - (a*a))", "Identity q_ * 0", "211"],
["x*x + (x*0 - (a*a))", "Commute *", "21"],
["x*x + (0 - (a*a))", "Identity q_ * 0", "21"],
["x*x + (0 + (-1)*(a*a))", "Undefine q_ - r_", "2"],
["x*x + ((-1)*(a*a) + 0)", "Commute +", "2"],
["x*x + (-1)*(a*a)", "Identity q_ + 0", "2"],
["x*x + (a*a)*(-1)", "Commute *", "2"],
["x*x + (-1)*(a*a)", "Commute *", "2"],
["x*x - (a*a)", "Define q_ - r_", "0"],


Now if I add:  q - q = 0;  q / q = 1; 
I may wouldn't  need "Arithmetic" at all.

Joe Austin


Ted Kosan

unread,
May 31, 2016, 1:37:25 AM5/31/16
to mathf...@googlegroups.com
Joe wrote:

> I had "x_" for one variable and plain "x" for the other.
> They both looked the same in the tree display,
> but Manipulate must have known the difference.

The tree display hides underscores by default in order to not confuse
people who don't know about MathPiper's meta-level syntax. However,
Manipulate works with the tree in meta-level form behind the scenes.



> But it seems like a long way around just to do a cross-multiply and collect terms!

It is indeed! What I found to be interesting, though, is many of the
students who have used this manipulation app got hooked on it almost
as if it were a game. They were not aware that equation solving could
be done at this level of detail, and they seemed to enjoy taking the
small manipulation steps it took to solve an equation.

What I am hoping is that students can first learn how equation solving
works at this high level of detail so they really understand what
axiomatic systems are and how they work. Then, when they use more
advanced solvers such as the following one, they should have a better
understanding of the mathematics involved in producing a solution:

In> Solve((_x + _a)*(_x - _a) == 0, _x)
Result: [_x == _a,_x == -_a]

Ted

Ted Kosan

unread,
May 31, 2016, 1:46:57 AM5/31/16
to mathf...@googlegroups.com
Joe wrote:

> It may not be the most efficient path, but I did it!
>
> ruleName := "Identity q_ + 0";
> <...>
> ruleName := "Identity q_ * 1";
> <...>
> ruleName := "Identity q_ * 0";
> <...>
> Now if I add: q - q = 0; q / q = 1;
> I may wouldn't need "Arithmetic" at all.

This is excellent! I was pretty sure it wouldn't take you too long to
successfully add some rules to the manipulator :-) What comes to mind
is to place extra rules like these into their own tab in the
manipulator so they are easy to access. What do you think about this
idea?

Ted

Joseph Austin

unread,
May 31, 2016, 11:40:57 AM5/31/16
to mathf...@googlegroups.com

On May 31, 2016, at 1:37 AM, Ted Kosan <ted....@gmail.com> wrote:

What I am hoping is that students can first learn how equation solving
works at this high level of detail so they really understand what
axiomatic systems are and how they work. Then, when they use more
advanced solvers such as the following one, they should have a better
understanding of the mathematics involved in producing a solution:

In> Solve((_x + _a)*(_x - _a) == 0, _x)
Result: [_x == _a,_x ==  -_a]

Ted

Of course, the challenging direction would be: 
Solve( _x^2 - _a^2 == 0, x)
Can't do that with the "rules of algebra" that are included in the current set--no power and root operators, or even divide.

How do your artificial intelligence methods address such equations?

And again, all this presumes the students already have a notion of what an equation represents in the first place.
This understanding could be achieved somewhat abstractly by considering equations and recipes for lines on the cartesian grid, or perhaps some other grid.

But ultimately there is the philosophical perspective that a mathematical relation mimics a physical relationship of measurable quantities.

Joe

Joseph Austin

unread,
May 31, 2016, 11:53:25 AM5/31/16
to mathf...@googlegroups.com
That would be a useful first step.

But I think it won't be long before I'll want not only "extra" rules but also to modify the existing rules. That would suggest a hierarchy of rules sets, like the libraries of "include" files in some programming languages.

How difficult is that? You might need something besides a numbering system to identify/distinguish rules.

Also, in an earlier email you mentioned modifications to the parser,
introduction of new operators, etc. That would also need to be part of the "customization" toolkit.

Joe


kirby urner

unread,
Jun 1, 2016, 1:26:43 AM6/1/16
to mathf...@googlegroups.com
On Tue, May 31, 2016 at 8:40 AM, Joseph Austin <drtec...@gmail.com> wrote:

On May 31, 2016, at 1:37 AM, Ted Kosan <ted....@gmail.com> wrote:

What I am hoping is that students can first learn how equation solving
works at this high level of detail so they really understand what
axiomatic systems are and how they work. Then, when they use more
advanced solvers such as the following one, they should have a better
understanding of the mathematics involved in producing a solution:

In> Solve((_x + _a)*(_x - _a) == 0, _x)
Result: [_x == _a,_x ==  -_a]

Ted

Of course, the challenging direction would be: 
Solve( _x^2 - _a^2 == 0, x)
Can't do that with the "rules of algebra" that are included in the current set--no power and root operators, or even divide.


CAS in general is able to solve such problems.  I was playing with Sympy this evening:

Python 3.5.1 |Anaconda 2.4.0 (x86_64)| (default, Dec  7 2015, 11:24:55) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> from sympy.solvers import solve
>>> from sympy import Symbol
>>> x = Symbol('x')
>>> solve(-4*x - (6*x) + 20, x)
[2]
>>> a = Symbol('a')
>>> solve(x**2 - a**2, x)
[-a, a]
>>>  

Kirby

Ted Kosan

unread,
Jun 1, 2016, 12:58:19 PM6/1/16
to mathf...@googlegroups.com
Joe wrote:

> Have you considered the LISP list notation for trees? <snip>

I agree that a strong argument can be made for using LISP list
notation in STEM education because of its ability to unambiguously
encode the structure of trees. Earlier I had stated that a requirement
be made that all mathematical expressions that are presented to
students should be accompanied by a fully parenthesized version of the
expression. Maybe it would be a good idea to extend this requirement
to also include a LISP list version of the expression?

Ted

Ted Kosan

unread,
Jun 1, 2016, 1:26:43 PM6/1/16
to mathf...@googlegroups.com
Joe wrote:

> But I think it won't be long before I'll want not only "extra" rules but also to modify
> the existing rules. That would suggest a hierarchy of rules sets, like the libraries
> of "include" files in some programming languages.
>
> How difficult is that? You might need something besides a numbering system to
> identify/distinguish rules.
>
> Also, in an earlier email you mentioned modifications to the parser,
> introduction of new operators, etc. That would also need to be part of the "customization" toolkit.

I spent quite a bit of time yesterday thinking about what you said
here about the need to have a flexible way to group rules, and some
possible ways to do it came to mind. Since having a more flexible way
to group rules will make the material I am writing for the next lesson
more clear, I am going to hold off on submitting the next lesson and
work on this rule grouping system for a while. I will keep you updated
on my progress.

Ted

Ted Kosan

unread,
Jun 1, 2016, 1:34:16 PM6/1/16
to mathf...@googlegroups.com
Joe wrote:

> Of course, the challenging direction would be:
> Solve( _x^2 - _a^2 == 0, x)
> Can't do that with the "rules of algebra" that are included in the current
> set--no power and root operators, or even divide.
>
> How do your artificial intelligence methods address such equations?

The program that the MathPiper step-by-step equation solver is based
on is named PRESS (PRolog Equation Solving System), and it is designed
to solve R Elementary Equations. These are transcendental expressions,
which are those involving polynomial, exponential, trigonometric,
logarithmic, and hyperbolic functions. In theory the MathPiper
step-by-step equation solver can be extended to solve all of these
kinds of equations.



> And again, all this presumes the students already have a notion of what an
> equation represents in the first place.
> This understanding could be achieved somewhat abstractly by considering
> equations and recipes for lines on the cartesian grid, or perhaps some other
> grid.
>
> But ultimately there is the philosophical perspective that a mathematical
> relation mimics a physical relationship of measurable quantities.

This need to have students understand how mathematical expressions are
related to interpretations brings us back to the need to teach
students logic starting at a very early age.

Ted

Joseph Austin

unread,
Jun 1, 2016, 6:15:33 PM6/1/16
to mathf...@googlegroups.com

On Jun 1, 2016, at 1:34 PM, Ted Kosan <ted....@gmail.com> wrote:

This need to have students understand how mathematical expressions are
related to interpretations brings us back to the need to teach
students logic starting at a very early age.

Logic is surely important, but more is needed.  
Students should understand common functional relationships,
and the idea that different phenomena exhibit different relationships.
For example:
Constant difference: age difference between student and a sibling.
Constant sum: total of items divided between two persons.
Constant ratio:  cookies decorated vs time spent
Constant product: A dozen coins arranged in various rectangles.
Square and cube: ratio of length, area and volume of rectangular surface or solid to unit length.
In such lessons, I would encourage students to investigate and discover quantitative relationships in everyday situations, learn to display the relationships in a graph and recognize the characteristic shape of the various functions, etc.

Joe Austin


Joseph Austin

unread,
Jun 1, 2016, 6:16:20 PM6/1/16
to mathf...@googlegroups.com
Sounds like a good plan.
Joe

Joseph Austin

unread,
Jun 1, 2016, 6:22:16 PM6/1/16
to mathf...@googlegroups.com
Yes. And besides, it would allow the student (or teacher) to use LISP/SCHEME systems to explore the functions, in case they end up in an environment without MathPiper.
And familiarity with LISP/SCHEME representation. essentially binary tree representation,
would prepare students for further study of data structures and recursive programming.

Joe

kirby urner

unread,
Jun 1, 2016, 8:39:38 PM6/1/16
to mathf...@googlegroups.com


On Jun 1, 2016 15:15, "Joseph Austin" <drtec...@gmail.com> wrote:
>
>
>> On Jun 1, 2016, at 1:34 PM, Ted Kosan

> Square and cube: ratio of length, area and volume of rectangular surface or solid to unit length.

This one is not constant though. Volume:Length is a 3rd power relationship I.e. 2x length -> 8x volume (4x area). True for any shape, not just squares and cubes. You didn't say constant so I'm not correcting, just agreeing this set of changing ratios is important.

Kirby

Joseph Austin

unread,
Jun 2, 2016, 4:56:57 PM6/2/16
to mathf...@googlegroups.com
Agreed.  

And I might have added exponential growth, the normal probability curves and "sine wave" to functional relationships that students should be familiar with,
even though the math for these may be considered "advanced."

I'd say I'm trying to include the "why" as well as the "what".
It's important for students to be able to do algebra and solve equations because the equations are important for understanding the world and how people relate to it.

Without an ability to evaluate quantitative relationships, our priorities might be diverted from serious concerns and effective remedies to the latest "squeaky wheel' or emotional appeal.

Joe Austin

Joseph Austin

unread,
Jun 2, 2016, 10:13:12 PM6/2/16
to mathf...@googlegroups.com
On Jun 1, 2016, at 1:26 AM, kirby urner <kirby...@gmail.com> wrote:

CAS in general is able to solve such problems.  I was playing with Sympy this evening:

Python 3.5.1 |Anaconda 2.4.0 (x86_64)| (default, Dec  7 2015, 11:24:55) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> from sympy.solvers import solve
>>> from sympy import Symbol
>>> x = Symbol('x')
>>> solve(-4*x - (6*x) + 20, x)
[2]
>>> a = Symbol('a')
>>> solve(x**2 - a**2, x)
[-a, a]
>>>  

Kirby

I'd like to see the solution trace.

Of course, this is a quadratic equation, which every Algebra 1 student is taught to solve (after much relatively useless practice factoring simple polynomials).

What I'd like to see is the "artificial intelligence" that derives the quadratic equation formula from the algebraic axioms!

Joe

Ted Kosan

unread,
Jun 3, 2016, 12:08:27 AM6/3/16
to mathf...@googlegroups.com
Joe wrote:

> Logic is surely important, but more is needed.
> Students should understand common functional relationships,
> and the idea that different phenomena exhibit different relationships.
> For example:
> Constant difference: age difference between student and a sibling.
> Constant sum: total of items divided between two persons.
> Constant ratio: cookies decorated vs time spent
> Constant product: A dozen coins arranged in various rectangles.
> Square and cube: ratio of length, area and volume of rectangular surface or
> solid to unit length.
> In such lessons, I would encourage students to investigate and discover
> quantitative relationships in everyday situations, learn to display the
> relationships in a graph and recognize the characteristic shape of the
> various functions, etc.

I agree with you that students need to understand relationships of all
kinds very well. However, since relations are one of the primary
topics that are part of logic, my thought is that students should have
a good understanding of what relations are before they start
investigating numerous examples of relations.

Since we have started giving books to each other, would you be
interested in having a free copy of the following book titled
"Introduction to Symbolic Logic and its Applications" by Rudolph
Carnap:

http://www.amazon.com/Introduction-Symbolic-Logic-Its-Applications/dp/0486604535/ref=sr_1_1?s=books&ie=UTF8&qid=1464925409&sr=1-1

This is one of the best books on symbolic logic I have encountered so
far, and its section on applications of symbolic logic contains
numerous examples of axiomatic systems for areas such as physics and
biology that I think you would find to be very interesting.

If you would like to have a free copy of this book, just email me your
physical address off list, and I will have one sent to you.

Ted

Ted Kosan

unread,
Jun 3, 2016, 12:23:01 AM6/3/16
to mathf...@googlegroups.com
Joe wrote:

> What I'd like to see is the "artificial intelligence" that derives the
> quadratic equation formula from the algebraic axioms!

PRESS can derive the solution for the General Quadratic Equation. The
following website contains most of the research papers that have been
written on PRESS:

http://www.research.ed.ac.uk/portal/en/persons/alan-bundy%28bfb547ed-a4df-4a6c-b1be-8ecd9b13419f%29/publications.html?pageSize=all&page=0

The paper titled "Using Matching in Algebraic Equation Solving",
Boring and Bundy, 1981 contains a summary of the steps PRESS takes to
do the derivation.

The paper titled "Analysing Mathematical Proofs (or Reading between
the Lines)", Bundy, 1975 describes the fundamentals of how PRESS
works, and reading this paper will be helpful for understanding the
above paper. A significant part of the content of next lesson I am
putting together comes from the longer version of this paper.

Ted

Joseph Austin

unread,
Jun 3, 2016, 7:48:46 PM6/3/16
to mathf...@googlegroups.com

On Jun 3, 2016, at 12:23 AM, Ted Kosan <ted....@gmail.com> wrote:


Thanks for the references.  I found them very helpful, in-spite of numerous critical typos in the on-line versions.

I can see that "basic method" of attraction, collection, and isolation is a level beyond what was typically taught when I was taking math.
"Isolation" is what I had taught my students as a tree-processing exercise.
"Attraction" seems to be the formalization of advice my trig teacher gave:
work with the most complicated side first.

But making these approaches explicit is what was missing in my own education.
I remember one time in college when a high-school classmate asked for my help with his trig class.  I could quickly do all his problems.  Then he asked me how I did that, and I couldn't tell him. To me, what to do was just "obvious"--but not to him.

So my next question is: given that AI can do as good a job as a professional mathematician--and certainly a much better job than the beginning student--is there still a societal need to teach "equation solving"? (At the elementary level, given cheap calculators, is there still a need to teach square roots? long division? even basic arithmetic?)  

Which is why I keep coming back to converting "word problems" and data relationships to formulas.  We should use our brains for things our machines can't (yet) do better!

And the ultimate philosophical question: what does mankind do once our computers are smarter than we are? I'd not be surprised it that day comes within the lifetime of some people living today.


The 

Ted Kosan

unread,
Jun 4, 2016, 9:38:20 PM6/4/16
to mathf...@googlegroups.com
Joe wrote:

> I can see that "basic method" of attraction, collection, and isolation is a
> level beyond what was typically taught when I was taking math.
> "Isolation" is what I had taught my students as a tree-processing exercise.
> "Attraction" seems to be the formalization of advice my trig teacher gave:
> work with the most complicated side first.
>
> But making these approaches explicit is what was missing in my own
> education.

Unfortunately, making these approaches explicit is what has been
missing in everyone's education since algebra was first taught.



> I remember one time in college when a high-school classmate asked for my help
> with his trig class. I could quickly do all his problems. Then he asked me how I did
> that, and I couldn't tell him. To me, what to do was just "obvious"--but not to him.

It appears that there are two kinds of people in the world:

1) Those who don't understand how to do math and can't do math.

2) Those who don't understand how to do math and can do math (math
teachers are in this category).

Apparently the amount of number 2s are very small compared to the
amount of number 1s. I am hoping we can use the new techniques to
create a third kind of person:

3) Those who understand how to do math and can do it.



> So my next question is: given that AI can do as good a job as a professional
> mathematician--and certainly a much better job than the beginning
> student--is there still a societal need to teach "equation solving"? (At the
> elementary level, given cheap calculators, is there still a need to teach
> square roots? long division? even basic arithmetic?)

There will probably not be a societal need to teach most of these
topics anymore. However, I think it would be unfeasible to drop these
topics all at once due to inertia. As a first step towards dropping
these topics they can be taught using the new techniques with much
greater clarity and in a small fraction of the time it normally takes
to teach them. The significant amount of time this first step would
free up can be devoted to teaching other topics such as computer
programming and logic. Later, each of the topics can be periodically
reconsidered for dropping completely.

One topic I would retain, however, is basic arithmetic in the form of
mental arithmetic because doing arithmetic mentally is often quicker
and more convenient than using a calculator.



> Which is why I keep coming back to converting "word problems" and data
> relationships to formulas. We should use our brains for things our machines
> can't (yet) do better!

I agree with this.



> And the ultimate philosophical question: what does mankind do once our
> computers are smarter than we are?

I think answers to this question depend on the simpler question "What
value is there in being smart?"


Ted

Bradford Hansen-Smith

unread,
Jun 5, 2016, 9:00:16 AM6/5/16
to mathf...@googlegroups.com
One old guy asking another, what does smart mean? Is it just accumulated knowledge or does it include life experience that together progressively generates understanding sometimes called wisdom. Maybe this term is not part of a deterministic world of computers and machines. It would be good to know if we have discarded the concept of wisdom having simply given it over to the functional value of a programmer's skill.


kirby urner

unread,
Jun 5, 2016, 10:02:45 AM6/5/16
to mathf...@googlegroups.com
On Sun, Jun 5, 2016 at 6:00 AM, Bradford Hansen-Smith <wholem...@gmail.com> wrote:
One old guy asking another, what does smart mean? Is it just accumulated knowledge or does it include life experience that together progressively generates understanding sometimes called wisdom. Maybe this term is not part of a deterministic world of computers and machines. It would be good to know if we have discarded the concept of wisdom having simply given it over to the functional value of a programmer's skill.



Useful query.  This being a Sunday, renamed First Day in the Quaker namespace by Puritan intruders who had a problem a so-called "pagan language" (real Quakers don't -- but sometimes say First Day anyway, finding it charming), I'm in the mood to ponder a query such as the above.  Means:  open ended question.

Big for me these days is ye old "phase space" meme as that's what gives us permission to call anything a "space" provided we're willing to parameterize it with some not-causally-colluding independent inputs.  Actually the inputs may well be entangled but for our purposes we have an API of input pins and output pins along with documented and tested behavior.  "If you do this, I do that" says the chip instructions.  Some of them even run instructions, as controlled by these pins (programs and data, all just more bits).

We know anything too mono-dimensional and universe, such as smarts versus no-smarts, is not gonna cut it in the big world (the so-called "real world").  People do not align neatly on a single line, though one may do so in party games like my guidance counselor liked (everyone line up in order of most to least attractive, yeah right, fun game I'm sure, funny guy though).

A lot of respected teachers are explicitly saying that it's not for a lack of smarts that we're having trouble. 

Or maybe lets put it another way:  individuals being individually smart and trying to prove that (SAT scores) in some race to the top, will be so pre-occupied at that level that when their oil trains crash and burn and rivers die for lack of fish, no one will have time to respond, because the "smarts" are not "invested in" at that level. 

So how smart is that really?  Right? 

We've got just such a crashed oil train here in Oregon right now, people evacuated, flames and oil in the river.  Meanwhile the Columbia used to bring tons of nitrogen in land in the form of huge fish migrations, much of it stopped thanks to barges and locks.  Huge implications.  The wattage from those dams is not that impressive either.

So what if the trains took the grain load from those barges and we made those dams go away.  How did the salmon get passed the lower dams then?  Do those fish ladders actually work?  There's a viewer window at Bonneville.  I remember seeing a few.

They trains wouldn't have to sell themselves to big oil if they had more grain business, would they? 

Yeah, a lot of local politics I realize, just what I think about when I wonder about "smarts".  It really doesn't matter in the end how smart I am, or you are, or the next person, if between us and among us we were unable to self-organize to manage our resources intelligently.  The tomb stone for civilization might be "just too dumb".  Too bad because much bigger brains on land animal chassis, with hands free, is hardly doable.  Dolphins will have to pick up the slack I guess.  Maybe the smartphones will help?

Kirby

kirby urner

unread,
Jun 5, 2016, 10:05:37 AM6/5/16
to mathf...@googlegroups.com
On Sun, Jun 5, 2016 at 7:02 AM, kirby urner <kirby...@gmail.com> wrote:


On Sun, Jun 5, 2016 at 6:00 AM, Bradford Hansen-Smith <wholem...@gmail.com> wrote:
One old guy asking another, what does smart mean? Is it just accumulated knowledge or does it include life experience that together progressively generates understanding sometimes called wisdom. Maybe this term is not part of a deterministic world of computers and machines. It would be good to know if we have discarded the concept of wisdom having simply given it over to the functional value of a programmer's skill.



Useful query.  This being a Sunday, renamed First Day in the Quaker namespace by Puritan intruders who had a problem a so-called "pagan language" (real Quakers don't -- but sometimes say First Day anyway, finding it charming), I'm in the mood to ponder a query such as the above.  Means:  open ended question.

Big for me these days is ye old "phase space" meme as that's what gives us permission to call anything a "space" provided we're willing to parameterize it with some not-causally-colluding independent inputs.  Actually the inputs may well be entangled but for our purposes we have an API of input pins and output pins along with documented and tested behavior.  "If you do this, I do that" says the chip instructions.  Some of them even run instructions, as controlled by these pins (programs and data, all just more bits).

We know anything too mono-dimensional and universe,

actually I meant "un-diverse" (not in the spellchecker).  :-D

If we use the "smart" axis to un-diversify our base, that'll prove we're not smart.

We hear a lot about AI.  That presumes there's RI (real intelligence) or else it's not defining its A.

Kirby



Ted Kosan

unread,
Jun 5, 2016, 1:26:36 PM6/5/16
to mathf...@googlegroups.com
Computation is controlled deduction, and the development of deduction
is one of the crowning achievements of the human race because it
enables a very high level of precision in thinking to be achieved. I
think much of the value humans obtain from computers comes from the
fact that they force the humans who program them to think precisely.

Instead of the world of computers discarding the concept of wisdom, I
think it puts pressure on humans to precisely define what wisdom is. I
have read that "wisdom" has a technical meaning that is so central to
reality that each of the world's main scriptures and myths have the
following symbols for it:

Greece: Hera/Fire
Rome: Juno
Iran: Armaiti
Scandinavia: Frigg
Chaldea: Istar
Christian: Holy Ghost
Kabbalah: World of Emanation
Ottoman Sufi: Relatively Invisible
Indian: Buddhi
Egypt: Isis
Japan: Ama-terasu
China: Fire
Medieval: Fire


Ted

kirby urner

unread,
Jun 5, 2016, 5:25:47 PM6/5/16
to mathf...@googlegroups.com
On Sun, Jun 5, 2016 at 10:26 AM, Ted Kosan <ted....@gmail.com> wrote:
Bradford wrote:

> One old guy asking another, what does smart mean? Is it just accumulated
> knowledge or does it include life experience that together progressively
> generates understanding sometimes called wisdom. Maybe this term is not part
> of a deterministic world of computers and machines. It would be good to know
> if we have discarded the concept of wisdom having simply given it over to
> the functional value of a programmer's skill.

Computation is controlled deduction, and the development of deduction
is one of the crowning achievements of the human race because it
enables a very high level of precision in thinking to be achieved. I
think much of the value humans obtain from computers comes from the
fact that they force the humans who program them to think precisely.


I'd like to join Ted in putting a positive spin on computers, without advancing
the agenda of what I call Robot World (recent postings).

With ubiquitous computing devices we have the potential to unleash another
Renaissance, which, like the first one, is about leveling the playing field,
diversifying the pool of those with access to capital.

Today we speak in terms of the "banked" and "unbanked" (clearly the set
of "undocumented" is a superset of the "unbanked").

Computers are enabling micro-loans and micro-transactions to where
finally the NGOs have the means to cut out the middle men.  You wanted
to send 30 pesos to that kid right there, on that screen, in that room, so
you do, using her public QR code.  That wasn't possible yesterday.

Instead of the world of computers discarding the concept of wisdom, I
think it puts pressure on humans to precisely define what wisdom is. I
have read that "wisdom" has a technical meaning that is so central to
reality that each of the world's main scriptures and myths have the
following symbols for it:


I recommend Logicomix by some Greek computer scientists, for showing
how there's an unbroken chain when it comes to wisdom traditions in
the same cloud as STEM topics.  They're not mutually exclusive, on the
contrary.

Lets remember that Hermann Grassmann, a pioneer of Universal Algebra,
was also a translator of the Rig Veda.  And that RBF was admired not
just by engineers, but by Hugh Kenner in The Pound Era.  Hugh was the
rare polymath who could teach about James Joyce then turn around and
write a column for Byte Magazine (McGraw-Hill).

STEAM and PATH intersect.  There's no reason to worry about 2D
becoming 1D.  Provided we stay 2D ourselves (more D is fine, I'm just
saying we have to keep integrating with the Humanities).
 
Greece: Hera/Fire
Rome: Juno
Iran: Armaiti
Scandinavia: Frigg
Chaldea: Istar
Christian: Holy Ghost
Kabbalah: World of Emanation
Ottoman Sufi: Relatively Invisible
Indian: Buddhi
Egypt: Isis
Japan: Ama-terasu
China: Fire
Medieval: Fire


Ted


I was mentioning the eye of Horus at the top of some Great Pyramid recently,
adding to the list. 

(Go:

horus eye pyramid

in Google images for more ideas).


Kirby

Joseph Austin

unread,
Jun 6, 2016, 9:57:27 AM6/6/16
to mathf...@googlegroups.com

On Jun 5, 2016, at 1:26 PM, Ted Kosan <ted....@gmail.com> wrote:

think much of the value humans obtain from computers comes from the
fact that they force the humans who program them to think precisely.

And it is precisely for this reason that I think coding should be included in the "math" curriculum, replacing if necessary less rigorous or less practical topics.
For example, I think coding embodies all of the intellectual virtues attributed to studying plane geometry, and could easily replace it.  If one retorts that "geometric knowledge" is important, incorporate it via Turtle Geometry. Could not the Turtle be enhanced to execute all the Constructions of Euclid?

1. to draw a straight-line from any point to any point.
2. to produce a finite straight-line continuously in a straight-line.
3. to draw a circle with any center and radius.
For (3), it would be necessary to add a version of "forward" that would curve with a constant radius.
Besides that, one would need an ability to locate the point of intersections of lines,
both straight and circular, though perhaps without explicit coordinates.
And of course, the ability to select arbitrary points in the plane or on a line
[Is that "postulate zero"?]

Or, consider teaching "Advanced Calculus" with the rigor required for using Math Piper to construct the proofs from axioms.  Does such a course or text exist?

Joe Austin

kirby urner

unread,
Jun 6, 2016, 10:23:59 AM6/6/16
to mathf...@googlegroups.com

Lets not forget The Math Myth which suggests that forcing kids to do rigorous things they will never use later in life, such as calculus, unless they happen to become a math teacher, informs them of one main lesson:  the adults are boring and stupid and only in it for themselves.  That's not the right conclusion to be drawing, but I understand why compulsory maths in the form we've seen, especially compulsory calculus, may be swiftly coming to an end.  We shall see.

Kirby



Joseph Austin

unread,
Jun 6, 2016, 4:18:49 PM6/6/16
to mathf...@googlegroups.com
Kirby,
I've observed that society tends to start doing things for very good reasons,
then keep doing them because "we've always done it that way" 
long after the original reasons are gone or even contradicted.

For example:
Prior to the widespread availability of the typewriter, one could make a good case for teaching cursive penmanship.
Prior to the widespread availability of calculators, one could make a good case for teaching the multiplication table, long division, etc.
Prior to the "discovery" of binary and hexadecimal in the context of computers, one could make a case for teaching the decimal number system (though some cultures preferred twelve or sixty).

In NC, the state legislature is currently debating abandoning the recently-adopted Common Core "Integrated" Math Curriculum of Math I, II, III and returning to the traditional Algebra 1, Geometry, Algebra 2 sequence.  

One item of contention is the course Advanced Functions and Modeling.

This seemed like the kind of course I have been suggesting,
though it is said to be oriented to non-math majors, and placed at the end of the curriculum rather than the beginning. (In an earlier life, I had worked alongside a math professor who was actively engaged in an "Algebra Reform" project, and it seemed they were taking a similar "data first" approach.)

Looking at the final exam, however
I have my doubts that the course actually teaches anything about the practical use of mathematics.

In contrast, given the significance of computers in contemporary society, it seems reasonable to insist that all citizens be familiar with the basic principles of their functioning, and equipped to use readily available programming systems to create (or customize) apps for their readily available devices.  Then in some future century, our descendants will wonder why they are still teaching kids "coding" when everything is being run by artificial intelligence!

Joe Austin

Joseph Austin

unread,
Jun 6, 2016, 4:41:59 PM6/6/16
to mathf...@googlegroups.com

Ted,
Is it possible to use Math Piper to solve multiple or simultaneous equations.
For example, suppose I want to solve for the points of intersection of a circle and a line, e.g. a circle with center (a,b) and radius r, and a line through points (c,d) and (e,f):

(x-a)^2 + (y-b)^2 == r^2
(y-d) == (f-d)/(e-c) * (x-c)

Joe Austin


kirby urner

unread,
Jun 6, 2016, 4:52:32 PM6/6/16
to mathf...@googlegroups.com
On Mon, Jun 6, 2016 at 1:18 PM, Joseph Austin <drtec...@gmail.com> wrote:
Kirby,
I've observed that society tends to start doing things for very good reasons,
then keep doing them because "we've always done it that way" 
long after the original reasons are gone or even contradicted.

Yes, inertia is real.  We should have something akin to physics, lets call
it metaphysics, that accounts for how reflex-conditioning starts out a life-saver
then becomes a life-threat when ingrained past its pull date.  We need to see
the mathematics curriculum as like the history curriculum:  in perpetual need
of upgrades to accommodate new findings.

Some people enter math teaching in the hopes of working with immutable
concepts in an environment guaranteed to be unchanging.  Any rocking of
their boat comes across as an implicit betrayal as mathematics was advertised
as change-immune, at least in the lower levels.

A first step in creating change is to avoid making implicit social contracts
such as:  if you learn this material you'll be guaranteed a steady job for X
years.  Lets not pretend we know so much more than we do for a change?

That being said, some computer languages are here to stay for many years.
This myth that we're on the brink of voice-automating everything, such that
programming will become a lost art, is pure science fiction from the standpoint
of today, way more fiction than science (a lot of the AI literature over-exaggerates
the state of the art; it's called "artificial" for a reason).
 

For example:
Prior to the widespread availability of the typewriter, one could make a good case for teaching cursive penmanship.

And now the typewriter has mostly gone away.  Keyboarding is still useful though.
I'm all for teaching keyboarding.  Readable penmanship, perhaps printing in upper
and lowercase, is still highly useful.  I recommend a lot of attention to fonts, to
Unicode, and to personalizing one's style.  Make your own fonts if you feel like
it:  those you draw, those you encode using vector graphics (not a trivial undertaking).
 
Prior to the widespread availability of calculators, one could make a good case for teaching the multiplication table, long division, etc.

I'm still all for showing off algorithms of some complexity, long division a good
example.  But am I in favor of "timed tests"?  That's a whole other question. 
Am I in favor of every student running out and buying a calculator while the
school wallows in having zero computer infrastructure of its own, no servers?

Every school needs servers, whether on site or not is a separate question.

We don't necessarily want to force little Johnny to have a global Internet
address at age 10, but practicing all these real world skills on the school
intranet, insulated from the outside, is perfectly feasible.  When they get
a little older, right of passage:  the school authorizes a real globally accessible
Internet c/o the school e.g. jun...@students.my_high_school.edu  That
converts to an alumni address upon graduation.

Baby schools with no IT to speak of will be able to use the expert services
of various support firms.  The better support firms are all about getting the
schools semi-independent, not victims of vendor lock-in.  That's where Open
Source comes in as a huge money saver.  There's really no excuse for
"vendor lock-in" when the software is free and written to Open Standards.

 
Prior to the "discovery" of binary and hexadecimal in the context of computers, one could make a case for teaching the decimal number system (though some cultures preferred twelve or sixty).


We still need to teach the decimal number system.  I agree with Douglas Crockford
that a next language beyond JavaScript that, like JavaScript, wants to standardize
on one single number type, would do well to consider his decimal type proposal.

https://news.ycombinator.com/item?id=7365812
(this is a heated debate, not preaching to some choir)
 
In NC, the state legislature is currently debating abandoning the recently-adopted Common Core "Integrated" Math Curriculum of Math I, II, III and returning to the traditional Algebra 1, Geometry, Algebra 2 sequence.  

One item of contention is the course Advanced Functions and Modeling.



I'm glad NC is joining the other states in helping the rest of the world get ahead. 
The US, having enjoyed being the most powerful and richest nation on earth for
so long, is now deliberately dumbing itself down en masse to allow other nations
a chance at bat.  I applaud this generosity.  The plan is working out well.

 
This seemed like the kind of course I have been suggesting,
though it is said to be oriented to non-math majors,

I think at the high school level it's pre-mature to speak of "majors" which usually
are not declared until say 2nd year college.

Over-specialization too early is going to deprive students of a broad foundation
in multiple disciplines.

"Math is an Outdoor Sport" is one of my slogans.  In my prototype school we're
out geocaching and physically doing stuff to learn math.  We do more cooking and
calorie counting (conservation of energy).  We do more hiking.  But that's because
we're close to the Columbia Gorge.

Seeing the stars, including Milky Way, directly, no planetarium, in a clear night,
should be a requirement for high school graduation, were we to cling to that
old model.  Chicago could never afford such a program, whereas Portland
already has Outdoor School baked in for all sixth graders.  Climate makes a
difference.
 
and placed at the end of the curriculum rather than the beginning. (In an earlier life, I had worked alongside a math professor who was actively engaged in an "Algebra Reform" project, and it seemed they were taking a similar "data first" approach.)

Looking at the final exam, however
I have my doubts that the course actually teaches anything about the practical use of mathematics.

In contrast, given the significance of computers in contemporary society, it seems reasonable to insist that all citizens be familiar with the basic principles of their functioning, and equipped to use readily available programming systems to create (or customize) apps for their readily available devices.  Then in some future century, our descendants will wonder why they are still teaching kids "coding" when everything is being run by artificial intelligence!

Joe Austin


I don't see learning to code as being about learning how computers work.
Computer languages are about modeling that same XYZ world of points and
shapes we get with calculators.  No time is spent, hardly, on the internals of
calculator design.  That's not the motivation.

Of course "how things work" is uber-important and I *want* students to have
an interest in computers, how they work, as a topic.  I just don't want to
perpetuate the stereotype that learning to code has anything whatsoever
with becoming a computer scientist or math major.  It's something artists
need to know just as seriously.m  Indeed, I'm thinking the Art Department
is going to come out ahead, given how the Math Department avoids the
historical dimension so assiduously.  When was the last time MAA published
anything coherent about volume 6 rhombic dodecahedra defining the IVM.
That's art school shop talk.  Mathematicians are forbidden to share it, at
least in the "everyone held back" USA (thanks again!).

Kirby

Joseph Austin

unread,
Jun 6, 2016, 5:00:51 PM6/6/16
to mathf...@googlegroups.com

On Jun 4, 2016, at 9:38 PM, Ted Kosan <ted....@gmail.com> wrote:

I am hoping we can use the new techniques to
create a third kind of person:

3) Those who understand how to do math and can do it.

There's one more requirement to create a self-sustaining society:
we must have those who know how to teach it, 
or at least those who can learn it.

It's not clear that those who know how to teach necessarily need to know how to do.  My brother has had a successful career as a corporate training executive developing training programs for all sorts of jobs in which he had no personal competence.

Certainly we have ample evidence that those who know how to do don't necessarily know how to teach.

Joe


Joseph Austin

unread,
Jun 6, 2016, 5:12:07 PM6/6/16
to mathf...@googlegroups.com

> On Jun 5, 2016, at 9:00 AM, Bradford Hansen-Smith <wholem...@gmail.com> wrote:
>
> One old guy asking another, what does smart mean? Is it just accumulated knowledge or does it include life experience that together progressively generates understanding sometimes called wisdom. Maybe this term is not part of a deterministic world of computers and machines. It would be good to know if we have discarded the concept of wisdom having simply given it over to the functional value of a programmer's skill.
>
Whatever you call it, there is value in being able to anticipate the consequences of various possible choices. It is even more valuable to be able to do the inverse: determine possible choices to achieve intended consequences.

What we tend to do instead is keep doing the same thing, hoping for a different result, which is Einstein's definition of insanity.

Joe


kirby urner

unread,
Jun 6, 2016, 5:35:40 PM6/6/16
to mathf...@googlegroups.com


On Mon, Jun 6, 2016 at 2:12 PM, Joseph Austin <drtec...@gmail.com> wrote:

<< SNIP >>
 
What we tend to do instead is keep doing the same thing, hoping for a different result, which is Einstein's definition of insanity.

Joe


Just like the Bible or the I Ching, we find conflicting advice on just about everything:

"If at first you don't succeed, try try again..." (tired old mantra)

"if you do that  (try try again in the face of failure), you're plain nuts"  (paraphrasing Einstein)

Another example:

"Be here now, live in the present" (guru so-and-so)

"Plan for the future or regret your irresponsible youth" (financial planner)

I can't blame people for being confused, given all the contradictory signals and bumper sticker advisories.

Sometimes the only thing to do is block it all out and do your own thinking.

"Never mind what everyone else says, what dost thou say?" (old Quaker adage)

Kirby



Joseph Austin

unread,
Jun 6, 2016, 6:18:49 PM6/6/16
to mathf...@googlegroups.com
Ted,
1. What do I need to know to add my own operators to MathPiper?

For example, I would like to add the following:

/ for unary multiplicative inverse: /u -> 1/u

^ exponential x^y = x to the y
(presumably already there, but not in axioms?

^/ root x ^/ 2 -> square root of x; = x to the 1/2 power

\^ log e\^x -> ln x; 10 \^ x -> log10 x



2. How does one handle compound data types,
e.g. cartesian points, polar points, complex numbers?

I suppose that would be enough to do algebra.
Phase 2: overload these to operate in other "groups/algebras",
e.g. permutations, quaternions, GA, Finte Automata, etc.
Joe




Ted Kosan

unread,
Jun 6, 2016, 8:40:22 PM6/6/16
to mathf...@googlegroups.com
Yacas was an experimental CAS and parts of it, including the equation
solver, were incomplete. What I did with MathPiper was to remove most
of the incomplete parts that came from Yacas and then offloaded
complex CAS operations (such as solving) to the Reduce CAS (a copy of
which is included with MathPiper).

Reduce is a commercial-quality CAS that has a physics emphasis. More
information about it can be obtained from these websites:

http://reduce-algebra.sourceforge.net/
http://reduce-algebra.com/

Reduce can solve simultaneous equations. However I have not added
support for sending more than one equation from MathPiper to Reduce
yet, although I do not think it would be too difficult to do. The
worksheet that contains the interface code between MathPiper and
Reduce can be viewed by selecting the "View source code" link that is
at the bottom of the documentation page for the "Solve" procedure.

Reduce can also be used directly using a %reduce fold:

%reduce

solve({3x + 5y = -4, 2*x + y = -10},{x,y});

%/reduce

%output,sequence="7",timestamp="2016-06-06 20:21:48.695",preserve="false"
{{x=( - 46)/7,y=22/7}}$
. %/output

Ted

Joseph Austin

unread,
Jun 6, 2016, 9:41:08 PM6/6/16
to mathf...@googlegroups.com

On May 21, 2016, at 6:18 PM, Ted Kosan <ted....@gmail.com> wrote:

In MathPiper, the arities, precedences, and
associativities of all operators are configurable
using MathPiper code. The following section of the file
src/org/mathpiper/scripts4/a_initialization/stdopers/stdopers.mpw
is where these properties of the arithmetic
operators are defined in the MathPiper library:

Ted,
I found such a file buried somewhat deeper in 

…/mathpiperide_source_dist_v901_beta/src/library_apps/mathpiper4/

So is it enough to edit that section and reexecute it,

or are there other things that must also be modified?

My objective is to add more operators so I can then add corresponding Manipulate rules.

Or should I just wait for your next lesson?

Joe Austin

Ted Kosan

unread,
Jun 6, 2016, 9:42:34 PM6/6/16
to mathf...@googlegroups.com
Joe wrote:

> 1. What do I need to know to add my own operators to MathPiper?
>
> For example, I would like to add the following:
>
> / for unary multiplicative inverse: /u -> 1/u

Create unary / operator, rulebase, and one rule.
%mathpiper

Retract("/", 1);

Prefix("/", 50);

RulebaseHoldArguments("/", ["u"]);

/u_ <-- 1/u;

%/mathpiper


In> /3
Result: 1/3



> ^ exponential x^y = x to the y
> (presumably already there, but not in axioms?

Correct, the ^ operator exists in the global rulebase, but not in the
manipulate rules.


> ^/ root x ^/ 2 -> square root of x; = x to the 1/2 power
>
> \^ log e\^x -> ln x; 10 \^ x -> log10 x

You can probable use the unary "/" example as a guide for creating
these operators, rulebases, and rules (let me know if you run into
difficulties).



> 2. How does one handle compound data types,
> e.g. cartesian points, polar points, complex numbers?

These data types can be handled with list notation:

In> /[u_, v_] <-- [/u, /v];

In> /[2,3];
Result: [1/2,1/3]

Or, as is the case with the existing complex number implementation,
with function notation:

In> I
Result: Complex(0,1)

In> 3+4*I
Result: Complex(3,4)

In> Complex(-2,0)
Result: -2


Ted

Ted Kosan

unread,
Jun 6, 2016, 9:53:30 PM6/6/16
to mathf...@googlegroups.com
Joe wrote:

> I found such a file buried somewhat deeper in
>
> …/mathpiperide_source_dist_v901_beta/src/library_apps/mathpiper4/
>
> So is it enough to edit that section and reexecute it,
>
> or are there other things that must also be modified?

This file is where most of the operators that are used in the library
are defined, and it is a good reference to use to see how to create
operators. However, to create your own operators, instead of editing
this file and evaluating it, the new operators can be created in your
own worksheets as is shown in my most recent emails.



> My objective is to add more operators so I can then add corresponding
> Manipulate rules.
>
> Or should I just wait for your next lesson?

I say go ahead and add the new operators and rules for them by editing
the rulebase_elementary_algebra.mpw file like you have been doing. You
can create the new operators at the top of this file. Then, when the
custom Manipulate rules system I am creating is working, you can move
your code to the new system.

Ted

Joseph Austin

unread,
Jun 7, 2016, 8:35:19 AM6/7/16
to mathf...@googlegroups.com

On Jun 6, 2016, at 9:42 PM, Ted Kosan <ted....@gmail.com> wrote:

%mathpiper

Retract("/", 1);

Prefix("/", 50);

RulebaseHoldArguments("/", ["u"]);

/u_ <-- 1/u;

%/mathpiper

 %error,sequence="2",timestamp="2016-06-07 08:33:08.607",preserve="false"
      Result: The procedure </> is a library procedures, and library procedures cannot be redefined.  Error on or before line 3 starting at index 0.
.   %/error

Joe

Ted Kosan

unread,
Jun 7, 2016, 11:12:56 AM6/7/16
to mathf...@googlegroups.com

Joe,

I forgot to add the following line of code to the example:

LibraryLock(False);

Ted

--

Ted Kosan

unread,
Jun 9, 2016, 5:18:51 AM6/9/16
to mathf...@googlegroups.com
Joe,

I just released version .902 of MathPiperIDE, and it has initial support for creating custom rule sets for "Manipulate". I am not sure yet how a rule inheritance mechanism would work, so for now each custom rule set needs to contain definitions for all of the rules in the set, even if some rules already exist in another set. An example of how to use the new custom rule set system is included below.

I am going to switch back to working on the next lesson now. Let me know if you notice any bugs in the new system.

Ted


%mathpiper

rewriteRules := [];

ruleName := "Identity q_ + 0";
rule := [];
rule["RuleName"] := ruleName;
rule["Head"] := '( q_ +$ 0 );
rule["Body"] := ''( q );
rule["DescriptionObjectLevel"] := ''("Eliminate additive identity.");
rule["DescriptionMetaLevel"] := "";
rule["ManualSequence"] := 1;
rule["HeadLatex"] :=  "q\\_ \\textcolor{green}{+} 0";
rule["BodyLatex"] := "q";
rewriteRules[ruleName] := rule;

ruleName := "Identity q_ * 1";
rule := [];
rule["RuleName"] := ruleName;
rule["Head"] := '( q_ *$ 1 );
rule["Body"] := ''( q );
rule["DescriptionObjectLevel"] := ''("Eliminate Multiplicative identity.");
rule["DescriptionMetaLevel"] := "";
rule["ManualSequence"] := 2;
rule["HeadLatex"] :=  "q\\_ \\textcolor{green}{*} 1";
rule["BodyLatex"] := "q";
rewriteRules[ruleName] := rule;

ruleName := "Identity q_ * 0";
rule := [];
rule["RuleName"] := ruleName;
rule["Head"] := '( q_ *$ 0 );
rule["Body"] := ''( 0 );
rule["DescriptionObjectLevel"] := ''("Multiply by Zero");
rule["DescriptionMetaLevel"] := "";
rule["ManualSequence"] := 3;
rule["HeadLatex"] :=  "q\\_ \\textcolor{green}{*} 0";
rule["BodyLatex"] := "0";
rewriteRules[ruleName] := rule;

Manipulate('((-1)*4 + (-1)*6)*_x == (-20), RewriteRules:rewriteRules, TabTitle:"Test");

%/mathpiper




 

Joseph Austin

unread,
Jun 9, 2016, 5:39:20 PM6/9/16
to mathf...@googlegroups.com
Ted,
Thanks for the update.

I see you have added the ruleset  .mpw file as an argument to Manipulate.


I was able to test the attached RewriteRules successfully with the following example:

Manipulate('((2*1 + 0)*0 + 2*0), RewriteRules:rewriteRules, TabTitle:"Test");

Of course, the attached ruleset does not contain any other rules.

I have not been immediately successful integrating the new rules with the Joe1 set you sent previously, but will keep trying and report back later.

Joe







Joseph Austin

unread,
Jun 10, 2016, 4:57:57 PM6/10/16
to mathf...@googlegroups.com
On Jun 9, 2016, at 5:18 AM, Ted Kosan <ted....@gmail.com> wrote:

I just released version .902 of MathPiperIDE, and it has initial support for creating custom rule sets for "Manipulate".

Seems to be working.  I integrated the Identity rules into the Joe1 set and solved two equations.

However: I noticed I could not apply the "Undefine" rules to the negative numbers--
not sure how useful that might have been.
Suggestion: It might be useful, if a rule application fails, to record the failure as such in the "show steps" log.
But not as useful as the next lesson!

Steps and integrated ruleset attached, FYI.

Joe


In> Manipulate('((2*1 + 0)*0 == 2*0),          RewriteRules:"?rulebaseElementaryAlgebra", TabTitle:"Test");
Result: [class org.mathpiper.builtin.functions.optional.TreeView$TreeViewPanel,class javax.swing.JFrame]

["(2*1 + 0)*0 == 2*0", "", "0"],
["(2 + 0)*0 == 2*0", "Identity q_ * 1", "111"],
["(2 + 0)*0 == 0", "Identity q_ * 0", "2"],
["2*0 == 0", "Identity q_ + 0", "11"],
["0 == 0", "Identity q_ * 0", "1"],

SUCCESS


===========
Manipulate('((-1)*4 + (-1)*6)*_x == (-20), RewriteRules:"?rulebaseElementaryAlgebra", TabTitle:"Test");

["((-1)*4 + (-1)*6)*x == (-20)", "", "0"],
["(-20) == ((-1)*4 + (-1)*6)*x", "Commute =", "0"],
["((-1)*4 + (-1)*6)*x == (-20)", "Commute =", "0"],
["(4*(-1) + (-1)*6)*x == (-20)", "Commute *", "111"],
["(4*(-1) + 6*(-1))*x == (-20)", "Commute *", "112"],
["((4 + 6)*(-1))*x == (-20)", "Eliminate Unknown 1", "11"],
["x == (-20)/((4 + 6)*(-1))", "Otherside 2 [=]", "0"],
["x == 2", "Arithmetic", "2"],

--------------
Joe902-0.mpw

Joseph Austin

unread,
Jun 10, 2016, 5:23:25 PM6/10/16
to mathf...@googlegroups.com
Ted,
under rules Joe102, adding this rule  of /x:

7*/14 = 1/2
but
/14*7 = 1/98

This of course in inconsistent with the intended meaning of /x as (1/x)
and with the advertized precedence rules of MathPiper which places / strictly ahead of *.

I note in passing that /0 evaluates to infinity.
0*/0 = undefined, but /0*0 = infinity.

In> 7*/14
Result: 1/2

In> /14*7
Result: 1/98

BUT
In> 1/14*7
Result: 1/2

In> 0*/0
Result: Undefined

In> /0*0
Result: Infinity

In> 1/0*0
Result: Undefined

Joe

Ted Kosan

unread,
Jun 10, 2016, 8:02:33 PM6/10/16
to mathf...@googlegroups.com
Joe wrote:

> However: I noticed I could not apply the "Undefine" rules to the negative numbers--
> not sure how useful that might have been.

It is interesting that there are the following two forms for negative
numbers. For example, -1 can be represented by a unary - operator that
has '1' as its operand:

a)
In> UnparseLisp('(-1))
Result: -1
Side Effects:
(-
1)


b)
As a 32 bit int in two's complement form: 0xFFFFFFFF.

Are you saying that the undefine rule for unary minus operators was
able to undefine a number that was in form a) ?



> Suggestion: It might be useful, if a rule application fails, to record the failure as such in the "show steps" log.

This is a good idea!



> But not as useful as the next lesson!

Your are currently doing things with rules that are well beyond what I
had in mind for the next (and probably last) lesson :-) The next
lesson will be devoted to explaining the isolation, collection, and
attraction methods that the AI researchers developed for PRESS. If you
would like to continue playing with MathPiper after the last lesson
has been submitted, we will probably move the discussion over to the
MathPiper developer list.



> Steps and integrated ruleset attached, FYI.

I modified your worksheet slightly and attached it to this email. The
modification was I renamed the variable "?rulebaseElementaryAlgebra"
to "joeRules" because "?rulebaseElementaryAlgebra" is currently a
global variable that I will be making private soon.

Ted
joe902-0a.mpw

Ted Kosan

unread,
Jun 10, 2016, 8:13:25 PM6/10/16
to mathf...@googlegroups.com
Joe wrote:

> under rules Joe102, adding this rule of /x:
>
> 7*/14 = 1/2
> but
> /14*7 = 1/98

Try changing the precedence of the new unary / operator from 50 to 30:

Prefix("/", 30);



> I note in passing that /0 evaluates to infinity.
> 0*/0 = undefined, but /0*0 = infinity. <snip>

Just add a rule that handles an operand that is 0:

In> /0
Result: Infinity

In> /0 <-- Undefined;
Result: True

In> /0
Result: Undefined

Rules can be added for the unary / operator as needed to handle
various expression patterns.


Ted

Joseph Austin

unread,
Jun 11, 2016, 8:40:15 AM6/11/16
to mathf...@googlegroups.com

On Jun 10, 2016, at 8:13 PM, Ted Kosan <ted....@gmail.com> wrote:

Try changing the precedence of the new unary / operator from 50 to 30:

Prefix("/", 30);

That worked:

In> /2
Result: 1/2

In> 25^/2
Result: 5

/* 
so, you get a "operator notation" of " ^/ " for sqrt for free;
the problem is, it's backwards from the usual convention!
*/

In> 14*/2
Result: 7

In> /2*14
Result: 7

In> /0
Result: Infinity

In> 1/0
Result: Infinity

In> 1*/0
Result: Infinity

In> 0/0
Result: Undefined

In> 0*/0
Result: Undefined

In> /0*0
Result: Undefined

Joseph Austin

unread,
Jun 11, 2016, 7:07:33 PM6/11/16
to mathf...@googlegroups.com
On Jun 10, 2016, at 8:02 PM, Ted Kosan <ted....@gmail.com> wrote:

Joe wrote:

However: I noticed I could not apply the "Undefine" rules to the negative numbers--
not sure how useful that might have been.

It is interesting that there are the following two forms for negative
numbers. For example, -1 can be represented by a unary - operator that
has '1' as its operand:

a)
In> UnparseLisp('(-1))
Result: -1
Side Effects:
(-
  1)


b)
As a 32 bit int in two's complement form: 0xFFFFFFFF.

Are you saying that the undefine rule for unary minus operators was
able to undefine a number that was in form a) ?

Consider the expression:

-4*x-2 == -2+x*-4

On the LHS, it is possible to apply the Undefine -q and Undefine q-r  rules;
but they cannot be applied to the -4 and -2 on the RHS.
In the LHS, the tree reflects the operator role of - , whereas in the RHS, the tree reflects the sign role.
This is particularly strange in LHS -4 vs RHS -4
In fact, in LHS, the -4*x is interpreted as -(4*x) rather than (-4)*x.
This is non-standard precedence for unary minus.

Regarding "minus", there are actually three or four possible interpretations:

* the subtraction operator (binary minus)
* the negation operator (unary minus)
* the negative sign of an integer (sign) -- this is usually incorporated into the number representation on the computer, as you observed,
but there is no corresponding convention for numerals in text.
[BTW, as you illustrate with your rational calculations, there ls likewise no textual distinction between fractions (rational numbers) and quotients (division operations)].  Of course computers do have a "rational" representation of sorts in so-called Floating Point, as long as the denominator is a power of two.  In fact, those are the only rationals the typical computer is capable of operating on with native instructions.

And if we include Peano, "negative" numbers arise from the Inverse of Successor applied to zero,
which is sometimes [I believe incorrectly] notated 0-1;  More properly, I might use  --0,
that is, prefix " ++ " for Successor and " -- " for Predecessor, rather than S() or S'() or S^-1(), etc.,
understanding these are NOT "addition" and "subtraction".

{It turns out to be useful to actually define FOUR incremental operators,
one pair to move in positive and negative directions; another to move toward or away from zero.
When doing "recursive induction" algorithms, you are only guaranteed termination if you step toward zero.
These could be accommodated within this syntax scheme by, for example, using prefix for signed step and postfix for "step toward zero",
understanding we have thereby preempted the C-style shortcut notation.)

I would insist on being able to syntactically distinguish an "integer sign" from a "subtraction" or "negation" operator,
at least by some convention, perhaps involving parentheses,
although they admit of polymorphic interpretation.
e.g., to force an interpretation with numbers, use parentheses: hyphen inside (-1)  is sign , hyphen outside  -(1) is negation

Similarly, I would insist on a distinction between a "rational number" and "division".
So my proposed /x <- 1/x  states a "conversion" between a reciprocal number and a quotient.
That is, (/x) = (1)/(x).

In the "Peano Extended" number system I propose, wherein numbers are represented in unary numerals,
the numerals 110, 10, 0, 01, 011 represent, successively, the numbers negative two, negative one, zero, positive one, positive two.
These numbers could also, more generally, be represented by pair of naturals  (p-q): (0-011) (0-01) (0-0) (01-0) (011-0),

The latter suggests a pair representation for rationals, e.g.
one-quarter, one-half, one, two, four could be:
(01/01111), (01/011), (01/01), (011/01), (01111/01).
In general, if p,q,r,s are naturals,
Any pair (p-q) represents an integer, and any pair of pairs (p-q/r-s) represents a rational [where - takes precedence over / ]
[NOTE: one must observe the usual restriction on /0 == "undefined" or "infinity". I prefer the latter, using the Riemann sphere.

The GCD and corresponding algorithm for differences can reduce any such quartet to "lowest terms" for a "normal form."

My next quest is whether this approach can be meaningfully extended to powers, roots, and logs.
-----
From a MathPiper perspective, the question is, can we introduce alternative number representations as well as alternative operators and rules?
I know how to represent such numerals as lists in Scheme; can I do something similar in MathPiper?
BTW, this would have application to conventional algebra in studying alternative number bases.

Speaking of which, does anyone ever cover "Scientific Representation" in math class?
In representing "irrationals" as truncated decimals, we gloss over the fact that we are using only a limited subset of the rationals,
specifically only rationals whose denominator is a power of ten.

But in scientific notation we are essentially performing a quasi-logarithmic transformation using only finite mantissa as well as limiting the denominator to powers of the base.  The fact that this "works" for interpretations of practical calculations is really rather remarkable!
It suggests that "ratio" may be as significant as "count."  Imagine if little kids were taught to do ratios as well as count!


 If you
would like to continue playing with MathPiper after the last lesson
has been submitted, we will probably move the discussion over to the
MathPiper developer list.


I would appreciate the opportunity to continue  explorations of MathPiper.



Steps and integrated ruleset attached, FYI.

New file seems to be working OK.
Thank you.

Ted
joe902-0a.mpw

Joseph Austin

unread,
Jun 11, 2016, 7:19:55 PM6/11/16
to mathf...@googlegroups.com
Ted,
I spent most of the afternoon composing an answer to this,
then apparently I accidentally deleted it.

The new file seems to be working. Thank you.

CAUTION:
With my new operator /x <- 1/x, the form */ is now syntactically meaningful in expressions.
This happens to also be the block comment close delimiter.

So placing block comments around expressions can have unintended effects.

Joe


> On Jun 10, 2016, at 8:02 PM, Ted Kosan <ted....@gmail.com> wrote:
>
joe902-0a.mpw

Ted Kosan

unread,
Jun 12, 2016, 1:47:55 PM6/12/16
to mathf...@googlegroups.com
Joe wrote:

> Consider the expression:
>
> -4*x-2 == -2+x*-4
>
> On the LHS, it is possible to apply the Undefine -q and Undefine q-r rules;
> but they cannot be applied to the -4 and -2 on the RHS.
> In the LHS, the tree reflects the operator role of - , whereas in the RHS,
> the tree reflects the sign role.

This is because near line 57 in the source code for "Manipulate", the
following rule is used to unassign all unary minus operators in an
expression that have a number as an operand before presenting the
expression for manipulation:

expression := (expression /: [-$ q_Number? <- SubtractN(0,1) * q]);

I added this rule because forcing students to unassign these kinds of
expressions appeared to cross a line of being more tedious than what
their educational value is worth. We could use an option to make this
automatic-unassignment behavior optional if people think it is a good
idea.



> This is particularly strange in LHS -4 vs RHS -4
> In fact, in LHS, the -4*x is interpreted as -(4*x) rather than (-4)*x.
> This is non-standard precedence for unary minus. <snip>

This thought and the other ones that are below it would be good topics
for discussion on the mathpiper-dev list after I have submitted the
last lesson. I would really like to determine why the Yacas developers
chose to have the precedence of the unary minus operator be lower than
the precedence of the multiplication operator.

Ted

Joseph Austin

unread,
Jun 12, 2016, 2:06:44 PM6/12/16
to mathf...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages