1 Theorem proving Alexander Serebrenik. 2 TP for FM FM: proving properties of programs. Theorem proving: proving statements in first-order logics (FOL).

Slides:



Advertisements
Similar presentations
Completeness and Expressiveness
Advertisements

1 A formula in predicate logic An atom is a formula. If F is a formula then (~F) is a formula. If F and G are Formulae then (F /\ G), (F \/ G), (F → G),
1 Logic Logic in general is a subfield of philosophy and its development is credited to ancient Greeks. Symbolic or mathematical logic is used in AI. In.
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
We have seen that we can use Generalized Modus Ponens (GMP) combined with search to see if a fact is entailed from a Knowledge Base. Unfortunately, there.
For Friday No reading Homework: –Chapter 9, exercise 4 (This is VERY short – do it while you’re running your tests) Make sure you keep variables and constants.
L41 Lecture 2: Predicates and Quantifiers.. L42 Agenda Predicates and Quantifiers –Existential Quantifier  –Universal Quantifier 
F22H1 Logic and Proof Week 7 Clausal Form and Resolution.
Computability and Complexity 9-1 Computability and Complexity Andrei Bulatov Logic Reminder (Cnt’d)
Formal Logic Proof Methods Direct Proof / Natural Deduction Conditional Proof (Implication Introduction) Reductio ad Absurdum Resolution Refutation.
Introduction to Computability Theory
What’s left in the course. The course in a nutshell Logics Techniques Applications.
CSE 311 Foundations of Computing I Lecture 6 Predicate Logic Autumn 2011 CSE 3111.
Monadic Predicate Logic is Decidable Boolos et al, Computability and Logic (textbook, 4 th Ed.)
ECE 667 Synthesis and Verification of Digital Systems
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 6 Limitations of propositional logic Introduction to predicate logic Symbols, terms and formulae, Parse.
Introduction to Logic for Artificial Intelligence Lecture 2 Erik Sandewall 2010.
Adapted from Discrete Math
First Order Logic. This Lecture Last time we talked about propositional logic, a logic on simple statements. This time we will talk about first order.
CSE 311 Foundations of Computing I Lecture 6 Predicate Logic, Logical Inference Spring
Methods of Proof & Proof Strategies
Deciding a Combination of Theories - Decision Procedure - Changki pswlab Combination of Theories Daniel Kroening, Ofer Strichman Presented by Changki.
CSci 2011 Discrete Mathematics Lecture 3 CSci 2011.
The Foundations: Logic and Proofs
Theoretical basis of GUHA Definition 1. A (simplified) observational predicate language L n consists of (i) (unary) predicates P 1,…,P n, and an infinite.
1 Sections 1.5 & 3.1 Methods of Proof / Proof Strategy.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and Logic.
First Order Predicate Logic
2.3Logical Implication: Rules of Inference From the notion of a valid argument, we begin a formal study of what we shall mean by an argument and when such.
First Order Logic Lecture 2: Sep 9. This Lecture Last time we talked about propositional logic, a logic on simple statements. This time we will talk about.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Copyright © Curt Hill Quantifiers. Copyright © Curt Hill Introduction What we have seen is called propositional logic It includes.
Correctness Proofs and Counter-model Generation with Authentication-Protocol Logic Koji Hasebe Mitsuhiro Okada Department of Philosophy, Keio University.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
CSE 311 Foundations of Computing I Lecture 7 Logical Inference Autumn 2012 CSE
1 Introduction to Abstract Mathematics Chapter 2: The Logic of Quantified Statements. Predicate Calculus Instructor: Hayk Melikya 2.3.
Great Theoretical Ideas in Computer Science.
CS6133 Software Specification and Verification
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
1 Introduction to Abstract Mathematics Predicate Logic Instructor: Hayk Melikya Purpose of Section: To introduce predicate logic (or.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 02: QUANTIFIERS Sections 1.3 and 1.4 Jarek Rossignac CS1050:
CS 285- Discrete Mathematics Lecture 4. Section 1.3 Predicate logic Predicate logic is an extension of propositional logic that permits concisely reasoning.
First Order Logic Lecture 3: Sep 13 (chapter 2 of the book)
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.
1 First order theories (Chapter 1, Sections 1.4 – 1.5) From the slides for the book “Decision procedures” by D.Kroening and O.Strichman.
1 Reasoning with Infinite stable models Piero A. Bonatti presented by Axel Polleres (IJCAI 2001,
Knowledge Repn. & Reasoning Lec. #5: First-Order Logic UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2004.
Predicate Logic One step stronger than propositional logic Copyright © Curt Hill.
Computing & Information Sciences Kansas State University Lecture 12 of 42 CIS 530 / 730 Artificial Intelligence Lecture 12 of 42 William H. Hsu Department.
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding Combined Theories.
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.
PREDICATES AND QUANTIFIERS COSC-1321 Discrete Structures 1.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
Chapter 1 Logic and proofs
Introduction to Logic for Artificial Intelligence Lecture 2
Advanced Algorithms Analysis and Design
CS201: Data Structures and Discrete Mathematics I
MA/CSSE 474 More Math Review Theory of Computation
Computer Security: Art and Science, 2nd Edition
Negations of quantifiers
Predicates and Quantifiers
CS201: Data Structures and Discrete Mathematics I
Presentation transcript:

1 Theorem proving Alexander Serebrenik

2 TP for FM FM: proving properties of programs. Theorem proving: proving statements in first-order logics (FOL). Hence: Translator Theorem prover programs and properties statements in FOL proof found no proof found

3 Today and Next Week Translator Theorem prover programs and properties statements in FOL proof found no proof found in two weeks

4 Propositional Calculus – Reminder Predicates: p, q, r, … Connectors: –  (“and”), –  (“or”), –  (“not”), –  (“implies”) E.g. (p  q)  r

5 First Order Logics – reminder Constants: ‘John Doe’, 1984, … Variables: x, y, z, … Function symbols: f, g, h, … Predicates: p, q, r, … Term: h(x), fatherOf(‘John Doe’) Atomic sentence: married(fatherOf(‘John Doe’), ‘Jane Smith’)

6 Connectors and Quantifiers Connectors: , , ,  married(x, ‘Jane’)  rich(x) Quantifiers: ,   x (married(x, ‘Jane’)  rich(x)) QQ: “Everybody needs somebody” A.  x  y needs(x,y) C.  x  y needs(x,y) B.  x  y needs(x,y) D.  x  y needs(x,y)

7 Variables: Free and Bound Intuition: variables that appear between () after ,  are called bound, otherwise they are called free. QQ: Which variables are free in the following sentence?  x ((p(x,y)  q(x))   z (r(v,z)  s(z)))

8 Questions so far? If these notions are not familiar… If you are not sure which variables are free in  x (p(x,y)   z q(z,x))… If you do not remember whether  (p(x)  q(y)) is equivalent to  p(x)   q(y) Check logics textbooks!

9 Some Sentences Are Always True If x and y are negative then x*y is positive. Any prime number greater than two is odd. We call this tautology and denote╞ φ –φ - sentence

10 ╞ φ ?╞ φ ?╞ φ ?╞ φ ? Check whether for all variable substitutions φ is evaluated to true.

11 Alternative We need a proof calculus –number of syntactic inference rules φ –when applied to axioms can produce φ Even better: reduce φ to axioms by applying the rules!Even better: reduce φ to axioms by applying the rules! QQ: Why is the second option better?QQ: Why is the second option better?

12 Proofs If φ can be reduced to axioms by applying the rules we write ├ φ Proof = series of reduction steps φ is provable

13 Correctness Properties for ├ Proof calculus should satisfy: ╞ φSoundness: If├ φ then ╞ φ –if something has been proved, it holds. ╞ φ thenCompleteness: If ╞ φ then ├ φ –if something holds, it can be proven.

14 System G a proof calculus for propositional calculus / first- order logics sound and complete basis for automated theorem provers We will see the axioms and the inference rules apply them to a number of examples discuss automation of the approach

15 Γ  ΔΓ  ΔΓ  ΔΓ  Δ antecedentssuccedents System G is Based on: Gentzen Sequent finite sequences of logic sentences

16 Intuition Let Γ be  A 1, …, A n , Δ be  B 1, …, B m  Γ  Δ corresponds to ╞ ((A 1  …  A n )  (B 1  …  B m ))

17 System G: Axioms Γ  Δ is an axiom if Γ  Δ ≠  QQ: Explain the choice of the axioms. Hint:Hint: recall the intuition behind Γ  Δ

18 System G: Inference Rules Depend on the outermost connector of quantifier. Conjunction (1): A, B are arbitrary sentences Γ, Δ, Λ are sequences of sentences Read upwards: –replace an antecedent A  B by two antecedents A and B

19 System G: Try It Yourself! QQ: Prove (A  B  A) Proof:

20 System G:  :right What if we need to prove A  B? We need to prove two statements: A and B  Replace one sequent by two:

21 System G: Try It Yourself! QQ: Prove (A,B  A  B) Proof:

22  -symmetry (1) If we need to prove A  B, we need to prove at least one of A or B

23  -symmetry (2) If we know A  B, we either know A or we know B.

24 Negation

25 Implication: Try Yourself! Reminder: A  B is equivalent to  A  B. Group B Group A

26 Implication: Group A Hence

27 Implication: Group B Hence

28 … But How Can We Prove φ? Start with  φ

29 Example Prove  A  A:

30 Summary So Far System G: –based on the notion of a Gentzen sequent –sequent: Γ  Δ Axioms: Γ  Δ is an axiom if Γ  Δ ≠  For propositional calculus: 8 inference rules ({ , , ,  } * {left, right}) For First-Order Logics: 4 more to come.

31 G for Propositional Calculus Sound and complete for propositional calculus. There exists an algorithm that given a sequent: –always terminates –proves the sequent if and only if it is a tautology –based on the notion of a proof tree, i.e., a tree with nodes labelled by sequents

32 Algorithm (1) algo search(Γ  Δ) T := one-node tree labeled with Γ  Δ while exists a leaf of T that can be expanded CopyT := T for each leaf node of CopyT if the node is not an axiom expand(node, T) if all leaves are axioms write(‘T is the proof of Γ  Δ’) else write(‘Γ  Δ is not a tautology’)

33 Algorithm (2) algo expand(node,T) let node be labeled  A 1, …,A n    B 1, …,B m  S := one-node tree labeled with  A 1, …,A n    B 1, …,B m  for i=1 to n if nonatomic(A i ) then apply2all(A i, left, S) for i=1 to m if nonatomic(A i ) then apply2all(A i, right, S) replace node in T by S

34 Algorithm: Let Us Try It! Tree T Tree S

35 Algorithm: Let Us Try It! Tree T Tree S

36 Algorithm: Let Us Try It! Tree T Both leaves are axioms! Hence, T is the proof of

37 Algorithm: QQ To prove that our algorithm terminates we have to find a certain value that decreases from a parent node to each one of the children nodes. What is this value?

38 Towards FOL:  :left  –if we know that  x A(x) holds, then we can chose any term t (not containing x) and replace x by t. –A[t/x] denotes replacement of all x’s in A by t QQ: Why do we keep  x A?

39 Towards FOL:  :right  –if we need to prove that  x A holds, we can take any term t (not containing x) and replace  x A by A[t/x]. –if the proof of A[t/x] succeeds, then we have also proved  x A –t is not necessarily unique, so we keep  x A

40 But what if we know  x A? We still do not know for which x does A hold! How can we guess? We do not need to guess! A new (unused) variable: let y be such that A[y/x] holds!

41  x A? And If We Need to Prove  x A? The same idea works! If A holds for a new unused variable y, then it holds for any value

42 QQ: Why Should y Be New? Otherwise, we loose soundness! Give an example.

43 Summary: System G for Quantifiers

44 QQ Group A: Prove  x A  A if A does not contain x. Group B: Prove A   x A if A does not contain x.

45 System G for FOL Sound and complete There exists an algorithm that given a sequent: –proves the sequent if and only if it is a tautology –extends our previous algorithm However, termination is no longer guaranteed

46 Hence Algorithm Terminates, the statement is not a tautology Terminates, the proof has been found. Does not terminate

47 Even more bad news There exists no algorithm for FOL that –always terminates, and –proves the sequent if and only if it is a tautology. In other words, the problem of deciding whether an FOL formula is a tautology is recursively enumerable, but not co- recursively enumerable.

48 Reasons for Non-Termination (1) Repetitive application of (  :left), (  :right). –it is useless to chose the same t twice for the same A. –for each term t keep a list of  xA and  xA such that t has been used for the replacement in (  :left) or (  :right).

49 Reasons for Non-Termination (2) As we have function symbols we have infinitely many terms to choose from: {a, f(a), f(f(a)), f(f(f(a))), …} –either try all of them in some order –or leave the choice to a human

50 How Shall We Adapt the Algorithm? (1) List of variables {x 0, x 1, …, x n } appearing in Γ  Δ List of variables for (  :right) and (  :left): {y 1, y 2, …} –disjoint from {x 0, x 1, …, x n } –a variable is removed from the list every time these rules are applied

51 How Shall We Adapt the Algorithm? (2) Structure TERM of pairs –S = a list of  xA and  xA such that t has been used for the replacement in (  :left) or (  :right). –initially:, where c is a constant or a free variable appearing in Γ  Δ, if exists y 0, otherwise List AVAIL of terms for (  :left) and (  :right): –AVAIL 0 - terms from free variables, constants (if exist) or y 0 (otherwise), and function symbols –AVAIL i - terms containing y i constructed from free variables, constants, y 1, …, y i, and function symbols

52 How Shall We Adapt the Algorithm? (3) (  :right) and (  :left): –Remove y i from {y 1, y 2, …} –Add y i to TERM –Remove y i from AVAIL i (  :left) and (  :right): –All terms from TERM are available –Add first element from AVAIL i to TERM and remove it from AVAIL i

53 Complete Algorithm? See handouts

54 We Have FOL, But We Need More We would like to compare terms, using = Sound and complete System G = for any f for any P

55 System G = : QQ axiom

56 P Can Be =!

57 Example: Symmetry of = T:T:

58 Automation For propositional calculus – complete –the user can make reasoning more efficient choice of  A 1, …, A n    B 1, …, B m  to apply an inference rule. For FOL and FOL = –only partial automation possible: choice of a term for the substitution. choice of  A 1, …, A n    B 1, …, B m  to apply an inference rule.

59 Summary (1) Proving properties of programs is based on proving logic formulae. To prove a formula one needs proof calculus. Proof calculus should be sound and complete. System G is based on the notion of a sequent.

60 Summary (2) Sequent Γ  Δ –Γ, Δ are finite sequences of sentences System G  for propositional calculus is sound and complete. –there is a proof algorithm that always terminates. System G for FOL is sound and complete. –proof algorithm can go forever. System G = for FOL = is sound and complete. –proof algorithm can go forever.

61 Next Lecture: PVS Prototype Verification System –Developed at SRI International –Open Source (GPL) since 1993 –Runs on Linux/Solaris/Mac –Uses Emacs as Interface –Supports System G reasoning… –and much, much more! We will use it, so install it at your laptops!