more operations: support type classes within the logic;
authorwenzelm
Sat, 20 Jul 2019 14:03:51 +0200
changeset 70385 68d2c533db9c
parent 70384 8ce08b154aa1
child 70386 6af87375b95f
more operations: support type classes within the logic;
src/Pure/pure_thy.scala
src/Pure/term.scala
--- a/src/Pure/pure_thy.scala	Sat Jul 20 12:52:29 2019 +0200
+++ b/src/Pure/pure_thy.scala	Sat Jul 20 14:03:51 2019 +0200
@@ -19,6 +19,7 @@
   val ALL: String = "Pure.all"
   val IMP: String = "Pure.imp"
   val EQ: String = "Pure.eq"
+  val TYPE: String = "Pure.type"
 
 
   /* proof terms (abstract syntax) */
--- a/src/Pure/term.scala	Sat Jul 20 12:52:29 2019 +0200
+++ b/src/Pure/term.scala	Sat Jul 20 14:03:51 2019 +0200
@@ -33,6 +33,24 @@
   case class App(fun: Term, arg: Term) extends Term
 
 
+  /* Pure logic */
+
+  def itselfT(ty: Typ): Typ = Type(Pure_Thy.ITSELF, List(ty))
+  val propT: Typ = Type(Pure_Thy.PROP, Nil)
+  def funT(ty1: Typ, ty2: Typ): Typ = Type(Pure_Thy.FUN, List(ty1, ty2))
+
+  def mk_type(ty: Typ): Term = Const(Pure_Thy.TYPE, itselfT(ty))
+
+  def const_of_class(c: String): String = c + "_class"
+
+  def mk_of_sort(ty: Typ, s: Sort): List[Term] =
+  {
+    val class_type = funT(itselfT(ty), propT)
+    val t = mk_type(ty)
+    s.map(c => App(Const(const_of_class(c), class_type), t))
+  }
+
+
   /* type arguments of consts */
 
   def const_typargs(name: String, typ: Typ, typargs: List[String], decl: Typ): List[Typ] =