author | wenzelm |
Fri, 18 Oct 2019 16:25:54 +0200 | |
changeset 70899 | 5f6dea6a7a4c |
parent 70896 | 8017d382a0d7 |
child 70913 | 935c78a90ee0 |
permissions | -rw-r--r-- |
68171 | 1 |
/* Title: Pure/Thy/export_theory.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Export foundational theory content. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
10 |
object Export_Theory |
|
11 |
{ |
|
68206 | 12 |
/** session content **/ |
13 |
||
70789 | 14 |
sealed case class Session(name: String, theory_graph: Graph[String, Option[Theory]]) |
68206 | 15 |
{ |
16 |
override def toString: String = name |
|
17 |
||
70789 | 18 |
def theory(theory_name: String): Option[Theory] = |
68206 | 19 |
if (theory_graph.defined(theory_name)) theory_graph.get_node(theory_name) |
70789 | 20 |
else None |
68206 | 21 |
|
22 |
def theories: List[Theory] = |
|
70789 | 23 |
theory_graph.topological_order.flatMap(theory(_)) |
68206 | 24 |
} |
25 |
||
70790
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
26 |
def read_session( |
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
27 |
store: Sessions.Store, |
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
28 |
sessions_structure: Sessions.Structure, |
68209 | 29 |
session_name: String, |
70790
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
30 |
progress: Progress = No_Progress, |
68206 | 31 |
types: Boolean = true, |
68264 | 32 |
consts: Boolean = true, |
33 |
axioms: Boolean = true, |
|
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
34 |
thms: Boolean = true, |
68264 | 35 |
classes: Boolean = true, |
68862 | 36 |
locales: Boolean = true, |
69069
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
37 |
locale_dependencies: Boolean = true, |
68295 | 38 |
classrel: Boolean = true, |
39 |
arities: Boolean = true, |
|
68862 | 40 |
typedefs: Boolean = true, |
68267 | 41 |
cache: Term.Cache = Term.make_cache()): Session = |
68206 | 42 |
{ |
43 |
val thys = |
|
70790
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
44 |
sessions_structure.build_requirements(List(session_name)).flatMap(session => |
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
45 |
using(store.open_database(session))(db => |
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
46 |
{ |
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
47 |
db.transaction { |
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
48 |
for (theory <- Export.read_theory_names(db, session)) |
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
49 |
yield { |
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
50 |
progress.echo("Reading theory " + theory) |
70891 | 51 |
read_theory(Export.Provider.database(db, session, theory), |
52 |
session, theory, types = types, consts = consts, |
|
53 |
axioms = axioms, thms = thms, classes = classes, locales = locales, |
|
54 |
locale_dependencies = locale_dependencies, classrel = classrel, arities = arities, |
|
55 |
typedefs = typedefs, cache = Some(cache)) |
|
70790
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
56 |
} |
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
57 |
} |
73514ccad7a6
clarified signature: read full session requirements;
wenzelm
parents:
70789
diff
changeset
|
58 |
})) |
68206 | 59 |
|
60 |
val graph0 = |
|
70890 | 61 |
(Graph.string[Option[Theory]] /: thys) { |
62 |
case (g, thy) => g.default_node(thy.name, Some(thy)) } |
|
68206 | 63 |
val graph1 = |
64 |
(graph0 /: thys) { case (g0, thy) => |
|
65 |
(g0 /: thy.parents) { case (g1, parent) => |
|
70789 | 66 |
g1.default_node(parent, None).add_edge_acyclic(parent, thy.name) } } |
68206 | 67 |
|
68 |
Session(session_name, graph1) |
|
69 |
} |
|
70 |
||
71 |
||
72 |
||
68203 | 73 |
/** theory content **/ |
74 |
||
68346 | 75 |
val export_prefix: String = "theory/" |
70539
30b3c58a1933
support Export_Theory.read_proof, based on theory_name and serial;
wenzelm
parents:
70534
diff
changeset
|
76 |
val export_prefix_proofs: String = "proofs/" |
68346 | 77 |
|
68208 | 78 |
sealed case class Theory(name: String, parents: List[String], |
79 |
types: List[Type], |
|
80 |
consts: List[Const], |
|
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
81 |
axioms: List[Axiom], |
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
82 |
thms: List[Thm], |
68264 | 83 |
classes: List[Class], |
68862 | 84 |
locales: List[Locale], |
69069
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
85 |
locale_dependencies: List[Locale_Dependency], |
68295 | 86 |
classrel: List[Classrel], |
68862 | 87 |
arities: List[Arity], |
88 |
typedefs: List[Typedef]) |
|
68206 | 89 |
{ |
90 |
override def toString: String = name |
|
68267 | 91 |
|
70789 | 92 |
def entity_iterator: Iterator[Entity] = |
93 |
types.iterator.map(_.entity) ++ |
|
94 |
consts.iterator.map(_.entity) ++ |
|
95 |
axioms.iterator.map(_.entity) ++ |
|
96 |
thms.iterator.map(_.entity) ++ |
|
97 |
classes.iterator.map(_.entity) ++ |
|
98 |
locales.iterator.map(_.entity) ++ |
|
99 |
locale_dependencies.iterator.map(_.entity) |
|
68711 | 100 |
|
68267 | 101 |
def cache(cache: Term.Cache): Theory = |
102 |
Theory(cache.string(name), |
|
103 |
parents.map(cache.string(_)), |
|
104 |
types.map(_.cache(cache)), |
|
105 |
consts.map(_.cache(cache)), |
|
106 |
axioms.map(_.cache(cache)), |
|
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
107 |
thms.map(_.cache(cache)), |
68267 | 108 |
classes.map(_.cache(cache)), |
68862 | 109 |
locales.map(_.cache(cache)), |
69069
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
110 |
locale_dependencies.map(_.cache(cache)), |
68295 | 111 |
classrel.map(_.cache(cache)), |
68862 | 112 |
arities.map(_.cache(cache)), |
113 |
typedefs.map(_.cache(cache))) |
|
68206 | 114 |
} |
115 |
||
68418 | 116 |
def read_theory(provider: Export.Provider, session_name: String, theory_name: String, |
68203 | 117 |
types: Boolean = true, |
68208 | 118 |
consts: Boolean = true, |
68232 | 119 |
axioms: Boolean = true, |
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
120 |
thms: Boolean = true, |
68264 | 121 |
classes: Boolean = true, |
68862 | 122 |
locales: Boolean = true, |
69069
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
123 |
locale_dependencies: Boolean = true, |
68295 | 124 |
classrel: Boolean = true, |
125 |
arities: Boolean = true, |
|
68862 | 126 |
typedefs: Boolean = true, |
68267 | 127 |
cache: Option[Term.Cache] = None): Theory = |
68203 | 128 |
{ |
68206 | 129 |
val parents = |
70891 | 130 |
if (theory_name == Thy_Header.PURE) Nil |
131 |
else { |
|
132 |
provider(export_prefix + "parents") match { |
|
133 |
case Some(entry) => split_lines(entry.uncompressed().text) |
|
134 |
case None => |
|
135 |
error("Missing theory export in session " + quote(session_name) + ": " + |
|
136 |
quote(theory_name)) |
|
137 |
} |
|
68206 | 138 |
} |
68267 | 139 |
val theory = |
140 |
Theory(theory_name, parents, |
|
68418 | 141 |
if (types) read_types(provider) else Nil, |
142 |
if (consts) read_consts(provider) else Nil, |
|
143 |
if (axioms) read_axioms(provider) else Nil, |
|
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
144 |
if (thms) read_thms(provider) else Nil, |
68418 | 145 |
if (classes) read_classes(provider) else Nil, |
68862 | 146 |
if (locales) read_locales(provider) else Nil, |
69069
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
147 |
if (locale_dependencies) read_locale_dependencies(provider) else Nil, |
68418 | 148 |
if (classrel) read_classrel(provider) else Nil, |
68862 | 149 |
if (arities) read_arities(provider) else Nil, |
150 |
if (typedefs) read_typedefs(provider) else Nil) |
|
68267 | 151 |
if (cache.isDefined) theory.cache(cache.get) else theory |
68203 | 152 |
} |
153 |
||
70883 | 154 |
def read_pure[A](store: Sessions.Store, read: (Export.Provider, String, String) => A): A = |
68710 | 155 |
{ |
156 |
val session_name = Thy_Header.PURE |
|
157 |
val theory_name = Thy_Header.PURE |
|
158 |
||
159 |
using(store.open_database(session_name))(db => |
|
160 |
{ |
|
161 |
db.transaction { |
|
70883 | 162 |
read(Export.Provider.database(db, session_name, theory_name), session_name, theory_name) |
68710 | 163 |
} |
164 |
}) |
|
165 |
} |
|
166 |
||
70883 | 167 |
def read_pure_theory(store: Sessions.Store, cache: Option[Term.Cache] = None): Theory = |
168 |
read_pure(store, read_theory(_, _, _, cache = cache)) |
|
169 |
||
70899
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
170 |
def read_pure_proof( |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
171 |
store: Sessions.Store, id: Thm_Id, cache: Option[Term.Cache] = None): Option[Proof] = |
70884 | 172 |
read_pure(store, (provider, _, _) => read_proof(provider, id, cache = cache)) |
70883 | 173 |
|
68203 | 174 |
|
68171 | 175 |
/* entities */ |
176 |
||
68714 | 177 |
object Kind extends Enumeration |
68171 | 178 |
{ |
68714 | 179 |
val TYPE = Value("type") |
180 |
val CONST = Value("const") |
|
181 |
val AXIOM = Value("axiom") |
|
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
182 |
val THM = Value("thm") |
70882 | 183 |
val PROOF = Value("proof") |
68714 | 184 |
val CLASS = Value("class") |
68862 | 185 |
val LOCALE = Value("locale") |
69069
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
186 |
val LOCALE_DEPENDENCY = Value("locale_dependency") |
68714 | 187 |
} |
188 |
||
68835 | 189 |
sealed case class Entity( |
68997 | 190 |
kind: Kind.Value, name: String, xname: String, pos: Position.T, id: Option[Long], serial: Long) |
68714 | 191 |
{ |
68718 | 192 |
override def toString: String = kind.toString + " " + quote(name) |
68267 | 193 |
|
194 |
def cache(cache: Term.Cache): Entity = |
|
68997 | 195 |
Entity(kind, cache.string(name), cache.string(xname), cache.position(pos), id, serial) |
68171 | 196 |
} |
197 |
||
68714 | 198 |
def decode_entity(kind: Kind.Value, tree: XML.Tree): (Entity, XML.Body) = |
68171 | 199 |
{ |
200 |
def err(): Nothing = throw new XML.XML_Body(List(tree)) |
|
201 |
||
202 |
tree match { |
|
203 |
case XML.Elem(Markup(Markup.ENTITY, props), body) => |
|
204 |
val name = Markup.Name.unapply(props) getOrElse err() |
|
68997 | 205 |
val xname = Markup.XName.unapply(props) getOrElse err() |
68830
44ec6fdaacf8
retain original id, which is command_id/exec_id for PIDE;
wenzelm
parents:
68726
diff
changeset
|
206 |
val pos = props.filter({ case (a, _) => Markup.POSITION_PROPERTIES(a) && a != Markup.ID }) |
68835 | 207 |
val id = Position.Id.unapply(props) |
68171 | 208 |
val serial = Markup.Serial.unapply(props) getOrElse err() |
68997 | 209 |
(Entity(kind, name, xname, pos, id, serial), body) |
68171 | 210 |
case _ => err() |
211 |
} |
|
212 |
} |
|
213 |
||
214 |
||
69077
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
215 |
/* approximative syntax */ |
69003 | 216 |
|
217 |
object Assoc extends Enumeration |
|
218 |
{ |
|
219 |
val NO_ASSOC, LEFT_ASSOC, RIGHT_ASSOC = Value |
|
220 |
} |
|
221 |
||
69077
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
222 |
sealed abstract class Syntax |
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
223 |
case object No_Syntax extends Syntax |
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
224 |
case class Prefix(delim: String) extends Syntax |
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
225 |
case class Infix(assoc: Assoc.Value, delim: String, pri: Int) extends Syntax |
69003 | 226 |
|
69077
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
227 |
def decode_syntax: XML.Decode.T[Syntax] = |
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
228 |
XML.Decode.variant(List( |
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
229 |
{ case (Nil, Nil) => No_Syntax }, |
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
230 |
{ case (List(delim), Nil) => Prefix(delim) }, |
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
231 |
{ case (Nil, body) => |
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
232 |
import XML.Decode._ |
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
233 |
val (ass, delim, pri) = triple(int, string, int)(body) |
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
234 |
Infix(Assoc(ass), delim, pri) })) |
69003 | 235 |
|
236 |
||
68171 | 237 |
/* types */ |
238 |
||
69003 | 239 |
sealed case class Type( |
69077
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
240 |
entity: Entity, syntax: Syntax, args: List[String], abbrev: Option[Term.Typ]) |
68267 | 241 |
{ |
242 |
def cache(cache: Term.Cache): Type = |
|
243 |
Type(entity.cache(cache), |
|
69003 | 244 |
syntax, |
68267 | 245 |
args.map(cache.string(_)), |
246 |
abbrev.map(cache.typ(_))) |
|
247 |
} |
|
68171 | 248 |
|
68418 | 249 |
def read_types(provider: Export.Provider): List[Type] = |
250 |
provider.uncompressed_yxml(export_prefix + "types").map((tree: XML.Tree) => |
|
251 |
{ |
|
68714 | 252 |
val (entity, body) = decode_entity(Kind.TYPE, tree) |
69003 | 253 |
val (syntax, args, abbrev) = |
68203 | 254 |
{ |
68418 | 255 |
import XML.Decode._ |
69077
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
256 |
triple(decode_syntax, list(string), option(Term_XML.Decode.typ))(body) |
68418 | 257 |
} |
69003 | 258 |
Type(entity, syntax, args, abbrev) |
68418 | 259 |
}) |
68171 | 260 |
|
261 |
||
262 |
/* consts */ |
|
263 |
||
68173 | 264 |
sealed case class Const( |
69003 | 265 |
entity: Entity, |
69077
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
266 |
syntax: Syntax, |
69003 | 267 |
typargs: List[String], |
268 |
typ: Term.Typ, |
|
69988 | 269 |
abbrev: Option[Term.Term], |
69992
bd3c10813cc4
more informative Spec_Rules.Equational, notably primrec argument types;
wenzelm
parents:
69988
diff
changeset
|
270 |
propositional: Boolean, |
69996
8f2d3a27aff0
more informative Spec_Rules.Equational: support corecursion;
wenzelm
parents:
69992
diff
changeset
|
271 |
primrec_types: List[String], |
8f2d3a27aff0
more informative Spec_Rules.Equational: support corecursion;
wenzelm
parents:
69992
diff
changeset
|
272 |
corecursive: Boolean) |
68267 | 273 |
{ |
274 |
def cache(cache: Term.Cache): Const = |
|
275 |
Const(entity.cache(cache), |
|
69003 | 276 |
syntax, |
68267 | 277 |
typargs.map(cache.string(_)), |
278 |
cache.typ(typ), |
|
69988 | 279 |
abbrev.map(cache.term(_)), |
69992
bd3c10813cc4
more informative Spec_Rules.Equational, notably primrec argument types;
wenzelm
parents:
69988
diff
changeset
|
280 |
propositional, |
69996
8f2d3a27aff0
more informative Spec_Rules.Equational: support corecursion;
wenzelm
parents:
69992
diff
changeset
|
281 |
primrec_types.map(cache.string(_)), |
8f2d3a27aff0
more informative Spec_Rules.Equational: support corecursion;
wenzelm
parents:
69992
diff
changeset
|
282 |
corecursive) |
68267 | 283 |
} |
68171 | 284 |
|
68418 | 285 |
def read_consts(provider: Export.Provider): List[Const] = |
286 |
provider.uncompressed_yxml(export_prefix + "consts").map((tree: XML.Tree) => |
|
287 |
{ |
|
68714 | 288 |
val (entity, body) = decode_entity(Kind.CONST, tree) |
69996
8f2d3a27aff0
more informative Spec_Rules.Equational: support corecursion;
wenzelm
parents:
69992
diff
changeset
|
289 |
val (syntax, (args, (typ, (abbrev, (propositional, (primrec_types, corecursive)))))) = |
68203 | 290 |
{ |
68418 | 291 |
import XML.Decode._ |
69992
bd3c10813cc4
more informative Spec_Rules.Equational, notably primrec argument types;
wenzelm
parents:
69988
diff
changeset
|
292 |
pair(decode_syntax, |
bd3c10813cc4
more informative Spec_Rules.Equational, notably primrec argument types;
wenzelm
parents:
69988
diff
changeset
|
293 |
pair(list(string), |
bd3c10813cc4
more informative Spec_Rules.Equational, notably primrec argument types;
wenzelm
parents:
69988
diff
changeset
|
294 |
pair(Term_XML.Decode.typ, |
69996
8f2d3a27aff0
more informative Spec_Rules.Equational: support corecursion;
wenzelm
parents:
69992
diff
changeset
|
295 |
pair(option(Term_XML.Decode.term), pair(bool, |
8f2d3a27aff0
more informative Spec_Rules.Equational: support corecursion;
wenzelm
parents:
69992
diff
changeset
|
296 |
pair(list(string), bool))))))(body) |
68418 | 297 |
} |
69996
8f2d3a27aff0
more informative Spec_Rules.Equational: support corecursion;
wenzelm
parents:
69992
diff
changeset
|
298 |
Const(entity, syntax, args, typ, abbrev, propositional, primrec_types, corecursive) |
68418 | 299 |
}) |
68208 | 300 |
|
301 |
||
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
302 |
/* axioms */ |
68232 | 303 |
|
68726 | 304 |
sealed case class Prop( |
305 |
typargs: List[(String, Term.Sort)], |
|
306 |
args: List[(String, Term.Typ)], |
|
307 |
term: Term.Term) |
|
68232 | 308 |
{ |
68726 | 309 |
def cache(cache: Term.Cache): Prop = |
310 |
Prop( |
|
311 |
typargs.map({ case (name, sort) => (cache.string(name), cache.sort(sort)) }), |
|
312 |
args.map({ case (name, typ) => (cache.string(name), cache.typ(typ)) }), |
|
313 |
cache.term(term)) |
|
68232 | 314 |
} |
68208 | 315 |
|
68726 | 316 |
def decode_prop(body: XML.Body): Prop = |
68267 | 317 |
{ |
68726 | 318 |
val (typargs, args, t) = |
319 |
{ |
|
320 |
import XML.Decode._ |
|
321 |
import Term_XML.Decode._ |
|
322 |
triple(list(pair(string, sort)), list(pair(string, typ)), term)(body) |
|
323 |
} |
|
324 |
Prop(typargs, args, t) |
|
68267 | 325 |
} |
68208 | 326 |
|
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
327 |
sealed case class Axiom(entity: Entity, prop: Prop) |
70534
fb876ebbf5a7
export facts with reconstructed proof term (if possible), but its PThm boxes need to be collected separately;
wenzelm
parents:
70384
diff
changeset
|
328 |
{ |
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
329 |
def cache(cache: Term.Cache): Axiom = |
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
330 |
Axiom(entity.cache(cache), prop.cache(cache)) |
70534
fb876ebbf5a7
export facts with reconstructed proof term (if possible), but its PThm boxes need to be collected separately;
wenzelm
parents:
70384
diff
changeset
|
331 |
} |
fb876ebbf5a7
export facts with reconstructed proof term (if possible), but its PThm boxes need to be collected separately;
wenzelm
parents:
70384
diff
changeset
|
332 |
|
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
333 |
def read_axioms(provider: Export.Provider): List[Axiom] = |
68418 | 334 |
provider.uncompressed_yxml(export_prefix + "axioms").map((tree: XML.Tree) => |
335 |
{ |
|
68714 | 336 |
val (entity, body) = decode_entity(Kind.AXIOM, tree) |
68726 | 337 |
val prop = decode_prop(body) |
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
338 |
Axiom(entity, prop) |
68418 | 339 |
}) |
68232 | 340 |
|
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
341 |
|
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
342 |
/* theorems */ |
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
343 |
|
70884 | 344 |
sealed case class Thm_Id(serial: Long, theory_name: String) |
345 |
{ |
|
346 |
def pure: Boolean = theory_name == Thy_Header.PURE |
|
347 |
||
348 |
def cache(cache: Term.Cache): Thm_Id = |
|
349 |
Thm_Id(serial, cache.string(theory_name)) |
|
350 |
} |
|
351 |
||
352 |
sealed case class Thm( |
|
353 |
entity: Entity, |
|
354 |
prop: Prop, |
|
355 |
deps: List[String], |
|
70896 | 356 |
proof_boxes: List[Thm_Id], |
357 |
proof: Term.Proof) |
|
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
358 |
{ |
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
359 |
def cache(cache: Term.Cache): Thm = |
70884 | 360 |
Thm( |
361 |
entity.cache(cache), |
|
362 |
prop.cache(cache), |
|
363 |
deps.map(cache.string _), |
|
70896 | 364 |
proof_boxes.map(_.cache(cache)), |
365 |
cache.proof(proof)) |
|
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
366 |
} |
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
367 |
|
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
368 |
def read_thms(provider: Export.Provider): List[Thm] = |
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
369 |
provider.uncompressed_yxml(export_prefix + "thms").map((tree: XML.Tree) => |
68418 | 370 |
{ |
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
371 |
val (entity, body) = decode_entity(Kind.THM, tree) |
70896 | 372 |
val (prop, (deps, (prf_boxes, prf))) = |
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
373 |
{ |
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
374 |
import XML.Decode._ |
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
375 |
import Term_XML.Decode._ |
70884 | 376 |
def thm_id(body: XML.Body): Thm_Id = |
377 |
{ |
|
378 |
val (serial, theory_name) = pair(long, string)(body) |
|
379 |
Thm_Id(serial, theory_name) |
|
380 |
} |
|
70896 | 381 |
pair(decode_prop _, pair(list(string), pair(list(thm_id), proof)))(body) |
70579
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
wenzelm
parents:
70539
diff
changeset
|
382 |
} |
70896 | 383 |
Thm(entity, prop, deps, prf_boxes, prf) |
68418 | 384 |
}) |
68264 | 385 |
|
70881 | 386 |
sealed case class Proof( |
387 |
typargs: List[(String, Term.Sort)], |
|
388 |
args: List[(String, Term.Typ)], |
|
389 |
term: Term.Term, |
|
390 |
proof: Term.Proof) |
|
391 |
{ |
|
70883 | 392 |
def prop: Prop = Prop(typargs, args, term) |
393 |
||
70881 | 394 |
def cache(cache: Term.Cache): Proof = |
395 |
Proof( |
|
396 |
typargs.map({ case (name, sort) => (cache.string(name), cache.sort(sort)) }), |
|
397 |
args.map({ case (name, typ) => (cache.string(name), cache.typ(typ)) }), |
|
398 |
cache.term(term), |
|
399 |
cache.proof(proof)) |
|
400 |
} |
|
401 |
||
70899
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
402 |
def read_proof( |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
403 |
provider: Export.Provider, id: Thm_Id, cache: Option[Term.Cache] = None): Option[Proof] = |
70539
30b3c58a1933
support Export_Theory.read_proof, based on theory_name and serial;
wenzelm
parents:
70534
diff
changeset
|
404 |
{ |
70899
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
405 |
for { entry <- provider.focus(id.theory_name)(export_prefix_proofs + id.serial) } |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
406 |
yield { |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
407 |
val body = entry.uncompressed_yxml() |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
408 |
val (typargs, (args, (prop_body, proof_body))) = |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
409 |
{ |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
410 |
import XML.Decode._ |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
411 |
import Term_XML.Decode._ |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
412 |
pair(list(pair(string, sort)), pair(list(pair(string, typ)), pair(x => x, x => x)))(body) |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
413 |
} |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
414 |
val env = args.toMap |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
415 |
val prop = Term_XML.Decode.term_env(env)(prop_body) |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
416 |
val proof = Term_XML.Decode.proof_env(env)(proof_body) |
70843
cc987440d776
more compact XML: separate environment for free variables;
wenzelm
parents:
70790
diff
changeset
|
417 |
|
70899
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
418 |
val result = Proof(typargs, args, prop, proof) |
5f6dea6a7a4c
clarified signature: support partial read_proof to accommodate proof term normalization vs. approximative proof_boxes as upper bound;
wenzelm
parents:
70896
diff
changeset
|
419 |
cache.map(result.cache(_)) getOrElse result |
70843
cc987440d776
more compact XML: separate environment for free variables;
wenzelm
parents:
70790
diff
changeset
|
420 |
} |
70539
30b3c58a1933
support Export_Theory.read_proof, based on theory_name and serial;
wenzelm
parents:
70534
diff
changeset
|
421 |
} |
30b3c58a1933
support Export_Theory.read_proof, based on theory_name and serial;
wenzelm
parents:
70534
diff
changeset
|
422 |
|
68264 | 423 |
|
424 |
/* type classes */ |
|
425 |
||
426 |
sealed case class Class( |
|
69023
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
wenzelm
parents:
69019
diff
changeset
|
427 |
entity: Entity, params: List[(String, Term.Typ)], axioms: List[Prop]) |
68267 | 428 |
{ |
429 |
def cache(cache: Term.Cache): Class = |
|
430 |
Class(entity.cache(cache), |
|
431 |
params.map({ case (name, typ) => (cache.string(name), cache.typ(typ)) }), |
|
69023
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
wenzelm
parents:
69019
diff
changeset
|
432 |
axioms.map(_.cache(cache))) |
68267 | 433 |
} |
68264 | 434 |
|
68418 | 435 |
def read_classes(provider: Export.Provider): List[Class] = |
436 |
provider.uncompressed_yxml(export_prefix + "classes").map((tree: XML.Tree) => |
|
437 |
{ |
|
68714 | 438 |
val (entity, body) = decode_entity(Kind.CLASS, tree) |
68418 | 439 |
val (params, axioms) = |
68264 | 440 |
{ |
68418 | 441 |
import XML.Decode._ |
442 |
import Term_XML.Decode._ |
|
69023
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
wenzelm
parents:
69019
diff
changeset
|
443 |
pair(list(pair(string, typ)), list(decode_prop))(body) |
68418 | 444 |
} |
445 |
Class(entity, params, axioms) |
|
446 |
}) |
|
68264 | 447 |
|
448 |
||
68862 | 449 |
/* locales */ |
450 |
||
451 |
sealed case class Locale( |
|
69019 | 452 |
entity: Entity, |
453 |
typargs: List[(String, Term.Sort)], |
|
69077
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
454 |
args: List[((String, Term.Typ), Syntax)], |
69023
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
wenzelm
parents:
69019
diff
changeset
|
455 |
axioms: List[Prop]) |
68862 | 456 |
{ |
457 |
def cache(cache: Term.Cache): Locale = |
|
458 |
Locale(entity.cache(cache), |
|
68864 | 459 |
typargs.map({ case (name, sort) => (cache.string(name), cache.sort(sort)) }), |
69076 | 460 |
args.map({ case ((name, typ), syntax) => ((cache.string(name), cache.typ(typ)), syntax) }), |
69023
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
wenzelm
parents:
69019
diff
changeset
|
461 |
axioms.map(_.cache(cache))) |
68862 | 462 |
} |
463 |
||
464 |
def read_locales(provider: Export.Provider): List[Locale] = |
|
465 |
provider.uncompressed_yxml(export_prefix + "locales").map((tree: XML.Tree) => |
|
466 |
{ |
|
467 |
val (entity, body) = decode_entity(Kind.LOCALE, tree) |
|
69019 | 468 |
val (typargs, args, axioms) = |
68862 | 469 |
{ |
470 |
import XML.Decode._ |
|
471 |
import Term_XML.Decode._ |
|
69077
11529ae45786
more approximative prefix syntax, including binder;
wenzelm
parents:
69076
diff
changeset
|
472 |
triple(list(pair(string, sort)), list(pair(pair(string, typ), decode_syntax)), |
69076 | 473 |
list(decode_prop))(body) |
68862 | 474 |
} |
69019 | 475 |
Locale(entity, typargs, args, axioms) |
68862 | 476 |
}) |
477 |
||
478 |
||
69069
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
479 |
/* locale dependencies */ |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
480 |
|
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
481 |
sealed case class Locale_Dependency( |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
482 |
entity: Entity, |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
483 |
source: String, |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
484 |
target: String, |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
485 |
prefix: List[(String, Boolean)], |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
486 |
subst_types: List[((String, Term.Sort), Term.Typ)], |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
487 |
subst_terms: List[((String, Term.Typ), Term.Term)]) |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
488 |
{ |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
489 |
def cache(cache: Term.Cache): Locale_Dependency = |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
490 |
Locale_Dependency(entity.cache(cache), |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
491 |
cache.string(source), |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
492 |
cache.string(target), |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
493 |
prefix.map({ case (name, mandatory) => (cache.string(name), mandatory) }), |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
494 |
subst_types.map({ case ((a, s), ty) => ((cache.string(a), cache.sort(s)), cache.typ(ty)) }), |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
495 |
subst_terms.map({ case ((x, ty), t) => ((cache.string(x), cache.typ(ty)), cache.term(t)) })) |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
496 |
|
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
497 |
def is_inclusion: Boolean = |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
498 |
subst_types.isEmpty && subst_terms.isEmpty |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
499 |
} |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
500 |
|
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
501 |
def read_locale_dependencies(provider: Export.Provider): List[Locale_Dependency] = |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
502 |
provider.uncompressed_yxml(export_prefix + "locale_dependencies").map((tree: XML.Tree) => |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
503 |
{ |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
504 |
val (entity, body) = decode_entity(Kind.LOCALE_DEPENDENCY, tree) |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
505 |
val (source, (target, (prefix, (subst_types, subst_terms)))) = |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
506 |
{ |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
507 |
import XML.Decode._ |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
508 |
import Term_XML.Decode._ |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
509 |
pair(string, pair(string, pair(list(pair(string, bool)), |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
510 |
pair(list(pair(pair(string, sort), typ)), list(pair(pair(string, typ), term))))))(body) |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
511 |
} |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
512 |
Locale_Dependency(entity, source, target, prefix, subst_types, subst_terms) |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
513 |
}) |
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
514 |
|
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
wenzelm
parents:
69023
diff
changeset
|
515 |
|
68295 | 516 |
/* sort algebra */ |
517 |
||
70384
8ce08b154aa1
clarified export of sort algebra: avoid logical operations in Isabelle/Scala;
wenzelm
parents:
69996
diff
changeset
|
518 |
sealed case class Classrel(class1: String, class2: String, prop: Prop) |
68295 | 519 |
{ |
520 |
def cache(cache: Term.Cache): Classrel = |
|
70384
8ce08b154aa1
clarified export of sort algebra: avoid logical operations in Isabelle/Scala;
wenzelm
parents:
69996
diff
changeset
|
521 |
Classrel(cache.string(class1), cache.string(class2), prop.cache(cache)) |
68295 | 522 |
} |
523 |
||
68418 | 524 |
def read_classrel(provider: Export.Provider): List[Classrel] = |
525 |
{ |
|
526 |
val body = provider.uncompressed_yxml(export_prefix + "classrel") |
|
527 |
val classrel = |
|
528 |
{ |
|
529 |
import XML.Decode._ |
|
70384
8ce08b154aa1
clarified export of sort algebra: avoid logical operations in Isabelle/Scala;
wenzelm
parents:
69996
diff
changeset
|
530 |
list(pair(decode_prop, pair(string, string)))(body) |
68418 | 531 |
} |
70384
8ce08b154aa1
clarified export of sort algebra: avoid logical operations in Isabelle/Scala;
wenzelm
parents:
69996
diff
changeset
|
532 |
for ((prop, (c1, c2)) <- classrel) yield Classrel(c1, c2, prop) |
68418 | 533 |
} |
68295 | 534 |
|
70384
8ce08b154aa1
clarified export of sort algebra: avoid logical operations in Isabelle/Scala;
wenzelm
parents:
69996
diff
changeset
|
535 |
sealed case class Arity(type_name: String, domain: List[Term.Sort], codomain: String, prop: Prop) |
68295 | 536 |
{ |
537 |
def cache(cache: Term.Cache): Arity = |
|
70384
8ce08b154aa1
clarified export of sort algebra: avoid logical operations in Isabelle/Scala;
wenzelm
parents:
69996
diff
changeset
|
538 |
Arity(cache.string(type_name), domain.map(cache.sort(_)), cache.string(codomain), |
8ce08b154aa1
clarified export of sort algebra: avoid logical operations in Isabelle/Scala;
wenzelm
parents:
69996
diff
changeset
|
539 |
prop.cache(cache)) |
68295 | 540 |
} |
541 |
||
68418 | 542 |
def read_arities(provider: Export.Provider): List[Arity] = |
543 |
{ |
|
544 |
val body = provider.uncompressed_yxml(export_prefix + "arities") |
|
545 |
val arities = |
|
546 |
{ |
|
547 |
import XML.Decode._ |
|
548 |
import Term_XML.Decode._ |
|
70384
8ce08b154aa1
clarified export of sort algebra: avoid logical operations in Isabelle/Scala;
wenzelm
parents:
69996
diff
changeset
|
549 |
list(pair(decode_prop, triple(string, list(sort), string)))(body) |
68418 | 550 |
} |
70384
8ce08b154aa1
clarified export of sort algebra: avoid logical operations in Isabelle/Scala;
wenzelm
parents:
69996
diff
changeset
|
551 |
for ((prop, (a, b, c)) <- arities) yield Arity(a, b, c, prop) |
68418 | 552 |
} |
68295 | 553 |
|
554 |
||
68264 | 555 |
/* HOL typedefs */ |
556 |
||
557 |
sealed case class Typedef(name: String, |
|
558 |
rep_type: Term.Typ, abs_type: Term.Typ, rep_name: String, abs_name: String, axiom_name: String) |
|
68267 | 559 |
{ |
560 |
def cache(cache: Term.Cache): Typedef = |
|
561 |
Typedef(cache.string(name), |
|
562 |
cache.typ(rep_type), |
|
563 |
cache.typ(abs_type), |
|
564 |
cache.string(rep_name), |
|
565 |
cache.string(abs_name), |
|
566 |
cache.string(axiom_name)) |
|
567 |
} |
|
68264 | 568 |
|
68418 | 569 |
def read_typedefs(provider: Export.Provider): List[Typedef] = |
570 |
{ |
|
571 |
val body = provider.uncompressed_yxml(export_prefix + "typedefs") |
|
572 |
val typedefs = |
|
573 |
{ |
|
574 |
import XML.Decode._ |
|
575 |
import Term_XML.Decode._ |
|
576 |
list(pair(string, pair(typ, pair(typ, pair(string, pair(string, string))))))(body) |
|
577 |
} |
|
578 |
for { (name, (rep_type, (abs_type, (rep_name, (abs_name, axiom_name))))) <- typedefs } |
|
579 |
yield Typedef(name, rep_type, abs_type, rep_name, abs_name, axiom_name) |
|
580 |
} |
|
68171 | 581 |
} |