NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some...

95
NICTA Advanced Course Theorem Proving Principles, Techniques, Applications HOL 1

Transcript of NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some...

Page 1: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

NICTA Advanced Course

Theorem Proving

Principles, Techniques, Applications

HOL

1

Page 2: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

CONTENT

➜ Intro & motivation, getting started with Isabelle

➜ Foundations & Principles

• Lambda Calculus

• Higher Order Logic, natural deduction

• Term rewriting

➜ Proof & Specification Techniques

• Datatypes, recursion, induction

• Inductively defined sets, rule induction

• Calculational reasoning, mathematics style proofs

• Hoare logic, proofs about programs

CONTENT 2

Page 3: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

LAST TIME ON HOL

➜ Proof rules for propositional and predicate logic

➜ Safe and unsafe rules

➜ Forward Proof

➜ The Epsilon Operator

➜ Some automation

LAST TIME ON HOL 3

Page 4: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

LAST TIME ON HOL

➜ Proof rules for propositional and predicate logic

➜ Safe and unsafe rules

➜ Forward Proof

➜ The Epsilon Operator

➜ Some automation

LAST TIME ON HOL 3-A

Page 5: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

LAST TIME ON HOL

➜ Proof rules for propositional and predicate logic

➜ Safe and unsafe rules

➜ Forward Proof

➜ The Epsilon Operator

➜ Some automation

LAST TIME ON HOL 3-B

Page 6: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

LAST TIME ON HOL

➜ Proof rules for propositional and predicate logic

➜ Safe and unsafe rules

➜ Forward Proof

➜ The Epsilon Operator

➜ Some automation

LAST TIME ON HOL 3-C

Page 7: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

LAST TIME ON HOL

➜ Proof rules for propositional and predicate logic

➜ Safe and unsafe rules

➜ Forward Proof

➜ The Epsilon Operator

➜ Some automation

LAST TIME ON HOL 3-D

Page 8: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DEFINING HIGHER ORDER LOGIC

4

Page 9: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

WHAT IS HIGHER ORDER LOGIC?

➜ Propositional Logic:

• no quantifiers

• all variables have type bool

➜ First Order Logic:

• quantification over values, but not over functions and predicates,

• terms and formulas syntactically distinct

➜ Higher Order Logic:

• quantification over everything, including predicates

• consistency by types

• formula = term of type bool

• definition built on λ→ with certain default types and constants

WHAT IS HIGHER ORDER LOGIC? 5

Page 10: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

WHAT IS HIGHER ORDER LOGIC?

➜ Propositional Logic:

• no quantifiers

• all variables have type bool

➜ First Order Logic:

• quantification over values, but not over functions and predicates,

• terms and formulas syntactically distinct

➜ Higher Order Logic:

• quantification over everything, including predicates

• consistency by types

• formula = term of type bool

• definition built on λ→ with certain default types and constants

WHAT IS HIGHER ORDER LOGIC? 5-A

Page 11: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

WHAT IS HIGHER ORDER LOGIC?

➜ Propositional Logic:

• no quantifiers

• all variables have type bool

➜ First Order Logic:

• quantification over values, but not over functions and predicates,

• terms and formulas syntactically distinct

➜ Higher Order Logic:

• quantification over everything, including predicates

• consistency by types

• formula = term of type bool

• definition built on λ→ with certain default types and constants

WHAT IS HIGHER ORDER LOGIC? 5-B

Page 12: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DEFINING HIGHER ORDER LOGIC

Default types:

bool

⇒ ind

➜ bool sometimes called o

➜ ⇒ sometimes called fun

Default Constants:

−→ :: bool ⇒ bool ⇒ bool

= :: α ⇒ α ⇒ bool

ε :: (α ⇒ bool) ⇒ α

DEFINING HIGHER ORDER LOGIC 6

Page 13: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DEFINING HIGHER ORDER LOGIC

Default types:

bool ⇒

ind

➜ bool sometimes called o

➜ ⇒ sometimes called fun

Default Constants:

−→ :: bool ⇒ bool ⇒ bool

= :: α ⇒ α ⇒ bool

ε :: (α ⇒ bool) ⇒ α

DEFINING HIGHER ORDER LOGIC 6-B

Page 14: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DEFINING HIGHER ORDER LOGIC

Default types:

bool ⇒ ind

➜ bool sometimes called o

➜ ⇒ sometimes called fun

Default Constants:

−→ :: bool ⇒ bool ⇒ bool

= :: α ⇒ α ⇒ bool

ε :: (α ⇒ bool) ⇒ α

DEFINING HIGHER ORDER LOGIC 6-C

Page 15: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DEFINING HIGHER ORDER LOGIC

Default types:

bool ⇒ ind

➜ bool sometimes called o

➜ ⇒ sometimes called fun

Default Constants:

−→ :: bool ⇒ bool ⇒ bool

= :: α ⇒ α ⇒ bool

ε :: (α ⇒ bool) ⇒ α

DEFINING HIGHER ORDER LOGIC 6-D

Page 16: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DEFINING HIGHER ORDER LOGIC

Default types:

bool ⇒ ind

➜ bool sometimes called o

➜ ⇒ sometimes called fun

Default Constants:

−→ :: bool ⇒ bool ⇒ bool

= :: α ⇒ α ⇒ bool

ε :: (α ⇒ bool) ⇒ α

DEFINING HIGHER ORDER LOGIC 6-E

Page 17: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DEFINING HIGHER ORDER LOGIC

Default types:

bool ⇒ ind

➜ bool sometimes called o

➜ ⇒ sometimes called fun

Default Constants:

−→ :: bool ⇒ bool ⇒ bool

= :: α ⇒ α ⇒ bool

ε :: (α ⇒ bool) ⇒ α

DEFINING HIGHER ORDER LOGIC 6-F

Page 18: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DEFINING HIGHER ORDER LOGIC

Default types:

bool ⇒ ind

➜ bool sometimes called o

➜ ⇒ sometimes called fun

Default Constants:

−→ :: bool ⇒ bool ⇒ bool

= :: α ⇒ α ⇒ bool

ε :: (α ⇒ bool) ⇒ α

DEFINING HIGHER ORDER LOGIC 6-G

Page 19: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DEFINING HIGHER ORDER LOGIC

Default types:

bool ⇒ ind

➜ bool sometimes called o

➜ ⇒ sometimes called fun

Default Constants:

−→ :: bool ⇒ bool ⇒ bool

= :: α ⇒ α ⇒ bool

ε :: (α ⇒ bool) ⇒ α

DEFINING HIGHER ORDER LOGIC 6-H

Page 20: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

HIGHER ORDER ABSTRACT SYNTAX

Problem: Define syntax for binders like ∀, ∃, ε

One approach: ∀ :: var ⇒ term ⇒ bool

Drawback: need to think about substitution, α conversion again.

But: Already have binder, substitution, α conversion in meta logic

λ

So: Use λ to encode all other binders.

HIGHER ORDER ABSTRACT SYNTAX 7

Page 21: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

HIGHER ORDER ABSTRACT SYNTAX

Problem: Define syntax for binders like ∀, ∃, ε

One approach: ∀ :: var ⇒ term ⇒ bool

Drawback: need to think about substitution, α conversion again.

But: Already have binder, substitution, α conversion in meta logic

λ

So: Use λ to encode all other binders.

HIGHER ORDER ABSTRACT SYNTAX 7-A

Page 22: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

HIGHER ORDER ABSTRACT SYNTAX

Problem: Define syntax for binders like ∀, ∃, ε

One approach: ∀ :: var ⇒ term ⇒ bool

Drawback: need to think about substitution, α conversion again.

But: Already have binder, substitution, α conversion in meta logic

λ

So: Use λ to encode all other binders.

HIGHER ORDER ABSTRACT SYNTAX 7-B

Page 23: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

HIGHER ORDER ABSTRACT SYNTAX

Problem: Define syntax for binders like ∀, ∃, ε

One approach: ∀ :: var ⇒ term ⇒ bool

Drawback: need to think about substitution, α conversion again.

But: Already have binder, substitution, α conversion in meta logic

λ

So: Use λ to encode all other binders.

HIGHER ORDER ABSTRACT SYNTAX 7-C

Page 24: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

HIGHER ORDER ABSTRACT SYNTAX

Example:ALL :: (α ⇒ bool) ⇒ bool

HOAS usual syntax

ALL (λx. x = 2) ∀x. x = 2

ALL P ∀x. P x

Isabelle can translate usual binder syntax into HOAS.

HIGHER ORDER ABSTRACT SYNTAX 8

Page 25: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

HIGHER ORDER ABSTRACT SYNTAX

Example:ALL :: (α ⇒ bool) ⇒ bool

HOAS usual syntax

ALL (λx. x = 2)

∀x. x = 2

ALL P ∀x. P x

Isabelle can translate usual binder syntax into HOAS.

HIGHER ORDER ABSTRACT SYNTAX 8-A

Page 26: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

HIGHER ORDER ABSTRACT SYNTAX

Example:ALL :: (α ⇒ bool) ⇒ bool

HOAS usual syntax

ALL (λx. x = 2) ∀x. x = 2

ALL P ∀x. P x

Isabelle can translate usual binder syntax into HOAS.

HIGHER ORDER ABSTRACT SYNTAX 8-B

Page 27: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

HIGHER ORDER ABSTRACT SYNTAX

Example:ALL :: (α ⇒ bool) ⇒ bool

HOAS usual syntax

ALL (λx. x = 2) ∀x. x = 2

ALL P

∀x. P x

Isabelle can translate usual binder syntax into HOAS.

HIGHER ORDER ABSTRACT SYNTAX 8-C

Page 28: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

HIGHER ORDER ABSTRACT SYNTAX

Example:ALL :: (α ⇒ bool) ⇒ bool

HOAS usual syntax

ALL (λx. x = 2) ∀x. x = 2

ALL P ∀x. P x

Isabelle can translate usual binder syntax into HOAS.

HIGHER ORDER ABSTRACT SYNTAX 8-D

Page 29: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

HIGHER ORDER ABSTRACT SYNTAX

Example:ALL :: (α ⇒ bool) ⇒ bool

HOAS usual syntax

ALL (λx. x = 2) ∀x. x = 2

ALL P ∀x. P x

Isabelle can translate usual binder syntax into HOAS.

HIGHER ORDER ABSTRACT SYNTAX 8-E

Page 30: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

SIDE TRACK: SYNTAX DECLARATIONS IN ISABELLE

➜ mixfix:consts drvbl :: ct ⇒ ct ⇒ fm ⇒ bool (” , ` ”)

Legal syntax now: Γ, Π ` F

➜ priorities:pattern can be annotated with priorities to indicate binding strengthExample: drvbl :: ct ⇒ ct ⇒ fm ⇒ bool (” , ` ” [30, 0, 20] 60)

➜ infixl/infixr: short form for left/right associative binary operatorsExample: or :: bool ⇒ bool ⇒ bool (infixr ” ∨ ” 30)

➜ binders: declaration must be of the formc :: (τ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)

SIDE TRACK: SYNTAX DECLARATIONS IN ISABELLE 9

Page 31: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

SIDE TRACK: SYNTAX DECLARATIONS IN ISABELLE

➜ mixfix:consts drvbl :: ct ⇒ ct ⇒ fm ⇒ bool (” , ` ”)

Legal syntax now: Γ, Π ` F

➜ priorities:pattern can be annotated with priorities to indicate binding strengthExample: drvbl :: ct ⇒ ct ⇒ fm ⇒ bool (” , ` ” [30, 0, 20] 60)

➜ infixl/infixr: short form for left/right associative binary operatorsExample: or :: bool ⇒ bool ⇒ bool (infixr ” ∨ ” 30)

➜ binders: declaration must be of the formc :: (τ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)

SIDE TRACK: SYNTAX DECLARATIONS IN ISABELLE 9-A

Page 32: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

SIDE TRACK: SYNTAX DECLARATIONS IN ISABELLE

➜ mixfix:consts drvbl :: ct ⇒ ct ⇒ fm ⇒ bool (” , ` ”)

Legal syntax now: Γ, Π ` F

➜ priorities:pattern can be annotated with priorities to indicate binding strengthExample: drvbl :: ct ⇒ ct ⇒ fm ⇒ bool (” , ` ” [30, 0, 20] 60)

➜ infixl/infixr: short form for left/right associative binary operatorsExample: or :: bool ⇒ bool ⇒ bool (infixr ” ∨ ” 30)

➜ binders: declaration must be of the formc :: (τ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)

SIDE TRACK: SYNTAX DECLARATIONS IN ISABELLE 9-B

Page 33: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

SIDE TRACK: SYNTAX DECLARATIONS IN ISABELLE

➜ mixfix:consts drvbl :: ct ⇒ ct ⇒ fm ⇒ bool (” , ` ”)

Legal syntax now: Γ, Π ` F

➜ priorities:pattern can be annotated with priorities to indicate binding strengthExample: drvbl :: ct ⇒ ct ⇒ fm ⇒ bool (” , ` ” [30, 0, 20] 60)

➜ infixl/infixr: short form for left/right associative binary operatorsExample: or :: bool ⇒ bool ⇒ bool (infixr ” ∨ ” 30)

➜ binders: declaration must be of the formc :: (τ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)

SIDE TRACK: SYNTAX DECLARATIONS IN ISABELLE 9-C

Page 34: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

SIDE TRACK: SYNTAX DECLARATIONS IN ISABELLE

➜ mixfix:consts drvbl :: ct ⇒ ct ⇒ fm ⇒ bool (” , ` ”)

Legal syntax now: Γ, Π ` F

➜ priorities:pattern can be annotated with priorities to indicate binding strengthExample: drvbl :: ct ⇒ ct ⇒ fm ⇒ bool (” , ` ” [30, 0, 20] 60)

➜ infixl/infixr: short form for left/right associative binary operatorsExample: or :: bool ⇒ bool ⇒ bool (infixr ” ∨ ” 30)

➜ binders: declaration must be of the formc :: (τ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)

SIDE TRACK: SYNTAX DECLARATIONS IN ISABELLE 9-D

Page 35: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

BACK TO HOL

Base: bool, ⇒, ind =, −→, ε

And the rest is

definitions:

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

BACK TO HOL 10

Page 36: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

BACK TO HOL

Base: bool, ⇒, ind =, −→, ε

And the rest is definitions:

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

BACK TO HOL 10-A

Page 37: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

THE AXIOMS OF HOL

t = t refls = t P s

P tsubst

∧x. f x = g x

(λx. f x) = (λx. g x)ext

P =⇒ Q

P −→ QimpI

P −→ Q P

Qmp

(P −→ Q) −→ (Q −→ P ) −→ (P = Q)iff

P = True ∨ P = FalseTrue or False

P ?xP (SOME x. P x)

someI

∃f :: ind ⇒ ind. inj f ∧ ¬surj finfty

THE AXIOMS OF HOL 11

Page 38: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

THE AXIOMS OF HOL

t = t refls = t P s

P tsubst

∧x. f x = g x

(λx. f x) = (λx. g x)ext

P =⇒ Q

P −→ QimpI

P −→ Q P

Qmp

(P −→ Q) −→ (Q −→ P ) −→ (P = Q)iff

P = True ∨ P = FalseTrue or False

P ?xP (SOME x. P x)

someI

∃f :: ind ⇒ ind. inj f ∧ ¬surj finfty

THE AXIOMS OF HOL 11-A

Page 39: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

THE AXIOMS OF HOL

t = t refls = t P s

P tsubst

∧x. f x = g x

(λx. f x) = (λx. g x)ext

P =⇒ Q

P −→ QimpI

P −→ Q P

Qmp

(P −→ Q) −→ (Q −→ P ) −→ (P = Q)iff

P = True ∨ P = FalseTrue or False

P ?xP (SOME x. P x)

someI

∃f :: ind ⇒ ind. inj f ∧ ¬surj finfty

THE AXIOMS OF HOL 11-B

Page 40: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

THE AXIOMS OF HOL

t = t refls = t P s

P tsubst

∧x. f x = g x

(λx. f x) = (λx. g x)ext

P =⇒ Q

P −→ QimpI

P −→ Q P

Qmp

(P −→ Q) −→ (Q −→ P ) −→ (P = Q)iff

P = True ∨ P = FalseTrue or False

P ?xP (SOME x. P x)

someI

∃f :: ind ⇒ ind. inj f ∧ ¬surj finfty

THE AXIOMS OF HOL 11-C

Page 41: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

THE AXIOMS OF HOL

t = t refls = t P s

P tsubst

∧x. f x = g x

(λx. f x) = (λx. g x)ext

P =⇒ Q

P −→ QimpI

P −→ Q P

Qmp

(P −→ Q) −→ (Q −→ P ) −→ (P = Q)iff

P = True ∨ P = FalseTrue or False

P ?xP (SOME x. P x)

someI

∃f :: ind ⇒ ind. inj f ∧ ¬surj finfty

THE AXIOMS OF HOL 11-D

Page 42: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

THE AXIOMS OF HOL

t = t refls = t P s

P tsubst

∧x. f x = g x

(λx. f x) = (λx. g x)ext

P =⇒ Q

P −→ QimpI

P −→ Q P

Qmp

(P −→ Q) −→ (Q −→ P ) −→ (P = Q)iff

P = True ∨ P = FalseTrue or False

P ?xP (SOME x. P x)

someI

∃f :: ind ⇒ ind. inj f ∧ ¬surj finfty

THE AXIOMS OF HOL 11-E

Page 43: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

THAT’S IT.

➜ 3 basic constants

➜ 3 basic types

➜ 9 axioms

With this you can define and derive all the rest.

Isabelle knows 2 more axioms:

x = yx ≡ y eq reflection (THE x. x = a) = a

the eq trivial

THAT’S IT. 12

Page 44: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

THAT’S IT.

➜ 3 basic constants

➜ 3 basic types

➜ 9 axioms

With this you can define and derive all the rest.

Isabelle knows 2 more axioms:

x = yx ≡ y eq reflection (THE x. x = a) = a

the eq trivial

THAT’S IT. 12-A

Page 45: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

THAT’S IT.

➜ 3 basic constants

➜ 3 basic types

➜ 9 axioms

With this you can define and derive all the rest.

Isabelle knows 2 more axioms:

x = yx ≡ y eq reflection (THE x. x = a) = a

the eq trivial

THAT’S IT. 12-B

Page 46: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DEMO: THE DEFINITIONS IN ISABELLE

13

Page 47: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

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

lemma [name :]

assumes [name1 :] ”< prop >1”assumes [name2 :] ”< prop >2”...shows ” < prop > ” < proof >

proves: [[ < prop >1; < prop >2; . . . ]] =⇒< prop >

DERIVING PROOF RULES 14

Page 48: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

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

lemma [name :]

assumes [name1 :] ”< prop >1”assumes [name2 :] ”< prop >2”...shows ” < prop > ” < proof >

proves: [[ < prop >1; < prop >2; . . . ]] =⇒< prop >

DERIVING PROOF RULES 14-A

Page 49: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

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

lemma [name :]

assumes [name1 :] ”< prop >1”assumes [name2 :] ”< prop >2”...shows ” < prop > ” < proof >

proves: [[ < prop >1; < prop >2; . . . ]] =⇒< prop >

DERIVING PROOF RULES 14-B

Page 50: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

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

lemma [name :]

assumes [name1 :] ”< prop >1”assumes [name2 :] ”< prop >2”...shows ” < prop > ” < proof >

proves: [[ < prop >1; < prop >2; . . . ]] =⇒< prop >

DERIVING PROOF RULES 14-C

Page 51: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

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

lemma [name :]

assumes [name1 :] ”< prop >1”assumes [name2 :] ”< prop >2”...shows ” < prop > ” < proof >

proves: [[ < prop >1; < prop >2; . . . ]] =⇒< prop >

DERIVING PROOF RULES 14-D

Page 52: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

TRUE

consts True :: bool

True ≡ (λx :: bool. x) = (λx. x)

Intuition:right hand side is always true

Proof Rules:

TrueTrueI

Proof:(λx :: bool. x) = (λx. x)

refl

Trueunfold True def

TRUE 15

Page 53: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

TRUE

consts True :: bool

True ≡ (λx :: bool. x) = (λx. x)

Intuition:right hand side is always true

Proof Rules:

TrueTrueI

Proof:(λx :: bool. x) = (λx. x)

refl

Trueunfold True def

TRUE 15-A

Page 54: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DEMO

16

Page 55: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

UNIVERSIAL QUANTIFIER

consts ALL :: (α ⇒ bool) ⇒ bool

ALL P ≡ P = (λx. True)

Intuition:

➜ 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.

Proof Rules:∧

x. P x

∀x. P xallI

∀x. P x P ?x =⇒ RR

allE

Proof: Isabelle Demo

UNIVERSIAL QUANTIFIER 17

Page 56: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

UNIVERSIAL QUANTIFIER

consts ALL :: (α ⇒ bool) ⇒ bool

ALL P ≡ P = (λx. True)

Intuition:

➜ 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.

Proof Rules:∧

x. P x

∀x. P xallI

∀x. P x P ?x =⇒ RR

allE

Proof: Isabelle Demo

UNIVERSIAL QUANTIFIER 17-A

Page 57: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

UNIVERSIAL QUANTIFIER

consts ALL :: (α ⇒ bool) ⇒ bool

ALL P ≡ P = (λx. True)

Intuition:

➜ 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.

Proof Rules:∧

x. P x

∀x. P xallI

∀x. P x P ?x =⇒ RR

allE

Proof: Isabelle Demo

UNIVERSIAL QUANTIFIER 17-B

Page 58: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

UNIVERSIAL QUANTIFIER

consts ALL :: (α ⇒ bool) ⇒ bool

ALL P ≡ P = (λx. True)

Intuition:

➜ 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.

Proof Rules:∧

x. P x

∀x. P xallI

∀x. P x P ?x =⇒ RR

allE

Proof: Isabelle Demo

UNIVERSIAL QUANTIFIER 17-C

Page 59: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

UNIVERSIAL QUANTIFIER

consts ALL :: (α ⇒ bool) ⇒ bool

ALL P ≡ P = (λx. True)

Intuition:

➜ 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.

Proof Rules:∧

x. P x

∀x. P xallI

∀x. P x P ?x =⇒ RR

allE

Proof: Isabelle Demo

UNIVERSIAL QUANTIFIER 17-D

Page 60: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

FALSE

consts False :: bool

False ≡ ∀P.P

Intuition:Everything can be derived from False.

Proof Rules:False

PFalseE

True 6= False

Proof: Isabelle Demo

FALSE 18

Page 61: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

FALSE

consts False :: bool

False ≡ ∀P.P

Intuition:Everything can be derived from False.

Proof Rules:False

PFalseE

True 6= False

Proof: Isabelle Demo

FALSE 18-A

Page 62: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

FALSE

consts False :: bool

False ≡ ∀P.P

Intuition:Everything can be derived from False.

Proof Rules:False

PFalseE

True 6= False

Proof: Isabelle Demo

FALSE 18-B

Page 63: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

NEGATION

consts Not :: bool ⇒ bool (¬ )

¬P ≡ P −→ False

Intuition:Try P = True and P = False and the traditional truth table for −→.

Proof Rules:

A =⇒ False¬A

notI¬A A

PnotE

Proof: Isabelle Demo

NEGATION 19

Page 64: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

NEGATION

consts Not :: bool ⇒ bool (¬ )

¬P ≡ P −→ False

Intuition:Try P = True and P = False and the traditional truth table for −→.

Proof Rules:

A =⇒ False¬A

notI¬A A

PnotE

Proof: Isabelle Demo

NEGATION 19-A

Page 65: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

NEGATION

consts Not :: bool ⇒ bool (¬ )

¬P ≡ P −→ False

Intuition:Try P = True and P = False and the traditional truth table for −→.

Proof Rules:

A =⇒ False¬A

notI¬A A

PnotE

Proof: Isabelle Demo

NEGATION 19-B

Page 66: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

EXISTENTIAL QUANTIFIER

consts EX :: (α ⇒ bool) ⇒ bool

EX P ≡ ∀Q. (∀x. P x −→ Q) −→ Q

Intuition:

➜ 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)

Proof Rules:P ?x

∃x. P xexI

∃x. P x∧

x. P x =⇒ R

RexE

Proof: Isabelle Demo

EXISTENTIAL QUANTIFIER 20

Page 67: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

EXISTENTIAL QUANTIFIER

consts EX :: (α ⇒ bool) ⇒ bool

EX P ≡ ∀Q. (∀x. P x −→ Q) −→ Q

Intuition:

➜ 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)

Proof Rules:P ?x

∃x. P xexI

∃x. P x∧

x. P x =⇒ R

RexE

Proof: Isabelle Demo

EXISTENTIAL QUANTIFIER 20-A

Page 68: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

EXISTENTIAL QUANTIFIER

consts EX :: (α ⇒ bool) ⇒ bool

EX P ≡ ∀Q. (∀x. P x −→ Q) −→ Q

Intuition:

➜ 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)

Proof Rules:P ?x

∃x. P xexI

∃x. P x∧

x. P x =⇒ R

RexE

Proof: Isabelle Demo

EXISTENTIAL QUANTIFIER 20-B

Page 69: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

EXISTENTIAL QUANTIFIER

consts EX :: (α ⇒ bool) ⇒ bool

EX P ≡ ∀Q. (∀x. P x −→ Q) −→ Q

Intuition:

➜ 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)

Proof Rules:P ?x

∃x. P xexI

∃x. P x∧

x. P x =⇒ R

RexE

Proof: Isabelle Demo

EXISTENTIAL QUANTIFIER 20-C

Page 70: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

EXISTENTIAL QUANTIFIER

consts EX :: (α ⇒ bool) ⇒ bool

EX P ≡ ∀Q. (∀x. P x −→ Q) −→ Q

Intuition:

➜ 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)

Proof Rules:P ?x

∃x. P xexI

∃x. P x∧

x. P x =⇒ R

RexE

Proof: Isabelle Demo

EXISTENTIAL QUANTIFIER 20-D

Page 71: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

EXISTENTIAL QUANTIFIER

consts EX :: (α ⇒ bool) ⇒ bool

EX P ≡ ∀Q. (∀x. P x −→ Q) −→ Q

Intuition:

➜ 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)

Proof Rules:P ?x

∃x. P xexI

∃x. P x∧

x. P x =⇒ R

RexE

Proof: Isabelle Demo

EXISTENTIAL QUANTIFIER 20-E

Page 72: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

CONJUNCTION

consts And :: bool ⇒ bool ⇒ bool ( ∧ )

P ∧ Q ≡ ∀R. (P −→ Q −→ R) −→ R

Intuition:

➜ Mirrors proof rules for ∧

➜ Try truth table for P , Q, and R

Proof Rules:

A BA ∧ B

conjIA ∧ B [[A; B]] =⇒ C

CconjE

Proof: Isabelle Demo

CONJUNCTION 21

Page 73: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

CONJUNCTION

consts And :: bool ⇒ bool ⇒ bool ( ∧ )

P ∧ Q ≡ ∀R. (P −→ Q −→ R) −→ R

Intuition:

➜ Mirrors proof rules for ∧

➜ Try truth table for P , Q, and R

Proof Rules:

A BA ∧ B

conjIA ∧ B [[A; B]] =⇒ C

CconjE

Proof: Isabelle Demo

CONJUNCTION 21-A

Page 74: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

CONJUNCTION

consts And :: bool ⇒ bool ⇒ bool ( ∧ )

P ∧ Q ≡ ∀R. (P −→ Q −→ R) −→ R

Intuition:

➜ Mirrors proof rules for ∧

➜ Try truth table for P , Q, and R

Proof Rules:

A BA ∧ B

conjIA ∧ B [[A; B]] =⇒ C

CconjE

Proof: Isabelle Demo

CONJUNCTION 21-B

Page 75: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

CONJUNCTION

consts And :: bool ⇒ bool ⇒ bool ( ∧ )

P ∧ Q ≡ ∀R. (P −→ Q −→ R) −→ R

Intuition:

➜ Mirrors proof rules for ∧

➜ Try truth table for P , Q, and R

Proof Rules:

A BA ∧ B

conjIA ∧ B [[A; B]] =⇒ C

CconjE

Proof: Isabelle Demo

CONJUNCTION 21-C

Page 76: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DISJUNCTION

consts Or :: bool ⇒ bool ⇒ bool ( ∨ )

P ∨ Q ≡ ∀R. (P −→ R) −→ (Q −→ R) −→ R

Intuition:

➜ Mirrors proof rules for ∨ (case distinction)

➜ Try truth table for P , Q, and R

Proof Rules:

AA ∨ B

BA ∨ B

disjI1/2 A ∨ B A =⇒ C B =⇒ CC

disjE

Proof: Isabelle Demo

DISJUNCTION 22

Page 77: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DISJUNCTION

consts Or :: bool ⇒ bool ⇒ bool ( ∨ )

P ∨ Q ≡ ∀R. (P −→ R) −→ (Q −→ R) −→ R

Intuition:

➜ Mirrors proof rules for ∨ (case distinction)

➜ Try truth table for P , Q, and R

Proof Rules:

AA ∨ B

BA ∨ B

disjI1/2 A ∨ B A =⇒ C B =⇒ CC

disjE

Proof: Isabelle Demo

DISJUNCTION 22-A

Page 78: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DISJUNCTION

consts Or :: bool ⇒ bool ⇒ bool ( ∨ )

P ∨ Q ≡ ∀R. (P −→ R) −→ (Q −→ R) −→ R

Intuition:

➜ Mirrors proof rules for ∨ (case distinction)

➜ Try truth table for P , Q, and R

Proof Rules:

AA ∨ B

BA ∨ B

disjI1/2 A ∨ B A =⇒ C B =⇒ CC

disjE

Proof: Isabelle Demo

DISJUNCTION 22-B

Page 79: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DISJUNCTION

consts Or :: bool ⇒ bool ⇒ bool ( ∨ )

P ∨ Q ≡ ∀R. (P −→ R) −→ (Q −→ R) −→ R

Intuition:

➜ Mirrors proof rules for ∨ (case distinction)

➜ Try truth table for P , Q, and R

Proof Rules:

AA ∨ B

BA ∨ B

disjI1/2 A ∨ B A =⇒ C B =⇒ CC

disjE

Proof: Isabelle Demo

DISJUNCTION 22-C

Page 80: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

IF-THEN-ELSE

consts If :: bool ⇒ α ⇒ α ⇒ α (if then else )

If P x y ≡ SOME z. (P = True −→ z = x) ∧ (P = False −→ z = y)

Intuition:

➜ for P = True, right hand side collapses to SOME z. z = x

➜ for P = False, right hand side collapses to SOME z. z = y

Proof Rules:

if True then s else t = sifTrue

if False then s else t = tifFalse

Proof: Isabelle Demo

IF-THEN-ELSE 23

Page 81: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

IF-THEN-ELSE

consts If :: bool ⇒ α ⇒ α ⇒ α (if then else )

If P x y ≡ SOME z. (P = True −→ z = x) ∧ (P = False −→ z = y)

Intuition:

➜ for P = True, right hand side collapses to SOME z. z = x

➜ for P = False, right hand side collapses to SOME z. z = y

Proof Rules:

if True then s else t = sifTrue

if False then s else t = tifFalse

Proof: Isabelle Demo

IF-THEN-ELSE 23-A

Page 82: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

IF-THEN-ELSE

consts If :: bool ⇒ α ⇒ α ⇒ α (if then else )

If P x y ≡ SOME z. (P = True −→ z = x) ∧ (P = False −→ z = y)

Intuition:

➜ for P = True, right hand side collapses to SOME z. z = x

➜ for P = False, right hand side collapses to SOME z. z = y

Proof Rules:

if True then s else t = sifTrue

if False then s else t = tifFalse

Proof: Isabelle Demo

IF-THEN-ELSE 23-B

Page 83: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

IF-THEN-ELSE

consts If :: bool ⇒ α ⇒ α ⇒ α (if then else )

If P x y ≡ SOME z. (P = True −→ z = x) ∧ (P = False −→ z = y)

Intuition:

➜ for P = True, right hand side collapses to SOME z. z = x

➜ for P = False, right hand side collapses to SOME z. z = y

Proof Rules:

if True then s else t = sifTrue

if False then s else t = tifFalse

Proof: Isabelle Demo

IF-THEN-ELSE 23-C

Page 84: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

THAT WAS HOL

24

Page 85: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

MORE ON AUTOMATION

Last time: safe and unsafe rule, heuristics: use safe before unsafe

This can be automated

Syntax:[<kind>!] for safe rules (<kind> one of intro, elim, dest)[<kind>] for unsafe rules

Application (roughly):do safe rules first, search/backtrack on unsafe rules only

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)

MORE ON AUTOMATION 25

Page 86: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

MORE ON AUTOMATION

Last time: safe and unsafe rule, heuristics: use safe before unsafe

This can be automated

Syntax:[<kind>!] for safe rules (<kind> one of intro, elim, dest)[<kind>] for unsafe rules

Application (roughly):do safe rules first, search/backtrack on unsafe rules only

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)

MORE ON AUTOMATION 25-A

Page 87: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

MORE ON AUTOMATION

Last time: safe and unsafe rule, heuristics: use safe before unsafe

This can be automated

Syntax:[<kind>!] for safe rules (<kind> one of intro, elim, dest)[<kind>] for unsafe rules

Application (roughly):do safe rules first, search/backtrack on unsafe rules only

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)

MORE ON AUTOMATION 25-C

Page 88: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

MORE ON AUTOMATION

Last time: safe and unsafe rule, heuristics: use safe before unsafe

This can be automated

Syntax:[<kind>!] for safe rules (<kind> one of intro, elim, dest)[<kind>] for unsafe rules

Application (roughly):do safe rules first, search/backtrack on unsafe rules only

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)

MORE ON AUTOMATION 25-D

Page 89: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

MORE ON AUTOMATION

Last time: safe and unsafe rule, heuristics: use safe before unsafe

This can be automated

Syntax:[<kind>!] for safe rules (<kind> one of intro, elim, dest)[<kind>] for unsafe rules

Application (roughly):do safe rules first, search/backtrack on unsafe rules only

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)

MORE ON AUTOMATION 25-E

Page 90: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

DEMO: AUTOMATION

26

Page 91: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

WE HAVE LEARNED TODAY ...

➜ Defining HOL

➜ Higher Order Abstract Syntax

➜ Deriving proof rules

➜ More automation

WE HAVE LEARNED TODAY ... 27

Page 92: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

WE HAVE LEARNED TODAY ...

➜ Defining HOL

➜ Higher Order Abstract Syntax

➜ Deriving proof rules

➜ More automation

WE HAVE LEARNED TODAY ... 27-A

Page 93: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

WE HAVE LEARNED TODAY ...

➜ Defining HOL

➜ Higher Order Abstract Syntax

➜ Deriving proof rules

➜ More automation

WE HAVE LEARNED TODAY ... 27-B

Page 94: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

WE HAVE LEARNED TODAY ...

➜ Defining HOL

➜ Higher Order Abstract Syntax

➜ Deriving proof rules

➜ More automation

WE HAVE LEARNED TODAY ... 27-C

Page 95: NICTA Advanced Course Theorem Proving Principles, Techniques, … · 2004. 9. 20. · Some automation LAST TIME ON HOL 3-D. DEFINING HIGHER ORDER LOGIC 4. WHAT IS HIGHER ORDER LOGIC?

EXERCISES

➜ derive the classical contradiction rule (¬P =⇒ False) =⇒ P in

Isabelle

➜ define nor and nand in Isabelle

➜ show nor x x = nand x x

➜ derive safe intro and elim rules for them

➜ use these in an automated proof of nor x x = nand x x

EXERCISES 28