src/HOL/Data_Structures/Define_Time_Function.thy
changeset 80738 6adf6cc82013
parent 79973 7bbb0d65ce72
child 81088 28ef01901650
equal deleted inserted replaced
80737:6984640568b9 80738:6adf6cc82013
    32 running time functions must already have been defined.
    32 running time functions must already have been defined.
    33 If the definition of the function requires a manual termination proof,
    33 If the definition of the function requires a manual termination proof,
    34 use \<open>time_function\<close> accompanied by a \<open>termination\<close> command.
    34 use \<open>time_function\<close> accompanied by a \<open>termination\<close> command.
    35 Limitation: The commands do not work properly in locales yet.
    35 Limitation: The commands do not work properly in locales yet.
    36 
    36 
       
    37 If \<open>f\<close> is defined in a type class, one needs to set up a corresponding type class, say \<open>T_f\<close>,
       
    38 that fixes a function \<open>T_f\<close> of the corresponding type (ending in type \<open>nat\<close>).
       
    39 For every instance of \<open>f :: \<tau>\<close> one needs to create a corresponding instance of the class \<open>T_f\<close>.
       
    40 Inside that instance one can now use \<open>time_fun "f :: \<tau>"\<close> to define an instance of the function \<open>T_f\<close>.
       
    41 For example, see the definition and instantiation of class \<open>T_size\<close> in theory \<open>Time_Funs\<close>.
       
    42 Note that we can just write \<open>time_fun length\<close> because \<open>length\<close> is an abbreviation for \<open>size\<close> on type \<open>list\<close>.
       
    43 
       
    44 If \<open>f\<close> has an argument of function type, the corresponding argument of \<open>T_f\<close> is a pair
       
    45 of that function argument \<open>g\<close> and its corresponding time function \<open>T_g\<close>.
       
    46 
    37 The pre-defined functions below are assumed to have constant running time.
    47 The pre-defined functions below are assumed to have constant running time.
    38 In fact, we make that constant 0.
    48 In fact, we make that constant 0.
    39 This does not change the asymptotic running time of user-defined functions using the
    49 This does not change the asymptotic running time of user-defined functions using the
    40 pre-defined functions because 1 is added for every user-defined function call.
    50 pre-defined functions because 1 is added for every user-defined function call.
    41 
    51