ProgTutorial/Advanced.thy
author Christian Urban <urbanc@in.tum.de>
Thu, 19 Nov 2009 20:23:15 +0100
changeset 397 6b423b39cc11
parent 396 a2e49e0771b3
child 400 7675427e311f
permissions -rw-r--r--
tuned
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
395
2c392f61f400 spilt the Essential's chapter
Christian Urban <urbanc@in.tum.de>
parents: 394
diff changeset
     1
theory Advanced
318
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
imports Base FirstSteps
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
346
0fea8b7a14a1 tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents: 345
diff changeset
     5
(*<*)
0fea8b7a14a1 tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents: 345
diff changeset
     6
setup{*
0fea8b7a14a1 tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents: 345
diff changeset
     7
open_file_with_prelude 
395
2c392f61f400 spilt the Essential's chapter
Christian Urban <urbanc@in.tum.de>
parents: 394
diff changeset
     8
  "Advanced_Code.thy"
346
0fea8b7a14a1 tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents: 345
diff changeset
     9
  ["theory General", "imports Base FirstSteps", "begin"]
0fea8b7a14a1 tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents: 345
diff changeset
    10
*}
0fea8b7a14a1 tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents: 345
diff changeset
    11
(*>*)
0fea8b7a14a1 tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents: 345
diff changeset
    12
0fea8b7a14a1 tuned the ML-output mechanism; tuned slightly the text
Christian Urban <urbanc@in.tum.de>
parents: 345
diff changeset
    13
395
2c392f61f400 spilt the Essential's chapter
Christian Urban <urbanc@in.tum.de>
parents: 394
diff changeset
    14
chapter {* Advanced Isabelle *}
381
97518188ef0e added more to the unification section
Christian Urban <urbanc@in.tum.de>
parents: 380
diff changeset
    15
97518188ef0e added more to the unification section
Christian Urban <urbanc@in.tum.de>
parents: 380
diff changeset
    16
text {*
395
2c392f61f400 spilt the Essential's chapter
Christian Urban <urbanc@in.tum.de>
parents: 394
diff changeset
    17
  TBD
318
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
*}
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
358
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    20
section {* Theories\label{sec:theories} (TBD) *}
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    21
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    22
text {*
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    23
  Theories are the most fundamental building blocks in Isabelle. They 
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    24
  contain definitions, syntax declarations, axioms, proofs etc. If a definition
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    25
  is stated, it must be stored in a theory in order to be usable later
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    26
  on. Similar with proofs: once a proof is finished, the proved theorem
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    27
  needs to be stored in the theorem database of the theory in order to
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    28
  be usable. All relevant data of a theort can be querried as follows.
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    29
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    30
  \begin{isabelle}
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    31
  \isacommand{print\_theory}\\
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    32
  @{text "> names: Pure Code_Generator HOL \<dots>"}\\
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    33
  @{text "> classes: Inf < type \<dots>"}\\
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    34
  @{text "> default sort: type"}\\
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    35
  @{text "> syntactic types: #prop \<dots>"}\\
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    36
  @{text "> logical types: 'a \<times> 'b \<dots>"}\\
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    37
  @{text "> type arities: * :: (random, random) random \<dots>"}\\
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    38
  @{text "> logical constants: == :: 'a \<Rightarrow> 'a \<Rightarrow> prop \<dots>"}\\
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    39
  @{text "> abbreviations: \<dots>"}\\
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    40
  @{text "> axioms: \<dots>"}\\
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    41
  @{text "> oracles: \<dots>"}\\
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    42
  @{text "> definitions: \<dots>"}\\
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    43
  @{text "> theorems: \<dots>"}
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    44
  \end{isabelle}
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    45
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    46
  \begin{center}
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    47
  \begin{tikzpicture}
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    48
  \node[top color=white, bottom color=gray!30, draw=black!100, drop shadow] {A};
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    49
  \end{tikzpicture}
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    50
  \end{center}
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    51
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    52
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    53
  In contrast to an ordinary theory, which simply consists of a type
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    54
  signature, as well as tables for constants, axioms and theorems, a local
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    55
  theory contains additional context information, such as locally fixed
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    56
  variables and local assumptions that may be used by the package. The type
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    57
  @{ML_type local_theory} is identical to the type of \emph{proof contexts}
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    58
  @{ML_type "Proof.context"}, although not every proof context constitutes a
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    59
  valid local theory.
361
Christian Urban <urbanc@in.tum.de>
parents: 360
diff changeset
    60
Christian Urban <urbanc@in.tum.de>
parents: 360
diff changeset
    61
  @{ML "Context.>> o Context.map_theory"}
392
47e5b71c7f6c modified the typ-pretty-printer and added parser exercise
Christian Urban <urbanc@in.tum.de>
parents: 389
diff changeset
    62
47e5b71c7f6c modified the typ-pretty-printer and added parser exercise
Christian Urban <urbanc@in.tum.de>
parents: 389
diff changeset
    63
  \footnote{\bf FIXME: list append in merge operations can cause 
47e5b71c7f6c modified the typ-pretty-printer and added parser exercise
Christian Urban <urbanc@in.tum.de>
parents: 389
diff changeset
    64
  exponential blowups.}
358
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    65
*}
9cf3bc448210 some polishing
Christian Urban <urbanc@in.tum.de>
parents: 356
diff changeset
    66
348
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    67
section {* Setups (TBD) *}
318
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
348
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    69
text {*
361
Christian Urban <urbanc@in.tum.de>
parents: 360
diff changeset
    70
  @{ML Sign.declare_const}
Christian Urban <urbanc@in.tum.de>
parents: 360
diff changeset
    71
348
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    72
  In the previous section we used \isacommand{setup} in order to make
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    73
  a theorem attribute known to Isabelle. What happens behind the scenes
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    74
  is that \isacommand{setup} expects a function of type 
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    75
  @{ML_type "theory -> theory"}: the input theory is the current theory and the 
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    76
  output the theory where the theory attribute has been stored.
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    77
  
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    78
  This is a fundamental principle in Isabelle. A similar situation occurs 
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    79
  for example with declaring constants. The function that declares a 
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    80
  constant on the ML-level is @{ML_ind  add_consts_i in Sign}. 
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    81
  If you write\footnote{Recall that ML-code  needs to be 
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    82
  enclosed in \isacommand{ML}~@{text "\<verbopen> \<dots> \<verbclose>"}.} 
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    83
*}  
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    84
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    85
ML{*Sign.add_consts_i [(@{binding "BAR"}, @{typ "nat"}, NoSyn)] @{theory} *}
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    86
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    87
text {*
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    88
  for declaring the constant @{text "BAR"} with type @{typ nat} and 
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    89
  run the code, then you indeed obtain a theory as result. But if you 
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    90
  query the constant on the Isabelle level using the command \isacommand{term}
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    91
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    92
  \begin{isabelle}
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    93
  \isacommand{term}~@{text [quotes] "BAR"}\\
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    94
  @{text "> \"BAR\" :: \"'a\""}
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    95
  \end{isabelle}
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    96
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    97
  you do not obtain a constant of type @{typ nat}, but a free variable (printed in 
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    98
  blue) of polymorphic type. The problem is that the ML-expression above did 
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
    99
  not register the declaration with the current theory. This is what the command
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   100
  \isacommand{setup} is for. The constant is properly declared with
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   101
*}
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   102
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   103
setup %gray {* Sign.add_consts_i [(@{binding "BAR"}, @{typ "nat"}, NoSyn)] *}
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   104
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   105
text {* 
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   106
  Now 
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   107
  
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   108
  \begin{isabelle}
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   109
  \isacommand{term}~@{text [quotes] "BAR"}\\
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   110
  @{text "> \"BAR\" :: \"nat\""}
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   111
  \end{isabelle}
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   112
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   113
  returns a (black) constant with the type @{typ nat}.
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   114
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   115
  A similar command is \isacommand{local\_setup}, which expects a function
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   116
  of type @{ML_type "local_theory -> local_theory"}. Later on we will also
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   117
  use the commands \isacommand{method\_setup} for installing methods in the
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   118
  current theory and \isacommand{simproc\_setup} for adding new simprocs to
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   119
  the current simpset.
Christian Urban <urbanc@in.tum.de>
parents: 347
diff changeset
   120
*}
318
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
341
62dea749d5ed more work on theorem section
Christian Urban <urbanc@in.tum.de>
parents: 340
diff changeset
   122
section {* Contexts (TBD) *}
62dea749d5ed more work on theorem section
Christian Urban <urbanc@in.tum.de>
parents: 340
diff changeset
   123
62dea749d5ed more work on theorem section
Christian Urban <urbanc@in.tum.de>
parents: 340
diff changeset
   124
section {* Local Theories (TBD) *}
62dea749d5ed more work on theorem section
Christian Urban <urbanc@in.tum.de>
parents: 340
diff changeset
   125
394
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   126
text {*
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   127
  @{ML_ind "Local_Theory.declaration"}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   128
*}
318
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
(*
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
setup {*
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
 Sign.add_consts_i [(Binding"bar", @{typ "nat"},NoSyn)] 
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
*}
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
lemma "bar = (1::nat)"
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
  oops
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
setup {*   
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
  Sign.add_consts_i [("foo", @{typ "nat"},NoSyn)] 
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
 #> PureThy.add_defs false [((@{binding "foo_def"}, 
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
       Logic.mk_equals (Const ("FirstSteps.foo", @{typ "nat"}), @{term "1::nat"})), [])] 
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
 #> snd
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
*}
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
*)
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
(*
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
lemma "foo = (1::nat)"
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
  apply(simp add: foo_def)
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
  done
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
thm foo_def
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
*)
336
a12bb28fe2bd polished on the pretty printing section
Christian Urban <urbanc@in.tum.de>
parents: 335
diff changeset
   151
394
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   152
section {* Morphisms (TBD) *}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   153
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   154
text {*
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   155
  Morphisms are arbitrary transformations over terms, types, theorems and bindings.
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   156
  They can be constructed using the function @{ML_ind morphism in Morphism},
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   157
  which expects a record with functions of type
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   158
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   159
  \begin{isabelle}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   160
  \begin{tabular}{rl}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   161
  @{text "binding:"} & @{text "binding -> binding"}\\
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   162
  @{text "typ:"}     & @{text "typ -> typ"}\\
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   163
  @{text "term:"}    & @{text "term -> term"}\\
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   164
  @{text "fact:"}    & @{text "thm list -> thm list"}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   165
  \end{tabular}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   166
  \end{isabelle}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   167
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   168
  The simplest morphism is the  @{ML_ind identity in Morphism}-morphism defined as
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   169
*}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   170
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   171
ML{*val identity = Morphism.morphism {binding = I, typ = I, term = I, fact = I}*}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   172
  
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   173
text {*
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   174
  Morphisms can be composed with the function @{ML_ind "$>" in Morphism}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   175
*}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   176
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   177
ML{*fun trm_phi (Free (x, T)) = Var ((x, 0), T) 
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   178
  | trm_phi (Abs (x, T, t)) = Abs (x, T, trm_phi t)
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   179
  | trm_phi (t $ s) = (trm_phi t) $ (trm_phi s)
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   180
  | trm_phi t = t*}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   181
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   182
ML{*val phi = Morphism.term_morphism trm_phi*}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   183
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   184
ML{*Morphism.term phi @{term "P x y"}*}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   185
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   186
text {*
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   187
  @{ML_ind term_morphism in Morphism}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   188
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   189
  @{ML_ind term in Morphism},
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   190
  @{ML_ind thm in Morphism}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   191
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   192
  \begin{readmore}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   193
  Morphisms are implemented in the file @{ML_file "Pure/morphism.ML"}.
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   194
  \end{readmore}
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   195
*}
318
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   196
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   197
section {* Misc (TBD) *}
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   198
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   199
ML {*Datatype.get_info @{theory} "List.list"*}
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   200
319
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   201
text {* 
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   202
FIXME: association lists:
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   203
@{ML_file "Pure/General/alist.ML"}
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   204
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   205
FIXME: calling the ML-compiler
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   206
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   207
*}
6bce4acf7f2a added file for producing a keyword file
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   208
335
163ac0662211 reorganised the certified terms section; tuned
Christian Urban <urbanc@in.tum.de>
parents: 329
diff changeset
   209
section {* Managing Name Spaces (TBD) *}
318
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   210
360
Christian Urban <urbanc@in.tum.de>
parents: 359
diff changeset
   211
ML {* Sign.intern_type @{theory} "list" *}
Christian Urban <urbanc@in.tum.de>
parents: 359
diff changeset
   212
ML {* Sign.intern_const @{theory} "prod_fun" *}
Christian Urban <urbanc@in.tum.de>
parents: 359
diff changeset
   213
387
5dcee4d751ad completed the unification section
Christian Urban <urbanc@in.tum.de>
parents: 386
diff changeset
   214
5dcee4d751ad completed the unification section
Christian Urban <urbanc@in.tum.de>
parents: 386
diff changeset
   215
text {* 
5dcee4d751ad completed the unification section
Christian Urban <urbanc@in.tum.de>
parents: 386
diff changeset
   216
  @{ML_ind "Binding.str_of"} returns the string with markup;
5dcee4d751ad completed the unification section
Christian Urban <urbanc@in.tum.de>
parents: 386
diff changeset
   217
  @{ML_ind "Binding.name_of"} returns the string without markup
394
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   218
0019ebf76e10 updated to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 393
diff changeset
   219
  @{ML_ind "Binding.conceal"} 
387
5dcee4d751ad completed the unification section
Christian Urban <urbanc@in.tum.de>
parents: 386
diff changeset
   220
*}
5dcee4d751ad completed the unification section
Christian Urban <urbanc@in.tum.de>
parents: 386
diff changeset
   221
388
0b337dedc306 added Skip_Proof.mk_thm and some pointers about concurrency
Christian Urban <urbanc@in.tum.de>
parents: 387
diff changeset
   222
section {* Concurrency (TBD) *}
0b337dedc306 added Skip_Proof.mk_thm and some pointers about concurrency
Christian Urban <urbanc@in.tum.de>
parents: 387
diff changeset
   223
0b337dedc306 added Skip_Proof.mk_thm and some pointers about concurrency
Christian Urban <urbanc@in.tum.de>
parents: 387
diff changeset
   224
text {*
0b337dedc306 added Skip_Proof.mk_thm and some pointers about concurrency
Christian Urban <urbanc@in.tum.de>
parents: 387
diff changeset
   225
  @{ML_ind prove_future in Goal}
0b337dedc306 added Skip_Proof.mk_thm and some pointers about concurrency
Christian Urban <urbanc@in.tum.de>
parents: 387
diff changeset
   226
  @{ML_ind future_result in Goal}
0b337dedc306 added Skip_Proof.mk_thm and some pointers about concurrency
Christian Urban <urbanc@in.tum.de>
parents: 387
diff changeset
   227
  @{ML_ind fork_pri in Future}
0b337dedc306 added Skip_Proof.mk_thm and some pointers about concurrency
Christian Urban <urbanc@in.tum.de>
parents: 387
diff changeset
   228
*}
387
5dcee4d751ad completed the unification section
Christian Urban <urbanc@in.tum.de>
parents: 386
diff changeset
   229
396
Christian Urban <urbanc@in.tum.de>
parents: 395
diff changeset
   230
section {* Parse and Print Translations (TBD) *}
Christian Urban <urbanc@in.tum.de>
parents: 395
diff changeset
   231
349
9e374cd891e1 updated to Isabelle changes
Christian Urban <urbanc@in.tum.de>
parents: 348
diff changeset
   232
section {* Summary *}
9e374cd891e1 updated to Isabelle changes
Christian Urban <urbanc@in.tum.de>
parents: 348
diff changeset
   233
9e374cd891e1 updated to Isabelle changes
Christian Urban <urbanc@in.tum.de>
parents: 348
diff changeset
   234
text {*
395
2c392f61f400 spilt the Essential's chapter
Christian Urban <urbanc@in.tum.de>
parents: 394
diff changeset
   235
  TBD
349
9e374cd891e1 updated to Isabelle changes
Christian Urban <urbanc@in.tum.de>
parents: 348
diff changeset
   236
*}
318
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   237
efb5fff99c96 split up the first-steps section into two chapters
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   238
end