Hi,
I'm not sure this would be that simple. The PG language currently
fineses the problem
of determining whether two expressions are equivalent by using
numerical checking rather
than symantic comparisons. Roughly speaking two functions are
"equivalent" if they produce
the same output at 5 randomly selected inputs. This works surprisingly
well, although for certain types of answers one has to be careful about
the domain and about round-off error.
By this rule, x^2+2x+1 and (x+1)^2 are indistinguishable (which is often what you want).
Checking the answer by pattern matching could get somewhat involved. For example
(x +1)(x+1), (x+1)^2, (1+x)(1+x), (x+1)(1+x), ((cos(x)^2+(sin(x))^2 +x)^2 are all
correct answers. It seems to me that trying to catch all of these soon leads you to reinventing
Mathematica or Maple, not just the PG language parser.
It is feasible to write an answer evaluator which calls Maple or
Mathematica from within perl
to check whether two expressions are equivalent, but I'm not sure that
even Maple would recognize the last example above as correct. Calling
Maple or Mathematica would also be a pretty hefty use
of computing resources.
Breaking the parser into more manageable pieces, or allowing it to be
customized more easily,
is a good idea in any case, but it will take some time to implement.
Bill Wheeler at Indiana University has made some progress in this
direction.
-- Mike
<| Post or View Comments |>
|