src/Tools/isac/BaseDefinitions/theoryC.sml
author wneuper <Walther.Neuper@jku.at>
Fri, 05 Aug 2022 08:45:37 +0200
changeset 60516 795d1352493a
parent 60500 59a3af532717
child 60557 0be383bdb883
permissions -rw-r--r--
finish Calc_Binop, add signature EXAMPLE
walther@59866
     1
(* Title:  BaseDefinitions/theoryC.sml
walther@59854
     2
   Author: Walther Neuper
walther@59854
     3
   (c) due to copyright terms
walther@59854
     4
walther@59865
     5
Probably this structure can be dropped due to improved reflection in Isabelle.
walther@59854
     6
*)
walther@59854
     7
signature THEORY_ISAC =
walther@59854
     8
sig
walther@59879
     9
  eqtype id
walther@59879
    10
  val cut_id: string -> id
walther@59856
    11
walther@60082
    12
  val last_isabelle_thy: theory
walther@60182
    13
  val session_specify_names: id list
walther@60081
    14
  val session_interpret_names: id list
walther@60081
    15
  val get_theory: id -> theory         (* restricted to Isac_Knowledge *)
walther@59879
    16
  val id_to_ctxt: id -> Proof.context
walther@59879
    17
walther@59879
    18
  val id_empty: id
walther@59854
    19
  val Isac: 'a -> theory
walther@59918
    20
  val parent_of: theory -> theory -> theory
walther@59965
    21
  val sub_common : theory * theory -> theory
wenzelm@60223
    22
\<^isac_test>\<open>
walther@60081
    23
  val get_thy: id -> theory            (* restricted to session Isac *)
wenzelm@60223
    24
\<close>
walther@59854
    25
end
walther@59854
    26
walther@59854
    27
(**)
walther@59854
    28
structure ThyC(**): THEORY_ISAC(**) =
walther@59854
    29
struct
walther@59854
    30
(**)
walther@59854
    31
walther@59879
    32
type id = string;
Walther@60428
    33
val id_empty = "empty_thy_id";
walther@59879
    34
fun cut_id dn = hd (space_explode "." dn);
walther@59865
    35
walther@60082
    36
val last_isabelle_thy = @{theory Complex_Main}
walther@60182
    37
val session_specify_names = ["Specify", "MathEngBasic", "Input_Descript",
Walther@60516
    38
  "ProgLang", "Auto_Prog", "Prog_Expr", "Tactical", "Prog_Tac", "Program", "ListC", "Calc_Binop",
walther@60081
    39
  "BaseDefinitions", "Know_Store"]
walther@60182
    40
val session_interpret_names = ["Interpret"]
walther@60227
    41
(*this is troublesome since the introduction of sessions*)
walther@60081
    42
fun get_thy thyID =
walther@60182
    43
  if member op = session_specify_names thyID
walther@60182
    44
  then Thy_Info.get_theory ("Specify." ^ thyID)
walther@60182
    45
  else if member op = session_interpret_names thyID
walther@60081
    46
  then Thy_Info.get_theory ("Interpret." ^ thyID)
walther@60081
    47
  else Thy_Info.get_theory ("Isac." ^ thyID);
walther@60081
    48
fun get_theory thy =   
Walther@60428
    49
    if thy = id_empty
walther@59881
    50
    then (get_thy "Base_Tools") (*lower bound of Knowledge*)
walther@60264
    51
    else (get_thy thy) handle ERROR _ => raise ERROR ("ME_Isa: thy \"" ^ thy ^ "\" not in system");
walther@59881
    52
walther@59879
    53
fun id_to_ctxt thy' = Proof_Context.init_global (get_theory thy');
walther@59879
    54
Walther@60500
    55
fun Isac _ = 
Walther@60500
    56
 (get_theory "Isac_Knowledge");
walther@59879
    57
walther@59918
    58
fun parent_of thy1 thy2 = if Context.subthy (thy1, thy2) then thy2 else thy1;
walther@59918
    59
walther@59965
    60
fun sub_common (thy1, thy2) =
walther@59965
    61
  if Context.subthy (thy1, thy2) then
walther@59965
    62
    thy2
walther@59965
    63
  else if Context.subthy (thy2, thy1) then
walther@59965
    64
      thy1
walther@59965
    65
    else get_theory "Isac_Knowledge"
walther@59965
    66
walther@59858
    67
(**)end(**)