src/HOL/Predicate_Compile_Examples/Specialisation_Examples.thy
changeset 36257 3f3e9f18f302
parent 36054 93d62439506c
child 37008 8da3b51726ac
equal deleted inserted replaced
36256:d1d9dee7a4bf 36257:3f3e9f18f302
    10 | "nth_el' (x # xs) i = (case i of 0 => Some x | Suc j => nth_el' xs j)"
    10 | "nth_el' (x # xs) i = (case i of 0 => Some x | Suc j => nth_el' xs j)"
    11 
    11 
    12 definition
    12 definition
    13   "greater_than_index xs = (\<forall>i x. nth_el' xs i = Some x --> x > i)"
    13   "greater_than_index xs = (\<forall>i x. nth_el' xs i = Some x --> x > i)"
    14 
    14 
    15 code_pred (expected_modes: i => bool) [inductify] greater_than_index .
    15 code_pred (expected_modes: i => bool) [inductify, skip_proof, specialise] greater_than_index .
    16 ML {* Predicate_Compile_Core.intros_of @{theory} @{const_name specialised_nth_el'P} *}
    16 ML {* Predicate_Compile_Core.intros_of @{theory} @{const_name specialised_nth_el'P} *}
    17 
    17 
    18 thm greater_than_index.equation
    18 thm greater_than_index.equation
    19 
    19 
    20 values [expected "{()}"] "{x. greater_than_index [1,2,4,6]}"
    20 values [expected "{()}"] "{x. greater_than_index [1,2,4,6]}"
    36 definition
    36 definition
    37   "max_of_my_Suc x = max x (Suc x)"
    37   "max_of_my_Suc x = max x (Suc x)"
    38 
    38 
    39 text {* In this example, max is specialised, hence the mode o => i => bool is possible *}
    39 text {* In this example, max is specialised, hence the mode o => i => bool is possible *}
    40 
    40 
    41 code_pred (modes: o => i => bool) [inductify] max_of_my_Suc .
    41 code_pred (modes: o => i => bool) [inductify, specialise, skip_proof] max_of_my_Suc .
    42 
    42 
    43 thm max_of_my_SucP.equation
    43 thm max_of_my_SucP.equation
    44 
    44 
    45 ML {* Predicate_Compile_Core.intros_of @{theory} @{const_name specialised_max_natP} *}
    45 ML {* Predicate_Compile_Core.intros_of @{theory} @{const_name specialised_max_natP} *}
    46 
    46 
   216 | T_TAbs: "TVarB T\<^isub>1 \<Colon> \<Gamma> \<turnstile> t\<^isub>2 : T\<^isub>2 \<Longrightarrow> \<Gamma> \<turnstile> (\<lambda><:T\<^isub>1. t\<^isub>2) : (\<forall><:T\<^isub>1. T\<^isub>2)"
   216 | T_TAbs: "TVarB T\<^isub>1 \<Colon> \<Gamma> \<turnstile> t\<^isub>2 : T\<^isub>2 \<Longrightarrow> \<Gamma> \<turnstile> (\<lambda><:T\<^isub>1. t\<^isub>2) : (\<forall><:T\<^isub>1. T\<^isub>2)"
   217 | T_TApp: "\<Gamma> \<turnstile> t\<^isub>1 : (\<forall><:T\<^isub>1\<^isub>1. T\<^isub>1\<^isub>2) \<Longrightarrow> \<Gamma> \<turnstile> T\<^isub>2 <: T\<^isub>1\<^isub>1 \<Longrightarrow>
   217 | T_TApp: "\<Gamma> \<turnstile> t\<^isub>1 : (\<forall><:T\<^isub>1\<^isub>1. T\<^isub>1\<^isub>2) \<Longrightarrow> \<Gamma> \<turnstile> T\<^isub>2 <: T\<^isub>1\<^isub>1 \<Longrightarrow>
   218     \<Gamma> \<turnstile> t\<^isub>1 \<bullet>\<^isub>\<tau> T\<^isub>2 : T\<^isub>1\<^isub>2[0 \<mapsto>\<^isub>\<tau> T\<^isub>2]\<^isub>\<tau>"
   218     \<Gamma> \<turnstile> t\<^isub>1 \<bullet>\<^isub>\<tau> T\<^isub>2 : T\<^isub>1\<^isub>2[0 \<mapsto>\<^isub>\<tau> T\<^isub>2]\<^isub>\<tau>"
   219 | T_Sub: "\<Gamma> \<turnstile> t : S \<Longrightarrow> \<Gamma> \<turnstile> S <: T \<Longrightarrow> \<Gamma> \<turnstile> t : T"
   219 | T_Sub: "\<Gamma> \<turnstile> t : S \<Longrightarrow> \<Gamma> \<turnstile> S <: T \<Longrightarrow> \<Gamma> \<turnstile> t : T"
   220 
   220 
   221 code_pred [inductify, skip_proof] typing .
   221 code_pred [inductify, skip_proof, specialise] typing .
   222 
   222 
   223 thm typing.equation
   223 thm typing.equation
   224 
   224 
   225 values 6 "{(E, t, T). typing E t T}"
   225 values 6 "{(E, t, T). typing E t T}"
   226 
   226