Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a tool interface for Mathematica's AsymptoticDSolveValue command. #84

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

nrfulton
Copy link
Member

This pull request contains an interface for Mathematica's AsymptoticDSolveValue and also exposes a CLI interface to this tool. The roadmap here is to rewrite the series approximation tactics so that they are more general, and also incorporate this tactic into master (for proving systems where there are either numeric or approximation-looking pre/post-conditions). I'm including just the Tool in a first pull request because the implementation details require significant consideration.

The AsymptoticDSolveValue tool itself is not soundness-critical. However, this pull request does contain some changes that perhaps require review/consideration prior to merging:

  • I've added support for Mathenatica's default/constant syntax in the m2k/k2m conversions. NB: Reduce can return results that contain C[]'s, so this is possibly soundness critical. However, I'm fairly certain that the particular inputs we give to Reduce will never result in return values that contain C[] (after all, we haven't known how to translate those until now). So, I'm (a) pretty sure C[]s will not show up in the QE tool code and (b) even if they do not sure if that would break soundness. So, whether it makes sense to convert C[]'s -- or especially whether it makes sense to add some logic that prevents QE tools from knowing about C[]'s -- is perhaps a reasonable thing to discuss before merging this pull request.
  • Should the DifferentialProgram k2m code be refaoctored? It currently exists in both the DSolve tool and the AsymptoticDSolveValue tool. Will there be other tools that send ODEs to Mathematica? If so, it might make sense to do a pretty significant refactor so that it's easier to generate Mathematica code from ODEs (e.g., systematic handing of ev dom constraints, initial conditions, etc.). Not sure this refactoring is needed before merging, but something to add to a TODO for next time an ODE tool is added.

nrfulton added 15 commits June 22, 2021 12:08
The executor may be null if a tool or subtool isn't initialized before use.
This can happen, e.g., when adding a new subtool to the main Mathematica tool and
forgetting about the various pieces of boilerplate (calling .init, .shutdown, etc. in the
relevant methods of the Mathematica tool).

I've run into this issue a few times now, and I always lose a significant amount of time before
remember that tools have state and associated protocols. Hopefully this error message will make
tool extension/development easier.
Mathematica uses C[i] as its default form for parameters/constants.
For example, when computing series approxiamtions to solutions of ODEs, C[i]
is used to represent the constant of integration.

Perhaps a better way of handling this is to ensure that we never get C[i] back from
Mathematica. This can be achieved by always specifying initial conditions in calls to solvers.
For example, instead of:

```
AsymptoticDSolveValue[
  {
    x'[t] == y[t],
    y'[t] == x[t],
    y[0] == x0,
    x[0] == y0
  },
  {x[t], y[t]},
  {t, 0, 10}
]
```

instead do:

```
AsymptoticDSolveValue[
  {
    x'[t] == y[t],
    y'[t] == x[t],
    y[0] == x0,
    x[0] == y0
  },
  {x[t], y[t]},
  {t, 0, 10}
]
```

and then handle x0 and y0 before passing formulas back out of the tool.

Note: this is not currently used in any soundness-critical way that I'm aware of,
but both Reduce and DSolve are capable of generating C[i] symbols. Therefore,
we should do a thorough check that C[i]s are never handed back to us when not expected
or else revert this commit.

See https://reference.wolfram.com/language/ref/C.html for more information on what C[i]
is used for in Mathematica.
Note: this code would already written in the DSolve tool, and now
exists in two different places. We should unify this code and clean up
the interface to the DifferenitalProgram converter.
The executor may be null if a tool or subtool isn't initialized before use.
This can happen, e.g., when adding a new subtool to the main Mathematica tool and
forgetting about the various pieces of boilerplate (calling .init, .shutdown, etc. in the
relevant methods of the Mathematica tool).

I've run into this issue a few times now, and I always lose a significant amount of time before
remember that tools have state and associated protocols. Hopefully this error message will make
tool extension/development easier.
Mathematica uses C[i] as its default form for parameters/constants.
For example, when computing series approxiamtions to solutions of ODEs, C[i]
is used to represent the constant of integration.

Perhaps a better way of handling this is to ensure that we never get C[i] back from
Mathematica. This can be achieved by always specifying initial conditions in calls to solvers.
For example, instead of:

```
AsymptoticDSolveValue[
  {
    x'[t] == y[t],
    y'[t] == x[t],
    y[0] == x0,
    x[0] == y0
  },
  {x[t], y[t]},
  {t, 0, 10}
]
```

instead do:

```
AsymptoticDSolveValue[
  {
    x'[t] == y[t],
    y'[t] == x[t],
    y[0] == x0,
    x[0] == y0
  },
  {x[t], y[t]},
  {t, 0, 10}
]
```

and then handle x0 and y0 before passing formulas back out of the tool.

Note: this is not currently used in any soundness-critical way that I'm aware of,
but both Reduce and DSolve are capable of generating C[i] symbols. Therefore,
we should do a thorough check that C[i]s are never handed back to us when not expected
or else revert this commit.

See https://reference.wolfram.com/language/ref/C.html for more information on what C[i]
is used for in Mathematica.
Note: this code would already written in the DSolve tool, and now
exists in two different places. We should unify this code and clean up
the interface to the DifferenitalProgram converter.
@nrfulton
Copy link
Member Author

To reiterate, I'm not so sure this merge request should be accepted as-in. Primarily, I want to get opinions on whether the addition of C[] in the translations is reasonable/safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant