282 } |
282 } |
283 Const(entity, syntax, args, typ, abbrev, propositional, primrec_types, corecursive) |
283 Const(entity, syntax, args, typ, abbrev, propositional, primrec_types, corecursive) |
284 }) |
284 }) |
285 |
285 |
286 |
286 |
287 /* facts */ |
287 /* axioms and facts */ |
288 |
288 |
289 sealed case class Prop( |
289 sealed case class Prop( |
290 typargs: List[(String, Term.Sort)], |
290 typargs: List[(String, Term.Sort)], |
291 args: List[(String, Term.Typ)], |
291 args: List[(String, Term.Typ)], |
292 term: Term.Term) |
292 term: Term.Term) |
307 triple(list(pair(string, sort)), list(pair(string, typ)), term)(body) |
307 triple(list(pair(string, sort)), list(pair(string, typ)), term)(body) |
308 } |
308 } |
309 Prop(typargs, args, t) |
309 Prop(typargs, args, t) |
310 } |
310 } |
311 |
311 |
312 sealed case class Fact_Single(entity: Entity, prop: Prop) |
312 |
|
313 sealed case class Fact(prop: Prop, proof: Option[Term.Proof]) |
|
314 { |
|
315 def cache(cache: Term.Cache): Fact = |
|
316 Fact(prop.cache(cache), proof.map(cache.proof _)) |
|
317 } |
|
318 |
|
319 def decode_fact(body: XML.Body): Fact = |
|
320 { |
|
321 val (prop, proof) = |
|
322 { |
|
323 import XML.Decode._ |
|
324 pair(decode_prop _, option(Term_XML.Decode.proof))(body) |
|
325 } |
|
326 Fact(prop, proof) |
|
327 } |
|
328 |
|
329 sealed case class Fact_Single(entity: Entity, fact: Fact) |
313 { |
330 { |
314 def cache(cache: Term.Cache): Fact_Single = |
331 def cache(cache: Term.Cache): Fact_Single = |
315 Fact_Single(entity.cache(cache), prop.cache(cache)) |
332 Fact_Single(entity.cache(cache), fact.cache(cache)) |
316 } |
333 |
317 |
334 def prop: Prop = fact.prop |
318 sealed case class Fact_Multi(entity: Entity, props: List[Prop]) |
335 def proof: Option[Term.Proof] = fact.proof |
|
336 } |
|
337 |
|
338 sealed case class Fact_Multi(entity: Entity, facts: List[Fact]) |
319 { |
339 { |
320 def cache(cache: Term.Cache): Fact_Multi = |
340 def cache(cache: Term.Cache): Fact_Multi = |
321 Fact_Multi(entity.cache(cache), props.map(_.cache(cache))) |
341 Fact_Multi(entity.cache(cache), facts.map(_.cache(cache))) |
|
342 |
|
343 def props: List[Prop] = facts.map(_.prop) |
322 |
344 |
323 def split: List[Fact_Single] = |
345 def split: List[Fact_Single] = |
324 props match { |
346 facts match { |
325 case List(prop) => List(Fact_Single(entity, prop)) |
347 case List(fact) => List(Fact_Single(entity, fact)) |
326 case _ => |
348 case _ => |
327 for ((prop, i) <- props.zipWithIndex) |
349 for ((fact, i) <- facts.zipWithIndex) |
328 yield Fact_Single(entity.copy(name = entity.name + "(" + (i + 1) + ")"), prop) |
350 yield Fact_Single(entity.copy(name = entity.name + "(" + (i + 1) + ")"), fact) |
329 } |
351 } |
330 } |
352 } |
331 |
353 |
332 def read_axioms(provider: Export.Provider): List[Fact_Single] = |
354 def read_axioms(provider: Export.Provider): List[Fact_Single] = |
333 provider.uncompressed_yxml(export_prefix + "axioms").map((tree: XML.Tree) => |
355 provider.uncompressed_yxml(export_prefix + "axioms").map((tree: XML.Tree) => |
334 { |
356 { |
335 val (entity, body) = decode_entity(Kind.AXIOM, tree) |
357 val (entity, body) = decode_entity(Kind.AXIOM, tree) |
336 val prop = decode_prop(body) |
358 val prop = decode_prop(body) |
337 Fact_Single(entity, prop) |
359 Fact_Single(entity, Fact(prop, None)) |
338 }) |
360 }) |
339 |
361 |
340 def read_facts(provider: Export.Provider): List[Fact_Multi] = |
362 def read_facts(provider: Export.Provider): List[Fact_Multi] = |
341 provider.uncompressed_yxml(export_prefix + "facts").map((tree: XML.Tree) => |
363 provider.uncompressed_yxml(export_prefix + "facts").map((tree: XML.Tree) => |
342 { |
364 { |
343 val (entity, body) = decode_entity(Kind.FACT, tree) |
365 val (entity, body) = decode_entity(Kind.FACT, tree) |
344 val props = XML.Decode.list(decode_prop)(body) |
366 val facts = XML.Decode.list(decode_fact)(body) |
345 Fact_Multi(entity, props) |
367 Fact_Multi(entity, facts) |
346 }) |
368 }) |
347 |
369 |
348 |
370 |
349 /* type classes */ |
371 /* type classes */ |
350 |
372 |