{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/refactor-learning-to-extract-theorems-from-1","title":"REFACTOR: Learning to Extract Theorems from Proofs","arxiv_id":"2402.17032","date":"2024-02-26","proceeding":null,"authors":["Jin Peng Zhou","Yuhuai Wu","Qiyang Li","Roger Grosse"],"abstract":"Human mathematicians are often good at recognizing modular and reusable theorems that make complex mathematical results within reach. In this paper, we propose a novel method called theoREm-from-prooF extrACTOR (REFACTOR) for training neural networks to mimic this ability in formal mathematical theorem proving. We show on a set of unseen proofs, REFACTOR is able to extract 19.6% of the theorems that humans would use to write the proofs. When applying the model to the existing Metamath library, REFACTOR extracted 16 new theorems. With newly extracted theorems, we show that the existing proofs in the MetaMath database can be refactored. The new theorems are used very frequently after refactoring, with an average usage of 733.5 times, and help shorten the proof lengths. Lastly, we demonstrate that the prover trained on the new-theorem refactored dataset proves more test theorems and outperforms state-of-the-art baselines by frequently leveraging a diverse set of newly extracted theorems. Code can be found at https://github.com/jinpz/refactor.","url_abs":"https://arxiv.org/abs/2402.17032v1","url_pdf":"https://arxiv.org/pdf/2402.17032v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"refactor-learning-to-extract-theorems-from-1","repo_url":"https://github.com/jinpz/refactor","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"automated-theorem-proving","task_name":"Automated Theorem Proving"}],"methods":[{"method_slug":"set","method_name":"SET"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2402.17032","atlas_url":"https://app.syntology.ai/?focus=2402.17032","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.17032"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/jinpz/refactor","reach":null}],"summary":{"ran_draft_wrong":4,"ran_fixture":1,"unverified":5},"by_repo_kind":{"official":{"samples":10,"ran":5,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":10,"samples":[{"code_sha256_prefix":"15039402e49532f8","entry":"export_expanded_proof","repo":"jinpz/refactor","repo_kind":"official","path":"theorem_expansion.py","file_url":"https://github.com/jinpz/refactor/blob/HEAD/theorem_expansion.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"15039402e49532f8"}},{"code_sha256_prefix":"bbba677db0d43623","entry":"export_proofs_with_fixed_word_dict","repo":"jinpz/refactor","repo_kind":"official","path":"theorem_expansion.py","file_url":"https://github.com/jinpz/refactor/blob/HEAD/theorem_expansion.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"bbba677db0d43623"}},{"code_sha256_prefix":"f0c6a82aae692795","entry":"get_dfs","repo":"jinpz/refactor","repo_kind":"official","path":"theorem_refactor.py","file_url":"https://github.com/jinpz/refactor/blob/HEAD/theorem_refactor.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f0c6a82aae692795"}},{"code_sha256_prefix":"db40d5002162de5e","entry":"get_post_order","repo":"jinpz/refactor","repo_kind":"official","path":"theorem_refactor.py","file_url":"https://github.com/jinpz/refactor/blob/HEAD/theorem_refactor.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"db40d5002162de5e"}},{"code_sha256_prefix":"56fcc9d1c8e19c76","entry":"get_proof_level_acc","repo":"jinpz/refactor","repo_kind":"official","path":"theorem_verification.py","file_url":"https://github.com/jinpz/refactor/blob/HEAD/theorem_verification.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"56fcc9d1c8e19c76"}},{"code_sha256_prefix":"0af7e62a184b94f1","entry":"evaluate_loader","repo":"jinpz/refactor","repo_kind":"official","path":"theorem_verification.py","file_url":"https://github.com/jinpz/refactor/blob/HEAD/theorem_verification.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0af7e62a184b94f1"}},{"code_sha256_prefix":"37e1021bf4e47dda","entry":"follow_color","repo":"jinpz/refactor","repo_kind":"official","path":"theorem_refactor.py","file_url":"https://github.com/jinpz/refactor/blob/HEAD/theorem_refactor.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"37e1021bf4e47dda"}},{"code_sha256_prefix":"44afba786ad88c30","entry":"get_correct_total_stat","repo":"jinpz/refactor","repo_kind":"official","path":"theorem_verification.py","file_url":"https://github.com/jinpz/refactor/blob/HEAD/theorem_verification.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":"OPAQUE_PARAMS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"44afba786ad88c30"}},{"code_sha256_prefix":"a15ed6ff6756225c","entry":"get_expression_indices_update_word_dict","repo":"jinpz/refactor","repo_kind":"official","path":"theorem_expansion.py","file_url":"https://github.com/jinpz/refactor/blob/HEAD/theorem_expansion.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":"OPAQUE_PARAMS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a15ed6ff6756225c"}},{"code_sha256_prefix":"73abad27553083e4","entry":"refactor_proof_single","repo":"jinpz/refactor","repo_kind":"official","path":"theorem_refactor.py","file_url":"https://github.com/jinpz/refactor/blob/HEAD/theorem_refactor.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"73abad27553083e4"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}