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,591 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import sys
4
+ root_dir = f"{__file__.split('itp_interface')[0]}"
5
+ if root_dir not in sys.path:
6
+ sys.path.append(root_dir)
7
+ import copy
8
+ import typing
9
+ import logging
10
+ import ray
11
+ from itp_interface.tools.isabelle_executor import IsabelleExecutor, HammerMode
12
+ from itp_interface.rl.proof_action import ProofAction
13
+ from itp_interface.rl.proof_state import ProofState
14
+ from itp_interface.tools.cache import SimpleLruCache
15
+ from itp_interface.rl.simple_proof_env import ProofEnv, ProofEnvActor, ProofEnvInfo, ProofEnvReRankStrategy, ProofExecutorCallback
16
+
17
+ def replicate_proof_env(proof_env: ProofEnv, logger: typing.Optional[logging.Logger] = None) -> ProofEnv:
18
+ new_proof_env = copy.deepcopy(proof_env)
19
+ new_proof_env.logger = logger if logger else logging.getLogger(__name__)
20
+ return new_proof_env
21
+
22
+ class CapturedException(Exception):
23
+ def __init__(self, exception: Exception):
24
+ self.exception = exception
25
+ super().__init__(str(exception))
26
+
27
+ def __str__(self):
28
+ return f"CapturedException: {str(self.exception)}"
29
+
30
+ @ray.remote
31
+ class CaptureExceptionActor:
32
+ def __init__(self, func, timeout:typing.Optional[float]=None, args=None, kwargs=None):
33
+ self.func = func
34
+ self.args = args if args else []
35
+ self.kwargs = kwargs if kwargs else {}
36
+ self.timeout = timeout
37
+
38
+ def try_capture_exception(self):
39
+ try:
40
+ ray_id = self.func.remote(*self.args, **self.kwargs)
41
+ if self.timeout is None:
42
+ return_typ = ray.get(ray_id)
43
+ else:
44
+ return_typ = ray.get(ray_id, timeout=self.timeout)
45
+ return return_typ
46
+ except Exception as e:
47
+ return CapturedException(e)
48
+
49
+ def run_safely_on_actor(func, timeout, *args, **kwargs):
50
+ capture_exception_actor = CaptureExceptionActor.remote(func, timeout=timeout, *args, **kwargs)
51
+ return capture_exception_actor.try_capture_exception.remote()
52
+
53
+ class ProofEnvPool(object):
54
+ def __init__(self,
55
+ pool_size: int = 1,
56
+ proof_env_actors: typing.List[ProofEnvActor] = None,
57
+ proof_env: ProofEnv = None,
58
+ logger: typing.Optional[logging.Logger] = None,
59
+ timeout: float = 120,
60
+ max_parallel_envs: int = None):
61
+ """
62
+ Keeps a pool of proof environments to be used in parallel,
63
+ and replenishes them as needed. It keeps extra environments
64
+ in a garbage collection list to be used when the pool is
65
+ replenished.
66
+ """
67
+ assert pool_size > 0 or len(proof_env_actors) > 0, "Pool size must be greater than 0"
68
+ self._current_index = 0
69
+ self._callback = None
70
+ self._logger = logger if logger else logging.getLogger(__name__)
71
+ self._env_to_steps_map : typing.Dict[int, typing.List[ProofAction]] = {}
72
+ self._nonactive_env_to_state_map : typing.Dict[int, ProofState] = {}
73
+ self._nonactive_env_to_done_map : typing.Dict[int, bool] = {}
74
+ self._env_args_map : typing.Dict[int, typing.List] = {}
75
+ self._env_kwargs_map : typing.Dict[int, typing.Dict] = {}
76
+ self._timeout = timeout
77
+ if proof_env_actors is None:
78
+ self.pool_size = pool_size
79
+ self._frozeen_env = replicate_proof_env(proof_env, self._logger) # This is like a frozen copy we never change it
80
+ self._proof_env_pool : typing.List[ProofEnvActor] = [
81
+ ProofEnvActor.remote(
82
+ name=self._frozeen_env.name,
83
+ dynamic_proof_executor_callback=self._frozeen_env.dynamic_proof_executor_callback,
84
+ lemma_name=self._frozeen_env.lemma_name,
85
+ retrieval_strategy=self._frozeen_env.retrieve_strategy,
86
+ max_proof_depth=self._frozeen_env.max_proof_depth,
87
+ always_retrieve_thms=self._frozeen_env._always_retrieve_thms,
88
+ logger=None,
89
+ should_load_env=False
90
+ )
91
+ for _ in range(self.pool_size)
92
+ ]
93
+ else:
94
+ self.pool_size = len(proof_env_actors)
95
+ self._frozeen_env = None
96
+ self._proof_env_pool : typing.List[ProofEnvActor] = proof_env_actors
97
+ all_args = ray.get([run_safely_on_actor(proof_env_actor.get_env_args, self._timeout) for proof_env_actor in self._proof_env_pool])
98
+ all_kwargs = ray.get([run_safely_on_actor(proof_env_actor.get_env_kwargs, self._timeout) for proof_env_actor in self._proof_env_pool])
99
+ for i, (args, kwargs) in enumerate(zip(all_args, all_kwargs)):
100
+ if isinstance(args, CapturedException) or isinstance(kwargs, CapturedException):
101
+ self._logger.error(f"Error getting arguments for proof environment {i}: {args}")
102
+ self._logger.error(f"Error getting keyword arguments for proof environment {i}: {kwargs}")
103
+ raise Exception(f"Error getting arguments for proof environment {i}: {args}")
104
+ self._env_args_map[i] = args
105
+ self._env_kwargs_map[i] = kwargs
106
+ self._errd_envs = set()
107
+ self._errd_envs_exceptions = {}
108
+ self._is_initialized = False
109
+ self._active_envs = set(list(range(self.pool_size)))
110
+ self._max_parallel_envs = max_parallel_envs if max_parallel_envs is not None else self.pool_size
111
+ self._env_cache = SimpleLruCache(max_size_in_bytes=self._max_parallel_envs)
112
+
113
+ def __enter__(self):
114
+ self._is_initialized = True
115
+ # load all environments which are not loaded
116
+ self.reset(list(range(self.pool_size)))
117
+ return self
118
+
119
+ def __exit__(self, exc_type, exc_value, traceback):
120
+ self._is_initialized = False
121
+ try:
122
+ self._try_cleanup_envs(list(range(self.pool_size)))
123
+ except Exception as e:
124
+ self._logger.error(f"Error cleaning up environments: {e}")
125
+
126
+ def add_and_init_proof_envs(self, count: int = 1):
127
+ count_before = len(self._proof_env_pool)
128
+ self.add_proof_envs(count=count)
129
+ count_after = len(self._proof_env_pool)
130
+ return self.reset(list(range(count_before, count_after)))
131
+
132
+ def add_proof_envs(self, count: int = 1):
133
+ assert self._is_initialized, "Cannot add proof environments after initialization"
134
+ assert self._frozeen_env is not None, "Frozen environment must be provided"
135
+ self._proof_env_pool.extend([
136
+ ProofEnvActor.remote(
137
+ name=self._frozeen_env.name,
138
+ dynamic_proof_executor_callback=self._frozeen_env.dynamic_proof_executor_callback,
139
+ lemma_name=self._frozeen_env.lemma_name,
140
+ retrieval_strategy=self._frozeen_env.retrieve_strategy,
141
+ max_proof_depth=self._frozeen_env.max_proof_depth,
142
+ always_retrieve_thms=self._frozeen_env._always_retrieve_thms,
143
+ logger=None,
144
+ should_load_env=False
145
+ )
146
+ for _ in range(count)
147
+ ])
148
+ self.pool_size += count
149
+
150
+ def add_proof_env(self, proof_env: ProofEnv = None):
151
+ assert self._is_initialized, "Cannot add proof environments after initialization"
152
+ if proof_env is None:
153
+ assert self._frozeen_env is not None, "Frozen environment must be provided"
154
+ self._proof_env_pool.append(
155
+ ProofEnvActor.remote(
156
+ name=self._frozeen_env.name,
157
+ dynamic_proof_executor_callback=self._frozeen_env.dynamic_proof_executor_callback,
158
+ lemma_name=self._frozeen_env.lemma_name,
159
+ retrieval_strategy=self._frozeen_env.retrieve_strategy,
160
+ max_proof_depth=self._frozeen_env.max_proof_depth,
161
+ always_retrieve_thms=self._frozeen_env._always_retrieve_thms,
162
+ logger=None,
163
+ should_load_env=False
164
+ )
165
+ )
166
+ else:
167
+ self._proof_env_pool.append(
168
+ ProofEnvActor.remote(
169
+ name=proof_env.name,
170
+ dynamic_proof_executor_callback=proof_env.dynamic_proof_executor_callback,
171
+ lemma_name=proof_env.lemma_name,
172
+ retrieval_strategy=proof_env.retrieve_strategy,
173
+ max_proof_depth=proof_env.max_proof_depth,
174
+ always_retrieve_thms=proof_env._always_retrieve_thms,
175
+ logger=None
176
+ )
177
+ )
178
+ self.pool_size += 1
179
+ args = ray.get(run_safely_on_actor(self._proof_env_pool[-1].get_env_args, self._timeout))
180
+ kwargs = ray.get(run_safely_on_actor(self._proof_env_pool[-1].get_env_kwargs, self._timeout))
181
+ if isinstance(args, CapturedException) or isinstance(kwargs, CapturedException):
182
+ self._logger.error(f"Error getting arguments for proof environment {self.pool_size-1}: {args}")
183
+ self._logger.error(f"Error getting keyword arguments for proof environment {self.pool_size-1}: {kwargs}")
184
+ raise Exception(f"Error getting arguments for proof environment {self.pool_size-1}: {args}")
185
+ self._env_args_map[self.pool_size-1] = args
186
+ self._env_kwargs_map[self.pool_size-1] = kwargs
187
+
188
+ def get_errd_envs(self):
189
+ return copy.deepcopy(self._errd_envs)
190
+
191
+ def get_errd_envs_exceptions(self):
192
+ return copy.deepcopy(self._errd_envs_exceptions)
193
+
194
+ def get_timeout(self):
195
+ return self._timeout
196
+
197
+ def step(self, actions: typing.List[ProofAction], idxs: typing.List[int] = None) -> typing.List[typing.Tuple[ProofState, ProofAction, ProofState, float, bool, ProofEnvInfo]]:
198
+ assert self._is_initialized, "Pool must be initialized before stepping"
199
+ assert len(actions) == len(self._proof_env_pool) or (idxs is not None and len(actions) == len(idxs)), \
200
+ "Number of actions must match the number of proof environments"
201
+ if idxs is None:
202
+ idxs = range(len(actions))
203
+ # Make sure we are not stepping an errored environment
204
+ assert len(set(idxs).intersection(self._errd_envs)) == 0, f"Cannot step errored environments: {set(idxs).intersection(self._errd_envs)}"
205
+
206
+ # Step the active environments
207
+ max_parallel_chunks = [(i, i+self._max_parallel_envs) for i in range(0, len(idxs), self._max_parallel_envs)]
208
+ all_step_res = []
209
+ for chunk in max_parallel_chunks:
210
+ all_step_res.extend(self._step_chunk(actions[chunk[0]:chunk[1]], idxs[chunk[0]:chunk[1]]))
211
+ return all_step_res
212
+
213
+ def get_pool(self, idxs: typing.List[int]) -> 'ProofEnvPool':
214
+ assert self._is_initialized, "Pool must be initialized before getting"
215
+ assert len(idxs) > 0, "Must provide at least one index"
216
+ return ProofEnvPool(
217
+ proof_env_actors=[self._proof_env_pool[idx] for idx in idxs],
218
+ logger=self._logger)
219
+
220
+ def reset(self, idxs: typing.List[int]) -> typing.List[typing.Tuple[ProofState, ProofAction, ProofState, float, bool, ProofEnvInfo]]:
221
+ assert self._is_initialized, "Pool must be initialized before resetting"
222
+ assert len(idxs) > 0, "Must provide at least one index"
223
+ assert len(set(idxs).intersection(self._errd_envs)) == 0, f"Cannot reset errored environments: {set(idxs).intersection(self._errd_envs)}"
224
+ reset_chunks = [idxs[i:i+self._max_parallel_envs] for i in range(0, len(idxs), self._max_parallel_envs)]
225
+ all_reset_res = []
226
+ for chunk in reset_chunks:
227
+ all_reset_res.extend(self._reset_chunk(chunk))
228
+ return all_reset_res
229
+
230
+ def get_state(self, idxs: int) -> typing.List[ProofState]:
231
+ assert self._is_initialized, "Pool must be initialized before getting"
232
+ assert len(idxs) > 0, "Must provide at least one index"
233
+ assert len(set(idxs).intersection(self._errd_envs)) == 0, f"Cannot get state of errored environments: {set(idxs).intersection(self._errd_envs)}"
234
+ active_idxs = []
235
+ nonactive_idxs = []
236
+ list_used = []
237
+ for idx in idxs:
238
+ if idx in self._active_envs:
239
+ active_idxs.append(idx)
240
+ list_used.append(active_idxs)
241
+ else:
242
+ nonactive_idxs.append(idx)
243
+ list_used.append(nonactive_idxs)
244
+ active_states = ray.get([run_safely_on_actor(self._proof_env_pool[idx].get_state, self._timeout) for idx in active_idxs])
245
+ for i, state in enumerate(active_states):
246
+ if isinstance(state, CapturedException):
247
+ raise Exception(f"Error getting state for proof environment {i}: {state}")
248
+ nonactive_states = [self._nonactive_env_to_state_map.get(idx, None) for idx in nonactive_idxs]
249
+ results = []
250
+ active_idx = 0
251
+ nonactive_idx = 0
252
+ for i, idx in enumerate(idxs):
253
+ list_to_use = list_used[i]
254
+ if list_to_use == active_idxs:
255
+ results.append(active_states[active_idx])
256
+ active_idx += 1
257
+ else:
258
+ results.append(nonactive_states[nonactive_idx])
259
+ nonactive_idx += 1
260
+ return results
261
+
262
+ def get_done(self, idxs: int) -> typing.List[bool]:
263
+ assert self._is_initialized, "Pool must be initialized before getting"
264
+ assert len(idxs) > 0, "Must provide at least one index"
265
+ assert len(set(idxs).intersection(self._errd_envs)) == 0, f"Cannot get done of errored environments: {set(idxs).intersection(self._errd_envs)}"
266
+ active_idxs = []
267
+ nonactive_idxs = []
268
+ list_used = []
269
+ for idx in idxs:
270
+ if idx in self._active_envs:
271
+ active_idxs.append(idx)
272
+ list_used.append(active_idxs)
273
+ else:
274
+ nonactive_idxs.append(idx)
275
+ list_used.append(nonactive_idxs)
276
+ active_dones = ray.get([run_safely_on_actor(self._proof_env_pool[idx].get_done, self._timeout) for idx in active_idxs])
277
+ for i, done in enumerate(active_dones):
278
+ if isinstance(done, CapturedException):
279
+ raise Exception(f"Error getting done for proof environment {i}: {done}")
280
+ nonactive_dones = [self._nonactive_env_to_done_map.get(idx, None) for idx in nonactive_idxs]
281
+ results = []
282
+ active_idx = 0
283
+ nonactive_idx = 0
284
+ for i, idx in enumerate(idxs):
285
+ list_to_use = list_used[i]
286
+ if list_to_use == active_idxs:
287
+ results.append(active_dones[active_idx])
288
+ active_idx += 1
289
+ else:
290
+ results.append(nonactive_dones[nonactive_idx])
291
+ nonactive_idx += 1
292
+ return results
293
+
294
+ def dump_proof(self, idxs: int):
295
+ assert self._is_initialized, "Pool must be initialized before dumping"
296
+ assert len(idxs) > 0, "Must provide at least one index"
297
+ assert len(set(idxs).intersection(self._errd_envs)) == 0, f"Cannot dump proof of errored environments: {set(idxs).intersection(self._errd_envs)}"
298
+ proofs = ray.get([run_safely_on_actor(self._proof_env_pool[idx].dump_proof, self._timeout) for idx in idxs])
299
+ for i, proof in enumerate(proofs):
300
+ if isinstance(proof, CapturedException):
301
+ raise Exception(f"Error dumping proof for proof environment {i}: {proof}")
302
+
303
+ def _get_attr(self, attr_name: str, idxs: typing.List[int]):
304
+ assert self._is_initialized, "Pool must be initialized before getting"
305
+ assert len(idxs) > 0, "Must provide at least one index"
306
+ assert len(set(idxs).intersection(self._errd_envs)) == 0, f"Cannot get attribute {attr_name} of errored environments: {set(idxs).intersection(self._errd_envs)}"
307
+ attrs = ray.get([run_safely_on_actor(self._proof_env_pool[idx].getattr, self._timeout, args = [attr_name]) for idx in idxs])
308
+ for i, attr in enumerate(attrs):
309
+ if isinstance(attr, CapturedException):
310
+ raise Exception(f"Error getting attribute {attr_name} for proof environment {i}: {attr}")
311
+ return attrs
312
+
313
+ def get_proof_search_res(self, idxs: typing.List[int]) -> typing.List[typing.Tuple[typing.List[ProofAction], float]]:
314
+ assert self._is_initialized, "Pool must be initialized before getting"
315
+ assert len(idxs) > 0, "Must provide at least one index"
316
+ assert len(set(idxs).intersection(self._errd_envs)) == 0, f"Cannot get proof search results of errored environments: {set(idxs).intersection(self._errd_envs)}"
317
+ return self._get_attr("proof_search_res", idxs)
318
+
319
+ def _reset_chunk(self, idxs: typing.List[int]) -> typing.List[ProofState]:
320
+ self._logger.info(f"Resetting environments: {idxs}")
321
+ assert self._is_initialized, "Pool must be initialized before resetting"
322
+ assert len(idxs) > 0, "Must provide at least one index"
323
+ assert len(set(idxs).intersection(self._errd_envs)) == 0, f"Cannot reset errored environments: {set(idxs).intersection(self._errd_envs)}"
324
+ should_load_envs = [False for _ in range(len(idxs))]
325
+ init_remotes = []
326
+ for should_load_env, idx in zip(should_load_envs, idxs):
327
+ if not should_load_env:
328
+ init_remotes.append(run_safely_on_actor(self._proof_env_pool[idx].reset, self._timeout))
329
+ env_init_stats = ray.get(init_remotes)
330
+ results = []
331
+ envs_to_remove = []
332
+ for i, env_init_stat in enumerate(env_init_stats):
333
+ if isinstance(env_init_stat, CapturedException):
334
+ self._errd_envs.add(idxs[i])
335
+ self._errd_envs_exceptions[idxs[i]] = env_init_stat
336
+ envs_to_remove.append(idxs[i])
337
+ self._logger.error(f"Error initializing proof environment {i}: {env_init_stat}")
338
+ results.append((None, None, None, 0.0, True, None))
339
+ else:
340
+ envs_removed = self._env_cache.add_to_cache(str(idxs[i]), idxs[i], 1)
341
+ for env_removed in envs_removed:
342
+ if int(env_removed) not in idxs:
343
+ envs_to_remove.append(env_removed)
344
+ self._active_envs.add(idxs[i])
345
+ results.append(env_init_stat)
346
+ if len(envs_to_remove) > 0:
347
+ self._try_cleanup_envs(envs_to_remove)
348
+ self._logger.info(f"Reset environments: {idxs}")
349
+ return results
350
+
351
+ def _step_chunk(self, actions: typing.List[ProofAction], idxs: typing.List[int] = None) -> typing.List[typing.Tuple[ProofState, ProofAction, ProofState, float, bool, ProofEnvInfo]]:
352
+ assert self._is_initialized, "Pool must be initialized before stepping"
353
+ assert len(actions) == len(self._proof_env_pool) or (idxs is not None and len(actions) == len(idxs)), \
354
+ "Number of actions must match the number of proof environments"
355
+ assert len(idxs) <= self._max_parallel_envs, f"Number of environments to step must be less than or equal to {self._max_parallel_envs}"
356
+ if idxs is None:
357
+ idxs = range(len(actions))
358
+ # Make sure we are not stepping an errored environment
359
+ assert len(set(idxs).intersection(self._errd_envs)) == 0, f"Cannot step errored environments: {set(idxs).intersection(self._errd_envs)}"
360
+ removed_envs = []
361
+ non_active_envs = []
362
+ self._logger.info(f"Stepping environments: {idxs}")
363
+ for idx in idxs:
364
+ envs_removed = self._env_cache.add_to_cache(str(idx), idx, 1)
365
+ if idx not in self._active_envs:
366
+ non_active_envs.append(idx)
367
+ for env in envs_removed:
368
+ if int(env) not in idxs:
369
+ removed_envs.append(env)
370
+ if len(removed_envs) > 0:
371
+ self._try_cleanup_envs(removed_envs)
372
+ if len(non_active_envs) > 0:
373
+ self._activate_envs(non_active_envs)
374
+ for i, idx in enumerate(idxs):
375
+ actions_so_far = self._env_to_steps_map.get(idx, [])
376
+ actions_so_far.append(actions[i])
377
+ self._env_to_steps_map[idx] = actions_so_far
378
+ return self._unsafe_step_chunk(actions, idxs)
379
+
380
+ def _activate_envs(self, idxs: typing.List[int]):
381
+ self._logger.info(f"Activating environments: {idxs}")
382
+ for idx in idxs:
383
+ if idx in self._active_envs:
384
+ continue
385
+ if self._frozeen_env is not None:
386
+ self._proof_env_pool[idx] = ProofEnvActor.remote(
387
+ name=self._frozeen_env.name,
388
+ dynamic_proof_executor_callback=self._frozeen_env.dynamic_proof_executor_callback,
389
+ lemma_name=self._frozeen_env.lemma_name,
390
+ retrieval_strategy=self._frozeen_env.retrieve_strategy,
391
+ max_proof_depth=self._frozeen_env.max_proof_depth,
392
+ always_retrieve_thms=self._frozeen_env._always_retrieve_thms,
393
+ logger=None,
394
+ should_load_env=False
395
+ )
396
+ else:
397
+ self._proof_env_pool[idx] = ProofEnvActor.remote(*self._env_args_map[idx], **self._env_kwargs_map[idx])
398
+ self.reset(idxs)
399
+ # Rerun the steps again on all the environments that were not active
400
+ idxs_to_run = []
401
+ actions_to_run = []
402
+ last_action_idx = 0
403
+ actions_added = True
404
+ while actions_added:
405
+ actions_added = False
406
+ for idx in idxs:
407
+ actions = self._env_to_steps_map.get(idx, [])
408
+ if len(actions) > 0:
409
+ if last_action_idx < len(actions):
410
+ actions_added = True
411
+ idxs_to_run.append(idx)
412
+ actions_to_run.append(actions[last_action_idx])
413
+ if actions_added:
414
+ last_action_idx += 1
415
+ self._unsafe_step_chunk(actions_to_run, idxs_to_run)
416
+ idxs_to_run = []
417
+ actions_to_run = []
418
+ self._logger.info(f"Activated environments: {idxs}")
419
+
420
+ def _unsafe_step_chunk(self, actions: typing.List[ProofAction], idxs: typing.List[int] = None) -> typing.List[typing.Tuple[ProofState, ProofAction, ProofState, float, bool, ProofEnvInfo]]:
421
+ remotes = []
422
+ for i, idx in enumerate(idxs):
423
+ remotes.append(run_safely_on_actor(self._proof_env_pool[idx].step, self._timeout, args=[actions[i]]))
424
+ return_remotes = ray.get(remotes)
425
+ actual_returns = []
426
+ for i, return_remote in enumerate(return_remotes):
427
+ if isinstance(return_remote, CapturedException):
428
+ self._errd_envs.add(idxs[i])
429
+ self._errd_envs_exceptions[idxs[i]] = return_remote
430
+ actual_returns.append((None, None, None, 0.0, True, None))
431
+ self._logger.error(f"Error stepping proof environment {i}: {return_remote}")
432
+ else:
433
+ actual_returns.append(return_remote)
434
+ return actual_returns
435
+
436
+ def _try_cleanup_envs(self, idxs: typing.Union[typing.List[int], typing.List[str]]):
437
+ self._logger.info(f"Cleaning up environments: {idxs}")
438
+ idxs = [int(idx) for idx in idxs]
439
+ try:
440
+ state_remotes = []
441
+ done_remotes = []
442
+ for env_idx in idxs:
443
+ proof_env_actor = self._proof_env_pool[env_idx]
444
+ if env_idx in self._active_envs:
445
+ state_remotes.append(run_safely_on_actor(proof_env_actor.get_state, self._timeout))
446
+ done_remotes.append(run_safely_on_actor(proof_env_actor.get_done, self._timeout))
447
+ states = ray.get(state_remotes)
448
+ dones = ray.get(done_remotes)
449
+ state_idx = 0
450
+ for env_idx in idxs:
451
+ if env_idx in self._active_envs:
452
+ if isinstance(states[state_idx], CapturedException) or isinstance(dones[state_idx], CapturedException):
453
+ self._logger.error(f"Error getting state/done for proof environment {env_idx}: {states[state_idx]}")
454
+ ex = Exception(f"Error getting state/done for proof environment {env_idx}: {states[state_idx]}")
455
+ raise CapturedException(ex)
456
+ else:
457
+ self._nonactive_env_to_state_map[env_idx] = states[state_idx]
458
+ self._nonactive_env_to_done_map[env_idx] = dones[state_idx]
459
+ state_idx += 1
460
+ cleanup_remotes = []
461
+ for env_idx in idxs:
462
+ proof_env_actor = self._proof_env_pool[env_idx]
463
+ if env_idx in self._active_envs:
464
+ cleanup_remotes.append(run_safely_on_actor(proof_env_actor.cleanup, timeout=15))
465
+ ray.get(cleanup_remotes)
466
+ except CapturedException as e:
467
+ raise
468
+ except Exception as e:
469
+ self._logger.error(f"Error cleaning up proof environments: {e}")
470
+ # Kill all actors
471
+ for env_idx in idxs:
472
+ if env_idx in self._active_envs:
473
+ proof_env_actor = self._proof_env_pool[env_idx]
474
+ try:
475
+ ray.kill(proof_env_actor)
476
+ except Exception as e:
477
+ self._logger.error(f"Error killing proof environment actor: {e}")
478
+ for env_idx in idxs:
479
+ if env_idx in self._active_envs:
480
+ self._active_envs.remove(env_idx)
481
+ self._logger.info(f"Removed environments: {idxs}")
482
+
483
+ if __name__ == "__main__":
484
+ import os
485
+ os.chdir(root_dir)
486
+
487
+ print("Interactive Proof Environment")
488
+ supported_actions = [x.name for x in ProofAction.ActionType]
489
+
490
+ def scan_action(language):
491
+ inp_action_type = input(f"Enter an action type from {supported_actions}: (default RUN_TACTIC)")
492
+ if inp_action_type not in supported_actions:
493
+ inp_action_type = ProofAction.ActionType.RUN_TACTIC.name
494
+ action_type = ProofAction.ActionType[inp_action_type]
495
+ if action_type == ProofAction.ActionType.RUN_TACTIC:
496
+ inp = input("Enter tactic(s) (';' separated): ")
497
+ inp = inp.split(';')
498
+ return ProofAction(action_type, language, tactics=inp)
499
+ elif action_type == ProofAction.ActionType.GET_DFNS_THMS or action_type == ProofAction.ActionType.BACKTRACK or action_type == ProofAction.ActionType.EXIT:
500
+ return ProofAction(action_type, language)
501
+ else:
502
+ raise Exception(f"Invalid action type {action_type}")
503
+ logging.basicConfig(level=logging.INFO, stream=sys.stdout)
504
+ inp = input("Want to run coq, lean, or isabelle env? (Enter 'coq'/'lean'/'lean4'/'isabelle') ")
505
+ language = ProofAction.Language.COQ
506
+ if inp == 'coq':
507
+ proof_exec_callback = ProofExecutorCallback(
508
+ project_folder=".",
509
+ file_path="data/test/SimpleAlgebra.v",
510
+ enable_search=False
511
+ )
512
+ theorem_name = "algb_add_comm"
513
+ language = ProofAction.Language.COQ
514
+ always_retrieve_thms = False
515
+ retrieval_strategy = ProofEnvReRankStrategy.BM25
516
+ elif inp == 'lean':
517
+ proof_exec_callback = ProofExecutorCallback(
518
+ project_folder="data/test/lean_proj",
519
+ file_path="data/test/lean_proj/src/simple_solved.lean",
520
+ language=ProofAction.Language.LEAN,
521
+ always_use_retrieval=True,
522
+ keep_local_context=True
523
+ )
524
+ theorem_name = "a_plus_b_a_minus_a"
525
+ language = ProofAction.Language.LEAN
526
+ always_retrieve_thms = True
527
+ retrieval_strategy = ProofEnvReRankStrategy.BM25
528
+ pass
529
+ elif inp == 'lean4':
530
+ proof_exec_callback = ProofExecutorCallback(
531
+ project_folder="data/test/lean4_proj",
532
+ file_path="data/test/lean4_proj/Lean4Proj/Basic.lean",
533
+ language=ProofAction.Language.LEAN4,
534
+ always_use_retrieval=False,
535
+ keep_local_context=True
536
+ )
537
+ theorem_name = "test3"
538
+ language = ProofAction.Language.LEAN4
539
+ always_retrieve_thms = False
540
+ retrieval_strategy = ProofEnvReRankStrategy.NO_RE_RANK
541
+ elif inp == 'isabelle':
542
+ proof_exec_callback = ProofExecutorCallback(
543
+ project_folder="data/test",
544
+ file_path="data/test/SimpleAlgebra.thy",
545
+ language=ProofAction.Language.ISABELLE,
546
+ use_hammer=HammerMode.AUTO
547
+ )
548
+ theorem_name = "sqrt_comp"
549
+ language = ProofAction.Language.ISABELLE
550
+ always_retrieve_thms = False
551
+ retrieval_strategy = ProofEnvReRankStrategy.BM25
552
+ else:
553
+ raise Exception(f"Invalid input {inp} for choosing coq/lean/lean4 env")
554
+
555
+ if language == ProofAction.Language.ISABELLE:
556
+ IsabelleExecutor.start_server(port=13000)
557
+
558
+ try:
559
+ test_ray = True
560
+ if test_ray:
561
+ logger = logging.getLogger(__name__)
562
+ ray.init()
563
+ env_actors = [
564
+ ProofEnvActor.remote("test", proof_exec_callback, theorem_name, retrieval_strategy=retrieval_strategy, max_proof_depth=10, always_retrieve_thms=always_retrieve_thms, logger=logger, should_load_env=False)
565
+ for _ in range(4)]
566
+ pool = ProofEnvPool(proof_env_actors=env_actors, logger=logger, max_parallel_envs=3)
567
+ with pool:
568
+ dones = pool.get_done(list(range(4)))
569
+ action = scan_action(language)
570
+ while action.action_type != ProofAction.ActionType.EXIT and not all(dones):
571
+ step_res = pool.step([action]*4, list(range(4)))
572
+ dones = []
573
+ for i, (state, act, new_state, reward, done, info) in enumerate(step_res):
574
+ if done:
575
+ print(f"Environment {i} done")
576
+ else:
577
+ print(f"Environment {i} not done")
578
+ dones.append(done)
579
+ print(f"[{i}] Reward: {reward}")
580
+ print(f"[{i}] Done: {done}")
581
+ print(f"[{i}] Info: {info.to_json()}")
582
+ if not all(dones):
583
+ action = scan_action(language)
584
+
585
+ # If you wish to explicitly kill the actor, do so after the cleanup
586
+ for env_actor in env_actors:
587
+ ray.kill(env_actor)
588
+ finally:
589
+ if language == ProofAction.Language.ISABELLE:
590
+ IsabelleExecutor.stop_server()
591
+