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

locales
SMART_READER_LITE
LIVE PREVIEW

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

NICTA Advanced Course Theorem Proving Principles, Techniques, Applications locales 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

locales

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
  • More recursion, Calculational reasoning
  • Hoare logic, proofs about programs
  • Locales, Presentation

CONTENT 2

slide-3
SLIDE 3

LAST TIME

➜ Syntax and semantics of IMP ➜ Hoare logic rules ➜ Soundness of Hoare logic ➜ Verification conditions ➜ Example program proofs

LAST TIME 3

slide-4
SLIDE 4

ISAR IS BASED ON CONTEXTS

theorem x. A = ⇒ C proof - fix x assume Ass: A . . . from Ass show C . . . qed

ISAR IS BASED ON CONTEXTS 4

slide-5
SLIDE 5

ISAR IS BASED ON CONTEXTS

theorem x. A = ⇒ C proof - fix x assume Ass: A . . . x and Ass are visible from Ass show C . . . inside this context qed

ISAR IS BASED ON CONTEXTS 4-A

slide-6
SLIDE 6

BEYOND ISAR CONTEXTS

Locales are extended contexts

BEYOND ISAR CONTEXTS 5

slide-7
SLIDE 7

BEYOND ISAR CONTEXTS

Locales are extended contexts

➜ Locales are named

BEYOND ISAR CONTEXTS 5-A

slide-8
SLIDE 8

BEYOND ISAR CONTEXTS

Locales are extended contexts

➜ Locales are named ➜ Fixed variables may have syntax

BEYOND ISAR CONTEXTS 5-B

slide-9
SLIDE 9

BEYOND ISAR CONTEXTS

Locales are extended contexts

➜ Locales are named ➜ Fixed variables may have syntax ➜ It is possible to add and export theorems

BEYOND ISAR CONTEXTS 5-C

slide-10
SLIDE 10

BEYOND ISAR CONTEXTS

Locales are extended contexts

➜ Locales are named ➜ Fixed variables may have syntax ➜ It is possible to add and export theorems ➜ Locale expression: combine and modify locales

BEYOND ISAR CONTEXTS 5-D

slide-11
SLIDE 11

CONTEXT ELEMENTS

Locales consist of context elements.

CONTEXT ELEMENTS 6

slide-12
SLIDE 12

CONTEXT ELEMENTS

Locales consist of context elements. fixes Parameter, with syntax

CONTEXT ELEMENTS 6-A

slide-13
SLIDE 13

CONTEXT ELEMENTS

Locales consist of context elements. fixes Parameter, with syntax assumes Assumption

CONTEXT ELEMENTS 6-B

slide-14
SLIDE 14

CONTEXT ELEMENTS

Locales consist of context elements. fixes Parameter, with syntax assumes Assumption defines Definition

CONTEXT ELEMENTS 6-C

slide-15
SLIDE 15

CONTEXT ELEMENTS

Locales consist of context elements. fixes Parameter, with syntax assumes Assumption defines Definition notes Record a theorem

CONTEXT ELEMENTS 6-D

slide-16
SLIDE 16

CONTEXT ELEMENTS

Locales consist of context elements. fixes Parameter, with syntax assumes Assumption defines Definition notes Record a theorem includes Import other locales (locale expressions)

CONTEXT ELEMENTS 6-E

slide-17
SLIDE 17

DECLARING LOCALES

Declaring locale (named context) loc: locale loc =

DECLARING LOCALES 7

slide-18
SLIDE 18

DECLARING LOCALES

Declaring locale (named context) loc: locale loc = loc1 + Import

DECLARING LOCALES 7-A

slide-19
SLIDE 19

DECLARING LOCALES

Declaring locale (named context) loc: locale loc = loc1 + Import fixes . . . Context elements assumes . . .

DECLARING LOCALES 7-B

slide-20
SLIDE 20

DECLARING LOCALES

Theorems may be stated relative to a named locale. lemma (in loc) P [simp]: proposition proof

DECLARING LOCALES 8

slide-21
SLIDE 21

DECLARING LOCALES

Theorems may be stated relative to a named locale. lemma (in loc) P [simp]: proposition proof

➜ Adds theorem P to context loc.

DECLARING LOCALES 8-A

slide-22
SLIDE 22

DECLARING LOCALES

Theorems may be stated relative to a named locale. lemma (in loc) P [simp]: proposition proof

➜ Adds theorem P to context loc. ➜ Theorem P is in the simpset in context loc.

DECLARING LOCALES 8-B

slide-23
SLIDE 23

DECLARING LOCALES

Theorems may be stated relative to a named locale. lemma (in loc) P [simp]: proposition proof

➜ Adds theorem P to context loc. ➜ Theorem P is in the simpset in context loc. ➜ Exported theorem loc.P visible in the entire theory.

DECLARING LOCALES 8-C

slide-24
SLIDE 24

DEMO: LOCALES 1

9

slide-25
SLIDE 25

PARAMETERS MUST BE CONSISTENT!

➜ Parameters in fixes are distinct.

PARAMETERS MUST BE CONSISTENT! 10

slide-26
SLIDE 26

PARAMETERS MUST BE CONSISTENT!

➜ Parameters in fixes are distinct. ➜ Free variables in assumes and defines occur in preceding fixes.

PARAMETERS MUST BE CONSISTENT! 10-A

slide-27
SLIDE 27

PARAMETERS MUST BE CONSISTENT!

➜ Parameters in fixes are distinct. ➜ Free variables in assumes and defines occur in preceding fixes. ➜ Defined parameters cannot occur in preceding assumes nor defines.

PARAMETERS MUST BE CONSISTENT! 10-B

slide-28
SLIDE 28

LOCALE EXPRESSIONS

Locale name: n

LOCALE EXPRESSIONS 11

slide-29
SLIDE 29

LOCALE EXPRESSIONS

Locale name: n Rename: e q1 . . . qn Change names of parameters in e.

LOCALE EXPRESSIONS 11-A

slide-30
SLIDE 30

LOCALE EXPRESSIONS

Locale name: n Rename: e q1 . . . qn Change names of parameters in e. Merge: e1 + e2 Context elements of e1, then e2.

LOCALE EXPRESSIONS 11-B

slide-31
SLIDE 31

LOCALE EXPRESSIONS

Locale name: n Rename: e q1 . . . qn Change names of parameters in e. Merge: e1 + e2 Context elements of e1, then e2.

➜ Syntax is lost after rename (currently).

LOCALE EXPRESSIONS 11-C

slide-32
SLIDE 32

DEMO: LOCALES 2

12

slide-33
SLIDE 33

NORMAL FORM OF LOCALE EXPRESSIONS

Locale expressions are converted to flattened lists of locale names.

NORMAL FORM OF LOCALE EXPRESSIONS 13

slide-34
SLIDE 34

NORMAL FORM OF LOCALE EXPRESSIONS

Locale expressions are converted to flattened lists of locale names.

➜ With full parameter lists

NORMAL FORM OF LOCALE EXPRESSIONS 13-A

slide-35
SLIDE 35

NORMAL FORM OF LOCALE EXPRESSIONS

Locale expressions are converted to flattened lists of locale names.

➜ With full parameter lists ➜ Duplicates removed

NORMAL FORM OF LOCALE EXPRESSIONS 13-B

slide-36
SLIDE 36

NORMAL FORM OF LOCALE EXPRESSIONS

Locale expressions are converted to flattened lists of locale names.

➜ With full parameter lists ➜ Duplicates removed

Allows for multiple inheritance!

NORMAL FORM OF LOCALE EXPRESSIONS 13-C

slide-37
SLIDE 37

INSTANTIATION

Move from abstract to concrete.

INSTANTIATION 14

slide-38
SLIDE 38

INSTANTIATION

Move from abstract to concrete. instantiate label: loc

INSTANTIATION 14-A

slide-39
SLIDE 39

INSTANTIATION

Move from abstract to concrete. instantiate label: loc

➜ From chained fact loc t1 . . . tn instantiate locale loc.

INSTANTIATION 14-B

slide-40
SLIDE 40

INSTANTIATION

Move from abstract to concrete. instantiate label: loc

➜ From chained fact loc t1 . . . tn instantiate locale loc. ➜ Imports all theorems of loc into current context.

INSTANTIATION 14-C

slide-41
SLIDE 41

INSTANTIATION

Move from abstract to concrete. instantiate label: loc

➜ From chained fact loc t1 . . . tn instantiate locale loc. ➜ Imports all theorems of loc into current context.

  • Instantiates the parameters with t1 . . . tn.
  • Interprets attributes of theorems.
  • Prefixes theorem names with label

INSTANTIATION 14-D

slide-42
SLIDE 42

INSTANTIATION

Move from abstract to concrete. instantiate label: loc

➜ From chained fact loc t1 . . . tn instantiate locale loc. ➜ Imports all theorems of loc into current context.

  • Instantiates the parameters with t1 . . . tn.
  • Interprets attributes of theorems.
  • Prefixes theorem names with label

➜ Currently only works inside Isar contexts.

INSTANTIATION 14-E

slide-43
SLIDE 43

DEMO: LOCALES 3

15

slide-44
SLIDE 44

PRESENTATION

16

slide-45
SLIDE 45

ISABELLE’S BATCH MODE

➜ used to process and check larger number of theories

ISABELLE’S BATCH MODE 17

slide-46
SLIDE 46

ISABELLE’S BATCH MODE

➜ used to process and check larger number of theories ➜ no interactive niceties (no sorry, no quick and dirty)

ISABELLE’S BATCH MODE 17-A

slide-47
SLIDE 47

ISABELLE’S BATCH MODE

➜ used to process and check larger number of theories ➜ no interactive niceties (no sorry, no quick and dirty) ➜ controlled by file ROOT.ML and script set isatool

ISABELLE’S BATCH MODE 17-B

slide-48
SLIDE 48

ISABELLE’S BATCH MODE

➜ used to process and check larger number of theories ➜ no interactive niceties (no sorry, no quick and dirty) ➜ controlled by file ROOT.ML and script set isatool ➜ can save state for later use (images)

ISABELLE’S BATCH MODE 17-C

slide-49
SLIDE 49

ISABELLE’S BATCH MODE

➜ used to process and check larger number of theories ➜ no interactive niceties (no sorry, no quick and dirty) ➜ controlled by file ROOT.ML and script set isatool ➜ can save state for later use (images) ➜ can generate HTML and L

AT

EX documentation

ISABELLE’S BATCH MODE 17-D

slide-50
SLIDE 50

ISATOOL

isatool <tool> <options>

ISATOOL 18

slide-51
SLIDE 51

ISATOOL

isatool <tool> <options> Get help with: isatool shows available tools isatool <tool> -? shows options for <tool>

ISATOOL 18-A

slide-52
SLIDE 52

ISATOOL

isatool <tool> <options> Get help with: isatool shows available tools isatool <tool> -? shows options for <tool> Interesting tools: isatool mkdir create session directory make/makeall run make for directory/all logics usedir batch session (documents, HTML, session graph) document/latex run L

AT

EX for generated sources

ISATOOL 18-B

slide-53
SLIDE 53

GENERATING L

ATEX FROM ISABELLE

<..>/isatool usedir -d pdf HOL <session> <..>/<session>/ROOT.ML <..>/<session>/MyTheory.thy <..>/<session>/document/root.tex

GENERATING L

ATEX FROM ISABELLE

19

slide-54
SLIDE 54

GENERATING L

ATEX FROM ISABELLE

<..>/isatool usedir -d pdf HOL <session> <..>/<session>/ROOT.ML <..>/<session>/MyTheory.thy <..>/<session>/document/root.tex

➜ In ROOT.ML: no\_document use_thy "MyLibrary"; use_thy "MyTheory";

GENERATING L

ATEX FROM ISABELLE

19-A

slide-55
SLIDE 55

GENERATING L

ATEX FROM ISABELLE

<..>/isatool usedir -d pdf HOL <session> <..>/<session>/ROOT.ML <..>/<session>/MyTheory.thy <..>/<session>/document/root.tex

➜ In ROOT.ML: no\_document use_thy "MyLibrary"; use_thy "MyTheory"; ➜ In document/root.tex:

  • include Isabelle style packages (isabelle.sty, isabellesym.sty)
  • include generated files

session.tex (for all theories) or MyTheory.tex

GENERATING L

ATEX FROM ISABELLE

19-B

slide-56
SLIDE 56

DEMO: EXAMPLE

20

slide-57
SLIDE 57

LARGE DEVELOPMENTS

Creating Images: <..>/<session>/isatool usedir -b HOL <session> <..>/<session>/ROOT.ML <..>/<session>/MyLibrary.thy

LARGE DEVELOPMENTS 21

slide-58
SLIDE 58

LARGE DEVELOPMENTS

Creating Images: <..>/<session>/isatool usedir -b HOL <session> <..>/<session>/ROOT.ML <..>/<session>/MyLibrary.thy

➜ Processes ROOT.ML

LARGE DEVELOPMENTS 21-A

slide-59
SLIDE 59

LARGE DEVELOPMENTS

Creating Images: <..>/<session>/isatool usedir -b HOL <session> <..>/<session>/ROOT.ML <..>/<session>/MyLibrary.thy

➜ Processes ROOT.ML ➜ Saves state after processing in ˜/isabelle/heaps/<ML-system>/HOL-<session>

LARGE DEVELOPMENTS 21-B

slide-60
SLIDE 60

LARGE DEVELOPMENTS

Creating Images: <..>/<session>/isatool usedir -b HOL <session> <..>/<session>/ROOT.ML <..>/<session>/MyLibrary.thy

➜ Processes ROOT.ML ➜ Saves state after processing in ˜/isabelle/heaps/<ML-system>/HOL-<session> ➜ Makes HOL-<session> available as logic in menu Isabelle→Logics

LARGE DEVELOPMENTS 21-C

slide-61
SLIDE 61

LARGE DEVELOPMENTS

Creating Images: <..>/<session>/isatool usedir -b HOL <session> <..>/<session>/ROOT.ML <..>/<session>/MyLibrary.thy

➜ Processes ROOT.ML ➜ Saves state after processing in ˜/isabelle/heaps/<ML-system>/HOL-<session> ➜ Makes HOL-<session> available as logic in menu Isabelle→Logics ➜ Direct start of Isabelle with new logic: Isabelle -l HOL-<session>

LARGE DEVELOPMENTS 21-D

slide-62
SLIDE 62

MARKUP COMMANDS

➜ document structure commands:

MARKUP COMMANDS 22

slide-63
SLIDE 63

MARKUP COMMANDS

➜ document structure commands: header section subsection subsubsection (meaning defined in isabelle.sty)

MARKUP COMMANDS 22-A

slide-64
SLIDE 64

MARKUP COMMANDS

➜ document structure commands: header section subsection subsubsection (meaning defined in isabelle.sty) ➜ normal text text {∗ . . . ∗} text raw {∗ . . . ∗}

MARKUP COMMANDS 22-B

slide-65
SLIDE 65

MARKUP COMMANDS

➜ document structure commands: header section subsection subsubsection (meaning defined in isabelle.sty) ➜ normal text text {∗ . . . ∗} text raw {∗ . . . ∗} ➜ text inside proofs txt {∗ . . . ∗} txt raw {∗ . . . ∗}

MARKUP COMMANDS 22-C

slide-66
SLIDE 66

MARKUP COMMANDS

➜ document structure commands: header section subsection subsubsection (meaning defined in isabelle.sty) ➜ normal text text {∗ . . . ∗} text raw {∗ . . . ∗} ➜ text inside proofs txt {∗ . . . ∗} txt raw {∗ . . . ∗} ➜ formal comments

  • - {∗ . . . ∗}

MARKUP COMMANDS 22-D

slide-67
SLIDE 67

MARKUP COMMANDS

➜ document structure commands: header section subsection subsubsection (meaning defined in isabelle.sty) ➜ normal text text {∗ . . . ∗} text raw {∗ . . . ∗} ➜ text inside proofs txt {∗ . . . ∗} txt raw {∗ . . . ∗} ➜ formal comments

  • - {∗ . . . ∗}

➜ make text invisible: (∗ < ∗) . . . (∗ > ∗)

MARKUP COMMANDS 22-E

slide-68
SLIDE 68

ANTIQUOTATIONS

Inside L

AT

EX you can go back to Isabelle commands and syntax. Useful Antiquotations:

ANTIQUOTATIONS 23

slide-69
SLIDE 69

ANTIQUOTATIONS

Inside L

AT

EX you can go back to Isabelle commands and syntax. Useful Antiquotations: @{typ τ} print type τ

ANTIQUOTATIONS 23-A

slide-70
SLIDE 70

ANTIQUOTATIONS

Inside L

AT

EX you can go back to Isabelle commands and syntax. Useful Antiquotations: @{typ τ} print type τ @{term t} print term t

ANTIQUOTATIONS 23-B

slide-71
SLIDE 71

ANTIQUOTATIONS

Inside L

AT

EX you can go back to Isabelle commands and syntax. Useful Antiquotations: @{typ τ} print type τ @{term t} print term t @{prop φ} print proposition φ @{prop [display] φ} print proposition φ with linebreaks @{prop [source] φ} check proposition φ, print its input

ANTIQUOTATIONS 23-C

slide-72
SLIDE 72

ANTIQUOTATIONS

Inside L

AT

EX you can go back to Isabelle commands and syntax. Useful Antiquotations: @{typ τ} print type τ @{term t} print term t @{prop φ} print proposition φ @{prop [display] φ} print proposition φ with linebreaks @{prop [source] φ} check proposition φ, print its input @{thm a} print fact a @{thm a [no vars]} print fact a, fixing schematic variables @{thm [source] a} check availability of a, print its name

ANTIQUOTATIONS 23-D

slide-73
SLIDE 73

ANTIQUOTATIONS

Inside L

AT

EX you can go back to Isabelle commands and syntax. Useful Antiquotations: @{typ τ} print type τ @{term t} print term t @{prop φ} print proposition φ @{prop [display] φ} print proposition φ with linebreaks @{prop [source] φ} check proposition φ, print its input @{thm a} print fact a @{thm a [no vars]} print fact a, fixing schematic variables @{thm [source] a} check availability of a, print its name @{text s} print uninterpreted text s

ANTIQUOTATIONS 23-E

slide-74
SLIDE 74

WRITING ABOUT ISABELLE THEORIES

To document definitions and proofs:

➜ put comments explanations directly in original theory ➜ keep explanations short and to the point ➜ formal definitions, lemmas, syntax should speak for themself

WRITING ABOUT ISABELLE THEORIES 24

slide-75
SLIDE 75

WRITING ABOUT ISABELLE THEORIES

To document definitions and proofs:

➜ put comments explanations directly in original theory ➜ keep explanations short and to the point ➜ formal definitions, lemmas, syntax should speak for themself

To write a paper/thesis about a formal development

➜ use a separate theory/document on top of the development

WRITING ABOUT ISABELLE THEORIES 24-A

slide-76
SLIDE 76

WRITING ABOUT ISABELLE THEORIES

To document definitions and proofs:

➜ put comments explanations directly in original theory ➜ keep explanations short and to the point ➜ formal definitions, lemmas, syntax should speak for themself

To write a paper/thesis about a formal development

➜ use a separate theory/document on top of the development ➜ only talk about the interesting parts

WRITING ABOUT ISABELLE THEORIES 24-B

slide-77
SLIDE 77

WRITING ABOUT ISABELLE THEORIES

To document definitions and proofs:

➜ put comments explanations directly in original theory ➜ keep explanations short and to the point ➜ formal definitions, lemmas, syntax should speak for themself

To write a paper/thesis about a formal development

➜ use a separate theory/document on top of the development ➜ only talk about the interesting parts ➜ use antiquoations for theorems and definitions

WRITING ABOUT ISABELLE THEORIES 24-C

slide-78
SLIDE 78

WRITING ABOUT ISABELLE THEORIES

To document definitions and proofs:

➜ put comments explanations directly in original theory ➜ keep explanations short and to the point ➜ formal definitions, lemmas, syntax should speak for themself

To write a paper/thesis about a formal development

➜ use a separate theory/document on top of the development ➜ only talk about the interesting parts ➜ use antiquoations for theorems and definitions ➜ use extra locales, definitions, syntax for polish

WRITING ABOUT ISABELLE THEORIES 24-D

slide-79
SLIDE 79

WRITING ABOUT ISABELLE THEORIES

To document definitions and proofs:

➜ put comments explanations directly in original theory ➜ keep explanations short and to the point ➜ formal definitions, lemmas, syntax should speak for themself

To write a paper/thesis about a formal development

➜ use a separate theory/document on top of the development ➜ only talk about the interesting parts ➜ use antiquoations for theorems and definitions ➜ use extra locales, definitions, syntax for polish ➜ make full proof document available separately

WRITING ABOUT ISABELLE THEORIES 24-E

slide-80
SLIDE 80

POLISH

Know your audience. Use the right notation.

POLISH 25

slide-81
SLIDE 81

POLISH

Know your audience. Use the right notation.

➜ Change L

AT

EX symbol interpretations \renewcommand{\isasymLongrightarrow} {\isamath{\longrightarrow}}

POLISH 25-A

slide-82
SLIDE 82

POLISH

Know your audience. Use the right notation.

➜ Change L

AT

EX symbol interpretations \renewcommand{\isasymLongrightarrow} {\isamath{\longrightarrow}} ➜ Declare special L

AT

EX output syntax: syntax (latex) Cons :: ”’a ⇒ ’a list ⇒ ’a list” (” ·/ ” [66,65] 65)

POLISH 25-B

slide-83
SLIDE 83

POLISH

Know your audience. Use the right notation.

➜ Change L

AT

EX symbol interpretations \renewcommand{\isasymLongrightarrow} {\isamath{\longrightarrow}} ➜ Declare special L

AT

EX output syntax: syntax (latex) Cons :: ”’a ⇒ ’a list ⇒ ’a list” (” ·/ ” [66,65] 65) ➜ Use translations to change output syntax: syntax (latex) notEx :: ”(’a ⇒ bool) ⇒ bool” (binder ”\<notex>” 10) translations ”\<notex>x. P” <= ”¬(∃x. P)” in document/root.tex: \newcommand{\isasymnotex}{\isamath{\neg\exists}}

POLISH 25-C

slide-84
SLIDE 84

USING LOCALES

making large developments more accessible

USING LOCALES 26

slide-85
SLIDE 85

USING LOCALES

making large developments more accessible Math textbook: Let (A, ·, 0) in the following be a group with x · y = y · x

USING LOCALES 26-A

slide-86
SLIDE 86

USING LOCALES

making large developments more accessible Math textbook: Let (A, ·, 0) in the following be a group with x · y = y · x Isabelle:

➜ Use locales to formalize contexts

USING LOCALES 26-B

slide-87
SLIDE 87

USING LOCALES

making large developments more accessible Math textbook: Let (A, ·, 0) in the following be a group with x · y = y · x Isabelle:

➜ Use locales to formalize contexts ➜ Antiquotations are sensitive to current locale context

USING LOCALES 26-C

slide-88
SLIDE 88

USING LOCALES

making large developments more accessible Math textbook: Let (A, ·, 0) in the following be a group with x · y = y · x Isabelle:

➜ Use locales to formalize contexts ➜ Antiquotations are sensitive to current locale context ➜ Example: locale agroup = group + assumes com: ”x · y = y · x” . . . (∗ < ∗) lemma (in agroup) True (∗ > ∗) txt {∗ . . . ∗} (∗ < ∗) oops (∗ > ∗)

USING LOCALES 26-D

slide-89
SLIDE 89

DEMO

27

slide-90
SLIDE 90

WE HAVE SEEN TODAY ...

➜ Locale Declarations + Theorems in Locales ➜ Locale Expressions + Inheritance ➜ Locale Instantiation ➜ Generating L

AT

EX ➜ Writing a thesis/paper in Isabelle

WE HAVE SEEN TODAY ... 28

slide-91
SLIDE 91

EXERCISES

➜ No Exercise Today

EXERCISES 29

slide-92
SLIDE 92

EXERCISES

➜ No Exercise Today

Theorem Proving Principles, Techniques, Applications

The End

EXERCISES 29-A