src/HOL/Import/hol4rews.ML
author wenzelm
Wed, 04 Apr 2007 00:11:03 +0200
changeset 22578 b0eb5652f210
parent 21858 05f57309170c
child 22846 fb79144af9a3
permissions -rw-r--r--
removed obsolete sign_of/sign_of_thm;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14620
1be590fd2422 Minor cleanup of headers and some speedup of the HOL4 import.
skalberg
parents: 14518
diff changeset
     1
(*  Title:      HOL/Import/hol4rews.ML
1be590fd2422 Minor cleanup of headers and some speedup of the HOL4 import.
skalberg
parents: 14518
diff changeset
     2
    ID:         $Id$
1be590fd2422 Minor cleanup of headers and some speedup of the HOL4 import.
skalberg
parents: 14518
diff changeset
     3
    Author:     Sebastian Skalberg (TU Muenchen)
1be590fd2422 Minor cleanup of headers and some speedup of the HOL4 import.
skalberg
parents: 14518
diff changeset
     4
*)
1be590fd2422 Minor cleanup of headers and some speedup of the HOL4 import.
skalberg
parents: 14518
diff changeset
     5
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
     6
structure StringPair = TableFun(type key = string * string val ord = prod_ord string_ord string_ord);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
     7
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
     8
type holthm = (term * term) list * thm
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
     9
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    10
datatype ImportStatus =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    11
	 NoImport
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    12
       | Generating of string
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    13
       | Replaying of string
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    14
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    15
structure HOL4DefThyArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    16
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    17
val name = "HOL4/import_status"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    18
type T = ImportStatus
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    19
val empty = NoImport
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    20
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    21
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    22
fun merge _ (NoImport,NoImport) = NoImport
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    23
  | merge _ _ = (warning "Import status set during merge"; NoImport)
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
    24
fun print _ import_status =
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    25
    Pretty.writeln (Pretty.str (case import_status of NoImport => "No current import" | Generating thyname => ("Generating " ^ thyname) | Replaying thyname => ("Replaying " ^ thyname)))
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    26
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    27
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    28
structure HOL4DefThy = TheoryDataFun(HOL4DefThyArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    29
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    30
structure ImportSegmentArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    31
struct
14620
1be590fd2422 Minor cleanup of headers and some speedup of the HOL4 import.
skalberg
parents: 14518
diff changeset
    32
val name = "HOL4/import_segment"
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    33
type T = string
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    34
val empty = ""
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    35
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    36
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    37
fun merge _ ("",arg) = arg
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    38
  | merge _ (arg,"") = arg
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    39
  | merge _ (s1,s2) =
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    40
    if s1 = s2
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    41
    then s1
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    42
    else error "Trying to merge two different import segments"
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
    43
fun print _ import_segment =
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    44
    Pretty.writeln (Pretty.str ("Import segment: " ^ import_segment))
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    45
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    46
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    47
structure ImportSegment = TheoryDataFun(ImportSegmentArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    48
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    49
val get_import_segment = ImportSegment.get
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    50
val set_import_segment = ImportSegment.put
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    51
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    52
structure HOL4UNamesArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    53
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    54
val name = "HOL4/used_names"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    55
type T = string list
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    56
val empty = []
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    57
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    58
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    59
fun merge _ ([],[]) = []
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    60
  | merge _ _ = error "Used names not empty during merge"
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
    61
fun print _ used_names =
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    62
    Pretty.writeln (Pretty.str "Printing of HOL4/used_names Not implemented")
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    63
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    64
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    65
structure HOL4UNames = TheoryDataFun(HOL4UNamesArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    66
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    67
structure HOL4DumpArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    68
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    69
val name = "HOL4/dump_data"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    70
type T = string * string * string list
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    71
val empty = ("","",[])
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    72
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    73
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    74
fun merge _ (("","",[]),("","",[])) = ("","",[])
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    75
  | merge _ _ = error "Dump data not empty during merge"
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
    76
fun print _ dump_data =
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    77
    Pretty.writeln (Pretty.str "Printing of HOL4/dump_data Not implemented")
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    78
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    79
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    80
structure HOL4Dump = TheoryDataFun(HOL4DumpArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    81
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    82
structure HOL4MovesArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    83
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    84
val name = "HOL4/moves"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    85
type T = string Symtab.table
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    86
val empty = Symtab.empty
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    87
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    88
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
    89
fun merge _ : T * T -> T = Symtab.merge (K true)
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
    90
fun print _ tab =
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
    91
  Pretty.writeln (Pretty.big_list "HOL4 moves:"
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
    92
    (Symtab.fold (fn (bef, aft) => fn xl => (Pretty.str (bef ^ " --> " ^ aft) :: xl)) tab []))
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    93
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    94
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    95
structure HOL4Moves = TheoryDataFun(HOL4MovesArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    96
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    97
structure HOL4ImportsArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    98
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
    99
val name = "HOL4/imports"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   100
type T = string Symtab.table
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   101
val empty = Symtab.empty
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   102
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   103
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   104
fun merge _ : T * T -> T = Symtab.merge (K true)
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   105
fun print _ tab =
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   106
  Pretty.writeln (Pretty.big_list "HOL4 imports:"
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   107
    (Symtab.fold (fn (thyname, segname) => fn xl => (Pretty.str (thyname ^ " imported from segment " ^ segname) :: xl)) tab []))
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   108
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   109
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   110
structure HOL4Imports = TheoryDataFun(HOL4ImportsArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   111
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   112
fun get_segment2 thyname thy =
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   113
  Symtab.lookup (HOL4Imports.get thy) thyname
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   114
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   115
fun set_segment thyname segname thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   116
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   117
	val imps = HOL4Imports.get thy
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   118
	val imps' = Symtab.update_new (thyname,segname) imps
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   119
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   120
	HOL4Imports.put imps' thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   121
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   122
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   123
structure HOL4CMovesArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   124
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   125
val name = "HOL4/constant_moves"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   126
type T = string Symtab.table
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   127
val empty = Symtab.empty
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   128
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   129
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   130
fun merge _ : T * T -> T = Symtab.merge (K true)
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   131
fun print _ tab =
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   132
  Pretty.writeln (Pretty.big_list "HOL4 constant moves:"
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   133
    (Symtab.fold (fn (bef, aft) => fn xl => (Pretty.str (bef ^ " --> " ^ aft) :: xl)) tab []))
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   134
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   135
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   136
structure HOL4CMoves = TheoryDataFun(HOL4CMovesArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   137
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   138
structure HOL4MapsArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   139
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   140
val name = "HOL4/mappings"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   141
type T = (string option) StringPair.table
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   142
val empty = StringPair.empty
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   143
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   144
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   145
fun merge _ : T * T -> T = StringPair.merge (K true)
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   146
fun print _ tab =
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   147
  Pretty.writeln (Pretty.big_list "HOL4 mappings:"
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   148
    (StringPair.fold (fn ((bthy, bthm), isathm) => fn xl =>
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   149
      (Pretty.str (bthy ^ "." ^ bthm ^ (case isathm of SOME th => " --> " ^ th | NONE => "IGNORED")) :: xl)) tab []))
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   150
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   151
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   152
structure HOL4Maps = TheoryDataFun(HOL4MapsArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   153
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   154
structure HOL4ThmsArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   155
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   156
val name = "HOL4/theorems"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   157
type T = holthm StringPair.table
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   158
val empty = StringPair.empty
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   159
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   160
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   161
fun merge _ : T * T -> T = StringPair.merge (K true)
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   162
fun print _ tab =
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   163
  Pretty.writeln (Pretty.big_list "HOL4 mappings:"
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   164
    (StringPair.fold (fn ((bthy, bthm), (_, thm)) => fn xl => (Pretty.str (bthy ^ "." ^ bthm ^ ":") :: Display.pretty_thm thm :: xl)) tab []))
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   165
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   166
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   167
structure HOL4Thms = TheoryDataFun(HOL4ThmsArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   168
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   169
structure HOL4ConstMapsArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   170
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   171
val name = "HOL4/constmappings"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   172
type T = (bool * string * typ option) StringPair.table
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   173
val empty = StringPair.empty
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   174
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   175
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   176
fun merge _ : T * T -> T = StringPair.merge (K true)
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   177
fun print _ tab =
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   178
  Pretty.writeln (Pretty.big_list "HOL4 constant mappings:"
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   179
    (StringPair.fold (fn ((bthy, bconst), (internal, isaconst, _)) => fn xl =>
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   180
      (Pretty.str (bthy ^ "." ^ bconst ^ " --> " ^ isaconst ^ (if internal then " (*)" else "")) :: xl)) tab []))
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   181
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   182
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   183
structure HOL4ConstMaps = TheoryDataFun(HOL4ConstMapsArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   184
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   185
structure HOL4RenameArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   186
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   187
val name = "HOL4/renamings"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   188
type T = string StringPair.table
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   189
val empty = StringPair.empty
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   190
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   191
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   192
fun merge _ : T * T -> T = StringPair.merge (K true)
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   193
fun print _ tab =
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   194
  Pretty.writeln (Pretty.big_list "HOL4 constant renamings:"
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   195
    (StringPair.fold (fn ((bthy,bconst),newname) => fn xl => (Pretty.str (bthy ^ "." ^ bconst ^ " --> " ^ newname)::xl)) tab []))
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   196
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   197
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   198
structure HOL4Rename = TheoryDataFun(HOL4RenameArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   199
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   200
structure HOL4DefMapsArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   201
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   202
val name = "HOL4/def_maps"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   203
type T = string StringPair.table
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   204
val empty = StringPair.empty
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   205
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   206
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   207
fun merge _ : T * T -> T = StringPair.merge (K true)
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   208
fun print _ tab =
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   209
  Pretty.writeln (Pretty.big_list "HOL4 constant definitions:"
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   210
    (StringPair.fold (fn ((bthy,bconst),newname) => fn xl => (Pretty.str (bthy ^ "." ^ bconst ^ ": " ^ newname)::xl)) tab []))
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   211
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   212
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   213
structure HOL4DefMaps = TheoryDataFun(HOL4DefMapsArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   214
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   215
structure HOL4TypeMapsArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   216
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   217
val name = "HOL4/typemappings"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   218
type T = (bool * string) StringPair.table
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   219
val empty = StringPair.empty
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   220
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   221
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   222
fun merge _ : T * T -> T = StringPair.merge (K true)
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   223
fun print _ tab =
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   224
  Pretty.writeln (Pretty.big_list "HOL4 type mappings:"
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   225
    (StringPair.fold (fn ((bthy, bconst), (internal, isaconst)) => fn xl =>
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   226
      (Pretty.str (bthy ^ "." ^ bconst ^ " --> " ^ isaconst ^ (if internal then " (*)" else "")) :: xl)) tab []))
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   227
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   228
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   229
structure HOL4TypeMaps = TheoryDataFun(HOL4TypeMapsArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   230
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   231
structure HOL4PendingArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   232
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   233
val name = "HOL4/pending"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   234
type T = ((term * term) list * thm) StringPair.table
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   235
val empty = StringPair.empty
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   236
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   237
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   238
fun merge _ : T * T -> T = StringPair.merge (K true)
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   239
fun print _ tab =
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   240
    Pretty.writeln (Pretty.big_list "HOL4 pending theorems:"
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   241
	(StringPair.fold (fn ((bthy,bthm),(_,th)) => fn xl => (Pretty.chunks [Pretty.str (bthy ^ "." ^ bthm ^ ":"),Display.pretty_thm th]::xl)) tab []))
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   242
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   243
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   244
structure HOL4Pending = TheoryDataFun(HOL4PendingArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   245
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   246
structure HOL4RewritesArgs: THEORY_DATA_ARGS =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   247
struct
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   248
val name = "HOL4/rewrites"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   249
type T = thm list
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   250
val empty = []
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   251
val copy = I
16424
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   252
val extend = I
18a07ad8fea8 accomodate change of TheoryDataFun;
wenzelm
parents: 15647
diff changeset
   253
fun merge _ = Library.gen_union Thm.eq_thm
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   254
fun print _ thms =
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   255
    Pretty.writeln (Pretty.big_list "HOL4 rewrite rules:"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   256
				    (map Display.pretty_thm thms))
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   257
end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   258
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   259
structure HOL4Rewrites = TheoryDataFun(HOL4RewritesArgs);
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   260
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   261
val hol4_debug = ref false
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   262
fun message s = if !hol4_debug then writeln s else ()
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   263
21546
268b6bed0cc8 removed HOL structure
haftmann
parents: 21056
diff changeset
   264
local
268b6bed0cc8 removed HOL structure
haftmann
parents: 21056
diff changeset
   265
  val eq_reflection = thm "eq_reflection"
268b6bed0cc8 removed HOL structure
haftmann
parents: 21056
diff changeset
   266
in
20897
3f8d2834b2c4 attribute: Context.mapping;
wenzelm
parents: 20071
diff changeset
   267
fun add_hol4_rewrite (Context.Theory thy, th) =
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   268
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   269
	val _ = message "Adding HOL4 rewrite"
21546
268b6bed0cc8 removed HOL structure
haftmann
parents: 21056
diff changeset
   270
	val th1 = th RS eq_reflection
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   271
	val current_rews = HOL4Rewrites.get thy
18921
f47c46d7d654 canonical member/insert/merge;
wenzelm
parents: 18728
diff changeset
   272
	val new_rews = insert Thm.eq_thm th1 current_rews
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   273
	val updated_thy  = HOL4Rewrites.put new_rews thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   274
    in
18728
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
   275
	(Context.Theory updated_thy,th1)
20897
3f8d2834b2c4 attribute: Context.mapping;
wenzelm
parents: 20071
diff changeset
   276
    end
21546
268b6bed0cc8 removed HOL structure
haftmann
parents: 21056
diff changeset
   277
  | add_hol4_rewrite (context, th) = (context, th RS eq_reflection);
268b6bed0cc8 removed HOL structure
haftmann
parents: 21056
diff changeset
   278
end
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   279
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   280
fun ignore_hol4 bthy bthm thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   281
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   282
	val _ = message ("Ignoring " ^ bthy ^ "." ^ bthm)
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   283
	val curmaps = HOL4Maps.get thy
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   284
	val newmaps = StringPair.update_new ((bthy,bthm),NONE) curmaps
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   285
	val upd_thy = HOL4Maps.put newmaps thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   286
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   287
	upd_thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   288
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   289
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   290
val opt_get_output_thy = #2 o HOL4Dump.get
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   291
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   292
fun get_output_thy thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   293
    case #2 (HOL4Dump.get thy) of
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   294
	"" => error "No theory file being output"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   295
      | thyname => thyname
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   296
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   297
val get_output_dir = #1 o HOL4Dump.get
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   298
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   299
fun add_hol4_move bef aft thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   300
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   301
	val curmoves = HOL4Moves.get thy
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   302
	val newmoves = Symtab.update_new (bef, aft) curmoves
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   303
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   304
	HOL4Moves.put newmoves thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   305
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   306
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   307
fun get_hol4_move bef thy =
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   308
  Symtab.lookup (HOL4Moves.get thy) bef
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   309
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   310
fun follow_name thmname thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   311
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   312
	val moves = HOL4Moves.get thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   313
	fun F thmname =
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   314
	    case Symtab.lookup moves thmname of
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14980
diff changeset
   315
		SOME name => F name
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14980
diff changeset
   316
	      | NONE => thmname
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   317
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   318
	F thmname
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   319
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   320
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   321
fun add_hol4_cmove bef aft thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   322
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   323
	val curmoves = HOL4CMoves.get thy
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   324
	val newmoves = Symtab.update_new (bef, aft) curmoves
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   325
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   326
	HOL4CMoves.put newmoves thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   327
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   328
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   329
fun get_hol4_cmove bef thy =
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   330
  Symtab.lookup (HOL4CMoves.get thy) bef
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   331
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   332
fun follow_cname thmname thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   333
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   334
	val moves = HOL4CMoves.get thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   335
	fun F thmname =
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   336
	    case Symtab.lookup moves thmname of
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14980
diff changeset
   337
		SOME name => F name
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14980
diff changeset
   338
	      | NONE => thmname
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   339
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   340
	F thmname
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   341
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   342
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   343
fun add_hol4_mapping bthy bthm isathm thy =
17644
bd59bfd4bf37 fixed disambiguation problem
obua
parents: 17607
diff changeset
   344
    let	
bd59bfd4bf37 fixed disambiguation problem
obua
parents: 17607
diff changeset
   345
       (* val _ = writeln ("Before follow_name: "^isathm)  *)
bd59bfd4bf37 fixed disambiguation problem
obua
parents: 17607
diff changeset
   346
      val isathm = follow_name isathm thy
bd59bfd4bf37 fixed disambiguation problem
obua
parents: 17607
diff changeset
   347
       (* val _ = writeln ("Adding theorem map: " ^ bthy ^ "." ^ bthm ^ " --> " ^ isathm)*)
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   348
	val curmaps = HOL4Maps.get thy
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   349
	val newmaps = StringPair.update_new ((bthy,bthm),SOME isathm) curmaps
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   350
	val upd_thy = HOL4Maps.put newmaps thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   351
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   352
	upd_thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   353
    end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   354
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   355
fun get_hol4_type_mapping bthy tycon thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   356
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   357
	val maps = HOL4TypeMaps.get thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   358
    in
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   359
	StringPair.lookup maps (bthy,tycon)
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   360
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   361
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   362
fun get_hol4_mapping bthy bthm thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   363
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   364
	val curmaps = HOL4Maps.get thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   365
    in
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   366
	StringPair.lookup curmaps (bthy,bthm)
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   367
    end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   368
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   369
fun add_hol4_const_mapping bthy bconst internal isaconst thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   370
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   371
	val thy = case opt_get_output_thy thy of
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   372
		      "" => thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   373
		    | output_thy => if internal
22578
b0eb5652f210 removed obsolete sign_of/sign_of_thm;
wenzelm
parents: 21858
diff changeset
   374
				    then add_hol4_cmove (Sign.full_name thy bconst) (output_thy ^ "." ^ bthy ^ "." ^ bconst) thy
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   375
				    else thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   376
	val _ = message ("Adding cmap " ^ bthy ^ "." ^ bconst ^ " -> " ^ isaconst ^ (if internal then " (*)" else ""))
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   377
	val curmaps = HOL4ConstMaps.get thy
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   378
	val newmaps = StringPair.update_new ((bthy,bconst),(internal,isaconst,NONE)) curmaps
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   379
	val upd_thy = HOL4ConstMaps.put newmaps thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   380
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   381
	upd_thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   382
    end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   383
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   384
fun add_hol4_const_renaming bthy bconst newname thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   385
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   386
	val currens = HOL4Rename.get thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   387
	val _ = message ("Adding renaming " ^ bthy ^ "." ^ bconst ^ " -> " ^ newname)
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   388
	val newrens = StringPair.update_new ((bthy,bconst),newname) currens
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   389
	val upd_thy = HOL4Rename.put newrens thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   390
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   391
	upd_thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   392
    end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   393
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   394
fun get_hol4_const_renaming bthy bconst thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   395
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   396
	val currens = HOL4Rename.get thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   397
    in
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   398
	StringPair.lookup currens (bthy,bconst)
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   399
    end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   400
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   401
fun get_hol4_const_mapping bthy bconst thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   402
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   403
	val bconst = case get_hol4_const_renaming bthy bconst thy of
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14980
diff changeset
   404
			 SOME name => name
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14980
diff changeset
   405
		       | NONE => bconst
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   406
	val maps = HOL4ConstMaps.get thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   407
    in
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   408
	StringPair.lookup maps (bthy,bconst)
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   409
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   410
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   411
fun add_hol4_const_wt_mapping bthy bconst internal isaconst typ thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   412
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   413
	val thy = case opt_get_output_thy thy of
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   414
		      "" => thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   415
		    | output_thy => if internal
22578
b0eb5652f210 removed obsolete sign_of/sign_of_thm;
wenzelm
parents: 21858
diff changeset
   416
				    then add_hol4_cmove (Sign.full_name thy bconst) (output_thy ^ "." ^ bthy ^ "." ^ bconst) thy
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   417
				    else thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   418
	val _ = message ("Adding cmap " ^ bthy ^ "." ^ bconst ^ " -> " ^ isaconst ^ (if internal then " (*)" else ""))
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   419
	val curmaps = HOL4ConstMaps.get thy
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   420
	val newmaps = StringPair.update_new ((bthy,bconst),(internal,isaconst,SOME typ)) curmaps
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   421
	val upd_thy = HOL4ConstMaps.put newmaps thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   422
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   423
	upd_thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   424
    end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   425
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   426
fun add_hol4_type_mapping bthy bconst internal isaconst thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   427
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   428
	val curmaps = HOL4TypeMaps.get thy
17322
781abf7011e6 Added HOLLight support to importer.
obua
parents: 17261
diff changeset
   429
	val _ = writeln ("Adding tmap " ^ bthy ^ "." ^ bconst ^ " -> " ^ isaconst ^ (if internal then " (*)" else ""))
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   430
	val newmaps = StringPair.update_new ((bthy,bconst),(internal,isaconst)) curmaps
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   431
               handle x => let val (internal, isaconst') = the (StringPair.lookup curmaps (bthy, bconst)) in
17322
781abf7011e6 Added HOLLight support to importer.
obua
parents: 17261
diff changeset
   432
                      warning ("couldn't map type "^bthy^"."^bconst^" to "^isaconst^": already mapped to "^isaconst'); raise x end
781abf7011e6 Added HOLLight support to importer.
obua
parents: 17261
diff changeset
   433
        val upd_thy = HOL4TypeMaps.put newmaps thy
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   434
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   435
	upd_thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   436
    end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   437
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   438
fun add_hol4_pending bthy bthm hth thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   439
    let
22578
b0eb5652f210 removed obsolete sign_of/sign_of_thm;
wenzelm
parents: 21858
diff changeset
   440
	val thmname = Sign.full_name thy bthm
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   441
	val _ = message ("Add pending " ^ bthy ^ "." ^ bthm)
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   442
	val curpend = HOL4Pending.get thy
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   443
	val newpend = StringPair.update_new ((bthy,bthm),hth) curpend
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   444
	val upd_thy = HOL4Pending.put newpend thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   445
	val thy' = case opt_get_output_thy upd_thy of
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   446
		       "" => add_hol4_mapping bthy bthm thmname upd_thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   447
		     | output_thy =>
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   448
		       let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   449
			   val new_thmname = output_thy ^ "." ^ bthy ^ "." ^ bthm
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   450
		       in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   451
			   upd_thy |> add_hol4_move thmname new_thmname
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   452
				   |> add_hol4_mapping bthy bthm new_thmname
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   453
		       end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   454
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   455
	thy'
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   456
    end;
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   457
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   458
fun get_hol4_theorem thyname thmname thy =
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   459
  let
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   460
    val isathms = HOL4Thms.get thy
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   461
  in
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   462
    StringPair.lookup isathms (thyname,thmname)
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   463
  end;
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   464
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   465
fun add_hol4_theorem thyname thmname hth =
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   466
  let
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   467
    val _ = message ("Adding HOL4 theorem " ^ thyname ^ "." ^ thmname)
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   468
  in
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   469
    HOL4Thms.map (StringPair.update_new ((thyname, thmname), hth))
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   470
  end;
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   471
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   472
fun export_hol4_pending thy =
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   473
  let
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   474
    val rews = HOL4Rewrites.get thy;
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   475
    val pending = HOL4Pending.get thy;
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   476
    fun process ((bthy,bthm), hth as (_,thm)) thy =
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   477
      let
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   478
        val thm1 = rewrite_rule (map (Thm.transfer thy) rews) (Thm.transfer thy thm);
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   479
        val thm2 = standard thm1;
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   480
      in
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   481
        thy
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   482
        |> PureThy.store_thm ((bthm, thm2), [])
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   483
        |> snd
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   484
        |> add_hol4_theorem bthy bthm hth
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   485
      end;
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   486
  in
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   487
    thy
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   488
    |> StringPair.fold process pending
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   489
    |> HOL4Pending.put StringPair.empty
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   490
  end;
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   491
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   492
fun setup_dump (dir,thyname) thy =
15647
b1f486a9c56b Updated import configuration.
skalberg
parents: 15570
diff changeset
   493
    HOL4Dump.put (dir,thyname,["(* AUTOMATICALLY GENERATED, DO NOT EDIT! *)"]) thy
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   494
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   495
fun add_dump str thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   496
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   497
	val (dir,thyname,curdump) = HOL4Dump.get thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   498
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   499
	HOL4Dump.put (dir,thyname,str::curdump) thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   500
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   501
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   502
fun flush_dump thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   503
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   504
	val (dir,thyname,dumpdata) = HOL4Dump.get thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   505
	val os = TextIO.openOut (OS.Path.joinDirFile {dir=dir,
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   506
						      file=thyname ^ ".thy"})
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   507
	val _  = app (fn s => TextIO.output(os,s ^ "\n\n")) (rev dumpdata)
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   508
	val  _ = TextIO.closeOut os
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   509
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   510
	HOL4Dump.put ("","",[]) thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   511
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   512
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   513
fun set_generating_thy thyname thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   514
    case HOL4DefThy.get thy of
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   515
	NoImport => HOL4DefThy.put (Generating thyname) thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   516
      | _ => error "Import already in progess"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   517
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   518
fun set_replaying_thy thyname thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   519
    case HOL4DefThy.get thy of
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   520
	NoImport => HOL4DefThy.put (Replaying thyname) thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   521
      | _ => error "Import already in progess"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   522
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   523
fun clear_import_thy thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   524
    case HOL4DefThy.get thy of
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   525
	NoImport => error "No import in progress"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   526
      | _ => HOL4DefThy.put NoImport thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   527
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   528
fun get_generating_thy thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   529
    case HOL4DefThy.get thy of
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   530
	Generating thyname => thyname
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   531
      | _ => error "No theory being generated"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   532
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   533
fun get_replaying_thy thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   534
    case HOL4DefThy.get thy of
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   535
	Replaying thyname => thyname
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   536
      | _ => error "No theory being replayed"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   537
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   538
fun get_import_thy thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   539
    case HOL4DefThy.get thy of
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   540
	Replaying thyname => thyname
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   541
      | Generating thyname => thyname
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   542
      | _ => error "No theory being imported"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   543
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   544
fun should_ignore thyname thy thmname =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   545
    case get_hol4_mapping thyname thmname thy of
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14980
diff changeset
   546
	SOME NONE => true 
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   547
      | _ => false
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   548
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   549
val trans_string =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   550
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   551
	fun quote s = "\"" ^ s ^ "\""
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   552
	fun F [] = []
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   553
	  | F (#"\\" :: cs) = patch #"\\" cs
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   554
	  | F (#"\"" :: cs) = patch #"\"" cs
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   555
	  | F (c     :: cs) = c :: F cs
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   556
	and patch c rest = #"\\" :: c :: F rest
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   557
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   558
	quote o String.implode o F o String.explode
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   559
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   560
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   561
fun dump_import_thy thyname thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   562
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   563
	val output_dir = get_output_dir thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   564
	val output_thy = get_output_thy thy
17607
7725da65f8e0 1) fixed bug in type_introduction: first stage uses different namespace than second stage
obua
parents: 17412
diff changeset
   565
	val input_thy = Context.theory_name thy
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   566
	val import_segment = get_import_segment thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   567
	val os = TextIO.openOut (OS.Path.joinDirFile {dir=output_dir,
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   568
						      file=thyname ^ ".imp"})
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   569
	fun out s = TextIO.output(os,s)
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   570
    val (ignored, mapped) = StringPair.fold
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   571
      (fn ((bthy, bthm), v) => fn (ign, map) =>
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   572
        if bthy = thyname
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   573
        then case v
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   574
         of NONE => (bthm :: ign, map)
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   575
          | SOME w => (ign, (bthm, w) :: map)
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   576
        else (ign, map)) (HOL4Maps.get thy) ([],[]);
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   577
    fun mk init = StringPair.fold
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   578
      (fn ((bthy, bthm), v) => if bthy = thyname then cons (bthm, v) else I) init [];
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   579
    val constmaps = mk (HOL4ConstMaps.get thy);
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   580
    val constrenames = mk (HOL4Rename.get thy);
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   581
    val typemaps = mk (HOL4TypeMaps.get thy);
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   582
    val defmaps = mk (HOL4DefMaps.get thy);
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   583
	fun new_name internal isa =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   584
	    if internal
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   585
	    then
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   586
		let
21858
05f57309170c avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents: 21546
diff changeset
   587
		    val paths = NameSpace.explode isa
15570
8d8c70b41bab Move towards standard functions.
skalberg
parents: 15531
diff changeset
   588
		    val i = Library.drop(length paths - 2,paths)
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   589
		in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   590
		    case i of
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   591
			[seg,con] => output_thy ^ "." ^ seg ^ "." ^ con
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   592
		      | _ => error "hol4rews.dump internal error"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   593
		end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   594
	    else
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   595
		isa
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   596
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   597
	val _ = out "import\n\n"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   598
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   599
	val _ = out ("import_segment " ^ trans_string import_segment ^ "\n\n")
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   600
	val _ = if null defmaps
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   601
		then ()
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   602
		else out "def_maps"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   603
	val _ = app (fn (hol,isa) =>
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   604
			out ("\n  " ^ (trans_string hol) ^ " > " ^ (trans_string isa))) defmaps
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   605
	val _ = if null defmaps
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   606
		then ()
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   607
		else out "\n\n"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   608
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   609
	val _ = if null typemaps
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   610
		then ()
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   611
		else out "type_maps"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   612
	val _ = app (fn (hol,(internal,isa)) =>
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   613
			out ("\n  " ^ (trans_string hol) ^ " > " ^ (trans_string (new_name internal isa)))) typemaps
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   614
	val _ = if null typemaps
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   615
		then ()
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   616
		else out "\n\n"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   617
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   618
	val _ = if null constmaps
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   619
		then ()
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   620
		else out "const_maps"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   621
	val _ = app (fn (hol,(internal,isa,opt_ty)) =>
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   622
			(out ("\n  " ^ (trans_string hol) ^ " > " ^ (trans_string (follow_cname isa thy)));
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   623
			 case opt_ty of
21056
2cfe839e8d58 Symtab.foldl replaced by Symtab.fold
haftmann
parents: 20897
diff changeset
   624
			     SOME ty => out (" :: \"" ^ (string_of_ctyp (ctyp_of thy ty)) ^ "\"")
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14980
diff changeset
   625
			   | NONE => ())) constmaps
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   626
	val _ = if null constmaps
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   627
		then ()
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   628
		else out "\n\n"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   629
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   630
	val _ = if null constrenames
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   631
		then ()
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   632
		else out "const_renames"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   633
	val _ = app (fn (old,new) =>
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   634
			out ("\n  " ^ (trans_string old) ^ " > " ^ (trans_string new))) constrenames
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   635
	val _ = if null constrenames
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   636
		then ()
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   637
		else out "\n\n"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   638
17607
7725da65f8e0 1) fixed bug in type_introduction: first stage uses different namespace than second stage
obua
parents: 17412
diff changeset
   639
	fun gen2replay in_thy out_thy s = 
7725da65f8e0 1) fixed bug in type_introduction: first stage uses different namespace than second stage
obua
parents: 17412
diff changeset
   640
	    let
21858
05f57309170c avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents: 21546
diff changeset
   641
		val ss = NameSpace.explode s
17607
7725da65f8e0 1) fixed bug in type_introduction: first stage uses different namespace than second stage
obua
parents: 17412
diff changeset
   642
	    in
7725da65f8e0 1) fixed bug in type_introduction: first stage uses different namespace than second stage
obua
parents: 17412
diff changeset
   643
		if (hd ss = in_thy) then 
21858
05f57309170c avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
wenzelm
parents: 21546
diff changeset
   644
		    NameSpace.implode (out_thy::(tl ss))
17607
7725da65f8e0 1) fixed bug in type_introduction: first stage uses different namespace than second stage
obua
parents: 17412
diff changeset
   645
		else
7725da65f8e0 1) fixed bug in type_introduction: first stage uses different namespace than second stage
obua
parents: 17412
diff changeset
   646
		    s
7725da65f8e0 1) fixed bug in type_introduction: first stage uses different namespace than second stage
obua
parents: 17412
diff changeset
   647
	    end 
7725da65f8e0 1) fixed bug in type_introduction: first stage uses different namespace than second stage
obua
parents: 17412
diff changeset
   648
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   649
	val _ = if null mapped
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   650
		then ()
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   651
		else out "thm_maps"
17607
7725da65f8e0 1) fixed bug in type_introduction: first stage uses different namespace than second stage
obua
parents: 17412
diff changeset
   652
	val _ = app (fn (hol,isa) => out ("\n  " ^ (trans_string hol) ^ " > " ^ (trans_string (gen2replay input_thy output_thy isa)))) mapped
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   653
	val _ = if null mapped 
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   654
		then ()
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   655
		else out "\n\n"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   656
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   657
	val _ = if null ignored
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   658
		then ()
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   659
		else out "ignore_thms"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   660
	val _ = app (fn ign => out ("\n  " ^ (trans_string ign))) ignored
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   661
	val _ = if null ignored
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   662
		then ()
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   663
		else out "\n\n"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   664
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   665
	val _ = out "end\n"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   666
	val _ = TextIO.closeOut os
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   667
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   668
	thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   669
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   670
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   671
fun set_used_names names thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   672
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   673
	val unames = HOL4UNames.get thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   674
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   675
	case unames of
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   676
	    [] => HOL4UNames.put names thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   677
	  | _ => error "hol4rews.set_used_names called on initialized data!"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   678
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   679
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   680
val clear_used_names = HOL4UNames.put HOL4UNamesArgs.empty
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   681
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   682
fun get_defmap thyname const thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   683
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   684
	val maps = HOL4DefMaps.get thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   685
    in
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   686
	StringPair.lookup maps (thyname,const)
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   687
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   688
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   689
fun add_defmap thyname const defname thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   690
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   691
	val _ = message ("Adding defmap " ^ thyname ^ "." ^ const ^ " --> " ^ defname)
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   692
	val maps = HOL4DefMaps.get thy
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   693
	val maps' = StringPair.update_new ((thyname,const),defname) maps
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   694
	val thy' = HOL4DefMaps.put maps' thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   695
    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   696
	thy'
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   697
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   698
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   699
fun get_defname thyname name thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   700
    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   701
	val maps = HOL4DefMaps.get thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   702
	fun F dname = (dname,add_defmap thyname name dname thy)
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   703
    in
17412
e26cb20ef0cc TableFun/Symtab: curried lookup and update;
wenzelm
parents: 17322
diff changeset
   704
	case StringPair.lookup maps (thyname,name) of
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14980
diff changeset
   705
	    SOME thmname => (thmname,thy)
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 14980
diff changeset
   706
	  | NONE =>
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   707
	    let
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   708
		val used = HOL4UNames.get thy
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   709
		val defname = def_name name
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   710
		val pdefname = name ^ "_primdef"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   711
	    in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   712
		if not (defname mem used)
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   713
		then F defname                 (* name_def *)
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   714
		else if not (pdefname mem used)
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   715
		then F pdefname                (* name_primdef *)
20071
8f3e1ddb50e6 replaced Term.variant(list) by Name.variant(_list);
wenzelm
parents: 18921
diff changeset
   716
		else F (Name.variant used pdefname) (* last resort *)
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   717
	    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   718
    end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   719
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   720
local
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   721
    fun handle_meta [x as Appl[Appl[Constant "_constrain", Constant "==", _],_,_]] = x
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   722
      | handle_meta [x as Appl[Appl[Constant "_constrain", Constant "all", _],_]] = x
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   723
      | handle_meta [x as Appl[Appl[Constant "_constrain", Constant "==>", _],_,_]] = x
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   724
      | handle_meta [x] = Appl[Constant "Trueprop",x]
14518
c3019a66180f Added a number of explicit type casts and delayed evaluations (all seemingly
skalberg
parents: 14516
diff changeset
   725
      | handle_meta _ = error "hol4rews error: Trueprop not applied to single argument"
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   726
in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   727
val smarter_trueprop_parsing = [("Trueprop",handle_meta)]
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   728
end
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   729
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   730
local
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   731
    fun initial_maps thy =
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   732
	thy |> add_hol4_type_mapping "min" "bool" false "bool"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   733
	    |> add_hol4_type_mapping "min" "fun" false "fun"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   734
	    |> add_hol4_type_mapping "min" "ind" false "Nat.ind"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   735
	    |> add_hol4_const_mapping "min" "=" false "op ="
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   736
	    |> add_hol4_const_mapping "min" "==>" false "op -->"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   737
	    |> add_hol4_const_mapping "min" "@" false "Hilbert_Choice.Eps"
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   738
in
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   739
val hol4_setup =
18708
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   740
  HOL4Rewrites.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   741
  HOL4Maps.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   742
  HOL4UNames.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   743
  HOL4DefMaps.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   744
  HOL4Moves.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   745
  HOL4CMoves.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   746
  HOL4ConstMaps.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   747
  HOL4Rename.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   748
  HOL4TypeMaps.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   749
  HOL4Pending.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   750
  HOL4Thms.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   751
  HOL4Dump.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   752
  HOL4DefThy.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   753
  HOL4Imports.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   754
  ImportSegment.init #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   755
  initial_maps #>
4b3dadb4fe33 setup: theory -> theory;
wenzelm
parents: 18358
diff changeset
   756
  Attrib.add_attributes
18728
6790126ab5f6 simplified type attribute;
wenzelm
parents: 18708
diff changeset
   757
    [("hol4rew", Attrib.no_args add_hol4_rewrite, "HOL4 rewrite rule")]
14516
a183dec876ab Added HOL proof importer.
skalberg
parents:
diff changeset
   758
end