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,174 @@
|
|
|
1
|
+
# A read-eval-print-loop for Lean 4
|
|
2
|
+
|
|
3
|
+
Run using `lake exe repl`.
|
|
4
|
+
Communicates via JSON on stdin and stdout.
|
|
5
|
+
Commands should be separated by blank lines.
|
|
6
|
+
|
|
7
|
+
The REPL works both in "command" mode and "tactic" mode.
|
|
8
|
+
|
|
9
|
+
## Command mode
|
|
10
|
+
|
|
11
|
+
In command mode, you send complete commands (e.g. declarations) to the REPL.
|
|
12
|
+
|
|
13
|
+
Commands may be of the form
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{ "cmd" : "def f := 2" }
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{ "cmd" : "example : f = 2 := rfl", "env" : 1 }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The `env` field, if present,
|
|
24
|
+
must contain a number received in the `env` field of a previous response,
|
|
25
|
+
and causes the command to be run in the existing environment.
|
|
26
|
+
|
|
27
|
+
If there is no `env` field, a new environment is created.
|
|
28
|
+
|
|
29
|
+
You can only use `import` commands when you do not specify the `env` field.
|
|
30
|
+
|
|
31
|
+
You can backtrack simply by using earlier values for `env`.
|
|
32
|
+
|
|
33
|
+
The response includes:
|
|
34
|
+
* A numeric label for the `Environment` after your command,
|
|
35
|
+
which you can use as the starting point for subsequent commands.
|
|
36
|
+
* Any messages generated while processing your command.
|
|
37
|
+
* A list of the `sorry`s in your command, including
|
|
38
|
+
* their expected type, and
|
|
39
|
+
* a numeric label for the proof state at the `sorry`, which you can then use in tactic mode.
|
|
40
|
+
|
|
41
|
+
Example output:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{"sorries":
|
|
45
|
+
[{"pos": {"line": 1, "column": 18},
|
|
46
|
+
"endPos": {"line": 1, "column": 23},
|
|
47
|
+
"goal": "⊢ Nat",
|
|
48
|
+
"proofState": 0}],
|
|
49
|
+
"messages":
|
|
50
|
+
[{"severity": "error",
|
|
51
|
+
"pos": {"line": 1, "column": 23},
|
|
52
|
+
"endPos": {"line": 1, "column": 26},
|
|
53
|
+
"data":
|
|
54
|
+
"type mismatch\n rfl\nhas type\n f = f : Prop\nbut is expected to have type\n f = 2 : Prop"}],
|
|
55
|
+
"env": 6}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
showing any messages generated, and sorries with their goal states.
|
|
59
|
+
|
|
60
|
+
## File mode
|
|
61
|
+
|
|
62
|
+
There is a simple wrapper around command mode that allows reading in an entire file.
|
|
63
|
+
|
|
64
|
+
If `test/file.lean` contains
|
|
65
|
+
```lean
|
|
66
|
+
def f : Nat := 37
|
|
67
|
+
|
|
68
|
+
def g := 2
|
|
69
|
+
|
|
70
|
+
theorem h : f + g = 39 := by exact rfl
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
then
|
|
74
|
+
```
|
|
75
|
+
echo '{"path": "test/file.lean", "allTactics": true}' | lake exe repl
|
|
76
|
+
```
|
|
77
|
+
results in output
|
|
78
|
+
```json
|
|
79
|
+
{"tactics":
|
|
80
|
+
[{"tactic": "exact rfl",
|
|
81
|
+
"proofState": 0,
|
|
82
|
+
"pos": {"line": 5, "column": 29},
|
|
83
|
+
"goals": "⊢ f + g = 39",
|
|
84
|
+
"endPos": {"line": 5, "column": 38}}],
|
|
85
|
+
"env": 0}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Tactic mode (experimental)
|
|
89
|
+
|
|
90
|
+
To enter tactic mode issue a command containing a `sorry`,
|
|
91
|
+
and then use the `proofState` index returned for each `sorry`.
|
|
92
|
+
|
|
93
|
+
Example usage:
|
|
94
|
+
```json
|
|
95
|
+
{"cmd" : "def f (x : Unit) : Nat := by sorry"}
|
|
96
|
+
|
|
97
|
+
{"sorries":
|
|
98
|
+
[{"proofState": 0,
|
|
99
|
+
"pos": {"line": 1, "column": 29},
|
|
100
|
+
"goal": "x : Unit\n⊢ Nat",
|
|
101
|
+
"endPos": {"line": 1, "column": 34}}],
|
|
102
|
+
"messages":
|
|
103
|
+
[{"severity": "warning",
|
|
104
|
+
"pos": {"line": 1, "column": 4},
|
|
105
|
+
"endPos": {"line": 1, "column": 5},
|
|
106
|
+
"data": "declaration uses 'sorry'"}],
|
|
107
|
+
"env": 0}
|
|
108
|
+
|
|
109
|
+
{"tactic": "apply Int.natAbs", "proofState": 0}
|
|
110
|
+
|
|
111
|
+
{"proofState": 1, "goals": ["x : Unit\n⊢ Int"]}
|
|
112
|
+
|
|
113
|
+
{"tactic": "exact -37", "proofState": 1}
|
|
114
|
+
|
|
115
|
+
{"proofState": 2, "goals": []}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
You can use `sorry` in tactic mode.
|
|
119
|
+
The result will contain additional `proofState` identifiers for the goal at each sorry.
|
|
120
|
+
|
|
121
|
+
At present there is nothing you can do with a completed proof state:
|
|
122
|
+
we would like to extend this so that you can replace the original `sorry` with your tactic script,
|
|
123
|
+
and obtain the resulting `Environment`
|
|
124
|
+
|
|
125
|
+
## Pickling
|
|
126
|
+
|
|
127
|
+
The REPL supports pickling environments and proof states to disk as `.olean` files.
|
|
128
|
+
As long as the same imports are available, it should be possible to move such an `.olean` file
|
|
129
|
+
to another machine and unpickle into a new REPL session.
|
|
130
|
+
|
|
131
|
+
The commands are
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{"pickleTo": "path/to/file.olean", "env": 7}
|
|
135
|
+
|
|
136
|
+
{"pickleTo": "path/to/file.olean", "proofState": 17}
|
|
137
|
+
|
|
138
|
+
{"unpickleEnvFrom": "path/to/file.olean"}
|
|
139
|
+
|
|
140
|
+
{"unpickleProofStateFrom": "path/to/file.olean"}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The unpickling commands will report the new "env" or "proofState" identifier that
|
|
144
|
+
you can use in subsequent commands.
|
|
145
|
+
|
|
146
|
+
Pickling is quite efficient:
|
|
147
|
+
* we don't record full `Environment`s, only the changes relative to imports
|
|
148
|
+
* unpickling uses memory mapping
|
|
149
|
+
* file sizes are generally small, but see https://github.com/digama0/leangz if compression is
|
|
150
|
+
desirable
|
|
151
|
+
|
|
152
|
+
## Using the REPL from another project
|
|
153
|
+
|
|
154
|
+
Set up your project as usual using `lake new` or `lake init`
|
|
155
|
+
(or the interactive setup GUI available via the VSCode extension under the `∀` menu).
|
|
156
|
+
|
|
157
|
+
In that project, add `require` statements in the `lakefile.lean` for any dependencies you need
|
|
158
|
+
(e.g. Mathlib). (You probably should verify that `lake build` works as expected in that project.)
|
|
159
|
+
|
|
160
|
+
Now you can run the REPL as:
|
|
161
|
+
```shell
|
|
162
|
+
lake env ../path/to/repl/.lake/build/bin/repl < commands.in
|
|
163
|
+
```
|
|
164
|
+
(Here `../path/to/repl/` represents the path to your checkout of this repository,
|
|
165
|
+
in which you've already run `lake build`.)
|
|
166
|
+
|
|
167
|
+
The `lake env` prefix sets up the environment associated to your local project, so that the REPL
|
|
168
|
+
can find needed imports.
|
|
169
|
+
|
|
170
|
+
## Future work
|
|
171
|
+
|
|
172
|
+
* Replay tactic scripts from tactic mode back into the original `sorry`.
|
|
173
|
+
* Currently if you create scoped environment extensions (e.g. scoped notations) in a session
|
|
174
|
+
these are not correctly pickled and unpickled in later sessions.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/-
|
|
2
|
+
Copyright (c) 2023 Scott Morrison. All rights reserved.
|
|
3
|
+
Released under Apache 2.0 license as described in the file LICENSE.
|
|
4
|
+
Authors: Scott Morrison
|
|
5
|
+
-/
|
|
6
|
+
import Lean.Elab.Frontend
|
|
7
|
+
|
|
8
|
+
open Lean Elab
|
|
9
|
+
|
|
10
|
+
namespace Lean.Elab.IO
|
|
11
|
+
|
|
12
|
+
/--
|
|
13
|
+
Wrapper for `IO.processCommands` that enables info states, and returns
|
|
14
|
+
* the new command state
|
|
15
|
+
* messages
|
|
16
|
+
* info trees
|
|
17
|
+
-/
|
|
18
|
+
def processCommandsWithInfoTrees
|
|
19
|
+
(inputCtx : Parser.InputContext) (parserState : Parser.ModuleParserState)
|
|
20
|
+
(commandState : Command.State) : IO (Command.State × List Message × List InfoTree) := do
|
|
21
|
+
let commandState := { commandState with infoState.enabled := true }
|
|
22
|
+
let s ← IO.processCommands inputCtx parserState commandState <&> Frontend.State.commandState
|
|
23
|
+
pure (s, s.messages.msgs.toList, s.infoState.trees.toList)
|
|
24
|
+
|
|
25
|
+
/--
|
|
26
|
+
Process some text input, with or without an existing command state.
|
|
27
|
+
If there is no existing environment, we parse the input for headers (e.g. import statements),
|
|
28
|
+
and create a new environment.
|
|
29
|
+
Otherwise, we add to the existing environment.
|
|
30
|
+
|
|
31
|
+
Returns the resulting command state, along with a list of messages and info trees.
|
|
32
|
+
-/
|
|
33
|
+
def processInput (input : String) (cmdState? : Option Command.State)
|
|
34
|
+
(opts : Options := {}) (fileName : Option String := none) :
|
|
35
|
+
IO (Command.State × List Message × List InfoTree) := unsafe do
|
|
36
|
+
Lean.initSearchPath (← Lean.findSysroot)
|
|
37
|
+
enableInitializersExecution
|
|
38
|
+
let fileName := fileName.getD "<input>"
|
|
39
|
+
let inputCtx := Parser.mkInputContext input fileName
|
|
40
|
+
let (parserState, commandState) ← match cmdState? with
|
|
41
|
+
| none => do
|
|
42
|
+
let (header, parserState, messages) ← Parser.parseHeader inputCtx
|
|
43
|
+
let (env, messages) ← processHeader header opts messages inputCtx
|
|
44
|
+
pure (parserState, (Command.mkState env messages opts))
|
|
45
|
+
| some cmdState => do
|
|
46
|
+
pure ({ : Parser.ModuleParserState }, cmdState)
|
|
47
|
+
processCommandsWithInfoTrees inputCtx parserState commandState
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/-
|
|
2
|
+
Copyright (c) 2023 Scott Morrison. All rights reserved.
|
|
3
|
+
Released under Apache 2.0 license as described in the file LICENSE.
|
|
4
|
+
Authors: Scott Morrison
|
|
5
|
+
-/
|
|
6
|
+
import Lean.Data.Json
|
|
7
|
+
import Lean.Message
|
|
8
|
+
import Lean.Elab.InfoTree.Main
|
|
9
|
+
|
|
10
|
+
open Lean Elab InfoTree
|
|
11
|
+
|
|
12
|
+
namespace REPL
|
|
13
|
+
|
|
14
|
+
structure CommandOptions where
|
|
15
|
+
allTactics : Option Bool := none
|
|
16
|
+
/--
|
|
17
|
+
Should be "full", "tactics", "original", or "substantive".
|
|
18
|
+
Anything else is ignored.
|
|
19
|
+
-/
|
|
20
|
+
infotree : Option String
|
|
21
|
+
|
|
22
|
+
/-- Run Lean commands.
|
|
23
|
+
If `env = none`, starts a new session (in which you can use `import`).
|
|
24
|
+
If `env = some n`, builds on the existing environment `n`.
|
|
25
|
+
-/
|
|
26
|
+
structure Command extends CommandOptions where
|
|
27
|
+
env : Option Nat
|
|
28
|
+
cmd : String
|
|
29
|
+
deriving ToJson, FromJson
|
|
30
|
+
|
|
31
|
+
/-- Process a Lean file in a fresh environment. -/
|
|
32
|
+
structure File extends CommandOptions where
|
|
33
|
+
path : System.FilePath
|
|
34
|
+
deriving FromJson
|
|
35
|
+
|
|
36
|
+
/--
|
|
37
|
+
Run a tactic in a proof state.
|
|
38
|
+
-/
|
|
39
|
+
structure ProofStep where
|
|
40
|
+
proofState : Nat
|
|
41
|
+
tactic : String
|
|
42
|
+
deriving ToJson, FromJson
|
|
43
|
+
|
|
44
|
+
/-- Line and column information for error messages and sorries. -/
|
|
45
|
+
structure Pos where
|
|
46
|
+
line : Nat
|
|
47
|
+
column : Nat
|
|
48
|
+
deriving ToJson, FromJson
|
|
49
|
+
|
|
50
|
+
/-- Severity of a message. -/
|
|
51
|
+
inductive Severity
|
|
52
|
+
| trace | info | warning | error
|
|
53
|
+
deriving ToJson, FromJson
|
|
54
|
+
|
|
55
|
+
/-- A Lean message. -/
|
|
56
|
+
structure Message where
|
|
57
|
+
pos : Pos
|
|
58
|
+
endPos : Option Pos
|
|
59
|
+
severity : Severity
|
|
60
|
+
data : String
|
|
61
|
+
deriving ToJson, FromJson
|
|
62
|
+
|
|
63
|
+
/-- Construct the JSON representation of a Lean message. -/
|
|
64
|
+
def Message.of (m : Lean.Message) : IO Message := do pure <|
|
|
65
|
+
{ pos := ⟨m.pos.line, m.pos.column⟩,
|
|
66
|
+
endPos := m.endPos.map fun p => ⟨p.line, p.column⟩,
|
|
67
|
+
severity := match m.severity with
|
|
68
|
+
| .information => .info
|
|
69
|
+
| .warning => .warning
|
|
70
|
+
| .error => .error,
|
|
71
|
+
data := (← m.data.toString).trim }
|
|
72
|
+
|
|
73
|
+
/-- A Lean `sorry`. -/
|
|
74
|
+
structure Sorry where
|
|
75
|
+
pos : Pos
|
|
76
|
+
endPos : Pos
|
|
77
|
+
goal : String
|
|
78
|
+
/--
|
|
79
|
+
The index of the proof state at the sorry.
|
|
80
|
+
You can use the `ProofStep` instruction to run a tactic at this state.
|
|
81
|
+
-/
|
|
82
|
+
proofState : Option Nat
|
|
83
|
+
deriving FromJson
|
|
84
|
+
|
|
85
|
+
instance : ToJson Sorry where
|
|
86
|
+
toJson r := Json.mkObj <| .join [
|
|
87
|
+
[("goal", r.goal)],
|
|
88
|
+
[("proofState", toJson r.proofState)],
|
|
89
|
+
if r.pos.line ≠ 0 then [("pos", toJson r.pos)] else [],
|
|
90
|
+
if r.endPos.line ≠ 0 then [("endPos", toJson r.endPos)] else [],
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
/-- Construct the JSON representation of a Lean sorry. -/
|
|
94
|
+
def Sorry.of (goal : String) (pos endPos : Lean.Position) (proofState : Option Nat) : Sorry :=
|
|
95
|
+
{ pos := ⟨pos.line, pos.column⟩,
|
|
96
|
+
endPos := ⟨endPos.line, endPos.column⟩,
|
|
97
|
+
goal,
|
|
98
|
+
proofState }
|
|
99
|
+
|
|
100
|
+
structure Tactic where
|
|
101
|
+
pos : Pos
|
|
102
|
+
endPos : Pos
|
|
103
|
+
goals : String
|
|
104
|
+
tactic : String
|
|
105
|
+
proofState : Option Nat
|
|
106
|
+
deriving ToJson, FromJson
|
|
107
|
+
|
|
108
|
+
/-- Construct the JSON representation of a Lean tactic. -/
|
|
109
|
+
def Tactic.of (goals tactic : String) (pos endPos : Lean.Position) (proofState : Option Nat) : Tactic :=
|
|
110
|
+
{ pos := ⟨pos.line, pos.column⟩,
|
|
111
|
+
endPos := ⟨endPos.line, endPos.column⟩,
|
|
112
|
+
goals,
|
|
113
|
+
tactic,
|
|
114
|
+
proofState }
|
|
115
|
+
|
|
116
|
+
/--
|
|
117
|
+
A response to a Lean command.
|
|
118
|
+
`env` can be used in later calls, to build on the stored environment.
|
|
119
|
+
-/
|
|
120
|
+
structure CommandResponse where
|
|
121
|
+
env : Nat
|
|
122
|
+
messages : List Message := []
|
|
123
|
+
sorries : List Sorry := []
|
|
124
|
+
tactics : List Tactic := []
|
|
125
|
+
infotree : Option Json := none
|
|
126
|
+
deriving FromJson
|
|
127
|
+
|
|
128
|
+
def Json.nonemptyList [ToJson α] (k : String) : List α → List (String × Json)
|
|
129
|
+
| [] => []
|
|
130
|
+
| l => [⟨k, toJson l⟩]
|
|
131
|
+
|
|
132
|
+
instance : ToJson CommandResponse where
|
|
133
|
+
toJson r := Json.mkObj <| .join [
|
|
134
|
+
[("env", r.env)],
|
|
135
|
+
Json.nonemptyList "messages" r.messages,
|
|
136
|
+
Json.nonemptyList "sorries" r.sorries,
|
|
137
|
+
Json.nonemptyList "tactics" r.tactics,
|
|
138
|
+
match r.infotree with | some j => [("infotree", j)] | none => []
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
/--
|
|
142
|
+
A response to a Lean tactic.
|
|
143
|
+
`proofState` can be used in later calls, to run further tactics.
|
|
144
|
+
-/
|
|
145
|
+
structure ProofStepResponse where
|
|
146
|
+
proofState : Nat
|
|
147
|
+
goals : List String
|
|
148
|
+
messages : List Message := []
|
|
149
|
+
sorries : List Sorry := []
|
|
150
|
+
traces : List String
|
|
151
|
+
deriving ToJson, FromJson
|
|
152
|
+
|
|
153
|
+
instance : ToJson ProofStepResponse where
|
|
154
|
+
toJson r := Json.mkObj <| .join [
|
|
155
|
+
[("proofState", r.proofState)],
|
|
156
|
+
[("goals", toJson r.goals)],
|
|
157
|
+
Json.nonemptyList "messages" r.messages,
|
|
158
|
+
Json.nonemptyList "sorries" r.sorries,
|
|
159
|
+
Json.nonemptyList "traces" r.traces
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
/-- Json wrapper for an error. -/
|
|
163
|
+
structure Error where
|
|
164
|
+
message : String
|
|
165
|
+
deriving ToJson, FromJson
|
|
166
|
+
|
|
167
|
+
structure PickleEnvironment where
|
|
168
|
+
env : Nat
|
|
169
|
+
pickleTo : System.FilePath
|
|
170
|
+
deriving ToJson, FromJson
|
|
171
|
+
|
|
172
|
+
structure UnpickleEnvironment where
|
|
173
|
+
unpickleEnvFrom : System.FilePath
|
|
174
|
+
deriving ToJson, FromJson
|
|
175
|
+
|
|
176
|
+
structure PickleProofState where
|
|
177
|
+
proofState : Nat
|
|
178
|
+
pickleTo : System.FilePath
|
|
179
|
+
deriving ToJson, FromJson
|
|
180
|
+
|
|
181
|
+
structure UnpickleProofState where
|
|
182
|
+
unpickleProofStateFrom : System.FilePath
|
|
183
|
+
env : Option Nat
|
|
184
|
+
deriving ToJson, FromJson
|
|
185
|
+
|
|
186
|
+
end REPL
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Lean
|
|
2
|
+
|
|
3
|
+
namespace Lean.Elab.ContextInfo
|
|
4
|
+
|
|
5
|
+
/-- Pretty print an expression in the given `ContextInfo` with the given `LocalContext`. -/
|
|
6
|
+
def ppExpr (ctx : ContextInfo) (lctx : LocalContext) (e : Expr) : IO Format :=
|
|
7
|
+
ctx.runMetaM lctx (do Meta.ppExpr (← instantiateMVars e))
|
|
8
|
+
|
|
9
|
+
end Lean.Elab.ContextInfo
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import REPL.Util.Pickle
|
|
2
|
+
import Lean.Replay
|
|
3
|
+
|
|
4
|
+
open System (FilePath)
|
|
5
|
+
|
|
6
|
+
namespace Lean.Environment
|
|
7
|
+
|
|
8
|
+
/--
|
|
9
|
+
Pickle an `Environment` to disk.
|
|
10
|
+
|
|
11
|
+
We only store:
|
|
12
|
+
* the list of imports
|
|
13
|
+
* the new constants from `Environment.constants`
|
|
14
|
+
and when unpickling, we build a fresh `Environment` from the imports,
|
|
15
|
+
and then add the new constants.
|
|
16
|
+
-/
|
|
17
|
+
def pickle (env : Environment) (path : FilePath) : IO Unit :=
|
|
18
|
+
_root_.pickle path (env.header.imports, env.constants.map₂)
|
|
19
|
+
|
|
20
|
+
/--
|
|
21
|
+
Unpickle an `Environment` from disk.
|
|
22
|
+
|
|
23
|
+
We construct a fresh `Environment` with the relevant imports,
|
|
24
|
+
and then replace the new constants.
|
|
25
|
+
-/
|
|
26
|
+
def unpickle (path : FilePath) : IO (Environment × CompactedRegion) := unsafe do
|
|
27
|
+
let ((imports, map₂), region) ← _root_.unpickle (Array Import × PHashMap Name ConstantInfo) path
|
|
28
|
+
let env ← importModules imports {} 0
|
|
29
|
+
return (← env.replay (HashMap.ofList map₂.toList), region)
|
|
30
|
+
|
|
31
|
+
end Lean.Environment
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import REPL.Lean.InfoTree
|
|
2
|
+
import REPL.Lean.ContextInfo
|
|
3
|
+
|
|
4
|
+
/-!
|
|
5
|
+
# Exporting an `InfoTree` as Json
|
|
6
|
+
|
|
7
|
+
-/
|
|
8
|
+
|
|
9
|
+
namespace Lean.Elab
|
|
10
|
+
|
|
11
|
+
structure InfoTreeNode (α : Type) where
|
|
12
|
+
kind : String
|
|
13
|
+
node : Option α
|
|
14
|
+
children : List Json
|
|
15
|
+
deriving ToJson
|
|
16
|
+
|
|
17
|
+
deriving instance ToJson for Lean.Position
|
|
18
|
+
|
|
19
|
+
structure Syntax.Range where
|
|
20
|
+
synthetic : Bool
|
|
21
|
+
start : Lean.Position
|
|
22
|
+
finish : Lean.Position
|
|
23
|
+
deriving ToJson
|
|
24
|
+
|
|
25
|
+
structure Syntax.Json where
|
|
26
|
+
pp : Option String
|
|
27
|
+
-- raw : String
|
|
28
|
+
range : Range
|
|
29
|
+
deriving ToJson
|
|
30
|
+
|
|
31
|
+
def _root_.Lean.Syntax.toRange (stx : Syntax) (ctx : ContextInfo) : Syntax.Range :=
|
|
32
|
+
let pos := stx.getPos?.getD 0
|
|
33
|
+
let endPos := stx.getTailPos?.getD pos
|
|
34
|
+
{ start := ctx.fileMap.toPosition pos
|
|
35
|
+
finish := ctx.fileMap.toPosition endPos
|
|
36
|
+
synthetic := match stx.getHeadInfo with
|
|
37
|
+
| .original .. => false
|
|
38
|
+
| _ => true }
|
|
39
|
+
|
|
40
|
+
def _root_.Lean.Syntax.toJson (stx : Syntax) (ctx : ContextInfo) (lctx : LocalContext) : IO Syntax.Json := do
|
|
41
|
+
return {
|
|
42
|
+
pp := match (← ctx.ppSyntax lctx stx).pretty with
|
|
43
|
+
| "failed to pretty print term (use 'set_option pp.rawOnError true' for raw representation)" => none
|
|
44
|
+
| pp => some pp
|
|
45
|
+
-- raw := toString stx
|
|
46
|
+
range := stx.toRange ctx }
|
|
47
|
+
|
|
48
|
+
structure TacticInfo.Json where
|
|
49
|
+
name : Option Name
|
|
50
|
+
stx : Syntax.Json
|
|
51
|
+
goalsBefore : List String
|
|
52
|
+
goalsAfter : List String
|
|
53
|
+
deriving ToJson
|
|
54
|
+
|
|
55
|
+
-- Note: this is not responsible for converting the children to Json.
|
|
56
|
+
def TacticInfo.toJson (i : TacticInfo) (ctx : ContextInfo) : IO TacticInfo.Json := do
|
|
57
|
+
return {
|
|
58
|
+
name := i.name?
|
|
59
|
+
stx :=
|
|
60
|
+
{ pp := Format.pretty (← i.pp ctx),
|
|
61
|
+
-- raw := toString i.info.stx,
|
|
62
|
+
range := i.stx.toRange ctx },
|
|
63
|
+
goalsBefore := (← i.goalState ctx).map Format.pretty,
|
|
64
|
+
goalsAfter := (← i.goalStateAfter ctx).map Format.pretty }
|
|
65
|
+
|
|
66
|
+
structure CommandInfo.Json where
|
|
67
|
+
elaborator : Option Name
|
|
68
|
+
stx : Syntax.Json
|
|
69
|
+
deriving ToJson
|
|
70
|
+
|
|
71
|
+
def CommandInfo.toJson (info : CommandInfo) (ctx : ContextInfo) : IO CommandInfo.Json := do
|
|
72
|
+
return {
|
|
73
|
+
elaborator := match info.elaborator with | .anonymous => none | n => some n,
|
|
74
|
+
stx := ← info.stx.toJson ctx {} }
|
|
75
|
+
|
|
76
|
+
structure TermInfo.Json where
|
|
77
|
+
elaborator : Option Name
|
|
78
|
+
stx : Syntax.Json
|
|
79
|
+
expectedType? : Option String
|
|
80
|
+
expr : String
|
|
81
|
+
isBinder : Bool
|
|
82
|
+
deriving ToJson
|
|
83
|
+
|
|
84
|
+
def TermInfo.toJson (info : TermInfo) (ctx : ContextInfo) : IO TermInfo.Json := do
|
|
85
|
+
return {
|
|
86
|
+
elaborator := match info.elaborator with | .anonymous => none | n => some n,
|
|
87
|
+
stx := ← info.stx.toJson ctx info.lctx,
|
|
88
|
+
expectedType? := ← info.expectedType?.mapM fun ty => do
|
|
89
|
+
pure (← ctx.ppExpr info.lctx ty).pretty
|
|
90
|
+
expr := (← ctx.ppExpr info.lctx info.expr).pretty
|
|
91
|
+
isBinder := info.isBinder }
|
|
92
|
+
|
|
93
|
+
structure InfoTree.HoleJson where
|
|
94
|
+
goalState : String
|
|
95
|
+
deriving ToJson
|
|
96
|
+
|
|
97
|
+
partial def InfoTree.toJson (t : InfoTree) (ctx? : Option ContextInfo) : IO Json := do
|
|
98
|
+
match t with
|
|
99
|
+
| .context ctx t => t.toJson (ctx.mergeIntoOuter? ctx?)
|
|
100
|
+
| .node info children =>
|
|
101
|
+
if let some ctx := ctx? then
|
|
102
|
+
let node : Option Json ← match info with
|
|
103
|
+
| .ofTermInfo info => some <$> (do pure <| Lean.toJson (← info.toJson ctx))
|
|
104
|
+
| .ofCommandInfo info => some <$> (do pure <| Lean.toJson (← info.toJson ctx))
|
|
105
|
+
| .ofTacticInfo info => some <$> (do pure <| Lean.toJson (← info.toJson ctx))
|
|
106
|
+
| _ => pure none
|
|
107
|
+
return Lean.toJson (InfoTreeNode.mk info.kind node (← children.toList.mapM fun t' => t'.toJson ctx))
|
|
108
|
+
else throw <| IO.userError "No `ContextInfo` available."
|
|
109
|
+
| .hole mvarId =>
|
|
110
|
+
if let some ctx := ctx? then
|
|
111
|
+
return Lean.toJson (InfoTree.HoleJson.mk (← ctx.runMetaM {} (do Meta.ppGoal mvarId)).pretty)
|
|
112
|
+
else throw <| IO.userError "No `ContextInfo` available."
|
|
113
|
+
|
|
114
|
+
end Lean.Elab
|