src/HOL/Predicate_Compile_Examples/Predicate_Compile_Examples.thy
changeset 36040 fcd7bea01a93
parent 35954 d87d85a5d9ab
child 36055 537876d0fa62
equal deleted inserted replaced
36039:affb6e1041e1 36040:fcd7bea01a93
   786 
   786 
   787 subsection {* Transforming functions into logic programs *}
   787 subsection {* Transforming functions into logic programs *}
   788 definition
   788 definition
   789   "case_f xs ys = (case (xs @ ys) of [] => [] | (x # xs) => xs)"
   789   "case_f xs ys = (case (xs @ ys) of [] => [] | (x # xs) => xs)"
   790 
   790 
   791 code_pred [inductify] case_f .
   791 code_pred [inductify, skip_proof] case_f .
   792 thm case_fP.equation
   792 thm case_fP.equation
   793 thm case_fP.intros
   793 thm case_fP.intros
   794 
   794 
   795 fun fold_map_idx where
   795 fun fold_map_idx where
   796   "fold_map_idx f i y [] = (y, [])"
   796   "fold_map_idx f i y [] = (y, [])"
   908 thm lenlex_conv
   908 thm lenlex_conv
   909 thm lex_conv
   909 thm lex_conv
   910 declare list.size(3,4)[code_pred_def]
   910 declare list.size(3,4)[code_pred_def]
   911 (*code_pred [inductify, show_steps, show_intermediate_results] length .*)
   911 (*code_pred [inductify, show_steps, show_intermediate_results] length .*)
   912 setup {* Predicate_Compile_Data.ignore_consts [@{const_name Orderings.top_class.top}] *}
   912 setup {* Predicate_Compile_Data.ignore_consts [@{const_name Orderings.top_class.top}] *}
   913 code_pred [inductify] lex .
   913 code_pred [inductify, skip_proof] lex .
   914 thm lex.equation
   914 thm lex.equation
   915 thm lex_def
   915 thm lex_def
   916 declare lenlex_conv[code_pred_def]
   916 declare lenlex_conv[code_pred_def]
   917 code_pred [inductify] lenlex .
   917 code_pred [inductify, skip_proof] lenlex .
   918 thm lenlex.equation
   918 thm lenlex.equation
   919 
   919 
   920 code_pred [random_dseq inductify] lenlex .
   920 code_pred [random_dseq inductify] lenlex .
   921 thm lenlex.random_dseq_equation
   921 thm lenlex.random_dseq_equation
   922 
   922 
  1035 thm size_listP.equation
  1035 thm size_listP.equation
  1036 thm size_listP.random_equation
  1036 thm size_listP.random_equation
  1037 *)
  1037 *)
  1038 (*values [random] 1 "{xs. size_listP (xs::nat list) (5::nat)}"*)
  1038 (*values [random] 1 "{xs. size_listP (xs::nat list) (5::nat)}"*)
  1039 
  1039 
  1040 code_pred (expected_modes: i => o => bool, o => i => bool, i => i => bool) [inductify] List.concat .
  1040 code_pred (expected_modes: i => o => bool, o => i => bool, i => i => bool) [inductify, skip_proof] List.concat .
  1041 thm concatP.equation
  1041 thm concatP.equation
  1042 
  1042 
  1043 values "{ys. concatP [[1, 2], [3, (4::int)]] ys}"
  1043 values "{ys. concatP [[1, 2], [3, (4::int)]] ys}"
  1044 values "{ys. concatP [[1, 2], [3]] [1, 2, (3::nat)]}"
  1044 values "{ys. concatP [[1, 2], [3]] [1, 2, (3::nat)]}"
  1045 
  1045 
  1066 code_pred (expected_modes: i => o => bool, i => i => bool) [inductify] tl .
  1066 code_pred (expected_modes: i => o => bool, i => i => bool) [inductify] tl .
  1067 thm tlP.equation
  1067 thm tlP.equation
  1068 values "{x. tlP [1, 2, (3::nat)] x}"
  1068 values "{x. tlP [1, 2, (3::nat)] x}"
  1069 values "{x. tlP [1, 2, (3::int)] [3]}"
  1069 values "{x. tlP [1, 2, (3::int)] [3]}"
  1070 
  1070 
  1071 code_pred [inductify] last .
  1071 code_pred [inductify, skip_proof] last .
  1072 thm lastP.equation
  1072 thm lastP.equation
  1073 
  1073 
  1074 code_pred [inductify] butlast .
  1074 code_pred [inductify, skip_proof] butlast .
  1075 thm butlastP.equation
  1075 thm butlastP.equation
  1076 
  1076 
  1077 code_pred [inductify] take .
  1077 code_pred [inductify, skip_proof] take .
  1078 thm takeP.equation
  1078 thm takeP.equation
  1079 
  1079 
  1080 code_pred [inductify] drop .
  1080 code_pred [inductify, skip_proof] drop .
  1081 thm dropP.equation
  1081 thm dropP.equation
  1082 code_pred [inductify] zip .
  1082 code_pred [inductify, skip_proof] zip .
  1083 thm zipP.equation
  1083 thm zipP.equation
  1084 
  1084 
  1085 code_pred [inductify] upt .
  1085 code_pred [inductify, skip_proof] upt .
  1086 code_pred [inductify] remdups .
  1086 code_pred [inductify, skip_proof] remdups .
  1087 thm remdupsP.equation
  1087 thm remdupsP.equation
  1088 code_pred [dseq inductify] remdups .
  1088 code_pred [dseq inductify] remdups .
  1089 values [dseq 4] 5 "{xs. remdupsP xs [1, (2::int)]}"
  1089 values [dseq 4] 5 "{xs. remdupsP xs [1, (2::int)]}"
  1090 
  1090 
  1091 code_pred [inductify] remove1 .
  1091 code_pred [inductify, skip_proof] remove1 .
  1092 thm remove1P.equation
  1092 thm remove1P.equation
  1093 values "{xs. remove1P 1 xs [2, (3::int)]}"
  1093 values "{xs. remove1P 1 xs [2, (3::int)]}"
  1094 
  1094 
  1095 code_pred [inductify] removeAll .
  1095 code_pred [inductify, skip_proof] removeAll .
  1096 thm removeAllP.equation
  1096 thm removeAllP.equation
  1097 code_pred [dseq inductify] removeAll .
  1097 code_pred [dseq inductify] removeAll .
  1098 
  1098 
  1099 values [dseq 4] 10 "{xs. removeAllP 1 xs [(2::nat)]}"
  1099 values [dseq 4] 10 "{xs. removeAllP 1 xs [(2::nat)]}"
  1100 
  1100 
  1101 code_pred [inductify] distinct .
  1101 code_pred [inductify] distinct .
  1102 thm distinct.equation
  1102 thm distinct.equation
  1103 code_pred [inductify] replicate .
  1103 code_pred [inductify, skip_proof] replicate .
  1104 thm replicateP.equation
  1104 thm replicateP.equation
  1105 values 5 "{(n, xs). replicateP n (0::int) xs}"
  1105 values 5 "{(n, xs). replicateP n (0::int) xs}"
  1106 
  1106 
  1107 code_pred [inductify] splice .
  1107 code_pred [inductify, skip_proof] splice .
  1108 thm splice.simps
  1108 thm splice.simps
  1109 thm spliceP.equation
  1109 thm spliceP.equation
  1110 
  1110 
  1111 values "{xs. spliceP xs [1, 2, 3] [1, 1, 1, 2, 1, (3::nat)]}"
  1111 values "{xs. spliceP xs [1, 2, 3] [1, 1, 1, 2, 1, (3::nat)]}"
  1112 
  1112 
  1113 code_pred [inductify] List.rev .
  1113 code_pred [inductify, skip_proof] List.rev .
  1114 code_pred [inductify] map .
  1114 code_pred [inductify] map .
  1115 code_pred [inductify] foldr .
  1115 code_pred [inductify] foldr .
  1116 code_pred [inductify] foldl .
  1116 code_pred [inductify] foldl .
  1117 code_pred [inductify] filter .
  1117 code_pred [inductify] filter .
  1118 code_pred [random_dseq inductify] filter .
  1118 code_pred [random_dseq inductify] filter .
  1157 | "w \<in> B\<^isub>3 \<Longrightarrow> a # w \<in> S\<^isub>3"
  1157 | "w \<in> B\<^isub>3 \<Longrightarrow> a # w \<in> S\<^isub>3"
  1158 | "w \<in> S\<^isub>3 \<Longrightarrow> a # w \<in> A\<^isub>3"
  1158 | "w \<in> S\<^isub>3 \<Longrightarrow> a # w \<in> A\<^isub>3"
  1159 | "w \<in> S\<^isub>3 \<Longrightarrow> b # w \<in> B\<^isub>3"
  1159 | "w \<in> S\<^isub>3 \<Longrightarrow> b # w \<in> B\<^isub>3"
  1160 | "\<lbrakk>v \<in> B\<^isub>3; w \<in> B\<^isub>3\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>3"
  1160 | "\<lbrakk>v \<in> B\<^isub>3; w \<in> B\<^isub>3\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>3"
  1161 
  1161 
  1162 code_pred [inductify] S\<^isub>3p .
  1162 code_pred [inductify, skip_proof] S\<^isub>3p .
  1163 thm S\<^isub>3p.equation
  1163 thm S\<^isub>3p.equation
  1164 
  1164 
  1165 values 10 "{x. S\<^isub>3p x}"
  1165 values 10 "{x. S\<^isub>3p x}"
  1166 
  1166 
  1167 inductive_set S\<^isub>4 and A\<^isub>4 and B\<^isub>4 where
  1167 inductive_set S\<^isub>4 and A\<^isub>4 and B\<^isub>4 where