Farmer - Equational reasoning in HERMIT (Haskell15)
FP encourages equational reasoning!
In Haskell, in practice: type class laws, RULES
Reasoning by hand: tedious! Easy to gloss over details without mechanical support. (So not done in practice)
HERMIT: interactive/scripted transformation on core
IDEA: add lemmas to HERMIT. Equivalences beween core expressions; support conjunction, disjunction, implication, quantification
Then redo KURE, transformations on lemmas, rather than on expressions.
Case study: type class laws, Pearls of Functional Algorithm Design
(ezyang: Soundness????)
Property:
filter (good . value) = filter (good . value) . filter (ok . value)
Workflow: state it as a RULE, then appeal to a general lemma
(some mucking about)
Mostly a lot of simplification and unfolding. Some practical aspects: getting unfoldings and coercions.
Q: About the proof you showed: not q imples not p of x.... I would have written it p implies q. Is this for a technical reason?
A: No, I happened to type the letters in that order. I probably started writing on the right hand side, and then wrote the left hand side.
Q: Do you have any format for Hermit itself? Semantics?
A: There's not formal logic or semantics. Your ability to demonstrate truth is based on what you can transform. All transforms are assumed to be correct. I would love to dive into that and prove some things are actually valid to use in all cases...
Q: Have you tried to use this script for a proof on a slightly different program, to see how much has to change?
A: The nice thing about universally quantified variables in lemmas is we can prove a general property; this property, we didn't assume it, I proved it. You can generally use it in other cases. You can use these commands in the consequent to apply them to it... the reuse story is better than before. It's all user directed, so you still have to point to a poin in the program. We haven't done a whole bunch of work in taking one transformation and applying to programs; ust concat vanishing transformations. We have one script.... (Did you say we'd be able to write tactics in Haskell?) Hopefully once the ghci basis works, instead of writing into a scripting language to KURE, you should just write KURE combinators directly.
Q: (Gundry) You mentioned a problem with newtype coercions getting in the way. What about reasoning with representational equality, rather than nominal equality.
A: No, haven't thought about it. ... I don't know. Thus far, we've gotten away with "get rid of this type of transformation" to move them out of the way. But no, we haven't looked into redefining what we consider equality. (Do you represent coercions explicitly in... the output?) I don't show them but we use the same syntax you would see in Richard's PDF, the little right hand triangle with the type equality on the RHS. The pretty-printer makes them look nice, you can abstract them if you don't want to look at them.
















