google / mathsteps

Step by step math solutions for everyone
https://socratic.org
Apache License 2.0
2.12k stars 275 forks source link

Keep track of solution constraints #114

Open kevinbarabash opened 7 years ago

kevinbarabash commented 7 years ago

As mentioned in https://github.com/socraticorg/mathsteps/pull/88 we should keep track of solution constraints. For example:

2 = (x^2 - 1)/(x-1)
=> 2 = ((x+1)*(x-1))/(x-1)
=> 2 = x+1
=> x = 1  // not a valid answer

The domain of the initial expression is x != 1. The domain should be maintained throughout so that we can identify answers which are invalid.

evykassirer commented 7 years ago

relevant conversation from #88:

We don't have anything that stores information like that yet. Do you think adding it to the NodeStatus object would be a good way to do it?

a new NodeStatus object is created for each step, right? If that's the case we'd probably want to copy any solution constraints to all subsequent steps so that it's easy to check. Any new solution constraints would have to be unioned with previous ones. The concept of solution constraints could also be applied to things like nthRoot(x) and other functions in the future.

and my reply to this:

yes, that's what I was thinking :)

I don't think there's an easy way to pass things between NodeStatuses right now, but we could refactor that to make it work I think.

aelnaiem commented 7 years ago

Interesting! Yea there's definitely something to having the SolutionStatus or something higher level. It could even be something passed from node status to node status... It also makes me think about how we'll manage multiple equations when we add systems of equations support in the future...

hmaurer commented 7 years ago

I think we should consider "domain tracking" for variables in any context, not just systems of equations. It it often convenient to ask the system to simplify an expression under some assumptions.

Regarding "domain tracking" for variables per se @sangwinc might have some advice; he has done research on the issue (as far as I understand): https://dspace.lboro.ac.uk/dspace-jspui/bitstream/2134/17434/1/AuditedAlgebra.pdf

kevinbarabash commented 7 years ago

Cool doc. Using intersection and union of relations to describe the domain makes sense. It's interesting that the domains can change as subsequent steps are taken. Their definition of natural domain is a bit hand wavy since they decide to use Reals as their base field even though Complex would allow for more solutions in some cases. I would encourage us to to be explicit about which field is being used in a solution even if it's always the Reals for the time being.