CookBook/Recipes/NamedThms.thy
author Christian Urban <urbanc@in.tum.de>
Wed, 01 Oct 2008 20:09:45 -0400
changeset 13 2b07da8b310d
parent 12 CookBook/NamedThms.thy@2f1736cb8f26
child 14 1c17e99f6f66
permissions -rw-r--r--
polished and added a subdirectory for the recipes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
theory NamedThms
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
imports Main
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
begin
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
2
978a3c2ed7ce split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents: 0
diff changeset
     6
13
2b07da8b310d polished and added a subdirectory for the recipes
Christian Urban <urbanc@in.tum.de>
parents: 12
diff changeset
     7
section {* Accumulate a List of Theorems under a Name *} 
2
978a3c2ed7ce split the document into smaller pieces;
Christian Urban <urbanc@in.tum.de>
parents: 0
diff changeset
     8
0
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
text {*
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
  \paragraph{Problem:} Your tool @{text foo} works with special rules, called @{text foo}-rules.
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
  Users should be able to declare @{text foo}-rules in the theory,
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
  which are then used by some method.
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
  \paragraph{Solution:}
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
  *}
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
ML {*
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
  structure FooRules = NamedThmsFun(
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
    val name = "foo" 
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
    val description = "Rules for foo"
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
  );
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
*}
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
setup FooRules.setup
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
text {*
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  This declares a context data slot where the theorems are stored,
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
  an attribute @{attribute foo} (with the usual @{text add} and @{text del} options
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
  to declare new rules, and the internal ML interface to retrieve and 
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
  modify the facts.
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
  Furthermore, the facts are made available under the dynamic fact name
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
  @{text foo}:
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
*}
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
lemma rule1[foo]: "A" sorry
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
lemma rule2[foo]: "B" sorry
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
declare rule1[foo del]
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
thm foo
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
ML {* 
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
  FooRules.get @{context};
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
*}
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
text {* 
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
  \begin{readmore}
12
2f1736cb8f26 various changes by Alex and Christian
Christian Urban <urbanc@in.tum.de>
parents: 2
diff changeset
    52
  For more information see @{ML_file "Pure/Tools/named_thms.ML"}.
0
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
  \end{readmore}
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
 *}
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
end
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
  
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
02503850a8cf initial commit of Alexander's files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61