HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1

Similar documents
Basic Foundations of Isabelle/HOL

Introduction to dependent types in Coq

Overview. A Compact Introduction to Isabelle/HOL. Tobias Nipkow. System Architecture. Overview of Isabelle/HOL

Theorem Proving Principles, Techniques, Applications Recursion

Programs and Proofs in Isabelle/HOL

λ calculus is inconsistent

COMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein

locales ISAR IS BASED ON CONTEXTS CONTENT Slide 3 Slide 1 proof - fix x assume Ass: A. x and Ass are visible Slide 2 Slide 4 inside this context

Higher-Order Logic. Specification and Verification with Higher-Order Logic

Preuves Interactives et Applications

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

Automated Reasoning. Natural Deduction in First-Order Logic

type classes & locales

A CRASH COURSE IN SEMANTICS

Organisatorials. About us. Binary Search (java.util.arrays) When Tue 9:00 10:30 Thu 9:00 10:30. COMP 4161 NICTA Advanced Course

Computer-supported Modeling and Reasoning. First-Order Logic. 1 More on Isabelle. 1.1 Isabelle System Architecture

COMP 4161 Data61 Advanced Course. Advanced Topics in Software Verification. Gerwin Klein, June Andronick, Christine Rizkallah, Miki Tanaka

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. Category Example Description. Inductive type with instances defined by constructors, including y of type Y. Inductive X : Univ :=

Programming and Proving in

Formal Systems and their Applications

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

An Introduction to Programming and Proving in Agda (incomplete draft)

Proofs are Programs. Prof. Clarkson Fall Today s music: Proof by Paul Simon

Typed Lambda Calculus

The Eisbach User Manual

Integration of SMT Solvers with ITPs There and Back Again

Inductive Definitions, continued

An Introduction to Isabelle/HOL 2008

Typed Lambda Calculus for Syntacticians

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

Calculus of Inductive Constructions

First-Class Type Classes

Programming Languages Lecture 14: Sum, Product, Recursive Types

Proofs are Programs. Prof. Clarkson Fall Today s music: Two Sides to Every Story by Dyan Cannon and Willie Nelson

Introduction to Type Theory August 2007 Types Summer School Bertinoro, It. Herman Geuvers Nijmegen NL

CMSC 336: Type Systems for Programming Languages Lecture 5: Simply Typed Lambda Calculus Acar & Ahmed January 24, 2008

Logical Verification Course Notes. Femke van Raamsdonk Vrije Universiteit Amsterdam

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

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

On Agda JAIST/AIST WS CVS/AIST Yoshiki Kinoshita, Yoriyuki Yamagata. Agenda

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals

Induction and Semantics in Dafny

CS 4110 Programming Languages & Logics. Lecture 28 Recursive Types

Programming and Proving in Isabelle/HOL

Isabelle s meta-logic. p.1

1. M,M sequential composition: try tactic M; if it succeeds try tactic M. sequential composition (, )

The three faces of homotopy type theory. Type theory and category theory. Minicourse plan. Typing judgments. Michael Shulman.

Propositional Calculus. Math Foundations of Computer Science

CSE505, Fall 2012, Midterm Examination October 30, 2012

Importing HOL-Light into Coq

Embedding logics in Dedukti

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.

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.

Lecture 3: Typed Lambda Calculus and Curry-Howard

The Prototype Verification System PVS

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Certified Programming with Dependent Types

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Concrete Semantics. A Proof Assistant Approach. Tobias Nipkow Fakultät für Informatik Technische Universität München

CSE-321 Programming Languages 2012 Midterm

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Lee Pike. June 3, 2005

Concepts of programming languages

Kripke-Style Contextual Modal Type Theory

Programming with Universes, Generically

CS4215 Programming Language Implementation. Martin Henz

Polymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy

Notes. Notes. Introduction. Notes. Propositional Functions. Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry.

Encryption as an Abstract Datatype:

Isabelle Tutorial: System, HOL and Proofs

Interactive Proof: Introduction to Isabelle/HOL

Programming Languages Fall 2014

Programming Languages Fall 2013

STABILITY AND PARADOX IN ALGORITHMIC LOGIC

Computation Club: Gödel s theorem

Inductive datatypes in HOL. lessons learned in Formal-Logic Engineering

Improving Coq Propositional Reasoning Using a Lazy CNF Conversion

CS 4110 Programming Languages & Logics. Lecture 27 Recursive Types

Numerical Computations and Formal Methods

CIS 194: Homework 8. Due Wednesday, 8 April. Propositional Logic. Implication

COMP4161: Advanced Topics in Software Verification. fun. Gerwin Klein, June Andronick, Ramana Kumar S2/2016. data61.csiro.au

Interactive Theorem Proving (ITP) Course Parts VII, VIII

CSE 20 DISCRETE MATH. Fall

Reasoning About Imperative Programs. COS 441 Slides 10

Propositional Calculus. Math Foundations of Computer Science

Types Summer School Gothenburg Sweden August Dogma oftype Theory. Everything has a type

Lecture Notes on Program Equivalence

Type Theory. Lecture 2: Dependent Types. Andreas Abel. Department of Computer Science and Engineering Chalmers and Gothenburg University

Programming Languages Assignment #7

a brief introduction to (dependent) type theory

A Case Study of Co-induction in Isabelle 1

CIS 500 Software Foundations Midterm I

Lambda Calculus and Type Inference

The Coq Proof Assistant A Tutorial

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Subsumption. Principle of safe substitution

Programming Language Features. CMSC 330: Organization of Programming Languages. Turing Completeness. Turing Machine.

CMSC 330: Organization of Programming Languages

Built-in Module BOOL. Lecture Note 01a

Transcription:

LAST TIME ON HOL Proof rules for propositional and predicate logic Safe and unsafe rules NICTA Advanced Course Forward Proof Slide 1 Theorem Proving Principles, Techniques, Applications Slide 3 The Epsilon Operator Some automation HOL CONTENT Intro & motivation, getting started with Isabelle Foundations & Principles Lambda Calculus Higher Order Logic, natural deduction Slide 2 Term rewriting Proof & Specification Techniques Slide 4 DEFINING HIGHER ORDER LOGIC Datatypes, recursion, induction Inductively defined sets, rule induction Calculational reasoning, mathematics style proofs Hoare logic, proofs about programs LAST TIME ON HOL 1 WHAT IS HIGHER ORDER LOGIC? 2

WHAT IS HIGHER ORDER LOGIC? HIGHER ORDER ABSTRACT SYNTAX Propositional Logic: Problem: Define syntax for binders like,, ε no quantifiers all variables have type bool First Order Logic: One approach: :: var term bool Drawback: need to think about substitution, α conversion again. Slide 5 quantification over values, but not over functions and predicates, terms and formulas syntactically distinct Higher Order Logic: quantification over everything, including predicates Slide 7 But: Already have binder, substitution, α conversion in meta logic λ consistency by types formula = term of type bool So: Use λ to encode all other binders. definition built on λ with certain default types and constants DEFINING HIGHER ORDER LOGIC HIGHER ORDER ABSTRACT SYNTAX Default types: bool ind Example: ALL :: (α bool) bool Slide 6 bool sometimes called o sometimes called fun Slide 8 HOAS usual syntax ALL (λx. x = 2) x. x = 2 Default Constants: ALL P x. P x :: bool bool bool = :: α α bool ɛ :: (α bool) α Isabelle can translate usual binder syntax into HOAS. HIGHER ORDER ABSTRACT SYNTAX 3 SIDE TRACK: SYNTAX DECLARATIONS IN ISABELLE 4

SIDE TRACK: SYNTAX DECLARATIONS IN ISABELLE THE AXIOMS OF HOL mixfix: consts drvbl :: ct ct fm bool (, ) Legal syntax now: Γ, Π F t = t refl s = t P s P t subst x. f x = g x (λx. f x) = (λx. g x) ext Slide 9 priorities: pattern can be annotated with priorities to indicate binding strength Example: drvbl :: ct ct fm bool (, [30, 0, 20] 60) infixl/infixr: short form for left/right associative binary operators Example: or :: bool bool bool (infixr 30) binders: declaration must be of the form c :: (τ 1 τ 2) τ 3 (binder B < p >) B x. P x translated into c P (and vice versa) Example ALL :: (α bool) bool (binder 10) More (including pretty printing) in Isabelle Reference Manual (7.3) Slide 11 P = Q P Q impi P Q P Q mp (P Q) (Q P ) (P = Q) iff True or False P = True P = False P?x P (SOME x. P x) somei f :: ind ind. inj f surj f infty BACK TO HOL THAT S IT. Base: bool,, ind =,, ε 3 basic constants And the rest is definitions: 3 basic types Slide 10 True (λx :: bool. x) = (λx. x) All P P = (λx. True) Ex P Q. ( x. P x Q) Q False P. P P P False P Q R. (P Q R) R P Q R. (P R) (Q R) R If P x y SOME z. (P = True z = x) (P = False z = y) inj f x y. f x = f y x = y surj f y. x. y = f x Slide 12 9 axioms With this you can define and derive all the rest. Isabelle knows 2 more axioms: x = y x y eq reflection (THE the eq trivial x. x = a) = a THE AXIOMS OF HOL 5 6

TRUE consts True :: bool True (λx :: bool. x) = (λx. x) right hand side is always true Slide 13 DEMO: THE DEFINITIONS IN ISABELLE Slide 15 True TrueI Proof: (λx :: bool. x) = (λx. x) refl unfold True def True DERIVING PROOF RULES In the following, we will look at the definitions in more detail derive the traditional proof rules from the axioms in Isabelle Convenient for deriving rules: named assumptions in lemmas Slide 14 lemma [name :] assumes [name 1 :] < prop > 1 assumes [name 2 :] < prop > 2. shows < prop > < proof > Slide 16 DEMO proves: [ < prop > 1 ; < prop > 2 ;... ] = < prop > TRUE 7 UNIVERSIAL QUANTIFIER 8

UNIVERSIAL QUANTIFIER NEGATION consts ALL :: (α bool) bool ALL P P = (λx. True) consts Not :: bool bool ( ) P P False Slide 17 ALL P is Higher Order Abstract Syntax for x. P x. P is a function that takes an x and yields a truth values. ALL P should be true iff P yields true for all x, i.e. if it is equivalent to the function λx. True. Slide 19 Try P = T rue and P = F alse and the traditional truth table for. x. P x x. P x alli x. P x P?x = R alle R A = F alse A noti A A P note FALSE EXISTENTIAL QUANTIFIER consts False :: bool False P.P consts EX :: (α bool) bool EX P Q. ( x. P x Q) Q Slide 18 Everything can be derived from False. False P FalseE True False Slide 20 EX P is HOAS for x. P x. (like ) Right hand side is characterization of with and Note that inner binds wide: ( x. P x Q) Remember lemma from last time: ( x. P x Q) = (( x. P x) Q) P?x x. P x exi x. P x x. P x = R exe R NEGATION 9 CONJUNCTION 10

CONJUNCTION IF-THEN-ELSE consts And :: bool bool bool ( ) P Q R. (P Q R) R consts If :: bool α α α (if then else ) If P x y SOME z. (P = True z = x) (P = False z = y) Slide 21 Mirrors proof rules for Try truth table for P, Q, and R Slide 23 for P = True, right hand side collapses to SOME z. z = x for P = False, right hand side collapses to SOME z. z = y A B A B conji A B [A; B ] = C C conje if True then s else t = s iftrue if False then s else t = t iffalse DISJUNCTION consts Or :: bool bool bool ( ) P Q R. (P R) (Q R) R Slide 22 Mirrors proof rules for (case distinction) Try truth table for P, Q, and R Slide 24 THAT WAS HOL A A B B A B disji1/2 A B A = C B = C C disje IF-THEN-ELSE 11 MORE ON AUTOMATION 12

MORE ON AUTOMATION WE HAVE LEARNED TODAY... Last time: safe and unsafe rule, heuristics: use safe before unsafe This can be automated Defining HOL Slide 25 Syntax: [<kind>!] [<kind>] for safe rules (<kind> one of intro, elim, dest) for unsafe rules Application (roughly): do safe rules first, search/backtrack on unsafe rules only Slide 27 Higher Order Abstract Syntax Deriving proof rules More automation Example: declare attribute globally declare conji [intro!] alle [elim] remove attribute gloabllay declare alle [rule del] use locally apply (blast intro: somei) delete locally apply (blast del: conji) EXERCISES derive the classical contradiction rule ( P = F alse) = P in Isabelle define nor and nand in Isabelle show nor x x = nand x x Slide 26 DEMO: AUTOMATION Slide 28 derive safe intro and elim rules for them use these in an automated proof of nor x x = nand x x WE HAVE LEARNED TODAY... 13 EXERCISES 14