Answers.Body: <p>What you're asking here is actually not reasoning but rather symbolic computation. <a href="https://www.sympy.org/en/index.html" rel="nofollow noreferrer"> Sympy</a> is an example of a library which does it.</p>
  <p>Explaining computer algebra systems could be a series of lectures and this is too broad for a single question. To give you an idea: (1) represent equations symbolically (2) bring them in a normal form (3) substitute.</p>
  <p>Although it is not elegant, you can simplify the problem by brute Force: try all combinations of solving for a variable and substituting it in the other equations.</p>
  <p>Related:</p>
  <ul>
  <li><a href="https://math.stackexchange.com/q/532897/6876">How do symbolic math software work? | Mathematics Stack Exchange</a></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-15T06:56:07.867Z
Answers.LastActivityDate: 2021-04-17T21:54:15.017Z
Answers.LastEditDate: 2021-04-17T21:54:15.017Z
Answers.UserDisplayName: Martin Thoma
Answers.Body: <p>I would turn this problem into graph search in which vertices are &quot;equivalent sets of equations&quot; and edges are &quot;valid operations&quot; such as such as substitution, division and so on, which always ensure that all states are mathematically equivalent. A very simple example of a few states and edges (to requote from your question):</p>
  <pre><code>State 0:
    Eq. 1: a = b + c;
    Eq. 2: s = b / a;
    Eq. 3: r = b / c.
  
  Operation 0--&gt;1:
    Multiply Eq. 3 by c
  
  State 1:
    Eq. 1: a = b + c;
    Eq. 2: s = b / a;
    Eq. 3: rc = b.
  
  Operation 0--&gt;2:
    Substitute Eq 1 into 2
  
  State 2:
    Eq. 1: a = b + c;
    Eq. 2: s = b / (b+c);
    Eq. 3: r = b / c.
  
  Operation 2--&gt;3:
    Rearrange Eq 3 so B is on right hand side.   
  
  etc etc
  </code></pre>
  <p>Depending on how many operations you have, this does mean that the graph could be quite large, so you may not want to generate the entire graph (actually, the graph will be infinite if the number of operations allowed is unlimited). It's also possible that the graph will contain cycles, since there may be multiple ways to reach the same state.</p>
  <p>You will have to think about how to develop data structures for representing the states and operations. Since this is a search problem, it will help to define what your &quot;goal&quot; states look like (e.g. states where <em>s</em> is defined in terms of <em>r</em>).</p>
  <p>To search the graph, I recommend one of these approaches:</p>
  <ul>
  <li>Breadth-first search: this will find the shortest number of operations needed to reach any goal states</li>
  <li>Best-first search: if the graph is too large for breadth first, you may need to guide the search to the goal states using a heuristic, e.g. you could rate states by how few variables are needed on the LHS of equations or something like that -- some experimentation will be needed here.</li>
  </ul>
  <p>The exact choice of search algorithm will depend on how big the graph is, which in turns depends on how many operations/edges you want.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-17T22:42:56.890Z
Answers.LastActivityDate: 2021-04-17T23:02:59.493Z
Answers.LastEditDate: 2021-04-17T23:02:59.493Z
Answers.UserDisplayName: Mike NZ
Body: <p>I have three equations that relates five variables <em>{a, b, c, r, s}</em> with a sum and two ratios.</p>
  
  <pre>
  Eq. 1: a = b + c;
  Eq. 2: s = b / a;
  Eq. 3: r = b / c.
  </pre>
  
  <p>Given two values for any of the five variables I get a solution. But, this is not the automation problem I want to solve.</p>
  
  <p>I can have the solution of variable <em>r</em> by simply knowing <em>s</em>. This is solved by a "human algorithm" as follows.</p>
  
  <ol>
  <li>Substitute a of Eq. 1 in Eq. 2.
  <li>Divide the second term of the new Eq. 2 by the variable c.
  <li>Replace b/c by the expression of Eq. 3.
  </ol>
  
  <p>That means s = r / (r+1).</p>
  
  <p>The questions is -How can an AI algorithm solve this?, i.e. the machine should recognize that given the variable <em>r</em> she can obtain directly the variable <em>s</em> and do no require another variable.</p>
  
Tags: <math><reasoning>
Title: Machine mathematical reasoning by clever substitutions, How to do with AI
UserDisplayName: LudgerSB
ThreadText: # Machine mathematical reasoning by clever substitutions, How to do with AI
  
  (Asked by: username_0 on 2018-11-15)
  
  I have three equations that relates five variables *{a, b, c, r, s}* with a sum and two ratios.
  
  ```
  
  Eq. 1: a = b + c;
  Eq. 2: s = b / a;
  Eq. 3: r = b / c.
  
  ```
  
  Given two values for any of the five variables I get a solution. But, this is not the automation problem I want to solve.
  
  I can have the solution of variable *r* by simply knowing *s*. This is solved by a "human algorithm" as follows.
  
  1. Substitute a of Eq. 1 in Eq. 2.
  2. Divide the second term of the new Eq. 2 by the variable c.
  3. Replace b/c by the expression of Eq. 3.
  
  That means s = r / (r+1).
  
  The questions is -How can an AI algorithm solve this?, i.e. the machine should recognize that given the variable *r* she can obtain directly the variable *s* and do no require another variable.
  
  **Tags:** math, reasoning
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-11-15. Score: 2
  
  What you're asking here is actually not reasoning but rather symbolic computation.  [Sympy](https://www.sympy.org/en/index.html) is an example of a library which does it.
  
  Explaining computer algebra systems could be a series of lectures and this is too broad for a single question. To give you an idea: (1) represent equations symbolically (2) bring them in a normal form (3) substitute.
  
  Although it is not elegant, you can simplify the problem by brute Force: try all combinations of solving for a variable and substituting it in the other equations.
  
  Related:
  
  * [How do symbolic math software work? | Mathematics Stack Exchange](https://math.stackexchange.com/q/532897/6876)
  
  
  ---
  
  ### Answer by username_2 on 2021-04-17. Score: 1
  
  I would turn this problem into graph search in which vertices are "equivalent sets of equations" and edges are "valid operations" such as such as substitution, division and so on, which always ensure that all states are mathematically equivalent. A very simple example of a few states and edges (to requote from your question):
  
  ```
  State 0:
    Eq. 1: a = b + c;
    Eq. 2: s = b / a;
    Eq. 3: r = b / c.
  
  Operation 0-->1:
    Multiply Eq. 3 by c
  
  State 1:
    Eq. 1: a = b + c;
    Eq. 2: s = b / a;
    Eq. 3: rc = b.
  
  Operation 0-->2:
    Substitute Eq 1 into 2
  
  State 2:
    Eq. 1: a = b + c;
    Eq. 2: s = b / (b+c);
    Eq. 3: r = b / c.
  
  Operation 2-->3:
    Rearrange Eq 3 so B is on right hand side.   
  
  etc etc
  
  ```
  
  Depending on how many operations you have, this does mean that the graph could be quite large, so you may not want to generate the entire graph (actually, the graph will be infinite if the number of operations allowed is unlimited). It's also possible that the graph will contain cycles, since there may be multiple ways to reach the same state.
  
  You will have to think about how to develop data structures for representing the states and operations. Since this is a search problem, it will help to define what your "goal" states look like (e.g. states where *s* is defined in terms of *r*).
  
  To search the graph, I recommend one of these approaches:
  
  * Breadth-first search: this will find the shortest number of operations needed to reach any goal states
  * Best-first search: if the graph is too large for breadth first, you may need to guide the search to the goal states using a heuristic, e.g. you could rate states by how few variables are needed on the LHS of equations or something like that -- some experimentation will be needed here.
  
  The exact choice of search algorithm will depend on how big the graph is, which in turns depends on how many operations/edges you want.
  
  
  ---
  
  