| 
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  | 
  | 
| 
 | 
    14  | 
  sealed case class Session(name: String, theory_graph: Graph[String, Theory])
  | 
| 
 | 
    15  | 
  {
 | 
| 
 | 
    16  | 
    override def toString: String = name
  | 
| 
 | 
    17  | 
  | 
| 
 | 
    18  | 
    def theory(theory_name: String): Theory =
  | 
| 
 | 
    19  | 
      if (theory_graph.defined(theory_name)) theory_graph.get_node(theory_name)
  | 
| 
 | 
    20  | 
      else error("Bad theory " + quote(theory_name))
 | 
| 
 | 
    21  | 
  | 
| 
 | 
    22  | 
    def theories: List[Theory] =
  | 
| 
 | 
    23  | 
      theory_graph.topological_order.map(theory_graph.get_node(_))
  | 
| 
 | 
    24  | 
  }
  | 
| 
 | 
    25  | 
  | 
| 
68209
 | 
    26  | 
  def read_session(store: Sessions.Store,
  | 
| 
 | 
    27  | 
    session_name: String,
  | 
| 
68206
 | 
    28  | 
    types: Boolean = true,
  | 
| 
68264
 | 
    29  | 
    consts: Boolean = true,
  | 
| 
 | 
    30  | 
    axioms: Boolean = true,
  | 
| 
 | 
    31  | 
    facts: Boolean = true,
  | 
| 
 | 
    32  | 
    classes: Boolean = true,
  | 
| 
68267
 | 
    33  | 
    typedefs: Boolean = true,
  | 
| 
68295
 | 
    34  | 
    classrel: Boolean = true,
  | 
| 
 | 
    35  | 
    arities: Boolean = true,
  | 
| 
68267
 | 
    36  | 
    cache: Term.Cache = Term.make_cache()): Session =
  | 
| 
68206
 | 
    37  | 
  {
 | 
| 
 | 
    38  | 
    val thys =
  | 
| 
68210
 | 
    39  | 
      using(store.open_database(session_name))(db =>
  | 
| 
68206
 | 
    40  | 
      {
 | 
| 
 | 
    41  | 
        db.transaction {
 | 
| 
68222
 | 
    42  | 
          Export.read_theory_names(db, session_name).map((theory_name: String) =>
  | 
| 
68418
 | 
    43  | 
            read_theory(Export.Provider.database(db, session_name, theory_name),
  | 
| 
 | 
    44  | 
              session_name, theory_name, types = types, consts = consts,
  | 
| 
68267
 | 
    45  | 
              axioms = axioms, facts = facts, classes = classes, typedefs = typedefs,
  | 
| 
 | 
    46  | 
              cache = Some(cache)))
  | 
| 
68206
 | 
    47  | 
        }
  | 
| 
 | 
    48  | 
      })
  | 
| 
 | 
    49  | 
  | 
| 
 | 
    50  | 
    val graph0 =
  | 
| 
 | 
    51  | 
      (Graph.string[Theory] /: thys) { case (g, thy) => g.new_node(thy.name, thy) }
 | 
| 
 | 
    52  | 
    val graph1 =
  | 
| 
 | 
    53  | 
      (graph0 /: thys) { case (g0, thy) =>
 | 
| 
 | 
    54  | 
        (g0 /: thy.parents) { case (g1, parent) =>
 | 
| 
 | 
    55  | 
          g1.default_node(parent, empty_theory(parent)).add_edge_acyclic(parent, thy.name) } }
  | 
| 
 | 
    56  | 
  | 
| 
 | 
    57  | 
    Session(session_name, graph1)
  | 
| 
 | 
    58  | 
  }
  | 
| 
 | 
    59  | 
  | 
| 
 | 
    60  | 
  | 
| 
 | 
    61  | 
  | 
| 
68203
 | 
    62  | 
  /** theory content **/
  | 
| 
 | 
    63  | 
  | 
| 
68346
 | 
    64  | 
  val export_prefix: String = "theory/"
  | 
| 
 | 
    65  | 
  | 
| 
68208
 | 
    66  | 
  sealed case class Theory(name: String, parents: List[String],
  | 
| 
 | 
    67  | 
    types: List[Type],
  | 
| 
 | 
    68  | 
    consts: List[Const],
  | 
| 
68232
 | 
    69  | 
    axioms: List[Axiom],
  | 
| 
68264
 | 
    70  | 
    facts: List[Fact],
  | 
| 
 | 
    71  | 
    classes: List[Class],
  | 
| 
68295
 | 
    72  | 
    typedefs: List[Typedef],
  | 
| 
 | 
    73  | 
    classrel: List[Classrel],
  | 
| 
 | 
    74  | 
    arities: List[Arity])
  | 
| 
68206
 | 
    75  | 
  {
 | 
| 
 | 
    76  | 
    override def toString: String = name
  | 
| 
68267
 | 
    77  | 
  | 
| 
68711
 | 
    78  | 
    lazy val entities: Set[Long] =
  | 
| 
 | 
    79  | 
      Set.empty[Long] ++
  | 
| 
 | 
    80  | 
        types.iterator.map(_.entity.serial) ++
  | 
| 
 | 
    81  | 
        consts.iterator.map(_.entity.serial) ++
  | 
| 
 | 
    82  | 
        axioms.iterator.map(_.entity.serial) ++
  | 
| 
 | 
    83  | 
        facts.iterator.map(_.entity.serial) ++
  | 
| 
 | 
    84  | 
        classes.iterator.map(_.entity.serial)
  | 
| 
 | 
    85  | 
  | 
| 
68267
 | 
    86  | 
    def cache(cache: Term.Cache): Theory =
  | 
| 
 | 
    87  | 
      Theory(cache.string(name),
  | 
| 
 | 
    88  | 
        parents.map(cache.string(_)),
  | 
| 
 | 
    89  | 
        types.map(_.cache(cache)),
  | 
| 
 | 
    90  | 
        consts.map(_.cache(cache)),
  | 
| 
 | 
    91  | 
        axioms.map(_.cache(cache)),
  | 
| 
 | 
    92  | 
        facts.map(_.cache(cache)),
  | 
| 
 | 
    93  | 
        classes.map(_.cache(cache)),
  | 
| 
68295
 | 
    94  | 
        typedefs.map(_.cache(cache)),
  | 
| 
 | 
    95  | 
        classrel.map(_.cache(cache)),
  | 
| 
 | 
    96  | 
        arities.map(_.cache(cache)))
  | 
| 
68206
 | 
    97  | 
  }
  | 
| 
 | 
    98  | 
  | 
| 
68295
 | 
    99  | 
  def empty_theory(name: String): Theory =
  | 
| 
 | 
   100  | 
    Theory(name, Nil, Nil, Nil, Nil, Nil, Nil, Nil, Nil, Nil)
  | 
| 
68203
 | 
   101  | 
  | 
| 
68418
 | 
   102  | 
  def read_theory(provider: Export.Provider, session_name: String, theory_name: String,
  | 
| 
68203
 | 
   103  | 
    types: Boolean = true,
  | 
| 
68208
 | 
   104  | 
    consts: Boolean = true,
  | 
| 
68232
 | 
   105  | 
    axioms: Boolean = true,
  | 
| 
68264
 | 
   106  | 
    facts: Boolean = true,
  | 
| 
 | 
   107  | 
    classes: Boolean = true,
  | 
| 
68267
 | 
   108  | 
    typedefs: Boolean = true,
  | 
| 
68295
 | 
   109  | 
    classrel: Boolean = true,
  | 
| 
 | 
   110  | 
    arities: Boolean = true,
  | 
| 
68267
 | 
   111  | 
    cache: Option[Term.Cache] = None): Theory =
  | 
| 
68203
 | 
   112  | 
  {
 | 
| 
68206
 | 
   113  | 
    val parents =
  | 
| 
68418
 | 
   114  | 
      provider(export_prefix + "parents") match {
 | 
| 
68231
 | 
   115  | 
        case Some(entry) => split_lines(entry.uncompressed().text)
  | 
| 
68206
 | 
   116  | 
        case None =>
  | 
| 
 | 
   117  | 
          error("Missing theory export in session " + quote(session_name) + ": " +
 | 
| 
 | 
   118  | 
            quote(theory_name))
  | 
| 
 | 
   119  | 
      }
  | 
| 
68267
 | 
   120  | 
    val theory =
  | 
| 
 | 
   121  | 
      Theory(theory_name, parents,
  | 
| 
68418
 | 
   122  | 
        if (types) read_types(provider) else Nil,
  | 
| 
 | 
   123  | 
        if (consts) read_consts(provider) else Nil,
  | 
| 
 | 
   124  | 
        if (axioms) read_axioms(provider) else Nil,
  | 
| 
 | 
   125  | 
        if (facts) read_facts(provider) else Nil,
  | 
| 
 | 
   126  | 
        if (classes) read_classes(provider) else Nil,
  | 
| 
 | 
   127  | 
        if (typedefs) read_typedefs(provider) else Nil,
  | 
| 
 | 
   128  | 
        if (classrel) read_classrel(provider) else Nil,
  | 
| 
 | 
   129  | 
        if (arities) read_arities(provider) else Nil)
  | 
| 
68267
 | 
   130  | 
    if (cache.isDefined) theory.cache(cache.get) else theory
  | 
| 
68203
 | 
   131  | 
  }
  | 
| 
 | 
   132  | 
  | 
| 
68711
 | 
   133  | 
  def read_pure_theory(store: Sessions.Store, cache: Option[Term.Cache] = None): Theory =
  | 
| 
68710
 | 
   134  | 
  {
 | 
| 
 | 
   135  | 
    val session_name = Thy_Header.PURE
  | 
| 
 | 
   136  | 
    val theory_name = Thy_Header.PURE
  | 
| 
 | 
   137  | 
  | 
| 
 | 
   138  | 
    using(store.open_database(session_name))(db =>
  | 
| 
 | 
   139  | 
    {
 | 
| 
 | 
   140  | 
      db.transaction {
 | 
| 
 | 
   141  | 
        read_theory(Export.Provider.database(db, session_name, theory_name),
  | 
| 
68711
 | 
   142  | 
          session_name, theory_name, cache = cache)
  | 
| 
68710
 | 
   143  | 
      }
  | 
| 
 | 
   144  | 
    })
  | 
| 
 | 
   145  | 
  }
  | 
| 
 | 
   146  | 
  | 
| 
68203
 | 
   147  | 
  | 
| 
68171
 | 
   148  | 
  /* entities */
  | 
| 
 | 
   149  | 
  | 
| 
68172
 | 
   150  | 
  sealed case class Entity(name: String, serial: Long, pos: Position.T)
  | 
| 
68171
 | 
   151  | 
  {
 | 
| 
 | 
   152  | 
    override def toString: String = name
  | 
| 
68267
 | 
   153  | 
  | 
| 
 | 
   154  | 
    def cache(cache: Term.Cache): Entity =
  | 
| 
 | 
   155  | 
      Entity(cache.string(name), serial, cache.position(pos))
  | 
| 
68171
 | 
   156  | 
  }
  | 
| 
 | 
   157  | 
  | 
| 
 | 
   158  | 
  def decode_entity(tree: XML.Tree): (Entity, XML.Body) =
  | 
| 
 | 
   159  | 
  {
 | 
| 
 | 
   160  | 
    def err(): Nothing = throw new XML.XML_Body(List(tree))
  | 
| 
 | 
   161  | 
  | 
| 
 | 
   162  | 
    tree match {
 | 
| 
 | 
   163  | 
      case XML.Elem(Markup(Markup.ENTITY, props), body) =>
  | 
| 
 | 
   164  | 
        val name = Markup.Name.unapply(props) getOrElse err()
  | 
| 
 | 
   165  | 
        val serial = Markup.Serial.unapply(props) getOrElse err()
  | 
| 
 | 
   166  | 
        val pos = props.filter({ case (a, _) => Markup.POSITION_PROPERTIES(a) })
 | 
| 
68172
 | 
   167  | 
        (Entity(name, serial, pos), body)
  | 
| 
68171
 | 
   168  | 
      case _ => err()
  | 
| 
 | 
   169  | 
    }
  | 
| 
 | 
   170  | 
  }
  | 
| 
 | 
   171  | 
  | 
| 
 | 
   172  | 
  | 
| 
 | 
   173  | 
  /* types */
  | 
| 
 | 
   174  | 
  | 
| 
 | 
   175  | 
  sealed case class Type(entity: Entity, args: List[String], abbrev: Option[Term.Typ])
  | 
| 
68267
 | 
   176  | 
  {
 | 
| 
68712
 | 
   177  | 
    def kind: String = "type"
  | 
| 
 | 
   178  | 
  | 
| 
68267
 | 
   179  | 
    def cache(cache: Term.Cache): Type =
  | 
| 
 | 
   180  | 
      Type(entity.cache(cache),
  | 
| 
 | 
   181  | 
        args.map(cache.string(_)),
  | 
| 
 | 
   182  | 
        abbrev.map(cache.typ(_)))
  | 
| 
 | 
   183  | 
  }
  | 
| 
68171
 | 
   184  | 
  | 
| 
68418
 | 
   185  | 
  def read_types(provider: Export.Provider): List[Type] =
  | 
| 
 | 
   186  | 
    provider.uncompressed_yxml(export_prefix + "types").map((tree: XML.Tree) =>
  | 
| 
 | 
   187  | 
      {
 | 
| 
 | 
   188  | 
        val (entity, body) = decode_entity(tree)
  | 
| 
 | 
   189  | 
        val (args, abbrev) =
  | 
| 
68203
 | 
   190  | 
        {
 | 
| 
68418
 | 
   191  | 
          import XML.Decode._
  | 
| 
 | 
   192  | 
          pair(list(string), option(Term_XML.Decode.typ))(body)
  | 
| 
 | 
   193  | 
        }
  | 
| 
 | 
   194  | 
        Type(entity, args, abbrev)
  | 
| 
 | 
   195  | 
      })
  | 
| 
68171
 | 
   196  | 
  | 
| 
 | 
   197  | 
  | 
| 
 | 
   198  | 
  /* consts */
  | 
| 
 | 
   199  | 
  | 
| 
68173
 | 
   200  | 
  sealed case class Const(
  | 
| 
 | 
   201  | 
    entity: Entity, typargs: List[String], typ: Term.Typ, abbrev: Option[Term.Term])
  | 
| 
68267
 | 
   202  | 
  {
 | 
| 
68712
 | 
   203  | 
    def kind: String = "const"
  | 
| 
 | 
   204  | 
  | 
| 
68267
 | 
   205  | 
    def cache(cache: Term.Cache): Const =
  | 
| 
 | 
   206  | 
      Const(entity.cache(cache),
  | 
| 
 | 
   207  | 
        typargs.map(cache.string(_)),
  | 
| 
 | 
   208  | 
        cache.typ(typ),
  | 
| 
 | 
   209  | 
        abbrev.map(cache.term(_)))
  | 
| 
 | 
   210  | 
  }
  | 
| 
68171
 | 
   211  | 
  | 
| 
68418
 | 
   212  | 
  def read_consts(provider: Export.Provider): List[Const] =
  | 
| 
 | 
   213  | 
    provider.uncompressed_yxml(export_prefix + "consts").map((tree: XML.Tree) =>
  | 
| 
 | 
   214  | 
      {
 | 
| 
 | 
   215  | 
        val (entity, body) = decode_entity(tree)
  | 
| 
 | 
   216  | 
        val (args, typ, abbrev) =
  | 
| 
68203
 | 
   217  | 
        {
 | 
| 
68418
 | 
   218  | 
          import XML.Decode._
  | 
| 
 | 
   219  | 
          triple(list(string), Term_XML.Decode.typ, option(Term_XML.Decode.term))(body)
  | 
| 
 | 
   220  | 
        }
  | 
| 
 | 
   221  | 
        Const(entity, args, typ, abbrev)
  | 
| 
 | 
   222  | 
      })
  | 
| 
68208
 | 
   223  | 
  | 
| 
 | 
   224  | 
  | 
| 
68232
 | 
   225  | 
  /* axioms and facts */
  | 
| 
 | 
   226  | 
  | 
| 
 | 
   227  | 
  def decode_props(body: XML.Body):
  | 
| 
 | 
   228  | 
    (List[(String, Term.Sort)], List[(String, Term.Typ)], List[Term.Term]) =
  | 
| 
 | 
   229  | 
  {
 | 
| 
 | 
   230  | 
    import XML.Decode._
  | 
| 
 | 
   231  | 
    import Term_XML.Decode._
  | 
| 
 | 
   232  | 
    triple(list(pair(string, sort)), list(pair(string, typ)), list(term))(body)
  | 
| 
 | 
   233  | 
  }
  | 
| 
68208
 | 
   234  | 
  | 
| 
 | 
   235  | 
  sealed case class Axiom(
  | 
| 
 | 
   236  | 
    entity: Entity,
  | 
| 
 | 
   237  | 
    typargs: List[(String, Term.Sort)],
  | 
| 
 | 
   238  | 
    args: List[(String, Term.Typ)],
  | 
| 
 | 
   239  | 
    prop: Term.Term)
  | 
| 
68267
 | 
   240  | 
  {
 | 
| 
68712
 | 
   241  | 
    def kind: String = "axiom"
  | 
| 
 | 
   242  | 
  | 
| 
68267
 | 
   243  | 
    def cache(cache: Term.Cache): Axiom =
  | 
| 
 | 
   244  | 
      Axiom(entity.cache(cache),
  | 
| 
 | 
   245  | 
        typargs.map({ case (name, sort) => (cache.string(name), cache.sort(sort)) }),
 | 
| 
 | 
   246  | 
        args.map({ case (name, typ) => (cache.string(name), cache.typ(typ)) }),
 | 
| 
 | 
   247  | 
        cache.term(prop))
  | 
| 
 | 
   248  | 
  }
  | 
| 
68208
 | 
   249  | 
  | 
| 
68418
 | 
   250  | 
  def read_axioms(provider: Export.Provider): List[Axiom] =
  | 
| 
 | 
   251  | 
    provider.uncompressed_yxml(export_prefix + "axioms").map((tree: XML.Tree) =>
  | 
| 
 | 
   252  | 
      {
 | 
| 
 | 
   253  | 
        val (entity, body) = decode_entity(tree)
  | 
| 
 | 
   254  | 
        val (typargs, args, List(prop)) = decode_props(body)
  | 
| 
 | 
   255  | 
        Axiom(entity, typargs, args, prop)
  | 
| 
 | 
   256  | 
      })
  | 
| 
68232
 | 
   257  | 
  | 
| 
 | 
   258  | 
  sealed case class Fact(
  | 
| 
 | 
   259  | 
    entity: Entity,
  | 
| 
 | 
   260  | 
    typargs: List[(String, Term.Sort)],
  | 
| 
 | 
   261  | 
    args: List[(String, Term.Typ)],
  | 
| 
 | 
   262  | 
    props: List[Term.Term])
  | 
| 
68267
 | 
   263  | 
  {
 | 
| 
68712
 | 
   264  | 
    def kind: String = "fact"
  | 
| 
 | 
   265  | 
  | 
| 
68267
 | 
   266  | 
    def cache(cache: Term.Cache): Fact =
  | 
| 
 | 
   267  | 
      Fact(entity.cache(cache),
  | 
| 
 | 
   268  | 
        typargs.map({ case (name, sort) => (cache.string(name), cache.sort(sort)) }),
 | 
| 
 | 
   269  | 
        args.map({ case (name, typ) => (cache.string(name), cache.typ(typ)) }),
 | 
| 
 | 
   270  | 
        props.map(cache.term(_)))
  | 
| 
 | 
   271  | 
  }
  | 
| 
68232
 | 
   272  | 
  | 
| 
68418
 | 
   273  | 
  def read_facts(provider: Export.Provider): List[Fact] =
  | 
| 
 | 
   274  | 
    provider.uncompressed_yxml(export_prefix + "facts").map((tree: XML.Tree) =>
  | 
| 
 | 
   275  | 
      {
 | 
| 
 | 
   276  | 
        val (entity, body) = decode_entity(tree)
  | 
| 
 | 
   277  | 
        val (typargs, args, props) = decode_props(body)
  | 
| 
 | 
   278  | 
        Fact(entity, typargs, args, props)
  | 
| 
 | 
   279  | 
      })
  | 
| 
68264
 | 
   280  | 
  | 
| 
 | 
   281  | 
  | 
| 
 | 
   282  | 
  /* type classes */
  | 
| 
 | 
   283  | 
  | 
| 
 | 
   284  | 
  sealed case class Class(
  | 
| 
 | 
   285  | 
    entity: Entity, params: List[(String, Term.Typ)], axioms: List[Term.Term])
  | 
| 
68267
 | 
   286  | 
  {
 | 
| 
68712
 | 
   287  | 
    def kind: String = "class"
  | 
| 
 | 
   288  | 
  | 
| 
68267
 | 
   289  | 
    def cache(cache: Term.Cache): Class =
  | 
| 
 | 
   290  | 
      Class(entity.cache(cache),
  | 
| 
 | 
   291  | 
        params.map({ case (name, typ) => (cache.string(name), cache.typ(typ)) }),
 | 
| 
 | 
   292  | 
        axioms.map(cache.term(_)))
  | 
| 
 | 
   293  | 
  }
  | 
| 
68264
 | 
   294  | 
  | 
| 
68418
 | 
   295  | 
  def read_classes(provider: Export.Provider): List[Class] =
  | 
| 
 | 
   296  | 
    provider.uncompressed_yxml(export_prefix + "classes").map((tree: XML.Tree) =>
  | 
| 
 | 
   297  | 
      {
 | 
| 
 | 
   298  | 
        val (entity, body) = decode_entity(tree)
  | 
| 
 | 
   299  | 
        val (params, axioms) =
  | 
| 
68264
 | 
   300  | 
        {
 | 
| 
68418
 | 
   301  | 
          import XML.Decode._
  | 
| 
 | 
   302  | 
          import Term_XML.Decode._
  | 
| 
 | 
   303  | 
          pair(list(pair(string, typ)), list(term))(body)
  | 
| 
 | 
   304  | 
        }
  | 
| 
 | 
   305  | 
        Class(entity, params, axioms)
  | 
| 
 | 
   306  | 
      })
  | 
| 
68264
 | 
   307  | 
  | 
| 
 | 
   308  | 
  | 
| 
68295
 | 
   309  | 
  /* sort algebra */
  | 
| 
 | 
   310  | 
  | 
| 
 | 
   311  | 
  sealed case class Classrel(class_name: String, super_names: List[String])
  | 
| 
 | 
   312  | 
  {
 | 
| 
 | 
   313  | 
    def cache(cache: Term.Cache): Classrel =
  | 
| 
 | 
   314  | 
      Classrel(cache.string(class_name), super_names.map(cache.string(_)))
  | 
| 
 | 
   315  | 
  }
  | 
| 
 | 
   316  | 
  | 
| 
68418
 | 
   317  | 
  def read_classrel(provider: Export.Provider): List[Classrel] =
  | 
| 
 | 
   318  | 
  {
 | 
| 
 | 
   319  | 
    val body = provider.uncompressed_yxml(export_prefix + "classrel")
  | 
| 
 | 
   320  | 
    val classrel =
  | 
| 
 | 
   321  | 
    {
 | 
| 
 | 
   322  | 
      import XML.Decode._
  | 
| 
 | 
   323  | 
      list(pair(string, list(string)))(body)
  | 
| 
 | 
   324  | 
    }
  | 
| 
 | 
   325  | 
    for ((c, cs) <- classrel) yield Classrel(c, cs)
  | 
| 
 | 
   326  | 
  }
  | 
| 
68295
 | 
   327  | 
  | 
| 
 | 
   328  | 
  sealed case class Arity(type_name: String, domain: List[Term.Sort], codomain: String)
  | 
| 
 | 
   329  | 
  {
 | 
| 
 | 
   330  | 
    def cache(cache: Term.Cache): Arity =
  | 
| 
 | 
   331  | 
      Arity(cache.string(type_name), domain.map(cache.sort(_)), cache.string(codomain))
  | 
| 
 | 
   332  | 
  }
  | 
| 
 | 
   333  | 
  | 
| 
68418
 | 
   334  | 
  def read_arities(provider: Export.Provider): List[Arity] =
  | 
| 
 | 
   335  | 
  {
 | 
| 
 | 
   336  | 
    val body = provider.uncompressed_yxml(export_prefix + "arities")
  | 
| 
 | 
   337  | 
    val arities =
  | 
| 
 | 
   338  | 
    {
 | 
| 
 | 
   339  | 
      import XML.Decode._
  | 
| 
 | 
   340  | 
      import Term_XML.Decode._
  | 
| 
 | 
   341  | 
      list(triple(string, list(sort), string))(body)
  | 
| 
 | 
   342  | 
    }
  | 
| 
 | 
   343  | 
    for ((a, b, c) <- arities) yield Arity(a, b, c)
  | 
| 
 | 
   344  | 
  }
  | 
| 
68295
 | 
   345  | 
  | 
| 
 | 
   346  | 
  | 
| 
68264
 | 
   347  | 
  /* HOL typedefs */
  | 
| 
 | 
   348  | 
  | 
| 
 | 
   349  | 
  sealed case class Typedef(name: String,
  | 
| 
 | 
   350  | 
    rep_type: Term.Typ, abs_type: Term.Typ, rep_name: String, abs_name: String, axiom_name: String)
  | 
| 
68267
 | 
   351  | 
  {
 | 
| 
 | 
   352  | 
    def cache(cache: Term.Cache): Typedef =
  | 
| 
 | 
   353  | 
      Typedef(cache.string(name),
  | 
| 
 | 
   354  | 
        cache.typ(rep_type),
  | 
| 
 | 
   355  | 
        cache.typ(abs_type),
  | 
| 
 | 
   356  | 
        cache.string(rep_name),
  | 
| 
 | 
   357  | 
        cache.string(abs_name),
  | 
| 
 | 
   358  | 
        cache.string(axiom_name))
  | 
| 
 | 
   359  | 
  }
  | 
| 
68264
 | 
   360  | 
  | 
| 
68418
 | 
   361  | 
  def read_typedefs(provider: Export.Provider): List[Typedef] =
  | 
| 
 | 
   362  | 
  {
 | 
| 
 | 
   363  | 
    val body = provider.uncompressed_yxml(export_prefix + "typedefs")
  | 
| 
 | 
   364  | 
    val typedefs =
  | 
| 
 | 
   365  | 
    {
 | 
| 
 | 
   366  | 
      import XML.Decode._
  | 
| 
 | 
   367  | 
      import Term_XML.Decode._
  | 
| 
 | 
   368  | 
      list(pair(string, pair(typ, pair(typ, pair(string, pair(string, string))))))(body)
  | 
| 
 | 
   369  | 
    }
  | 
| 
 | 
   370  | 
    for { (name, (rep_type, (abs_type, (rep_name, (abs_name, axiom_name))))) <- typedefs }
 | 
| 
 | 
   371  | 
    yield Typedef(name, rep_type, abs_type, rep_name, abs_name, axiom_name)
  | 
| 
 | 
   372  | 
  }
  | 
| 
68171
 | 
   373  | 
}
  |