Inductive Definitions with Inference Rules 1 / 27

Similar documents
INDUCTIVE DEFINITION

Inductive Definitions

Supplementary Notes on Inductive Definitions

Predicate Logic. Xinyu Feng 09/26/2011. University of Science and Technology of China (USTC)

Lecture Notes on Inductive Definitions

Lecture Notes on Inductive Definitions

Propositional Calculus - Hilbert system H Moonzoo Kim CS Division of EECS Dept. KAIST

Model Theory in the Univalent Foundations

Predicate Logic. Xinyu Feng 11/20/2013. University of Science and Technology of China (USTC)

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications

Axiomatic Semantics. Semantics of Programming Languages course. Joosep Rõõmusaare

CVO103: Programming Languages. Lecture 2 Inductive Definitions (2)

INTRODUCTION TO LOGIC. Propositional Logic. Examples of syntactic claims

Learning Goals of CS245 Logic and Computation

Finite Automata Theory and Formal Languages TMV027/DIT321 LP Recap: Logic, Sets, Relations, Functions

Logic, Sets, and Proofs

Predicate Logic. x. x + 0 = x. Predicate logic over integer expressions: a language of logical assertions, for example. Why discuss predicate logic?

CS522 - Programming Language Semantics

Hoare Examples & Proof Theory. COS 441 Slides 11

Knowledge representation DATA INFORMATION KNOWLEDGE WISDOM. Figure Relation ship between data, information knowledge and wisdom.

Outline. A recursive function follows the structure of inductively-defined data.

Introduction to type theory and homotopy theory

1 / A bird s-eye view of type theory. 2 A bird s-eye view of homotopy theory. 3 Path spaces and identity types. 4 Homotopy type theory

Typing λ-terms. Types. Typed λ-terms. Base Types. The Typing Relation. Advanced Formal Methods. Lecture 3: Simply Typed Lambda calculus

Discrete Mathematics

Propositional Calculus - Deductive Systems

AN INTRODUCTION TO SEPARATION LOGIC. 2. Assertions

Logic for Computer Science - Week 2 The Syntax of Propositional Logic

1. Model existence theorem.

Reasoning with Higher-Order Abstract Syntax and Contexts: A Comparison

Chapter 2. Assertions. An Introduction to Separation Logic c 2011 John C. Reynolds February 3, 2011

Proof Techniques (Review of Math 271)

Propositional Logic: Deductive Proof & Natural Deduction Part 1

Lecture Notes on Data Abstraction

Discrete Mathematics. Spring 2017

Propositional Logic: Syntax

COSE212: Programming Languages. Lecture 1 Inductive Definitions (1)

185.A09 Advanced Mathematical Logic

Lecture 7. Logic. Section1: Statement Logic.

Context Free Grammars

Intelligent Agents. First Order Logic. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University. last change: 19.

Type Inference. For the Simply-Typed Lambda Calculus. Peter Thiemann, Manuel Geffken. Albert-Ludwigs-Universität Freiburg. University of Freiburg

Consequence Relations and Natural Deduction

Introduction to Semantics. The Formalization of Meaning 1

COSE212: Programming Languages. Lecture 1 Inductive Definitions (1)

CHAPTER 2 INTRODUCTION TO CLASSICAL PROPOSITIONAL LOGIC

CSE20: Discrete Mathematics

The Absoluteness of Constructibility

Lecture Notes on Logic Programming

CS558 Programming Languages

MAI0203 Lecture 7: Inference and Predicate Calculus

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

Lecture 11: Measuring the Complexity of Proofs

COMP 3161/9161 Week 2

Completeness for FOL

Sub-λ-calculi, Classified

Mathematical Induction

Propositional Calculus - Hilbert system H Moonzoo Kim CS Dept. KAIST

Note that r = 0 gives the simple principle of induction. Also it can be shown that the principle of strong induction follows from simple induction.

MATH 215 Final. M4. For all a, b in Z, a b = b a.

n(n + 1). 2 . If n = 3, then 1+2+3=6= 3(3+1) . If n = 2, then = 3 = 2(2+1)

The semantics of propositional logic

Gödel s Incompleteness Theorem. Overview. Computability and Logic

What are the recursion theoretic properties of a set of axioms? Understanding a paper by William Craig Armando B. Matos

Complete Induction and the Well- Ordering Principle

Models of Computation,

Typed Arithmetic Expressions

The Curry-Howard Isomorphism

Outline. Overview. Syntax Semantics. Introduction Hilbert Calculus Natural Deduction. 1 Introduction. 2 Language: Syntax and Semantics

Examples: P: it is not the case that P. P Q: P or Q P Q: P implies Q (if P then Q) Typical formula:

A BRIEF INTRODUCTION TO TYPED PREDICATE LOGIC

We want to show P (n) is true for all integers

20.1 Detecting the Need for Structural Induction

Programming Languages and Types

Lecture Notes on Heyting Arithmetic

Modeling and Analysis of Communicating Systems

Outline. We will cover (over the next few weeks) Induction Strong Induction Constructive Induction Structural Induction

Inference and Proofs (1.6 & 1.7)

CSC 344 Algorithms and Complexity. Proof by Mathematical Induction

The natural numbers. Definition. Let X be any inductive set. We define the set of natural numbers as N = C(X).

Propositional Logic: Part II - Syntax & Proofs 0-0

CSE 311: Foundations of Computing I Autumn 2014 Practice Final: Section X. Closed book, closed notes, no cell phones, no calculators.

CSC236H Lecture 2. Ilir Dema. September 19, 2018

Natural Deduction for Propositional Logic

Classical Program Logics: Hoare Logic, Weakest Liberal Preconditions

Lecture 4: Probability, Proof Techniques, Method of Induction Lecturer: Lale Özkahya

cse541 LOGIC FOR COMPUTER SCIENCE

Propositional Logic: Syntax

CS 220: Discrete Structures and their Applications. Mathematical Induction in zybooks

CS481F01 Solutions 8

Gödel s Incompleteness Theorem. Overview. Computability and Logic

Lecture 2: Proof Techniques Lecturer: Lale Özkahya

Focusing on Binding and Computation

An Intuitively Complete Analysis of Gödel s Incompleteness

Propositional Logic and Semantics

Proof Terminology. Technique #1: Direct Proof. Learning objectives. Proof Techniques (Rosen, Sections ) Direct Proof:

Lecture Notes on Logic Programming

Mathematical Induction. Rosen Chapter 4.1,4.2 (6 th edition) Rosen Ch. 5.1, 5.2 (7 th edition)

Deductive Characterization of Logic

Krivine s Intuitionistic Proof of Classical Completeness (for countable languages)

Transcription:

Inductive Definitions with Inference Rules 1 / 27

Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction 2 / 27

What are inference rules? Inference rules a mathematical metalanguage For specifying and formally reasoning about inductive definitions Inductive definition Recursively defines something in terms of itself premises Human(x) Mortal(x) Mortal(x) Human(x) conclusion Introduction 3 / 27

Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction Specifying inductive definitions 4 / 27

Other metalanguages for specifying inductive definitions Haskell data types data Nat = Z S Nat data Exp = Add Exp Exp Neg Exp Lit Nat Recursive functions in Haskell even :: Nat -> Bool even Z = True even (S Z) = False even (S (S n)) = even n Grammars n Nat ::= Z S n e Exp ::= add e e neg e n Can also define all of these with inference rules! Specifying inductive definitions 5 / 27

Example: defining syntax by inference rules Grammars n Nat ::= Z S n e Exp ::= add e e neg e n rule schema Z Nat axiom (no premises) n Nat S n Nat n Nat n Exp e Exp neg e Exp e 1 Exp e 2 Exp add e 1 e 2 Exp Specifying inductive definitions 6 / 27

Example: defining a predicate Recursive function in Haskell even :: Nat -> Bool even Z = True even (S Z) = False even (S (S n)) = even n Option 1: Constructive judgment Even(n) Even(Z) Even(S (S n)) Option 2: Relate inputs to outputs Even(Z, true) Even(S Z, false) Even(n, b) Even(S (S n), b) Specifying inductive definitions 7 / 27

Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction Specifying inductive definitions 8 / 27

The structure of a definition How to define a concept in three parts: 1. syntax how to express the concept 2. type what kind of information does it relate? 3. content the definition itself Example: dictionary definition Syntax: e ven ēv n Type: adjective Content: (of a number) divisible by two without a remainder e Example: function definition even :: Nat -> Bool even Z = True even (S Z) = False even (S (S n)) = even n Specifying inductive definitions 9 / 27

How to define a concept using inference rules 1. Define a judgment form syntax and type States that one or more values have some property or exist in some relation to each other 2. Write down the rules for the judgment content axioms base cases, only conclusion proper rules recursive cases, premises + conclusion Specifying inductive definitions 10 / 27

Judgments 1. Define a judgment form syntax and type States that one or more values have some property or exist in some relation to each other Syntax Type Property or relation n Nat AST n is in the syntactic category Nat Even(n) Nat n is an even number n 1 < n 2 Nat Nat n 1 is less than n 2 e : T Exp Type e has type T Γ e : T Env Exp Type e has type T in environment Γ Specifying inductive definitions 11 / 27

Set theoretic view of judgments A judgment is (conceptually) a predicate that indicates set membership Example: Even(n) Nat Even : Nat B = {(Z, true), (S Z, false), (S (S Z), true),...} {Z, S (S Z), S (S (S (S Z))),...} Nat Example: n 1 < n 2 Nat Nat < : Nat Nat B = {((0, 0), false), ((0, 1), true),... ((5, 3), false),... ((5, 7), true),...} {(0, 1),... (5, 7),...} Nat Nat Specifying inductive definitions 12 / 27

Giving meaning to a judgment by inference rules 2. Write down the rules of the judgment content axioms base cases, only conclusion proper rules recursive cases, premises + conclusion Inductively defines the instances of a judgment (i.e. members of its set) Rules for: Even(n) Nat Rules for: n 1 < n 2 Nat Nat Even(Z) Even(n) Even(S (S n)) Z < S Z n 1 < n 2 n 1 < S n 2 n 1 < n 2 S n 1 < S n 2 Specifying inductive definitions 13 / 27

Exercises 1. Define the judgment: Odd(n) Nat 2. Define the judgment: n 1 + n 2 = n 3 Nat Nat Nat For reference: Rules for: Even(n) Nat Rules for: n 1 < n 2 Nat Nat Even(Z) Even(n) Even(S (S n)) Z < S Z n 1 < n 2 n 1 < S n 2 n 1 < n 2 S n 1 < S n 2 Specifying inductive definitions 14 / 27

Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction Reasoning about inductive definitions 15 / 27

Expressing claims We can use inference rules to express claims about judgments Examples S (S Z) Nat Even(S n) Odd(n) n 1 < n 2 n 2 < n 3 n 1 < n 3 n 1 + n 2 = n 3 n 2 + n 1 = n 3 How can we prove these claims? Use definition of judgment and one of three main techniques: 1. direct proof derive conclusion from premises using the definition 2. admissibility derive conclusion from derivations of premises 3. rule induction reason inductively using the definition Reasoning about inductive definitions 16 / 27

Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction Reasoning about inductive definitions 17 / 27

Direct proof by derivation Definition: n Nat Succ n Nat Z Nat S n Nat Definition: n 1 < n 2 Nat Nat Z < S Z S n 1 < n 2 n 1 < S n 2 +1 n 1 < n 2 S n 1 < S n 2 Succ Z Nat S Z Nat Succ S (S Z) Nat +1 Z < S Z S Z < S (S Z) S Z < S (S (S Z)) Reasoning about inductive definitions 18 / 27

Proof trees Definition: e Exp Axioms: 0 Nat, 1 Nat, 2 Nat,... lit n Nat n Exp neg e Exp neg e Exp add e 1 Exp e 2 Exp add e 1 e 2 Exp lit 2 Nat lit 3 Nat lit 4 Nat 2 3 4 add neg add 2 3 Exp neg 4 Exp add add (add 2 3) (neg 4) Exp Reasoning about inductive definitions 19 / 27

Exercises Prove that the following expressions are valid terms in Exp 1. neg (add 5 (neg 2)) 2. add (neg (neg 3)) 4 Definition: e Exp Axioms: 0 Nat, 1 Nat, 2 Nat,... lit n Nat n Exp neg e Exp neg e Exp add e 1 Exp e 2 Exp add e 1 e 2 Exp Reasoning about inductive definitions 20 / 27

Philosophical point: intension vs. extension Intensional definition: a description of the meaning of a judgment captured by the inference rules directly Extensional meaning: the set of all instances that satisfy the judgment derivable from the inference rules Syntax Intension: definition by grammar Extension: set of all ASTs Function (example) Intension: f (x) = x + 3 Extension: {... (1, 4), (2, 5), (3, 6),...} Reasoning about inductive definitions 21 / 27

Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction Reasoning about inductive definitions 22 / 27

Admissibility An alternative way to prove a claim, based on constructing proofs from assumed derivations of the premises Proof technique Assume the definition of the judgment is complete all valid judgments can be derived from axioms using only the rules in the definition Then, if the premise of a claim is satisfied, it must have a derivation key insight: use derivations to construct a proof of the conclusion Show that all derivations of premises yield a proof of the conclusion basically, apply definition rules backwards and prove for each case Reasoning about inductive definitions 23 / 27

Super simple example Definition: n Nat AST Succ n Nat Z Nat S n Nat Bold claim S (S n) Nat n Nat Proof sketch: Enumerate derivations of premise Show that each derivation proves the conclusion Only possible derivation Succ n Nat S n Nat Succ S (S n) Nat Reasoning about inductive definitions 24 / 27

Outline Introduction Specifying inductive definitions Inference rules in action Judgments, axioms, and rules Reasoning about inductive definitions Direct proofs Admissibility Rule induction Reasoning about inductive definitions 25 / 27

Rule induction Just like structural induction on inductive data types! Definition: e Exp AST n Nat n Exp e Exp neg e Exp e 1 Exp e 2 Exp add e 1 e 2 Exp Suppose I want to prove property P on all Exps. Just prove: n Nat, P(n) P(e) P(neg e) P(e 1 ) P(e 2 ) P(add e 1 e 2 ) Reasoning about inductive definitions 26 / 27

Example: admissibility + rule induction Def: n 1 < n 2 (Nat Nat) Claim Z Z < S n +LR n 1 < n 2 S n 1 < S n 2 +R n 1 < n 2 n 1 < S n 2 Derivation 1: Let n 1 = Z, n 2 = S n 2 Plug into claim: +R Z Z < S n 2 Z < S n 2 Z < S (S n 2 ) Direct proof with Z, n = S n 2 Derivation 2: Let n 1 = S n 1, n 2 = S n 2 Plug into claim: +R n 1 < n 2 S n 1 < S (S n 2 ) S n 1 < S n 2 S (S n 1 ) < S (S (S n 2 )) Rule +LR, then induction hypothesis Reasoning about inductive definitions 27 / 27