280 likes | 600 Views
Quang M. Tran E-mail: tranqm@mcmaster.ca. Isabelle / HOL Theorem Proving System. Course: CAS760 Logic for Practical Use Instructor: Dr. William M. Farmer Department of Computing and Software McMaster University, ON, Hamilton, Canada. Outline. History overview
E N D
Quang M. Tran E-mail: tranqm@mcmaster.ca Isabelle / HOL Theorem Proving System Course: CAS760 Logic for Practical Use Instructor: Dr. William M. Farmer Department of Computing and Software McMaster University, ON, Hamilton, Canada
Outline • History overview • Isabelle / HOL first taste: screenshot + Prove: rev (rev list) = list • Isabelle / HOL: big picture + terminologies • Natural deduction: Prove P v Q => Q v P • Isabelle classical reasoner • References + Conclusion • Conclusion Isabelle / HOL
History: All started with Robin Milner • British computer scientist. • 1972: Milner developed proof checker for Scott’s “Logic for Computable Functions” (LCF) at Stanford (known as “Stanford LCF” ). • 1973: Milner moved to Edinburgh and started the successor project “LCF Edinburgh”. ML language is born in this time. • 1981: Mike Gordon joined Cambridge and HOL was born. • 1990s: Larry Paulson developed Isabelle. Milner Paulson Isabelle / HOL
Isabelle / HOL first taste : Fun with (Toy)List • (*ToyList.thy*) • theory ToyList • imports Datatype • begin • (*Datatype of list*) • datatype'a list = Nil ("[]") • | Cons 'a "'a list" (infixr ":" 65) • … (contd. next slide) CAS760: list as inductive data type,remember? Isabelle / HOL
Isabelle / HOL first taste (contd.) • (*Functions on lists*) • primrecconcat :: "'a list => 'a list => 'a list" (infixr “++" 65) • where • "[] ++ ys = ys" | • "(x : xs) ++ ys = x : (xs ++ ys)“ • primrec rev :: "'a list => 'a list" where • "rev [] = [] " | • "rev (x : xs) = (rev xs) ++ (x : [])" “++” is defined by primitive recursion. Isabelle / HOL
Proof: rev (rev list) = list Generate subgoals Simplified Simplified … theoremrev_rev [simp]: "rev(rev xs) = xs” apply(induct_tacxs) (*Apply induction tactic*) apply(auto) (*Try to solve “automatically” using simplifier) … Isabelle / HOL
Proof (contd.) We need a lemma Find subgoals … lemma rev_app [simp]: "rev(xs ++ ys) = (rev ys) ++ (rev xs)" apply(induct_tacxs) (*Apply induction tactic on xs*) apply(auto) (*Try to solve “automatically” using simplifier) … Isabelle / HOL
Complete Proof: rev(rev list) = list • … • lemmaapp_assoc [simp]: "(xs ++ ys) ++ zs = xs ++ (ys ++ zs)" • apply(induct_tacxs) • apply(auto) • done • lemma app_Nil2 [simp]: "xs ++ [] = xs" • apply(induct_tacxs) • apply(auto) • done • lemmarev_app [simp]: "rev(xs ++ ys) = (rev ys) ++ (rev xs)" • apply(induct_tacxs) • apply(auto) • done • theoremrev_rev [simp]: "rev(rev xs) = xs" • apply(induct_tacxs) • apply(auto) • done We need to prove 3 supporting lemmas , i.e. “Backward” proof This is the theorem what we want to prove Isabelle / HOL
Isabelle: big picture (X)EmacsGUI for theorem provers A concrete Isabelle instance for Higher-Order-Logic (HOL) Proof General For Isabelle Isabelle / HOL Isabelle / Your Logic Here Isabelle / ZF Provides a generic infrastructure to develop theorem provers. Isabelle Isabelle / HOL
Theorem proving terminologies Isabelle / HOL
Natural deduction • By the German mathematician and logician Gentzen. • Motivation: Logical formalism that occurs “naturally” (closely to human reasoning). • Assume: “If pigs can fly, then there are green men on Mars” is true. • You see a pig flies in Hamilton? Then there are green men on Mars! Gentzen Modus Ponens. This is true for arbitrary P, Q Isabelle / HOL
Natural deduction: Inference rules Conjunction elim. Conjunctionintro. Disjunction elim. Disjunctionintro. Implication elim. (modus pones !) Implicationintro. Isabelle / HOL
Natural deduction (contd.) Universal quantifierintro. Universal quantifierelim. Existential quantifierintro. Existential quantifierelim. Isabelle / HOL
Proof: P v Q => Q v P • lemma disj_swap: "P v Q => Q v P" • apply (eruledisjE) • Subgoals: • P => Q v P (1) • Q => Q v P (2) • apply (rule disjI2) • Subgoal: • P => P • apply assumption • (*Likewise for (2)*) • apply (rule disjI1) • apply assumption • done Applies disjunction elim. rule: • Applies disjunction intro. rule (2) : Isabelle / HOL
Isabelle’s classical reasoner • lemma disj_swap2: "P v Q => Q v P" • apply (blast) • No subgoals! • Done! • Working with primitive rules like before are tedious. • Classical reasoner= a family of tools that perform proofs automatically. • Examples: blast method. “blast“ can solve this automatically Isabelle / HOL
Proof: P v Q => Q v P • Demo Isabelle / HOL
References • Isabelle newcomers:A Proof Assistant for Higher-Order Logic, written by Isabelle authors e.g. C. Paulson, online PDF available. • Historical development:From LCF to HOL: a short history , Mike Gordon and The next 700 Theorem Provers, C. Paulson. • Theorem prover design techniques:Design a Theorem Prover, C. Paulson. Isabelle / HOL
Conclusion: Should I bother with Isabelle? • If you need computer-aided proofs, e.g. formal verification. • If you want to deepen your knowledge in logics / mathematics / functional programming. • If you have interest in mechanizing mathematics. • … then the answer is Yes. • Isabelle can be used as a tool to get work done or simply a platform to experiment and study. Isabelle / HOL
Acknowledgements • The author is grateful to TianZhang, Eden Burton and BojanNokovic (ITB 206) for their very useful feedbacks while preparing this presentation. Create your first workbook
The End • Comments? • Questions? Isabelle / HOL