Interactive Formal Verification Review (17) 1-7.pdfInteractive Formal Verification Review (17) Tjark...

Post on 18-Aug-2019

215 views 0 download

transcript

   

Interactive Formal VerificationReview (1­7)

Tjark WeberComputer Laboratory

University of Cambridge

   

Isabelle Theories

theory T imports Main A B

begin

end

   

Isabelle Theories

theory T imports Main A B

begin

end

Name of the theory

   

Isabelle Theories

theory T imports Main A B

begin

end

Names of existing theories

Name of the theory

   

Isabelle Theories

theory T imports Main A B

begin

end

Names of existing theoriesMain: contains all of Isabelle/HOL

Name of the theory

   

Defining Types

● typedecl ('a,'b) t

   

Defining Types

● typedecl ('a,'b) tIntroduces an unspecified type

   

Defining Types

● typedecl ('a,'b) tIntroduces an unspecified type

Optional: type arguments

   

Defining Types

● typedecl ('a,'b) t

● type_synonym 'a multiset = "'a => nat"

Introduces an unspecified type

Optional: type arguments

   

Defining Types

● typedecl ('a,'b) t

● type_synonym 'a multiset = "'a => nat"

Introduces a new name for an existing type

Optional: type arguments

Introduces an unspecified type

   

Defining Types

● typedecl ('a,'b) t

● type_synonym 'a multiset = "'a => nat"

● datatype 'a list = Nil | Cons 'a "'a list"

Optional: type arguments

Introduces an unspecified type

Introduces a new name for an existing type

   

Defining Types

● typedecl ('a,'b) t

● type_synonym 'a multiset = "'a => nat"

● datatype 'a list = Nil | Cons 'a "'a list"

Optional: type arguments

Defines an inductive datatype

Introduces an unspecified type

Introduces a new name for an existing type

   

Defining Types

● typedecl ('a,'b) t

● type_synonym 'a multiset = "'a => nat"

● datatype 'a list = Nil | Cons 'a "'a list"

Optional: type arguments

Defines an inductive datatype

Constructor names and argument types

Introduces an unspecified type

Introduces a new name for an existing type

   

Defining Constants

● definition even :: "nat => bool" where "even n = (∃k. n = 2*k)"

   

Defining Constants

● definition even :: "nat => bool" where "even n = (∃k. n = 2*k)"

For non-recursive definitions

   

Defining Constants

● definition even :: "nat => bool" where "even n = (∃k. n = 2*k)"

For non-recursive definitions Optional: the constant's type

   

Defining Constants

● definition even :: "nat => bool" where "even n = (∃k. n = 2*k)"

For non-recursive definitions Optional: the constant's type

Provides a lemma: even_def

   

Defining Constants

● definition even :: "nat => bool" where "even n = (∃k. n = 2*k)"

● fun even' where "even' 0 = True"| "even' (Suc 0) = False"| "even' n = even' (n-2)"

For non-recursive definitions Optional: the constant's type

Provides a lemma: even_def

   

Defining Constants

● definition even :: "nat => bool" where "even n = (∃k. n = 2*k)"

● fun even' where "even' 0 = True"| "even' (Suc 0) = False"| "even' n = even' (n-2)"

For non-recursive definitions Optional: the constant's type

Provides a lemma: even_defFor recursive functions

   

Defining Constants

● definition even :: "nat => bool" where "even n = (∃k. n = 2*k)"

● fun even' where "even' 0 = True"| "even' (Suc 0) = False"| "even' n = even' (n-2)"

For non-recursive definitions Optional: the constant's type

Provides a lemma: even_def

Provides even'.simps and even'.induct

For recursive functions

   

Defining Constants

● inductive_set tclfor R :: "('a*'a) set"where "(x,y):R ==> (x,y):tcl R"| "(x,y):tcl R ==> (y,z):tcl R ==> (x,z):tcl R"

   

Defining Constants

● inductive_set tclfor R :: "('a*'a) set"where "(x,y):R ==> (x,y):tcl R"| "(x,y):tcl R ==> (y,z):tcl R ==> (x,z):tcl R"

For inductive sets

   

Defining Constants

● inductive_set tclfor R :: "('a*'a) set"where "(x,y):R ==> (x,y):tcl R"| "(x,y):tcl R ==> (y,z):tcl R ==> (x,z):tcl R"

For inductive sets Optional: the constant's type

   

Defining Constants

● inductive_set tclfor R :: "('a*'a) set"where "(x,y):R ==> (x,y):tcl R"| "(x,y):tcl R ==> (y,z):tcl R ==> (x,z):tcl R"

For inductive sets

Parameters (types are optional again)

Optional: the constant's type

   

Defining Constants

● inductive_set tclfor R :: "('a*'a) set"where "(x,y):R ==> (x,y):tcl R"| "(x,y):tcl R ==> (y,z):tcl R ==> (x,z):tcl R"

For inductive sets

Provides tcl.cases, tcl.induct,tcl.intros and tcl.simps

Optional: the constant's type

Parameters (types are optional again)

   

Theorems and Proofs

● lemma add_com [simp]: "x+y = y+x"● apply method● done● by method● oops● sorry

   

Theorems and Proofs

● lemma add_com [simp]: "x+y = y+x"● apply method● done● by method● oops● sorry

Starts a proof

   

Theorems and Proofs

● lemma add_com [simp]: "x+y = y+x"● apply method● done● by method● oops● sorry

Starts a proofOptional: a name and attributes

   

Theorems and Proofs

● lemma add_com [simp]: "x+y = y+x"● apply method● done● by method● oops● sorry

Starts a proofOptional: a name and attributes

Modifies some subgoal(s)

   

Theorems and Proofs

● lemma add_com [simp]: "x+y = y+x"● apply method● done● by method● oops● sorry

Starts a proofOptional: a name and attributes

Modifies some subgoal(s)

Finishes a proof

   

Theorems and Proofs

● lemma add_com [simp]: "x+y = y+x"● apply method● done● by method● oops● sorry

Starts a proofOptional: a name and attributes

Modifies some subgoal(s)

Finishes a proof

Finishes a proof in a single step

   

Theorems and Proofs

● lemma add_com [simp]: "x+y = y+x"● apply method● done● by method● oops● sorry

Starts a proofOptional: a name and attributes

Modifies some subgoal(s)

Finishes a proof

Finishes a proof in a single step

Aborts a proof attempt

   

Theorems and Proofs

● lemma add_com [simp]: "x+y = y+x"● apply method● done● by method● oops● sorry

Starts a proofOptional: a name and attributes

Modifies some subgoal(s)

Finishes a proof

Finishes a proof in a single step

Aborts a proof attempt

Finishes a proof (cheating!)

   

Automated Proof Methods

● (induct x y arbitrary: z rule: r.induct)● (simp add: l1 del: l2)● (auto simp add: l1 intro: l2)● (blast intro: l1 elim: l2)● arith● (metis l1 l2 l3)● sledgehammer

   

Automated Proof Methods

● (induct x y arbitrary: z rule: r.induct)● (simp add: l1 del: l2)● (auto simp add: l1 intro: l2)● (blast intro: l1 elim: l2)● arith● (metis l1 l2 l3)● sledgehammer

Induction

   

Automated Proof Methods

● (induct x y arbitrary: z rule: r.induct)● (simp add: l1 del: l2)● (auto simp add: l1 intro: l2)● (blast intro: l1 elim: l2)● arith● (metis l1 l2 l3)● sledgehammer

Induction

Simplification

   

Automated Proof Methods

● (induct x y arbitrary: z rule: r.induct)● (simp add: l1 del: l2)● (auto simp add: l1 intro: l2)● (blast intro: l1 elim: l2)● arith● (metis l1 l2 l3)● sledgehammer

Induction

Simplification

Simplification and some logic

   

Automated Proof Methods

● (induct x y arbitrary: z rule: r.induct)● (simp add: l1 del: l2)● (auto simp add: l1 intro: l2)● (blast intro: l1 elim: l2)● arith● (metis l1 l2 l3)● sledgehammer

Induction

Simplification

Simplification and some logic

Good for sets and quantifiers

   

Automated Proof Methods

● (induct x y arbitrary: z rule: r.induct)● (simp add: l1 del: l2)● (auto simp add: l1 intro: l2)● (blast intro: l1 elim: l2)● arith● (metis l1 l2 l3)● sledgehammer

Induction

Simplification

Simplification and some logic

Good for sets and quantifiers

Good for arithmetic goals

   

Automated Proof Methods

● (induct x y arbitrary: z rule: r.induct)● (simp add: l1 del: l2)● (auto simp add: l1 intro: l2)● (blast intro: l1 elim: l2)● arith● (metis l1 l2 l3)● sledgehammer

Induction

Simplification

Simplification and some logic

Good for sets and quantifiers

Powerful first-order prover

Good for arithmetic goals

   

Automated Proof Methods

● (induct x y arbitrary: z rule: r.induct)● (simp add: l1 del: l2)● (auto simp add: l1 intro: l2)● (blast intro: l1 elim: l2)● arith● (metis l1 l2 l3)● sledgehammer

Induction

Simplification

Simplification and some logic

Good for sets and quantifiers

Powerful first-order prover

Good for arithmetic goals

Finds lemmas for metis

   

Basic Methods for Rulesthm: "[| P1; ...; Pn |] ==> Q"

● (rule thm)● (erule thm)● (drule thm)● (frule thm)

● (rule_tac x="..." and y="..." in thm)

   

Basic Methods for Rulesthm: "[| P1; ...; Pn |] ==> Q"

● (rule thm)● (erule thm)● (drule thm)● (frule thm)

● (rule_tac x="..." and y="..." in thm)

Unifies Q with the conclusion

   

Basic Methods for Rulesthm: "[| P1; ...; Pn |] ==> Q"

● (rule thm)● (erule thm)● (drule thm)● (frule thm)

● (rule_tac x="..." and y="..." in thm)

Unifies Q with the conclusion

Unifies Q; unifies P1 with some assumption

   

Basic Methods for Rulesthm: "[| P1; ...; Pn |] ==> Q"

● (rule thm)● (erule thm)● (drule thm)● (frule thm)

● (rule_tac x="..." and y="..." in thm)

Unifies Q with the conclusion

Unifies Q; unifies P1 with some assumption

Unifies P1 with some assumption

   

Basic Methods for Rulesthm: "[| P1; ...; Pn |] ==> Q"

● (rule thm)● (erule thm)● (drule thm)● (frule thm)

● (rule_tac x="..." and y="..." in thm)

Unifies Q with the conclusion

Unifies Q; unifies P1 with some assumption

Unifies P1 with some assumption

Like drule, but does not delete the assumption

   

Basic Methods for Rulesthm: "[| P1; ...; Pn |] ==> Q"

● (rule thm)● (erule thm)● (drule thm)● (frule thm)

● (rule_tac x="..." and y="..." in thm)

Unifies Q with the conclusion

Unifies Q; unifies P1 with some assumption

Unifies P1 with some assumption

Manual instantiation of variables

Like drule, but does not delete the assumption

   

Insiders' Tips

● term "..."● thm name● Find theorems● Isabelle > Settings > Display ...● Isabelle > Show me ...

   

Insiders' Tips

● term "..."● thm name● Find theorems● Isabelle > Settings > Display ...● Isabelle > Show me ...

Prints a term (with its type)

   

Insiders' Tips

● term "..."● thm name● Find theorems● Isabelle > Settings > Display ...● Isabelle > Show me ...

Prints a term (with its type)

Prints a specific theorem

   

Insiders' Tips

● term "..."● thm name● Find theorems● Isabelle > Settings > Display ...● Isabelle > Show me ...

Prints a term (with its type)

Prints a specific theorem

Search for theorems by pattern

   

Insiders' Tips

● term "..."● thm name● Find theorems● Isabelle > Settings > Display ...● Isabelle > Show me ...

Prints a term (with its type)

Prints a specific theorem

Search for theorems by pattern

Show types, sorts etc.

   

Insiders' Tips

● term "..."● thm name● Find theorems● Isabelle > Settings > Display ...● Isabelle > Show me ...

Prints a term (with its type)

Prints a specific theorem

Search for theorems by pattern

Show types, sorts etc.

Show all commands, all methods etc.