Induction Schemes. Math Foundations of Computer Science

Size: px
Start display at page:

Download "Induction Schemes. Math Foundations of Computer Science"

Transcription

1 Induction Schemes Math Foundations of Computer Science

2 Topics Induction Example Induction scheme over the naturals Termination Reduction to equational reasoning ACL2 proof General Induction Schemes Induction scheme over lists Induction over recursively defined data structures

3 nind (defunc nind (n) :input-contract (natp n) :output-contract t (if (equal n 0) 0 (nind (- n 1)))) This function is admissible. Given a natural number n it counts down to 0 and returns, therefore it is terminating.

4 Induction Scheme over Naturals Every terminating function gives rise to an induction scheme 1. (not (natp n)) ϕ 2. (natp n) (equal n 0) ϕ 3. (natp n) (not (equal n 0)) ϕ ((n n-1)) ϕ (1) and (2) are base cases and (3) is the induction hypothesis More powerful than case analysis since you can use assume the induction hypothesis

5 Why does Induction Work? By (1) ϕ holds for (not (natp n)) By (2) ϕ ((n 0)) By (3) (natp 1) (not (equal 1 0)) ϕ ((n 0)) ϕ ((n 1)) (natp 2) (not (equal 2 0)) ϕ ((n 1)) ϕ ((n 2)) (natp 3) (not (equal 3 0)) ϕ ((n 2)) ϕ ((n 3))

6 sum (defunc sum (n) :input-contract (natp n) :output-contract (integerp (sum n)) (if (equal n 0) 0 (+ n (sum (- n 1))))) Conjecture. (sum n) = n*(n+1)/2

7 Induction Scheme for sum Theorem. (natp n) (equal (sum n) (/ (* n (+ n 1)) 2)) {contract check} 1. (not (natp n)) (natp n) (equal (sum n) (/ (* n (+ n 1)) 2)) 2. (natp n) (equal n 0) (natp n) (equal (sum n) (/ (* n (+ n 1)) 2)) 3. (natp n) (not (equal n 0)) [(natp (- n 1) (equal (sum (- n 1) (/ (* (- n 1) n) 2))] [(natp n) (equal (sum n) (/ (* n (+ n 1)) 2))]

8 Base Cases 1. (not (natp n)) (natp n) (equal (sum n) (/ (* n (+ n 1)) 2)) A (A B) T False implies anything ( A A) B F B F B T B T

9 Base Case Use equational reasoning for case (natp 0) (equal (sum 0) (/ (* 0 (+ 0 1)) 2)) (sum 0) = (if (equal 0 0) 0 (+ n (sum (- n 1))))) {def of sum and (natp 0)} = (if t 0 (+ n (sum (- n 1))))) {equal axiom} = 0 {if axiom} (/ (* 0 (+ 0 1)) 2)) = 0 {arithmetic}

10 General Case (IH) 3. (natp n) (not (equal n 0)) [(natp (- n 1) (equal (sum (- n 1)) (/ (* (- n 1) n) 2))] [(natp n) (equal (sum n) (/ (* n (+ n 1)) 2))] (natp n) (not (equal n 0)) [(natp (- n 1) (equal (sum (- n 1)) (/ (* (- n 1) n) 2))] (equal (sum n) (/ (* n (+ n 1)) 2))

11 Context (natp n) (not (equal n 0)) [(natp (- n 1) (equal (sum (- n 1)) (/ (* (- n 1) n) 2))] (equal (sum n) (/ (* n (+ n 1)) 2)) C1. (natp n) C2. (not (equal n 0)) C3. (natp (- n 1)) (equal (sum (- n 1)) (/ (* (- n 1) n) 2)) C4. (natp (- n 1)) {C1, C2} C5. (equal (sum (- n 1)) (/ (* (- n 1) n) 2)) {C3, C4, MP}

12 Proof of General Case Theorem. (natp n) (not (equal n 0)) [(natp (- n 1) (equal (sum (- n 1) (/ (* (- n 1) n) 2))] (equal (sum n) (/ (* n (+ n 1)) 2)) Proof. (sum n) = (if (equal n 0) 0 (+ n (sum (- n 1))))) {by def of sum and C1} = (if nil 0 (+ n (sum (- n 1))))) {by C2 and equal axiom} = (+ n (sum (- n 1))) {by if axiom} = (+ n (/ (* - n 1) n) 2) {by C5} = (2n + (n-1)n)/2 = (n*n + n)/2 = n(n+1)/2 {arithmetic}

13 Induction in ACL2 ACL2S B!>QUERY (thm (implies (natp n) (equal (sum n) (/ (* n (+ n 1)) 2)))) << Starting proof tree logging >> Goal' Goal'' ^^^ Checkpoint Goal'' ^^^ ([ A key checkpoint: Goal'' (IMPLIES (AND (INTEGERP N) (<= 0 N)) (EQUAL (SUM N) (COMMON-LISP::+ (COMMON-LISP::* 1/2 N) (COMMON-LISP::* 1/2 (COMMON-LISP::EXPT N 2)))))

14 Induction in ACL2 *1 (Goal'') is pushed for proof by induction. ]) Perhaps we can prove *1 by induction. One induction scheme is suggested by this conjecture. We will induct according to a scheme suggested by (SUM N). This suggestion was produced using the :induction rules SUM-INDUCTION- SCHEME and SUM-INDUCTION-SCHEME-FROM-DEFINITION. If we let (:P N) denote *1 above then the induction scheme we'll use is (AND (IMPLIES (NOT (NATP N)) (:P N)) (IMPLIES (AND (NATP N) (NOT (EQUAL N 0)) (:P (COMMON-LISP::+ -1 N))) (:P N)) (IMPLIES (AND (NATP N) (EQUAL N 0)) (:P N))).

15 Induction in ACL2 This induction is justified by the same argument used to admit SUM. When applied to the goal at hand the above induction scheme produces five nontautological subgoals. ^^^ Checkpoint *1 ^^^ Subgoal *1/5 Subgoal *1/4 Subgoal *1/4' Subgoal *1/3 Subgoal *1/2 Subgoal *1/1 Subgoal *1/1' *1 is COMPLETED! Thus key checkpoint Goal'' is COMPLETED! Q.E.D.

16 Induction in ACL2 Summary Form: ( THM...) Rules: ((:COMPOUND-RECOGNIZER ACL2::NATP-COMPOUND- RECOGNIZER) (:DEFINITION *-DEFINITION-RULE) (:DEFINITION +-DEFINITION-RULE) (:DEFINITION NATP) (:DEFINITION NOT) (:DEFINITION SUM-DEFINITION-RULE) (:DEFINITION ACL2::SYNP) (:EXECUTABLE-COUNTERPART COMMON-LISP::<) (:EXECUTABLE-COUNTERPART ACL2S-BB-IDENTITY-BOOL-GUARD) (:EXECUTABLE-COUNTERPART ACL2::BINARY-*) (:EXECUTABLE-COUNTERPART ACL2::BINARY-+) (:EXECUTABLE-COUNTERPART EQUAL) (:EXECUTABLE-COUNTERPART COMMON-LISP::EXPT) (:EXECUTABLE-COUNTERPART INTEGERP) (:EXECUTABLE-COUNTERPART NOT)

17 Induction in ACL2 (:EXECUTABLE-COUNTERPART SUM) (:EXECUTABLE-COUNTERPART ACL2::UNARY--) (:FAKE-RUNE-FOR-TYPE-SET NIL) (:INDUCTION SUM-INDUCTION-SCHEME) (:INDUCTION SUM-INDUCTION-SCHEME-FROM-DEFINITION) (:REWRITE ACL2:: (* -1 x) ) (:REWRITE ACL2:: (* 0 x) ) (:REWRITE ACL2:: (* 1 x) ) (:REWRITE ACL2:: (* c (* d x)) ) (:REWRITE ACL2:: (* x (+ y z)) ) (:REWRITE ACL2:: (* x (- y)) ) (:REWRITE ACL2:: (* x x) ) (:REWRITE ACL2:: (* y (* x z)) ) (:REWRITE ACL2:: (* y x) ) (:REWRITE ACL2:: (+ (* c x) (* d x)) ) (:REWRITE ACL2:: (+ (+ x y) z) ) (:REWRITE ACL2:: (+ (- x) (* c x)) ) (:REWRITE ACL2:: (+ 0 x) )

18 . Induction in ACL2 (:REWRITE ACL2:: (+ c (+ d x)) ) (:REWRITE ACL2:: (+ x (- x)) ) (:REWRITE ACL2:: (+ y (+ x z)) ) (:REWRITE ACL2:: (+ y x) ) (:REWRITE ACL2:: (- (* c x)) ) (:REWRITE ACL2:: (expt (+ x y) 2) ) (:REWRITE ACL2S-BB-IDENTITY-BOOL-GUARD-EQUAL) (:REWRITE ACL2::BUBBLE-DOWN-*-MATCH-1) (:REWRITE ACL2::BUBBLE-DOWN-+-MATCH-3) (:REWRITE ACL2::NORMALIZE-ADDENDS) (:REWRITE ACL2::NORMALIZE-FACTORS-GATHER-EXPONENTS) (:REWRITE ACL2::PREFER-POSITIVE-ADDENDS-EQUAL) (:REWRITE ACL2::SIMPLIFY-SUMS-EQUAL) (:TYPE-PRESCRIPTION ACL2S-BB-IDENTITY-BOOL-GUARD) (:TYPE-PRESCRIPTION ACL2::EXPT-TYPE-PRESCRIPTION-INTEGERP- BASE) (:TYPE-PRESCRIPTION ACL2::EXPT-TYPE-PRESCRIPTION- NONNEGATIVE-BASE)

19 Induction in ACL2 (:TYPE-PRESCRIPTION ACL2::EXPT-TYPE-PRESCRIPTION-POSITIVE- BASE) (:TYPE-PRESCRIPTION SUM-CONTRACT-TYPE-PRESCRIPTION)) Time: 0.30 seconds (prove: 0.16, print: 0.00, proof tree: 0.00, other: 0.14) Prover steps counted: 1129 Proof succeeded.

20 General Induction Scheme (defunc foo (x 1... x n ) :input-contract ic :output-contract oc (cond (t 1 c 1 ) (t 2 c 2 )... (t m c m ) (t c m+1 ))) None of the c i s should have ifs in them If c i has a recursive call to foo, it is called a recursive case otherwise a base case.

21 General Induction Scheme Case 1 = t 1 Case 2 = t 2 t 1 Case i = t i t 1 t i-1 Case m+1 = t t 1 t m If c i is a recursive case with R i calls to foo with the jth call, 1 j R i, obtained by the substitution (foo x 1... x n ) s ij

22 General Induction Scheme To prove ϕ prove the following ic ϕ [ic Case i ] ϕ For all c i s that are base cases [ic Case i 1 i R i ϕ sij ] ϕ For all c i s that are recursive cases

23 listp (defunc listp (l) :input-contract t :output-contract (booleanp (listp l)) (if (consp l) (listp (rest l)) (equal l ()))) This function is admissible.

24 app (defunc app (a b) :input-contract (and (listp a) (listp b)) :output-contract (listp (app a b)) (if (endp a) b (cons (first a) (app (rest a) b))))

25 rev (defunc rev (a) :input-contract (listp a) :output-contract (listp (rev a)) (if (endp a) nil (app (rev (rest a)) (cons (first a) nil))))

26 Conjecture After contract checking 1. (implies (and (listp a) (listp b) (listp c)) (equal (app a (app b c)) (app (app a b) c))) 2. (implies (and (listp a) (listp b)) (equal (len (app a b)) (+ (len a) (len b)))) 3. (implies (listp a) (equal (rev (rev a)) a))

27 Induction Scheme Base Case [(listp x) (listp y) (listp z)] (app (app x y) z) = (app x (app y z)) (endp x) (listp x) (listp y) (listp z) (app (app x y) z) = (app x (app y z)) Induction Step [(consp x) (listp x) (listp y) (listp z) [(listp (rest x)) (listp y) (listp z) (app (app (rest x) y) z) = (app (rest x) (app y z))]] (app (app x y) z) = (app x (app y z)) Conclude (app (app x y) z) = (app x (app y z))

28 Failed Proof Proof failure (implies (listp a) (equal (rev (rev x)) x)) Proof gets stuck - Try it! When proof gets stuck, it may suggest a lemma which should be proved before proceeding Need two additional lemmas (implies (and (listp a) (listp b)) (equal (rev (app a b)) (app (rev b) (rev a)))) (implies (listp a) (equal (app a nil) a))

29 Exercise 1. Write down the induction schemes for conjectures (2) and (3). 2. Use equational reasoning and the above induction scheme to prove (2). 3. Use ACL2s to prove (2). 4. Try to prove (3) by hand and using ACL2s. Where do you get stuck 5. Write down induction schemes and prove the lemmas needed for (3). 6. Complete the proof by hand and using ACL2s of (3)

30 Data Function Trinity 1. Data definitions give rise to predicates recognizing such definitions. These predicates must be shown to terminate. Their bodies give rise to a recursion scheme 2. Functions over these data types are defined by using the recursion scheme as a template. Templates allow us to define correct functions by assuming that the function we are defining works correctly in the recursive case.

31 Data Function Trinity 3. Proofs by induction involving such functions and data definitions should use the same recursion scheme to generate proof obligations. Nonrecursive cases are proven directly. For each recursive case, we assume the theorem under any substitutions that map the formals to arguments in that recursive call.

Reasoning About Programs Panagiotis Manolios

Reasoning About Programs Panagiotis Manolios Reasoning About Programs Panagiotis Manolios Northeastern University February 26, 2017 Version: 100 Copyright c 2017 by Panagiotis Manolios All rights reserved. We hereby grant permission for this publication

More information

Introduction to ACL2. CS 680 Formal Methods for Computer Verification. Jeremy Johnson Drexel University

Introduction to ACL2. CS 680 Formal Methods for Computer Verification. Jeremy Johnson Drexel University Introduction to ACL2 CS 680 Formal Methods for Computer Verification Jeremy Johnson Drexel University ACL2 www.cs.utexas.edu/~moore/acl2 ACL2 is a programming language, logic, and theorem prover/checker

More information

Reasoning About Programs Panagiotis Manolios

Reasoning About Programs Panagiotis Manolios Reasoning About Programs Panagiotis Manolios Northeastern University March 22, 2012 Version: 58 Copyright c 2012 by Panagiotis Manolios All rights reserved. We hereby grant permission for this publication

More information

Reasoning About Programs Panagiotis Manolios

Reasoning About Programs Panagiotis Manolios Reasoning About Programs Panagiotis Manolios Northeastern University March 1, 2017 Version: 101 Copyright c 2017 by Panagiotis Manolios All rights reserved. We hereby grant permission for this publication

More information

A Tool for Simplifying ACL2 Definitions

A Tool for Simplifying ACL2 Definitions 1/27 A Tool for Simplifying ACL2 Definitions Matt Kaufmann The University of Texas at Austin May 3, 2016 2/27 INTRODUCTION (1) In this talk we present a tool for simplifying ACL2 definitions. Used in Kestrel

More information

Logic and Computation Lecture 20 CSU 290 Spring 2009 (Pucella) Thursday, Mar 12, 2009

Logic and Computation Lecture 20 CSU 290 Spring 2009 (Pucella) Thursday, Mar 12, 2009 Logic and Computation Lecture 20 CSU 290 Spring 2009 (Pucella) Thursday, Mar 12, 2009 Note that I change the name of the functions slightly in these notes from what I used in class, to be consistent with

More information

Reasoning About Programs Panagiotis Manolios

Reasoning About Programs Panagiotis Manolios Reasoning About Programs Panagiotis Manolios Northeastern University April 2, 2016 Version: 95 Copyright c 2016 by Panagiotis Manolios All rights reserved. We hereby grant permission for this publication

More information

Backtracking and Induction in ACL2

Backtracking and Induction in ACL2 Backtracking and Induction in ACL2 John Erickson University of Texas at Austin jderick@cs.utexas.edu ABSTRACT This paper presents an extension to ACL2 that allows backtracking to occur when a proof fails.

More information

Propositional Calculus. Math Foundations of Computer Science

Propositional Calculus. Math Foundations of Computer Science Propositional Calculus Math Foundations of Computer Science Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they can use it to

More information

Recursion and Induction

Recursion and Induction Recursion and Induction Basics Warren A. Hunt, Jr. hunt@cs.utexas.edu University of Texas, Austin January 28, 2015 Adapted from J Moore s Recursion and Induction Notes. Introduction The language we will

More information

Finite Set Theory. based on Fully Ordered Lists. Jared Davis UT Austin. ACL2 Workshop 2004

Finite Set Theory. based on Fully Ordered Lists. Jared Davis UT Austin. ACL2 Workshop 2004 Finite Set Theory based on Fully Ordered Lists Jared Davis UT Austin ACL2 Workshop 2004 Motivation (1/2) Unique representation for each set No mutual recursion needed for membership, subset, and set equality

More information

Milawa an extensible proof checker

Milawa an extensible proof checker Milawa an extensible proof checker Jared Davis ACL2 Seminar, November 16, 2005 Outline The Milawa logic A primitive proof checker An extended proof checker Soundness of the extended checker A reflection

More information

MoreIntro_annotated.v. MoreIntro_annotated.v. Printed by Zach Tatlock. Oct 04, 16 21:55 Page 1/10

MoreIntro_annotated.v. MoreIntro_annotated.v. Printed by Zach Tatlock. Oct 04, 16 21:55 Page 1/10 Oct 04, 16 21:55 Page 1/10 * Lecture 02 Infer some type arguments automatically. Set Implicit Arguments. Note that the type constructor for functions (arrow " >") associates to the right: A > B > C = A

More information

Improving Eliminate-Irrelevance for ACL2

Improving Eliminate-Irrelevance for ACL2 1/19 Improving Eliminate-Irrelevance for ACL2 Matt Kaufmann (Joint Work with J Moore) The University of Texas at Austin October 14, 2016 2/19 OUTLINE Organization of this talk. 2/19 OUTLINE Organization

More information

Proof-Pattern Recognition and Lemma Discovery in ACL2

Proof-Pattern Recognition and Lemma Discovery in ACL2 Proof-Pattern Recognition and Lemma Discovery in ACL2 Jónathan Heras (joint work with K. Komendantskaya, M. Johansson and E. Maclean) University of Dundee http://staff.computing.dundee.ac.uk/jheras/acl2ml/

More information

May, 2008 (updated, April, 2018)

May, 2008 (updated, April, 2018) Recursion and Induction J Strother Moore Department of Computer Sciences University of Texas at Austin Austin, Tx 78712 moore@cs.utexas.edu (512) 471-9590 May, 2008 (updated, April, 2018) 1 Abstract This

More information

Midterm Exam 2 CS313K Logic, Sets, and Functions Spring, 2009

Midterm Exam 2 CS313K Logic, Sets, and Functions Spring, 2009 Your Name: Your EID: Circle Your Discussion Section: 54075: Ian Wehrman, Friday, 9:00 10:00a, ENS 109 54080: Ian Wehrman, Friday, 10:00 11:00a, GSB 2.122 54085: David Rager, Friday, 10:00 11:00a, JES A218A

More information

Verifying Centaur s Floating Point Adder

Verifying Centaur s Floating Point Adder Verifying Centaur s Floating Point Adder Sol Swords sswords@cs.utexas.edu April 23, 2008 Sol Swords () Verifying Centaur s Floating Point Adder April 23, 2008 1 / 21 Problem Given: Verilog RTL for the

More information

Theorem Proving Principles, Techniques, Applications Recursion

Theorem Proving Principles, Techniques, Applications Recursion NICTA Advanced Course Theorem Proving Principles, Techniques, Applications Recursion 1 CONTENT Intro & motivation, getting started with Isabelle Foundations & Principles Lambda Calculus Higher Order Logic,

More information

Creating Formally Verified Components for Layered Assurance with an LLVM-to-ACL2 Translator

Creating Formally Verified Components for Layered Assurance with an LLVM-to-ACL2 Translator Creating Formally Verified Components for Layered Assurance with an LLVM-to-ACL2 Translator Jennifer Davis, David Hardin, Jedidiah McClurg December 2013 Introduction Research objectives: Reduce need to

More information

An Industrially Useful Prover

An Industrially Useful Prover An Industrially Useful Prover J Strother Moore Department of Computer Science University of Texas at Austin July, 2017 1 Recap Yesterday s Talk: ACL2 is used routinely in the microprocessor industry to

More information

Development of a Translator from LLVM to ACL2

Development of a Translator from LLVM to ACL2 Development of a Translator from LLVM to ACL2 David Hardin, Jennifer Davis, David Greve, and Jedidiah McClurg July 2014 Introduction Research objectives: Reason about machine code generated from high-level

More information

Recursion and Induction

Recursion and Induction Recursion and Induction Paul S. Miner NASA Langley Formal Methods Group p.s.miner@nasa.gov 28 November 2007 Outline Recursive definitions in PVS Simple inductive proofs Automated proofs by induction More

More information

Efficient execution in an automated reasoning environment

Efficient execution in an automated reasoning environment JFP 18 (1): 15 46, 2008. c 2007 Cambridge University Press doi:10.1017/s0956796807006338 First published online 23 April 2007 Printed in the United Kingdom 15 Efficient execution in an automated reasoning

More information

A Mechanically Checked Proof of the Correctness of the Boyer-Moore Fast String Searching Algorithm

A Mechanically Checked Proof of the Correctness of the Boyer-Moore Fast String Searching Algorithm A Mechanically Checked Proof of the Correctness of the Boyer-Moore Fast String Searching Algorithm J Strother MOORE a,1 and Matt MARTINEZ a a Department of Computer Sciences, University of Texas at Austin,

More information

SAT Solver. CS 680 Formal Methods Jeremy Johnson

SAT Solver. CS 680 Formal Methods Jeremy Johnson SAT Solver CS 680 Formal Methods Jeremy Johnson Disjunctive Normal Form A Boolean expression is a Boolean function Any Boolean function can be written as a Boolean expression s x 0 x 1 f Disjunctive normal

More information

CSE 215: Foundations of Computer Science Recitation Exercises Set #4 Stony Brook University. Name: ID#: Section #: Score: / 4

CSE 215: Foundations of Computer Science Recitation Exercises Set #4 Stony Brook University. Name: ID#: Section #: Score: / 4 CSE 215: Foundations of Computer Science Recitation Exercises Set #4 Stony Brook University Name: ID#: Section #: Score: / 4 Unit 7: Direct Proof Introduction 1. The statement below is true. Rewrite the

More information

Integrating External Deduction Tools with ACL2,

Integrating External Deduction Tools with ACL2, Integrating External Deduction Tools with ACL2, Matt Kaufmann Department of Computer Sciences, University of Texas at Austin, Austin, TX 78712-0233, USA. J Strother Moore Department of Computer Sciences,

More information

Mathematica for the symbolic. Combining ACL2 and. ACL2 Workshop 2003 Boulder,CO. TIMA Laboratory -VDS Group, Grenoble, France

Mathematica for the symbolic. Combining ACL2 and. ACL2 Workshop 2003 Boulder,CO. TIMA Laboratory -VDS Group, Grenoble, France Combining ACL2 and Mathematica for the symbolic simulation of digital systems AL SAMMANE Ghiath, BORRIONE Dominique, OSTIER Pierre, SCHMALTZ Julien, TOMA Diana TIMA Laboratory -VDS Group, Grenoble, France

More information

Copyright by Sol Otis Swords 2010

Copyright by Sol Otis Swords 2010 Copyright by Sol Otis Swords 2010 The Dissertation Committee for Sol Otis Swords certifies that this is the approved version of the following dissertation: A Verified Framework for Symbolic Execution in

More information

Parameterized Congruences in ACL2

Parameterized Congruences in ACL2 Parameterized Congruences in ACL2 David Greve Rockwell Collins Advanced Technology Center Cedar Rapids, IA dagreve@rockwellcollins.com ABSTRACT Support for congruence-based rewriting is built into ACL2.

More information

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1 Graph fundamentals Bipartite graph characterization Lemma. If a graph contains an odd closed walk, then it contains an odd cycle. Proof strategy: Consider a shortest closed odd walk W. If W is not a cycle,

More information

Fall Recursion and induction. Stephen Brookes. Lecture 4

Fall Recursion and induction. Stephen Brookes. Lecture 4 15-150 Fall 2018 Stephen Brookes Lecture 4 Recursion and induction Last time Specification format for a function F type assumption guarantee (REQUIRES) (ENSURES) For all (properly typed) x satisfying the

More information

Induction in Coq. Nate Foster Spring 2018

Induction in Coq. Nate Foster Spring 2018 Induction in Coq Nate Foster Spring 2018 Review Previously in 3110: Functional programming in Coq Logic in Coq Curry-Howard correspondence (proofs are programs) Today: Induction in Coq REVIEW: INDUCTION

More information

Formal Systems and their Applications

Formal Systems and their Applications Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction

More information

Fundamental mathematical techniques reviewed: Mathematical induction Recursion. Typically taught in courses such as Calculus and Discrete Mathematics.

Fundamental mathematical techniques reviewed: Mathematical induction Recursion. Typically taught in courses such as Calculus and Discrete Mathematics. Fundamental mathematical techniques reviewed: Mathematical induction Recursion Typically taught in courses such as Calculus and Discrete Mathematics. Techniques introduced: Divide-and-Conquer Algorithms

More information

6.001 Notes: Section 4.1

6.001 Notes: Section 4.1 6.001 Notes: Section 4.1 Slide 4.1.1 In this lecture, we are going to take a careful look at the kinds of procedures we can build. We will first go back to look very carefully at the substitution model,

More information

Programming Languages Fall 2014

Programming Languages Fall 2014 Programming Languages Fall 2014 Lecture 7: Simple Types and Simply-Typed Lambda Calculus Prof. Liang Huang huang@qc.cs.cuny.edu 1 Types stuck terms? how to fix it? 2 Plan First I For today, we ll go back

More information

Refinement and Theorem Proving

Refinement and Theorem Proving Refinement and Theorem Proving Panagiotis Manolios College of Computing Georgia Institute of Technology Atlanta, GA, 30318 manolios@cc.gatech.edu 1 Introduction In this chapter, we describe the ACL2 theorem

More information

Extending ACL2 with SMT solvers

Extending ACL2 with SMT solvers Extending ACL2 with SMT solvers Yan Peng & Mark Greenstreet University of British Columbia October 2nd, 2015 Smtlink handles tedious details of proofs so you can focus on the interesting parts. 1 / 24

More information

Week 5 Tutorial Structural Induction

Week 5 Tutorial Structural Induction Department of Computer Science, Australian National University COMP2600 / COMP6260 Formal Methods in Software Engineering Semester 2, 2016 Week 5 Tutorial Structural Induction You should hand in attempts

More information

Basic Foundations of Isabelle/HOL

Basic Foundations of Isabelle/HOL Basic Foundations of Isabelle/HOL Peter Wullinger May 16th 2007 1 / 29 1 Introduction into Isabelle s HOL Why Type Theory Basic Type Syntax 2 More HOL Typed λ Calculus HOL Rules 3 Example proof 2 / 29

More information

Copyright. John D. Erickson

Copyright. John D. Erickson Copyright by John D. Erickson 2008 The Dissertation Committee for John D. Erickson certifies that this is the approved version of the following dissertation: Generalization, Lemma Generation, and Induction

More information

Theorem proving. PVS theorem prover. Hoare style verification PVS. More on embeddings. What if. Abhik Roychoudhury CS 6214

Theorem proving. PVS theorem prover. Hoare style verification PVS. More on embeddings. What if. Abhik Roychoudhury CS 6214 Theorem proving PVS theorem prover Abhik Roychoudhury National University of Singapore Both specification and implementation can be formalized in a suitable logic. Proof rules for proving statements in

More information

Progress Report: Term Dags Using Stobjs

Progress Report: Term Dags Using Stobjs Progress Report: Term Dags Using Stobjs J.-L. Ruiz-Reina, J.-A. Alonso, M.-J. Hidalgo and F.-J. Martín-Mateos http://www.cs.us.es/{~jruiz, ~jalonso, ~mjoseh, ~fmartin} Departamento de Ciencias de la Computación

More information

Mechanized Operational Semantics

Mechanized Operational Semantics Mechanized Operational Semantics J Strother Moore Department of Computer Sciences University of Texas at Austin Marktoberdorf Summer School 2008 (Lecture 3: Direct Proofs) 1 Fact 1 Given an operational

More information

Proving Properties of Recursive Functions and Data Structures. CS 270 Math Foundations of CS Jeremy Johnson

Proving Properties of Recursive Functions and Data Structures. CS 270 Math Foundations of CS Jeremy Johnson Proving Properties of Recursive Functions and Data Structures CS 270 Math Foundations of CS Jeremy Johnson 1 Objective To implement and verify recursive functions for processing recursive data structures.

More information

Making Induction Manifest in Modular ACL2

Making Induction Manifest in Modular ACL2 Making Induction Manifest in Modular ACL2 Carl Eastlund Matthias Felleisen Northeastern University Boston, Massachusetts, U.S.A. {cce,matthias}@ccs.neu.edu Abstract ACL2, a Common Lisp-based language for

More information

MoreIntro.v. MoreIntro.v. Printed by Zach Tatlock. Oct 07, 16 18:11 Page 1/10. Oct 07, 16 18:11 Page 2/10. Monday October 10, 2016 lec02/moreintro.

MoreIntro.v. MoreIntro.v. Printed by Zach Tatlock. Oct 07, 16 18:11 Page 1/10. Oct 07, 16 18:11 Page 2/10. Monday October 10, 2016 lec02/moreintro. Oct 07, 16 18:11 Page 1/10 * Lecture 02 Set Implicit Arguments. Inductive list (A: Type) : Type := nil : list A cons : A > list A > list A. Fixpoint length (A: Type) (l: list A) : nat := nil _ => O cons

More information

Functions, Conditionals & Predicates

Functions, Conditionals & Predicates Functions, Conditionals & Predicates York University Department of Computer Science and Engineering 1 Overview Functions as lambda terms Defining functions Variables (bound vs. free, local vs. global)

More information

3.4 Warm Up. Substitute the given values of m, x, and y into the equation y = mx + b and solve for b. 2. m = 2, x = 3, and y = 0

3.4 Warm Up. Substitute the given values of m, x, and y into the equation y = mx + b and solve for b. 2. m = 2, x = 3, and y = 0 3.4 Warm Up 1. Find the values of x and y. Substitute the given values of m, x, and y into the equation y = mx + b and solve for b. 2. m = 2, x = 3, and y = 0 3. m = -1, x = 5, and y = -4 3.3 Proofs with

More information

The Formal Semantics of Programming Languages An Introduction. Glynn Winskel. The MIT Press Cambridge, Massachusetts London, England

The Formal Semantics of Programming Languages An Introduction. Glynn Winskel. The MIT Press Cambridge, Massachusetts London, England The Formal Semantics of Programming Languages An Introduction Glynn Winskel The MIT Press Cambridge, Massachusetts London, England Series foreword Preface xiii xv 1 Basic set theory 1 1.1 Logical notation

More information

Case-Analysis for Rippling and Inductive Proof

Case-Analysis for Rippling and Inductive Proof Case-Analysis for Rippling and Inductive Proof Moa Johansson 1 Joint work with Lucas Dixon 2 and Alan Bundy 2 Dipartimento di Informatica, Università degli Studi di Verona, Italy. 1 School of Informatics,

More information

Introduction to Co-Induction in Coq

Introduction to Co-Induction in Coq August 2005 Motivation Reason about infinite data-structures, Reason about lazy computation strategies, Reason about infinite processes, abstracting away from dates. Finite state automata, Temporal logic,

More information

PARSIFAL Summer 2011 Internship Report Logically validating logic programs

PARSIFAL Summer 2011 Internship Report Logically validating logic programs PARSIFAL Summer 2011 Internship Report Logically validating logic programs Chris Martens August 22, 2011 1 Overview Logic programs can be used to specify systems, and logic programming languages such as

More information

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Section 17.2

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Section 17.2 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Section 17.2 Instructor: Carlos Varela Rensselaer Polytechnic Institute Spring 2018 CSCI.6962/4962

More information

Functional Programming with Isabelle/HOL

Functional Programming with Isabelle/HOL Functional Programming with Isabelle/HOL = Isabelle λ β HOL α Florian Haftmann Technische Universität München January 2009 Overview Viewing Isabelle/HOL as a functional programming language: 1. Isabelle/HOL

More information

Induction and Recursion. CMPS/MATH 2170: Discrete Mathematics

Induction and Recursion. CMPS/MATH 2170: Discrete Mathematics Induction and Recursion CMPS/MATH 2170: Discrete Mathematics Outline Mathematical induction (5.1) Sequences and Summations (2.4) Strong induction (5.2) Recursive definitions (5.3) Recurrence Relations

More information

CONTENTS defstructure CONTENTS Contents 1 Introduction 3 2 User's Guide Basic Use Typed Structur

CONTENTS defstructure CONTENTS Contents 1 Introduction 3 2 User's Guide Basic Use Typed Structur defstructure for ACL2 Version 2.0 Bishop Brock Computational Logic, Inc. brock@cli.com December 1, 1997 Abstract This article documents the defstructure macro, a facility provided by the ACL2 book acl2-sources/books/data-structures/structures.lisp

More information

4 Programming with Types

4 Programming with Types 4 Programming with Types 4.1 Polymorphism We ve been working a lot with lists of numbers, but clearly programs also need to be able to manipulate lists whose elements are drawn from other types lists of

More information

A Machine-Checked Safety Proof for a CISC-Compatible SFI Technique

A Machine-Checked Safety Proof for a CISC-Compatible SFI Technique A Machine-Checked Safety Proof for a CISC-Compatible SFI Technique Stephen McCamant Massachusetts Institute of Technology Computer Science and Artificial Intelligence Laboratory Cambridge, MA 02139 smcc@csail.mit.edu

More information

Proving Theorems about Java and the JVM

Proving Theorems about Java and the JVM Proving Theorems about Java and the JVM with ACL2 J Strother Moore Department of Computer Sciences, University of Texas at Austin, Taylor Hall 2.124, Austin, Texas 78712 DRAFT June 16, 2002 Abstract. We

More information

Polymorphic Types in ACL2

Polymorphic Types in ACL2 Polymorphic Types in ACL2 Benjamin Selfridge University of Texas at Austin Austin, TX benself@cs.utexas.edu Eric Smith Kestrel Institute Palo Alto, CA eric.smith@kestrel.edu This paper describes a tool

More information

Using Hashtables to Find the Generation Point of a Problematic Cons

Using Hashtables to Find the Generation Point of a Problematic Cons Using Hashtables to Find the Generation Point of a Problematic Cons Often when you generate a piece of bad data, you don t see a failure until after the program makes a lot of progress. In this case, issuing

More information

Expr_annotated.v. Expr_annotated.v. Printed by Zach Tatlock

Expr_annotated.v. Expr_annotated.v. Printed by Zach Tatlock Oct 05, 16 8:02 Page 1/14 * Lecture 03 Include some useful libraries. Require Import Bool. Require Import List. Require Import String. Require Import ZArith. Require Import Omega. List provides the cons

More information

3 Pairs and Lists. 3.1 Formal vs. Informal Proofs

3 Pairs and Lists. 3.1 Formal vs. Informal Proofs 3 Pairs and Lists 3.1 Formal vs. Informal Proofs The question of what, exactly, constitutes a proof of a mathematical claim has challenged philosophers throughout the ages. A rough and ready definition,

More information

CS240 Fall Mike Lam, Professor. Recurrences

CS240 Fall Mike Lam, Professor. Recurrences CS240 Fall 2014 Mike Lam, Professor Recurrences Announcement A solution to PA2 has been posted on Canvas Most of the functions can be re-used between PA2 and PA3 As long as they are written in terms independent

More information

Bit-Blasting ACL2 Theorems

Bit-Blasting ACL2 Theorems Bit-Blasting ACL2 Theorems Sol Swords and Jared Davis Centaur Technology Inc. 7600-C N. Capital of Texas Hwy, Suite 300 Austin, TX 78731 {sswords,jared}@centtech.com Interactive theorem proving requires

More information

Fall 2013 Midterm Exam 10/22/13. This is a closed-book, closed-notes exam. Problem Points Score. Various definitions are provided in the exam.

Fall 2013 Midterm Exam 10/22/13. This is a closed-book, closed-notes exam. Problem Points Score. Various definitions are provided in the exam. Programming Languages Fall 2013 Midterm Exam 10/22/13 Time Limit: 100 Minutes Name (Print): Graduate Center I.D. This is a closed-book, closed-notes exam. Various definitions are provided in the exam.

More information

Proving Theorems with Athena

Proving Theorems with Athena Proving Theorems with Athena David R. Musser Aytekin Vargun August 28, 2003, revised January 26, 2005 Contents 1 Introduction 1 2 Proofs about order relations 2 3 Proofs about natural numbers 7 3.1 Term

More information

A Small Interpreted Language

A Small Interpreted Language A Small Interpreted Language What would you need to build a small computing language based on mathematical principles? The language should be simple, Turing equivalent (i.e.: it can compute anything that

More information

A verified runtime for a verified theorem prover

A verified runtime for a verified theorem prover A verified runtime for a verified theorem prover Magnus Myreen 1 and Jared Davis 2 1 University of Cambridge, UK 2 Centaur Technology, USA Two projects meet My theorem prover is written in Lisp. Can I

More information

CSE 20 DISCRETE MATH. Winter

CSE 20 DISCRETE MATH. Winter CSE 20 DISCRETE MATH Winter 2017 http://cseweb.ucsd.edu/classes/wi17/cse20-ab/ Final exam The final exam is Saturday March 18 8am-11am. Lecture A will take the exam in GH 242 Lecture B will take the exam

More information

Machines Reasoning about Machines

Machines Reasoning about Machines Machines Reasoning about Machines A Personal Perspective J Strother Moore Department of Computer Sciences University of Texas at Austin 1 Prologue For forty years I have been working toward one goal: to

More information

Recursion & Iteration

Recursion & Iteration Recursion & Iteration York University Department of Computer Science and Engineering 1 Overview Recursion Examples Iteration Examples Iteration vs. Recursion Example [ref.: Chap 5,6 Wilensky] 2 Recursion

More information

λ calculus is inconsistent

λ calculus is inconsistent Content Rough timeline COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray λ Intro & motivation, getting started [1] Foundations & Principles

More information

Integrating Reasoning about Ordinal Arithmetic into ACL2

Integrating Reasoning about Ordinal Arithmetic into ACL2 Integrating Reasoning about Ordinal Arithmetic into ACL2 Panagiotis Manolios and Daron Vroon Georgia Institute of Technology, College of Computing 801 Atlantic Drive, Atlanta, Georgia, 30332, USA, {manolios,vroon}@cc.gatech.edu

More information

3-2 Angles and Parallel Lines. In the figure, m 1 = 94. Find the measure of each angle. Tell which postulate(s) or theorem (s) you used.

3-2 Angles and Parallel Lines. In the figure, m 1 = 94. Find the measure of each angle. Tell which postulate(s) or theorem (s) you used. In the figure, m 1 = 94. Find the measure of each angle. Tell which postulate(s) or theorem (s) you used. 7. ROADS In the diagram, the guard rail is parallel to the surface of the roadway and the vertical

More information

Finite Set Theory based on Fully Ordered Lists

Finite Set Theory based on Fully Ordered Lists Finite Set Theory based on Fully Ordered Lists Jared Davis Department of Computer Sciences The University of Texas at Austin Austin, TX 78712-1188 jared@cs.utexas.edu Abstract We present a new finite set

More information

Inductive data types

Inductive data types Inductive data types Assia Mahboubi 9 juin 2010 In this class, we shall present how Coq s type system allows us to define data types using inductive declarations. Generalities Inductive declarations An

More information

Verification in Coq. Prof. Clarkson Fall Today s music: Check Yo Self by Ice Cube

Verification in Coq. Prof. Clarkson Fall Today s music: Check Yo Self by Ice Cube Verification in Coq Prof. Clarkson Fall 2017 Today s music: Check Yo Self by Ice Cube Review Previously in 3110: Functional programming in Coq Logic in Coq Curry-Howard correspondence (proofs are programs)

More information

c constructor P, Q terms used as propositions G, H hypotheses scope identifier for a notation scope M, module identifiers t, u arbitrary terms

c constructor P, Q terms used as propositions G, H hypotheses scope identifier for a notation scope M, module identifiers t, u arbitrary terms Coq quick reference Meta variables Usage Meta variables Usage c constructor P, Q terms used as propositions db identifier for a hint database s string G, H hypotheses scope identifier for a notation scope

More information

Coq quick reference. Category Example Description. Inductive type with instances defined by constructors, including y of type Y. Inductive X : Univ :=

Coq quick reference. Category Example Description. Inductive type with instances defined by constructors, including y of type Y. Inductive X : Univ := Coq quick reference Category Example Description Meta variables Usage Meta variables Usage c constructor P, Q terms used as propositions db identifier for a hint database s string G, H hypotheses scope

More information

CIS 500: Software Foundations

CIS 500: Software Foundations CIS 500: Software Foundations Midterm I October 3, 2017 Name (printed): Username (PennKey login id): My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic

More information

An ACL2 Tutorial. Matt Kaufmann and J Strother Moore

An ACL2 Tutorial. Matt Kaufmann and J Strother Moore An ACL2 Tutorial Matt Kaufmann and J Strother Moore Department of Computer Sciences, University of Texas at Austin, Taylor Hall 2.124, Austin, Texas 78712 {kaufmann,moore}@cs.utexas.edu Abstract. We describe

More information

Programming Languages

Programming Languages CSE 230: Winter 2008 Principles of Programming Languages Ocaml/HW #3 Q-A Session Push deadline = Mar 10 Session Mon 3pm? Lecture 15: Type Systems Ranjit Jhala UC San Diego Why Typed Languages? Development

More information

CSE 20 DISCRETE MATH WINTER

CSE 20 DISCRETE MATH WINTER CSE 20 DISCRETE MATH WINTER 2016 http://cseweb.ucsd.edu/classes/wi16/cse20-ab/ Today's learning goals Explain the steps in a proof by (strong) mathematical induction Use (strong) mathematical induction

More information

CIS 500: Software Foundations

CIS 500: Software Foundations CIS 500: Software Foundations Midterm I October 4, 2016 Name (printed): Username (PennKey login id): My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic

More information

Software Verification with ACL2

Software Verification with ACL2 Software Verification with ACL2 Francisco Palomo Lozano francisco.palomo@uca.es Software Verification and Validation Department of Computer Science Summary Introduction 1 Introduction 2 First Steps 3 Atoms

More information

The Prototype Verification System PVS

The Prototype Verification System PVS The Prototype Verification System PVS Wolfgang Schreiner Wolfgang.Schreiner@risc.uni-linz.ac.at Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria http://www.risc.uni-linz.ac.at

More information

CSC236 Week 4. Larry Zhang

CSC236 Week 4. Larry Zhang CSC236 Week 4 Larry Zhang 1 Announcements PS2 is out Larry s office hours in the reading week: as usual Tuesday 12-2, Wednesday 2-4 2 NEW TOPIC Recursion To really understand the math of recursion, and

More information

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections p.

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections p. CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections 10.1-10.3 p. 1/106 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer

More information

Lisp. Versions of LISP

Lisp. Versions of LISP Lisp Versions of LISP Lisp is an old language with many variants Lisp is alive and well today Most modern versions are based on Common Lisp LispWorks is based on Common Lisp Scheme is one of the major

More information

TECH. Recurrence Equations vs. Recursive Procedures. Recursion and Induction. e.g. Fibonacci Function. The working of recursive procedure

TECH. Recurrence Equations vs. Recursive Procedures. Recursion and Induction. e.g. Fibonacci Function. The working of recursive procedure Recursion and Induction For advanced algorithm development, recursion is an essential design technique Recursive Procedures What is a Proof? Induction Proofs Proving Correctness of Procedures Recurrence

More information

AXIOMS FOR THE INTEGERS

AXIOMS FOR THE INTEGERS AXIOMS FOR THE INTEGERS BRIAN OSSERMAN We describe the set of axioms for the integers which we will use in the class. The axioms are almost the same as what is presented in Appendix A of the textbook,

More information

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Copyright Cengage Learning. All rights reserved. SECTION 5.5 Application: Correctness of Algorithms Copyright Cengage Learning. All rights reserved.

More information

CIS 500 Software Foundations. Midterm I. (Standard and advanced versions together) October 1, 2013 Answer key

CIS 500 Software Foundations. Midterm I. (Standard and advanced versions together) October 1, 2013 Answer key CIS 500 Software Foundations Midterm I (Standard and advanced versions together) October 1, 2013 Answer key 1. (12 points) Write the type of each of the following Coq expressions, or write ill-typed if

More information

Lecture 6: Sequential Sorting

Lecture 6: Sequential Sorting 15-150 Lecture 6: Sequential Sorting Lecture by Dan Licata February 2, 2012 Today s lecture is about sorting. Along the way, we ll learn about divide and conquer algorithms, the tree method, and complete

More information

August 5-10, 2013, Tsinghua University, Beijing, China. Polymorphic types

August 5-10, 2013, Tsinghua University, Beijing, China. Polymorphic types 5th Asian-Pacific Summer School on Formal Methods August 5-10, 2013, Tsinghua University, Beijing, China Polymorphic types jean-jacques.levy@inria.fr 2013-8-8 http://sts.thss.tsinghua.edu.cn/coqschool2013

More information

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Alessandro Artale UniBZ - http://www.inf.unibz.it/ artale/ SECTION 5.5 Application: Correctness of Algorithms Copyright Cengage Learning. All

More information