src/HOL/Tools/Function/partial_function.ML
changeset 42949 618adb3584e5
parent 42495 1af81b70cf09
child 43080 73a1d6a7ef1d
equal deleted inserted replaced
42948:e6990acab6ff 42949:618adb3584e5
     5 *)
     5 *)
     6 
     6 
     7 signature PARTIAL_FUNCTION =
     7 signature PARTIAL_FUNCTION =
     8 sig
     8 sig
     9   val setup: theory -> theory
     9   val setup: theory -> theory
    10   val init: term -> term -> thm -> declaration
    10   val init: string -> term -> term -> thm -> declaration
    11 
    11 
    12   val add_partial_function: string -> (binding * typ option * mixfix) list ->
    12   val add_partial_function: string -> (binding * typ option * mixfix) list ->
    13     Attrib.binding * term -> local_theory -> local_theory
    13     Attrib.binding * term -> local_theory -> local_theory
    14 
    14 
    15   val add_partial_function_cmd: string -> (binding * string option * mixfix) list ->
    15   val add_partial_function_cmd: string -> (binding * string option * mixfix) list ->
    28   val empty = Symtab.empty;
    28   val empty = Symtab.empty;
    29   val extend = I;
    29   val extend = I;
    30   fun merge data = Symtab.merge (K true) data;
    30   fun merge data = Symtab.merge (K true) data;
    31 )
    31 )
    32 
    32 
    33 fun init fixp mono fixp_eq phi =
    33 fun init mode fixp mono fixp_eq phi =
    34   let
    34   let
    35     val term = Morphism.term phi;
    35     val term = Morphism.term phi;
    36     val data' = ((term fixp, term mono), Morphism.thm phi fixp_eq);
    36     val data' = ((term fixp, term mono), Morphism.thm phi fixp_eq);
    37     val mode = (* extract mode identifier from morphism prefix! *)
    37   in
    38       Binding.prefix_of (Morphism.binding phi (Binding.empty))
    38     Modes.map (Symtab.update (mode, data'))
    39       |> map fst |> space_implode ".";
       
    40   in
       
    41     if mode = "" then I
       
    42     else Modes.map (Symtab.update (mode, data'))
       
    43   end
    39   end
    44 
    40 
    45 val known_modes = Symtab.keys o Modes.get o Context.Proof;
    41 val known_modes = Symtab.keys o Modes.get o Context.Proof;
    46 val lookup_mode = Symtab.lookup o Modes.get o Context.Proof;
    42 val lookup_mode = Symtab.lookup o Modes.get o Context.Proof;
    47 
    43