CSE-490 Logic in Computer Science The Coq Proof Assistant POSTECH Dec 15, 2006 박성우.

Slides:



Advertisements
Similar presentations
Verifying the Four Colour Theorem Georges Gonthier Microsoft Research Cambridge.
Advertisements

Types and Programming Languages Lecture 4 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Functional Programming Lecture 13 - induction on lists.
Isabelle / HOL Theorem Proving System
Computing Fundamentals 2 Introduction to CafeOBJ Lecturer: Patrick Browne Lecture Room: K408 Lab Room: A308 Based on work by: Nakamura Masaki, João Pascoal.
Formalising the structure of extremal p-groups Georges Gonthier.
Proofs and Programs Wei Hu 11/01/2007. Outline  Motivation  Theory  Lambda calculus  Curry-Howard Isomorphism  Dependent types  Practice  Coq Wei.
Semantics of Hoare Logic Aquinas Hobor and Martin Henz.
Computer Science & Engineering 2111 IF and Boolean Functions 1 CSE 2111 Lecture-IF and Boolean Functions.
1 How to transform an analyzer into a verifier. 2 OUTLINE OF THE LECTURE a verification technique which combines abstract interpretation and Park’s fixpoint.
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
Automated reasoning about retrograde chess problems using Coq Marko Maliković, Ph.D. The Faculty of Humanities and Social Sciences University of Rijeka,
School of Computing and Mathematics, University of Huddersfield CAS2545: WEEK 11 LECTURE: n The meaning of Algebraic Specifications TUTORIAL/PRACTICAL:
CPSC 322, Lecture 20Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Computer Science cpsc322, Lecture 20 (Textbook.
מבנה המחשב + מבוא למחשבים ספרתיים תרגול 1#
School of Computing and Mathematics, University of Huddersfield CIA2326 Week 14 LECTURE: How to reason with Algebraic Specifications TUTORIAL/PRACTICAL:
General Computer Science for Engineers CISC 106 Lecture 33 Dr. John Cavazos Computer and Information Sciences 05/11/2009.
Discrete Structures Chapter 5: Sequences, Mathematical Induction, and Recursion 5.2 Mathematical Induction I [Mathematical induction is] the standard proof.
Propositional Calculus CS 680: Formal Methods in Verification Computer Systems Jeremy Johnson.
Equational Reasoning Math Foundations of Computer Science.
The ACL2 Proof Assistant Formal Methods Jeremy Johnson.
CISC 2315 Discrete Structures Professor William G. Tanner, Jr. Fall 2010 Slides created by James L. Hein, author of Discrete Structures, Logic, and Computability,
CAS- 734 (Presentation -1) By : Vasudha Kapil
Induction Schemes Math Foundations of Computer Science.
CSE 311: Foundations of Computing Fall 2013 Lecture 8: More Proofs.
CSE-321 Programming Languages Introduction to Functional Programming (Part II) POSTECH March 13, 2006 박성우.
F22H1 Logic and Proof Week 6 Reasoning. How can we show that this is a tautology (section 11.2): The hard way: “logical calculation” The “easy” way: “reasoning”
CSE 311 Foundations of Computing I Lecture 8 Proofs and Set Theory Spring
Mathematical Induction II Lecture 21 Section 4.3 Mon, Feb 27, 2006.
Slides for CISC 2315: Discrete Structures Chapters CISC 2315 Discrete Structures Professor William G. Tanner, Jr. SPRING 2010 Slides created by James.
CISC 2315 Discrete Structures Professor William G. Tanner, Jr. Spring 2011 Slides created by James L. Hein, author of Discrete Structures, Logic, and Computability,
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Type Safety Kangwon National University 임현승 Programming Languages.
School of Computing and Engineering, University of Huddersfield CIA2326 Week 14 LECTURE: Formal Specifications. How to reason with Algebraic Specifications.
Logic in Computer Science - Overview Sep 1, 2009 박성우.
Lecture 7 All-Pairs Shortest Paths. All-Pairs Shortest Paths.
Proofs, Induction and Recursion Basic Proof Techniques Mathematical Induction Recursive Functions and Recurrence Relations.
Inductive Predicates  Unit vs True  Inductive unit : Set := tt : unit  Inductive True : Prop := I : True  Curry Howard Isomorphism  But Coq distinguish.
CSE 311 Foundations of Computing I Lecture 9 Proofs and Set Theory Autumn 2012 CSE
CSE-321 Programming Languages Review POSTECH June 14, 2011 박성우.
October 3, 2001CSE 373, Autumn Mathematical Background Exponents X A X B = X A+B X A / X B = X A-B (X A ) B = X AB X N +X N = 2X N 2 N +2 N = 2 N+1.
Lecture 4 Correctness and Fairness Verification and Assurance.
CSE 311: Foundations of Computing Fall 2013 Lecture 8: Proofs and Set theory.
CSE-321 Programming Languages Curry-Howard Isomorphism POSTECH June 4, 2009 박성우.
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
Boolean Expression Evaluation CS 270: Math Foundations of CS Jeremy Johnson.
Carnegie Mellon Vadim Zaliva, Franz Franchetti Carnegie Mellon University Department of Electrical and Computer Engineering Funded by the DARPA I2O HACMS.
CSE 311 Foundations of Computing I Lecture 8 Proofs Autumn 2011 CSE 3111.
CSE 311 Foundations of Computing I Lecture 8 Proofs Autumn 2012 CSE
Integrating Math Units and Proof Checking for Specification and Verification SAVCBS Workshop 2008 SIGSOFT 2008 / FSE 16 November 9th, 2008 Hampton Smith.
Section 8.4 Mathematical Induction. Mathematical Induction In this section we are going to perform a type of mathematical proof called mathematical induction.
Section 2.3 Mathematical Induction. First Example Investigate the sum of the first n positive odd integers. 1= ____ 1 + 3= ____ = ____
Foundations of Computing I CSE 311 Fall Announcements Homework #2 due today – Solutions available (paper format) in front – HW #3 will be posted.
Mostly-Automated Verification of Low-Level Programs in Computational Separation Logic Adam Chlipala Harvard University PLDI 2011.
1 Interactive Computer Theorem Proving CS294-9 October 5, 2006 Adam Chlipala UC Berkeley Lecture 7: Programming with Proofs.
1 Interactive Computer Theorem Proving CS294-9 November 30, 2006 Adam Chlipala UC Berkeley Lecture 14: Twelf.
1 Interactive Computer Theorem Proving CS294-9 October 19, 2006 Adam Chlipala UC Berkeley Lecture 9: Beyond Primitive Recursion.
1 Interactive Computer Theorem Proving CS294-9 September 7, 2006 Adam Chlipala UC Berkeley Lecture 3: Data structures and Induction.
1 Interactive Computer Theorem Proving CS294-9 September 14, 2006 Adam Chlipala UC Berkeley Lecture 4: Inductively- Defined Predicates.
1 Parametric Higher-Order Abstract Syntax for Mechanized Semantics Adam Chlipala Harvard University ICFP 2008.
Lecture 2: Propositional and First-Order Logic
Lecture 11: Proof by Reflection
Disjunctive Normal Form
Proofs, Recursion and Analysis of Algorithms
CSE 311: Foundations of Computing
CSE 311: Foundations of Computing
Simplification of Boolean Expressions
Copyright © Cengage Learning. All rights reserved.
Search techniques.
Copyright © Cengage Learning. All rights reserved.
Presentation transcript:

CSE-490 Logic in Computer Science The Coq Proof Assistant POSTECH Dec 15, 2006 박성우

2 Welcome to the Last Lecture! Coq –A formal proof checker – NOT our goal: –to learn a lot and become an expert Coq programmer Our goal: –to see how much of what we learned is actually used in a proof checker –and to relax...

3 Natural Numbers ] coqtop Welcome to Coq 8.0pl3 (Jan 2006) Coq < Check O. 0 : nat Coq < Check S. S : nat -> nat

4 2, 3, double Coq < Definition one := S O. one is defined Coq < Definition two := S one. two is defined Coq < Definition three := S two. three is defined Coq < Definition double (m:nat) := plus m m. double is defined Coq < Check double. double : nat -> nat

5 Assuming n > 0 Coq < Section CSE490. Coq < Check gt. gt : nat -> nat -> Prop Coq < Variable n : nat. n is assumed Coq < Hypothesis Pos_n : gt n O. Pos_n is assumed Coq < Check Pos_n. Pos_n : n > 0

6 Proving A ! A Coq < Parameter A B C : Prop. A is assumed B is assumed C is assumed Coq A. 1 subgoal ============================ A -> A I < intro x. 1 subgoal x : A ============================ A I < exact x. Proof completed. I < Qed. intro x. exact x. I is defined Coq < Check I. I : A -> A

7 Coq B -> C) -> (A -> B) -> A -> C. 1 subgoal ============================ (A -> B -> C) -> (A -> B) -> A -> C S < intro x. 1 subgoal x : A -> B -> C ============================ (A -> B) -> A -> C S < intro y. 1 subgoal x : A -> B -> C y : A -> B ============================ A -> C S < intro z. 1 subgoal x : A -> B -> C y : A -> B z : A ============================ C S < exact z. Proof completed. S < Qed. intro x. intro y. intro z. apply x. exact z. apply y. exact z. S is defined S < apply x. 2 subgoals x : A -> B -> C y : A -> B z : A ============================ A subgoal 2 is: B S < exact z. 1 subgoal x : A -> B -> C y : A -> B z : A ============================ B S < apply y. 1 subgoal x : A -> B -> C y : A -> B z : A ============================ A (A ! B ! C) ! (A ! B) ! (A ! C)

8 A Æ B ! B Æ A Coq B /\ A. 1 subgoal ============================ A /\ B -> B /\ A and_commutative < intro. 1 subgoal H : A /\ B ============================ B /\ A and_commutative < elim H. 1 subgoal H : A /\ B ============================ A -> B -> B /\ A and_commutative < intros. 1 subgoal H : A /\ B H0 : A H1 : B ============================ B /\ A and_commutative < split. 2 subgoals H : A /\ B H0 : A H1 : B ============================ B subgoal 2 is: A and_commutative < exact H1. 1 subgoal H : A /\ B H0 : A H1 : B ============================ A and_commutative < exact H0. Proof completed.

9 Classical Reasoning Coq B) -> A) -> A. 1 subgoal ============================ ((A -> B) -> A) -> A Peirce < try tauto. 1 subgoal ============================ ((A -> B) -> A) -> A Peirce < Require Import Classical. Peirce < Check NNPP. NNPP : forall p : Prop, ~ ~ p -> p Peirce < apply NNPP. 1 subgoal ============================ ~ ~ (((A -> B) -> A) -> A) Peirce < tauto. Proof completed. Peirce < Qed. try tauto. apply NNPP. tauto. Peirce is defined

10 Inductive Booleans Coq < Inductive bool : Set := true | false. bool is defined bool_rect is defined bool_ind is defined bool_rec is defined Coq < Check bool_ind. bool_ind : forall P : bool -> Prop, P true -> P false -> forall b : bool, P b Coq < Check bool_rec. bool_rec : forall P : bool -> Set, P true -> P false -> forall b : bool, P b Coq < Check bool_rect. bool_rect : forall P : bool -> Type, P true -> P false -> forall b : bool, P b

11 First First-Order Formula! Coq < Lemma duality : forall b:bool, b = true \/ b = false. 1 subgoal ============================ forall b : bool, b = true \/ b = false duality < intro b. 1 subgoal b : bool ============================ b = true \/ b = false duality < elim b. 2 subgoals b : bool ============================ true = true \/ true = false subgoal 2 is: false = true \/ false = false duality < left. 2 subgoals b : bool ============================ true = true subgoal 2 is: false = true \/ false = false duality < trivial. 1 subgoal b : bool ============================ false = true \/ false = false duality < right; trivial. Proof completed.

12 Natural Numbers Coq nat. nat is defined nat_rect is defined nat_ind is defined nat_rec is defined Coq < Check nat_ind. nat_ind : forall P : nat -> Prop, P O -> (forall n : nat, P n -> P (S n)) -> forall n : nat, P n Coq < Check nat_rec. nat_rec : forall P : nat -> Set, P O -> (forall n : nat, P n -> P (S n)) -> forall n : nat, P n

13 Primitive Recursion Coq < Check nat_rec. nat_rec : forall P : nat -> Set, P O -> (forall n : nat, P n -> P (S n)) -> forall n : nat, P n Coq nat). prim_rec is defined Coq S rec) n. addition is defined Coq < Eval compute in (addition (S (S O)) (S (S (S O)))). = S (S (S (S (S O)))) : (fun _ : nat => nat) (S (S O))

14 Definitional Equality Coq < Fixpoint plus (n m:nat) {struct n} : nat := Coq < match n with Coq m Coq S (plus p m) Coq < end. plus is recursively defined Coq < Check plus. plus : nat -> nat -> nat Coq < Lemma plus_n_O : forall n:nat, n = plus n 0. 1 subgoal ============================ forall n : nat, n = plus n 0 plus_n_O < intro n; elim n. 2 subgoals n : nat ============================ 0 = plus 0 0 subgoal 2 is: forall n0 : nat, n0 = plus n0 0 -> S n0 = plus (S n0) 0 plus_n_O < simpl. 2 subgoals n : nat ============================ 0 = 0 subgoal 2 is: forall n0 : nat, n0 = plus n0 0 -> S n0 = plus (S n0) 0 plus_n_O < trivial. 1 subgoal n : nat ============================ forall n0 : nat, n0 = plus n0 0 -> S n0 = plus (S n0) 0 plus_n_O < intro. 1 subgoal n : nat n0 : nat ============================ n0 = plus n0 0 -> S n0 = plus (S n0) 0 plus_n_O < intro. 1 subgoal n : nat n0 : nat H : n0 = plus n0 0 ============================ S n0 = plus (S n0) 0 plus_n_O < simpl. 1 subgoal n : nat n0 : nat H : n0 = plus n0 0 ============================ S n0 = S (plus n0 0) plus_n_O < rewrite <- H. 1 subgoal n : nat n0 : nat H : n0 = plus n0 0 ============================ S n0 = S n0 plus_n_O < trivial. Proof completed.

Congratulations - You made it!