12.07.2015 Views

Tutorial on Isabelle/HOL

Tutorial on Isabelle/HOL

Tutorial on Isabelle/HOL

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

32 3. More Functi<strong>on</strong>al ProgrammingThe simplifier does not split case-expressi<strong>on</strong>s, as it does if-expressi<strong>on</strong>s, becausewith recursive datatypes it could lead to n<strong>on</strong>terminati<strong>on</strong>. Instead, thesimplifier has a modifier split for adding splitting rules explicitly. The lemmaabove can be proved in <strong>on</strong>e step byapply(simp split: list.split)whereas apply(simp) al<strong>on</strong>e will not succeed.Every datatype t comes with a theorem t.split which can be declaredto be a split rule either locally as above, or by giving it the split attributeglobally:declare list.split [split]The split attribute can be removed with the del modifier, either locallyapply(simp split del: split_if)or globally:declare list.split [split del]Polished proofs typically perform splitting within simp rather than invokingthe split method. However, if a goal c<strong>on</strong>tains several if and caseexpressi<strong>on</strong>s, the split method can be helpful in selectively exploring theeffects of splitting.The split rules shown above are intended to affect <strong>on</strong>ly the subgoal’sc<strong>on</strong>clusi<strong>on</strong>. If you want to split an if or case-expressi<strong>on</strong> in the assumpti<strong>on</strong>s,you have to apply split_if_asm or t.split_asm:lemma "if xs = [] then ys ≠ [] else ys = [] =⇒ xs @ ys ≠ []"apply(split split_if_asm)Unlike splitting the c<strong>on</strong>clusi<strong>on</strong>, this step creates two separate subgoals, whichhere can be solved by simp_all:1. [[xs = []; ys ≠ []]] =⇒ xs @ ys ≠ []2. [[xs ≠ []; ys = []]] =⇒ xs @ ys ≠ []If you need to split both in the assumpti<strong>on</strong>s and the c<strong>on</strong>clusi<strong>on</strong>, use t.splitswhich subsumes t.split and t.split_asm. Analogously, there is if_splits.!!The simplifier merely simplifies the c<strong>on</strong>diti<strong>on</strong> of an if but not the then orelse parts. The latter are simplified <strong>on</strong>ly after the c<strong>on</strong>diti<strong>on</strong> reduces to Trueor False, or after splitting. The same is true for case-expressi<strong>on</strong>s: <strong>on</strong>ly the selectoris simplified at first, until either the expressi<strong>on</strong> reduces to <strong>on</strong>e of the cases or it issplit.3.1.10 TracingUsing the simplifier effectively may take a bit of experimentati<strong>on</strong>. Set theProof General flag <strong>Isabelle</strong> > Settings > Trace Simplifier to get a better ideaof what is going <strong>on</strong>:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!