800 likes | 929 Views
Automated functional program verification using fixpoint fusion. William Sonnex University of Cambridge (Imperial College at heart). Proof by simplification. Start with: Simplify:. Properties provable. Properties proven by current implementation: Properties hopefully provable soon:.
E N D
Automated functional program verification using fixpoint fusion William Sonnex University of Cambridge (Imperial College at heart)
Proof by simplification Start with: Simplify:
Properties provable Properties proven by current implementation: Properties hopefully provable soon:
Functional language used Simply typed lambda calculus with general recursion, absurdityand algebraic data-types (constructors and pattern matching).
Functional language used Simply typed lambda calculus with general recursion, absurdityand algebraic data-types (constructors and pattern matching).
Contents • What is fixpoint fusion? • New technique “fixpoint fission” allows for • How do we prove implications? e.g. • New technique “fold-fix fission” allows us to prove
Fixpoint fusion Turns a context containing a recursive function into just a recursive function:
Fixpoint fusion Three steps to find : • Unwrap the recursive function • Simplify • Replace occurrences of with to get Fails if occurrences of remain in
Fusing reverse and append Let’s run fusion on:
Fix-fix fusion First type/usage of fusion is “fix-fix fusion” (my name) fusing the composition of two fixpoints so will be a fixpoint/recursive function So in we are fusing and So is and is we’ll call , so we are discovering
Fusing • Unwrap • Simplify • Replace with
Fusing So we have discovered: Big deal. This example is done in Wadler’s deforestation paper from 1990. Let’s add some more uses of fusion… (the next stuff is mine.)
Contents • What is fixpoint fusion? • New technique “fixpoint fission” allows for • How do we prove implications? e.g. • New technique “fold-fix fission” allows us to prove
Fixpoint fission This next technique is “fixpoint fission” it is the reverse of fusion: Fusion starts with and and derives Fission starts with and and derives
Fixpoint fission Backwards three steps of fusion: • Start with and replace with • Simplify • Drop to get Fails if not of the form for some
Fissioning Earlier we fused Using simple code analysis we can conjecture that for some
Fissioning We can use “constructor fission” on where and • Start with … and replace with , i.e.
Fissioning • Start with and replace with • Simplify • Drop to get
Fissioning We fissioned from which is -equivalent to so we have found: Woo, lemma discovery using simplification
Fusing With the sub-simplification: We can use fix-fix fusion on: This is a fixpoint fission stepwhere which I don’t have time to explain
Contents • What is fixpoint fusion? • New technique “fixpoint fission” allows for • How do we prove implications? e.g. • New technique “fold-fix fission” allows us to prove
What about implication? So far we have seen simplifications equivalent to equational lemma discovery. Some lemmas feature implication e.g. how do we reason like this within simplification?
What about implication? Some lemmas feature implication e.g. how do we reason like this within simplification? My interpretation of is: If we are down a branch where is pattern matched to then
What about implication? We want: Since we have an inner recursive function () and an outer context (the pattern match) we can use fusion!
What about implication? We want: First we express the pattern match at the location of the recursive function: Now we can run fusion on
What about implication? Now we can run fusion on where and
What about implication? • Unwrap • Simplify
What about implication? • Unwrap • Simplify
What about implication? • Unwrap • Simplify
What about implication? • Unwrap • Simplify
What about implication? • Simplify • Replace occurrences of with
What about implication? We have fused with yielding: which simplifies to just:
Recap of match-fix fusion We had: We expressed where was:We ran fusion:I call this match-fix fusion
Match-fix fusion But what about properties with multiple antecedents?This corresponds to multiple pattern matches: We could run one big fusion step…
Match-fix fusion We could run one big fusion step: But there is no need, we can fuse each match in one by one:
Match-fix fusion We can always fuse matches in one by one with no loss of simplifiability(proven) Consider:Certain definitions of here will block induction hence ACL2 has heuristics for dropping antecedentsFusion of just fails and we move on no heuristics needed!
Compositionality of fusion Fusion is a compositional approach each step can be run one by one, e.g.
Compositionality of fusion Fusion is a compositional approach each step can be run one by one, e.g.
Compositionality of fusion Fusion is a compositional approach each step can be run one by one, e.g.
Compositionality of fusion Fusion is a compositional approach each step can be run one by one, e.g.
Compositionality of fusion Fusion is a compositional approach each step can be run one by one, e.g.
Compositionality of fusion Fusion is a compositional approach each step can be run one by one, e.g.
Compositionality of fusion Fusion is a compositional approach each step can be run one by one, e.g.
Fusion doesn’t require search Simplifications are fully automatic. If they happen in isolation they’ll happen in a larger proof/simplification.If a proof needs we don’t need to provide the lemma we don’t need rules to guide rewriting (like rippling).
So far… Fix-fix fusion, constructor fission and match-fix fusion can solve almost all of the properties I tested Zeno on. Notably All of the above has been implemented. Now I will demonstrate the next phase of my work which simplifies
Contents • What is fixpoint fusion? • New technique “fixpoint fission” allows for • How do we prove implications? e.g. • New technique “fold-fix fission” allows us to prove
Verifying Proving requires the lemma: This lemma is not a generalisation of a sub-goal (sorry ACL2). This lemma contains functions which are not in the original definition, (sorry HipSpec).
Verifying We start with: Mathematically impossibleto fuse with