src/Pure/Thy/README
author lcp
Thu, 08 Sep 1994 13:17:57 +0200
changeset 592 9154d8410514
child 4273 c9b577c8f7a1
permissions -rw-r--r--
documentation on theories
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
592
9154d8410514 documentation on theories
lcp
parents:
diff changeset
     1
    ID:         $Id$
9154d8410514 documentation on theories
lcp
parents:
diff changeset
     2
    Directory:  Pure/Thy
9154d8410514 documentation on theories
lcp
parents:
diff changeset
     3
    Author:     Carsten Clasohm
9154d8410514 documentation on theories
lcp
parents:
diff changeset
     4
    Copyright   1994 TU Muenchen
9154d8410514 documentation on theories
lcp
parents:
diff changeset
     5
9154d8410514 documentation on theories
lcp
parents:
diff changeset
     6
9154d8410514 documentation on theories
lcp
parents:
diff changeset
     7
Conventions for theory- and filenames:
9154d8410514 documentation on theories
lcp
parents:
diff changeset
     8
9154d8410514 documentation on theories
lcp
parents:
diff changeset
     9
- Files for theory T are named T.thy and T.ML where only one of these two
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    10
  must exist.
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    11
- Either T.thy or T.ML must define a ML structure containing an element
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    12
  named thy (the theory).
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    13
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    14
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    15
Information stored about loaded theories:
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    16
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    17
- name of the theory
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    18
- absolute path of the theory's files
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    19
- time of last modification for .thy and .ML file
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    20
  (updated when the files are read)
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    21
- names of all read theories that depend on the theory
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    22
- the theory as a ML object
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    23
- theorems
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    24
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    25
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    26
How to rebuild the theory hierarchy:
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    27
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    28
The database not only contains theories read from files but also the 
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    29
'mother of all theories' - Pure. By retrieving this theory's child list
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    30
(i.e. the names of all theories that are extensions of it) one can build the 
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    31
hierarchy by recursively repeating this procedure.
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    32
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    33
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    34
The datatype used:
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    35
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    36
Information is stored in the variable loaded_thys which has type
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    37
"thy_info Symtab.table ref", i.e. as an unbalanced binary tree with
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    38
the theory names as keys and entries of type thy_info:
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    39
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    40
datatype thy_info = ThyInfo of {path: string,
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    41
                                children: string list,
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    42
                                thy_time: string option,
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    43
                                ml_time: string option,
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    44
                                theory: theory option,
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    45
                                thms: thm Symtab.table};
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    46
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    47
path: absolute path of directory where the files where located when the theory
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    48
      was last read
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    49
children: names of all read theories that are descendants of this theory
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    50
thy_time: If T.thy existed this contains information about the file which
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    51
  looks like this: Some "-rw-r--r--  1 clasohm       232 Aug 19 11:10 ".
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    52
  Else it is 'None'.
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    53
ml_time: same for T.ML
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    54
theory: ML object containing the theory. As entries in loaded_thys are created
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    55
  before the theory has been read this may be 'None' in case of an error
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    56
  during use_thy "T".
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    57
thms: theorems
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    58
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    59
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    60
An entry may look like this:
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    61
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    62
   ("Fun",
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    63
      ThyInfo
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    64
         {path = "/disk1/usr/stud/clasohm/isabelle/HOL/./",
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    65
            thms = ?,
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    66
            theory = Some {Pure, HOL, Ord, Set},
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    67
            ml_time = Some "-rw-r--r--  1 clasohm      6076 Aug 30 10:04 ",
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    68
            children = ["Prod", "subset"],
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    69
            thy_time =
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    70
            Some "-rw-r--r--  1 clasohm       243 Aug 19 11:02 "})
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    71
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    72
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    73
Notes:
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    74
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    75
In general all theories contained in loaded_thys are linked with Pure.
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    76
Though stray theories are possible they are removed from loaded_thys 
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    77
automatically as soon as update(); is used.
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    78
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    79
Cycles in the hierarchy are not allowed and it is guaranteed that
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    80
loaded_thys doesn't contain one. On the other hand this is possible
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    81
(with all lines representing downward arrows):
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    82
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    83
     A
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    84
    / \
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    85
   B   C
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    86
   |   |
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    87
   \   D
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    88
    \ /
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    89
     E
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    90
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    91
Isabelle first searches for theory files in the directory stored in
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    92
thy_info's path component. But in case they have been moved meanwhile
9154d8410514 documentation on theories
lcp
parents:
diff changeset
    93
the variable load_path (string list ref) is used to find them.