src/HOL/Tools/Function/partial_function.ML
changeset 57959 1bfed12a7646
parent 54883 dd04a8b654fc
child 58839 ccda99401bc8
equal deleted inserted replaced
57958:045c96e3edf0 57959:1bfed12a7646
     4 Partial function definitions based on least fixed points in ccpos.
     4 Partial function definitions based on least fixed points in ccpos.
     5 *)
     5 *)
     6 
     6 
     7 signature PARTIAL_FUNCTION =
     7 signature PARTIAL_FUNCTION =
     8 sig
     8 sig
     9   val setup: theory -> theory
       
    10   val init: string -> term -> term -> thm -> thm -> thm option -> declaration
     9   val init: string -> term -> term -> thm -> thm -> thm option -> declaration
    11 
    10 
    12   val mono_tac: Proof.context -> int -> tactic
    11   val mono_tac: Proof.context -> int -> tactic
    13 
    12 
    14   val add_partial_function: string -> (binding * typ option * mixfix) list ->
    13   val add_partial_function: string -> (binding * typ option * mixfix) list ->
    50     Modes.map (Symtab.update (mode, data'))
    49     Modes.map (Symtab.update (mode, data'))
    51   end
    50   end
    52 
    51 
    53 val known_modes = Symtab.keys o Modes.get o Context.Proof;
    52 val known_modes = Symtab.keys o Modes.get o Context.Proof;
    54 val lookup_mode = Symtab.lookup o Modes.get o Context.Proof;
    53 val lookup_mode = Symtab.lookup o Modes.get o Context.Proof;
    55 
       
    56 
       
    57 structure Mono_Rules = Named_Thms
       
    58 (
       
    59   val name = @{binding partial_function_mono};
       
    60   val description = "monotonicity rules for partial function definitions";
       
    61 );
       
    62 
    54 
    63 
    55 
    64 (*** Automated monotonicity proofs ***)
    56 (*** Automated monotonicity proofs ***)
    65 
    57 
    66 fun strip_cases ctac = ctac #> Seq.map snd;
    58 fun strip_cases ctac = ctac #> Seq.map snd;
   107 
    99 
   108 (*monotonicity proof: apply rules + split case expressions*)
   100 (*monotonicity proof: apply rules + split case expressions*)
   109 fun mono_tac ctxt =
   101 fun mono_tac ctxt =
   110   K (Local_Defs.unfold_tac ctxt [@{thm curry_def}])
   102   K (Local_Defs.unfold_tac ctxt [@{thm curry_def}])
   111   THEN' (TRY o REPEAT_ALL_NEW
   103   THEN' (TRY o REPEAT_ALL_NEW
   112    (resolve_tac (Mono_Rules.get ctxt)
   104    (resolve_tac (rev (Named_Theorems.get ctxt @{named_theorems partial_function_mono}))
   113      ORELSE' split_cases_tac ctxt));
   105      ORELSE' split_cases_tac ctxt));
   114 
   106 
   115 
   107 
   116 (*** Auxiliary functions ***)
   108 (*** Auxiliary functions ***)
   117 
   109 
   319 val _ =
   311 val _ =
   320   Outer_Syntax.local_theory @{command_spec "partial_function"} "define partial function"
   312   Outer_Syntax.local_theory @{command_spec "partial_function"} "define partial function"
   321     ((mode -- (Parse.fixes -- (Parse.where_ |-- Parse_Spec.spec)))
   313     ((mode -- (Parse.fixes -- (Parse.where_ |-- Parse_Spec.spec)))
   322       >> (fn (mode, (fixes, spec)) => add_partial_function_cmd mode fixes spec));
   314       >> (fn (mode, (fixes, spec)) => add_partial_function_cmd mode fixes spec));
   323 
   315 
   324 
       
   325 val setup = Mono_Rules.setup;
       
   326 
       
   327 end
   316 end