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.
- itp_interface/__init__.py +0 -0
- itp_interface/agent/__init__.py +0 -0
- itp_interface/agent/simple_proof_agent.py +100 -0
- itp_interface/coq_ser_api/__init__.py +165 -0
- itp_interface/coq_ser_api/contexts.py +283 -0
- itp_interface/coq_ser_api/coq_agent.py +459 -0
- itp_interface/coq_ser_api/coq_backend.py +135 -0
- itp_interface/coq_ser_api/coq_util.py +839 -0
- itp_interface/coq_ser_api/example.py +67 -0
- itp_interface/coq_ser_api/lsp_backend.py +375 -0
- itp_interface/coq_ser_api/py.typed +0 -0
- itp_interface/coq_ser_api/serapi_backend.py +841 -0
- itp_interface/coq_ser_api/util.py +145 -0
- itp_interface/coq_ser_api_old/__init__.py +2583 -0
- itp_interface/coq_ser_api_old/contexts.py +172 -0
- itp_interface/coq_ser_api_old/util.py +146 -0
- itp_interface/lean_server/__init__.py +0 -0
- itp_interface/lean_server/commands.py +484 -0
- itp_interface/lean_server/lean3_search_tool.py +358 -0
- itp_interface/lean_server/lean4_repl_interface.py +151 -0
- itp_interface/lean_server/lean4_utils.py +255 -0
- itp_interface/lean_server/lean_cmd_server.py +111 -0
- itp_interface/lean_server/lean_context.py +60 -0
- itp_interface/lean_server/lean_sync_server.py +174 -0
- itp_interface/lean_server/lean_utils.py +199 -0
- itp_interface/lean_server/py.typed +1 -0
- itp_interface/main/__init__.py +0 -0
- itp_interface/main/config/afp_data_gen.yaml +14 -0
- itp_interface/main/config/benchmark/CompCert.yaml +366 -0
- itp_interface/main/config/benchmark/GeoCoq.yaml +930 -0
- itp_interface/main/config/benchmark/UniMath.yaml +2690 -0
- itp_interface/main/config/benchmark/afp_isabelle.yaml +29200 -0
- itp_interface/main/config/benchmark/agent_proverbot_hard.yaml +247 -0
- itp_interface/main/config/benchmark/category-theory.yaml +470 -0
- itp_interface/main/config/benchmark/compcert_118_subset.yaml +148 -0
- itp_interface/main/config/benchmark/compcert_benchmark.yaml +36 -0
- itp_interface/main/config/benchmark/compcert_benchmark_hard.yaml +498 -0
- itp_interface/main/config/benchmark/compcert_benchmark_hard_1.yaml +55 -0
- itp_interface/main/config/benchmark/compcert_benchmark_hard_2.yaml +24 -0
- itp_interface/main/config/benchmark/compcert_benchmark_hard_3.yaml +95 -0
- itp_interface/main/config/benchmark/compcert_benchmark_hard_7_per_cent.yaml +78 -0
- itp_interface/main/config/benchmark/compcert_benchmark_test.yaml +38 -0
- itp_interface/main/config/benchmark/compcert_benchmark_train.yaml +340 -0
- itp_interface/main/config/benchmark/leandojo_novel_premises_test.yaml +2908 -0
- itp_interface/main/config/benchmark/leandojo_novel_premises_train.yaml +98645 -0
- itp_interface/main/config/benchmark/leandojo_novel_premises_val.yaml +2912 -0
- itp_interface/main/config/benchmark/leandojo_random.yaml +2889 -0
- itp_interface/main/config/benchmark/leandojo_random_test.yaml +2421 -0
- itp_interface/main/config/benchmark/leandojo_random_train.yaml +62729 -0
- itp_interface/main/config/benchmark/leandojo_random_val.yaml +2504 -0
- itp_interface/main/config/benchmark/math-comp.yaml +200 -0
- itp_interface/main/config/benchmark/miniF2F_test.yaml +12 -0
- itp_interface/main/config/benchmark/miniF2F_test_aime.yaml +27 -0
- itp_interface/main/config/benchmark/miniF2F_test_algebra.yaml +30 -0
- itp_interface/main/config/benchmark/miniF2F_test_amc12.yaml +57 -0
- itp_interface/main/config/benchmark/miniF2F_test_few_shot_hard.yaml +231 -0
- itp_interface/main/config/benchmark/miniF2F_test_imo.yaml +32 -0
- itp_interface/main/config/benchmark/miniF2F_test_induction.yaml +20 -0
- itp_interface/main/config/benchmark/miniF2F_test_mathd_algebra.yaml +82 -0
- itp_interface/main/config/benchmark/miniF2F_test_mathd_algebra_hard.yaml +72 -0
- itp_interface/main/config/benchmark/miniF2F_test_mathd_numbertheory.yaml +72 -0
- itp_interface/main/config/benchmark/miniF2F_test_numbertheory.yaml +20 -0
- itp_interface/main/config/benchmark/minicompcert_benchmark_1.yaml +14 -0
- itp_interface/main/config/benchmark/proverbot_hard.yaml +104 -0
- itp_interface/main/config/benchmark/re_prover.yaml +66 -0
- itp_interface/main/config/benchmark/re_prover_hard.yaml +41 -0
- itp_interface/main/config/benchmark/re_prover_very_hard.yaml +22 -0
- itp_interface/main/config/benchmark/reprover_with_retrieval.yaml +73 -0
- itp_interface/main/config/benchmark/reprover_with_retrieval_hard.yaml +30 -0
- itp_interface/main/config/benchmark/reprover_with_retrieval_neg.yaml +195 -0
- itp_interface/main/config/benchmark/simple_benchmark_1.yaml +24 -0
- itp_interface/main/config/benchmark/simple_benchmark_8.yaml +50 -0
- itp_interface/main/config/benchmark/simple_benchmark_9.yaml +65 -0
- itp_interface/main/config/benchmark/simple_benchmark_isabelle.yaml +18 -0
- itp_interface/main/config/benchmark/simple_benchmark_lean.yaml +12 -0
- itp_interface/main/config/benchmark/simple_benchmark_lean_training_data.yaml +12 -0
- itp_interface/main/config/benchmark/simple_rl_benchmark_lean.yaml +14 -0
- itp_interface/main/config/benchmark/stack_machine.yaml +13 -0
- itp_interface/main/config/benchmark/stack_machine_hard.yaml +15 -0
- itp_interface/main/config/category_theory_data_gen.yaml +14 -0
- itp_interface/main/config/category_theory_data_gen_random.yaml +16 -0
- itp_interface/main/config/compcert_data_gen_test.yaml +10 -0
- itp_interface/main/config/compcert_data_gen_train.yaml +7 -0
- itp_interface/main/config/env_settings/bm25_retrieval.yaml +2 -0
- itp_interface/main/config/env_settings/bm25_retrieval_no_dfns.yaml +2 -0
- itp_interface/main/config/env_settings/bm25_retrieval_only_local_no_dfns.yaml +2 -0
- itp_interface/main/config/env_settings/bm25_retrieval_with_print.yaml +2 -0
- itp_interface/main/config/env_settings/bm25_retrieval_with_print_only_local.yaml +2 -0
- itp_interface/main/config/env_settings/bm25_retrieval_with_print_only_local_no_dfns.yaml +2 -0
- itp_interface/main/config/env_settings/no_retrieval.yaml +2 -0
- itp_interface/main/config/experiments.yaml +12 -0
- itp_interface/main/config/geo_coq_data_gen.yaml +14 -0
- itp_interface/main/config/geo_coq_data_gen_random.yaml +16 -0
- itp_interface/main/config/leandojo_random_data_gen.yaml +16 -0
- itp_interface/main/config/math_comp_data_gen.yaml +14 -0
- itp_interface/main/config/math_comp_data_gen_random.yaml +16 -0
- itp_interface/main/config/mathlib_data_gen.yaml +14 -0
- itp_interface/main/config/repo/coq_repos.yaml +191 -0
- itp_interface/main/config/run_settings/default_coq_data_generation_transforms.yaml +24 -0
- itp_interface/main/config/run_settings/default_isabelle_data_generation_transforms.yaml +24 -0
- itp_interface/main/config/run_settings/default_lean4_data_generation_transforms.yaml +24 -0
- itp_interface/main/config/run_settings/default_lean_data_generation_transforms.yaml +24 -0
- itp_interface/main/config/simple_coq_data_gen.yaml +12 -0
- itp_interface/main/config/simple_coq_data_gen_random.yaml +17 -0
- itp_interface/main/config/simple_lean_data_gen.yaml +12 -0
- itp_interface/main/config/simple_rl_lean_data_gen.yaml +12 -0
- itp_interface/main/config/uni_math_data_gen.yaml +14 -0
- itp_interface/main/config.py +192 -0
- itp_interface/main/extract_benchmark_dataset.py +106 -0
- itp_interface/main/filter_dataset.py +107 -0
- itp_interface/main/install.py +92 -0
- itp_interface/main/merge_dataset.py +96 -0
- itp_interface/main/run_tool.py +444 -0
- itp_interface/pisa/.git +1 -0
- itp_interface/pisa/.gitignore +125 -0
- itp_interface/pisa/.idea/.gitignore +8 -0
- itp_interface/pisa/.idea/ClojureProjectResolveSettings.xml +6 -0
- itp_interface/pisa/.idea/codeStyles/Project.xml +7 -0
- itp_interface/pisa/.idea/codeStyles/codeStyleConfig.xml +5 -0
- itp_interface/pisa/.idea/inspectionProfiles/Project_Default.xml +16 -0
- itp_interface/pisa/.idea/libraries/sbt__com_google_android_annotations_4_1_1_4_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_google_api_grpc_proto_google_common_protos_1_17_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_google_code_findbugs_jsr305_3_0_2_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_google_code_gson_gson_2_8_6_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_google_errorprone_error_prone_annotations_2_3_4_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_google_guava_failureaccess_1_0_1_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_google_guava_guava_30_0_jre_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_google_guava_listenablefuture_9999_0_empty_to_avoid_conflict_with_guava_jar.xml +9 -0
- itp_interface/pisa/.idea/libraries/sbt__com_google_j2objc_j2objc_annotations_1_3_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_google_protobuf_protobuf_java_3_12_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_google_protobuf_protobuf_java_util_3_12_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_lihaoyi_fastparse_2_13_2_3_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_lihaoyi_geny_2_13_0_6_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_lihaoyi_sourcecode_2_13_0_2_1_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_thesamet_scalapb_lenses_2_13_0_10_9_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_thesamet_scalapb_scalapb_runtime_2_13_0_10_9_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_thesamet_scalapb_scalapb_runtime_grpc_2_13_0_10_9_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_thesamet_scalapb_zio_grpc_zio_grpc_core_2_13_0_4_2_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__com_thoughtworks_paranamer_paranamer_2_8_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__commons_io_commons_io_2_8_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__de_unruh_java_patterns_0_1_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__de_unruh_scala_isabelle_2_13_master_SNAPSHOT_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__dev_zio_izumi_reflect_2_13_1_0_0_M9_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__dev_zio_izumi_reflect_thirdparty_boopickle_shaded_2_13_1_0_0_M9_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__dev_zio_zio_2_13_1_0_3_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__dev_zio_zio_stacktracer_2_13_1_0_3_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__dev_zio_zio_streams_2_13_1_0_3_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_api_1_34_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_context_1_34_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_core_1_34_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_netty_1_34_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_protobuf_1_34_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_protobuf_lite_1_34_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_services_1_34_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_grpc_grpc_stub_1_34_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_buffer_4_1_51_Final_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_codec_4_1_51_Final_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_codec_http2_4_1_51_Final_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_codec_http_4_1_51_Final_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_codec_socks_4_1_51_Final_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_common_4_1_51_Final_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_handler_4_1_51_Final_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_handler_proxy_4_1_51_Final_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_resolver_4_1_51_Final_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_netty_netty_transport_4_1_51_Final_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__io_perfmark_perfmark_api_0_19_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__net_java_dev_jna_jna_5_3_1_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__net_liftweb_lift_json_2_13_3_4_3_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_apache_commons_commons_lang3_3_11_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_apache_commons_commons_text_1_9_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_checkerframework_checker_qual_3_5_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_codehaus_mojo_animal_sniffer_annotations_1_18_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_jetbrains_annotations_20_1_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_jline_jline_3_16_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_log4s_log4s_2_13_1_9_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_scala_lang_modules_scala_collection_compat_2_13_2_1_6_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_scala_lang_modules_scala_xml_2_13_1_3_0_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_scala_lang_scala_compiler_2_13_4_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_scala_lang_scala_library_2_13_4_jar.xml +23 -0
- itp_interface/pisa/.idea/libraries/sbt__org_scala_lang_scala_reflect_2_13_4_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_scala_lang_scalap_2_13_4_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_scalaz_scalaz_core_2_13_7_3_2_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_slf4j_slf4j_api_1_7_30_jar.xml +13 -0
- itp_interface/pisa/.idea/libraries/sbt__org_slf4j_slf4j_simple_1_7_30_jar.xml +13 -0
- itp_interface/pisa/.idea/misc.xml +7 -0
- itp_interface/pisa/.idea/modules/PISA-build.iml +127 -0
- itp_interface/pisa/.idea/modules/PISA.iml +94 -0
- itp_interface/pisa/.idea/modules.xml +9 -0
- itp_interface/pisa/.idea/other.xml +6 -0
- itp_interface/pisa/.idea/sbt.xml +20 -0
- itp_interface/pisa/.idea/scala_compiler.xml +6 -0
- itp_interface/pisa/.idea/uiDesigner.xml +124 -0
- itp_interface/pisa/.idea/vcs.xml +6 -0
- itp_interface/pisa/.scalafmt.conf +2 -0
- itp_interface/pisa/LICENSE +29 -0
- itp_interface/pisa/README.md +262 -0
- itp_interface/pisa/build.sbt +49 -0
- itp_interface/pisa/build.sh +26 -0
- itp_interface/pisa/command_generation/close_gaps.py +44 -0
- itp_interface/pisa/command_generation/conjecture_normal_order.py +62 -0
- itp_interface/pisa/command_generation/conjecturer_command_generator.py +36 -0
- itp_interface/pisa/command_generation/create_dirs.py +11 -0
- itp_interface/pisa/command_generation/find_std.py +67 -0
- itp_interface/pisa/command_generation/generate_build_commands_afp.py +15 -0
- itp_interface/pisa/command_generation/generate_build_commands_std.py +15 -0
- itp_interface/pisa/command_generation/generate_commands_afp.py +103 -0
- itp_interface/pisa/command_generation/generate_commands_mini.py +73 -0
- itp_interface/pisa/command_generation/generate_commands_std.py +69 -0
- itp_interface/pisa/command_generation/generate_hammer_extraction_text.py +5 -0
- itp_interface/pisa/command_generation/hammer_command_generator.py +40 -0
- itp_interface/pisa/command_generation/hp_search_command_generator.py +63 -0
- itp_interface/pisa/command_generation/oracle_command_generator.py +56 -0
- itp_interface/pisa/command_generation/search_command_generator.py +69 -0
- itp_interface/pisa/command_generation/summarise_problem_names.py +45 -0
- itp_interface/pisa/command_generation/tpu_hp_search.py +75 -0
- itp_interface/pisa/docker/Dockerfile +34 -0
- itp_interface/pisa/docker/docker_tutorial.md +64 -0
- itp_interface/pisa/eval_setup/copy_isabelle.py +42 -0
- itp_interface/pisa/eval_setup/copy_pisa_jars.py +18 -0
- itp_interface/pisa/mesh_transformer_utils/tokenization.py +86 -0
- itp_interface/pisa/project/build.properties +1 -0
- itp_interface/pisa/project/plugins.sbt +5 -0
- itp_interface/pisa/requirements.txt +4 -0
- itp_interface/pisa/scripts/extract_last_k_steps.py +28 -0
- itp_interface/pisa/scripts/extract_proof_corpus.py +26 -0
- itp_interface/pisa/scripts/gather_hammer_results.py +27 -0
- itp_interface/pisa/scripts/length_in_char_stats.py +20 -0
- itp_interface/pisa/scripts/mix.py +127 -0
- itp_interface/pisa/scripts/results_stat.py +52 -0
- itp_interface/pisa/scripts/test_array_job.sh +34 -0
- itp_interface/pisa/setup.sh +25 -0
- itp_interface/pisa/src/main/protobuf/server.proto +60 -0
- itp_interface/pisa/src/main/python/.idea/.gitignore +8 -0
- itp_interface/pisa/src/main/python/.idea/inspectionProfiles/Project_Default.xml +18 -0
- itp_interface/pisa/src/main/python/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- itp_interface/pisa/src/main/python/.idea/misc.xml +4 -0
- itp_interface/pisa/src/main/python/.idea/modules.xml +8 -0
- itp_interface/pisa/src/main/python/.idea/python.iml +12 -0
- itp_interface/pisa/src/main/python/.idea/vcs.xml +6 -0
- itp_interface/pisa/src/main/python/conjecturing_parsing/conjecturer_postprocessing.py +59 -0
- itp_interface/pisa/src/main/python/data_extraction/extract_data.py +184 -0
- itp_interface/pisa/src/main/python/data_extraction/find_premises.py +221 -0
- itp_interface/pisa/src/main/python/data_extraction/process_data.py +129 -0
- itp_interface/pisa/src/main/python/legacy/PisaFlexibleClient.py +167 -0
- itp_interface/pisa/src/main/python/legacy/autof_test.py +74 -0
- itp_interface/pisa/src/main/python/legacy/cmd_client.py +23 -0
- itp_interface/pisa/src/main/python/legacy/convert_scala_dump_to_test_name_jsons.py +14 -0
- itp_interface/pisa/src/main/python/legacy/create_data_txt.py +72 -0
- itp_interface/pisa/src/main/python/legacy/create_finetune_tfrecords.py +311 -0
- itp_interface/pisa/src/main/python/legacy/demo.py +49 -0
- itp_interface/pisa/src/main/python/legacy/evaluate.py +108 -0
- itp_interface/pisa/src/main/python/legacy/extract_first_step.py +25 -0
- itp_interface/pisa/src/main/python/legacy/get_global_facts.py +35 -0
- itp_interface/pisa/src/main/python/legacy/mix_data.py +19 -0
- itp_interface/pisa/src/main/python/legacy/one_stage_extraction.py +111 -0
- itp_interface/pisa/src/main/python/legacy/prepare_episodic_transitions.py +137 -0
- itp_interface/pisa/src/main/python/legacy/prepare_translation_pairs.py +277 -0
- itp_interface/pisa/src/main/python/pisa_client.py +322 -0
- itp_interface/pisa/src/main/python/server_pb2.py +394 -0
- itp_interface/pisa/src/main/python/server_pb2_grpc.py +230 -0
- itp_interface/pisa/src/main/python/test_client.py +17 -0
- itp_interface/pisa/src/main/python/test_client2.py +79 -0
- itp_interface/pisa/src/main/python/utils/filters.py +59 -0
- itp_interface/pisa/src/main/python/utils/pisa_server_control.py +29 -0
- itp_interface/pisa/src/main/scala/pisa/agent/CheckSyntax.scala +257 -0
- itp_interface/pisa/src/main/scala/pisa/agent/DepThms.scala +29 -0
- itp_interface/pisa/src/main/scala/pisa/agent/PisaStat.scala +46 -0
- itp_interface/pisa/src/main/scala/pisa/agent/RefactorTest.scala +40 -0
- itp_interface/pisa/src/main/scala/pisa/agent/RepHammer.scala +95 -0
- itp_interface/pisa/src/main/scala/pisa/server/HammFacts.scala +63 -0
- itp_interface/pisa/src/main/scala/pisa/server/PisaOS.scala +881 -0
- itp_interface/pisa/src/main/scala/pisa/server/PisaOneStage.scala +540 -0
- itp_interface/pisa/src/main/scala/pisa/server/PisaOneStageServers.scala +1048 -0
- itp_interface/pisa/src/main/scala/pisa/utils/TheoryManager.scala +95 -0
- itp_interface/pisa/src/test/python/analyse_debug.py +33 -0
- itp_interface/pisa/src/test/python/extract_test_seq2seq.py +53 -0
- itp_interface/pisa/src/test/python/extract_test_theorem_ground_truth_indices.py +31 -0
- itp_interface/pisa/src/test/python/proof_originality.py +24 -0
- itp_interface/pisa/src/test/python/test_command_generator.py +25 -0
- itp_interface/pisa/src/test/python/test_model_sequence_accuracy.py +70 -0
- itp_interface/pisa/src/test/scala/pisa/Easy.scala +26 -0
- itp_interface/pisa/src/test/scala/pisa/TestCurl.scala +82 -0
- itp_interface/pisa/src/test/scala/pisa/TestIsa.scala +27 -0
- itp_interface/pisa/test.sh +19 -0
- itp_interface/pisa/universal_test_theorems.tar.gz +0 -0
- itp_interface/repo/build.py +78 -0
- itp_interface/repo/clone.py +79 -0
- itp_interface/repo/dataset_discovery.py +99 -0
- itp_interface/retrieval/__init__.py +0 -0
- itp_interface/retrieval/abstraction.py +35 -0
- itp_interface/retrieval/coq_bm25_reranker.py +153 -0
- itp_interface/retrieval/isabelle_bm25_reranker.py +86 -0
- itp_interface/retrieval/lean3_bm25_reranker.py +86 -0
- itp_interface/rl/__init__.py +0 -0
- itp_interface/rl/abstraction.py +168 -0
- itp_interface/rl/proof_action.py +172 -0
- itp_interface/rl/proof_state.py +149 -0
- itp_interface/rl/proof_tree.py +109 -0
- itp_interface/rl/simpl_proof_env_pool.py +16 -0
- itp_interface/rl/simple_proof_env.py +713 -0
- itp_interface/rl/simple_proof_env_pool.py +591 -0
- itp_interface/scripts/setup.sh +228 -0
- itp_interface/tools/__init__.py +0 -0
- itp_interface/tools/basic_utils.py +172 -0
- itp_interface/tools/bin_packing.py +61 -0
- itp_interface/tools/cache.py +93 -0
- itp_interface/tools/coq_build_spec.py +31 -0
- itp_interface/tools/coq_build_tool.py +319 -0
- itp_interface/tools/coq_context_helper.py +354 -0
- itp_interface/tools/coq_executor.py +508 -0
- itp_interface/tools/coq_local_data_generation_transform.py +158 -0
- itp_interface/tools/coq_parse_utils.py +154 -0
- itp_interface/tools/coq_raw_proofs.py +193 -0
- itp_interface/tools/coq_theorem_proof_pair_generation_transform.py +146 -0
- itp_interface/tools/coq_training_data_generator.py +76 -0
- itp_interface/tools/dynamic_coq_proof_exec.py +220 -0
- itp_interface/tools/dynamic_isabelle_proof_exec.py +229 -0
- itp_interface/tools/dynamic_lean4_proof_exec.py +236 -0
- itp_interface/tools/dynamic_lean_proof_exec.py +228 -0
- itp_interface/tools/isabelle_context_helper.py +66 -0
- itp_interface/tools/isabelle_executor.py +862 -0
- itp_interface/tools/isabelle_local_data_generation_transform.py +149 -0
- itp_interface/tools/isabelle_parse_utils.py +131 -0
- itp_interface/tools/isabelle_server.py +106 -0
- itp_interface/tools/lean4_context_helper.py +72 -0
- itp_interface/tools/lean4_local_data_generation_transform.py +122 -0
- itp_interface/tools/lean4_sync_executor.py +1193 -0
- itp_interface/tools/lean_cmd_executor.py +804 -0
- itp_interface/tools/lean_context_helper.py +327 -0
- itp_interface/tools/lean_dojo_data_generation_transform.py +206 -0
- itp_interface/tools/lean_executor.py +687 -0
- itp_interface/tools/lean_local_data_generation_transform.py +136 -0
- itp_interface/tools/lean_parse_utils.py +32 -0
- itp_interface/tools/log_utils.py +20 -0
- itp_interface/tools/proof_exec_callback.py +76 -0
- itp_interface/tools/ray_utils.py +265 -0
- itp_interface/tools/repl/.git +1 -0
- itp_interface/tools/repl/.github/workflows/ci.yml +24 -0
- itp_interface/tools/repl/.gitignore +7 -0
- itp_interface/tools/repl/.vscode/copyright.code-snippets +13 -0
- itp_interface/tools/repl/.vscode/extensions.json +13 -0
- itp_interface/tools/repl/.vscode/module-docstring.code-snippets +35 -0
- itp_interface/tools/repl/.vscode/settings.json +11 -0
- itp_interface/tools/repl/README.md +174 -0
- itp_interface/tools/repl/REPL/Frontend.lean +47 -0
- itp_interface/tools/repl/REPL/JSON.lean +186 -0
- itp_interface/tools/repl/REPL/Lean/ContextInfo.lean +9 -0
- itp_interface/tools/repl/REPL/Lean/Environment.lean +31 -0
- itp_interface/tools/repl/REPL/Lean/InfoTree/ToJson.lean +114 -0
- itp_interface/tools/repl/REPL/Lean/InfoTree.lean +272 -0
- itp_interface/tools/repl/REPL/Main.lean +323 -0
- itp_interface/tools/repl/REPL/Snapshots.lean +306 -0
- itp_interface/tools/repl/REPL/Util/Path.lean +36 -0
- itp_interface/tools/repl/REPL/Util/Pickle.lean +44 -0
- itp_interface/tools/repl/REPL.lean +4 -0
- itp_interface/tools/repl/lake-manifest.json +5 -0
- itp_interface/tools/repl/lakefile.lean +15 -0
- itp_interface/tools/repl/lean-toolchain +1 -0
- itp_interface/tools/repl/test/Mathlib/.gitignore +5 -0
- itp_interface/tools/repl/test/Mathlib/H20231110.sh +2 -0
- itp_interface/tools/repl/test/Mathlib/ReplMathlibTests.lean +1 -0
- itp_interface/tools/repl/test/Mathlib/lake-manifest.json +68 -0
- itp_interface/tools/repl/test/Mathlib/lakefile.lean +11 -0
- itp_interface/tools/repl/test/Mathlib/lean-toolchain +1 -0
- itp_interface/tools/repl/test/Mathlib/test/20240209.expected.out +20 -0
- itp_interface/tools/repl/test/Mathlib/test/20240209.in +3 -0
- itp_interface/tools/repl/test/Mathlib/test/20240209.lean +4 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231020.expected.out +8 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231020.in +8 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231020.lean +22 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231110.expected.out +4 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231110.in +4 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231115.expected.out +19 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231115.in +5 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231115_2.expected.out +18 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231115_2.in +4 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231115_3.expected.out +10 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231115_3.in +4 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231214.in +9 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231214.lean +30 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231215.expected.out +4 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231215.in +4 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231215_2.expected.out +14 -0
- itp_interface/tools/repl/test/Mathlib/test/H20231215_2.in +3 -0
- itp_interface/tools/repl/test/Mathlib/test/exact.expected.out +37 -0
- itp_interface/tools/repl/test/Mathlib/test/exact.in +10 -0
- itp_interface/tools/repl/test/Mathlib/test/import_Mathlib.lean +1 -0
- itp_interface/tools/repl/test/Mathlib/test/induction.expected.out +29 -0
- itp_interface/tools/repl/test/Mathlib/test/induction.in +10 -0
- itp_interface/tools/repl/test/Mathlib/test/induction.lean +6 -0
- itp_interface/tools/repl/test/Mathlib/test/on_goal.expected.out +22 -0
- itp_interface/tools/repl/test/Mathlib/test/on_goal.in +5 -0
- itp_interface/tools/repl/test/Mathlib/test/pickle.expected.out +16 -0
- itp_interface/tools/repl/test/Mathlib/test/pickle.in +6 -0
- itp_interface/tools/repl/test/Mathlib/test/pickle_2.expected.out +4 -0
- itp_interface/tools/repl/test/Mathlib/test/pickle_2.in +4 -0
- itp_interface/tools/repl/test/Mathlib/test.sh +41 -0
- itp_interface/tools/repl/test/all_tactics.expected.out +13 -0
- itp_interface/tools/repl/test/all_tactics.in +1 -0
- itp_interface/tools/repl/test/by_cases.expected.out +25 -0
- itp_interface/tools/repl/test/by_cases.in +8 -0
- itp_interface/tools/repl/test/by_cases.lean +4 -0
- itp_interface/tools/repl/test/calc.expected.out +32 -0
- itp_interface/tools/repl/test/calc.in +1 -0
- itp_interface/tools/repl/test/def_eval.expected.out +9 -0
- itp_interface/tools/repl/test/def_eval.in +3 -0
- itp_interface/tools/repl/test/enableInitializersExecution.expected.out +2 -0
- itp_interface/tools/repl/test/enableInitializersExecution.in +1 -0
- itp_interface/tools/repl/test/file.expected.out +8 -0
- itp_interface/tools/repl/test/file.in +1 -0
- itp_interface/tools/repl/test/file.lean +5 -0
- itp_interface/tools/repl/test/have_by_sorry.expected.out +28 -0
- itp_interface/tools/repl/test/have_by_sorry.in +6 -0
- itp_interface/tools/repl/test/import_lean.in +1 -0
- itp_interface/tools/repl/test/incomplete.expected.out +18 -0
- itp_interface/tools/repl/test/incomplete.in +3 -0
- itp_interface/tools/repl/test/incomplete.lean +0 -0
- itp_interface/tools/repl/test/infotree.expected.out +20 -0
- itp_interface/tools/repl/test/infotree.in +2 -0
- itp_interface/tools/repl/test/invalid_tactic.expected.out +20 -0
- itp_interface/tools/repl/test/invalid_tactic.in +3 -0
- itp_interface/tools/repl/test/name_generator.expected.out +53 -0
- itp_interface/tools/repl/test/name_generator.in +18 -0
- itp_interface/tools/repl/test/no_goal_sorry.expected.out +11 -0
- itp_interface/tools/repl/test/no_goal_sorry.in +1 -0
- itp_interface/tools/repl/test/no_goal_sorry_2.expected.out +12 -0
- itp_interface/tools/repl/test/no_goal_sorry_2.in +1 -0
- itp_interface/tools/repl/test/options.expected.out +17 -0
- itp_interface/tools/repl/test/options.in +6 -0
- itp_interface/tools/repl/test/pickle_environment.expected.out +8 -0
- itp_interface/tools/repl/test/pickle_environment.in +7 -0
- itp_interface/tools/repl/test/pickle_environment_with_imports.expected.out +10 -0
- itp_interface/tools/repl/test/pickle_environment_with_imports.in +9 -0
- itp_interface/tools/repl/test/pickle_open.expected.out +8 -0
- itp_interface/tools/repl/test/pickle_open.in +7 -0
- itp_interface/tools/repl/test/pickle_open_2.expected.out +4 -0
- itp_interface/tools/repl/test/pickle_open_2.in +3 -0
- itp_interface/tools/repl/test/pickle_open_scoped.expected.out +18 -0
- itp_interface/tools/repl/test/pickle_open_scoped.in +8 -0
- itp_interface/tools/repl/test/pickle_open_scoped_2.expected.out +14 -0
- itp_interface/tools/repl/test/pickle_open_scoped_2.in +3 -0
- itp_interface/tools/repl/test/pickle_proof_state_1.expected.out +26 -0
- itp_interface/tools/repl/test/pickle_proof_state_1.in +15 -0
- itp_interface/tools/repl/test/pickle_proof_state_2.expected.out +4 -0
- itp_interface/tools/repl/test/pickle_proof_state_2.in +3 -0
- itp_interface/tools/repl/test/pickle_proof_state_env.expected.out +26 -0
- itp_interface/tools/repl/test/pickle_proof_state_env.in +15 -0
- itp_interface/tools/repl/test/pickle_scoped_notation.in +16 -0
- itp_interface/tools/repl/test/pickle_scoped_notation_2.in +3 -0
- itp_interface/tools/repl/test/proof_step.expected.out +18 -0
- itp_interface/tools/repl/test/proof_step.in +7 -0
- itp_interface/tools/repl/test/readme.expected.out +16 -0
- itp_interface/tools/repl/test/readme.in +5 -0
- itp_interface/tools/repl/test/sorry_hypotheses.expected.out +16 -0
- itp_interface/tools/repl/test/sorry_hypotheses.in +4 -0
- itp_interface/tools/repl/test/synthesize_placeholder.expected.out +7 -0
- itp_interface/tools/repl/test/synthesize_placeholder.in +1 -0
- itp_interface/tools/repl/test/tactic_mode_sorry.expected.out +14 -0
- itp_interface/tools/repl/test/tactic_mode_sorry.in +3 -0
- itp_interface/tools/repl/test/tactic_sorry.expected.out +12 -0
- itp_interface/tools/repl/test/tactic_sorry.in +1 -0
- itp_interface/tools/repl/test/term_sorry.expected.out +12 -0
- itp_interface/tools/repl/test/term_sorry.in +1 -0
- itp_interface/tools/repl/test/trace_simp.expected.out +41 -0
- itp_interface/tools/repl/test/trace_simp.in +15 -0
- itp_interface/tools/repl/test/unfinished_tactic_block.expected.out +11 -0
- itp_interface/tools/repl/test/unfinished_tactic_block.in +1 -0
- itp_interface/tools/repl/test/unknown_environment.expected.out +2 -0
- itp_interface/tools/repl/test/unknown_environment.in +1 -0
- itp_interface/tools/repl/test/unknown_proof_state.expected.out +14 -0
- itp_interface/tools/repl/test/unknown_proof_state.in +3 -0
- itp_interface/tools/repl/test/unknown_tactic.expected.out +14 -0
- itp_interface/tools/repl/test/unknown_tactic.in +3 -0
- itp_interface/tools/repl/test/variables.expected.out +26 -0
- itp_interface/tools/repl/test/variables.in +5 -0
- itp_interface/tools/repl/test.sh +43 -0
- itp_interface/tools/run_data_generation_transforms.py +350 -0
- itp_interface/tools/theorem_details.py +25 -0
- itp_interface/tools/training_data.py +358 -0
- itp_interface/tools/training_data_format.py +599 -0
- itp_interface-1.0.0.dist-info/METADATA +78 -0
- itp_interface-1.0.0.dist-info/RECORD +485 -0
- itp_interface-1.0.0.dist-info/WHEEL +4 -0
- itp_interface-1.0.0.dist-info/entry_points.txt +3 -0
- itp_interface-1.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,149 @@
|
|
|
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 typing
|
|
8
|
+
import uuid
|
|
9
|
+
import os
|
|
10
|
+
from itp_interface.tools.isabelle_executor import IsabelleExecutor
|
|
11
|
+
from itp_interface.tools.isabelle_context_helper import IsabelleContextHelper
|
|
12
|
+
from itp_interface.tools.coq_training_data_generator import GenericTrainingDataGenerationTransform, TrainingDataGenerationType
|
|
13
|
+
from itp_interface.tools.training_data_format import Goal, MergableCollection, TrainingDataMetadataFormat, TrainingDataCollection, TrainingDataFormat
|
|
14
|
+
from itp_interface.tools.training_data import TrainingData
|
|
15
|
+
|
|
16
|
+
# See this for running transformation on AFP
|
|
17
|
+
# https://github.com/albertqjiang/Portal-to-ISAbelle/blob/56def2c39f85d211e1f40cc5765581a567879106/src/main/python/legacy/demo.py#L2
|
|
18
|
+
|
|
19
|
+
class LocalDataGenerationTransform(GenericTrainingDataGenerationTransform):
|
|
20
|
+
def __init__(self,
|
|
21
|
+
depth = None,
|
|
22
|
+
max_search_results = None,
|
|
23
|
+
buffer_size : int = 10000,
|
|
24
|
+
logger = None,
|
|
25
|
+
max_parallelism : int = 4,
|
|
26
|
+
**kwargs):
|
|
27
|
+
super().__init__(TrainingDataGenerationType.LOCAL, buffer_size, logger)
|
|
28
|
+
self.depth = depth
|
|
29
|
+
self.max_search_results = max_search_results
|
|
30
|
+
self.max_parallelism = max_parallelism
|
|
31
|
+
self.ray_resource_pool = kwargs.get('resource_pool', None)
|
|
32
|
+
self.pisa_severs = []
|
|
33
|
+
|
|
34
|
+
def get_meta_object(self) -> MergableCollection:
|
|
35
|
+
return TrainingDataMetadataFormat(training_data_buffer_size=self.buffer_size)
|
|
36
|
+
|
|
37
|
+
def get_data_collection_object(self) -> MergableCollection:
|
|
38
|
+
return TrainingDataCollection()
|
|
39
|
+
|
|
40
|
+
def load_meta_from_file(self, file_path) -> MergableCollection:
|
|
41
|
+
return TrainingDataMetadataFormat.load_from_file(file_path)
|
|
42
|
+
|
|
43
|
+
def load_data_from_file(self, file_path) -> MergableCollection:
|
|
44
|
+
return TrainingDataCollection.load_from_file(file_path, self.logger)
|
|
45
|
+
|
|
46
|
+
def __call__(self, training_data: TrainingData, project_id : str, isabelle_executor: IsabelleExecutor, print_coq_executor_callback: typing.Callable[[], IsabelleExecutor], theorems: typing.List[str] = None, other_args: dict = {}) -> TrainingData:
|
|
47
|
+
print_isabelle_executor = print_coq_executor_callback()
|
|
48
|
+
isabelle_context_helper = IsabelleContextHelper(print_isabelle_executor, self.depth, self.logger)
|
|
49
|
+
isabelle_context_helper.__enter__()
|
|
50
|
+
file_namespace = isabelle_executor.main_file.replace('/', '.')
|
|
51
|
+
self.logger.info(f"=========================Processing {file_namespace}=========================")
|
|
52
|
+
proof_running = False
|
|
53
|
+
cmd_ran = isabelle_executor.run_next(proof_search_mode=False)
|
|
54
|
+
cmd_exec = isabelle_executor.current_stmt
|
|
55
|
+
prev_goal : typing.List[Goal] = isabelle_context_helper.get_focussed_goals(isabelle_executor) if isabelle_executor.is_in_proof_mode() else []
|
|
56
|
+
line_number = isabelle_executor.line_num
|
|
57
|
+
lemma_name = isabelle_executor.get_lemma_name_if_running()
|
|
58
|
+
if lemma_name is None:
|
|
59
|
+
lemma_name = "__NONE__"
|
|
60
|
+
theorem_id = str(uuid.uuid4())
|
|
61
|
+
proof_id = theorem_id # self.get_proof_id(theorem_id, file_namespace, line_number, lemma_name)
|
|
62
|
+
local_lemma_refs_cnt = 0
|
|
63
|
+
external_lemma_refs_cnt = 0
|
|
64
|
+
theorems = set(theorems) if theorems is not None else None
|
|
65
|
+
while cmd_ran:
|
|
66
|
+
if isabelle_executor.is_in_proof_mode() and lemma_name != "__NONE__" and (theorems is None or lemma_name in theorems):
|
|
67
|
+
proof_running = True
|
|
68
|
+
prev_goal : typing.List[Goal] = [Goal(goal.hypotheses, goal.goal) for goal in prev_goal]
|
|
69
|
+
next_goal : typing.List[Goal] = isabelle_context_helper.get_focussed_goals(isabelle_executor)
|
|
70
|
+
if len(prev_goal) > 0:
|
|
71
|
+
training_data_format = TrainingDataFormat(
|
|
72
|
+
proof_id=proof_id,
|
|
73
|
+
all_useful_defns_theorems=[],
|
|
74
|
+
start_goals=prev_goal,
|
|
75
|
+
end_goals=next_goal,
|
|
76
|
+
proof_steps=[cmd_exec],
|
|
77
|
+
simplified_goals=[],
|
|
78
|
+
addition_state_info={},
|
|
79
|
+
file_path=isabelle_executor.main_file,
|
|
80
|
+
theorem_name=lemma_name,
|
|
81
|
+
project_id=project_id)
|
|
82
|
+
assert len(training_data_format.proof_steps) > 0, f"Proof steps cannot be empty for {proof_id}"
|
|
83
|
+
for goal in training_data_format.start_goals:
|
|
84
|
+
lemma_cnt = len(training_data_format.all_useful_defns_theorems)
|
|
85
|
+
assert all([0 <= lemma_ref.lemma_idx < lemma_cnt for lemma_ref in goal.used_theorems_local]), f"Invalid lemma idx in {proof_id}"
|
|
86
|
+
assert all([0 <= lemma_ref.lemma_idx < lemma_cnt for lemma_ref in goal.used_theorems_external]), f"Invalid lemma idx in {proof_id}"
|
|
87
|
+
assert all([0 <= lemma_ref.lemma_idx < lemma_cnt for lemma_ref in goal.possible_useful_theorems_external]), f"Invalid lemma idx in {proof_id}"
|
|
88
|
+
assert all([0 <= lemma_ref.lemma_idx < lemma_cnt for lemma_ref in goal.possible_useful_theorems_local]), f"Invalid lemma idx in {proof_id}"
|
|
89
|
+
training_data.merge(training_data_format)
|
|
90
|
+
local_lemma_refs_cnt += sum([len(goal.used_theorems_local) for goal in training_data_format.start_goals])
|
|
91
|
+
external_lemma_refs_cnt += sum([len(goal.used_theorems_external) for goal in training_data_format.start_goals])
|
|
92
|
+
prev_goal = next_goal
|
|
93
|
+
else:
|
|
94
|
+
prev_goal = []
|
|
95
|
+
cmd_ran = isabelle_executor.run_next(proof_search_mode=False)
|
|
96
|
+
cmd_exec = isabelle_executor.current_stmt
|
|
97
|
+
line_number = isabelle_executor.line_num
|
|
98
|
+
if proof_running and not isabelle_executor.is_in_proof_mode():
|
|
99
|
+
proof_running = False
|
|
100
|
+
self.logger.info(f"Finished processing lemma [{theorem_id}] {lemma_name}")
|
|
101
|
+
theorem_id = str(uuid.uuid4())
|
|
102
|
+
lemma_name = isabelle_executor.get_lemma_name_if_running()
|
|
103
|
+
if lemma_name is None:
|
|
104
|
+
lemma_name = "__NONE__"
|
|
105
|
+
proof_id = theorem_id # self.get_proof_id(theorem_id, file_namespace, line_number, lemma_name)
|
|
106
|
+
|
|
107
|
+
self.logger.info(f"===============Finished processing {file_namespace}=====================")
|
|
108
|
+
try:
|
|
109
|
+
isabelle_context_helper.__exit__(None, None, None)
|
|
110
|
+
except:
|
|
111
|
+
pass
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if __name__ == "__main__":
|
|
115
|
+
import logging
|
|
116
|
+
import time
|
|
117
|
+
os.chdir(root_dir)
|
|
118
|
+
project_dir = "data/test/isabelle/custom_hol"
|
|
119
|
+
file_name = "data/test/isabelle/custom_hol/Basic_Logic.thy"
|
|
120
|
+
project_id = project_dir.replace('/', '.')
|
|
121
|
+
time_str = time.strftime("%Y%m%d-%H%M%S")
|
|
122
|
+
output_path = f".log/local_data_generation_transform/data/{time_str}"
|
|
123
|
+
log_path = f".log/local_data_generation_transform/log/{time_str}"
|
|
124
|
+
log_file = f"{log_path}/local_data_generation_transform-{time_str}.log"
|
|
125
|
+
os.makedirs(output_path, exist_ok=True)
|
|
126
|
+
os.makedirs(log_path, exist_ok=True)
|
|
127
|
+
logging.basicConfig(filename=log_file, level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s')
|
|
128
|
+
logger = logging.getLogger(__name__)
|
|
129
|
+
def _print_isabelle_executor_callback():
|
|
130
|
+
search_isabelle_exec = IsabelleExecutor(project_root=project_dir, main_file=file_name, use_human_readable_proof_context=True, suppress_error_log=True)
|
|
131
|
+
search_isabelle_exec.__enter__()
|
|
132
|
+
return search_isabelle_exec
|
|
133
|
+
transform = LocalDataGenerationTransform(0, buffer_size=1000)
|
|
134
|
+
training_data = TrainingData(
|
|
135
|
+
output_path,
|
|
136
|
+
"training_metadata.json",
|
|
137
|
+
training_meta=transform.get_meta_object(),
|
|
138
|
+
logger=logger)
|
|
139
|
+
|
|
140
|
+
IsabelleExecutor.start_server(port=13000)
|
|
141
|
+
|
|
142
|
+
try:
|
|
143
|
+
with IsabelleExecutor(project_root=project_dir, main_file=file_name, use_human_readable_proof_context=True, suppress_error_log=True) as isabelle_exec:
|
|
144
|
+
transform(training_data, project_id, isabelle_exec, _print_isabelle_executor_callback)
|
|
145
|
+
finally:
|
|
146
|
+
IsabelleExecutor.stop_server()
|
|
147
|
+
|
|
148
|
+
save_info = training_data.save()
|
|
149
|
+
logger.info(f"Saved training data to {save_info}")
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# TODO: this parser doesn't work well because it relies on newlines as delimiters,
|
|
4
|
+
# which is often not the case in Isar proofs. However, Isar doesn't have a good delimiter in general.
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
root_dir = f"{__file__.split('itp_interface')[0]}"
|
|
9
|
+
if root_dir not in sys.path:
|
|
10
|
+
sys.path.append(root_dir)
|
|
11
|
+
import typing
|
|
12
|
+
import re
|
|
13
|
+
|
|
14
|
+
class IsabelleLineByLineReader:
|
|
15
|
+
|
|
16
|
+
theorem_regex = r"((((theorem\s+|lemma\s+)([\w+|\d+'_]*)))(\s*:\s*)([\S|\s]*?))(\ssorry|\susing\s|\sby\s|\sproof)"
|
|
17
|
+
theorem_match = re.compile(theorem_regex, re.MULTILINE)
|
|
18
|
+
|
|
19
|
+
def __init__(self, file_name: str = None, file_content: str = None):
|
|
20
|
+
assert file_name is not None or file_content is not None, "Either file_name or file_content must be provided"
|
|
21
|
+
assert file_name is None or file_content is None, "Only one of file_name or file_content must be provided"
|
|
22
|
+
self.file_name : str = file_name
|
|
23
|
+
self.file_content : str = file_content
|
|
24
|
+
if self.file_name is not None:
|
|
25
|
+
with open(file_name, 'r') as fd:
|
|
26
|
+
self.file_content : str = fd.read()
|
|
27
|
+
self.remove_comments()
|
|
28
|
+
self.handle_theorems()
|
|
29
|
+
|
|
30
|
+
def remove_comments(self):
|
|
31
|
+
CODE_MODE = 0
|
|
32
|
+
COMMENT_MODE = 1
|
|
33
|
+
idx = 0
|
|
34
|
+
mode = CODE_MODE
|
|
35
|
+
code_without_comments = []
|
|
36
|
+
comment_stack = []
|
|
37
|
+
while idx < len(self.file_content):
|
|
38
|
+
ch = self.file_content[idx]
|
|
39
|
+
if mode == CODE_MODE and ch == '(' and idx + 1 < len(self.file_content) and self.file_content[idx + 1] == '*':
|
|
40
|
+
mode = COMMENT_MODE
|
|
41
|
+
idx += 2
|
|
42
|
+
comment_stack.append("(*")
|
|
43
|
+
elif mode == COMMENT_MODE and ch == '(' and idx + 1 < len(self.file_content) and self.file_content[idx + 1] == '*':
|
|
44
|
+
mode = COMMENT_MODE
|
|
45
|
+
idx += 2
|
|
46
|
+
comment_stack.append("(*") # Start of nested comment
|
|
47
|
+
elif mode == COMMENT_MODE and ch == '*' and idx + 1 < len(self.file_content) and self.file_content[idx + 1] == ')':
|
|
48
|
+
comment_stack.pop()
|
|
49
|
+
if len(comment_stack) == 0:
|
|
50
|
+
mode = CODE_MODE
|
|
51
|
+
else:
|
|
52
|
+
assert comment_stack[-1] == "(*", "Comment stack should only contain '(*'"
|
|
53
|
+
mode = COMMENT_MODE # There is some nested comment still open
|
|
54
|
+
idx += 2
|
|
55
|
+
elif mode == COMMENT_MODE:
|
|
56
|
+
mode = COMMENT_MODE
|
|
57
|
+
idx += 1
|
|
58
|
+
elif mode == CODE_MODE:
|
|
59
|
+
code_without_comments.append(ch)
|
|
60
|
+
idx += 1
|
|
61
|
+
else:
|
|
62
|
+
raise Exception("Unknown mode")
|
|
63
|
+
self.file_content = "".join(code_without_comments)
|
|
64
|
+
|
|
65
|
+
# Make sure that when a theorem is parsed, there aren't any tactics on the same line
|
|
66
|
+
def handle_theorems(self):
|
|
67
|
+
self.file_content = IsabelleLineByLineReader.theorem_match.sub(r'\1\n\8', self.file_content)
|
|
68
|
+
|
|
69
|
+
def instruction_step_generator(self) -> typing.Iterator[str]:
|
|
70
|
+
lines = self.file_content.split('\n')
|
|
71
|
+
for line in lines:
|
|
72
|
+
if not len(line.strip()) == 0:
|
|
73
|
+
yield line.strip()
|
|
74
|
+
|
|
75
|
+
class IsabelleStepByStepStdInReader:
|
|
76
|
+
def __init__(self):
|
|
77
|
+
pass
|
|
78
|
+
|
|
79
|
+
def instruction_step_generator(self) -> typing.Iterator[str]:
|
|
80
|
+
while True:
|
|
81
|
+
try:
|
|
82
|
+
line = input()
|
|
83
|
+
if line == "(* exit *)":
|
|
84
|
+
break
|
|
85
|
+
yield line.strip() # Keep going line by line
|
|
86
|
+
except EOFError:
|
|
87
|
+
break
|
|
88
|
+
|
|
89
|
+
if __name__ == "__main__":
|
|
90
|
+
file_content = """
|
|
91
|
+
(*
|
|
92
|
+
Authors: Wenda Li
|
|
93
|
+
*)
|
|
94
|
+
|
|
95
|
+
theory aime_1983_p1 imports Complex_Main
|
|
96
|
+
begin
|
|
97
|
+
|
|
98
|
+
theorem aime_1983_p1:
|
|
99
|
+
fixes x y z w :: nat
|
|
100
|
+
assumes ht : "1 < x \<and> 1 < y \<and> 1 < z"
|
|
101
|
+
and hw : "0 \<le> w"
|
|
102
|
+
and h0 : "ln w / ln x = 24"
|
|
103
|
+
and h1 : "ln w / ln y = 40"
|
|
104
|
+
and h2 : "ln w / ln (x * y * z) = 12"
|
|
105
|
+
shows "ln w / ln z = 60"
|
|
106
|
+
proof -
|
|
107
|
+
define xx yy zz ww where "xx=ln x" and "yy = ln y"
|
|
108
|
+
and "zz = ln z" and "ww = ln w"
|
|
109
|
+
have "xx= ww/24" using h0 ht unfolding xx_def ww_def
|
|
110
|
+
by (auto simp:field_simps)
|
|
111
|
+
moreover have "yy = ww / 40" using ht h1 unfolding yy_def ww_def
|
|
112
|
+
by (auto simp:field_simps)
|
|
113
|
+
moreover have "xx+yy+zz > 0"
|
|
114
|
+
unfolding xx_def yy_def zz_def using ht
|
|
115
|
+
by (metis ln_gt_zero of_nat_1 of_nat_less_iff pos_add_strict)
|
|
116
|
+
then have "ww = 12*(xx+yy+zz)"using ht h2
|
|
117
|
+
unfolding xx_def yy_def zz_def ww_def
|
|
118
|
+
by (auto simp:field_simps ln_mult)
|
|
119
|
+
ultimately have "ww = 12*(ww/24 + ww/40 + zz)"
|
|
120
|
+
by blast
|
|
121
|
+
then have "ww=60*zz"
|
|
122
|
+
by (auto simp:field_simps)
|
|
123
|
+
then show ?thesis unfolding ww_def zz_def using ht by auto
|
|
124
|
+
qed
|
|
125
|
+
|
|
126
|
+
end
|
|
127
|
+
"""
|
|
128
|
+
isabelle_reader = IsabelleLineByLineReader(file_content=file_content)
|
|
129
|
+
assert isabelle_reader.file_content is not None
|
|
130
|
+
for idx, instruction in enumerate(isabelle_reader.instruction_step_generator()):
|
|
131
|
+
print(f"[{idx}]: {instruction}")
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
root_dir = f"{__file__.split('itp_interface')[0]}"
|
|
3
|
+
if root_dir not in sys.path:
|
|
4
|
+
sys.path.append(root_dir)
|
|
5
|
+
import os
|
|
6
|
+
import ray
|
|
7
|
+
import signal
|
|
8
|
+
import subprocess
|
|
9
|
+
import time
|
|
10
|
+
import threading
|
|
11
|
+
import uuid
|
|
12
|
+
from itp_interface.tools.log_utils import setup_logger
|
|
13
|
+
|
|
14
|
+
@ray.remote
|
|
15
|
+
class IsabelleServer(object):
|
|
16
|
+
def __init__(self, log_filename: str, port: int = 8000):
|
|
17
|
+
assert port > 0, "Port number must be greater than 0"
|
|
18
|
+
assert port < 65536, "Port number must be less than 65536"
|
|
19
|
+
self.log_filename = log_filename
|
|
20
|
+
self.port = port
|
|
21
|
+
logger_id = str(uuid.uuid4())
|
|
22
|
+
with open(log_filename, "w") as f:
|
|
23
|
+
f.write("")
|
|
24
|
+
self.logger = setup_logger(f"isabelle_server_{logger_id}", log_filename)
|
|
25
|
+
self.pid = None
|
|
26
|
+
self.thread_id = None
|
|
27
|
+
self.process_killed = False
|
|
28
|
+
self.process = None
|
|
29
|
+
|
|
30
|
+
def start_server(self):
|
|
31
|
+
last_dir = os.path.dirname(root_dir)
|
|
32
|
+
os.chdir(last_dir)
|
|
33
|
+
|
|
34
|
+
jar_path = "itp_interface/pisa/target/scala-2.13/PISA-assembly-0.1.jar"
|
|
35
|
+
assert os.path.exists(jar_path), "PISA jar file not found. Please build the project using 'sbt assembly' commnad"
|
|
36
|
+
cmd = f"java -cp {jar_path} pisa.server.PisaOneStageServer{self.port}"
|
|
37
|
+
# Start the server in a separate process
|
|
38
|
+
cwd = os.getcwd()
|
|
39
|
+
server_process = subprocess.Popen(
|
|
40
|
+
cmd,
|
|
41
|
+
cwd=cwd,
|
|
42
|
+
shell=True,
|
|
43
|
+
stdout=subprocess.PIPE,
|
|
44
|
+
stderr=subprocess.PIPE,
|
|
45
|
+
preexec_fn=os.setsid) # Create a new process group so that we can kill the process and all its children
|
|
46
|
+
pid = server_process.pid
|
|
47
|
+
self.pid = pid
|
|
48
|
+
# Log the process id
|
|
49
|
+
self.logger.info(f"Server process id: {self.pid}")
|
|
50
|
+
# Log the port number
|
|
51
|
+
self.logger.info(f"Server port: {self.port}")
|
|
52
|
+
self.logger.info("Waiting for server to start")
|
|
53
|
+
time.sleep(5)
|
|
54
|
+
server_running = self.check_server_running()
|
|
55
|
+
if not server_running:
|
|
56
|
+
self.logger.error(f"Server is not running on port {self.port}")
|
|
57
|
+
else:
|
|
58
|
+
self.process = server_process
|
|
59
|
+
thread = threading.Thread(target=self._server_logging_thread)
|
|
60
|
+
thread.start()
|
|
61
|
+
thread_id = thread.ident
|
|
62
|
+
self.thread_id = thread_id
|
|
63
|
+
pass
|
|
64
|
+
|
|
65
|
+
def check_server_running(self):
|
|
66
|
+
# log the netsat result netstat -nlp | grep :{port}
|
|
67
|
+
netstat_cmd = f"netstat -nlp | grep :{self.port}"
|
|
68
|
+
self.logger.info(f"Netstat command: {netstat_cmd}")
|
|
69
|
+
output = subprocess.run(netstat_cmd, shell=True, capture_output=True)
|
|
70
|
+
self.logger.info(f"Netstat output: {output}")
|
|
71
|
+
output_str = output.stdout.decode("utf-8")
|
|
72
|
+
self.logger.info(f"Netstat output stdout: {output_str}")
|
|
73
|
+
server_running = "tcp" in output_str
|
|
74
|
+
return server_running
|
|
75
|
+
|
|
76
|
+
def _server_logging_thread(self):
|
|
77
|
+
# Keep checking the server is running
|
|
78
|
+
while not self.process_killed:
|
|
79
|
+
try:
|
|
80
|
+
line = self.process.stdout.readline()
|
|
81
|
+
if not line:
|
|
82
|
+
break
|
|
83
|
+
self.logger.info(line)
|
|
84
|
+
except:
|
|
85
|
+
self.logger.info("Stdout is closed")
|
|
86
|
+
time.sleep(1)
|
|
87
|
+
self.logger.info("Server is shut down")
|
|
88
|
+
# Print the environment variables
|
|
89
|
+
self.logger.info(f"Environment variables at shutdown time: {os.environ}")
|
|
90
|
+
time.sleep(1)
|
|
91
|
+
pass
|
|
92
|
+
|
|
93
|
+
def stop_server(self):
|
|
94
|
+
self.process_killed = True
|
|
95
|
+
try:
|
|
96
|
+
# Kill the server process
|
|
97
|
+
os.killpg(self.pid, signal.SIGTERM)
|
|
98
|
+
except:
|
|
99
|
+
pass
|
|
100
|
+
thread_id = self.thread_id
|
|
101
|
+
# Find the right thread object
|
|
102
|
+
for thread in threading.enumerate():
|
|
103
|
+
if thread.ident == thread_id:
|
|
104
|
+
thread.join(5)
|
|
105
|
+
break
|
|
106
|
+
pass
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
|
|
8
|
+
import logging
|
|
9
|
+
import typing
|
|
10
|
+
from itp_interface.tools.lean4_sync_executor import Lean4SyncExecutor, ProofContext
|
|
11
|
+
from itp_interface.tools.training_data_format import Goal, LemmaRefWithScore, LemmaReferences, TrainingDataFormat
|
|
12
|
+
from typing import List
|
|
13
|
+
|
|
14
|
+
class Lean4ContextHelper(object):
|
|
15
|
+
max_relevance_score = 0.95
|
|
16
|
+
def __init__(self, search_executor: Lean4SyncExecutor, depth : typing.Optional[int] = None, logger: logging.Logger = None) -> None:
|
|
17
|
+
assert search_executor is not None, "Search executor cannot be None"
|
|
18
|
+
assert depth is None or depth >= 0, "Depth should be greater than 0"
|
|
19
|
+
self.search_executor = search_executor
|
|
20
|
+
self.depth = depth if depth is not None else -1
|
|
21
|
+
self.logger = logger if logger is not None else logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
def __enter__(self):
|
|
24
|
+
return self
|
|
25
|
+
|
|
26
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
def get_focussed_goals(self, lean_executor: Lean4SyncExecutor) -> List[Goal]:
|
|
30
|
+
# Only consider the foreground goals because we can handle the multi-line tactics
|
|
31
|
+
return [Goal(hypotheses=goal.hypotheses, goal=goal.goal) for goal in lean_executor.proof_context.fg_goals]
|
|
32
|
+
|
|
33
|
+
def get_focussed_goals_from_proof_context(self, proof_context: ProofContext) -> List[Goal]:
|
|
34
|
+
# Only consider the foreground goals because we can handle the multi-line tactics
|
|
35
|
+
return [Goal(hypotheses=goal.hypotheses, goal=goal.goal) for goal in proof_context.fg_goals]
|
|
36
|
+
|
|
37
|
+
def get_unfocussed_goals(self, lean_executor: Lean4SyncExecutor) -> List[Goal]:
|
|
38
|
+
# Only consider the foreground goals because we can handle the multi-line tactics
|
|
39
|
+
other_goals = lean_executor.proof_context.bg_goals + lean_executor.proof_context.shelved_goals + lean_executor.proof_context.given_up_goals
|
|
40
|
+
return [Goal(hypotheses=goal.hypotheses, goal=goal.goal) for goal in other_goals]
|
|
41
|
+
|
|
42
|
+
def get_local_lemmas(self, lean_executor: Lean4SyncExecutor, logger: logging.Logger = None) -> List[typing.Tuple[str, str]]:
|
|
43
|
+
# Search is not supported in Lean as of now
|
|
44
|
+
raise Exception("Search is not supported in Lean as of now")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def set_relevant_defns_in_training_data_point(self, training_data_point: TrainingDataFormat, lean_executor: Lean4SyncExecutor, logger: logging.Logger = None, depth: int = None):
|
|
48
|
+
# Search is not supported in Lean as of now
|
|
49
|
+
raise Exception("Search is not supported in Lean as of now")
|
|
50
|
+
|
|
51
|
+
def set_all_type_matched_query_result(self, training_data_point: TrainingDataFormat, lean_executor: Lean4SyncExecutor, logger: logging.Logger = None, depth: int = None):
|
|
52
|
+
unique_thms = {defn.lemma_name: idx for idx, defn in enumerate(training_data_point.all_useful_defns_theorems)}
|
|
53
|
+
# query = training_data_point.get_human_readable_serialized_goal(idx, skip_special_tokens=True)
|
|
54
|
+
relevant_thms = self.search_executor.search_type_matching_defns("") # Here the search simply returns everything
|
|
55
|
+
# Add all lemma references to unique_defns
|
|
56
|
+
for thm in relevant_thms:
|
|
57
|
+
thm_name = f"{thm.namespace}.{thm.name}"
|
|
58
|
+
if thm.name not in unique_thms:
|
|
59
|
+
_idx = len(training_data_point.all_useful_defns_theorems)
|
|
60
|
+
unique_thms[thm_name] = _idx
|
|
61
|
+
training_data_point.all_useful_defns_theorems.append(LemmaReferences(_idx, thm_name, thm.dfn))
|
|
62
|
+
for _, goal in enumerate(training_data_point.start_goals):
|
|
63
|
+
goal.possible_useful_theorems_external = [LemmaRefWithScore(unique_thms[f"{thm.namespace}.{thm.name}"], 1.0) for thm in relevant_thms]
|
|
64
|
+
goal.possible_useful_theorems_local = []
|
|
65
|
+
|
|
66
|
+
def set_useful_defns_theorems_for_training_data_generation(self, current_stmt: str, training_data_point: TrainingDataFormat, lean_executor: Lean4SyncExecutor, logger: logging.Logger = None, depth: int = None, max_search_res: typing.Optional[int] = None):
|
|
67
|
+
# Search is not supported in Lean as of now
|
|
68
|
+
raise Exception("Search is not supported in Lean as of now")
|
|
69
|
+
|
|
70
|
+
def set_local_thms_dfns(self, training_data_point: TrainingDataFormat, lean_executor: Lean4SyncExecutor, logger: logging.Logger = None):
|
|
71
|
+
# Search is not supported in Lean as of now
|
|
72
|
+
raise Exception("Search is not supported in Lean as of now")
|
|
@@ -0,0 +1,122 @@
|
|
|
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 typing
|
|
8
|
+
import uuid
|
|
9
|
+
from itp_interface.tools.lean4_sync_executor import Lean4SyncExecutor
|
|
10
|
+
from itp_interface.tools.lean4_context_helper import Lean4ContextHelper
|
|
11
|
+
from itp_interface.tools.coq_training_data_generator import GenericTrainingDataGenerationTransform, TrainingDataGenerationType
|
|
12
|
+
from itp_interface.tools.training_data_format import MergableCollection, TrainingDataMetadataFormat, TrainingDataCollection, TrainingDataFormat
|
|
13
|
+
from itp_interface.tools.training_data import TrainingData
|
|
14
|
+
|
|
15
|
+
class Local4DataGenerationTransform(GenericTrainingDataGenerationTransform):
|
|
16
|
+
def __init__(self,
|
|
17
|
+
depth = None,
|
|
18
|
+
max_search_results = None,
|
|
19
|
+
buffer_size : int = 10000,
|
|
20
|
+
logger = None,
|
|
21
|
+
max_parallelism : int = 4):
|
|
22
|
+
super().__init__(TrainingDataGenerationType.LOCAL, buffer_size, logger)
|
|
23
|
+
self.depth = depth
|
|
24
|
+
self.max_search_results = max_search_results
|
|
25
|
+
self.max_parallelism = max_parallelism
|
|
26
|
+
|
|
27
|
+
def get_meta_object(self) -> MergableCollection:
|
|
28
|
+
return TrainingDataMetadataFormat(training_data_buffer_size=self.buffer_size)
|
|
29
|
+
|
|
30
|
+
def get_data_collection_object(self) -> MergableCollection:
|
|
31
|
+
return TrainingDataCollection()
|
|
32
|
+
|
|
33
|
+
def load_meta_from_file(self, file_path) -> MergableCollection:
|
|
34
|
+
return TrainingDataMetadataFormat.load_from_file(file_path)
|
|
35
|
+
|
|
36
|
+
def load_data_from_file(self, file_path) -> MergableCollection:
|
|
37
|
+
return TrainingDataCollection.load_from_file(file_path, self.logger)
|
|
38
|
+
|
|
39
|
+
def __call__(self, training_data: TrainingData, project_id : str, lean_executor: Lean4SyncExecutor, print_coq_executor_callback: typing.Callable[[], Lean4SyncExecutor], theorems: typing.List[str] = None, other_args: dict = {}) -> TrainingData:
|
|
40
|
+
print_lean_executor = print_coq_executor_callback()
|
|
41
|
+
lean_context_helper = Lean4ContextHelper(print_lean_executor, self.depth, self.logger)
|
|
42
|
+
lean_context_helper.__enter__()
|
|
43
|
+
file_namespace = lean_executor.main_file.replace('/', '.')
|
|
44
|
+
self.logger.info(f"=========================Processing {file_namespace}=========================")
|
|
45
|
+
theorem_id = str(uuid.uuid4())
|
|
46
|
+
theorems = set(theorems) if theorems is not None else None
|
|
47
|
+
assert len(theorems) == 1, "Only one theorem can be processed at a time"
|
|
48
|
+
with lean_executor:
|
|
49
|
+
lean_executor.set_run_exactly()
|
|
50
|
+
lean_executor._skip_to_theorem(theorems.pop())
|
|
51
|
+
start_goals = lean_context_helper.get_focussed_goals_from_proof_context(lean_executor.proof_context)
|
|
52
|
+
ran_next = lean_executor.run_next()
|
|
53
|
+
cmd_ran = lean_executor.current_stmt
|
|
54
|
+
try:
|
|
55
|
+
theorem_id = theorem_id + "/" + lean_executor.get_current_lemma_name()
|
|
56
|
+
except:
|
|
57
|
+
pass
|
|
58
|
+
proof_id = theorem_id
|
|
59
|
+
while not lean_executor.execution_complete and ran_next:
|
|
60
|
+
if lean_executor.is_in_proof_mode():
|
|
61
|
+
end_goals = lean_context_helper.get_focussed_goals_from_proof_context(lean_executor.proof_context)
|
|
62
|
+
else:
|
|
63
|
+
end_goals = []
|
|
64
|
+
if len(start_goals) > 0 and \
|
|
65
|
+
(len(start_goals) != len(end_goals) or not all(s_g == e_g for s_g, e_g in zip(start_goals, end_goals))):
|
|
66
|
+
tdf = TrainingDataFormat(
|
|
67
|
+
proof_id=proof_id,
|
|
68
|
+
all_useful_defns_theorems=[],
|
|
69
|
+
start_goals=start_goals,
|
|
70
|
+
end_goals=end_goals,
|
|
71
|
+
proof_steps=[cmd_ran],
|
|
72
|
+
simplified_goals=[],
|
|
73
|
+
addition_state_info={},
|
|
74
|
+
file_path=lean_executor.main_file,
|
|
75
|
+
theorem_name=proof_id,
|
|
76
|
+
project_id=project_id)
|
|
77
|
+
training_data.merge(tdf)
|
|
78
|
+
if lean_executor.is_in_proof_mode():
|
|
79
|
+
start_goals = end_goals
|
|
80
|
+
ran_next = lean_executor.run_next()
|
|
81
|
+
cmd_ran = lean_executor.current_stmt
|
|
82
|
+
else:
|
|
83
|
+
ran_next = False
|
|
84
|
+
training_data.meta.num_theorems += 1
|
|
85
|
+
self.logger.info(f"===============Finished processing {file_namespace}=====================")
|
|
86
|
+
self.logger.info(f"Total theorems processed in this transform: 1")
|
|
87
|
+
try:
|
|
88
|
+
lean_context_helper.__exit__(None, None, None)
|
|
89
|
+
except:
|
|
90
|
+
pass
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
if __name__ == "__main__":
|
|
94
|
+
import os
|
|
95
|
+
import logging
|
|
96
|
+
import time
|
|
97
|
+
os.chdir(root_dir)
|
|
98
|
+
project_dir = 'data/test/lean4_proj/'
|
|
99
|
+
file_name = 'data/test/lean4_proj/Lean4Proj/Basic.lean'
|
|
100
|
+
project_id = project_dir.replace('/', '.')
|
|
101
|
+
time_str = time.strftime("%Y%m%d-%H%M%S")
|
|
102
|
+
output_path = f".log/local_data_generation_transform/data/{time_str}"
|
|
103
|
+
log_path = f".log/local_data_generation_transform/log/{time_str}"
|
|
104
|
+
log_file = f"{log_path}/local_data_generation_transform-{time_str}.log"
|
|
105
|
+
os.makedirs(output_path, exist_ok=True)
|
|
106
|
+
os.makedirs(log_path, exist_ok=True)
|
|
107
|
+
logging.basicConfig(filename=log_file, level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s')
|
|
108
|
+
logger = logging.getLogger(__name__)
|
|
109
|
+
def _print_lean_executor_callback():
|
|
110
|
+
search_lean_exec = Lean4SyncExecutor(main_file=file_name, project_root=project_dir)
|
|
111
|
+
search_lean_exec.__enter__()
|
|
112
|
+
return search_lean_exec
|
|
113
|
+
transform = Local4DataGenerationTransform(0, buffer_size=1000)
|
|
114
|
+
training_data = TrainingData(
|
|
115
|
+
output_path,
|
|
116
|
+
"training_metadata.json",
|
|
117
|
+
training_meta=transform.get_meta_object(),
|
|
118
|
+
logger=logger)
|
|
119
|
+
with Lean4SyncExecutor(project_root=project_dir, main_file=file_name, use_human_readable_proof_context=True, suppress_error_log=True) as coq_exec:
|
|
120
|
+
transform(training_data, project_id, coq_exec, _print_lean_executor_callback, theorems=['{"namespace": "Lean4Proj1", "name": "test2"}'])
|
|
121
|
+
save_info = training_data.save()
|
|
122
|
+
logger.info(f"Saved training data to {save_info}")
|