1 C ONTENT Intro & motivation, getting started with Isabelle - - PowerPoint PPT Presentation

1 c ontent intro motivation getting started with isabelle
SMART_READER_LITE
LIVE PREVIEW

1 C ONTENT Intro & motivation, getting started with Isabelle - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

NICTA Advanced Course Theorem Proving Principles, Techniques, Applications

− →

1

slide-2
SLIDE 2

CONTENT

➜ Intro & motivation, getting started with Isabelle ➜ Foundations & Principles

  • Lambda Calculus
  • Higher Order Logic, natural deduction
  • Term rewriting

➜ Proof & Specification Techniques

  • Inductively defined sets, rule induction
  • Datatypes, recursion, induction
  • Calculational reasoning, mathematics style proofs
  • Hoare logic, proofs about programs

CONTENT 2

slide-3
SLIDE 3

LAST TIME ON HOL

➜ Defining HOL

LAST TIME ON HOL 3

slide-4
SLIDE 4

LAST TIME ON HOL

➜ Defining HOL ➜ Higher Order Abstract Syntax

LAST TIME ON HOL 3-A

slide-5
SLIDE 5

LAST TIME ON HOL

➜ Defining HOL ➜ Higher Order Abstract Syntax ➜ Deriving proof rules

LAST TIME ON HOL 3-B

slide-6
SLIDE 6

LAST TIME ON HOL

➜ Defining HOL ➜ Higher Order Abstract Syntax ➜ Deriving proof rules ➜ More automation

LAST TIME ON HOL 3-C

slide-7
SLIDE 7

THE THREE BASIC WAYS OF INTRODUCING THEOREMS

➜ Axioms: Expample: axioms refl: ”t = t”

THE THREE BASIC WAYS OF INTRODUCING THEOREMS 4

slide-8
SLIDE 8

THE THREE BASIC WAYS OF INTRODUCING THEOREMS

➜ Axioms: Expample: axioms refl: ”t = t” Do not use. Evil. Can make your logic inconsistent.

THE THREE BASIC WAYS OF INTRODUCING THEOREMS 4-A

slide-9
SLIDE 9

THE THREE BASIC WAYS OF INTRODUCING THEOREMS

➜ Axioms: Expample: axioms refl: ”t = t” Do not use. Evil. Can make your logic inconsistent. ➜ Definitions: Example: defs inj def: ”inj f ≡ ∀x y. f x = f y − → x = y”

THE THREE BASIC WAYS OF INTRODUCING THEOREMS 4-B

slide-10
SLIDE 10

THE THREE BASIC WAYS OF INTRODUCING THEOREMS

➜ Axioms: Expample: axioms refl: ”t = t” Do not use. Evil. Can make your logic inconsistent. ➜ Definitions: Example: defs inj def: ”inj f ≡ ∀x y. f x = f y − → x = y” ➜ Proofs: Example: lemma ”inj (λx. x + 1)”

THE THREE BASIC WAYS OF INTRODUCING THEOREMS 4-C

slide-11
SLIDE 11

THE THREE BASIC WAYS OF INTRODUCING THEOREMS

➜ Axioms: Expample: axioms refl: ”t = t” Do not use. Evil. Can make your logic inconsistent. ➜ Definitions: Example: defs inj def: ”inj f ≡ ∀x y. f x = f y − → x = y” ➜ Proofs: Example: lemma ”inj (λx. x + 1)” The harder, but safe choice.

THE THREE BASIC WAYS OF INTRODUCING THEOREMS 4-D

slide-12
SLIDE 12

THE THREE BASIC WAYS OF INTRODUCING TYPES

➜ typedecl: by name only Example: typedecl names

THE THREE BASIC WAYS OF INTRODUCING TYPES 5

slide-13
SLIDE 13

THE THREE BASIC WAYS OF INTRODUCING TYPES

➜ typedecl: by name only Example: typedecl names Introduces new type names without any further assumptions

THE THREE BASIC WAYS OF INTRODUCING TYPES 5-A

slide-14
SLIDE 14

THE THREE BASIC WAYS OF INTRODUCING TYPES

➜ typedecl: by name only Example: typedecl names Introduces new type names without any further assumptions ➜ types: by abbreviation Example: types α rel = ”α ⇒ α ⇒ bool”

THE THREE BASIC WAYS OF INTRODUCING TYPES 5-B

slide-15
SLIDE 15

THE THREE BASIC WAYS OF INTRODUCING TYPES

➜ typedecl: by name only Example: typedecl names Introduces new type names without any further assumptions ➜ types: by abbreviation Example: types α rel = ”α ⇒ α ⇒ bool” Introduces abbreviation rel for existing type α ⇒ α ⇒ bool Type abbreviations are immediatly expanded internally

THE THREE BASIC WAYS OF INTRODUCING TYPES 5-C

slide-16
SLIDE 16

THE THREE BASIC WAYS OF INTRODUCING TYPES

➜ typedecl: by name only Example: typedecl names Introduces new type names without any further assumptions ➜ types: by abbreviation Example: types α rel = ”α ⇒ α ⇒ bool” Introduces abbreviation rel for existing type α ⇒ α ⇒ bool Type abbreviations are immediatly expanded internally ➜ typedef: by definiton as a set Example: typdef new type = ”{some set}” <proof>

THE THREE BASIC WAYS OF INTRODUCING TYPES 5-D

slide-17
SLIDE 17

THE THREE BASIC WAYS OF INTRODUCING TYPES

➜ typedecl: by name only Example: typedecl names Introduces new type names without any further assumptions ➜ types: by abbreviation Example: types α rel = ”α ⇒ α ⇒ bool” Introduces abbreviation rel for existing type α ⇒ α ⇒ bool Type abbreviations are immediatly expanded internally ➜ typedef: by definiton as a set Example: typdef new type = ”{some set}” <proof> Introduces a new type as a subset of an existing type. The proof shows that the set on the rhs in non-empty.

THE THREE BASIC WAYS OF INTRODUCING TYPES 5-E

slide-18
SLIDE 18

HOW TYPEDEF WORKS

✬ ✫ ✩ ✪ new type

HOW TYPEDEF WORKS 6

slide-19
SLIDE 19

HOW TYPEDEF WORKS

✬ ✫ ✩ ✪ new type existing type

HOW TYPEDEF WORKS 6-A

slide-20
SLIDE 20

HOW TYPEDEF WORKS

✬ ✫ ✩ ✪ new type existing type

HOW TYPEDEF WORKS 6-B

slide-21
SLIDE 21

HOW TYPEDEF WORKS

✬ ✫ ✩ ✪ new type existing type ✛ Abs ✲ Rep

HOW TYPEDEF WORKS 6-C

slide-22
SLIDE 22

HOW TYPEDEF WORKS

✬ ✫ ✩ ✪ new type existing type ✛ Abs ✲ Rep

HOW TYPEDEF WORKS 7

slide-23
SLIDE 23

EXAMPLE: PAIRS

(α, β) Prod

➀ Pick existing type:

EXAMPLE: PAIRS 8

slide-24
SLIDE 24

EXAMPLE: PAIRS

(α, β) Prod

➀ Pick existing type: α ⇒ β ⇒ bool ➁ Identify subset:

EXAMPLE: PAIRS 8-A

slide-25
SLIDE 25

EXAMPLE: PAIRS

(α, β) Prod

➀ Pick existing type: α ⇒ β ⇒ bool ➁ Identify subset: (α, β) Prod = {f. ∃a b. f = λ(x :: α) (y :: β). x = a ∧ y = b} ➂ We get from Isabelle:

EXAMPLE: PAIRS 8-B

slide-26
SLIDE 26

EXAMPLE: PAIRS

(α, β) Prod

➀ Pick existing type: α ⇒ β ⇒ bool ➁ Identify subset: (α, β) Prod = {f. ∃a b. f = λ(x :: α) (y :: β). x = a ∧ y = b} ➂ We get from Isabelle:

  • functions Abs Prod, Rep Prod
  • both injective
  • Abs Prod (Rep Prod x) = x

➃ We now can:

EXAMPLE: PAIRS 8-C

slide-27
SLIDE 27

EXAMPLE: PAIRS

(α, β) Prod

➀ Pick existing type: α ⇒ β ⇒ bool ➁ Identify subset: (α, β) Prod = {f. ∃a b. f = λ(x :: α) (y :: β). x = a ∧ y = b} ➂ We get from Isabelle:

  • functions Abs Prod, Rep Prod
  • both injective
  • Abs Prod (Rep Prod x) = x

➃ We now can:

  • define constants Pair, fst, snd in terms of Abs Prod and Rep Prod
  • derive all characteristic theorems
  • forget about Rep/Abs, use characteristic theorems instead

EXAMPLE: PAIRS 8-D

slide-28
SLIDE 28

DEMO: INTRODUCTING NEW TYPES

9

slide-29
SLIDE 29

TERM REWRITING

10

slide-30
SLIDE 30

THE PROBLEM

Given a set of equations l1 = r1 l2 = r2 . . . ln = rn

THE PROBLEM 11

slide-31
SLIDE 31

THE PROBLEM

Given a set of equations l1 = r1 l2 = r2 . . . ln = rn does equation l = r hold?

THE PROBLEM 11-A

slide-32
SLIDE 32

THE PROBLEM

Given a set of equations l1 = r1 l2 = r2 . . . ln = rn does equation l = r hold? Applications in:

➜ Mathematics (algebra, group theory, etc) ➜ Functional Programming (model of execution) ➜ Theorem Proving (dealing with equations, simplifying statements)

THE PROBLEM 11-B

slide-33
SLIDE 33

TERM REWRITING: THE IDEA

use equations as reduction rules l1 − → r1 l2 − → r2 . . . ln − → rn decide l = r by deciding l

← → r

TERM REWRITING: THE IDEA 12

slide-34
SLIDE 34

ARROW CHEAT SHEET

− → = {(x, y)|x = y} identity

ARROW CHEAT SHEET 13

slide-35
SLIDE 35

ARROW CHEAT SHEET

− → = {(x, y)|x = y} identity

n+1

− → =

n

− → ◦ − → n+1 fold composition

ARROW CHEAT SHEET 13-A

slide-36
SLIDE 36

ARROW CHEAT SHEET

− → = {(x, y)|x = y} identity

n+1

− → =

n

− → ◦ − → n+1 fold composition

+

− → =

  • i>0

i

− → transitive closure

ARROW CHEAT SHEET 13-B

slide-37
SLIDE 37

ARROW CHEAT SHEET

− → = {(x, y)|x = y} identity

n+1

− → =

n

− → ◦ − → n+1 fold composition

+

− → =

  • i>0

i

− → transitive closure

− → =

+

− → ∪ − → refl exive transitive closure

ARROW CHEAT SHEET 13-C

slide-38
SLIDE 38

ARROW CHEAT SHEET

− → = {(x, y)|x = y} identity

n+1

− → =

n

− → ◦ − → n+1 fold composition

+

− → =

  • i>0

i

− → transitive closure

− → =

+

− → ∪ − → refl exive transitive closure

=

− → = − → ∪ − → refl exive closure

ARROW CHEAT SHEET 13-D

slide-39
SLIDE 39

ARROW CHEAT SHEET

− → = {(x, y)|x = y} identity

n+1

− → =

n

− → ◦ − → n+1 fold composition

+

− → =

  • i>0

i

− → transitive closure

− → =

+

− → ∪ − → refl exive transitive closure

=

− → = − → ∪ − → refl exive closure

−1

− → = {(y, x)|x − → y} inverse

ARROW CHEAT SHEET 13-E

slide-40
SLIDE 40

ARROW CHEAT SHEET

− → = {(x, y)|x = y} identity

n+1

− → =

n

− → ◦ − → n+1 fold composition

+

− → =

  • i>0

i

− → transitive closure

− → =

+

− → ∪ − → refl exive transitive closure

=

− → = − → ∪ − → refl exive closure

−1

− → = {(y, x)|x − → y} inverse ← − =

−1

− → inverse

ARROW CHEAT SHEET 13-F

slide-41
SLIDE 41

ARROW CHEAT SHEET

− → = {(x, y)|x = y} identity

n+1

− → =

n

− → ◦ − → n+1 fold composition

+

− → =

  • i>0

i

− → transitive closure

− → =

+

− → ∪ − → refl exive transitive closure

=

− → = − → ∪ − → refl exive closure

−1

− → = {(y, x)|x − → y} inverse ← − =

−1

− → inverse ← → = ← − ∪ − → symmetric closure

ARROW CHEAT SHEET 13-G

slide-42
SLIDE 42

ARROW CHEAT SHEET

− → = {(x, y)|x = y} identity

n+1

− → =

n

− → ◦ − → n+1 fold composition

+

− → =

  • i>0

i

− → transitive closure

− → =

+

− → ∪ − → refl exive transitive closure

=

− → = − → ∪ − → refl exive closure

−1

− → = {(y, x)|x − → y} inverse ← − =

−1

− → inverse ← → = ← − ∪ − → symmetric closure

+

← → =

  • i>0

i

← → transitive symmetric closure

← → =

+

← → ∪ ← → refl exive transitive symmetric closure

ARROW CHEAT SHEET 13-H

slide-43
SLIDE 43

HOW TO DECIDE l

← → r

Same idea as for β:

HOW TO DECIDE l

← → r 14

slide-44
SLIDE 44

HOW TO DECIDE l

← → r

Same idea as for β: look for n such that l

− → n and r

− → n Does this always work?

HOW TO DECIDE l

← → r 14-A

slide-45
SLIDE 45

HOW TO DECIDE l

← → r

Same idea as for β: look for n such that l

− → n and r

− → n Does this always work? If l

− → n and r

− → n then l

← → r. Ok.

HOW TO DECIDE l

← → r 14-B

slide-46
SLIDE 46

HOW TO DECIDE l

← → r

Same idea as for β: look for n such that l

− → n and r

− → n Does this always work? If l

− → n and r

− → n then l

← → r. Ok. If l

← → r, will there always be a suitable n?

HOW TO DECIDE l

← → r 14-C

slide-47
SLIDE 47

HOW TO DECIDE l

← → r

Same idea as for β: look for n such that l

− → n and r

− → n Does this always work? If l

− → n and r

− → n then l

← → r. Ok. If l

← → r, will there always be a suitable n? No! Example: Rules: f x − → a, g x − → b, f (g x) − → b

HOW TO DECIDE l

← → r 14-D

slide-48
SLIDE 48

HOW TO DECIDE l

← → r

Same idea as for β: look for n such that l

− → n and r

− → n Does this always work? If l

− → n and r

− → n then l

← → r. Ok. If l

← → r, will there always be a suitable n? No! Example: Rules: f x − → a, g x − → b, f (g x) − → b f x

← → g x because f x − → a ← − f (g x) − → b ← − g x

HOW TO DECIDE l

← → r 14-E

slide-49
SLIDE 49

HOW TO DECIDE l

← → r

Same idea as for β: look for n such that l

− → n and r

− → n Does this always work? If l

− → n and r

− → n then l

← → r. Ok. If l

← → r, will there always be a suitable n? No! Example: Rules: f x − → a, g x − → b, f (g x) − → b f x

← → g x because f x − → a ← − f (g x) − → b ← − g x But: f x − → a and g x − → b and a, b in normal form

HOW TO DECIDE l

← → r 14-F

slide-50
SLIDE 50

HOW TO DECIDE l

← → r

Same idea as for β: look for n such that l

− → n and r

− → n Does this always work? If l

− → n and r

− → n then l

← → r. Ok. If l

← → r, will there always be a suitable n? No! Example: Rules: f x − → a, g x − → b, f (g x) − → b f x

← → g x because f x − → a ← − f (g x) − → b ← − g x But: f x − → a and g x − → b and a, b in normal form Works only for systems with Church-Rosser property: l

← → r = ⇒ ∃n. l

− → n ∧ r

− → n

HOW TO DECIDE l

← → r 14-G

slide-51
SLIDE 51

HOW TO DECIDE l

← → r

Same idea as for β: look for n such that l

− → n and r

− → n Does this always work? If l

− → n and r

− → n then l

← → r. Ok. If l

← → r, will there always be a suitable n? No! Example: Rules: f x − → a, g x − → b, f (g x) − → b f x

← → g x because f x − → a ← − f (g x) − → b ← − g x But: f x − → a and g x − → b and a, b in normal form Works only for systems with Church-Rosser property: l

← → r = ⇒ ∃n. l

− → n ∧ r

− → n Fact: − → is Church-Rosser iff it is confl uent.

HOW TO DECIDE l

← → r 14-H

slide-52
SLIDE 52

CONFLUENCE

s x y t ∗ ∗ ∗ ∗ Problem: is a given set of reduction rules confl uent?

CONFLUENCE 15

slide-53
SLIDE 53

CONFLUENCE

s x y t ∗ ∗ ∗ ∗ Problem: is a given set of reduction rules confl uent? undecidable

CONFLUENCE 15-A

slide-54
SLIDE 54

CONFLUENCE

s x y t ∗ ∗ ∗ ∗ Problem: is a given set of reduction rules confl uent? undecidable Local Confluence s x y t ∗ ∗

CONFLUENCE 15-B

slide-55
SLIDE 55

CONFLUENCE

s x y t ∗ ∗ ∗ ∗ Problem: is a given set of reduction rules confl uent? undecidable Local Confluence s x y t ∗ ∗ Fact: local confl uence and termination = ⇒ confl uence

CONFLUENCE 15-C

slide-56
SLIDE 56

TERMINATION

− → is terminating if there are no infinite reduction chains − → is normalizing if each element has a normal form − → is convergent if it is terminating and confl uent Example:

TERMINATION 16

slide-57
SLIDE 57

TERMINATION

− → is terminating if there are no infinite reduction chains − → is normalizing if each element has a normal form − → is convergent if it is terminating and confl uent Example: − →β in λ is not terminating, but confl uent

TERMINATION 16-A

slide-58
SLIDE 58

TERMINATION

− → is terminating if there are no infinite reduction chains − → is normalizing if each element has a normal form − → is convergent if it is terminating and confl uent Example: − →β in λ is not terminating, but confl uent − →β in λ→ is terminating and confl uent, i.e. convergent

TERMINATION 16-B

slide-59
SLIDE 59

TERMINATION

− → is terminating if there are no infinite reduction chains − → is normalizing if each element has a normal form − → is convergent if it is terminating and confl uent Example: − →β in λ is not terminating, but confl uent − →β in λ→ is terminating and confl uent, i.e. convergent Problem: is a given set of reduction rules terminating?

TERMINATION 16-C

slide-60
SLIDE 60

TERMINATION

− → is terminating if there are no infinite reduction chains − → is normalizing if each element has a normal form − → is convergent if it is terminating and confl uent Example: − →β in λ is not terminating, but confl uent − →β in λ→ is terminating and confl uent, i.e. convergent Problem: is a given set of reduction rules terminating? undecidable

TERMINATION 16-D

slide-61
SLIDE 61

WHEN IS − → TERMINATING?

Basic Idea:

WHEN IS − → TERMINATING? 17

slide-62
SLIDE 62

WHEN IS − → TERMINATING?

Basic Idea: when the ri are in some way simpler then the li

WHEN IS − → TERMINATING? 17-A

slide-63
SLIDE 63

WHEN IS − → TERMINATING?

Basic Idea: when the ri are in some way simpler then the li More formally: − → is terminating when there is a well founded order < in which ri < li for all rules. (well founded = no infinite decreasing chains a1 > a2 > . . .) Example:

WHEN IS − → TERMINATING? 17-B

slide-64
SLIDE 64

WHEN IS − → TERMINATING?

Basic Idea: when the ri are in some way simpler then the li More formally: − → is terminating when there is a well founded order < in which ri < li for all rules. (well founded = no infinite decreasing chains a1 > a2 > . . .) Example: f (g x) − → g x, g (f x) − → f x This system always terminates. Reduction order:

WHEN IS − → TERMINATING? 17-C

slide-65
SLIDE 65

WHEN IS − → TERMINATING?

Basic Idea: when the ri are in some way simpler then the li More formally: − → is terminating when there is a well founded order < in which ri < li for all rules. (well founded = no infinite decreasing chains a1 > a2 > . . .) Example: f (g x) − → g x, g (f x) − → f x This system always terminates. Reduction order: s <r t iff size(s) < size(t) with size(s) = numer of function symbols in s

WHEN IS − → TERMINATING? 17-D

slide-66
SLIDE 66

WHEN IS − → TERMINATING?

Basic Idea: when the ri are in some way simpler then the li More formally: − → is terminating when there is a well founded order < in which ri < li for all rules. (well founded = no infinite decreasing chains a1 > a2 > . . .) Example: f (g x) − → g x, g (f x) − → f x This system always terminates. Reduction order: s <r t iff size(s) < size(t) with size(s) = numer of function symbols in s

➀ g x <r f (g x) and f x <r g (f x)

WHEN IS − → TERMINATING? 17-E

slide-67
SLIDE 67

WHEN IS − → TERMINATING?

Basic Idea: when the ri are in some way simpler then the li More formally: − → is terminating when there is a well founded order < in which ri < li for all rules. (well founded = no infinite decreasing chains a1 > a2 > . . .) Example: f (g x) − → g x, g (f x) − → f x This system always terminates. Reduction order: s <r t iff size(s) < size(t) with size(s) = numer of function symbols in s

➀ g x <r f (g x) and f x <r g (f x) ➁ <r is well founded, because < is well founded on I N

WHEN IS − → TERMINATING? 17-F

slide-68
SLIDE 68

TERM REWRITING IN ISABELLE

Term rewriting engine in Isabelle is called Simplifier

TERM REWRITING IN ISABELLE 18

slide-69
SLIDE 69

TERM REWRITING IN ISABELLE

Term rewriting engine in Isabelle is called Simplifier apply simp

➜ uses simplification rules

TERM REWRITING IN ISABELLE 18-A

slide-70
SLIDE 70

TERM REWRITING IN ISABELLE

Term rewriting engine in Isabelle is called Simplifier apply simp

➜ uses simplification rules ➜ (almost) blindly from left to right

TERM REWRITING IN ISABELLE 18-B

slide-71
SLIDE 71

TERM REWRITING IN ISABELLE

Term rewriting engine in Isabelle is called Simplifier apply simp

➜ uses simplification rules ➜ (almost) blindly from left to right ➜ until no rule is applicable.

TERM REWRITING IN ISABELLE 18-C

slide-72
SLIDE 72

TERM REWRITING IN ISABELLE

Term rewriting engine in Isabelle is called Simplifier apply simp

➜ uses simplification rules ➜ (almost) blindly from left to right ➜ until no rule is applicable.

termination: not guaranteed (may loop)

TERM REWRITING IN ISABELLE 18-D

slide-73
SLIDE 73

TERM REWRITING IN ISABELLE

Term rewriting engine in Isabelle is called Simplifier apply simp

➜ uses simplification rules ➜ (almost) blindly from left to right ➜ until no rule is applicable.

termination: not guaranteed (may loop) confluence: not guaranteed (result may depend on which rule is used first)

TERM REWRITING IN ISABELLE 18-E

slide-74
SLIDE 74

CONTROL

➜ Equations turned into simplifaction rules with [simp] attribute

CONTROL 19

slide-75
SLIDE 75

CONTROL

➜ Equations turned into simplifaction rules with [simp] attribute ➜ Adding/deleting equations locally: apply (simp add: <rules>) and apply (simp del: <rules>)

CONTROL 19-A

slide-76
SLIDE 76

CONTROL

➜ Equations turned into simplifaction rules with [simp] attribute ➜ Adding/deleting equations locally: apply (simp add: <rules>) and apply (simp del: <rules>) ➜ Using only the specified set of equations: apply (simp only: <rules>)

CONTROL 19-B

slide-77
SLIDE 77

DEMO

20

slide-78
SLIDE 78

ISAR A LANGUAGE FOR STRUCTURED PROOFS

21

slide-79
SLIDE 79

ISAR

apply scripts ➜ unreadable

ISAR 22

slide-80
SLIDE 80

ISAR

apply scripts ➜ unreadable ➜ hard to maintain

ISAR 22-A

slide-81
SLIDE 81

ISAR

apply scripts ➜ unreadable ➜ hard to maintain ➜ do not scale

ISAR 22-B

slide-82
SLIDE 82

ISAR

apply scripts ➜ unreadable ➜ hard to maintain ➜ do not scale

No structure.

ISAR 22-C

slide-83
SLIDE 83

ISAR

apply scripts What about.. ➜ unreadable ➜ Elegance? ➜ hard to maintain ➜ do not scale

No structure.

ISAR 22-D

slide-84
SLIDE 84

ISAR

apply scripts What about.. ➜ unreadable ➜ Elegance? ➜ hard to maintain ➜ Explaining deeper insights? ➜ do not scale

No structure.

ISAR 22-E

slide-85
SLIDE 85

ISAR

apply scripts What about.. ➜ unreadable ➜ Elegance? ➜ hard to maintain ➜ Explaining deeper insights? ➜ do not scale ➜ Large developments?

No structure.

ISAR 22-F

slide-86
SLIDE 86

ISAR

apply scripts What about.. ➜ unreadable ➜ Elegance? ➜ hard to maintain ➜ Explaining deeper insights? ➜ do not scale ➜ Large developments?

No structure. Isar!

ISAR 22-G

slide-87
SLIDE 87

A TYPICAL ISAR PROOF

proof assume formula0 have formula1 by simp . . . have formulan by blast show formulan+1 by . . . qed

A TYPICAL ISAR PROOF 23

slide-88
SLIDE 88

A TYPICAL ISAR PROOF

proof assume formula0 have formula1 by simp . . . have formulan by blast show formulan+1 by . . . qed proves formula0 = ⇒ formulan+1

A TYPICAL ISAR PROOF 23-A

slide-89
SLIDE 89

A TYPICAL ISAR PROOF

proof assume formula0 have formula1 by simp . . . have formulan by blast show formulan+1 by . . . qed proves formula0 = ⇒ formulan+1 (analogous to assumes/shows in lemma statements)

A TYPICAL ISAR PROOF 23-B

slide-90
SLIDE 90

ISAR CORE SYNTAX

proof = proof [method] statement∗ qed | by method

ISAR CORE SYNTAX 24

slide-91
SLIDE 91

ISAR CORE SYNTAX

proof = proof [method] statement∗ qed | by method method = (simp . . . ) | (blast . . . ) | (rule . . . ) | . . .

ISAR CORE SYNTAX 24-A

slide-92
SLIDE 92

ISAR CORE SYNTAX

proof = proof [method] statement∗ qed | by method method = (simp . . . ) | (blast . . . ) | (rule . . . ) | . . . statement = fix variables () | assume proposition (= ⇒) | [from name+] (have | show) proposition proof | next

(separates subgoals)

ISAR CORE SYNTAX 24-B

slide-93
SLIDE 93

ISAR CORE SYNTAX

proof = proof [method] statement∗ qed | by method method = (simp . . . ) | (blast . . . ) | (rule . . . ) | . . . statement = fix variables () | assume proposition (= ⇒) | [from name+] (have | show) proposition proof | next

(separates subgoals)

proposition = [name:] formula

ISAR CORE SYNTAX 24-C

slide-94
SLIDE 94

PROOF AND QED

proof [method] statement∗ qed lemma ”[ [A; B] ] = ⇒ A ∧ B”

PROOF AND QED

25

slide-95
SLIDE 95

PROOF AND QED

proof [method] statement∗ qed lemma ”[ [A; B] ] = ⇒ A ∧ B” proof (rule conjI)

PROOF AND QED

25-A

slide-96
SLIDE 96

PROOF AND QED

proof [method] statement∗ qed lemma ”[ [A; B] ] = ⇒ A ∧ B” proof (rule conjI) assume A: ”A” from A show ”A” by assumption

PROOF AND QED

25-B

slide-97
SLIDE 97

PROOF AND QED

proof [method] statement∗ qed lemma ”[ [A; B] ] = ⇒ A ∧ B” proof (rule conjI) assume A: ”A” from A show ”A” by assumption next

PROOF AND QED

25-C

slide-98
SLIDE 98

PROOF AND QED

proof [method] statement∗ qed lemma ”[ [A; B] ] = ⇒ A ∧ B” proof (rule conjI) assume A: ”A” from A show ”A” by assumption next assume B: ”B” from B show ”B” by assumption

PROOF AND QED

25-D

slide-99
SLIDE 99

PROOF AND QED

proof [method] statement∗ qed lemma ”[ [A; B] ] = ⇒ A ∧ B” proof (rule conjI) assume A: ”A” from A show ”A” by assumption next assume B: ”B” from B show ”B” by assumption qed

PROOF AND QED

25-E

slide-100
SLIDE 100

PROOF AND QED

proof [method] statement∗ qed lemma ”[ [A; B] ] = ⇒ A ∧ B” proof (rule conjI) assume A: ”A” from A show ”A” by assumption next assume B: ”B” from B show ”B” by assumption qed ➜ proof (<method>) applies method to the stated goal

PROOF AND QED

25-F

slide-101
SLIDE 101

PROOF AND QED

proof [method] statement∗ qed lemma ”[ [A; B] ] = ⇒ A ∧ B” proof (rule conjI) assume A: ”A” from A show ”A” by assumption next assume B: ”B” from B show ”B” by assumption qed ➜ proof (<method>) applies method to the stated goal ➜ proof applies a single rule that fits

PROOF AND QED

25-G

slide-102
SLIDE 102

PROOF AND QED

proof [method] statement∗ qed lemma ”[ [A; B] ] = ⇒ A ∧ B” proof (rule conjI) assume A: ”A” from A show ”A” by assumption next assume B: ”B” from B show ”B” by assumption qed ➜ proof (<method>) applies method to the stated goal ➜ proof applies a single rule that fits ➜ proof - does nothing to the goal

PROOF AND QED

25-H

slide-103
SLIDE 103

HOW DO I KNOW WHAT TO ASSUME AND SHOW?

Look at the proof state! lemma ”[ [A; B] ] = ⇒ A ∧ B” proof (rule conjI)

HOW DO I KNOW WHAT TO ASSUME AND SHOW? 26

slide-104
SLIDE 104

HOW DO I KNOW WHAT TO ASSUME AND SHOW?

Look at the proof state! lemma ”[ [A; B] ] = ⇒ A ∧ B” proof (rule conjI)

➜ proof (rule conjI) changes proof state to

  • 1. [

[A; B] ] = ⇒ A

  • 2. [

[A; B] ] = ⇒ B

HOW DO I KNOW WHAT TO ASSUME AND SHOW? 26-A

slide-105
SLIDE 105

HOW DO I KNOW WHAT TO ASSUME AND SHOW?

Look at the proof state! lemma ”[ [A; B] ] = ⇒ A ∧ B” proof (rule conjI)

➜ proof (rule conjI) changes proof state to

  • 1. [

[A; B] ] = ⇒ A

  • 2. [

[A; B] ] = ⇒ B ➜ so we need 2 shows: show ”A” and show ”B”

HOW DO I KNOW WHAT TO ASSUME AND SHOW? 26-B

slide-106
SLIDE 106

HOW DO I KNOW WHAT TO ASSUME AND SHOW?

Look at the proof state! lemma ”[ [A; B] ] = ⇒ A ∧ B” proof (rule conjI)

➜ proof (rule conjI) changes proof state to

  • 1. [

[A; B] ] = ⇒ A

  • 2. [

[A; B] ] = ⇒ B ➜ so we need 2 shows: show ”A” and show ”B” ➜ We are allowed to assume A, because A is in the assumptions of the proof state.

HOW DO I KNOW WHAT TO ASSUME AND SHOW? 26-C

slide-107
SLIDE 107

THE THREE MODES OF ISAR

➜ [prove]: goal has been stated, proof needs to follow.

THE THREE MODES OF ISAR 27

slide-108
SLIDE 108

THE THREE MODES OF ISAR

➜ [prove]: goal has been stated, proof needs to follow. ➜ [state]: proof block has openend or subgoal has been proved, new from statement, goal statement or assumptions can follow.

THE THREE MODES OF ISAR 27-A

slide-109
SLIDE 109

THE THREE MODES OF ISAR

➜ [prove]: goal has been stated, proof needs to follow. ➜ [state]: proof block has openend or subgoal has been proved, new from statement, goal statement or assumptions can follow. ➜ [chain]: from statement has been made, goal statement needs to follow.

THE THREE MODES OF ISAR 27-B

slide-110
SLIDE 110

THE THREE MODES OF ISAR

➜ [prove]: goal has been stated, proof needs to follow. ➜ [state]: proof block has openend or subgoal has been proved, new from statement, goal statement or assumptions can follow. ➜ [chain]: from statement has been made, goal statement needs to follow.

lemma ”[ [A; B] ] = ⇒ A ∧ B”

THE THREE MODES OF ISAR 27-C

slide-111
SLIDE 111

THE THREE MODES OF ISAR

➜ [prove]: goal has been stated, proof needs to follow. ➜ [state]: proof block has openend or subgoal has been proved, new from statement, goal statement or assumptions can follow. ➜ [chain]: from statement has been made, goal statement needs to follow.

lemma ”[ [A; B] ] = ⇒ A ∧ B” [prove]

THE THREE MODES OF ISAR 27-D

slide-112
SLIDE 112

THE THREE MODES OF ISAR

➜ [prove]: goal has been stated, proof needs to follow. ➜ [state]: proof block has openend or subgoal has been proved, new from statement, goal statement or assumptions can follow. ➜ [chain]: from statement has been made, goal statement needs to follow.

lemma ”[ [A; B] ] = ⇒ A ∧ B” [prove] proof (rule conjI) [state]

THE THREE MODES OF ISAR 27-E

slide-113
SLIDE 113

THE THREE MODES OF ISAR

➜ [prove]: goal has been stated, proof needs to follow. ➜ [state]: proof block has openend or subgoal has been proved, new from statement, goal statement or assumptions can follow. ➜ [chain]: from statement has been made, goal statement needs to follow.

lemma ”[ [A; B] ] = ⇒ A ∧ B” [prove] proof (rule conjI) [state] assume A: ”A” [state]

THE THREE MODES OF ISAR 27-F

slide-114
SLIDE 114

THE THREE MODES OF ISAR

➜ [prove]: goal has been stated, proof needs to follow. ➜ [state]: proof block has openend or subgoal has been proved, new from statement, goal statement or assumptions can follow. ➜ [chain]: from statement has been made, goal statement needs to follow.

lemma ”[ [A; B] ] = ⇒ A ∧ B” [prove] proof (rule conjI) [state] assume A: ”A” [state] from A [chain]

THE THREE MODES OF ISAR 27-G

slide-115
SLIDE 115

THE THREE MODES OF ISAR

➜ [prove]: goal has been stated, proof needs to follow. ➜ [state]: proof block has openend or subgoal has been proved, new from statement, goal statement or assumptions can follow. ➜ [chain]: from statement has been made, goal statement needs to follow.

lemma ”[ [A; B] ] = ⇒ A ∧ B” [prove] proof (rule conjI) [state] assume A: ”A” [state] from A [chain] show ”A” [prove] by assumption [state] next [state] . . .

THE THREE MODES OF ISAR 27-H

slide-116
SLIDE 116

HAVE

Can be used to make intermediate steps. Example:

HAVE 28

slide-117
SLIDE 117

HAVE

Can be used to make intermediate steps. Example: lemma ”(x :: nat) + 1 = 1 + x” proof - have A: ”x + 1 = Suc x” by simp have B: ”1 + x = Suc x” by simp show ”x + 1 = 1 + x” by (simp only: A B) qed

HAVE 28-A

slide-118
SLIDE 118

DEMO: ISAR PROOFS

29

slide-119
SLIDE 119

WE HAVE LEARNED TODAY ...

➜ Introducing new Types

WE HAVE LEARNED TODAY ... 30

slide-120
SLIDE 120

WE HAVE LEARNED TODAY ...

➜ Introducing new Types ➜ Equations and Term Rewriting

WE HAVE LEARNED TODAY ... 30-A

slide-121
SLIDE 121

WE HAVE LEARNED TODAY ...

➜ Introducing new Types ➜ Equations and Term Rewriting ➜ Confluence and Termination of reduction systems

WE HAVE LEARNED TODAY ... 30-B

slide-122
SLIDE 122

WE HAVE LEARNED TODAY ...

➜ Introducing new Types ➜ Equations and Term Rewriting ➜ Confluence and Termination of reduction systems ➜ Term Rewriting in Isabelle

WE HAVE LEARNED TODAY ... 30-C

slide-123
SLIDE 123

WE HAVE LEARNED TODAY ...

➜ Introducing new Types ➜ Equations and Term Rewriting ➜ Confluence and Termination of reduction systems ➜ Term Rewriting in Isabelle ➜ First structured proofs (Isar)

WE HAVE LEARNED TODAY ... 30-D

slide-124
SLIDE 124

EXERCISES

➜ use typedef to define a new type v with exactly one element. ➜ define a constant u of type v ➜ show that every element of v is equal to u ➜ design a set of rules that turns formulae with ∧, ∨, − →, ¬ into disjunctive normal form (= disjunction of conjunctions with negation only directly on variables) ➜ prove those rules in Isabelle ➜ use simp only with these rules on (¬B − → C) − → A − → B

EXERCISES 31