src/Pure/Thy/export_theory.scala
changeset 68208 d9f2cf4fc002
parent 68206 dedf1a70d1fa
child 68209 aeffd8f1f079
     1.1 --- a/src/Pure/Thy/export_theory.scala	Thu May 17 19:16:41 2018 +0200
     1.2 +++ b/src/Pure/Thy/export_theory.scala	Fri May 18 16:30:20 2018 +0200
     1.3 @@ -54,17 +54,20 @@
     1.4  
     1.5    /** theory content **/
     1.6  
     1.7 -  sealed case class Theory(
     1.8 -    name: String, parents: List[String], types: List[Type], consts: List[Const])
     1.9 +  sealed case class Theory(name: String, parents: List[String],
    1.10 +    types: List[Type],
    1.11 +    consts: List[Const],
    1.12 +    axioms: List[Axiom])
    1.13    {
    1.14      override def toString: String = name
    1.15    }
    1.16  
    1.17 -  def empty_theory(name: String): Theory = Theory(name, Nil, Nil, Nil)
    1.18 +  def empty_theory(name: String): Theory = Theory(name, Nil, Nil, Nil, Nil)
    1.19  
    1.20    def read_theory(db: SQL.Database, session_name: String, theory_name: String,
    1.21      types: Boolean = true,
    1.22 -    consts: Boolean = true): Theory =
    1.23 +    consts: Boolean = true,
    1.24 +    axioms: Boolean = true): Theory =
    1.25    {
    1.26      val parents =
    1.27        Export.read_entry(db, session_name, theory_name, "theory/parents") match {
    1.28 @@ -77,7 +80,8 @@
    1.29        }
    1.30      Theory(theory_name, parents,
    1.31        if (types) read_types(db, session_name, theory_name) else Nil,
    1.32 -      if (consts) read_consts(db, session_name, theory_name) else Nil)
    1.33 +      if (consts) read_consts(db, session_name, theory_name) else Nil,
    1.34 +      if (axioms) read_axioms(db, session_name, theory_name) else Nil)
    1.35    }
    1.36  
    1.37  
    1.38 @@ -147,4 +151,27 @@
    1.39            }
    1.40            Const(entity, args, typ, abbrev)
    1.41          })
    1.42 +
    1.43 +
    1.44 +  /* axioms */
    1.45 +
    1.46 +  sealed case class Axiom(
    1.47 +    entity: Entity,
    1.48 +    typargs: List[(String, Term.Sort)],
    1.49 +    args: List[(String, Term.Typ)],
    1.50 +    prop: Term.Term)
    1.51 +
    1.52 +  def read_axioms(db: SQL.Database, session_name: String, theory_name: String): List[Axiom] =
    1.53 +    read_entities(db, session_name, theory_name, "axioms",
    1.54 +      (tree: XML.Tree) =>
    1.55 +        {
    1.56 +          val (entity, body) = decode_entity(tree)
    1.57 +          val (typargs, args, prop) =
    1.58 +          {
    1.59 +            import XML.Decode._
    1.60 +            import Term_XML.Decode._
    1.61 +            triple(list(pair(string, sort)), list(pair(string, typ)), term)(body)
    1.62 +          }
    1.63 +          Axiom(entity, typargs, args, prop)
    1.64 +        })
    1.65  }