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,79 @@
1
+ from .pisa_client import initialise_env
2
+
3
+
4
+ if __name__ == '__main__':
5
+ env = initialise_env()
6
+ default_st = env.initialise()
7
+
8
+ # Default state
9
+ print(default_st)
10
+
11
+ # Returns error string!
12
+ # obs_string = env.step('default', 'theory Drinker', 'state0')
13
+ # print(obs_string)
14
+
15
+ # Initialization of theory
16
+ obs_string = env.step('default', 'theory Drinker imports Main begin', 'state0')
17
+ print(obs_string)
18
+
19
+ # Declare a lemma
20
+ obs_string = env.step('state0',
21
+ 'lemma de_Morgan: assumes "\\<not> (\\<forall>x. P x)" shows "\\<exists>x. \\<not> P x"',
22
+ 'state1')
23
+ print(env.get_state('state1'))
24
+
25
+ # all_lemmas = env.get_total_lemmas('state1')
26
+ # print("Num lemmas: " + str(len(all_lemmas)))
27
+ # for lemma in all_lemmas: # Sanity check with less complicated/weird lemmas
28
+ # if "ln_gt_zero" in lemma.name:
29
+ # print(lemma.dfn)
30
+
31
+ # Attempt to use Sledgehammer
32
+ obs_string = env.apply_hammer('state1', 'hammered')
33
+ print(obs_string)
34
+ print("Finished? " + str(env.is_finished('hammered')))
35
+
36
+ # Prove the lemma
37
+ obs_string = env.step('state1',
38
+ "proof (rule classical)",
39
+ 'state2')
40
+ print(obs_string)
41
+ obs_string = env.step('state2',
42
+ "assume \"\\<nexists>x. \\<not> P x\"",
43
+ 'state3')
44
+ print(obs_string)
45
+ obs_string = env.step('state3',
46
+ """
47
+ have "\\<forall>x. P x"
48
+ proof
49
+ fix x show "P x"
50
+ proof (rule classical)
51
+ assume "\\<not> P x"
52
+ then have "\\<exists>x. \\<not> P x" ..
53
+ with \\<open>\\<nexists>x. \\<not> P x\\<close> show ?thesis by contradiction
54
+ qed
55
+ qed
56
+ """,
57
+ 'state4')
58
+ print(obs_string)
59
+ obs_string = env.step('state4',
60
+ "with \\<open>\\<not> (\\<forall>x. P x)\\<close> show ?thesis by contradiction",
61
+ 'state5')
62
+ print(obs_string)
63
+
64
+ # Proof is not done until qed
65
+ print("Finished? " + str(env.is_finished('state5')))
66
+ # Re-using the same state is ok too
67
+ obs_string = env.step('state5',
68
+ 'qed',
69
+ 'state5')
70
+ print("Finished? " + str(env.is_finished('state5')))
71
+
72
+ # # Test some non-sledgehammerable theorems
73
+ # obs_string = env.step('state0',
74
+ # 'lemma conc_empty: "conc xs Empty = xs"',
75
+ # 'state1')
76
+ # print(env.get_state('state1'))
77
+
78
+ # obs_string = env.apply_hammer('state1', 'hammered2')
79
+ # print(obs_string)
@@ -0,0 +1,59 @@
1
+ import re
2
+
3
+
4
+ def filter_comments(input_text, opening_marks, closing_marks):
5
+ output_text = re.sub(re.compile("{}.*?{}".format(opening_marks, closing_marks), re.DOTALL), "", input_text)
6
+ return output_text
7
+
8
+
9
+ def filter_isar_comments(input_text):
10
+ text = filter_comments(input_text, "\(\*", "\*\)")
11
+ text = filter_comments(text, "text\\\<open\>", "\\\<close\>")
12
+ return text
13
+
14
+
15
+ def spit_out_first_parsable_segment(input_text: str):
16
+ find_first_line_separator = input_text.find("\n")
17
+ if find_first_line_separator == -1:
18
+ return input_text.strip(), ""
19
+
20
+ first_line = input_text[:find_first_line_separator]
21
+
22
+ # Theorem definitions must be read until the proof starts
23
+ if "theorem" in first_line or "lemma" in first_line:
24
+ find_first_proof = input_text.find("proof")
25
+ find_first_apply = input_text.find("apply")
26
+ find_first_by = input_text.find("by")
27
+
28
+ if find_first_proof != -1 and find_first_proof < find_first_apply and find_first_proof < find_first_by:
29
+ truncation_index = find_first_proof
30
+ elif find_first_apply != -1 and find_first_apply < find_first_proof and find_first_apply < find_first_by:
31
+ truncation_index = find_first_apply
32
+ elif find_first_by != -1 and find_first_by < find_first_proof and find_first_by < find_first_apply:
33
+ truncation_index = find_first_by
34
+ else:
35
+ raise NotImplementedError("We haven't thought of this situation. The Isar proof is as follows:\n" + input_text)
36
+
37
+ first_bit = input_text[:truncation_index].strip()
38
+ first_bit = first_bit.replace("\n", " ")
39
+
40
+ return first_bit, input_text[truncation_index:].strip()
41
+
42
+ # Inner syntax must not be read in two segments
43
+ if first_line.count('"') % 2 == 0:
44
+ return first_line.strip(), input_text[find_first_line_separator:].strip()
45
+ # Find the next first double quotation mark as the end
46
+ find_first_double_quotation = input_text[find_first_line_separator:].find('"')
47
+ if find_first_double_quotation == -1:
48
+ raise AssertionError
49
+ return first_line.strip() + " " + input_text[find_first_line_separator:][:find_first_double_quotation+1].strip(), \
50
+ input_text[find_first_line_separator:][find_first_double_quotation + 1:]
51
+
52
+
53
+ def spit_out_all_parsable_segments(input_text: str):
54
+ segments = list()
55
+ rest_of_the_text = input_text.strip()
56
+ while rest_of_the_text:
57
+ first_segment, rest_of_the_text = spit_out_first_parsable_segment(rest_of_the_text)
58
+ segments.append(first_segment)
59
+ return segments
@@ -0,0 +1,29 @@
1
+ import subprocess
2
+ import time
3
+ import psutil
4
+ import signal
5
+
6
+
7
+ def start_server(jar_path, port, outputfile=None, errorfile=None):
8
+ command = ["java", "-cp", jar_path, f"pisa.server.PisaOneStageServer{port}"]
9
+ outputfile = subprocess.PIPE if outputfile is None else outputfile
10
+ errorfile = subprocess.PIPE if errorfile is None else errorfile
11
+ server_subprocess_id = subprocess.Popen(
12
+ command,
13
+ stdout=open(outputfile, "w"),
14
+ stderr=open(errorfile, "w"),
15
+ ).pid
16
+ time.sleep(5)
17
+ return server_subprocess_id
18
+
19
+
20
+ def close_server(server_subprocess_id):
21
+ # Kill the server and its subprocesses
22
+ try:
23
+ p_process = psutil.Process(server_subprocess_id)
24
+ children = p_process.children(recursive=True)
25
+ for process in children:
26
+ process.send_signal(signal.SIGTERM)
27
+ p_process.send_signal(signal.SIGTERM)
28
+ except psutil.NoSuchProcess:
29
+ pass
@@ -0,0 +1,257 @@
1
+ package pisa.agent
2
+
3
+ import de.unruh.isabelle.control.{Isabelle, IsabelleMLException}
4
+ import de.unruh.isabelle.mlvalue.MLFunction2
5
+ import de.unruh.isabelle.pure.{Theory, ToplevelState}
6
+ import de.unruh.isabelle.mlvalue.Implicits._
7
+ import de.unruh.isabelle.pure.Implicits._
8
+ import pisa.server.{PisaOS, Transition}
9
+
10
+ import _root_.java.nio.file.{Files, Path}
11
+ import java.io.PrintWriter
12
+ import scala.collection.mutable.ListBuffer
13
+ import scala.concurrent.ExecutionContext
14
+ import scala.concurrent._
15
+ import scala.concurrent.duration._
16
+
17
+ class CheckSyntax(path_to_isa_bin: String, path_to_file: String, working_directory: String) {
18
+ def divide_by_theorem(total_string: String): (String, List[String]) = {
19
+ val keyword = "theorem"
20
+ val split_theorems = total_string.split(keyword)
21
+ split_theorems.foreach(println)
22
+ val header = split_theorems.head
23
+ (header, split_theorems.drop(1).map(x => keyword + x).toList)
24
+ }
25
+
26
+ def try_to_parse_theorem(theorem_string: String): Boolean = {
27
+ var trial_state = pisaos.copy_tls.retrieveNow
28
+ try {
29
+ for ((transition, text) <- parse_text(thy, theorem_string).force.retrieveNow) {
30
+ if (text.trim.isEmpty) {}
31
+ else {
32
+ println(text)
33
+ trial_state = step(text, trial_state)
34
+ }
35
+ }
36
+ true
37
+ } catch {
38
+ case e: Throwable =>
39
+ println(e); false
40
+ }
41
+ }
42
+
43
+ // def try_to_parse_theorem_with_hammer(theorem_string: String): (Boolean, String) = {
44
+ // var trial_state = pisaos.copy_tls.retrieveNow
45
+ // var stateActionTotal: String = ""
46
+ // var current_state_string: String = pisaos.getStateString(trial_state)
47
+ // var current_proof_level: Int = pisaos.getProofLevel(trial_state)
48
+ // try {
49
+ // for ((_, text) <- parse_text(thy, theorem_string).force.retrieveNow) {
50
+ // if (text.trim.isEmpty) {}
51
+ // else if (text.trim == "sledgehammer") {
52
+ // val hammer_results = pisaos.normal_with_hammer(trial_state, List[String](), List[String](), 60000)
53
+ // val hammered_string = {
54
+ // if (hammer_results._1) {
55
+ // val hammer_strings = hammer_results._2
56
+ // var found = false
57
+ // var real_string = ""
58
+ // for (attempt_string <- hammer_strings) {
59
+ // if (!found && (attempt_string contains "Try this:")) {
60
+ // found = true
61
+ // real_string = attempt_string.trim.stripPrefix("Try this:").trim.split('(').dropRight(1).mkString("(")
62
+ // }
63
+ // }
64
+ // if (found) real_string
65
+ // else throw new IsabelleMLException
66
+ // } else {
67
+ // throw IsabelleMLException
68
+ // }
69
+ // }.trim
70
+ // trial_state = step(hammered_string, trial_state, 20000)
71
+ // stateActionTotal = stateActionTotal + (current_state_string + "<\\STATESEP>" + hammered_string.trim + "<\\STATESEP>" + s"$current_proof_level" + "<\\TRANSEP>")
72
+ // current_state_string = pisaos.getStateString(trial_state)
73
+ // current_proof_level = pisaos.getProofLevel(trial_state)
74
+ // } else {
75
+ // trial_state = step(text, trial_state)
76
+ // stateActionTotal = stateActionTotal + (current_state_string + "<\\STATESEP>" + text.trim + "<\\STATESEP>" + s"$current_proof_level" + "<\\TRANSEP>")
77
+ // current_state_string = pisaos.getStateString(trial_state)
78
+ // current_proof_level = pisaos.getProofLevel(trial_state)
79
+ // }
80
+ // }
81
+ // (true, stateActionTotal)
82
+ // } catch {
83
+ // case e: Throwable => (false, "")
84
+ // }
85
+ // }
86
+
87
+ def try_to_drive_contradictions_from_theorem(theorem_string: String): Boolean = {
88
+ val theorem_lines = theorem_string.split("\n")
89
+ val theorem_decl = theorem_lines.head
90
+ // Find where the keyword "shows" starts in theorem_decl
91
+ val show_start = theorem_decl.indexOf("shows")
92
+ if (show_start == -1) false
93
+ else if (theorem_string.contains("sos")) false
94
+ else {
95
+ val modified_theorem_decl = theorem_decl.substring(0, show_start) + """shows "False""""
96
+ val modified_theorem_string = modified_theorem_decl + "\n" + theorem_lines.drop(1).mkString("\n")
97
+ try_to_parse_theorem(modified_theorem_string)
98
+ }
99
+ }
100
+
101
+ def get_all_parsable_theorems(list_of_theorem_strings: List[String]): List[String] = {
102
+ list_of_theorem_strings.filter(x => try_to_parse_theorem(x))
103
+ }
104
+
105
+ def get_all_parsable_theorems : List[String] = get_all_parsable_theorems(individual_theorem_strings)
106
+
107
+ // def get_all_parsable_hammer_theorems(list_of_theorem_strings: List[String]): String = {
108
+ // val list_of_theorem_strings_parsed: List[(Boolean, String)] = list_of_theorem_strings.map(try_to_parse_theorem_with_hammer)
109
+ // val parsable_strings: List[String] = list_of_theorem_strings_parsed.filter(x => x._1).map(x => x._2)
110
+ // parsable_strings.mkString
111
+ // }
112
+
113
+ // def get_all_parsable_hammer_theorems: String = get_all_parsable_hammer_theorems(individual_theorem_strings)
114
+
115
+ def get_all_contradictions(list_of_theorem_strings: List[String]): List[String] = {
116
+ list_of_theorem_strings.filter(x => try_to_drive_contradictions_from_theorem(x))
117
+ }
118
+
119
+ def get_all_contradictions: List[String] = get_all_contradictions(individual_theorem_strings)
120
+
121
+ def step(isar_string: String, top_level_state: ToplevelState, timeout_in_millis: Int = 10000): ToplevelState = {
122
+ pisaos.step(isar_string, top_level_state, timeout_in_millis)
123
+ }
124
+
125
+ // Load PisaOS and useful methods and attributes
126
+ val pisaos = new PisaOS(path_to_isa_bin = path_to_isa_bin, path_to_file = path_to_file, working_directory = working_directory)
127
+ implicit val isabelle: Isabelle = pisaos.isabelle
128
+ implicit val ec: ExecutionContext = pisaos.ec
129
+ val thy: Theory = pisaos.thy1
130
+ val parse_text: MLFunction2[Theory, String, List[(Transition.T, String)]] = pisaos.parse_text
131
+ val top_level_state: ToplevelState = pisaos.toplevel
132
+ // Names of all the parsable theorems
133
+ var parsable_theorem_names: ListBuffer[String] = ListBuffer[String]()
134
+ // String of the entire file
135
+ val file_string: String = Files.readString(Path.of(path_to_file))
136
+ val (header: String, individual_theorem_strings: List[String]) = divide_by_theorem(file_string)
137
+ pisaos.step(header)
138
+
139
+
140
+ // Some constants
141
+ val header_script: String = """(*
142
+ | Authors: Codex from Lean
143
+ |*)
144
+ |
145
+ |theory miniF2F_correct
146
+ | imports
147
+ | HOL.HOL
148
+ | Complex_Main
149
+ | "HOL-Library.Code_Target_Numeral"
150
+ | "HOL-Library.Sum_of_Squares"
151
+ | "Symmetric_Polynomials.Vieta"
152
+ | "HOL-Computational_Algebra.Computational_Algebra"
153
+ | "HOL-Number_Theory.Number_Theory"
154
+ |begin
155
+ |""".stripMargin
156
+ val ending_script: String = """
157
+ |end
158
+ |""".stripMargin
159
+ }
160
+
161
+ object CheckSyntax {
162
+ def main(args: Array[String]): Unit = {
163
+ val theory_path: String = args(0).trim
164
+ val dump_path: String = args(1).trim
165
+ val syntax_checker: CheckSyntax = new CheckSyntax(
166
+ path_to_isa_bin = "/home/qj213/Isabelle2021",
167
+ path_to_file = theory_path,
168
+ working_directory = "/home/qj213/afp-2021-10-22/thys/Symmetric_Polynomials"
169
+ )
170
+
171
+ new PrintWriter("syntax_correct_theorem_names") {
172
+ for (str <- syntax_checker.get_all_parsable_theorems) {
173
+ write(str.replaceAll("\n", " ").replaceAll(" +", " ").trim)
174
+ write("\n")
175
+ }
176
+ close()
177
+ }
178
+
179
+ for ((theorem_full, i) <- syntax_checker.get_all_parsable_theorems.zipWithIndex) {
180
+ val theorem_name: String = theorem_full.split(":").head.split(" ")(1)
181
+ val theorem_decl: String = theorem_full.trim.split("\n").dropRight(1).mkString.replaceAll(" +", " ")
182
+ val theory_path = dump_path + s"/$theorem_name.thy"
183
+ new PrintWriter(theory_path) {
184
+ write(s"""(*
185
+ | Authors: Codex from Lean
186
+ |*)
187
+ |
188
+ |theory $theorem_name
189
+ | imports
190
+ | HOL.HOL
191
+ | Complex_Main
192
+ | "HOL-Library.Code_Target_Numeral"
193
+ | "HOL-Library.Sum_of_Squares"
194
+ | "Symmetric_Polynomials.Vieta"
195
+ | "HOL-Computational_Algebra.Computational_Algebra"
196
+ | "HOL-Number_Theory.Number_Theory"
197
+ |begin
198
+ |""".stripMargin)
199
+ write(theorem_full)
200
+ write("""
201
+ |end
202
+ |""".stripMargin)
203
+ close()
204
+ }
205
+
206
+ new PrintWriter(dump_path + s"/test_name_$i") {
207
+ write(theory_path)
208
+ write("\n")
209
+ write(theorem_decl)
210
+ close()
211
+ }
212
+ }
213
+
214
+
215
+ // new PrintWriter(dump_path) {
216
+ // write(syntax_checker.header_script)
217
+ // for (theorem_decl <- syntax_checker.get_all_parsable_theorems) {
218
+ // write(theorem_decl)
219
+ // }
220
+ // write(syntax_checker.ending_script)
221
+ // close()
222
+ // }
223
+ }
224
+ }
225
+
226
+ // object ParseWithHammer {
227
+ // def main(args: Array[String]): Unit = {
228
+ // val theory_path: String = args(0).trim
229
+ // val dump_path: String = args(1).trim
230
+ // val syntax_checker: CheckSyntax = new CheckSyntax(
231
+ // path_to_isa_bin = "/home/qj213/Isabelle2021",
232
+ // path_to_file = theory_path,
233
+ // working_directory = "/home/qj213/afp-2021-10-22/thys/Symmetric_Polynomials"
234
+ // )
235
+ // new PrintWriter(dump_path) {
236
+ // write(syntax_checker.get_all_parsable_hammer_theorems)
237
+ // close()
238
+ // }
239
+ // }
240
+ // }
241
+
242
+
243
+ object DriveContradictions {
244
+ def main(args: Array[String]) : Unit = {
245
+ val theory_path: String = args(0).trim
246
+ val dump_path: String = args(1).trim
247
+ val syntax_checker: CheckSyntax = new CheckSyntax(
248
+ path_to_isa_bin = "/home/qj213/Isabelle2021",
249
+ path_to_file = theory_path,
250
+ working_directory = "/home/qj213/afp-2021-10-22/thys/Symmetric_Polynomials"
251
+ )
252
+ new PrintWriter(dump_path) {
253
+ write(syntax_checker.get_all_contradictions.mkString("\n"))
254
+ close()
255
+ }
256
+ }
257
+ }
@@ -0,0 +1,29 @@
1
+ package pisa.agent
2
+
3
+ import pisa.server.PisaOS
4
+ import de.unruh.isabelle.control.Isabelle
5
+ import scala.concurrent.ExecutionContext
6
+
7
+ object DepThms {
8
+ val path_to_isa_bin: String = "/home/qj213/Isabelle2022"
9
+ val working_directory: String = "/home/qj213/Isabelle2022/src/HOL/Computational_Algebra"
10
+ val path_to_file: String = "/home/qj213/Isabelle2022/src/HOL/Computational_Algebra/Primes.thy"
11
+ val theorem_string = "by (auto simp add: prime_int_iff')"
12
+
13
+ def main(args: Array[String]): Unit = {
14
+ val pisaos = new PisaOS(
15
+ path_to_isa_bin=path_to_isa_bin,
16
+ path_to_file=path_to_file,
17
+ working_directory=working_directory
18
+ )
19
+ implicit val isabelle: Isabelle = pisaos.isabelle
20
+ implicit val ec: ExecutionContext = pisaos.ec
21
+
22
+ pisaos.step_to_transition_text(theorem_string, after = false)
23
+ println(pisaos.getStateString(pisaos.toplevel))
24
+
25
+ pisaos.top_level_state_map += ("default" -> pisaos.copy_tls)
26
+ println("~"*50)
27
+ println(pisaos.fact_definition("default", "prime_dvd_fact_iff"))
28
+ }
29
+ }
@@ -0,0 +1,46 @@
1
+ package pisa.agent
2
+
3
+ import net.liftweb.json.{DefaultFormats, parse}
4
+ import pisa.server.PisaOS
5
+
6
+ import java.io.PrintWriter
7
+ import scala.io.Source
8
+
9
+ object PisaStat {
10
+ implicit val formats: DefaultFormats = DefaultFormats
11
+
12
+ def main(args: Array[String]): Unit = {
13
+ val test_theorem_number: String = args(0).split('/').last.split('.').head.split('_').last
14
+ val dump_path: String = "results/pisa_stat"
15
+ val json_element = parse(
16
+ {
17
+ val textSource = Source.fromFile(args(0))
18
+ val str = textSource.mkString
19
+ textSource.close()
20
+ str
21
+ }
22
+ ).children.head
23
+ val theory_path = json_element(0).extract[String].replaceAll("/home/ywu/afp-2021-02-11", "/home/qj213/afp-2021-10-22")
24
+ val thys_index = theory_path.split("/").indexOf("thys")
25
+ val working_directory = {
26
+ if (theory_path.contains("miniF2F")) "/home/qj213/afp-2021-10-22/thys/Symmetric_Polynomials"
27
+ else theory_path.split("/").take(thys_index + 2).mkString("/")
28
+ }
29
+ val theorem_name = json_element(1).extract[String].replaceAll("\n", " ").replaceAll(" +", " ").trim
30
+ val starting_point = System.nanoTime
31
+ val pisaos = new PisaOS(
32
+ path_to_isa_bin = "/home/qj213/Isabelle2021",
33
+ path_to_file = theory_path,
34
+ working_directory = working_directory
35
+ )
36
+ val load_timestamp = System.nanoTime
37
+ val load_library_time = (load_timestamp - starting_point) / 1e9d
38
+ pisaos.step_to_transition_text(theorem_name)
39
+ val proceed_to_line_time = (System.nanoTime - load_timestamp) / 1e9d
40
+
41
+ new PrintWriter(s"$dump_path/$test_theorem_number" + "_time.info") {
42
+ write(s"load_library_time: $load_library_time\nproceed_to_line_time: $proceed_to_line_time")
43
+ close()
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,40 @@
1
+ package pisa.agent
2
+
3
+
4
+ import de.unruh.isabelle.control.Isabelle
5
+ import de.unruh.isabelle.mlvalue.Implicits._
6
+ import de.unruh.isabelle.pure.Implicits._
7
+ import de.unruh.isabelle.pure.ToplevelState
8
+ import pisa.server.PisaOS
9
+
10
+ import scala.concurrent._
11
+ import scala.concurrent.ExecutionContext
12
+ import scala.concurrent.blocking
13
+ import scala.concurrent.ExecutionContext.Implicits._
14
+ import scala.util.control.Breaks
15
+ import java.util.concurrent.CancellationException
16
+ import java.io._
17
+ import java.util.Base64
18
+ import java.nio.charset.StandardCharsets.UTF_8
19
+
20
+ object RefactorTest {
21
+ val path_to_isa_bin: String = "/home/qj213/Isabelle2022"
22
+ val working_directory: String = "/home/qj213/afp-2022-12-06/thys/Formal_SSA"
23
+ val path_to_file: String = "/home/qj213/afp-2022-12-06/thys/Formal_SSA/Construct_SSA.thy"
24
+ val problem1: String = "lemma phiDefNodes_aux_cases:\n obtains (nonrec) \"phiDefNodes_aux g v unvisited n = {}\" \"(n \\<notin> set unvisited \\<or> v \\<in> defs g n)\"\n | (rec) \"phiDefNodes_aux g v unvisited n = fold union (map (phiDefNodes_aux g v (removeAll n unvisited)) (predecessors g n))\n (if length (predecessors g n) = 1 then {} else {n})\"\n \"n \\<in> set unvisited\" \"v \\<notin> defs g n\""
25
+ val problem2: String = "lemma phiDefNode_aux_is_join_node:\n assumes \"n \\<in> phiDefNodes_aux g v un m\"\n shows \"length (predecessors g n) \\<noteq> 1\""
26
+
27
+ def main(args: Array[String]): Unit = {
28
+ val pisaos = new PisaOS(
29
+ path_to_isa_bin=path_to_isa_bin,
30
+ path_to_file=path_to_file,
31
+ working_directory=working_directory
32
+ )
33
+ pisaos.accumulative_step_to_theorem_end(problem1)
34
+ pisaos.top_level_state_map += ("default" -> pisaos.copy_tls)
35
+ println(pisaos.get_dependent_theorems("default", "phiDefNodes_aux_cases"))
36
+ pisaos.accumulative_step_to_theorem_end(problem2)
37
+ pisaos.top_level_state_map += ("default" -> pisaos.copy_tls)
38
+ println(pisaos.get_dependent_theorems("default", "phiDefNode_aux_is_join_node"))
39
+ }
40
+ }
@@ -0,0 +1,95 @@
1
+ package pisa.agent
2
+
3
+ import pisa.utils.TheoryManager
4
+
5
+ import de.unruh.isabelle.control.Isabelle
6
+ import de.unruh.isabelle.control.Isabelle.Setup
7
+ import de.unruh.isabelle.mlvalue.MLFunction4
8
+ import de.unruh.isabelle.mlvalue.MLValue.{compileFunction, compileFunction0}
9
+ import de.unruh.isabelle.mlvalue.AdHocConverter
10
+ import de.unruh.isabelle.pure.{Theory, TheoryHeader, ToplevelState}
11
+ import de.unruh.isabelle.control.{Isabelle, OperationCollection}
12
+ import de.unruh.isabelle.mlvalue.MLValue.compileFunction
13
+ import de.unruh.isabelle.pure.{Position, Theory, TheoryHeader}
14
+
15
+ import java.nio.file.{Path, Paths}
16
+
17
+ import de.unruh.isabelle.mlvalue.Implicits._
18
+ import de.unruh.isabelle.pure.Implicits._
19
+ import scala.concurrent.ExecutionContext.Implicits.global
20
+
21
+ object Transition extends AdHocConverter("Toplevel.transition")
22
+
23
+
24
+ object RepHammer {
25
+ val isabelleHome: Path = Paths.get("/Applications/Isabelle2022.app")
26
+ val setup: Setup = Setup(isabelleHome = isabelleHome)
27
+ val theoryManager: TheoryManager = new TheoryManager(
28
+ path_to_isa_bin="/Applications/Isabelle2022.app",
29
+ wd="/Applications/Isabelle2022.app/src/HOL"
30
+ )
31
+ def main(args: Array[String]): Unit = {
32
+ implicit val isabelle: Isabelle = new Isabelle(setup)
33
+
34
+ val theorySource = TheoryManager.Text(
35
+ """ theory Test imports Main begin lemma test: "1+1=(2::nat)" """,
36
+ Paths.get("Test.thy").toAbsolutePath)
37
+
38
+ val thy0 = theoryManager.beginTheory(theorySource)
39
+ val init_toplevel = compileFunction0[ToplevelState]("Toplevel.init_toplevel")
40
+ var toplevel = init_toplevel().force.retrieveNow
41
+
42
+ val parse_text = compileFunction[Theory, String, List[(Transition.T, String)]](
43
+ """fn (thy, text) => let
44
+ | val transitions = Outer_Syntax.parse_text thy (K thy) Position.start text
45
+ | fun addtext symbols [tr] =
46
+ | [(tr, implode symbols)]
47
+ | | addtext _ [] = []
48
+ | | addtext symbols (tr::nextTr::trs) = let
49
+ | val (this,rest) = Library.chop (Position.distance_of (Toplevel.pos_of tr, Toplevel.pos_of nextTr) |> Option.valOf) symbols
50
+ | in (tr, implode this) :: addtext rest (nextTr::trs) end
51
+ | in addtext (Symbol.explode text) transitions end""".stripMargin)
52
+
53
+ val command_exception = compileFunction[Boolean, Transition.T, ToplevelState, ToplevelState](
54
+ "fn (int, tr, st) => Toplevel.command_exception int tr st")
55
+
56
+ for ((transition, text) <- parse_text(thy0, theorySource.text).force.retrieveNow) {
57
+ println(s"""Transition: "${text.strip}"""")
58
+ toplevel = command_exception(true, transition, toplevel).retrieveNow.force
59
+ }
60
+
61
+ // val finalThy = toplevel_end_theory(toplevel).retrieveNow.force
62
+
63
+ val thy_for_sledgehammer = thy0
64
+ val Sledgehammer: String = thy_for_sledgehammer.importMLStructureNow("Sledgehammer")
65
+ val Sledgehammer_Commands: String = thy_for_sledgehammer.importMLStructureNow("Sledgehammer_Commands")
66
+ val Sledgehammer_Prover: String = thy_for_sledgehammer.importMLStructureNow("Sledgehammer_Prover")
67
+
68
+ val normal_with_Sledgehammer: MLFunction4[ToplevelState, Theory, List[String], List[String], (Boolean, (String, List[String]))] =
69
+ compileFunction[ToplevelState, Theory, List[String], List[String], (Boolean, (String, List[String]))](
70
+ s""" fn (state, thy, adds, dels) =>
71
+ | let
72
+ | val override = {add=[],del=[],only=false};
73
+ | fun go_run (state, thy) =
74
+ | let
75
+ | val p_state = Toplevel.proof_of state;
76
+ | val ctxt = Proof.context_of p_state;
77
+ | val params = ${Sledgehammer_Commands}.default_params thy
78
+ | [("provers", "e"),("timeout","30"),("verbose","true")];
79
+ | val results = ${Sledgehammer}.run_sledgehammer params ${Sledgehammer_Prover}.Normal NONE 1 override p_state;
80
+ | val (result, (outcome, step)) = results;
81
+ | in
82
+ | (result, (${Sledgehammer}.short_string_of_sledgehammer_outcome outcome, [YXML.content_of step]))
83
+ | end;
84
+ | in
85
+ | Timeout.apply (Time.fromSeconds 35) go_run (state, thy) end
86
+ |""".stripMargin
87
+ )
88
+
89
+ // Apply transitions to toplevel such that it is at a "hammerable" place
90
+ // Then
91
+ val result = normal_with_Sledgehammer(toplevel, thy0, List[String](), List[String]()).force.retrieveNow
92
+ println(result)
93
+
94
+ }
95
+ }