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,95 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This is adapted from contents in Dominique Unruh's package scala-isabelle
|
|
3
|
+
The package can be found on github at https://github.com/dominique-unruh/scala-isabelle
|
|
4
|
+
This particular file is adapted from https://github.com/dominique-unruh/scala-isabelle/blob/master/src/test/scala/de/unruh/isabelle/experiments/TheoryManager.scala
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
package pisa.utils
|
|
8
|
+
|
|
9
|
+
import java.nio.file.{Path, Paths}
|
|
10
|
+
// import scala.concurrent.ExecutionContext
|
|
11
|
+
import de.unruh.isabelle.control.{Isabelle, OperationCollection}
|
|
12
|
+
import de.unruh.isabelle.mlvalue.MLValue.{compileFunction, compileFunction0}
|
|
13
|
+
import de.unruh.isabelle.pure.{Position, Theory, TheoryHeader, ToplevelState}
|
|
14
|
+
import de.unruh.isabelle.mlvalue.{MLFunction, MLFunction0, MLFunction2, MLFunction3}
|
|
15
|
+
import pisa.utils.TheoryManager.{Heap, Source, Text}
|
|
16
|
+
import pisa.server.Transition
|
|
17
|
+
import TheoryManager.Ops
|
|
18
|
+
|
|
19
|
+
// Implicits
|
|
20
|
+
import de.unruh.isabelle.mlvalue.Implicits._
|
|
21
|
+
import de.unruh.isabelle.pure.Implicits._
|
|
22
|
+
import scala.concurrent.ExecutionContext.Implicits.global
|
|
23
|
+
|
|
24
|
+
class TheoryManager(var path_to_isa_bin: String, var wd : String) {
|
|
25
|
+
val setup: Isabelle.Setup = Isabelle.Setup(isabelleHome = Path.of(path_to_isa_bin),
|
|
26
|
+
sessionRoots = Nil,
|
|
27
|
+
userDir = None,
|
|
28
|
+
logic = "HOL",
|
|
29
|
+
workingDirectory = Path.of(wd),
|
|
30
|
+
build=false
|
|
31
|
+
)
|
|
32
|
+
implicit val isabelle: Isabelle = new Isabelle(setup)
|
|
33
|
+
|
|
34
|
+
val command_exception: MLFunction3[Boolean, Transition.T, ToplevelState, ToplevelState] =
|
|
35
|
+
compileFunction[Boolean, Transition.T, ToplevelState, ToplevelState](
|
|
36
|
+
"fn (int, tr, st) => Toplevel.command_exception int tr st")
|
|
37
|
+
val init_toplevel: MLFunction0[ToplevelState] = compileFunction0[ToplevelState]("Toplevel.init_toplevel")
|
|
38
|
+
val parse_text: MLFunction2[Theory, String, List[(Transition.T, String)]] =
|
|
39
|
+
compileFunction[Theory, String, List[(Transition.T, String)]](
|
|
40
|
+
"""fn (thy, text) => let
|
|
41
|
+
| val transitions = Outer_Syntax.parse_text thy (K thy) Position.start text
|
|
42
|
+
| fun addtext symbols [tr] =
|
|
43
|
+
| [(tr, implode symbols)]
|
|
44
|
+
| | addtext _ [] = []
|
|
45
|
+
| | addtext symbols (tr::nextTr::trs) = let
|
|
46
|
+
| val (this,rest) = Library.chop (Position.distance_of (Toplevel.pos_of tr, Toplevel.pos_of nextTr) |> Option.valOf) symbols
|
|
47
|
+
| in (tr, implode this) :: addtext rest (nextTr::trs) end
|
|
48
|
+
| in addtext (Symbol.explode text) transitions end""".stripMargin)
|
|
49
|
+
val toplevel_end_theory: MLFunction[ToplevelState, Theory] = compileFunction[ToplevelState, Theory]("Toplevel.end_theory Position.none")
|
|
50
|
+
|
|
51
|
+
def getTheorySource(name: String): Source = Heap(name)
|
|
52
|
+
def getTheory(source: Source)(implicit isabelle: Isabelle): Theory = source match {
|
|
53
|
+
case Heap(name) => Theory(name)
|
|
54
|
+
case Text(text, path, position) =>
|
|
55
|
+
var toplevel = init_toplevel().force.retrieveNow
|
|
56
|
+
var thy0 = beginTheory(source)
|
|
57
|
+
for ((transition, text) <- parse_text(thy0, text).force.retrieveNow) {
|
|
58
|
+
toplevel = command_exception(true, transition, toplevel).retrieveNow.force
|
|
59
|
+
}
|
|
60
|
+
toplevel_end_theory(toplevel).retrieveNow.force
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
def beginTheory(source: Source)(implicit isabelle: Isabelle): Theory = {
|
|
64
|
+
val header = getHeader(source)
|
|
65
|
+
val masterDir = source.path.getParent
|
|
66
|
+
// println(masterDir, header, header.imports.map(getTheorySource).map(getTheory))
|
|
67
|
+
Ops.begin_theory(masterDir, header, header.imports.map(getTheorySource).map(getTheory)).retrieveNow
|
|
68
|
+
}
|
|
69
|
+
def getHeader(source: Source)(implicit isabelle: Isabelle): TheoryHeader = source match {
|
|
70
|
+
case Text(text, path, position) => Ops.header_read(text, position).retrieveNow
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
object TheoryManager extends OperationCollection {
|
|
75
|
+
trait Source { def path : Path }
|
|
76
|
+
case class Heap(name: String) extends Source {
|
|
77
|
+
override def path: Path = Paths.get("INVALID")
|
|
78
|
+
}
|
|
79
|
+
case class File(path: Path) extends Source
|
|
80
|
+
case class Text(text: String, path: Path, position: Position) extends Source
|
|
81
|
+
object Text {
|
|
82
|
+
def apply(text: String, path: Path)(implicit isabelle: Isabelle): Text = new Text(text, path, Position.none)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//noinspection TypeAnnotation
|
|
86
|
+
protected final class Ops(implicit isabelle: Isabelle) {
|
|
87
|
+
val header_read = compileFunction[String, Position, TheoryHeader]("fn (text,pos) => Thy_Header.read pos text")
|
|
88
|
+
val begin_theory = compileFunction[Path, TheoryHeader, List[Theory], Theory](
|
|
89
|
+
"fn (path, header, parents) => Resources.begin_theory path header parents")
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
override protected def newOps(implicit isabelle: Isabelle, ec: scala.concurrent.ExecutionContext) = {
|
|
93
|
+
new this.Ops
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
state_only_total_ground_truth_length = 0
|
|
5
|
+
proof_and_state_total_ground_truth_length = 0
|
|
6
|
+
state_only_proved = 0
|
|
7
|
+
state_only_matched = 0
|
|
8
|
+
proof_state_proved = 0
|
|
9
|
+
proof_state_matched = 0
|
|
10
|
+
|
|
11
|
+
total_one_liners = 0
|
|
12
|
+
for file_name in os.listdir("debug"):
|
|
13
|
+
if file_name.startswith("debug"):
|
|
14
|
+
file_content = open(os.path.join("debug", file_name)).readlines()
|
|
15
|
+
ground_truth_length = int(file_content[0].strip("\n").split(" ")[-2])
|
|
16
|
+
if ground_truth_length == 1:
|
|
17
|
+
total_one_liners += 1
|
|
18
|
+
if file_content[1].strip("\n").split(" ")[-2].startswith("t"):
|
|
19
|
+
state_only_proved += 1
|
|
20
|
+
state_only_matched += int(file_content[2].strip("\n").split(" ")[-2])
|
|
21
|
+
state_only_total_ground_truth_length += ground_truth_length
|
|
22
|
+
if file_content[3].strip("\n").split(" ")[-2].startswith("t"):
|
|
23
|
+
proof_state_proved += 1
|
|
24
|
+
proof_state_matched += int(file_content[4].strip("\n").split(" ")[-2])
|
|
25
|
+
proof_and_state_total_ground_truth_length += ground_truth_length
|
|
26
|
+
|
|
27
|
+
print("State only proved: {}".format(state_only_proved))
|
|
28
|
+
print("State only matched: {}".format(state_only_matched))
|
|
29
|
+
print("State only ground truth length: {}".format(state_only_total_ground_truth_length))
|
|
30
|
+
print("Proof and state proved: {}".format(proof_state_proved))
|
|
31
|
+
print("Proof and state matched: {}".format(proof_state_matched))
|
|
32
|
+
print("Proof and state ground truth length: {}".format(proof_and_state_total_ground_truth_length))
|
|
33
|
+
print("Total one liners: {}".format(total_one_liners))
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import json
|
|
4
|
+
import random
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
random.seed(0)
|
|
9
|
+
|
|
10
|
+
if sys.argv[1] == "state":
|
|
11
|
+
state_only = True
|
|
12
|
+
elif sys.argv[1] == "proof_state":
|
|
13
|
+
state_only = False
|
|
14
|
+
else:
|
|
15
|
+
raise NotImplementedError
|
|
16
|
+
|
|
17
|
+
if state_only:
|
|
18
|
+
path_to_dir = "data/seq2seq/seq2seq_with_state"
|
|
19
|
+
output_dir = "debug/with_state"
|
|
20
|
+
else:
|
|
21
|
+
path_to_dir = "data/seq2seq/seq2seq_with_proof_and_state"
|
|
22
|
+
output_dir = "debug/with_proof_and_state"
|
|
23
|
+
|
|
24
|
+
line_index_to_pair = dict()
|
|
25
|
+
with open(os.path.join(path_to_dir, "test.src")) as f1, open(os.path.join(path_to_dir, "test.tgt")) as f2:
|
|
26
|
+
src_lines = list(f1.readlines())
|
|
27
|
+
tgt_lines = list(f2.readlines())
|
|
28
|
+
for i in range(len(src_lines)):
|
|
29
|
+
src = src_lines[i].rstrip("\n")
|
|
30
|
+
tgt = tgt_lines[i].rstrip("\n")
|
|
31
|
+
line_index_to_pair[i] = (src, tgt)
|
|
32
|
+
|
|
33
|
+
problem_index_to_line_indices = dict()
|
|
34
|
+
with open("debug/good_indices.txt") as fin:
|
|
35
|
+
for line in fin.readlines():
|
|
36
|
+
line = line.rstrip("\n")
|
|
37
|
+
problem_index, line_index = line.split("|")
|
|
38
|
+
problem_index = int(problem_index.strip())
|
|
39
|
+
line_index = int(line_index.strip())
|
|
40
|
+
|
|
41
|
+
if problem_index not in problem_index_to_line_indices:
|
|
42
|
+
problem_index_to_line_indices[problem_index] = [line_index]
|
|
43
|
+
else:
|
|
44
|
+
problem_index_to_line_indices[problem_index].append(line_index)
|
|
45
|
+
|
|
46
|
+
for problem_index in range(300):
|
|
47
|
+
line_indices = problem_index_to_line_indices[problem_index]
|
|
48
|
+
line_indices = sorted(line_indices)
|
|
49
|
+
with open(os.path.join(output_dir, "{}_pairs.txt".format(problem_index)), "w") as fout:
|
|
50
|
+
for line_index in line_indices:
|
|
51
|
+
pair = line_index_to_pair[line_index]
|
|
52
|
+
fout.write("{} <SEP> {}".format(pair[0], pair[1]))
|
|
53
|
+
fout.write("\n")
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
path_to_dir = "data/seq2seq/seq2seq_with_proof_and_state"
|
|
7
|
+
|
|
8
|
+
ground_truth_dictionary = {}
|
|
9
|
+
with open(os.path.join(path_to_dir, "test.src")) as f1, open(os.path.join(path_to_dir, "test.tgt")) as f2:
|
|
10
|
+
src_lines = list(f1.readlines())
|
|
11
|
+
tgt_lines = list(f2.readlines())
|
|
12
|
+
for i in range(len(src_lines)):
|
|
13
|
+
src = src_lines[i].rstrip("\n")
|
|
14
|
+
tgt = tgt_lines[i].rstrip("\n")
|
|
15
|
+
ground_truth_dictionary[src] = i
|
|
16
|
+
|
|
17
|
+
good_ones = set()
|
|
18
|
+
for file_name in os.listdir("universal_test_theorems"):
|
|
19
|
+
problem_index = int(file_name.split("_")[-1].split(".")[0])
|
|
20
|
+
if file_name.startswith("quick"):
|
|
21
|
+
file_content = json.load(open(os.path.join("universal_test_theorems", file_name)))
|
|
22
|
+
theorem_declaration = file_content[0][1]
|
|
23
|
+
for key in ground_truth_dictionary:
|
|
24
|
+
if theorem_declaration in key:
|
|
25
|
+
good_ones.add((problem_index, ground_truth_dictionary[key]))
|
|
26
|
+
|
|
27
|
+
with open("debug/good_indices.txt", "w") as fout:
|
|
28
|
+
for good_index in good_ones:
|
|
29
|
+
# Problem index, line index
|
|
30
|
+
fout.write("{} | {}".format(good_index[0], good_index[1]))
|
|
31
|
+
fout.write("\n")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
target_directory = sys.argv[1]
|
|
4
|
+
|
|
5
|
+
test_sentences = []
|
|
6
|
+
with open("data/seq2seq/seq2seq_with_state/test.tgt") as fhand:
|
|
7
|
+
for line in fhand.readlines():
|
|
8
|
+
test_sentences.append(line.strip().rstrip("\n"))
|
|
9
|
+
test_sentences = set(test_sentences)
|
|
10
|
+
|
|
11
|
+
succ_proofs = 0
|
|
12
|
+
originality = 0
|
|
13
|
+
for file_name in os.listdir(target_directory):
|
|
14
|
+
if file_name.startswith("succ"):
|
|
15
|
+
succ_proofs += 1
|
|
16
|
+
with open(os.path.join(target_directory, file_name)) as fhand:
|
|
17
|
+
ground_truth_lines = 0
|
|
18
|
+
total_lines = fhand.readlines()
|
|
19
|
+
for line in total_lines:
|
|
20
|
+
line = line.strip().rstrip("\n")
|
|
21
|
+
if line in test_sentences:
|
|
22
|
+
ground_truth_lines += 1
|
|
23
|
+
originality += ground_truth_lines / len(total_lines)
|
|
24
|
+
print("Originality: {}".format(1-originality/succ_proofs))
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import glob
|
|
2
|
+
import os
|
|
3
|
+
import shutil
|
|
4
|
+
|
|
5
|
+
number_of_processes = input("Enter the number of processes you want to run at the same time:\n").strip()
|
|
6
|
+
number_of_processes = int(number_of_processes)
|
|
7
|
+
|
|
8
|
+
script = 'echo "y" | sbt "test:runMain pisa.TransparentComparison {}"'
|
|
9
|
+
|
|
10
|
+
total_cmds = list()
|
|
11
|
+
pattern = "/home/ywu/PISA/universal_test_theorems/quick_test_name_*.json"
|
|
12
|
+
|
|
13
|
+
for file_name in glob.glob(pattern, recursive=True):
|
|
14
|
+
total_cmds.append(script.format(file_name))
|
|
15
|
+
|
|
16
|
+
process_number_to_cmds = {i: [] for i in range(number_of_processes)}
|
|
17
|
+
for i, cmd in enumerate(total_cmds):
|
|
18
|
+
process_number_to_cmds[i%number_of_processes].append(cmd)
|
|
19
|
+
|
|
20
|
+
for process_number, process_cmds in process_number_to_cmds.items():
|
|
21
|
+
with open("scripts/test_search_{}.sh".format(process_number), "w") as f:
|
|
22
|
+
for process_cmd in process_cmds:
|
|
23
|
+
f.write(process_cmd+"\n")
|
|
24
|
+
f.write("PIDmain=$!\n")
|
|
25
|
+
f.write("wait $PIDmain\n")
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import json
|
|
4
|
+
import random
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
|
|
7
|
+
random.seed(0)
|
|
8
|
+
|
|
9
|
+
if sys.argv[1] == "state":
|
|
10
|
+
state_only = True
|
|
11
|
+
elif sys.argv[1] == "proof_state":
|
|
12
|
+
state_only = False
|
|
13
|
+
else:
|
|
14
|
+
raise NotImplementedError
|
|
15
|
+
|
|
16
|
+
final_line = " PROOFSTEP\", \"best_of\": 1, \"temperature\": 0, \"max_tokens\": 128, \"n\": 1}'"
|
|
17
|
+
if state_only:
|
|
18
|
+
path_to_dir = "pisa_seq2seq/state_only"
|
|
19
|
+
preceding_line = """curl https://api.openai.com/v1/engines/formal-small-isabelle-v6-c4/completions -H 'Content-Type: application/json' -H 'Authorization: Bearer <OPENAI_TOKEN>' -d '{\"prompt\": \""""
|
|
20
|
+
|
|
21
|
+
else:
|
|
22
|
+
path_to_dir = "pisa_seq2seq/proof_and_state"
|
|
23
|
+
preceding_line = """curl https://api.openai.com/v1/engines/formal-small-isabelle-wproof-v1-c4/completions -H 'Content-Type: application/json' -H 'Authorization: Bearer <OPENAI_TOKEN>' -d '{\"prompt\": \""""
|
|
24
|
+
|
|
25
|
+
ground_truth_dictionary = {}
|
|
26
|
+
|
|
27
|
+
with open(os.path.join(path_to_dir, "val.src")) as f1, open(os.path.join(path_to_dir, "val.tgt")) as f2:
|
|
28
|
+
src_lines = list(f1.readlines())
|
|
29
|
+
tgt_lines = list(f2.readlines())
|
|
30
|
+
for i in range(len(src_lines)):
|
|
31
|
+
src = src_lines[i].rstrip("\n")
|
|
32
|
+
tgt = tgt_lines[i].rstrip("\n")
|
|
33
|
+
ground_truth_dictionary[src] = tgt
|
|
34
|
+
# print(src)
|
|
35
|
+
# print(tgt)
|
|
36
|
+
# break
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def preprocess(cmd, state_only):
|
|
40
|
+
if state_only:
|
|
41
|
+
returned_cmd = cmd.replace("State:", "[IS] GOAL").replace("\\", "\\\\").replace("\n", "\\n")\
|
|
42
|
+
.replace("\"", "\\\"").replace("\'", "\\u0027")
|
|
43
|
+
else:
|
|
44
|
+
returned_cmd = cmd.replace("Proof:", "[IS] PROOF").replace("State:", "[IS] GOAL").replace("\\", "\\\\")\
|
|
45
|
+
.replace("\n", "\\n") \
|
|
46
|
+
.replace("\"", "\\\"").replace("\'", "\\u0027")
|
|
47
|
+
return returned_cmd
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
random_keys = list(ground_truth_dictionary.keys())
|
|
51
|
+
random.shuffle(random_keys)
|
|
52
|
+
correct = 0
|
|
53
|
+
for src_line in tqdm(random_keys[:1000]):
|
|
54
|
+
cmd = preprocess(src_line, state_only)
|
|
55
|
+
cmd = preceding_line + cmd + final_line
|
|
56
|
+
# print(cmd)
|
|
57
|
+
stream = os.popen(cmd)
|
|
58
|
+
output = stream.read().rstrip("\n")
|
|
59
|
+
try:
|
|
60
|
+
text = json.loads(output)["choices"][0]["text"].strip()
|
|
61
|
+
# print(text)
|
|
62
|
+
# print(text)
|
|
63
|
+
# print(ground_truth_dictionary[src_line])
|
|
64
|
+
# print(text == ground_truth_dictionary[src_line])
|
|
65
|
+
if text == ground_truth_dictionary[src_line]:
|
|
66
|
+
correct += 1
|
|
67
|
+
except Exception as e:
|
|
68
|
+
print(e)
|
|
69
|
+
|
|
70
|
+
print(correct/1000)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package pisa
|
|
2
|
+
|
|
3
|
+
import de.unruh.isabelle.control.Isabelle
|
|
4
|
+
import de.unruh.isabelle.pure.Theory
|
|
5
|
+
|
|
6
|
+
import java.nio.file.Path
|
|
7
|
+
import scala.concurrent.ExecutionContext
|
|
8
|
+
|
|
9
|
+
object Easy {
|
|
10
|
+
implicit val ec: ExecutionContext = ExecutionContext.global
|
|
11
|
+
val path_to_isa_bin: String = "/Applications/Isabelle2020.app/Isabelle"
|
|
12
|
+
val setup: Isabelle.Setup = Isabelle.Setup(
|
|
13
|
+
isabelleHome = Path.of(path_to_isa_bin),
|
|
14
|
+
sessionRoots = Seq(Path.of("/Users/qj213/Projects/afp-2021-02-11/thys")),
|
|
15
|
+
userDir = None,
|
|
16
|
+
logic = "Functional-Automata",
|
|
17
|
+
workingDirectory = Path.of("/Users/qj213/Projects/afp-2021-02-11/thys"),
|
|
18
|
+
build = false
|
|
19
|
+
)
|
|
20
|
+
implicit val isabelle: Isabelle = new Isabelle(setup)
|
|
21
|
+
|
|
22
|
+
def main(args: Array[String]): Unit = {
|
|
23
|
+
// Theory("Functional-Automata.RegExp2NA").force.await
|
|
24
|
+
Theory("Abstract-Rewriting.Seq").force.await
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
package pisa
|
|
2
|
+
|
|
3
|
+
import net.liftweb.json._
|
|
4
|
+
|
|
5
|
+
import scala.collection.mutable.ListBuffer
|
|
6
|
+
import scala.sys.process._
|
|
7
|
+
import scala.io.Source
|
|
8
|
+
|
|
9
|
+
case class GetText(text: String)
|
|
10
|
+
|
|
11
|
+
object TestCurl {
|
|
12
|
+
implicit val formats : DefaultFormats = DefaultFormats
|
|
13
|
+
def preprocess(cmd : String, state_only : Boolean): String = {
|
|
14
|
+
if (state_only) {
|
|
15
|
+
cmd.trim.replace("State:", "[IS] GOAL").replace("\\", "\\\\").replace("\n", "\\n")
|
|
16
|
+
.replace("\"", "\\\"").replace("\'", "\\u0027")
|
|
17
|
+
} else {
|
|
18
|
+
cmd.replace("Proof:", "[IS] PROOF").replace("State:", "[IS] GOAL").replace("\\", "\\\\")
|
|
19
|
+
.replace("\n", "\\n").replace("\"", "\\\"").replace("\'", "\\u0027")
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
def main(args: Array[String]): Unit = {
|
|
24
|
+
val state_only : Boolean = {
|
|
25
|
+
if (args(0).startsWith("state")) true
|
|
26
|
+
else false
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
val path_to_dir : String = {
|
|
30
|
+
if (state_only) "pisa_seq2seq/state_only"
|
|
31
|
+
else "pisa_seq2seq/proof_and_state"
|
|
32
|
+
}
|
|
33
|
+
val preceding_line : String = {
|
|
34
|
+
if (state_only) "curl https://api.openai.com/v1/engines/formal-small-isabelle-v6-c4/completions -H 'Content-Type: application/json' -H 'Authorization: Bearer <OPENAI_TOKEN>' -d '{\"prompt\": \""
|
|
35
|
+
else "curl https://api.openai.com/v1/engines/formal-small-isabelle-wproof-v1-c4/completions -H 'Content-Type: application/json' -H 'Authorization: Bearer <OPENAI_TOKEN>' -d '{\"prompt\": \""
|
|
36
|
+
}
|
|
37
|
+
val final_line = " PROOFSTEP\", \"best_of\": 1, \"temperature\": 0.1, \"max_tokens\": 128, \"n\": 1}'"
|
|
38
|
+
|
|
39
|
+
val src_name : String = path_to_dir + "/" + "val.src"
|
|
40
|
+
val tgt_name : String = path_to_dir + "/" + "val.tgt"
|
|
41
|
+
|
|
42
|
+
val src_open = Source.fromFile(src_name)
|
|
43
|
+
val src_list : List[String] = src_open.getLines.toList
|
|
44
|
+
src_open.close
|
|
45
|
+
val tgt_open = Source.fromFile(tgt_name)
|
|
46
|
+
val tgt_list : List[String] = tgt_open.getLines.toList
|
|
47
|
+
tgt_open.close
|
|
48
|
+
|
|
49
|
+
var src2tgt : Map[String, ListBuffer[String]] = Map()
|
|
50
|
+
for (i <- List.range(0, src_list.length)) {
|
|
51
|
+
val src : String = src_list(i)
|
|
52
|
+
if (src2tgt.contains(src)) {
|
|
53
|
+
var tgt_old_list : ListBuffer[String] = src2tgt(src)
|
|
54
|
+
tgt_old_list += tgt_list(i)
|
|
55
|
+
src2tgt += (src -> tgt_old_list)
|
|
56
|
+
} else {
|
|
57
|
+
src2tgt += (src_list(i) -> ListBuffer(tgt_list(i)))
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
val src_keys = src2tgt.keys.toList.take(1000)
|
|
62
|
+
|
|
63
|
+
var correct = 0
|
|
64
|
+
for (key <- src_keys) {
|
|
65
|
+
val test_value = src2tgt(key)
|
|
66
|
+
val test_str = preceding_line + preprocess(key, state_only) + final_line
|
|
67
|
+
// println(test_str)
|
|
68
|
+
|
|
69
|
+
val returned_str = test_str.!!
|
|
70
|
+
if (returned_str.contains("error")) {}
|
|
71
|
+
else {
|
|
72
|
+
val parsed_value = (parse(returned_str) \ "choices")(0).extract[GetText].text.trim
|
|
73
|
+
|
|
74
|
+
if (test_value.contains(parsed_value)) {
|
|
75
|
+
correct += 1
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
println(correct/1000.0)
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package pisa
|
|
2
|
+
|
|
3
|
+
import de.unruh.isabelle.control.Isabelle
|
|
4
|
+
|
|
5
|
+
import java.nio.file.Path
|
|
6
|
+
|
|
7
|
+
object TestIsa {
|
|
8
|
+
val setup: Isabelle.Setup = Isabelle.Setup(isabelleHome = Path.of("/Applications/Isabelle2020.app/Isabelle"),
|
|
9
|
+
sessionRoots = Nil,
|
|
10
|
+
userDir = None,
|
|
11
|
+
logic = "HOL",
|
|
12
|
+
workingDirectory = Path.of("./"),
|
|
13
|
+
build = false
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
implicit val isabelle: Isabelle = new Isabelle(setup)
|
|
17
|
+
|
|
18
|
+
println("Initialised isabelle")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def main(args: Array[String]): Unit = {
|
|
22
|
+
Thread.sleep(10000)
|
|
23
|
+
isabelle.destroy()
|
|
24
|
+
println("Destroyed isabelle")
|
|
25
|
+
Thread.sleep(100000)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
sbt "runMain pisa.server.PisaServer" &
|
|
2
|
+
PIDmain=$!
|
|
3
|
+
sleep 12
|
|
4
|
+
python src/main/python/extract_and_load_problems.py --json-path first_stage_output/Functional-Automata/Automata.json --isa-path /home/ywu/Isabelle2020 --afp /home/ywu/afp-2021-02-11 --saving-directory second_stage_output &
|
|
5
|
+
PID0=$!
|
|
6
|
+
python src/main/python/extract_and_load_problems.py --json-path first_stage_output/Functional-Automata/MaxChop.json --isa-path /home/ywu/Isabelle2020 --afp /home/ywu/afp-2021-02-11 --saving-directory second_stage_output &
|
|
7
|
+
PID1=$!
|
|
8
|
+
python src/main/python/extract_and_load_problems.py --json-path first_stage_output/Functional-Automata/DA.json --isa-path /home/ywu/Isabelle2020 --afp /home/ywu/afp-2021-02-11 --saving-directory second_stage_output &
|
|
9
|
+
PID2=$!
|
|
10
|
+
python src/main/python/extract_and_load_problems.py --json-path first_stage_output/Functional-Automata/RegExp2NA.json --isa-path /home/ywu/Isabelle2020 --afp /home/ywu/afp-2021-02-11 --saving-directory second_stage_output &
|
|
11
|
+
PID3=$!
|
|
12
|
+
wait $PID0
|
|
13
|
+
wait $PID1
|
|
14
|
+
wait $PID2
|
|
15
|
+
wait $PID3
|
|
16
|
+
ps aux |grep scala |awk '{print $2}' |xargs kill
|
|
17
|
+
ps aux |grep java |awk '{print $2}' |xargs kill
|
|
18
|
+
ps aux |grep poly |awk '{print $2}' |xargs kill
|
|
19
|
+
ps aux | grep "bash sbt" | awk '{print $2}' | xargs kill
|
|
Binary file
|
|
@@ -0,0 +1,78 @@
|
|
|
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 os
|
|
8
|
+
import subprocess
|
|
9
|
+
import yaml
|
|
10
|
+
import random
|
|
11
|
+
from multiprocessing import Pool
|
|
12
|
+
from itp_interface.repo.clone import RepoCloner
|
|
13
|
+
|
|
14
|
+
class RepoBuilder:
|
|
15
|
+
def __init__(self, folder, disable_build=False):
|
|
16
|
+
self.folder = folder
|
|
17
|
+
self.folder = os.path.abspath(self.folder)
|
|
18
|
+
self.disable_build = disable_build
|
|
19
|
+
self._check_git_installed()
|
|
20
|
+
self.cloner = RepoCloner(folder)
|
|
21
|
+
|
|
22
|
+
def _check_git_installed(self):
|
|
23
|
+
try:
|
|
24
|
+
subprocess.run(['git', '--version'], check=True, stdout=subprocess.PIPE)
|
|
25
|
+
except subprocess.CalledProcessError:
|
|
26
|
+
raise RuntimeError("Git is not installed on this machine.")
|
|
27
|
+
|
|
28
|
+
def build_repos(self, yaml_file):
|
|
29
|
+
with open(yaml_file, 'r') as stream:
|
|
30
|
+
data = yaml.safe_load(stream)
|
|
31
|
+
repos = data.get('repos', [])
|
|
32
|
+
# Using a multiprocessing Pool for parallel building
|
|
33
|
+
with Pool(processes=len(repos)) as pool:
|
|
34
|
+
pool.map(self.clone_repo, repos)
|
|
35
|
+
|
|
36
|
+
# Build cannot be parallelized because of opam locks
|
|
37
|
+
for repo in repos:
|
|
38
|
+
self.build_repo(repo)
|
|
39
|
+
|
|
40
|
+
def clone_repo(self, repo):
|
|
41
|
+
repo_name = next(iter(repo))
|
|
42
|
+
repo_data = repo[repo_name]
|
|
43
|
+
self.cloner.clone_repo(repo_data)
|
|
44
|
+
|
|
45
|
+
def build_repo(self, repo):
|
|
46
|
+
print(f"Building repo: {repo}")
|
|
47
|
+
repo_name = next(iter(repo))
|
|
48
|
+
repo_data = repo[repo_name]
|
|
49
|
+
build_cmds = repo_data.get('build_cmds', [])
|
|
50
|
+
build_path = os.path.join(self.folder, repo_name)
|
|
51
|
+
self._build_repo(build_path, build_cmds, self.disable_build)
|
|
52
|
+
print(f"Finished building repo: {repo}")
|
|
53
|
+
|
|
54
|
+
def _build_repo(self, build_path, build_cmds, build_disabled):
|
|
55
|
+
random_id = random.randint(0, 100000)
|
|
56
|
+
os.chdir(build_path)
|
|
57
|
+
# Make a temporary shell script to run all build commands
|
|
58
|
+
with open(f"temptodelbuild{random_id}.sh", 'w') as f:
|
|
59
|
+
f.write("#!/bin/bash\n")
|
|
60
|
+
for cmd in build_cmds:
|
|
61
|
+
f.write(f"{cmd}\n")
|
|
62
|
+
os.system(f"chmod 777 ./temptodelbuild{random_id}.sh")
|
|
63
|
+
if not build_disabled:
|
|
64
|
+
# Run the shell script
|
|
65
|
+
os.system(f"./temptodelbuild{random_id}.sh")
|
|
66
|
+
# Clean up the shell script
|
|
67
|
+
os.remove(f"./temptodelbuild{random_id}.sh")
|
|
68
|
+
|
|
69
|
+
# Example usage
|
|
70
|
+
if __name__ == "__main__":
|
|
71
|
+
import argparse
|
|
72
|
+
parser = argparse.ArgumentParser()
|
|
73
|
+
parser.add_argument("--repo_yaml", help="Path to the yaml file containing repo data")
|
|
74
|
+
parser.add_argument("--disable_build", action="store_true", help="Disable building the repos")
|
|
75
|
+
parser.add_argument("--repo_folder", default=".repo", help="Folder to clone and build the repos in")
|
|
76
|
+
args = parser.parse_args()
|
|
77
|
+
builder = RepoBuilder(args.repo_folder, args.disable_build)
|
|
78
|
+
builder.build_repos(args.repo_yaml)
|
|
@@ -0,0 +1,79 @@
|
|
|
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 os
|
|
8
|
+
import subprocess
|
|
9
|
+
import yaml
|
|
10
|
+
|
|
11
|
+
class RepoCloner:
|
|
12
|
+
def __init__(self, folder):
|
|
13
|
+
self.folder = folder
|
|
14
|
+
self._check_git_installed()
|
|
15
|
+
|
|
16
|
+
def _check_git_installed(self):
|
|
17
|
+
try:
|
|
18
|
+
subprocess.run(['git', '--version'], check=True, stdout=subprocess.PIPE)
|
|
19
|
+
except subprocess.CalledProcessError:
|
|
20
|
+
raise RuntimeError("Git is not installed on this machine.")
|
|
21
|
+
|
|
22
|
+
def clone_repos(self, yaml_file):
|
|
23
|
+
with open(yaml_file, 'r') as stream:
|
|
24
|
+
data = yaml.safe_load(stream)
|
|
25
|
+
repos = data.get('repos', [])
|
|
26
|
+
for repo in repos:
|
|
27
|
+
assert len(repo) == 1, "Each repo entry should have exactly one key-value pair"
|
|
28
|
+
repo_name = list(repo.keys())[0]
|
|
29
|
+
print(f"Cloning {repo_name}")
|
|
30
|
+
repo = list(repo.values())[0]
|
|
31
|
+
self.clone_repo(repo)
|
|
32
|
+
|
|
33
|
+
def clone_repo(self, repo_dict):
|
|
34
|
+
url = repo_dict.get('url')
|
|
35
|
+
commit = repo_dict.get('commit', None)
|
|
36
|
+
branch = repo_dict.get('branch', None)
|
|
37
|
+
if not branch:
|
|
38
|
+
branch = self._get_default_branch(url)
|
|
39
|
+
if not commit:
|
|
40
|
+
commit = self._get_latest_commit(url, branch)
|
|
41
|
+
self._clone_repo(url, commit, branch)
|
|
42
|
+
|
|
43
|
+
def _clone_repo(self, url, commit, branch):
|
|
44
|
+
repo_name = url.split('/')[-1].replace('.git', '')
|
|
45
|
+
repo_path = os.path.join(self.folder, repo_name)
|
|
46
|
+
if not os.path.exists(repo_path):
|
|
47
|
+
os.makedirs(repo_path)
|
|
48
|
+
os.chdir(repo_path)
|
|
49
|
+
print(f"Cloning {url} at commit {commit} to branch {branch}")
|
|
50
|
+
subprocess.run(['git', 'clone', '--single-branch', '--branch', branch, url, '.'])
|
|
51
|
+
subprocess.run(['git', 'checkout', commit])
|
|
52
|
+
print(f"Cloned {url} at commit {commit} to branch {branch}")
|
|
53
|
+
|
|
54
|
+
def _get_default_branch(self, url):
|
|
55
|
+
try:
|
|
56
|
+
output = subprocess.run(['git', 'ls-remote', '--symref', url, 'HEAD'], stdout=subprocess.PIPE)
|
|
57
|
+
default_branch = None
|
|
58
|
+
for line in output.stdout.decode().split('\n'):
|
|
59
|
+
if line.startswith('ref: refs/heads/'):
|
|
60
|
+
default_branch = line.split('/')[-1].split('\t')[0].strip()
|
|
61
|
+
break
|
|
62
|
+
if not default_branch:
|
|
63
|
+
raise RuntimeError("Unable to determine default branch for repository: {}".format(url))
|
|
64
|
+
return default_branch
|
|
65
|
+
except subprocess.CalledProcessError:
|
|
66
|
+
raise RuntimeError("Unable to determine default branch for repository: {}".format(url))
|
|
67
|
+
|
|
68
|
+
def _get_latest_commit(self, url, branch):
|
|
69
|
+
try:
|
|
70
|
+
output = subprocess.run(['git', 'ls-remote', url, 'refs/heads/' + branch], stdout=subprocess.PIPE)
|
|
71
|
+
latest_commit = output.stdout.decode().split()[0]
|
|
72
|
+
return latest_commit
|
|
73
|
+
except subprocess.CalledProcessError:
|
|
74
|
+
raise RuntimeError("Unable to fetch latest commit for repository: {}".format(url))
|
|
75
|
+
|
|
76
|
+
# Example usage
|
|
77
|
+
if __name__ == "__main__":
|
|
78
|
+
cloner = RepoCloner(".repo")
|
|
79
|
+
cloner.clone_repos("src/itp_interface/main/config/repo/coq_repos.yaml")
|