itp-interface 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (485) hide show
  1. itp_interface/__init__.py +0 -0
  2. itp_interface/agent/__init__.py +0 -0
  3. itp_interface/agent/simple_proof_agent.py +100 -0
  4. itp_interface/coq_ser_api/__init__.py +165 -0
  5. itp_interface/coq_ser_api/contexts.py +283 -0
  6. itp_interface/coq_ser_api/coq_agent.py +459 -0
  7. itp_interface/coq_ser_api/coq_backend.py +135 -0
  8. itp_interface/coq_ser_api/coq_util.py +839 -0
  9. itp_interface/coq_ser_api/example.py +67 -0
  10. itp_interface/coq_ser_api/lsp_backend.py +375 -0
  11. itp_interface/coq_ser_api/py.typed +0 -0
  12. itp_interface/coq_ser_api/serapi_backend.py +841 -0
  13. itp_interface/coq_ser_api/util.py +145 -0
  14. itp_interface/coq_ser_api_old/__init__.py +2583 -0
  15. itp_interface/coq_ser_api_old/contexts.py +172 -0
  16. itp_interface/coq_ser_api_old/util.py +146 -0
  17. itp_interface/lean_server/__init__.py +0 -0
  18. itp_interface/lean_server/commands.py +484 -0
  19. itp_interface/lean_server/lean3_search_tool.py +358 -0
  20. itp_interface/lean_server/lean4_repl_interface.py +151 -0
  21. itp_interface/lean_server/lean4_utils.py +255 -0
  22. itp_interface/lean_server/lean_cmd_server.py +111 -0
  23. itp_interface/lean_server/lean_context.py +60 -0
  24. itp_interface/lean_server/lean_sync_server.py +174 -0
  25. itp_interface/lean_server/lean_utils.py +199 -0
  26. itp_interface/lean_server/py.typed +1 -0
  27. itp_interface/main/__init__.py +0 -0
  28. itp_interface/main/config/afp_data_gen.yaml +14 -0
  29. itp_interface/main/config/benchmark/CompCert.yaml +366 -0
  30. itp_interface/main/config/benchmark/GeoCoq.yaml +930 -0
  31. itp_interface/main/config/benchmark/UniMath.yaml +2690 -0
  32. itp_interface/main/config/benchmark/afp_isabelle.yaml +29200 -0
  33. itp_interface/main/config/benchmark/agent_proverbot_hard.yaml +247 -0
  34. itp_interface/main/config/benchmark/category-theory.yaml +470 -0
  35. itp_interface/main/config/benchmark/compcert_118_subset.yaml +148 -0
  36. itp_interface/main/config/benchmark/compcert_benchmark.yaml +36 -0
  37. itp_interface/main/config/benchmark/compcert_benchmark_hard.yaml +498 -0
  38. itp_interface/main/config/benchmark/compcert_benchmark_hard_1.yaml +55 -0
  39. itp_interface/main/config/benchmark/compcert_benchmark_hard_2.yaml +24 -0
  40. itp_interface/main/config/benchmark/compcert_benchmark_hard_3.yaml +95 -0
  41. itp_interface/main/config/benchmark/compcert_benchmark_hard_7_per_cent.yaml +78 -0
  42. itp_interface/main/config/benchmark/compcert_benchmark_test.yaml +38 -0
  43. itp_interface/main/config/benchmark/compcert_benchmark_train.yaml +340 -0
  44. itp_interface/main/config/benchmark/leandojo_novel_premises_test.yaml +2908 -0
  45. itp_interface/main/config/benchmark/leandojo_novel_premises_train.yaml +98645 -0
  46. itp_interface/main/config/benchmark/leandojo_novel_premises_val.yaml +2912 -0
  47. itp_interface/main/config/benchmark/leandojo_random.yaml +2889 -0
  48. itp_interface/main/config/benchmark/leandojo_random_test.yaml +2421 -0
  49. itp_interface/main/config/benchmark/leandojo_random_train.yaml +62729 -0
  50. itp_interface/main/config/benchmark/leandojo_random_val.yaml +2504 -0
  51. itp_interface/main/config/benchmark/math-comp.yaml +200 -0
  52. itp_interface/main/config/benchmark/miniF2F_test.yaml +12 -0
  53. itp_interface/main/config/benchmark/miniF2F_test_aime.yaml +27 -0
  54. itp_interface/main/config/benchmark/miniF2F_test_algebra.yaml +30 -0
  55. itp_interface/main/config/benchmark/miniF2F_test_amc12.yaml +57 -0
  56. itp_interface/main/config/benchmark/miniF2F_test_few_shot_hard.yaml +231 -0
  57. itp_interface/main/config/benchmark/miniF2F_test_imo.yaml +32 -0
  58. itp_interface/main/config/benchmark/miniF2F_test_induction.yaml +20 -0
  59. itp_interface/main/config/benchmark/miniF2F_test_mathd_algebra.yaml +82 -0
  60. itp_interface/main/config/benchmark/miniF2F_test_mathd_algebra_hard.yaml +72 -0
  61. itp_interface/main/config/benchmark/miniF2F_test_mathd_numbertheory.yaml +72 -0
  62. itp_interface/main/config/benchmark/miniF2F_test_numbertheory.yaml +20 -0
  63. itp_interface/main/config/benchmark/minicompcert_benchmark_1.yaml +14 -0
  64. itp_interface/main/config/benchmark/proverbot_hard.yaml +104 -0
  65. itp_interface/main/config/benchmark/re_prover.yaml +66 -0
  66. itp_interface/main/config/benchmark/re_prover_hard.yaml +41 -0
  67. itp_interface/main/config/benchmark/re_prover_very_hard.yaml +22 -0
  68. itp_interface/main/config/benchmark/reprover_with_retrieval.yaml +73 -0
  69. itp_interface/main/config/benchmark/reprover_with_retrieval_hard.yaml +30 -0
  70. itp_interface/main/config/benchmark/reprover_with_retrieval_neg.yaml +195 -0
  71. itp_interface/main/config/benchmark/simple_benchmark_1.yaml +24 -0
  72. itp_interface/main/config/benchmark/simple_benchmark_8.yaml +50 -0
  73. itp_interface/main/config/benchmark/simple_benchmark_9.yaml +65 -0
  74. itp_interface/main/config/benchmark/simple_benchmark_isabelle.yaml +18 -0
  75. itp_interface/main/config/benchmark/simple_benchmark_lean.yaml +12 -0
  76. itp_interface/main/config/benchmark/simple_benchmark_lean_training_data.yaml +12 -0
  77. itp_interface/main/config/benchmark/simple_rl_benchmark_lean.yaml +14 -0
  78. itp_interface/main/config/benchmark/stack_machine.yaml +13 -0
  79. itp_interface/main/config/benchmark/stack_machine_hard.yaml +15 -0
  80. itp_interface/main/config/category_theory_data_gen.yaml +14 -0
  81. itp_interface/main/config/category_theory_data_gen_random.yaml +16 -0
  82. itp_interface/main/config/compcert_data_gen_test.yaml +10 -0
  83. itp_interface/main/config/compcert_data_gen_train.yaml +7 -0
  84. itp_interface/main/config/env_settings/bm25_retrieval.yaml +2 -0
  85. itp_interface/main/config/env_settings/bm25_retrieval_no_dfns.yaml +2 -0
  86. itp_interface/main/config/env_settings/bm25_retrieval_only_local_no_dfns.yaml +2 -0
  87. itp_interface/main/config/env_settings/bm25_retrieval_with_print.yaml +2 -0
  88. itp_interface/main/config/env_settings/bm25_retrieval_with_print_only_local.yaml +2 -0
  89. itp_interface/main/config/env_settings/bm25_retrieval_with_print_only_local_no_dfns.yaml +2 -0
  90. itp_interface/main/config/env_settings/no_retrieval.yaml +2 -0
  91. itp_interface/main/config/experiments.yaml +12 -0
  92. itp_interface/main/config/geo_coq_data_gen.yaml +14 -0
  93. itp_interface/main/config/geo_coq_data_gen_random.yaml +16 -0
  94. itp_interface/main/config/leandojo_random_data_gen.yaml +16 -0
  95. itp_interface/main/config/math_comp_data_gen.yaml +14 -0
  96. itp_interface/main/config/math_comp_data_gen_random.yaml +16 -0
  97. itp_interface/main/config/mathlib_data_gen.yaml +14 -0
  98. itp_interface/main/config/repo/coq_repos.yaml +191 -0
  99. itp_interface/main/config/run_settings/default_coq_data_generation_transforms.yaml +24 -0
  100. itp_interface/main/config/run_settings/default_isabelle_data_generation_transforms.yaml +24 -0
  101. itp_interface/main/config/run_settings/default_lean4_data_generation_transforms.yaml +24 -0
  102. itp_interface/main/config/run_settings/default_lean_data_generation_transforms.yaml +24 -0
  103. itp_interface/main/config/simple_coq_data_gen.yaml +12 -0
  104. itp_interface/main/config/simple_coq_data_gen_random.yaml +17 -0
  105. itp_interface/main/config/simple_lean_data_gen.yaml +12 -0
  106. itp_interface/main/config/simple_rl_lean_data_gen.yaml +12 -0
  107. itp_interface/main/config/uni_math_data_gen.yaml +14 -0
  108. itp_interface/main/config.py +192 -0
  109. itp_interface/main/extract_benchmark_dataset.py +106 -0
  110. itp_interface/main/filter_dataset.py +107 -0
  111. itp_interface/main/install.py +92 -0
  112. itp_interface/main/merge_dataset.py +96 -0
  113. itp_interface/main/run_tool.py +444 -0
  114. itp_interface/pisa/.git +1 -0
  115. itp_interface/pisa/.gitignore +125 -0
  116. itp_interface/pisa/.idea/.gitignore +8 -0
  117. itp_interface/pisa/.idea/ClojureProjectResolveSettings.xml +6 -0
  118. itp_interface/pisa/.idea/codeStyles/Project.xml +7 -0
  119. itp_interface/pisa/.idea/codeStyles/codeStyleConfig.xml +5 -0
  120. itp_interface/pisa/.idea/inspectionProfiles/Project_Default.xml +16 -0
  121. itp_interface/pisa/.idea/libraries/sbt__com_google_android_annotations_4_1_1_4_jar.xml +13 -0
  122. itp_interface/pisa/.idea/libraries/sbt__com_google_api_grpc_proto_google_common_protos_1_17_0_jar.xml +13 -0
  123. itp_interface/pisa/.idea/libraries/sbt__com_google_code_findbugs_jsr305_3_0_2_jar.xml +13 -0
  124. itp_interface/pisa/.idea/libraries/sbt__com_google_code_gson_gson_2_8_6_jar.xml +13 -0
  125. itp_interface/pisa/.idea/libraries/sbt__com_google_errorprone_error_prone_annotations_2_3_4_jar.xml +13 -0
  126. itp_interface/pisa/.idea/libraries/sbt__com_google_guava_failureaccess_1_0_1_jar.xml +13 -0
  127. itp_interface/pisa/.idea/libraries/sbt__com_google_guava_guava_30_0_jre_jar.xml +13 -0
  128. itp_interface/pisa/.idea/libraries/sbt__com_google_guava_listenablefuture_9999_0_empty_to_avoid_conflict_with_guava_jar.xml +9 -0
  129. itp_interface/pisa/.idea/libraries/sbt__com_google_j2objc_j2objc_annotations_1_3_jar.xml +13 -0
  130. itp_interface/pisa/.idea/libraries/sbt__com_google_protobuf_protobuf_java_3_12_0_jar.xml +13 -0
  131. itp_interface/pisa/.idea/libraries/sbt__com_google_protobuf_protobuf_java_util_3_12_0_jar.xml +13 -0
  132. itp_interface/pisa/.idea/libraries/sbt__com_lihaoyi_fastparse_2_13_2_3_0_jar.xml +13 -0
  133. itp_interface/pisa/.idea/libraries/sbt__com_lihaoyi_geny_2_13_0_6_0_jar.xml +13 -0
  134. itp_interface/pisa/.idea/libraries/sbt__com_lihaoyi_sourcecode_2_13_0_2_1_jar.xml +13 -0
  135. itp_interface/pisa/.idea/libraries/sbt__com_thesamet_scalapb_lenses_2_13_0_10_9_jar.xml +13 -0
  136. itp_interface/pisa/.idea/libraries/sbt__com_thesamet_scalapb_scalapb_runtime_2_13_0_10_9_jar.xml +13 -0
  137. itp_interface/pisa/.idea/libraries/sbt__com_thesamet_scalapb_scalapb_runtime_grpc_2_13_0_10_9_jar.xml +13 -0
  138. itp_interface/pisa/.idea/libraries/sbt__com_thesamet_scalapb_zio_grpc_zio_grpc_core_2_13_0_4_2_jar.xml +13 -0
  139. itp_interface/pisa/.idea/libraries/sbt__com_thoughtworks_paranamer_paranamer_2_8_jar.xml +13 -0
  140. itp_interface/pisa/.idea/libraries/sbt__commons_io_commons_io_2_8_0_jar.xml +13 -0
  141. itp_interface/pisa/.idea/libraries/sbt__de_unruh_java_patterns_0_1_0_jar.xml +13 -0
  142. itp_interface/pisa/.idea/libraries/sbt__de_unruh_scala_isabelle_2_13_master_SNAPSHOT_jar.xml +13 -0
  143. itp_interface/pisa/.idea/libraries/sbt__dev_zio_izumi_reflect_2_13_1_0_0_M9_jar.xml +13 -0
  144. itp_interface/pisa/.idea/libraries/sbt__dev_zio_izumi_reflect_thirdparty_boopickle_shaded_2_13_1_0_0_M9_jar.xml +13 -0
  145. itp_interface/pisa/.idea/libraries/sbt__dev_zio_zio_2_13_1_0_3_jar.xml +13 -0
  146. itp_interface/pisa/.idea/libraries/sbt__dev_zio_zio_stacktracer_2_13_1_0_3_jar.xml +13 -0
  147. itp_interface/pisa/.idea/libraries/sbt__dev_zio_zio_streams_2_13_1_0_3_jar.xml +13 -0
  148. itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_api_1_34_0_jar.xml +13 -0
  149. itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_context_1_34_0_jar.xml +13 -0
  150. itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_core_1_34_0_jar.xml +13 -0
  151. itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_netty_1_34_0_jar.xml +13 -0
  152. itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_protobuf_1_34_0_jar.xml +13 -0
  153. itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_protobuf_lite_1_34_0_jar.xml +13 -0
  154. itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_services_1_34_0_jar.xml +13 -0
  155. itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_stub_1_34_0_jar.xml +13 -0
  156. itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_buffer_4_1_51_Final_jar.xml +13 -0
  157. itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_codec_4_1_51_Final_jar.xml +13 -0
  158. itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_codec_http2_4_1_51_Final_jar.xml +13 -0
  159. itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_codec_http_4_1_51_Final_jar.xml +13 -0
  160. itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_codec_socks_4_1_51_Final_jar.xml +13 -0
  161. itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_common_4_1_51_Final_jar.xml +13 -0
  162. itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_handler_4_1_51_Final_jar.xml +13 -0
  163. itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_handler_proxy_4_1_51_Final_jar.xml +13 -0
  164. itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_resolver_4_1_51_Final_jar.xml +13 -0
  165. itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_transport_4_1_51_Final_jar.xml +13 -0
  166. itp_interface/pisa/.idea/libraries/sbt__io_perfmark_perfmark_api_0_19_0_jar.xml +13 -0
  167. itp_interface/pisa/.idea/libraries/sbt__net_java_dev_jna_jna_5_3_1_jar.xml +13 -0
  168. itp_interface/pisa/.idea/libraries/sbt__net_liftweb_lift_json_2_13_3_4_3_jar.xml +13 -0
  169. itp_interface/pisa/.idea/libraries/sbt__org_apache_commons_commons_lang3_3_11_jar.xml +13 -0
  170. itp_interface/pisa/.idea/libraries/sbt__org_apache_commons_commons_text_1_9_jar.xml +13 -0
  171. itp_interface/pisa/.idea/libraries/sbt__org_checkerframework_checker_qual_3_5_0_jar.xml +13 -0
  172. itp_interface/pisa/.idea/libraries/sbt__org_codehaus_mojo_animal_sniffer_annotations_1_18_jar.xml +13 -0
  173. itp_interface/pisa/.idea/libraries/sbt__org_jetbrains_annotations_20_1_0_jar.xml +13 -0
  174. itp_interface/pisa/.idea/libraries/sbt__org_jline_jline_3_16_0_jar.xml +13 -0
  175. itp_interface/pisa/.idea/libraries/sbt__org_log4s_log4s_2_13_1_9_0_jar.xml +13 -0
  176. itp_interface/pisa/.idea/libraries/sbt__org_scala_lang_modules_scala_collection_compat_2_13_2_1_6_jar.xml +13 -0
  177. itp_interface/pisa/.idea/libraries/sbt__org_scala_lang_modules_scala_xml_2_13_1_3_0_jar.xml +13 -0
  178. itp_interface/pisa/.idea/libraries/sbt__org_scala_lang_scala_compiler_2_13_4_jar.xml +13 -0
  179. itp_interface/pisa/.idea/libraries/sbt__org_scala_lang_scala_library_2_13_4_jar.xml +23 -0
  180. itp_interface/pisa/.idea/libraries/sbt__org_scala_lang_scala_reflect_2_13_4_jar.xml +13 -0
  181. itp_interface/pisa/.idea/libraries/sbt__org_scala_lang_scalap_2_13_4_jar.xml +13 -0
  182. itp_interface/pisa/.idea/libraries/sbt__org_scalaz_scalaz_core_2_13_7_3_2_jar.xml +13 -0
  183. itp_interface/pisa/.idea/libraries/sbt__org_slf4j_slf4j_api_1_7_30_jar.xml +13 -0
  184. itp_interface/pisa/.idea/libraries/sbt__org_slf4j_slf4j_simple_1_7_30_jar.xml +13 -0
  185. itp_interface/pisa/.idea/misc.xml +7 -0
  186. itp_interface/pisa/.idea/modules/PISA-build.iml +127 -0
  187. itp_interface/pisa/.idea/modules/PISA.iml +94 -0
  188. itp_interface/pisa/.idea/modules.xml +9 -0
  189. itp_interface/pisa/.idea/other.xml +6 -0
  190. itp_interface/pisa/.idea/sbt.xml +20 -0
  191. itp_interface/pisa/.idea/scala_compiler.xml +6 -0
  192. itp_interface/pisa/.idea/uiDesigner.xml +124 -0
  193. itp_interface/pisa/.idea/vcs.xml +6 -0
  194. itp_interface/pisa/.scalafmt.conf +2 -0
  195. itp_interface/pisa/LICENSE +29 -0
  196. itp_interface/pisa/README.md +262 -0
  197. itp_interface/pisa/build.sbt +49 -0
  198. itp_interface/pisa/build.sh +26 -0
  199. itp_interface/pisa/command_generation/close_gaps.py +44 -0
  200. itp_interface/pisa/command_generation/conjecture_normal_order.py +62 -0
  201. itp_interface/pisa/command_generation/conjecturer_command_generator.py +36 -0
  202. itp_interface/pisa/command_generation/create_dirs.py +11 -0
  203. itp_interface/pisa/command_generation/find_std.py +67 -0
  204. itp_interface/pisa/command_generation/generate_build_commands_afp.py +15 -0
  205. itp_interface/pisa/command_generation/generate_build_commands_std.py +15 -0
  206. itp_interface/pisa/command_generation/generate_commands_afp.py +103 -0
  207. itp_interface/pisa/command_generation/generate_commands_mini.py +73 -0
  208. itp_interface/pisa/command_generation/generate_commands_std.py +69 -0
  209. itp_interface/pisa/command_generation/generate_hammer_extraction_text.py +5 -0
  210. itp_interface/pisa/command_generation/hammer_command_generator.py +40 -0
  211. itp_interface/pisa/command_generation/hp_search_command_generator.py +63 -0
  212. itp_interface/pisa/command_generation/oracle_command_generator.py +56 -0
  213. itp_interface/pisa/command_generation/search_command_generator.py +69 -0
  214. itp_interface/pisa/command_generation/summarise_problem_names.py +45 -0
  215. itp_interface/pisa/command_generation/tpu_hp_search.py +75 -0
  216. itp_interface/pisa/docker/Dockerfile +34 -0
  217. itp_interface/pisa/docker/docker_tutorial.md +64 -0
  218. itp_interface/pisa/eval_setup/copy_isabelle.py +42 -0
  219. itp_interface/pisa/eval_setup/copy_pisa_jars.py +18 -0
  220. itp_interface/pisa/mesh_transformer_utils/tokenization.py +86 -0
  221. itp_interface/pisa/project/build.properties +1 -0
  222. itp_interface/pisa/project/plugins.sbt +5 -0
  223. itp_interface/pisa/requirements.txt +4 -0
  224. itp_interface/pisa/scripts/extract_last_k_steps.py +28 -0
  225. itp_interface/pisa/scripts/extract_proof_corpus.py +26 -0
  226. itp_interface/pisa/scripts/gather_hammer_results.py +27 -0
  227. itp_interface/pisa/scripts/length_in_char_stats.py +20 -0
  228. itp_interface/pisa/scripts/mix.py +127 -0
  229. itp_interface/pisa/scripts/results_stat.py +52 -0
  230. itp_interface/pisa/scripts/test_array_job.sh +34 -0
  231. itp_interface/pisa/setup.sh +25 -0
  232. itp_interface/pisa/src/main/protobuf/server.proto +60 -0
  233. itp_interface/pisa/src/main/python/.idea/.gitignore +8 -0
  234. itp_interface/pisa/src/main/python/.idea/inspectionProfiles/Project_Default.xml +18 -0
  235. itp_interface/pisa/src/main/python/.idea/inspectionProfiles/profiles_settings.xml +6 -0
  236. itp_interface/pisa/src/main/python/.idea/misc.xml +4 -0
  237. itp_interface/pisa/src/main/python/.idea/modules.xml +8 -0
  238. itp_interface/pisa/src/main/python/.idea/python.iml +12 -0
  239. itp_interface/pisa/src/main/python/.idea/vcs.xml +6 -0
  240. itp_interface/pisa/src/main/python/conjecturing_parsing/conjecturer_postprocessing.py +59 -0
  241. itp_interface/pisa/src/main/python/data_extraction/extract_data.py +184 -0
  242. itp_interface/pisa/src/main/python/data_extraction/find_premises.py +221 -0
  243. itp_interface/pisa/src/main/python/data_extraction/process_data.py +129 -0
  244. itp_interface/pisa/src/main/python/legacy/PisaFlexibleClient.py +167 -0
  245. itp_interface/pisa/src/main/python/legacy/autof_test.py +74 -0
  246. itp_interface/pisa/src/main/python/legacy/cmd_client.py +23 -0
  247. itp_interface/pisa/src/main/python/legacy/convert_scala_dump_to_test_name_jsons.py +14 -0
  248. itp_interface/pisa/src/main/python/legacy/create_data_txt.py +72 -0
  249. itp_interface/pisa/src/main/python/legacy/create_finetune_tfrecords.py +311 -0
  250. itp_interface/pisa/src/main/python/legacy/demo.py +49 -0
  251. itp_interface/pisa/src/main/python/legacy/evaluate.py +108 -0
  252. itp_interface/pisa/src/main/python/legacy/extract_first_step.py +25 -0
  253. itp_interface/pisa/src/main/python/legacy/get_global_facts.py +35 -0
  254. itp_interface/pisa/src/main/python/legacy/mix_data.py +19 -0
  255. itp_interface/pisa/src/main/python/legacy/one_stage_extraction.py +111 -0
  256. itp_interface/pisa/src/main/python/legacy/prepare_episodic_transitions.py +137 -0
  257. itp_interface/pisa/src/main/python/legacy/prepare_translation_pairs.py +277 -0
  258. itp_interface/pisa/src/main/python/pisa_client.py +322 -0
  259. itp_interface/pisa/src/main/python/server_pb2.py +394 -0
  260. itp_interface/pisa/src/main/python/server_pb2_grpc.py +230 -0
  261. itp_interface/pisa/src/main/python/test_client.py +17 -0
  262. itp_interface/pisa/src/main/python/test_client2.py +79 -0
  263. itp_interface/pisa/src/main/python/utils/filters.py +59 -0
  264. itp_interface/pisa/src/main/python/utils/pisa_server_control.py +29 -0
  265. itp_interface/pisa/src/main/scala/pisa/agent/CheckSyntax.scala +257 -0
  266. itp_interface/pisa/src/main/scala/pisa/agent/DepThms.scala +29 -0
  267. itp_interface/pisa/src/main/scala/pisa/agent/PisaStat.scala +46 -0
  268. itp_interface/pisa/src/main/scala/pisa/agent/RefactorTest.scala +40 -0
  269. itp_interface/pisa/src/main/scala/pisa/agent/RepHammer.scala +95 -0
  270. itp_interface/pisa/src/main/scala/pisa/server/HammFacts.scala +63 -0
  271. itp_interface/pisa/src/main/scala/pisa/server/PisaOS.scala +881 -0
  272. itp_interface/pisa/src/main/scala/pisa/server/PisaOneStage.scala +540 -0
  273. itp_interface/pisa/src/main/scala/pisa/server/PisaOneStageServers.scala +1048 -0
  274. itp_interface/pisa/src/main/scala/pisa/utils/TheoryManager.scala +95 -0
  275. itp_interface/pisa/src/test/python/analyse_debug.py +33 -0
  276. itp_interface/pisa/src/test/python/extract_test_seq2seq.py +53 -0
  277. itp_interface/pisa/src/test/python/extract_test_theorem_ground_truth_indices.py +31 -0
  278. itp_interface/pisa/src/test/python/proof_originality.py +24 -0
  279. itp_interface/pisa/src/test/python/test_command_generator.py +25 -0
  280. itp_interface/pisa/src/test/python/test_model_sequence_accuracy.py +70 -0
  281. itp_interface/pisa/src/test/scala/pisa/Easy.scala +26 -0
  282. itp_interface/pisa/src/test/scala/pisa/TestCurl.scala +82 -0
  283. itp_interface/pisa/src/test/scala/pisa/TestIsa.scala +27 -0
  284. itp_interface/pisa/test.sh +19 -0
  285. itp_interface/pisa/universal_test_theorems.tar.gz +0 -0
  286. itp_interface/repo/build.py +78 -0
  287. itp_interface/repo/clone.py +79 -0
  288. itp_interface/repo/dataset_discovery.py +99 -0
  289. itp_interface/retrieval/__init__.py +0 -0
  290. itp_interface/retrieval/abstraction.py +35 -0
  291. itp_interface/retrieval/coq_bm25_reranker.py +153 -0
  292. itp_interface/retrieval/isabelle_bm25_reranker.py +86 -0
  293. itp_interface/retrieval/lean3_bm25_reranker.py +86 -0
  294. itp_interface/rl/__init__.py +0 -0
  295. itp_interface/rl/abstraction.py +168 -0
  296. itp_interface/rl/proof_action.py +172 -0
  297. itp_interface/rl/proof_state.py +149 -0
  298. itp_interface/rl/proof_tree.py +109 -0
  299. itp_interface/rl/simpl_proof_env_pool.py +16 -0
  300. itp_interface/rl/simple_proof_env.py +713 -0
  301. itp_interface/rl/simple_proof_env_pool.py +591 -0
  302. itp_interface/scripts/setup.sh +228 -0
  303. itp_interface/tools/__init__.py +0 -0
  304. itp_interface/tools/basic_utils.py +172 -0
  305. itp_interface/tools/bin_packing.py +61 -0
  306. itp_interface/tools/cache.py +93 -0
  307. itp_interface/tools/coq_build_spec.py +31 -0
  308. itp_interface/tools/coq_build_tool.py +319 -0
  309. itp_interface/tools/coq_context_helper.py +354 -0
  310. itp_interface/tools/coq_executor.py +508 -0
  311. itp_interface/tools/coq_local_data_generation_transform.py +158 -0
  312. itp_interface/tools/coq_parse_utils.py +154 -0
  313. itp_interface/tools/coq_raw_proofs.py +193 -0
  314. itp_interface/tools/coq_theorem_proof_pair_generation_transform.py +146 -0
  315. itp_interface/tools/coq_training_data_generator.py +76 -0
  316. itp_interface/tools/dynamic_coq_proof_exec.py +220 -0
  317. itp_interface/tools/dynamic_isabelle_proof_exec.py +229 -0
  318. itp_interface/tools/dynamic_lean4_proof_exec.py +236 -0
  319. itp_interface/tools/dynamic_lean_proof_exec.py +228 -0
  320. itp_interface/tools/isabelle_context_helper.py +66 -0
  321. itp_interface/tools/isabelle_executor.py +862 -0
  322. itp_interface/tools/isabelle_local_data_generation_transform.py +149 -0
  323. itp_interface/tools/isabelle_parse_utils.py +131 -0
  324. itp_interface/tools/isabelle_server.py +106 -0
  325. itp_interface/tools/lean4_context_helper.py +72 -0
  326. itp_interface/tools/lean4_local_data_generation_transform.py +122 -0
  327. itp_interface/tools/lean4_sync_executor.py +1193 -0
  328. itp_interface/tools/lean_cmd_executor.py +804 -0
  329. itp_interface/tools/lean_context_helper.py +327 -0
  330. itp_interface/tools/lean_dojo_data_generation_transform.py +206 -0
  331. itp_interface/tools/lean_executor.py +687 -0
  332. itp_interface/tools/lean_local_data_generation_transform.py +136 -0
  333. itp_interface/tools/lean_parse_utils.py +32 -0
  334. itp_interface/tools/log_utils.py +20 -0
  335. itp_interface/tools/proof_exec_callback.py +76 -0
  336. itp_interface/tools/ray_utils.py +265 -0
  337. itp_interface/tools/repl/.git +1 -0
  338. itp_interface/tools/repl/.github/workflows/ci.yml +24 -0
  339. itp_interface/tools/repl/.gitignore +7 -0
  340. itp_interface/tools/repl/.vscode/copyright.code-snippets +13 -0
  341. itp_interface/tools/repl/.vscode/extensions.json +13 -0
  342. itp_interface/tools/repl/.vscode/module-docstring.code-snippets +35 -0
  343. itp_interface/tools/repl/.vscode/settings.json +11 -0
  344. itp_interface/tools/repl/README.md +174 -0
  345. itp_interface/tools/repl/REPL/Frontend.lean +47 -0
  346. itp_interface/tools/repl/REPL/JSON.lean +186 -0
  347. itp_interface/tools/repl/REPL/Lean/ContextInfo.lean +9 -0
  348. itp_interface/tools/repl/REPL/Lean/Environment.lean +31 -0
  349. itp_interface/tools/repl/REPL/Lean/InfoTree/ToJson.lean +114 -0
  350. itp_interface/tools/repl/REPL/Lean/InfoTree.lean +272 -0
  351. itp_interface/tools/repl/REPL/Main.lean +323 -0
  352. itp_interface/tools/repl/REPL/Snapshots.lean +306 -0
  353. itp_interface/tools/repl/REPL/Util/Path.lean +36 -0
  354. itp_interface/tools/repl/REPL/Util/Pickle.lean +44 -0
  355. itp_interface/tools/repl/REPL.lean +4 -0
  356. itp_interface/tools/repl/lake-manifest.json +5 -0
  357. itp_interface/tools/repl/lakefile.lean +15 -0
  358. itp_interface/tools/repl/lean-toolchain +1 -0
  359. itp_interface/tools/repl/test/Mathlib/.gitignore +5 -0
  360. itp_interface/tools/repl/test/Mathlib/H20231110.sh +2 -0
  361. itp_interface/tools/repl/test/Mathlib/ReplMathlibTests.lean +1 -0
  362. itp_interface/tools/repl/test/Mathlib/lake-manifest.json +68 -0
  363. itp_interface/tools/repl/test/Mathlib/lakefile.lean +11 -0
  364. itp_interface/tools/repl/test/Mathlib/lean-toolchain +1 -0
  365. itp_interface/tools/repl/test/Mathlib/test/20240209.expected.out +20 -0
  366. itp_interface/tools/repl/test/Mathlib/test/20240209.in +3 -0
  367. itp_interface/tools/repl/test/Mathlib/test/20240209.lean +4 -0
  368. itp_interface/tools/repl/test/Mathlib/test/H20231020.expected.out +8 -0
  369. itp_interface/tools/repl/test/Mathlib/test/H20231020.in +8 -0
  370. itp_interface/tools/repl/test/Mathlib/test/H20231020.lean +22 -0
  371. itp_interface/tools/repl/test/Mathlib/test/H20231110.expected.out +4 -0
  372. itp_interface/tools/repl/test/Mathlib/test/H20231110.in +4 -0
  373. itp_interface/tools/repl/test/Mathlib/test/H20231115.expected.out +19 -0
  374. itp_interface/tools/repl/test/Mathlib/test/H20231115.in +5 -0
  375. itp_interface/tools/repl/test/Mathlib/test/H20231115_2.expected.out +18 -0
  376. itp_interface/tools/repl/test/Mathlib/test/H20231115_2.in +4 -0
  377. itp_interface/tools/repl/test/Mathlib/test/H20231115_3.expected.out +10 -0
  378. itp_interface/tools/repl/test/Mathlib/test/H20231115_3.in +4 -0
  379. itp_interface/tools/repl/test/Mathlib/test/H20231214.in +9 -0
  380. itp_interface/tools/repl/test/Mathlib/test/H20231214.lean +30 -0
  381. itp_interface/tools/repl/test/Mathlib/test/H20231215.expected.out +4 -0
  382. itp_interface/tools/repl/test/Mathlib/test/H20231215.in +4 -0
  383. itp_interface/tools/repl/test/Mathlib/test/H20231215_2.expected.out +14 -0
  384. itp_interface/tools/repl/test/Mathlib/test/H20231215_2.in +3 -0
  385. itp_interface/tools/repl/test/Mathlib/test/exact.expected.out +37 -0
  386. itp_interface/tools/repl/test/Mathlib/test/exact.in +10 -0
  387. itp_interface/tools/repl/test/Mathlib/test/import_Mathlib.lean +1 -0
  388. itp_interface/tools/repl/test/Mathlib/test/induction.expected.out +29 -0
  389. itp_interface/tools/repl/test/Mathlib/test/induction.in +10 -0
  390. itp_interface/tools/repl/test/Mathlib/test/induction.lean +6 -0
  391. itp_interface/tools/repl/test/Mathlib/test/on_goal.expected.out +22 -0
  392. itp_interface/tools/repl/test/Mathlib/test/on_goal.in +5 -0
  393. itp_interface/tools/repl/test/Mathlib/test/pickle.expected.out +16 -0
  394. itp_interface/tools/repl/test/Mathlib/test/pickle.in +6 -0
  395. itp_interface/tools/repl/test/Mathlib/test/pickle_2.expected.out +4 -0
  396. itp_interface/tools/repl/test/Mathlib/test/pickle_2.in +4 -0
  397. itp_interface/tools/repl/test/Mathlib/test.sh +41 -0
  398. itp_interface/tools/repl/test/all_tactics.expected.out +13 -0
  399. itp_interface/tools/repl/test/all_tactics.in +1 -0
  400. itp_interface/tools/repl/test/by_cases.expected.out +25 -0
  401. itp_interface/tools/repl/test/by_cases.in +8 -0
  402. itp_interface/tools/repl/test/by_cases.lean +4 -0
  403. itp_interface/tools/repl/test/calc.expected.out +32 -0
  404. itp_interface/tools/repl/test/calc.in +1 -0
  405. itp_interface/tools/repl/test/def_eval.expected.out +9 -0
  406. itp_interface/tools/repl/test/def_eval.in +3 -0
  407. itp_interface/tools/repl/test/enableInitializersExecution.expected.out +2 -0
  408. itp_interface/tools/repl/test/enableInitializersExecution.in +1 -0
  409. itp_interface/tools/repl/test/file.expected.out +8 -0
  410. itp_interface/tools/repl/test/file.in +1 -0
  411. itp_interface/tools/repl/test/file.lean +5 -0
  412. itp_interface/tools/repl/test/have_by_sorry.expected.out +28 -0
  413. itp_interface/tools/repl/test/have_by_sorry.in +6 -0
  414. itp_interface/tools/repl/test/import_lean.in +1 -0
  415. itp_interface/tools/repl/test/incomplete.expected.out +18 -0
  416. itp_interface/tools/repl/test/incomplete.in +3 -0
  417. itp_interface/tools/repl/test/incomplete.lean +0 -0
  418. itp_interface/tools/repl/test/infotree.expected.out +20 -0
  419. itp_interface/tools/repl/test/infotree.in +2 -0
  420. itp_interface/tools/repl/test/invalid_tactic.expected.out +20 -0
  421. itp_interface/tools/repl/test/invalid_tactic.in +3 -0
  422. itp_interface/tools/repl/test/name_generator.expected.out +53 -0
  423. itp_interface/tools/repl/test/name_generator.in +18 -0
  424. itp_interface/tools/repl/test/no_goal_sorry.expected.out +11 -0
  425. itp_interface/tools/repl/test/no_goal_sorry.in +1 -0
  426. itp_interface/tools/repl/test/no_goal_sorry_2.expected.out +12 -0
  427. itp_interface/tools/repl/test/no_goal_sorry_2.in +1 -0
  428. itp_interface/tools/repl/test/options.expected.out +17 -0
  429. itp_interface/tools/repl/test/options.in +6 -0
  430. itp_interface/tools/repl/test/pickle_environment.expected.out +8 -0
  431. itp_interface/tools/repl/test/pickle_environment.in +7 -0
  432. itp_interface/tools/repl/test/pickle_environment_with_imports.expected.out +10 -0
  433. itp_interface/tools/repl/test/pickle_environment_with_imports.in +9 -0
  434. itp_interface/tools/repl/test/pickle_open.expected.out +8 -0
  435. itp_interface/tools/repl/test/pickle_open.in +7 -0
  436. itp_interface/tools/repl/test/pickle_open_2.expected.out +4 -0
  437. itp_interface/tools/repl/test/pickle_open_2.in +3 -0
  438. itp_interface/tools/repl/test/pickle_open_scoped.expected.out +18 -0
  439. itp_interface/tools/repl/test/pickle_open_scoped.in +8 -0
  440. itp_interface/tools/repl/test/pickle_open_scoped_2.expected.out +14 -0
  441. itp_interface/tools/repl/test/pickle_open_scoped_2.in +3 -0
  442. itp_interface/tools/repl/test/pickle_proof_state_1.expected.out +26 -0
  443. itp_interface/tools/repl/test/pickle_proof_state_1.in +15 -0
  444. itp_interface/tools/repl/test/pickle_proof_state_2.expected.out +4 -0
  445. itp_interface/tools/repl/test/pickle_proof_state_2.in +3 -0
  446. itp_interface/tools/repl/test/pickle_proof_state_env.expected.out +26 -0
  447. itp_interface/tools/repl/test/pickle_proof_state_env.in +15 -0
  448. itp_interface/tools/repl/test/pickle_scoped_notation.in +16 -0
  449. itp_interface/tools/repl/test/pickle_scoped_notation_2.in +3 -0
  450. itp_interface/tools/repl/test/proof_step.expected.out +18 -0
  451. itp_interface/tools/repl/test/proof_step.in +7 -0
  452. itp_interface/tools/repl/test/readme.expected.out +16 -0
  453. itp_interface/tools/repl/test/readme.in +5 -0
  454. itp_interface/tools/repl/test/sorry_hypotheses.expected.out +16 -0
  455. itp_interface/tools/repl/test/sorry_hypotheses.in +4 -0
  456. itp_interface/tools/repl/test/synthesize_placeholder.expected.out +7 -0
  457. itp_interface/tools/repl/test/synthesize_placeholder.in +1 -0
  458. itp_interface/tools/repl/test/tactic_mode_sorry.expected.out +14 -0
  459. itp_interface/tools/repl/test/tactic_mode_sorry.in +3 -0
  460. itp_interface/tools/repl/test/tactic_sorry.expected.out +12 -0
  461. itp_interface/tools/repl/test/tactic_sorry.in +1 -0
  462. itp_interface/tools/repl/test/term_sorry.expected.out +12 -0
  463. itp_interface/tools/repl/test/term_sorry.in +1 -0
  464. itp_interface/tools/repl/test/trace_simp.expected.out +41 -0
  465. itp_interface/tools/repl/test/trace_simp.in +15 -0
  466. itp_interface/tools/repl/test/unfinished_tactic_block.expected.out +11 -0
  467. itp_interface/tools/repl/test/unfinished_tactic_block.in +1 -0
  468. itp_interface/tools/repl/test/unknown_environment.expected.out +2 -0
  469. itp_interface/tools/repl/test/unknown_environment.in +1 -0
  470. itp_interface/tools/repl/test/unknown_proof_state.expected.out +14 -0
  471. itp_interface/tools/repl/test/unknown_proof_state.in +3 -0
  472. itp_interface/tools/repl/test/unknown_tactic.expected.out +14 -0
  473. itp_interface/tools/repl/test/unknown_tactic.in +3 -0
  474. itp_interface/tools/repl/test/variables.expected.out +26 -0
  475. itp_interface/tools/repl/test/variables.in +5 -0
  476. itp_interface/tools/repl/test.sh +43 -0
  477. itp_interface/tools/run_data_generation_transforms.py +350 -0
  478. itp_interface/tools/theorem_details.py +25 -0
  479. itp_interface/tools/training_data.py +358 -0
  480. itp_interface/tools/training_data_format.py +599 -0
  481. itp_interface-1.0.0.dist-info/METADATA +78 -0
  482. itp_interface-1.0.0.dist-info/RECORD +485 -0
  483. itp_interface-1.0.0.dist-info/WHEEL +4 -0
  484. itp_interface-1.0.0.dist-info/entry_points.txt +3 -0
  485. itp_interface-1.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,129 @@
1
+ import json
2
+ from tqdm import tqdm
3
+ from mpmath import mp, mpf, fmod
4
+ import hashlib
5
+ import os
6
+
7
+
8
+ def hash_string_to_int(arg):
9
+ return int(hashlib.sha256(arg.encode("utf-8")).hexdigest(), 16) % 10**30
10
+
11
+ def hash_string_to_float(arg):
12
+ x = mpf(hash_string_to_int(arg))
13
+ return fmod(x * mp.pi, mpf(1.))
14
+
15
+ def get_split(arg):
16
+ float_hash = hash_string_to_float(arg)
17
+ if float_hash < 0.98:
18
+ return "train"
19
+ elif float_hash < 0.99:
20
+ return "val"
21
+ else:
22
+ return "test"
23
+
24
+ def process_one_extraction_file(file):
25
+ # Load the file
26
+ extraction = json.load(open(file))
27
+ # Get the information
28
+ theory_file_path = extraction["theory_file_path"]
29
+ assert os.path.exists(theory_file_path), f"Could not find {theory_file_path}"
30
+ working_directory = extraction["working_directory"]
31
+ problem_names = extraction["problem_names"]
32
+ transitions = extraction["translations"]
33
+ # Leave in only the actual problem names
34
+ problem_names = [problem_name.strip() for problem_name in problem_names]
35
+ problem_names = [problem_name for problem_name in problem_names if (problem_name.startswith("lemma") or problem_name.startswith("theorem")) and not problem_name.startswith("lemmas")]
36
+
37
+ if not problem_names:
38
+ return {
39
+ "theory_file_path": theory_file_path,
40
+ "working_directory": working_directory,
41
+ "problems": []
42
+ }
43
+ # Filter out comments
44
+ good_transitions = []
45
+ for transition in transitions:
46
+ transition_text = transition[1].strip()
47
+ if transition_text.startswith("(*") and transition_text.endswith("*)"):
48
+ continue
49
+ if (transition_text.startswith("text \\<open>") or transition_text.startswith("txt \\<open>")) and transition_text.endswith("\\<close>"):
50
+ continue
51
+ good_transitions.append(transition)
52
+
53
+ # Filter out all the transitions that are not in proofs
54
+ current_problem_name = None
55
+ problem_name_to_transitions = {}
56
+ proof_open = False
57
+ for transition in good_transitions:
58
+ _, transition_text, proof_level, _ = transition
59
+ # print(transition_text, proof_level)
60
+ if transition_text in problem_names:
61
+ current_problem_name = transition_text
62
+ assert proof_level == 0, transition
63
+ problem_name_to_transitions[current_problem_name] = [transition]
64
+ proof_open = True
65
+ elif proof_level == 0:
66
+ proof_open = False
67
+ continue
68
+ elif proof_open:
69
+ problem_name_to_transitions[current_problem_name].append(transition)
70
+ else:
71
+ pass
72
+
73
+ assert None not in problem_name_to_transitions
74
+ assert set(problem_name_to_transitions.keys()) == set(problem_names)
75
+
76
+ problems = []
77
+ for problem_name in problem_names:
78
+ transitions = problem_name_to_transitions[problem_name]
79
+ full_proof_text = "\n".join([transition[1] for transition in transitions])
80
+ split = get_split(problem_name)
81
+ problems.append(
82
+ {
83
+ "problem_name": problem_name,
84
+ "full_proof_text": full_proof_text,
85
+ "transitions": transitions,
86
+ "split": split
87
+ }
88
+ )
89
+
90
+ return {
91
+ "theory_file_path": theory_file_path,
92
+ "working_directory": working_directory,
93
+ "problems": problems
94
+ }
95
+
96
+ def process_extractions(files, saving_directory):
97
+ """Process the extractions"""
98
+ for file in tqdm(files):
99
+ extraction_from_a_file = process_one_extraction_file(file)
100
+ basename = os.path.basename(file)
101
+ assert basename.endswith("thy_output.json"), basename
102
+
103
+ new_basename = basename.replace("thy_output.json", "thy_problems.json")
104
+ saving_file_path = os.path.join(saving_directory, new_basename)
105
+ json.dump(extraction_from_a_file, open(saving_file_path, "w"))
106
+
107
+
108
+ if __name__ == "__main__":
109
+ import argparse
110
+ import glob
111
+ import os
112
+ import shutil
113
+ parser = argparse.ArgumentParser(description='Processing and filtering proving data.')
114
+ parser.add_argument('--extraction-file-directory', '-efd', help='Where the parsed json files are')
115
+ parser.add_argument('--saving-directory', '-sd', help='Where to save the translation pairs')
116
+ args = parser.parse_args()
117
+
118
+ extraction_file_directory = args.extraction_file_directory
119
+ saving_directory = args.saving_directory
120
+ if os.path.isdir(saving_directory):
121
+ shutil.rmtree(saving_directory)
122
+ os.makedirs(saving_directory)
123
+
124
+ files = glob.glob(f"{extraction_file_directory}/**/*.thy_output.json", recursive=True)
125
+ process_extractions(files, saving_directory)
126
+ # json.dump(
127
+ # process_one_extraction_file("/home/qj213/afp_extractions/data/_home_qj213_afp-2022-12-06_thys_pGCL_Tutorial_Primitives.thy_output.json"),
128
+ # open("test.json", "w"),
129
+ # )
@@ -0,0 +1,167 @@
1
+ from __future__ import print_function
2
+
3
+ import os
4
+ import json
5
+ import grpc
6
+
7
+ from copy import copy
8
+ from func_timeout import func_set_timeout
9
+
10
+ import server_pb2
11
+ import server_pb2_grpc
12
+
13
+ MAX_MESSAGE_LENGTH = 10485760
14
+
15
+
16
+ def create_stub(port=9000):
17
+ channel = grpc.insecure_channel('localhost:{}'.format(port),
18
+ options=[('grpc.max_send_message_length', MAX_MESSAGE_LENGTH),
19
+ ('grpc.max_receive_message_length', MAX_MESSAGE_LENGTH)])
20
+ return server_pb2_grpc.ServerStub(channel)
21
+
22
+
23
+ class IsaFlexEnv:
24
+ def __init__(self, port=9000, isa_path="/Applications/Isabelle2020.app/Isabelle",
25
+ starter_string="theory Test imports Complex_Main begin",
26
+ working_directory="/Users/qj213/Projects/afp-2021-02-11/thys/Functional-Automata"):
27
+ self.port = port
28
+ self.isa_path = isa_path
29
+ self.starter_string = starter_string
30
+ self.working_directory = working_directory
31
+
32
+ self.stub = None
33
+ self.obs_string = None
34
+ self.successful_starting = False
35
+ self.reset()
36
+
37
+ def observation(self):
38
+ return self.obs_string
39
+
40
+ def is_finished(self, name_of_tls):
41
+ returned_string = self.stub.IsabelleCommand(server_pb2.IsaCommand(command=f"<is finished> {name_of_tls}")).state.strip()
42
+ if returned_string.startswith("t"):
43
+ return True
44
+ else:
45
+ return False
46
+
47
+ @staticmethod
48
+ def reward(done):
49
+ return 1. if done else 0.
50
+
51
+ def reset(self):
52
+ self.stub = create_stub(port=self.port)
53
+ try:
54
+ print(self.stub.InitialiseIsabelle(server_pb2.IsaPath(path=self.isa_path)).message)
55
+ print(self.stub.IsabelleWorkingDirectory(server_pb2.IsaPath(path=self.working_directory)).message)
56
+ print(self.stub.IsabelleContext(server_pb2.IsaContext(context=self.starter_string)).message)
57
+ self.successful_starting = True
58
+ except Exception as e:
59
+ print("Failure at initialising Isabelle process. "
60
+ "Make sure the path your provide is where the Isabelle executable is.")
61
+ print(e)
62
+ return self.obs_string
63
+
64
+ @func_set_timeout(1800, allowOverride=True)
65
+ def step_to_top_level_state(self, action, tls_name, new_name):
66
+ # last_obs_string = self.stub.IsabelleCommand(server_pb2.IsaCommand(command=f"<get state> {tls_name}")).state
67
+ obs_string = "Step error"
68
+ done = False
69
+ try:
70
+ obs_string = self.stub.IsabelleCommand(
71
+ server_pb2.IsaCommand(command=f"<apply to top level state> {tls_name} <apply to top level state> {action} <apply to top level state> {new_name}")).state
72
+ except Exception as e:
73
+ print("***Something went wrong***")
74
+ print(e)
75
+
76
+ done = self.is_finished(new_name)
77
+ # done = True if ("subgoal" in last_obs_string and "subgoal" not in obs_string) else False
78
+ return obs_string, self.reward(done), done, {}
79
+
80
+ def proceed_after(self, line_string):
81
+ return self.post(f"<proceed after> {line_string}", forceTimeout=10000)
82
+
83
+ def clone_to_new_name(self, new_name):
84
+ return self.post(f"<clone> default <clone> {new_name}", forceTimeout=10)
85
+
86
+ @func_set_timeout(1800, allowOverride=True)
87
+ def post(self, action):
88
+ return self.stub.IsabelleCommand(server_pb2.IsaCommand(command=action)).state
89
+ # last_obs_string = self.obs_string
90
+ # try:
91
+ # self.obs_string = self.stub.IsabelleCommand(server_pb2.IsaCommand(command=action)).state
92
+ # except Exception as e:
93
+ # print("***Something went wrong***")
94
+ # print(e)
95
+
96
+ # # done = self.is_finished(self.obs_string)
97
+ # done = self.is_finished("default")
98
+
99
+ # return self.obs_string, self.reward(done), done, {}
100
+
101
+ # def human_play(self):
102
+ # done = False
103
+ # while not done:
104
+ # print(self.obs_string)
105
+ # human_proof_line = input("Your tactic is my command: ")
106
+ # if human_proof_line == "exit":
107
+ # break
108
+ # else:
109
+ # obs, _, done, _ = self.step(human_proof_line)
110
+ # print(obs)
111
+ # print("=" * 50)
112
+
113
+ # def clone_top_level_state(self, tls_name):
114
+ # try:
115
+ # message = self.stub.IsabelleCommand(server_pb2.IsaCommand(command=f"<clone> {tls_name}")).state
116
+ # print(message)
117
+ # print(f"Cloned state called {tls_name}")
118
+ # except Exception as e:
119
+ # print("**Clone unsuccessful**")
120
+ # print(e)
121
+
122
+ def proceed_to_line(self, line_stirng, before_after):
123
+ assert before_after in ["before", "after"]
124
+ try:
125
+ command = f"<proceed {before_after}> {line_stirng}"
126
+ print(command)
127
+ message = self.stub.IsabelleCommand(server_pb2.IsaCommand(command=command)).state
128
+ print(message)
129
+ except Exception as e:
130
+ print("Failure to proceed before line")
131
+ print(e)
132
+
133
+
134
+ def parsed_json_to_env_and_dict(path_to_json, afp_path, port=9000, isa_path="/Applications/Isabelle2020.app/Isabelle"):
135
+ save_dict = json.load(open(path_to_json))
136
+ project = save_dict["project"]
137
+ wd = os.path.join(afp_path, "thys", project)
138
+ segments = save_dict["segments"]
139
+ # Find starter string
140
+ starter_string = None
141
+ for line in segments:
142
+ if line.strip().startswith("theory"):
143
+ starter_string = " ".join(line.strip().split("\n"))
144
+ break
145
+ assert starter_string
146
+ # print(port, isa_path, starter_string, wd, segments)
147
+ return IsaFlexEnv(port=port, isa_path=isa_path,
148
+ starter_string=starter_string,
149
+ working_directory=wd), save_dict
150
+
151
+
152
+ def initialise_env(port, isa_path, theory_file_path=None, working_directory=None):
153
+ return IsaFlexEnv(port=port, isa_path=isa_path, starter_string=theory_file_path, working_directory=working_directory)
154
+
155
+
156
+ def initialise_problem(env, problem_name):
157
+ env.proceed_to_line(problem_name, "after")
158
+ return env
159
+
160
+
161
+ if __name__ == '__main__':
162
+ env = initialise_env(8000,
163
+ working_directory="/Applications/Isabelle2021.app/src/HOL/Examples",
164
+ isa_path="/Applications/Isabelle2021.app",
165
+ theory_file_path="/Applications/Isabelle2021.app/src/HOL/Examples/Adhoc_Overloading_Examples.thy"
166
+ )
167
+ print(env.post("<get_ancestors>"))
@@ -0,0 +1,74 @@
1
+ from PisaFlexibleClient import initialise_env
2
+
3
+
4
+ theorem2 = """theory FunWithFunctions imports Complex_Main begin
5
+ theorem 1:
6
+ fixes f:: "real \<Rightarrow> real"
7
+ and g:: "real \<Rightarrow> real"
8
+ assumes "\<forall> x. f x = 3 * x - 8"
9
+ and "\<forall> x. g (f x) = 2 * x powr 2 + 5 * x - 3"
10
+ shows "g (-5) = 4"
11
+ proof -
12
+ have "f 1 = -5"
13
+ by (simp add: assms(1))
14
+ then have "g (-5) = g (f 1)"
15
+ by auto
16
+ then show ?thesis
17
+ by (simp add: assms(2))
18
+ qed"""
19
+
20
+ theorem2_sledgehammer = """theory NA imports Main begin
21
+ theorem 1: "1+2=3"
22
+ proof -
23
+ show ?thesis
24
+ sledgehammer
25
+ qed"""
26
+
27
+ def get_parsed(env, theory, tls_name='default'):
28
+ # env.reset()
29
+ env.post('<initialise>')
30
+ steps = env.post(f"<parse text> ${theory}")
31
+ return steps.split('<SEP>')
32
+
33
+ def run_proof_example(env, steps, tls_name='default'):
34
+ # env.reset()
35
+ env.post('<initialise>')
36
+
37
+ for i, step in enumerate(steps):
38
+ print("(%d) %s" % (i, step))
39
+ obs, reward, done, metadata = env.step_to_top_level_state(
40
+ action=step,
41
+ tls_name=tls_name,
42
+ new_name=tls_name
43
+ )
44
+ print("\tobs: %s\n\treward: %s\n\tdone: %s" % (obs, reward, done))
45
+
46
+
47
+ if __name__ == '__main__':
48
+ import argparse
49
+ parser = argparse.ArgumentParser()
50
+ parser.add_argument('--isa-path', default='/private/home/aqj/Isabelle2021')
51
+ parser.add_argument('--working-dir', default='/private/home/aqj/afp-2021-10-22/thys/FunWithFunctions')
52
+ parser.add_argument('--theory-file', default='/private/home/aqj/afp-2021-10-22/thys/FunWithFunctions/FunWithFunctions.thy')
53
+
54
+ args = parser.parse_args()
55
+
56
+ # import ipdb; ipdb.set_trace(context=20)
57
+ env = initialise_env(9000,
58
+ working_directory=args.working_dir,
59
+ isa_path=args.isa_path,
60
+ theory_file_path=args.theory_file
61
+ )
62
+ steps = get_parsed(env, theorem2)
63
+
64
+ steps = [step for step in steps if step!="$"]
65
+ print(steps)
66
+
67
+ new_env = initialise_env(9000,
68
+ working_directory=args.working_dir,
69
+ isa_path=args.isa_path,
70
+ theory_file_path=args.theory_file
71
+ )
72
+ run_proof_example(new_env, steps)
73
+
74
+ # print(env.post("<get_ancestors>"))
@@ -0,0 +1,23 @@
1
+ from PisaFlexibleClient import IsaFlexEnv
2
+
3
+ import os
4
+
5
+
6
+ if __name__ == "__main__":
7
+ isa_path = input("Path to Isabelle (default /home/qj213/Isabelle2021): ")
8
+ isa_path = "/home/qj213/Isabelle2021" if not isa_path else isa_path.strip()
9
+ afp_path = input("Path to the working directory (default /home/qj213/Isabelle2021/src/HOL/Examples): ")
10
+ afp_path = "/home/qj213/Isabelle2021/src/HOL/Examples" if not afp_path else afp_path.strip()
11
+ file_path = input("Path to a theory file (default /home/qj213/Isabelle2021/src/HOL/Examples/Drinker.thy): ")
12
+ file_path = "/home/qj213/Isabelle2021/src/HOL/Examples/Drinker.thy" if not file_path else file_path.strip()
13
+ env = IsaFlexEnv(
14
+ port=8000, isa_path=isa_path, starter_string=file_path,
15
+ working_directory=afp_path,
16
+ )
17
+
18
+ while True:
19
+ proof_step = input("Your chosen proof step ('<fin>' to exit): ")
20
+ if proof_step.strip().startswith("<fin>"):
21
+ break
22
+ obs, rewards, done, _ = env.step(proof_step)
23
+ print(obs)
@@ -0,0 +1,14 @@
1
+ if __name__ == "__main__":
2
+ import argparse
3
+ import os
4
+ import json
5
+ parser = argparse.ArgumentParser(description="Convert Scala dump to test name JSONs.")
6
+ parser.add_argument("--scala-dump-path", required=True, help="Scala dump path.")
7
+ args = parser.parse_args()
8
+
9
+ for file in os.listdir(args.scala_dump_path):
10
+ if file.startswith("test_name_"):
11
+ with open(os.path.join(args.scala_dump_path, file), "r") as f:
12
+ lines = f.read().strip()
13
+ thy_path, theorem_decl = lines.split("\n")
14
+ json.dump([[thy_path, theorem_decl]], open(os.path.join(args.scala_dump_path, file+".json"), "w"))
@@ -0,0 +1,72 @@
1
+ import os
2
+ import argparse
3
+ import random
4
+ from smart_open import open
5
+ from tqdm import tqdm
6
+
7
+
8
+ # Token id: 14457; token: Cambridge
9
+ # We use this token to separate the source and the target
10
+ # It's unlikely to appear in the Isabelle proof corpus as it's the name of a place
11
+ # Token id: 50256; token <|endoftext|>
12
+
13
+ def process(src_path, tgt_path, output_path, mode):
14
+ random.seed(0)
15
+ if not output_path.startswith('gs://'):
16
+ os.makedirs(os.path.dirname(output_path), exist_ok=True)
17
+
18
+ with open(src_path) as src_fhand, open(tgt_path) as tgt_fhand, open(
19
+ output_path, "w") as output_fhand:
20
+ src_lines = src_fhand.readlines()
21
+ tgt_lines = tgt_fhand.readlines()
22
+
23
+ total_lines = len(src_lines)
24
+ random_order = list(range(total_lines))
25
+ random.shuffle(random_order)
26
+ for index in tqdm(random_order):
27
+ src_line = src_lines[index]
28
+ tgt_line = tgt_lines[index]
29
+
30
+ if mode == "state_only":
31
+ output_fhand.write(src_line.strip().replace("State:",
32
+ "<ISA_OBS>") + " Cambridge " + tgt_line.strip() + " <|endoftext|> ")
33
+ elif mode == "proof_only":
34
+ output_fhand.write(src_line.strip().replace("Proof:", "<ISA_PRF>") + " Cambridge " + tgt_line.strip() + " <|endoftext|> ")
35
+ elif mode == "proof_and_state":
36
+ output_fhand.write(
37
+ src_line.strip().replace("<PS_SEP> State:",
38
+ "<ISA_OBS>").replace("Proof:",
39
+ "<ISA_PRF>")
40
+ + " Cambridge " + tgt_line.strip() + " <|endoftext|> "
41
+ )
42
+ else:
43
+ output_fhand.write(src_line.strip() + " Cambridge " + tgt_line.strip() + " <|endoftext|> ")
44
+
45
+
46
+ def create_data(data_dir, output_dir, name, mode):
47
+ train_src_path = os.path.join(data_dir, "train.src")
48
+ train_tgt_path = os.path.join(data_dir, "train.tgt")
49
+ # assert name in ["state_only", "proof_only", "proof_and_state"]
50
+ train_output_path = os.path.join(output_dir,
51
+ "train", "{}_train.txt".format(name))
52
+ val_src_path = os.path.join(data_dir, "val.src")
53
+ val_tgt_path = os.path.join(data_dir, "val.tgt")
54
+ val_output_path = os.path.join(output_dir,
55
+ "val", "{}_val.txt".format(name))
56
+ process(train_src_path, train_tgt_path, train_output_path, mode=mode)
57
+ process(val_src_path, val_tgt_path, val_output_path, mode=mode)
58
+
59
+
60
+ if __name__ == "__main__":
61
+ parser = argparse.ArgumentParser(
62
+ description="Create the .txt files for fine-tuning from the raw PISA src-tgt pairs.")
63
+ parser.add_argument("--data-dir", type=str, default="",
64
+ help="Input directory (default: current directory)")
65
+ parser.add_argument("--output-dir", type=str, default="/home/qj213/data",
66
+ help="Output directory (default: home data directory)")
67
+ parser.add_argument("--name", type=str,
68
+ help="Name of the currently processed data.")
69
+ parser.add_argument("--mode", type=str,
70
+ help="mode of the currently processed data (state_only, proof_only, proof_and_state, custom).")
71
+ args = parser.parse_args()
72
+ create_data(args.data_dir, args.output_dir, args.name, args.mode)