After today Week 9 –Tu: Pat Rondon –Th: Ravi/Nathan Week 10 –Tu: Nathan/Ravi –Th: Class canceled Finals week –Th: Zach, John.

Slides:



Advertisements
Similar presentations
Completeness and Expressiveness
Advertisements

Inference Rules Universal Instantiation Existential Generalization
Techniques for Proving the Completeness of a Proof System Hongseok Yang Seoul National University Cristiano Calcagno Imperial College.
10 October 2006 Foundations of Logic and Constraint Programming 1 Unification ­An overview Need for Unification Ranked alfabeths and terms. Substitutions.
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
Inference in first-order logic Chapter 9. Outline Reducing first-order inference to propositional inference Unification Generalized Modus Ponens Forward.
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.
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
Induction and recursion
Formal Logic Proof Methods Direct Proof / Natural Deduction Conditional Proof (Implication Introduction) Reductio ad Absurdum Resolution Refutation.
Plan for today Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search.
What’s left in the course. The course in a nutshell Logics Techniques Applications.
Constraint Logic Programming Ryan Kinworthy. Overview Introduction Logic Programming LP as a constraint programming language Constraint Logic Programming.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
Proof-system search ( ` ) Interpretation search ( ² ) Main search strategy DPLL Backtracking Incremental SAT Natural deduction Sequents Resolution Main.
` ² Q E D I Nelson-Oppen review
Catriel Beeri Pls/Winter 2004/5 inductive-revisited 1 Inductive definitions revisited  Generated and Freely generated sets oPattern match, unification.
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
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.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
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 … }
Normal forms for Context-Free Grammars
Course announcement Software Reliability Methods –Spring 06, Tu Th 9:30am-11:00am –Instructors: Ingolf Krueger, Ranjit Jhala, Sorin Lerner Topics: –Model.
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.
Course eval results More applications Last question –Luging: 0.5 –Curling: 1.5 –Figure skating: 2 –Ice fishing: 6.5 –Foosball: 0.5.
1 Section 3.3 Mathematical Induction. 2 Technique used extensively to prove results about large variety of discrete objects Can only be used to prove.
Going back to techniques Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain.
Induction and recursion
Chapter 4: A Universal Program 1. Coding programs Example : For our programs P we have variables that are arranged in a certain order: Y 1 X 1 Z 1 X 2.
Equational Reasoning Math Foundations of Computer Science.
What it is? Why is it a legitimate proof method? How to use it?
Methods of Proof & Proof Strategies
Induction and recursion
The ACL2 Proof Assistant Formal Methods Jeremy Johnson.
Introduction to Proofs
Induction Schemes Math Foundations of Computer Science.
1 Inference Rules and Proofs (Z); Program Specification and Verification Inference Rules and Proofs (Z); Program Specification and Verification.
1 Sections 1.5 & 3.1 Methods of Proof / Proof Strategy.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Copyright © Zeph Grunschlag, Induction Zeph Grunschlag.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Section 3.3: Mathematical Induction Mathematical induction is a proof technique that can be used to prove theorems of the form:  n  Z +,P(n) We have.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
1 INFO 2950 Prof. Carla Gomes Module Induction Rosen, Chapter 4.
Advanced Formal Methods Lecture 4: Isabelle – Types and Terms Mads Dam KTH/CSC Course 2D1453, Some material from Paulson.
Inference in First Order Logic. Outline Reducing first order inference to propositional inference Unification Generalized Modus Ponens Forward and backward.
Inductive Proofs Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
Copyright © Zeph Grunschlag, Induction Zeph Grunschlag.
CS357 Lecture 13: Symbolic model checking without BDDs Alex Aiken David Dill 1.
From Natural Language to LTL: Difficulties Capturing Natural Language Specification in Formal Languages for Automatic Analysis Elsa L Gunter NJIT.
Chapter 5. Section 5.1 Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach.
Interface specifications At the core of each Larch interface language is a model of the state manipulated by the associated programming language. Each.
Section 1.7. Section Summary Mathematical Proofs Forms of Theorems Direct Proofs Indirect Proofs Proof of the Contrapositive Proof by Contradiction.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
1 Proving Properties of Recursive List Functions CS 270 Math Foundations of CS Jeremy Johnson.
Chapter 1 Logic and proofs
1 Section 4.4 Inductive Proof What do we believe about nonempty subsets of N? Since  N, <  is well-founded, and in fact it is linear, it follows that.
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
CS151: Mathematical Foundations of Computing Mathematical Induction.
Reasoning About Code.
Reasoning about code CSE 331 University of Washington.
Induction and recursion
Proving Properties of Recursive List Functions
Induction and recursion
MA/CSSE 474 More Math Review Theory of Computation
Search techniques.
Presentation transcript:

After today Week 9 –Tu: Pat Rondon –Th: Ravi/Nathan Week 10 –Tu: Nathan/Ravi –Th: Class canceled Finals week –Th: Zach, John

Techniques on last time! Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy E-graph Rewrite rules Communication between decision procedures and between prover and decision procedures DPLL Backtracking Incremental SAT Matching Skolemization Unification Natural deduction Sequents Tactics & Tacticals Resolution Today

Induction Is just another way of proving universal quantifiers Important technique for proving properties of inductively defined structures, such as recursive data structures, recursive programs, and derivations

Principle of induction Induction over natural numbers P(0) 8 i:Nat P(i) ) P(i+1) 8 i:Nat. P(i)

Principle of induction More generally: well-founded induction Well founded order: for every non-empty subset, there is a minimal element (an element such that no other element is smaller than it) Equivalently: there are no infinite descending chains 8 j ( [ 8 i < j. P(i)] ) P(j) ) (<, N) is a well-founded order 8 i:N. P(i)

Principle of induction Structural induction: well-founded induction where the induction is done on the (usually syntactic) structure of elements of N

Automating induction Automating induction is hard –not many theorem provers do it automatically Difficulties –determine when to apply induction –determine what variables to apply induction on –derive a strong enough hypothesis

Induction in ACL2 Similarity between recursive definitions and induction A recursive function calls itself with arguments that are “smaller” (by some measure) than the original arguments A proof of P(x) by induction consists of proving P(x) by assuming that P holds for terms “smaller” (by some measure) than x

Induction in ACL2 ACL2 proves theorems about recursive functions, and so the above similarity leads to a scheme for applying induction Suppose that a formula P to be proven contains a call to a function f that is defined recursively, and suppose each recursive call drives down the measure Then we can apply induction on the structure of the recursive definition of f

Simple example (sum N) = (IF (<= N 0) 0 (+ N (sum (- N 1)))) (defthm (IMPLIES (>= N 0) (= (sum N) (/ (* N (+ N 1)) 2))))

Two parts First part: identify possible measures –done when a recursive function is defined Second part: apply induction during a proof –use the analysis done during the first part to guide the application

Identifying measures Suppose we have (f x 1 … x n ) = body, where the body contains recursive calls to f. We are looking for a measure function m that satisfies the following: –for every sub-term of the form (f y 1 … y n ), we must have (r (m y 1 … y n ) (m x 1 … x n )) –where r is a well-founded relation

Example (funny-fact n i) = (IF (<= n 0) 1 (IF (= i 0) (* n (funny-fact (- n 1) i)) (IF (> i 0) (* n (funny-fact (- n i) i)) (* n (funny-fact (+ n i) i))))))

Refine: identifying measures Suppose we have (f x 1 … x n ) = body, where the body contains recursive calls to f. We are looking for a measure function m that satisfies the following: –for every sub-term of the form (f y 1 … y n ), we must have: (IMPLIES (AND t 1 … t k ) (r (m y 1 … y n ) (m x 1 … x n ))) –where r is a well-founded relation

Build the “machine” for a function casetestrecursive calls 1 (funny-fact (- n 1) i) 2 (funny-fact (- n i) i) 3 (funny-fact (+ n i) i) (funny-fact n i) = (IF (<= n 0) 1 (IF (= i 0) (* n (funny-fact (- n 1) i)) (IF (> i 0) (* n (funny-fact (- n i) i)) (* n (funny-fact (+ n i) i))))))

Build the “machine” for a function casetestrecursive calls 1 (AND (NOT (<= n 0)) (= i 0)) (funny-fact (- n 1) i) 2 (AND (NOT (<= n 0)) (NOT (= i 0) (> i 0)) (funny-fact (- n i) i) 3 (AND (NOT (<= n 0)) (NOT (= i 0) (NOT (> i 0)) (funny-fact (+ n i) i) (funny-fact n i) = (IF (<= n 0) 1 (IF (= i 0) (* n (funny-fact (- n 1) i)) (IF (> i 0) (* n (funny-fact (- n i) i)) (* n (funny-fact (+ n i) i))))))

Use machine to test measure For example, for case 3: (IMPLIES (AND (NOT (<= n 0)) (NOT (= i 0) (NOT (> i 0)) (< (+ n i) n))

How do you guess measure? Rely on lemmas that have been labeled with the “induction” hint These so-called induction lemmas state under what conditions certain measures decrease For example: (IMPLIES (is-cons-cell X) (< (length (cdr X) (length X)))

How do you guess measure? Suppose we have a function append: (append L1 L2) = (IF (is-cons-cell L1) (cons (car L1) (append (cdr L1) L2)) L2)) (IMPLIES (is-cons-cell X) (< (length (cdr X) (length X))) casetestrecursive calls 1

How do you guess measure? Suppose we have a function append: (append L1 L2) = (IF (is-cons-cell L1) (cons (car L1) (append (cdr L1) L2)) L2)) (IMPLIES (is-cons-cell X) (< (length (cdr X) (length X))) casetestrecursive calls 1 (is-cons-cell L1)(append (cdr L1) L2)) Table and induction lemma immediately point out that length works as the measure and < works as the order

Another example (ACK M N) = (IF (= M 0) (+ N 1) (IF (= N 0) (ACK (- M 1) 1) (ACK (- M 1) (ACK M (- N 1))))) casetestrecursive calls 1 2

Another example (ACK M N) = (IF (= M 0) (+ N 1) (IF (= N 0) (ACK (- M 1) 1) (ACK (- M 1) (ACK M (- N 1))))) casetestrecursive calls 1 (AND (NOT (= M 0)) (= N 0)) (ACK (- M 1) 1) 2 (AND (NOT (= M 0)) (NOT (= N 0))) (ACK (- M 1) (ACK M (- N 1))) (ACK M (- N 1)) Measure?

Another example Lexicographical order of (M, N) (LEX-< (cons (- M 1) N) (cons M N)) (LEX-< (cons (- M 1) (ACK...)) (cons M N)) (LEX-< (cons M (- N 1)) (cons M N))

First part summary When the function is defined, try to find measure Use induction lemmas to guide search Also allow programmer to provide the measure Once a measure has been found, the function is “admitted” As a side benefit, guarantees termination

Second part: applying induction Suppose term (f t 1 … t n ) appears in the goal G Assume t 1 … t n are all variables –if they are not, things get more complicated Assume “machine” for f looks like this: casetestrecursive calls 1 q1q1 r r 1 h1 2 q2q2 r r 2 h2 … …… k qkqk r k 1... r k hk Also, assume  i h is subst such that  i h applied to (f t 1 … t n ) gives r i h

Second part: applying induction casetestrecursive calls 1 q1q1 r r 1 h1 2 q2q2 r r 2 h2 … …… k qkqk r k 1... r k hk Also, assume  i h is subst such that  i h applied to (f t 1 … t n ) gives r i h Goal G with sub-term (f t 1 … t n )

Second part: applying induction casetestrecursive calls 1 q1q1 r r 1 h1 2 q2q2 r r 2 h2 … …… k qkqk r k 1... r k hk Also, assume  i h is subst such that  i h applied to (f t 1 … t n ) gives r i h Goal G with sub-term (f t 1 … t n )

Simple example from before (sum N) = (IF (<= N 0) 0 (+ N (sum (- N 1)))) (defthm (IMPLIES (>= N 0) (= (sum N) (/ (* N (+ N 1)) 2)))) casetestrecursive calls 1 == G

Simple example from before (sum N) = (IF (<= N 0) 0 (+ N (sum (- N 1)))) (defthm (IMPLIES (>= N 0) (= (sum N) (/ (* N (+ N 1)) 2)))) casetestrecursive calls 1 (NOT (<= N 0)) (sum (- N 1))) (IMPLIES (AND G[N ! (- N 1)] (NOT (<= N 0))) G)  = [ N ! (- N 1) ] (IMPLIES (<= N 0) G) G

Strengthening It is often advantageous, and sometimes even necessary to strengthen a conjecture before attempting an inductive proof ACL2 does this with a generalization process, which runs before induction is applied Tries to replace certain non-variable terms by fresh variables, which are implicitly universally quantified

Strengthening example Suppose we want to prove (all free vars universally quantified): (append (reverse A) nil) = (reverse A) This conjecture is generalized –by replacing (reverse A) with L (append L nil) = L

Strengthening gone wrong The problem with generalization is that the generalized conjecture may be “too strong” –and in fact may not hold even though the original conjecture did! Example: (= (sum (fib N)) (/ (* (fib N) (+ (fib N) 1)) 2))))

Strengthening gone wrong The problem with generalization is that the generalized conjecture may be “too strong” –and in fact may not hold even though the original conjecture did! Example: (= (sum (fib N)) (/ (* (fib N) (+ (fib N) 1)) 2)))) Generalize: (= (sum M) (/ (* M (+ M 1)) 2)))) This does not hold! We need to know that M is positive!

Strengthening fixed The generalization process constrains the newly introduced variables using theorems that have been labeled “generalize” by the user In the previous case, the following theorem could be used: (>= (fib N) 0) Once this theorem has been proven and labeled “generalize”, subsequent generalizations of (fib N) to M will include the hypothesis (>= M 0). –Generalized conjecture in example becomes: (IMPLIES (>= M 0) (= (sum M) (/ (* M (+ M 1)) 2))))

Induction in ACL2: summary The three difficulties, again When to apply induction –as a last resort What variables to apply induction on –analyze function at definition time to find decreasing measures How to strengthen induction hypothesis –replace certain terms with fresh vars

Similar ideas, but elsewhere Using recursive definitions to drive the application of induction appears in other theorem provers, for example Twelf Twelf is a theorem prover based on the LF logical framework, which can be used to encode logics, programming languages, and deductive systems Properties of such systems can then be proven by induction

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 )E)E  ` A  ` A Ç B ÇI1ÇI1  ` B  ` A Ç B ÇI2ÇI2  ` C ÇEÇE  ` C  ` C

Proving properties of derivations Say we want to prove a property: –for every derivation D, P(D) holds

Proving properties of derivations Say we want to prove a property: –for every derivation D, P(D) holds

Twelf Twelf can performs these kinds of proofs automatically The application of induction is interspersed with case splitting and the backward application of Twelf’s sequent inference rules