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,67 @@
|
|
|
1
|
+
|
|
2
|
+
import coq_serapy
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# A main function demonstrating some of the features of the coq_serapy module
|
|
6
|
+
|
|
7
|
+
# To properly run this example, you need Coq installed (versions 8.9-8.12) and
|
|
8
|
+
# Coq Serapi installed. Then, copy this into the folder *above* the coq_serapy
|
|
9
|
+
# module.
|
|
10
|
+
def main():
|
|
11
|
+
proof_commands = [
|
|
12
|
+
"Theorem t: forall n: nat, 1 + n > n.",
|
|
13
|
+
"Proof.",
|
|
14
|
+
"intro.",
|
|
15
|
+
"omega.",
|
|
16
|
+
"Qed."]
|
|
17
|
+
# You can also load commands from a file, like this:
|
|
18
|
+
#
|
|
19
|
+
# proof_commands = coq_serapy.load_commands(<filename>)
|
|
20
|
+
# OR
|
|
21
|
+
# proof_commands = coq_serapy.read_commands(<string>)
|
|
22
|
+
|
|
23
|
+
with coq_serapy.SerapiContext(
|
|
24
|
+
# How you want the underlying sertop binary to be run. If not sure,
|
|
25
|
+
# use this.
|
|
26
|
+
["sertop", "--implicit"],
|
|
27
|
+
# A top level module for the code to reside in. Empty string or
|
|
28
|
+
# None leaves in the default top module.
|
|
29
|
+
"MyModule",
|
|
30
|
+
# A prelude directory in which to start the binary
|
|
31
|
+
".") as coq:
|
|
32
|
+
|
|
33
|
+
# Runs commands from a list until we enter a proof, then returns a
|
|
34
|
+
# tuple of (commands-left-over, commands-that-were-run)
|
|
35
|
+
cmds_left, cmds_run, _ = coq.run_into_next_proof(
|
|
36
|
+
proof_commands)
|
|
37
|
+
assert cmds_run == ["Theorem t: forall n: nat, 1 + n > n."], cmds_run
|
|
38
|
+
assert cmds_left == [
|
|
39
|
+
"Proof.",
|
|
40
|
+
"intro.",
|
|
41
|
+
"omega.",
|
|
42
|
+
"Qed."], cmds_left
|
|
43
|
+
|
|
44
|
+
# Print out the proof context
|
|
45
|
+
print(coq.proof_context)
|
|
46
|
+
|
|
47
|
+
# Setting this makes sure that coq doesn't print extra on failed
|
|
48
|
+
# commands. Without it, failed proofs will get a message printed to
|
|
49
|
+
# standard out, even if you catch the exception.
|
|
50
|
+
coq.quiet = True
|
|
51
|
+
|
|
52
|
+
try:
|
|
53
|
+
_, _, _ = coq.finish_proof(cmds_left)
|
|
54
|
+
except coq_serapy.CoqExn:
|
|
55
|
+
# Oops! We forgot to import omega."
|
|
56
|
+
# Back out of the proof and import it.
|
|
57
|
+
while coq.proof_context:
|
|
58
|
+
coq.cancel_last()
|
|
59
|
+
coq.run_stmt("Require Import Omega.")
|
|
60
|
+
cmds_left, cmds_run, _ = coq.run_into_next_proof(proof_commands)
|
|
61
|
+
# Now it should finish fine
|
|
62
|
+
_, _ = coq.finish_proof(cmds_left)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# Run main if this module is being run standalone
|
|
66
|
+
if __name__ == "__main__":
|
|
67
|
+
main()
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
import threading
|
|
4
|
+
import subprocess
|
|
5
|
+
import re
|
|
6
|
+
import os
|
|
7
|
+
import queue
|
|
8
|
+
import functools
|
|
9
|
+
|
|
10
|
+
from typing import Any, Dict, List, cast, Callable, Optional, Tuple, Union
|
|
11
|
+
|
|
12
|
+
import pylspclient
|
|
13
|
+
|
|
14
|
+
from .contexts import ProofContext, Obligation, SexpObligation
|
|
15
|
+
from .coq_backend import CoqBackend, UnrecognizedError, CoqException, CoqExn, CoqTimeoutError, CoqAnomaly
|
|
16
|
+
from .coq_util import setup_opam_env
|
|
17
|
+
from .util import eprint, unwrap
|
|
18
|
+
|
|
19
|
+
class QueuePipe(threading.Thread):
|
|
20
|
+
|
|
21
|
+
def __init__(self, pipe):
|
|
22
|
+
threading.Thread.__init__(self)
|
|
23
|
+
self.pipe = pipe
|
|
24
|
+
self.queue = queue.Queue()
|
|
25
|
+
|
|
26
|
+
def run(self):
|
|
27
|
+
line = self.pipe.readline().decode('utf-8')
|
|
28
|
+
while line:
|
|
29
|
+
eprint(f"Error line: {line}")
|
|
30
|
+
self.queue.put(line)
|
|
31
|
+
line = self.pipe.readline().decode('utf-8')
|
|
32
|
+
def get(self) -> str:
|
|
33
|
+
return self.queue.get()
|
|
34
|
+
|
|
35
|
+
def verbosePut(verbosity: int, queue: queue.Queue, queue_name: str, msg: str) -> None:
|
|
36
|
+
if verbosity >= 3:
|
|
37
|
+
eprint(queue_name, ":", msg)
|
|
38
|
+
queue.put(msg)
|
|
39
|
+
|
|
40
|
+
class CoqLSPyInstance(CoqBackend):
|
|
41
|
+
proc: Any
|
|
42
|
+
stderr_queue: QueuePipe
|
|
43
|
+
messageQueues: Dict[str, queue.Queue]
|
|
44
|
+
endpoint: pylspclient.LspEndpoint
|
|
45
|
+
lsp_client: pylspclient.LspClient
|
|
46
|
+
|
|
47
|
+
open_doc: str
|
|
48
|
+
doc_version: int
|
|
49
|
+
doc_sentences: List[str]
|
|
50
|
+
state_dirty: bool
|
|
51
|
+
cached_context: Optional[ProofContext]
|
|
52
|
+
verbosity: int
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def __init__(self, lsp_command: Union[str, List[str]],
|
|
56
|
+
root_dir: Optional[str] = None, concise: bool = True,
|
|
57
|
+
timeout: int = 30, set_env: bool = True, verbosity: int = 0,
|
|
58
|
+
initialFilename: str = "local1.v") -> None:
|
|
59
|
+
if set_env:
|
|
60
|
+
setup_opam_env()
|
|
61
|
+
self.verbosity = verbosity
|
|
62
|
+
self.concise = concise
|
|
63
|
+
if isinstance(lsp_command, str):
|
|
64
|
+
lsp_command = [lsp_command]
|
|
65
|
+
server_delay = 0.05
|
|
66
|
+
full_command = lsp_command + (["-D", str(server_delay)] if self.concise else [])
|
|
67
|
+
self.proc = subprocess.Popen(full_command,
|
|
68
|
+
stdin=subprocess.PIPE,
|
|
69
|
+
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
70
|
+
self.stderr_queue = QueuePipe(self.proc.stderr)
|
|
71
|
+
self.stderr_queue.start()
|
|
72
|
+
|
|
73
|
+
queuedMessages = ['window/logMessage', '$/logTrace',
|
|
74
|
+
'textDocument/publishDiagnostics']
|
|
75
|
+
printedMessages: List[str] = []
|
|
76
|
+
ignoredMessages = ['$/coq/fileProgress', '$/coq/filePerfData']
|
|
77
|
+
self.messageQueues = {msg_type: queue.Queue() for
|
|
78
|
+
msg_type in queuedMessages}
|
|
79
|
+
self.timeout_for_message = timeout
|
|
80
|
+
self.endpoint = pylspclient.LspEndpoint(
|
|
81
|
+
pylspclient.JsonRpcEndpoint(self.proc.stdin, self.proc.stdout),
|
|
82
|
+
notify_callbacks={**{msg_type: cast(Callable[[Any], None],
|
|
83
|
+
# functools.partial(queue.Queue.put,
|
|
84
|
+
# msgqueue))
|
|
85
|
+
functools.partial(verbosePut, verbosity,
|
|
86
|
+
msgqueue, msg_type))
|
|
87
|
+
for msg_type, msgqueue in self.messageQueues.items()},
|
|
88
|
+
**{msg_type: functools.partial(print, msg_type) for msg_type in printedMessages},
|
|
89
|
+
**{msg_type: lambda x: None for msg_type in ignoredMessages}},
|
|
90
|
+
timeout=timeout)
|
|
91
|
+
self.lsp_client = pylspclient.LspClient(self.endpoint)
|
|
92
|
+
self.root_uri = "file://" + (os.path.abspath(root_dir) or os.getcwd())
|
|
93
|
+
workspace_folders = [{'name': 'coq-lsp', 'uri': self.root_uri}]
|
|
94
|
+
capabilities: Dict[str, Any] = {}
|
|
95
|
+
init_options = {"verbosity": 1} if self.concise else None
|
|
96
|
+
self.lsp_client.initialize(self.proc.pid, self.root_uri, self.root_uri, init_options,
|
|
97
|
+
capabilities,
|
|
98
|
+
"off", workspace_folders)
|
|
99
|
+
if not self.concise:
|
|
100
|
+
self.verify_init_messages()
|
|
101
|
+
self.lsp_client.initialized()
|
|
102
|
+
if not self.concise:
|
|
103
|
+
self.checkMessage("$/logTrace", '[process_queue]: Serving Request: initialized')
|
|
104
|
+
|
|
105
|
+
self.state_dirty = True
|
|
106
|
+
self.doc_sentences = []
|
|
107
|
+
self.openDoc(initialFilename)
|
|
108
|
+
|
|
109
|
+
def openDoc(self, filename: str) -> None:
|
|
110
|
+
self.open_doc = filename
|
|
111
|
+
docContents = ""
|
|
112
|
+
|
|
113
|
+
self.doc_version = 1
|
|
114
|
+
file_uri = os.path.join(self.root_uri, self.open_doc)
|
|
115
|
+
self.lsp_client.didOpen({"uri": file_uri,
|
|
116
|
+
"languageId": "Coq",
|
|
117
|
+
"version": self.doc_version,
|
|
118
|
+
"text": docContents})
|
|
119
|
+
msgs = [
|
|
120
|
+
r'\[process_queue\]: Serving Request: textDocument/didOpen',
|
|
121
|
+
r'\[process_queue\]: resuming document checking',
|
|
122
|
+
r'\[check\]: resuming(?: \[v: \d+\])?, from: \d+ l: \d+',
|
|
123
|
+
r'\[check\]: done \[\d+\.\d+\]: document fully checked .*',
|
|
124
|
+
r'\[cache\]: hashing: \d+.\d+ | parsing: \d+.\d+ | exec: \d+.\d+',
|
|
125
|
+
r'\[cache\]: .*']
|
|
126
|
+
if not self.concise:
|
|
127
|
+
for msg in msgs:
|
|
128
|
+
self.checkMessagePattern('$/logTrace', msg)
|
|
129
|
+
self._checkError()
|
|
130
|
+
|
|
131
|
+
def _checkError(self) -> None:
|
|
132
|
+
severe_errors = []
|
|
133
|
+
try:
|
|
134
|
+
while True: # Keep getting messages until the queue is empty
|
|
135
|
+
error = self.messageQueues['textDocument/publishDiagnostics'].get_nowait()
|
|
136
|
+
if error['version'] < self.doc_version:
|
|
137
|
+
if len(error['diagnostics']) == 0:
|
|
138
|
+
continue
|
|
139
|
+
eprint("Skipping error from an old doc version", guard=self.verbosity >= 2)
|
|
140
|
+
eprint(error, guard=self.verbosity >= 3)
|
|
141
|
+
continue
|
|
142
|
+
for message in error['diagnostics']:
|
|
143
|
+
if message['severity'] < 2 and message not in severe_errors:
|
|
144
|
+
assert error["version"] == self.doc_version,\
|
|
145
|
+
(error["version"], self.doc_version)
|
|
146
|
+
severe_errors.append(message)
|
|
147
|
+
except queue.Empty as e:
|
|
148
|
+
if len(severe_errors) > 0:
|
|
149
|
+
exceptions = [self._handleError(message)
|
|
150
|
+
for message in severe_errors]
|
|
151
|
+
raise exceptions[0] from e
|
|
152
|
+
return
|
|
153
|
+
def _handleError(self, message_json: Dict[str, Any]) -> CoqException:
|
|
154
|
+
sentence_num, sentence = self._sentence_at_line(
|
|
155
|
+
message_json['range']['start']['line'])
|
|
156
|
+
eprint("Problem running statement: ", sentence, guard=self.verbosity >= 2)
|
|
157
|
+
if sentence_num < len(self.doc_sentences):
|
|
158
|
+
eprint(f"Rolling back {len(self.doc_sentences) - sentence_num} sentence(s)",
|
|
159
|
+
guard=self.verbosity >= 2)
|
|
160
|
+
self.doc_sentences = self.doc_sentences[:sentence_num]
|
|
161
|
+
msg_text = message_json['message']
|
|
162
|
+
eprint(msg_text, guard=self.verbosity >= 2)
|
|
163
|
+
return CoqExn(msg_text)
|
|
164
|
+
|
|
165
|
+
# Uses 0-based line numbering, so the first line is line 0, the second is
|
|
166
|
+
# line 1, etc.
|
|
167
|
+
def _sentence_at_line(self, line: int) -> Tuple[int, str]:
|
|
168
|
+
cur_line = 0
|
|
169
|
+
for idx, sentence in enumerate(self.doc_sentences):
|
|
170
|
+
sentence_lines = len(sentence.split("\n"))
|
|
171
|
+
cur_line += sentence_lines
|
|
172
|
+
if line < cur_line:
|
|
173
|
+
return (idx, sentence)
|
|
174
|
+
assert False, "Line number is after all the statements we have!"
|
|
175
|
+
|
|
176
|
+
def __enter__(self) -> 'CoqLSPyInstance':
|
|
177
|
+
return self
|
|
178
|
+
|
|
179
|
+
def __exit__(self, exc_type, exc_val, exc_tb) -> None:
|
|
180
|
+
self.close()
|
|
181
|
+
|
|
182
|
+
def close(self) -> None:
|
|
183
|
+
self.lsp_client.shutdown()
|
|
184
|
+
self.lsp_client.exit()
|
|
185
|
+
self.proc.terminate()
|
|
186
|
+
self.proc.wait()
|
|
187
|
+
try:
|
|
188
|
+
self.stderr_queue.join()
|
|
189
|
+
except:
|
|
190
|
+
pass
|
|
191
|
+
|
|
192
|
+
def checkMessage(self, queue_name: str, message_text: str):
|
|
193
|
+
message = self.messageQueues[queue_name].get()
|
|
194
|
+
assert message['message'] == message_text, \
|
|
195
|
+
f"Looking for message {repr(message_text)}, got message {repr(message['message'])}"
|
|
196
|
+
|
|
197
|
+
def checkInMessage(self, queue_name: str, message_substring: str):
|
|
198
|
+
message = self.messageQueues[queue_name].get()
|
|
199
|
+
assert message_substring in message['message'],\
|
|
200
|
+
f"Couldn't find substring {message_substring} in message {message['message']}"
|
|
201
|
+
|
|
202
|
+
def checkMessagePattern(self, queue_name: str, message_pattern: str):
|
|
203
|
+
message = self.messageQueues[queue_name].get()
|
|
204
|
+
assert re.match(message_pattern, message['message']), \
|
|
205
|
+
f"Message {message['message']} doesn't match pattern {message_pattern}"
|
|
206
|
+
|
|
207
|
+
def verify_init_messages(self) -> None:
|
|
208
|
+
self.checkInMessage('window/logMessage', "Initializing coq-lsp server") # v0.1.4
|
|
209
|
+
self.checkMessage('window/logMessage', "Server initialized") # v0.1.4
|
|
210
|
+
|
|
211
|
+
self.checkInMessage('window/logMessage', "Configuration loaded") # v0.1.4
|
|
212
|
+
root_path = self.root_uri[7:]
|
|
213
|
+
expected_msgs = ['[init]: custom client options:',
|
|
214
|
+
'[init]: [init]: {}',
|
|
215
|
+
'[client_version]: any',
|
|
216
|
+
f'[workspace]: initialized {root_path}'] # v0.1.4
|
|
217
|
+
|
|
218
|
+
for expected_msg in expected_msgs:
|
|
219
|
+
self.checkMessage("$/logTrace", expected_msg)
|
|
220
|
+
|
|
221
|
+
def addStmt(self, stmt: str, timeout:Optional[int] = None,
|
|
222
|
+
force_update_nonfg_goals: bool = False) -> None:
|
|
223
|
+
del force_update_nonfg_goals
|
|
224
|
+
self.addStmt_noupdate(stmt, timeout)
|
|
225
|
+
self.getProofContext()
|
|
226
|
+
|
|
227
|
+
def addStmt_noupdate(self, stmt: str, timeout:Optional[int] = None) -> None:
|
|
228
|
+
self.doc_sentences.append(stmt.strip("\n"))
|
|
229
|
+
self.state_dirty = True
|
|
230
|
+
|
|
231
|
+
def cancelLastStmt(self, cancelled: str, force_update_nonfg_goals: bool = False) -> None:
|
|
232
|
+
del force_update_nonfg_goals
|
|
233
|
+
self.doc_sentences.pop()
|
|
234
|
+
self.state_dirty = True
|
|
235
|
+
def cancelLastStmt_noupdate(self, cancelled: str) -> None:
|
|
236
|
+
self.cancelLastStmt(cancelled)
|
|
237
|
+
|
|
238
|
+
def updateState(self) -> None:
|
|
239
|
+
pass
|
|
240
|
+
|
|
241
|
+
def getProofContext(self, anomaly_on_timeout: bool = False) -> Optional[ProofContext]:
|
|
242
|
+
if not self.state_dirty:
|
|
243
|
+
return self.cached_context
|
|
244
|
+
|
|
245
|
+
doc = "\n".join(self.doc_sentences)
|
|
246
|
+
file_uri = os.path.join(self.root_uri, self.open_doc)
|
|
247
|
+
self.doc_version += 1
|
|
248
|
+
self.lsp_client.didChange(
|
|
249
|
+
{"uri": file_uri,
|
|
250
|
+
"version": self.doc_version},
|
|
251
|
+
[{"text": doc}])
|
|
252
|
+
if not self.concise:
|
|
253
|
+
msgs = [
|
|
254
|
+
r'\[process_queue\]: Serving Request: textDocument/didChange',
|
|
255
|
+
fr'\[bump file\]: {file_uri} / version: {self.doc_version}',
|
|
256
|
+
r'\[bump file took\]: \d+\.\d+',
|
|
257
|
+
r'\[process_queue\]: resuming document checking',
|
|
258
|
+
r'\[check\]: resuming(?: \[v: \d+\])?, from: \d+ l: \d+',
|
|
259
|
+
r'\[check\]: done \[\d+\.\d+\]: document .*',
|
|
260
|
+
r'\[cache\]: hashing: \d+.\d+ | parsing: \d+.\d+ | exec: \d+.\d+',
|
|
261
|
+
r'\[cache\]: .*',
|
|
262
|
+
]
|
|
263
|
+
optional_msgs = [
|
|
264
|
+
r'\[resume\]: last node .*',
|
|
265
|
+
r'\[prefix\]: common prefix offset found at \d+',
|
|
266
|
+
r'\[prefix\]: resuming from .*',
|
|
267
|
+
]
|
|
268
|
+
for expected_msg_pattern in msgs:
|
|
269
|
+
while True:
|
|
270
|
+
try:
|
|
271
|
+
actual_message = self.messageQueues["$/logTrace"].get(timeout=self.timeout_for_message)['message']
|
|
272
|
+
except queue.Empty:
|
|
273
|
+
if anomaly_on_timeout:
|
|
274
|
+
raise CoqAnomaly("Timing out")
|
|
275
|
+
self._handle_timeout()
|
|
276
|
+
if any(re.match(optional_msg_pattern, actual_message)
|
|
277
|
+
for optional_msg_pattern in optional_msgs):
|
|
278
|
+
continue
|
|
279
|
+
else:
|
|
280
|
+
assert re.match(expected_msg_pattern, actual_message), f"Message {actual_message} didn't match pattern {expected_msg_pattern}"
|
|
281
|
+
break
|
|
282
|
+
line = len(doc.split("\n")) - 1
|
|
283
|
+
character = len(doc.split("\n")[-1]) if len(doc) > 0 else 0
|
|
284
|
+
try:
|
|
285
|
+
response = self.endpoint.call_method(
|
|
286
|
+
"proof/goals", textDocument={"uri": file_uri},
|
|
287
|
+
position={"line": line,
|
|
288
|
+
"character": character})
|
|
289
|
+
parsed_response = parseGoalResponse(response)
|
|
290
|
+
except TimeoutError:
|
|
291
|
+
if anomaly_on_timeout:
|
|
292
|
+
raise CoqAnomaly("Timing out")
|
|
293
|
+
self._handle_timeout()
|
|
294
|
+
if not self.concise:
|
|
295
|
+
self.checkMessage("$/logTrace", "[process_queue]: Serving Request: proof/goals")
|
|
296
|
+
self._checkError()
|
|
297
|
+
self.cached_context = parsed_response
|
|
298
|
+
self.state_dirty = False
|
|
299
|
+
return self.cached_context
|
|
300
|
+
def getSexpProofContext(self) -> List[SexpObligation]:
|
|
301
|
+
return [SexpObligation([], []) for _ in
|
|
302
|
+
unwrap(self.getProofContext()).all_goals]
|
|
303
|
+
|
|
304
|
+
def _handle_timeout(self) -> None:
|
|
305
|
+
self._checkError()
|
|
306
|
+
eprint("Rolling back 1 sentence for timeout",
|
|
307
|
+
guard=self.verbosity >= 2)
|
|
308
|
+
self.doc_sentences = self.doc_sentences[:-1]
|
|
309
|
+
# Currently coq-lsp often can't recover from timeouts
|
|
310
|
+
self.getProofContext(anomaly_on_timeout=True)
|
|
311
|
+
raise CoqTimeoutError("Timing out getting context")
|
|
312
|
+
|
|
313
|
+
def isInProof(self) -> bool:
|
|
314
|
+
return self.getProofContext() is not None
|
|
315
|
+
|
|
316
|
+
def queryVernac(self, vernac: str) -> List[str]:
|
|
317
|
+
raise NotImplementedError()
|
|
318
|
+
def interrupt(self) -> None:
|
|
319
|
+
raise NotImplementedError()
|
|
320
|
+
def resetCommandState(self) -> None:
|
|
321
|
+
self.doc_version += 1
|
|
322
|
+
self.doc_sentences = []
|
|
323
|
+
self.state_dirty = True
|
|
324
|
+
def setFilename(self, filename: str) -> None:
|
|
325
|
+
return
|
|
326
|
+
# self.openDoc(filename)
|
|
327
|
+
@property
|
|
328
|
+
def cur_state(self) -> int:
|
|
329
|
+
return len(self.doc_sentences)
|
|
330
|
+
def backToState(self, state_num: int) -> None:
|
|
331
|
+
self.doc_sentences = self.doc_sentence[:state_num]
|
|
332
|
+
self.state_dirty = True
|
|
333
|
+
def backToState_noupdate(self, state_num: int) -> None:
|
|
334
|
+
self.backToState(state_num)
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def parseObligation(obl_obj: Dict[str, Any]) -> Obligation:
|
|
338
|
+
return Obligation([
|
|
339
|
+
", ".join(hyp_obj["names"]) + " : " + hyp_obj["ty"]
|
|
340
|
+
for hyp_obj in obl_obj["hyps"]],
|
|
341
|
+
obl_obj["ty"])
|
|
342
|
+
|
|
343
|
+
def parseGoalResponse(response: Dict[str, Any]) -> Optional[ProofContext]:
|
|
344
|
+
if "goals" not in response or response["goals"] is None:
|
|
345
|
+
return None
|
|
346
|
+
goals = response["goals"]
|
|
347
|
+
return ProofContext([parseObligation(obl_obj)
|
|
348
|
+
for obl_obj in goals["goals"]],
|
|
349
|
+
[parseObligation(obl_obj)
|
|
350
|
+
for stack in goals["stack"]
|
|
351
|
+
for substack in stack
|
|
352
|
+
for obl_obj in substack],
|
|
353
|
+
[parseObligation(obl_obj)
|
|
354
|
+
for obl_obj in goals["shelf"]],
|
|
355
|
+
[parseObligation(obl_obj)
|
|
356
|
+
for obl_obj in goals["given_up"]])
|
|
357
|
+
|
|
358
|
+
def main():
|
|
359
|
+
|
|
360
|
+
with CoqLSPyInstance("cd $HOME/research/coq-lsp && dune exec -- coq-lsp") as coq:
|
|
361
|
+
print(coq.getProofContext())
|
|
362
|
+
coq.addStmt("Theorem nat_refl : forall n : nat, n= n.")
|
|
363
|
+
coq.addStmt("Proof.")
|
|
364
|
+
coq.addStmt("intro.")
|
|
365
|
+
print(coq.getProofContext())
|
|
366
|
+
coq.cancelLastStmt()
|
|
367
|
+
print(coq.getProofContext())
|
|
368
|
+
coq.addStmt("induction n.")
|
|
369
|
+
coq.addStmt("{")
|
|
370
|
+
print(coq.getProofContext())
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
# Run main if this module is being run standalone
|
|
374
|
+
if __name__ == "__main__":
|
|
375
|
+
main()
|
|
File without changes
|