quotient_info.ML
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Thu, 12 Nov 2009 13:56:07 +0100
changeset 314 3b3c5feb6b73
parent 311 77fc6f3c0343
child 318 746b17e1d6d8
permissions -rw-r--r--
merged
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
signature QUOTIENT_INFO =
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
sig
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
  type maps_info = {mapfun: string, relfun: string}
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
  val maps_lookup: theory -> string -> maps_info option
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
  val maps_update_thy: string -> maps_info -> theory -> theory    
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
  val maps_update: string -> maps_info -> Proof.context -> Proof.context     
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
  type quotient_info = {qtyp: typ, rtyp: typ, rel: term, equiv_thm: thm}
310
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
     9
  val print_quotinfo: Proof.context -> unit
311
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
    10
  val quotdata_lookup_thy: theory -> string -> quotient_info option
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
    11
  val quotdata_lookup: Proof.context -> string -> quotient_info option
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
    12
  val quotdata_update_thy: string -> (typ * typ * term * thm) -> theory -> theory
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
    13
  val quotdata_update: string -> (typ * typ * term * thm) -> Proof.context -> Proof.context
268
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
    14
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
    15
  type qenv = (typ * typ) list
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
    16
  val mk_qenv: Proof.context -> qenv
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
    17
  val lookup_qenv: ((typ * typ) -> bool) -> qenv -> typ -> (typ * typ) option
310
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
    18
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
    19
  type qconsts_info = {qconst: term, rconst: term}
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
    20
  val qconsts_lookup: theory -> string -> qconsts_info option
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
    21
  val qconsts_update_thy: string -> qconsts_info -> theory -> theory    
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
    22
  val qconsts_update: string -> qconsts_info -> Proof.context -> Proof.context 
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
    23
  val print_qconstinfo: Proof.context -> unit
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
end;
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
structure Quotient_Info: QUOTIENT_INFO =
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
struct
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
268
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
    29
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
(* data containers *)
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
(*******************)
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
(* info about map- and rel-functions *)
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
type maps_info = {mapfun: string, relfun: string}
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
306
e7279efbe3dd updated to new Theory_Data and to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
    36
structure MapsData = Theory_Data
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
  (type T = maps_info Symtab.table
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
   val empty = Symtab.empty
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
   val extend = I
306
e7279efbe3dd updated to new Theory_Data and to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
    40
   val merge = Symtab.merge (K true))
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
val maps_lookup = Symtab.lookup o MapsData.get
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
fun maps_update_thy k minfo = MapsData.map (Symtab.update (k, minfo))
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
fun maps_update k minfo = ProofContext.theory (maps_update_thy k minfo)
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
fun maps_attribute_aux s minfo = Thm.declaration_attribute 
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
  (fn thm => Context.mapping (maps_update_thy s minfo) (maps_update s minfo))
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
(* attribute to be used in declare statements *)
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
fun maps_attribute (ctxt, (tystr, (mapstr, relstr))) = 
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
let  
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
  val thy = ProofContext.theory_of ctxt
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
  val tyname = Sign.intern_type thy tystr
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  val mapname = Sign.intern_const thy mapstr
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
  val relname = Sign.intern_const thy relstr
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
in
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
  maps_attribute_aux tyname {mapfun = mapname, relfun = relname}
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
end
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
val maps_attr_parser = 
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
      Args.context -- Scan.lift
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
       ((Args.name --| OuterParse.$$$ "=") -- 
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
         (OuterParse.$$$ "(" |-- Args.name --| OuterParse.$$$ "," -- 
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
           Args.name --| OuterParse.$$$ ")"))
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
val _ = Context.>> (Context.map_theory
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
         (Attrib.setup @{binding "map"} (maps_attr_parser >> maps_attribute) 
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
           "declaration of map information"))
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
(* info about the quotient types *)
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
type quotient_info = {qtyp: typ, rtyp: typ, rel: term, equiv_thm: thm}
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
306
e7279efbe3dd updated to new Theory_Data and to new Isabelle
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
    75
structure QuotData = Theory_Data
311
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
    76
  (type T = quotient_info Symtab.table
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
    77
   val empty = Symtab.empty
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
   val extend = I
311
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
    79
   val merge = Symtab.merge (K true)) 
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
311
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
    81
val quotdata_lookup_thy = Symtab.lookup o QuotData.get
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
    82
val quotdata_lookup = quotdata_lookup_thy o ProofContext.theory_of
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
314
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 311
diff changeset
    84
fun quotdata_update_thy qty_name (qty, rty, rel, equiv_thm) =
311
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
    85
      QuotData.map (Symtab.update (qty_name, {qtyp = qty, rtyp = rty, rel = rel, equiv_thm = equiv_thm}))
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
311
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
    87
fun quotdata_update qty_name (qty, rty, rel, equiv_thm) = 
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
    88
      ProofContext.theory (quotdata_update_thy qty_name (qty, rty, rel, equiv_thm))
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
310
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
    90
fun print_quotinfo ctxt =
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
let
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
  fun prt_quot {qtyp, rtyp, rel, equiv_thm} = 
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
      Pretty.block (Library.separate (Pretty.brk 2)
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
          [Pretty.str ("quotient type:"), 
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
           Syntax.pretty_typ ctxt qtyp,
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
           Pretty.str ("raw type:"), 
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
           Syntax.pretty_typ ctxt rtyp,
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
           Pretty.str ("relation:"), 
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
           Syntax.pretty_term ctxt rel,
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
           Pretty.str ("equiv. thm:"), 
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
           Syntax.pretty_term ctxt (prop_of equiv_thm)])
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
in
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
  QuotData.get (ProofContext.theory_of ctxt)
311
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
   104
  |> Symtab.dest
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
   105
  |> map (prt_quot o snd)
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
  |> Pretty.big_list "quotients:" 
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
  |> Pretty.writeln
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
end
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
val _ = 
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
  OuterSyntax.improper_command "print_quotients" "print out all quotients" 
310
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   112
    OuterKeyword.diag (Scan.succeed (Toplevel.keep (print_quotinfo o Toplevel.context_of)))
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
268
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   114
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   115
(* environments of quotient and raw types *)
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   116
type qenv = (typ * typ) list
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   117
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   118
fun mk_qenv ctxt =
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   119
let
311
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
   120
  val thy = ProofContext.theory_of ctxt
77fc6f3c0343 changed the quotdata to be a symtab table (needs fixing)
Christian Urban <urbanc@in.tum.de>
parents: 310
diff changeset
   121
  val qinfo = (QuotData.get thy) |> Symtab.dest |> map snd
268
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   122
in
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   123
  map (fn {qtyp, rtyp, ...} => (qtyp, rtyp)) qinfo
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   124
end
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   125
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   126
fun lookup_qenv _ [] _ = NONE
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   127
  | lookup_qenv eq ((qty, rty)::xs) qty' =
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   128
      if eq (qty', qty) then SOME (qty, rty)
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   129
      else lookup_qenv eq xs qty'
4d58c02289ca simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
   130
310
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   131
(* information about quotient constants *)
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   132
type qconsts_info = {qconst: term, rconst: term}
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   133
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   134
structure QConstsData = Theory_Data
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   135
  (type T = qconsts_info Symtab.table
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   136
   val empty = Symtab.empty
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   137
   val extend = I
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   138
   val merge = Symtab.merge (K true))
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   139
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   140
val qconsts_lookup = Symtab.lookup o QConstsData.get
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   141
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   142
fun qconsts_update_thy k qcinfo = QConstsData.map (Symtab.update (k, qcinfo))
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   143
fun qconsts_update k qcinfo = ProofContext.theory (qconsts_update_thy k qcinfo)
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   144
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   145
fun print_qconstinfo ctxt =
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   146
let
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   147
  fun prt_qconst {qconst, rconst} = 
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   148
      Pretty.block (Library.separate (Pretty.brk 2)
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   149
          [Syntax.pretty_term ctxt qconst,
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   150
           Pretty.str (" := "),
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   151
           Syntax.pretty_term ctxt rconst])
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   152
in
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   153
  QConstsData.get (ProofContext.theory_of ctxt)
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   154
  |> Symtab.dest
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   155
  |> map (prt_qconst o snd)
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   156
  |> Pretty.big_list "quotient constants:" 
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   157
  |> Pretty.writeln
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   158
end
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   159
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   160
val _ = 
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   161
  OuterSyntax.improper_command "print_quotconsts" "print out all quotient constants" 
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   162
    OuterKeyword.diag (Scan.succeed (Toplevel.keep (print_qconstinfo o Toplevel.context_of)))
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   163
fec6301a1989 added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
parents: 306
diff changeset
   164
264
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
end; (* structure *)
d0581fbc096c split quotient.ML into two files
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
314
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 311
diff changeset
   167
open Quotient_Info