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

More principled logging and observation of proof state #4

Open
martinberger opened this issue Feb 9, 2023 · 1 comment
Open

More principled logging and observation of proof state #4

martinberger opened this issue Feb 9, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@martinberger
Copy link
Owner

Currently, the implementation follows [1] in that we have the Thm class, tactics and all proof state handling use the Option monad. Logging, and observation of proof state is done by printing to the command line. It might be worthwhile to be more principle here, and using an Either monad instead or similar abstractions.


  1. D. P. Mulligan, Mosquito: an implementation of higher-order logic (Rough diamond)
@martinberger martinberger added the enhancement New feature or request label Feb 11, 2023
@martinberger
Copy link
Owner Author

martinberger commented Feb 14, 2023

Here is an elaboration of the issues with several possible approaches. Currently debugging is difficult because ad-hoc, and needs recompilation to switch on/off debugging and logging. Typically we want to hone in on where a proof starts to fail, but not how we got there. So we are interested in getting:

  • Which tactic used just before the proof fails?
  • What was the proof state just before failure?

This suggests that we add principled mechanisms for logging and printing:

  • proof state
  • tactics used
  • mechanisms for switching on/off the above

Here are some ideas on how to do this (not mutually exclusive):

  • Ideal: trace state + tactics and by default, if proof fails, return last $N$ used tactic, and proof states before failure (with $N=1$ being the default). This could be implemented in several ways:

    • Stateful: maintain a list of tactics used and proof state. (Trivial to implement.)
    • Pure: with a logging monad. (Clean but more work.)
  • Have suitable (pre-)tactics "switch on printing" and "switch off printing" with options for state and used-tactic printing. This is really easy to implement. This should be at the pre-tactic level and not tactics (as it is now) since most proofs are specified as a list of pre-tactics.

  • Augment the Try tactic so it automatically prints out used tactic and state in case of failure. When this integrated with the makeGeneric function, this requires no changes with current test suite.

  • Even less invasive than the last bullet is also using the OrElse and FailWith tactics as follows. Typically a proof is a list of pretactics like so

     Apply(pt1), ..., Apply(pt17)
    

    which we replace by

     OrElse(Apply(pt1), AndThen(PrintState(), FailWith(s"last used: ${pt1.toString}"))), ...
    

    Note that this transformation cannot be expressed in the tactics DSL, but uses the meta-language. Should this be seen as an expressive weakness of the tactics DSL?

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

No branches or pull requests

1 participant