Advanced Formal Methods Lecture 6: Isabelle - HOL Mads Dam KTH/CSC Course 2D1453, 2006-07 Material from L. Paulson.

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Programmed Strategies for Program Verification Richard B. Kieburtz OHSU/OGI School of Science and Engineering and Portland State University.
Types and Programming Languages Lecture 13 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Isabelle / HOL Theorem Proving System
Introduction to Proofs
SLD-resolution Introduction Most general unifiers SLD-resolution
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
Deduction In addition to being able to represent facts, or real- world statements, as formulas, we want to be able to manipulate facts, e.g., derive new.
Predicate Calculus Formal Methods in Verification of Computer Systems Jeremy Johnson.
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 1 Lecture 3 CS 1813 – Discrete Mathematics Truth Inference and the Logical Way.
Formal Logic Proof Methods Direct Proof / Natural Deduction Conditional Proof (Implication Introduction) Reductio ad Absurdum Resolution Refutation.
What’s left in the course. The course in a nutshell Logics Techniques Applications.
Inference and Resolution for Problem Solving
Computing Fundamentals 1 Lecture 1 Lecturer: Patrick Browne Room K308 Based on Chapter 1. A Logical approach to Discrete.
Advanced Formal Methods Lecture 7: Isabelle – Sets Mads Dam KTH/CSC Course 2D1453, Material from L. Paulson.
` ² Q E D I Nelson-Oppen review
Administrative stuff On Thursday, we will start class at 11:10, and finish at 11:55 This means that each project will get a 10 minute presentation + 5.
Natural deduction  ` A  ` B  ` A Æ B  ` A  ` A Æ B  ` B  ` B  ` A ) B  ` A  ` A ) B  ` B  ` A ÆIÆI ÆE1ÆE1 ÆE2ÆE2 Assume )I)I.
Review: forward E { P } { P && E } TF { P && ! E } { P 1 } { P 2 } { P 1 || P 2 } x = E { P } { \exists … }
Review: forward E { P } { P && E } TF { P && ! E } { P 1 } { P 2 } { P 1 || P 2 } x = E { P } { \exists … }
Plan for the rest of the quarter TuesdayThursday Week 7ResolutionProof carrying code Week 8No class (Sorin in DC for workshop) Predicate abstraction (Mystery.
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2.1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 6 Limitations of propositional logic Introduction to predicate logic Symbols, terms and formulae, Parse.
EE1J2 – Discrete Maths Lecture 5 Analysis of arguments (continued) More example proofs Formalisation of arguments in natural language Proof by contradiction.
Room Change!!!! Starting Wednesday Room 302. Inductive Definitions COS 441 Princeton University Fall 2004.
Course eval results More applications Last question –Luging: 0.5 –Curling: 1.5 –Figure skating: 2 –Ice fishing: 6.5 –Foosball: 0.5.
EE1J2 – Discrete Maths Lecture 4 Analysis of arguments Logical consequence Rules of deduction Rules of equivalence Formal proof of arguments See: Anderson,
Introduction to Logic for Artificial Intelligence Lecture 2 Erik Sandewall 2010.
Methods of Proof & Proof Strategies
The ACL2 Proof Assistant Formal Methods Jeremy Johnson.
Introduction to Proofs
CAS- 734 (Presentation -1) By : Vasudha Kapil
MATH 224 – Discrete Mathematics
1 Math/CSE 1019C: Discrete Mathematics for Computer Science Fall 2011 Suprakash Datta Office: CSEB 3043 Phone: ext
0 What logic is or should be Propositions Boolean operations The language of classical propositional logic Interpretation and truth Validity (tautologicity)
Advanced Formal Methods Lecture 5: Isabelle – Proofs and Rewriting Mads Dam KTH/CSC Course 2D1453, Some slides from Paulson.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
Natural Deduction System for First Order Logic Student: Wei Lei Instructor: W. M. Farmer Department of Computing and Software McMaster University, Hamilton,
1 Introduction to Abstract Mathematics Chapter 2: The Logic of Quantified Statements. Predicate Calculus Instructor: Hayk Melikya 2.3.
CS6133 Software Specification and Verification
0 Propositional logic versus first-order (predicate) logic The universe of discourse Constants, variables, terms and valuations Predicates as generalized.
Copyright © Cengage Learning. All rights reserved The Chain Rule.
Of 38 lecture 13: propositional logic – part II. of 38 propositional logic Gentzen system PROP_G design to be simple syntax and vocabulary the same as.
Advanced Formal Methods Lecture 3: Simply Typed Lambda calculus Mads Dam KTH/CSC Course 2D1453, Some material from B. Pierce: TAPL + some from.
Advanced Formal Methods Lecture 4: Isabelle – Types and Terms Mads Dam KTH/CSC Course 2D1453, Some material from Paulson.
Week 4 - Friday.  What did we talk about last time?  Floor and ceiling  Proof by contradiction.
An Introduction to Classical Logic (propositional and Predicate Logic)
1 Lecture 5 PVS commands. 2 Last week Logical formalisms, first-order logic (syntax, semantics). Introduction to PVS. Language of PVS. Proving sequents.
Metalogic Soundness and Completeness. Two Notions of Logical Consequence Validity: If the premises are true, then the conclusion must be true. Provability:
CT214 – Logical Foundations of Computing Darren Doherty Rm. 311 Dept. of Information Technology NUI Galway
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
Copyright 1999Paul F. Reynolds, Jr. Foundations of Logic Programming.
Uniqueness Quantifier ROI for Quantified Statement.
Lecture 2: Proofs and Recursion. Lecture 2-1: Proof Techniques Proof methods : –Inductive reasoning Lecture 2-2 –Deductive reasoning Using counterexample.
Chapter 7. Propositional and Predicate Logic
Introduction to Logic for Artificial Intelligence Lecture 2
Rationale Behind the Precise Formulation of the Four Quantifier Rules
Chapter 1: The Foundations: Logic and Proofs
Lecture 6 CS 1813 – Discrete Mathematics
Formal Program Specification
Cirquent calculus Episode 15 About cirquent calculus in general
The Foundations: Logic and Proofs
Formal Program Specification
Computer Security: Art and Science, 2nd Edition
Search techniques.
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
Lecture Notes for SWE 623 by Duminda Wijesekera
Formal Program Specification
Presentation transcript:

Advanced Formal Methods Lecture 6: Isabelle - HOL Mads Dam KTH/CSC Course 2D1453, Material from L. Paulson

What Is Higher Order Logic? Propositional logic No quantifiers All variables have type bool First Order Logic Quantification over values of base type Terms and formulas are syntactically distinct Higher Order Logic Quantification over functions and predicates Consistency by typing Formula = term of type bool Predicate = function with codomain bool ! + a few types and constants

Natural Deduction Two kinds of rules for each logical operator © Introduction rules: How can A © B be proved? Elimination rules: What can be inferred from A © B? Natural deduction calculus: Proof trees may have unproven leaves = assumptions Assumptions can be introduced and discharged Sequent calculus: All assumptions (and alternative conclusions) represented explicitly in proof judgments

Rule Notation Write Instead of «A 1 ;... ; A n ¬ ) A In other words: Stipulating an inference rule ”RuleName” Same as: Declaring an Isabelle metalogic term «A 1 ;... ; A n ¬ ) A to be provable by named rule Derived rule «A 1 ;... ; A n ¬ ) A Rule is provable in Isabelle’s metalogic A 1... A n A RuleName

Natural Deduction, Propositional Logic A B A Æ B ÆIÆI AÆB «A;B¬ ) C C ÆEÆE AÇB A ) C B ) C C ÇEÇE A A Ç B ÇI1/2 B A Ç B A ) B A ! B )I)I A ) B A B ) C C )E)E A ) B B ) A A = B iffI A ) False :A :I:I A = B A ) B iffD1/2 A = B B ) A :A A C :E:E D for ”definition”

Equality Exercise 1: Prove that the following rules are derived: - t = t =I s = t A[s/x] A[t/x] =E s = t t = s Sym r = s s = t r = t Trans s = t A[s/x] A[t/x] ) C C =E’

More Rules ccontr and classical not derivable from other rules They make the logic ”classical”, i.e. non-constructive A ! B A B mp :A ) False A ccontr :A ) A A classical

Proof by Assumption Implicit in Isabelle’s metalogic «A 1 ;... ; A n ¬ ) A i provable for any i: 1· i· n In isabelle: apply assumption proves 1. «B 1 ;... ; B n ¬ ) C by unifying C with some B i, 1 · i · n Note: This may cause backtracking!

Rule Application Rule: « A 1 ;... ; A n ¬ ) A Subgoal: 1. « B 1 ;... ; B m ¬ ) C Substitution:  (A) ==  (C) (recall: == means ”same term as”) New subgoals: 1.  (« B 1 ;... ; B m ¬ ) A 1 )... n.  (« B 1 ;... ; B m ¬ ) A n ) Command: apply (rule )

Exercises Exercise 2: Prove the following in HOL. Pen and paper is fine. If you use Isabelle, use only basic HOL rules corresponding to rules given in previous slides – no simplifiers 1.A Ç (B Ç C) ! (A Ç B) Ç C 2.(A ! (B ! C)) ! (A Æ B) ! C 3.A Ç A ! A Æ A 4.A Ç B ! : A ! B 5.A Æ (B Ç C) ! (A Æ B) Ç C 6.(A Æ :B) Ç (B Æ :A) = (A = :B) 7. :(A Æ B) ! (:A) Ç (:B)

Elimination Rules in Isabelle Tactic erule assumes that first rule premise is assumption to be eliminated: apply (erule ): Example: Rule: « ?P Æ ?Q ; « ?P; ?Q ¬ ) ?R¬ ) ?R Subgoal: « X ; A Æ B ; Y ¬ ) Z Unifier: ?R == Z, ?P == A, ?Q == B New subgoal: « X; Y ¬ ) « A; B ¬ ) Z Same as: « X; Y; A; B ¬ ) Z

Safe and Unsafe Rules Recall: Rules applied bottom up Safe rules: Provability is preserved (in bottom up direction) Examples: ÆI, !I, :I, iffI, refl, ccontr, classical, ÆE, ÇE Unsafe rules: Can turn provable goal into unprovable one: Examples: ÇI1, ÇI2, !E, iffD1, iffD2, :E

) vs. ! Theorems should be written as ¬ A 1 ;... ; A n ¬ ) A Not as A 1 Æ... Æ A n ! A Exception: Induction variable must not occur in premises Example: « A; B(x)¬ ) C(x), not good Use instead: A ) B(x) ! C(x)

Predicate Logic - Parameters Subgoal: 1. Æ x 1... x n. Formula The x i are parameters of the subgoal Intuition: Local constants, arbitrary, fixed values Rules automatically lifted over Æ x 1... x n and applied directly to Formula

Scope Scope of parameters: Whole subgoal Scope of HOL connectives: Never extend to meta-level I.e. ends with ; or ) Æ x y. « 8y. P y ! Q z y; Q x y¬ ) 9x. Q x y means Æ x y.« (8y 1. P y 1 ! Q z y 1 ); Q x y¬ ) 9x 1. Q x 1 y

Natural Deduction, Predicate Logic 8I and 9E introduce new parameters (Æx) 9I and 8E introduce new unknowns (?x) Æx.(P x) 8x.(P x) 8I8I 8x.(P x) (P ?x) ) R R 8E8E (P ?x) 9x.(P x) 9I9I 9 x.(P x) Æ x.(P x) ) R R 9E9E

Instantiating Rules apply (rule tac x = t in ) Acts as, but ?x in is instantiated to t before application erule tac is similar So: x is in, not in the goal

Two Successful Proofs 1. 8x. 9y. x = y apply (rule 8I) 1. Æx. 9y. x = y Best practice apply (rule tac x = ”x” in 9I) 1. Æx. x = x apply (rule refl) Exploration apply (rule 9I) 1. Æx. x = ?y x apply (rule refl) Simpler and clearer ?y  z.z Shorter and trickier

Two Unsuccessful Proofs 1. 9 y. 8 x. x = y apply (rule tac x = ??? in 9I) ??? apply (rule 9I) 1. 8x. x = ?y apply (rule 8I) 1. Æ x. x = ?y apply (rule refl) ?y  x yields Æx’. x’ = x ???

Safe and Unsafe Rules Safe: 8I, 9E Unsafe: 8E, 9I Create parameters first, unknowns later

Exercises, Predicate Logic Exercise 3. Prove or disprove the following formulas. If you prove the formulas, use Isabelle, as in exercise 2. For a disproof it is sufficient to show that the formulas are false in ordinary first-order logic. 1. 8x.8y. R x y = 8y.8x. R x y 2.(9x. P x) Ç (9y. Q y) = 9z. (P z) Ç (Q z) 3. : 8x. P x ) 9y.:(P y) 4. 9x.(P x ! 8y.P y)

Renaming Parameters Careful with Isabelle-generated names 1. 8 x. 9 y. x = y apply (rule 8I) 1. Æx. 9y. x = y apply (rule tac x = ”x” in 9I) What if the above used in context which already knows some x? Instead: apply (rename tac xxx) 1. Æxxx. 9y. x = y apply (rule tac x = ”xxx” in 9I)

Forward Proof ”Forward” rule:A 1 ) A Subgoal:1. « B 1 ;... ; B m ¬ ) C Substitution:  (B i ) ==  (A 1 ) New subgoal:1.  (« B 1 ;... ; B n ; A ¬ ) C) Command: apply (frule ) Like frule but deletes B i : apply (drule )