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,220 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
root_dir = f"{__file__.split('itp_interface')[0]}"
|
|
7
|
+
if root_dir not in sys.path:
|
|
8
|
+
sys.path.append(root_dir)
|
|
9
|
+
import typing
|
|
10
|
+
import os
|
|
11
|
+
import enum
|
|
12
|
+
import logging
|
|
13
|
+
from itp_interface.tools.training_data_format import Goal, TrainingDataFormat
|
|
14
|
+
from itp_interface.tools.coq_parse_utils import CoqLineByLineReader
|
|
15
|
+
from itp_interface.tools.coq_executor import CoqExecutor
|
|
16
|
+
from itp_interface.tools.coq_context_helper import CoqContextHelper
|
|
17
|
+
|
|
18
|
+
class IntertwinedIterator(object):
|
|
19
|
+
def __init__(self, iterator: typing.Optional[typing.Iterator[str]] = None):
|
|
20
|
+
self.base_iterator = iterator
|
|
21
|
+
self.next_instruction: typing.Optional[str] = None
|
|
22
|
+
self.base_iterator_stopped = iterator is None # if the base iterator is None, then it is stopped
|
|
23
|
+
|
|
24
|
+
def set_next_instruction(self, instruction: str):
|
|
25
|
+
assert self.next_instruction is None, "next_instruction must be None"
|
|
26
|
+
assert instruction is not None, "instruction must not be None"
|
|
27
|
+
self.next_instruction = instruction
|
|
28
|
+
|
|
29
|
+
def __iter__(self):
|
|
30
|
+
return self
|
|
31
|
+
|
|
32
|
+
def __next__(self):
|
|
33
|
+
if self.next_instruction is not None:
|
|
34
|
+
# Return the next instruction if it is set
|
|
35
|
+
next_instruction = self.next_instruction
|
|
36
|
+
self.next_instruction = None
|
|
37
|
+
return next_instruction
|
|
38
|
+
# Otherwise, get the next instruction from the base iterator
|
|
39
|
+
if self.base_iterator is not None and not self.base_iterator_stopped:
|
|
40
|
+
try:
|
|
41
|
+
instruction = next(self.base_iterator)
|
|
42
|
+
return instruction
|
|
43
|
+
except StopIteration:
|
|
44
|
+
self.base_iterator_stopped = True
|
|
45
|
+
raise
|
|
46
|
+
else:
|
|
47
|
+
raise StopIteration()
|
|
48
|
+
|
|
49
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
50
|
+
if self.base_iterator is not None:
|
|
51
|
+
self.base_iterator.close()
|
|
52
|
+
pass
|
|
53
|
+
|
|
54
|
+
class DynamicProofExecutor(CoqExecutor):
|
|
55
|
+
class RunState(object):
|
|
56
|
+
def __init__(self):
|
|
57
|
+
self.tatics_ran = []
|
|
58
|
+
self.last_exception : typing.Optional[str] = None
|
|
59
|
+
UnfocussedGoalsDescription = "There are unfocussed goals."
|
|
60
|
+
ProofFinishedDescription = "Proof finished."
|
|
61
|
+
NotInProofModeDescription = "Not in proof mode."
|
|
62
|
+
GoalDescriptionOrder = {
|
|
63
|
+
UnfocussedGoalsDescription: 2, # This more hard
|
|
64
|
+
ProofFinishedDescription: 1, # This is easier coz proof is almost done
|
|
65
|
+
NotInProofModeDescription: 0 # This is the easiest as the proof is done
|
|
66
|
+
}
|
|
67
|
+
class ContextType(enum.Enum):
|
|
68
|
+
NoContext = 0
|
|
69
|
+
LocalContext = 1
|
|
70
|
+
BestContext = 2
|
|
71
|
+
|
|
72
|
+
def goal_description_compare(description1: str, descripton2: str) -> int:
|
|
73
|
+
"""
|
|
74
|
+
Returns 1 if description1 < description2, 0 if description1 == description2, -1 if description1 > description2
|
|
75
|
+
"""
|
|
76
|
+
# In case of no description it is much more harder as we have to do a lot of work
|
|
77
|
+
# So None will have same value as unfocussed goals
|
|
78
|
+
order1 = DynamicProofExecutor.GoalDescriptionOrder.get(description1, 2) if description1 is not None else 2
|
|
79
|
+
order2 = DynamicProofExecutor.GoalDescriptionOrder.get(descripton2, 2) if descripton2 is not None else 2
|
|
80
|
+
if order1 < order2:
|
|
81
|
+
return 1
|
|
82
|
+
elif order1 == order2:
|
|
83
|
+
return 0
|
|
84
|
+
else:
|
|
85
|
+
return -1
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def __init__(self, coq_context_helper: CoqContextHelper, project_folder: str = None, proof_file: str = None, instruction_iter: typing.Optional[str] = None, use_hammer: bool = False, timeout_in_seconds: int = 60, use_human_readable_proof_context: bool = True, suppress_error_log: bool = True, context_type: ContextType = ContextType.NoContext, setup_cmds: typing.List[str] = []):
|
|
89
|
+
assert proof_file is None or os.path.exists(proof_file), f"Proof file {proof_file} does not exist"
|
|
90
|
+
assert coq_context_helper is not None, "coq_context_helper must not be None"
|
|
91
|
+
self.proof_file = proof_file
|
|
92
|
+
self.context_type = context_type
|
|
93
|
+
self.coq_file_iter = CoqLineByLineReader(proof_file).instruction_step_generator() if proof_file is not None else instruction_iter
|
|
94
|
+
self.tactic_switch_iterator = IntertwinedIterator(self.coq_file_iter)
|
|
95
|
+
self.run_state = DynamicProofExecutor.RunState()
|
|
96
|
+
self.logger = None
|
|
97
|
+
self.coq_context_helper = coq_context_helper
|
|
98
|
+
super().__init__(project_root=project_folder, proof_step_iter=self.tactic_switch_iterator, use_hammer=use_hammer, timeout_in_sec=timeout_in_seconds, use_human_readable_proof_context=use_human_readable_proof_context, suppress_error_log=suppress_error_log, setup_cmds=setup_cmds)
|
|
99
|
+
|
|
100
|
+
def __enter__(self):
|
|
101
|
+
self.coq_context_helper.__enter__()
|
|
102
|
+
return super().__enter__()
|
|
103
|
+
|
|
104
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
105
|
+
self.coq_context_helper.__exit__(exc_type, exc_val, exc_tb)
|
|
106
|
+
super().__exit__(exc_type, exc_val, exc_tb)
|
|
107
|
+
|
|
108
|
+
def set_logger(self, logger: logging.Logger):
|
|
109
|
+
self.logger = logger
|
|
110
|
+
pass
|
|
111
|
+
|
|
112
|
+
def get_focussed_goals(self) -> typing.List[Goal]:
|
|
113
|
+
if not self.is_in_proof_mode():
|
|
114
|
+
return []
|
|
115
|
+
return self.coq_context_helper.get_focussed_goals(self)
|
|
116
|
+
|
|
117
|
+
def get_unfocussed_goals(self) -> typing.List[Goal]:
|
|
118
|
+
if not self.is_in_proof_mode():
|
|
119
|
+
return []
|
|
120
|
+
return self.coq_context_helper.get_unfocussed_goals(self)
|
|
121
|
+
|
|
122
|
+
def get_current_proof_state_as_training_data(self) -> TrainingDataFormat:
|
|
123
|
+
# get the current goal
|
|
124
|
+
if self.needs_cut_close():
|
|
125
|
+
current_goals = self.get_unfocussed_goals()
|
|
126
|
+
training_data_format = TrainingDataFormat(start_goals=current_goals)
|
|
127
|
+
training_data_format.goal_description = DynamicProofExecutor.UnfocussedGoalsDescription
|
|
128
|
+
elif not self.is_in_proof_mode():
|
|
129
|
+
current_goals = self.get_focussed_goals()
|
|
130
|
+
training_data_format = TrainingDataFormat(start_goals=current_goals)
|
|
131
|
+
training_data_format.goal_description = DynamicProofExecutor.NotInProofModeDescription
|
|
132
|
+
elif self.needs_qed():
|
|
133
|
+
current_goals = self.get_focussed_goals()
|
|
134
|
+
assert len(current_goals) == 0, "There should be no goals when needs_qed is True"
|
|
135
|
+
training_data_format = TrainingDataFormat(start_goals=current_goals)
|
|
136
|
+
training_data_format.goal_description = DynamicProofExecutor.ProofFinishedDescription
|
|
137
|
+
else:
|
|
138
|
+
current_goals = self.get_focussed_goals()
|
|
139
|
+
training_data_format = TrainingDataFormat(start_goals=current_goals)
|
|
140
|
+
training_data_format.goal_description = None
|
|
141
|
+
return training_data_format
|
|
142
|
+
|
|
143
|
+
def get_all_relevant_thms(self, should_print_symbol: bool = False) -> TrainingDataFormat:
|
|
144
|
+
training_data_format = self.get_current_proof_state_as_training_data()
|
|
145
|
+
self.coq_context_helper.set_all_type_matched_query_result(training_data_format, self, self.logger, should_print_symbol=should_print_symbol)
|
|
146
|
+
return training_data_format
|
|
147
|
+
|
|
148
|
+
def get_all_relevant_thms_within_local_context(self) -> TrainingDataFormat:
|
|
149
|
+
training_data_format = self.get_current_proof_state_as_training_data()
|
|
150
|
+
self.coq_context_helper.set_local_thms_dfns(training_data_format, self, self.logger)
|
|
151
|
+
return training_data_format
|
|
152
|
+
|
|
153
|
+
def get_all_relevant_defns(self) -> TrainingDataFormat:
|
|
154
|
+
training_data_format = self.get_current_proof_state_as_training_data()
|
|
155
|
+
self.coq_context_helper.set_relevant_defns_in_training_data_point(training_data_format, self, self.logger)
|
|
156
|
+
return training_data_format
|
|
157
|
+
|
|
158
|
+
def get_all_relevant_defns_and_thms(self, should_print_symbol: bool = False, only_local: bool = False, only_proof_state: bool = False) -> TrainingDataFormat:
|
|
159
|
+
training_data_format = self.get_current_proof_state_as_training_data()
|
|
160
|
+
if not only_proof_state:
|
|
161
|
+
self.coq_context_helper.set_relevant_defns_in_training_data_point(training_data_format, self, self.logger, should_print_symbol=should_print_symbol, only_local=only_local)
|
|
162
|
+
# Don't print symbols for theorems as it will print the proof as well which is not needed to apply the theorem
|
|
163
|
+
self.coq_context_helper.set_all_type_matched_query_result(training_data_format, self, self.logger, should_print_symbol=False, only_local=only_local)
|
|
164
|
+
return training_data_format
|
|
165
|
+
|
|
166
|
+
def run_cmds(self, cmds: typing.List[str], raise_exception=False) -> typing.Tuple[int, bool]:
|
|
167
|
+
cmd_failed = False
|
|
168
|
+
start_line_num = self.line_num
|
|
169
|
+
for cmd in cmds:
|
|
170
|
+
self.tactic_switch_iterator.set_next_instruction(cmd)
|
|
171
|
+
try:
|
|
172
|
+
self.run_next()
|
|
173
|
+
except Exception:
|
|
174
|
+
self.line_num -= 1
|
|
175
|
+
cmd_failed = True
|
|
176
|
+
if raise_exception:
|
|
177
|
+
raise
|
|
178
|
+
else:
|
|
179
|
+
break
|
|
180
|
+
return start_line_num, not cmd_failed
|
|
181
|
+
|
|
182
|
+
def run_tactics(self, tactics: typing.List[str]) -> typing.Tuple[int, bool]:
|
|
183
|
+
tactic_failed = False
|
|
184
|
+
start_line_num = self.line_num
|
|
185
|
+
for tactic in tactics:
|
|
186
|
+
self.tactic_switch_iterator.set_next_instruction(tactic)
|
|
187
|
+
try:
|
|
188
|
+
self.run_next()
|
|
189
|
+
self.run_state.tatics_ran.append(tactic)
|
|
190
|
+
except Exception as e:
|
|
191
|
+
self.line_num -= 1
|
|
192
|
+
tactic_failed = True
|
|
193
|
+
self.run_state.last_exception = str(e)
|
|
194
|
+
#self.coq.cancel_failed()
|
|
195
|
+
break
|
|
196
|
+
return start_line_num, not tactic_failed
|
|
197
|
+
|
|
198
|
+
def get_last_exception(self) -> typing.Optional[str]:
|
|
199
|
+
last_exception = self.run_state.last_exception
|
|
200
|
+
self.run_state.last_exception = None
|
|
201
|
+
return last_exception
|
|
202
|
+
|
|
203
|
+
def cancel_tactic_till_line(self, tactic_line_num: int) -> bool:
|
|
204
|
+
assert tactic_line_num <= self.line_num, "tactic_line_num must be <= self.line_num"
|
|
205
|
+
assert tactic_line_num >= 0, "tactic_line_num must be >= 0"
|
|
206
|
+
cancelled_some_tactics = False
|
|
207
|
+
# if self.logger is not None:
|
|
208
|
+
# self.logger.info(f"Cancellation called till line {tactic_line_num}, now at line {self.line_num}")
|
|
209
|
+
while self.line_num > tactic_line_num:
|
|
210
|
+
self.coq.cancel_last(force_update_nonfg_goals=True)
|
|
211
|
+
tactic = self.run_state.tatics_ran.pop()
|
|
212
|
+
# if self.logger is not None:
|
|
213
|
+
# self.logger.info(f"Canceling tactic {tactic}")
|
|
214
|
+
self.line_num -= 1
|
|
215
|
+
cancelled_some_tactics = True
|
|
216
|
+
# if cancelled_some_tactics and self.logger is not None:
|
|
217
|
+
# self.logger.info(f"Cancelled till line {tactic_line_num}")
|
|
218
|
+
# elif self.logger is not None:
|
|
219
|
+
# self.logger.info(f"No tactics cancelled")
|
|
220
|
+
return cancelled_some_tactics
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
root_dir = f"{__file__.split('itp_interface')[0]}"
|
|
6
|
+
if root_dir not in sys.path:
|
|
7
|
+
sys.path.append(root_dir)
|
|
8
|
+
import typing
|
|
9
|
+
import os
|
|
10
|
+
import copy
|
|
11
|
+
import enum
|
|
12
|
+
import logging
|
|
13
|
+
from itp_interface.rl.proof_action import ProofAction
|
|
14
|
+
from itp_interface.tools.training_data_format import Goal, TrainingDataFormat
|
|
15
|
+
from itp_interface.tools.isabelle_parse_utils import IsabelleLineByLineReader
|
|
16
|
+
from itp_interface.tools.isabelle_executor import IsabelleExecutor, HammerMode
|
|
17
|
+
from itp_interface.tools.isabelle_context_helper import IsabelleContextHelper
|
|
18
|
+
|
|
19
|
+
class IntertwinedIterator(object):
|
|
20
|
+
def __init__(self, iterator: typing.Optional[typing.Iterator[str]] = None):
|
|
21
|
+
self.base_iterator = iterator
|
|
22
|
+
self.next_instruction: typing.Optional[str] = None
|
|
23
|
+
self.base_iterator_stopped = iterator is None # if the base iterator is None, then it is stopped
|
|
24
|
+
|
|
25
|
+
def set_next_instruction(self, instruction: str):
|
|
26
|
+
assert self.next_instruction is None, "next_instruction must be None"
|
|
27
|
+
assert instruction is not None, "instruction must not be None"
|
|
28
|
+
self.next_instruction = instruction
|
|
29
|
+
|
|
30
|
+
def __iter__(self):
|
|
31
|
+
return self
|
|
32
|
+
|
|
33
|
+
def __next__(self):
|
|
34
|
+
if self.next_instruction is not None:
|
|
35
|
+
# Return the next instruction if it is set
|
|
36
|
+
next_instruction = self.next_instruction
|
|
37
|
+
self.next_instruction = None
|
|
38
|
+
return next_instruction
|
|
39
|
+
# Otherwise, get the next instruction from the base iterator
|
|
40
|
+
if self.base_iterator is not None and not self.base_iterator_stopped:
|
|
41
|
+
try:
|
|
42
|
+
instruction = next(self.base_iterator)
|
|
43
|
+
return instruction
|
|
44
|
+
except StopIteration:
|
|
45
|
+
self.base_iterator_stopped = True
|
|
46
|
+
raise
|
|
47
|
+
else:
|
|
48
|
+
raise StopIteration()
|
|
49
|
+
|
|
50
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
51
|
+
if self.base_iterator is not None:
|
|
52
|
+
self.base_iterator.close()
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
class DynamicProofExecutor(IsabelleExecutor):
|
|
56
|
+
class RunState(object):
|
|
57
|
+
def __init__(self):
|
|
58
|
+
self.tatics_ran = []
|
|
59
|
+
self.last_exception : typing.Optional[str] = None
|
|
60
|
+
self.line_tactic_map = {}
|
|
61
|
+
self.line_proof_context_map = {}
|
|
62
|
+
UnfocussedGoalsDescription = "There are unfocussed goals."
|
|
63
|
+
ProofFinishedDescription = "Proof finished."
|
|
64
|
+
NotInProofModeDescription = "Not in proof mode."
|
|
65
|
+
GoalDescriptionOrder = {
|
|
66
|
+
UnfocussedGoalsDescription: 2, # This more hard
|
|
67
|
+
ProofFinishedDescription: 1, # This is easier coz proof is almost done
|
|
68
|
+
NotInProofModeDescription: 0 # This is the easiest as the proof is done
|
|
69
|
+
}
|
|
70
|
+
class ContextType(enum.Enum):
|
|
71
|
+
NoContext = 0
|
|
72
|
+
LocalContext = 1
|
|
73
|
+
BestContext = 2
|
|
74
|
+
|
|
75
|
+
def goal_description_compare(description1: str, descripton2: str) -> int:
|
|
76
|
+
"""
|
|
77
|
+
Returns 1 if description1 < description2, 0 if description1 == description2, -1 if description1 > description2
|
|
78
|
+
"""
|
|
79
|
+
# In case of no description it is much more harder as we have to do a lot of work
|
|
80
|
+
# So None will have same value as unfocussed goals
|
|
81
|
+
order1 = DynamicProofExecutor.GoalDescriptionOrder.get(description1, 2) if description1 is not None else 2
|
|
82
|
+
order2 = DynamicProofExecutor.GoalDescriptionOrder.get(descripton2, 2) if descripton2 is not None else 2
|
|
83
|
+
if order1 < order2:
|
|
84
|
+
return 1
|
|
85
|
+
elif order1 == order2:
|
|
86
|
+
return 0
|
|
87
|
+
else:
|
|
88
|
+
return -1
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def __init__(self, isabelle_context_helper: IsabelleContextHelper, project_folder: str = None, proof_file: str = None, instruction_iter: typing.Optional[str] = None, use_hammer: HammerMode = HammerMode.AUTO, timeout_in_seconds: int = 60, use_human_readable_proof_context: bool = True, suppress_error_log: bool = True, context_type: ContextType = ContextType.NoContext, port: typing.Optional[int] = None):
|
|
92
|
+
assert proof_file is None or os.path.exists(proof_file), f"Proof file {proof_file} does not exist"
|
|
93
|
+
assert isabelle_context_helper is not None, "isabelle_context_helper must not be None"
|
|
94
|
+
self.proof_file = proof_file
|
|
95
|
+
self.context_type = context_type
|
|
96
|
+
self.isabelle_file_iter = IsabelleLineByLineReader(proof_file).instruction_step_generator() if proof_file is not None else instruction_iter
|
|
97
|
+
self.tactic_switch_iterator = IntertwinedIterator(self.isabelle_file_iter)
|
|
98
|
+
self.run_state = DynamicProofExecutor.RunState()
|
|
99
|
+
self.logger = None
|
|
100
|
+
self.isabelle_context_helper = isabelle_context_helper
|
|
101
|
+
super().__init__(project_root=project_folder, main_file=proof_file, proof_step_iter=self.tactic_switch_iterator, use_hammer=use_hammer, timeout_in_sec=timeout_in_seconds, use_human_readable_proof_context=use_human_readable_proof_context, suppress_error_log=suppress_error_log, port=port)
|
|
102
|
+
|
|
103
|
+
def __enter__(self):
|
|
104
|
+
self.isabelle_context_helper.__enter__()
|
|
105
|
+
return super().__enter__()
|
|
106
|
+
|
|
107
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
108
|
+
self.isabelle_context_helper.__exit__(exc_type, exc_val, exc_tb)
|
|
109
|
+
super().__exit__(exc_type, exc_val, exc_tb)
|
|
110
|
+
|
|
111
|
+
def set_logger(self, logger: logging.Logger):
|
|
112
|
+
self.logger = logger
|
|
113
|
+
pass
|
|
114
|
+
|
|
115
|
+
def get_focussed_goals(self) -> typing.List[Goal]:
|
|
116
|
+
if not self.is_in_proof_mode():
|
|
117
|
+
return []
|
|
118
|
+
return self.isabelle_context_helper.get_focussed_goals(self)
|
|
119
|
+
|
|
120
|
+
def get_unfocussed_goals(self) -> typing.List[Goal]:
|
|
121
|
+
if not self.is_in_proof_mode():
|
|
122
|
+
return []
|
|
123
|
+
return self.isabelle_context_helper.get_unfocussed_goals(self)
|
|
124
|
+
|
|
125
|
+
def get_current_proof_state_as_training_data(self) -> TrainingDataFormat:
|
|
126
|
+
# get the current goal
|
|
127
|
+
if self.needs_cut_close():
|
|
128
|
+
current_goals = self.get_unfocussed_goals()
|
|
129
|
+
training_data_format = TrainingDataFormat(start_goals=current_goals)
|
|
130
|
+
training_data_format.goal_description = DynamicProofExecutor.UnfocussedGoalsDescription
|
|
131
|
+
elif not self.is_in_proof_mode():
|
|
132
|
+
current_goals = self.get_focussed_goals()
|
|
133
|
+
training_data_format = TrainingDataFormat(start_goals=current_goals)
|
|
134
|
+
training_data_format.goal_description = DynamicProofExecutor.NotInProofModeDescription
|
|
135
|
+
elif self.needs_qed():
|
|
136
|
+
current_goals = self.get_focussed_goals()
|
|
137
|
+
assert len(current_goals) == 0, "There should be no goals when needs_qed is True"
|
|
138
|
+
training_data_format = TrainingDataFormat(start_goals=current_goals)
|
|
139
|
+
training_data_format.goal_description = DynamicProofExecutor.ProofFinishedDescription
|
|
140
|
+
else:
|
|
141
|
+
current_goals = self.get_focussed_goals()
|
|
142
|
+
training_data_format = TrainingDataFormat(start_goals=current_goals)
|
|
143
|
+
training_data_format.goal_description = None
|
|
144
|
+
return training_data_format
|
|
145
|
+
|
|
146
|
+
def get_all_relevant_thms(self, should_print_symbol: bool = False) -> TrainingDataFormat:
|
|
147
|
+
training_data_format = self.get_current_proof_state_as_training_data()
|
|
148
|
+
self.isabelle_context_helper.set_all_type_matched_query_result(training_data_format, self, self.logger)
|
|
149
|
+
return training_data_format
|
|
150
|
+
|
|
151
|
+
def get_all_relevant_thms_within_local_context(self) -> TrainingDataFormat:
|
|
152
|
+
training_data_format = self.get_current_proof_state_as_training_data()
|
|
153
|
+
self.isabelle_context_helper.set_local_thms_dfns(training_data_format, self, self.logger)
|
|
154
|
+
return training_data_format
|
|
155
|
+
|
|
156
|
+
def get_all_relevant_defns(self) -> TrainingDataFormat:
|
|
157
|
+
training_data_format = self.get_current_proof_state_as_training_data()
|
|
158
|
+
self.isabelle_context_helper.set_relevant_defns_in_training_data_point(training_data_format, self, self.logger)
|
|
159
|
+
return training_data_format
|
|
160
|
+
|
|
161
|
+
def get_all_relevant_defns_and_thms(self, should_print_symbol: bool = False, only_local: bool = False, only_proof_state: bool = False) -> TrainingDataFormat:
|
|
162
|
+
training_data_format = self.get_current_proof_state_as_training_data()
|
|
163
|
+
# self.isabelle_context_helper.set_relevant_defns_in_training_data_point(training_data_format, self, self.logger)
|
|
164
|
+
if not only_proof_state:
|
|
165
|
+
self.isabelle_context_helper.set_all_type_matched_query_result(training_data_format, self, self.logger)
|
|
166
|
+
return training_data_format
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def run_cmds(self, cmds: typing.List[str], raise_exception=False) -> typing.Tuple[int, bool]:
|
|
170
|
+
cmd_failed = False
|
|
171
|
+
start_line_num = self.line_num
|
|
172
|
+
for cmd in cmds:
|
|
173
|
+
self.tactic_switch_iterator.set_next_instruction(cmd)
|
|
174
|
+
try:
|
|
175
|
+
self.run_next()
|
|
176
|
+
except Exception:
|
|
177
|
+
self.line_num -= 1
|
|
178
|
+
cmd_failed = True
|
|
179
|
+
if raise_exception:
|
|
180
|
+
raise
|
|
181
|
+
else:
|
|
182
|
+
break
|
|
183
|
+
return start_line_num, not cmd_failed
|
|
184
|
+
|
|
185
|
+
def run_tactics(self, tactics: typing.List[str]) -> typing.Tuple[int, bool]:
|
|
186
|
+
tactic_failed = False
|
|
187
|
+
start_line_num = self.line_num
|
|
188
|
+
self.run_state.line_tactic_map[self.line_num] = len(self.run_state.tatics_ran)
|
|
189
|
+
self.run_state.line_proof_context_map[self.line_num] = copy.deepcopy(self.proof_context)
|
|
190
|
+
for idx, tactic in enumerate(tactics):
|
|
191
|
+
self.tactic_switch_iterator.set_next_instruction(tactic)
|
|
192
|
+
try:
|
|
193
|
+
actual_tactic = self.run_next()
|
|
194
|
+
tactics[idx] = actual_tactic
|
|
195
|
+
self.run_state.tatics_ran.append(actual_tactic)
|
|
196
|
+
self.run_state.line_proof_context_map[self.line_num] = copy.deepcopy(self.proof_context)
|
|
197
|
+
except Exception as e:
|
|
198
|
+
self.line_num -= 1
|
|
199
|
+
tactic_failed = True
|
|
200
|
+
self.run_state.last_exception = str(e)
|
|
201
|
+
break
|
|
202
|
+
return start_line_num, not tactic_failed
|
|
203
|
+
|
|
204
|
+
def get_last_exception(self) -> typing.Optional[str]:
|
|
205
|
+
last_exception = self.run_state.last_exception
|
|
206
|
+
self.run_state.last_exception = None
|
|
207
|
+
return last_exception
|
|
208
|
+
|
|
209
|
+
def cancel_tactic_till_line(self, tactic_line_num: int) -> bool:
|
|
210
|
+
assert tactic_line_num <= self.line_num, "tactic_line_num must be <= self.line_num"
|
|
211
|
+
assert tactic_line_num >= 0, "tactic_line_num must be >= 0"
|
|
212
|
+
cancelled_some_tactics = False
|
|
213
|
+
if tactic_line_num < self.line_num:
|
|
214
|
+
state_num = self.run_state.line_tactic_map[tactic_line_num]
|
|
215
|
+
self.run_state.tatics_ran = self.run_state.tatics_ran[:state_num]
|
|
216
|
+
self.proof_context = self.run_state.line_proof_context_map[tactic_line_num]
|
|
217
|
+
line_tactic_map_keys = list(self.run_state.line_tactic_map.keys())
|
|
218
|
+
for line_num in line_tactic_map_keys:
|
|
219
|
+
if line_num >= tactic_line_num:
|
|
220
|
+
del self.run_state.line_tactic_map[line_num]
|
|
221
|
+
line_proof_context_map_keys = list(self.run_state.line_proof_context_map.keys())
|
|
222
|
+
for line_num in line_proof_context_map_keys:
|
|
223
|
+
if line_num >= tactic_line_num:
|
|
224
|
+
del self.run_state.line_proof_context_map[line_num]
|
|
225
|
+
self.line_num = tactic_line_num
|
|
226
|
+
assert self.line_num_to_state[self.line_num] is not None, "Nonexistent state found on line " + str(self.line_num)
|
|
227
|
+
self.current_state = self.line_num_to_state[self.line_num]
|
|
228
|
+
cancelled_some_tactics = True
|
|
229
|
+
return cancelled_some_tactics
|