{"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/learning-with-logical-constraints-but-without","title":"Learning with Logical Constraints but without Shortcut Satisfaction","arxiv_id":"2403.00329","date":"2024-03-01","proceeding":null,"authors":["Zenan Li","Zehua Liu","Yuan YAO","Jingwei Xu","Taolue Chen","Xiaoxing Ma","Jian Lü"],"abstract":"Recent studies in neuro-symbolic learning have explored the integration of logical knowledge into deep learning via encoding logical constraints as an additional loss function. However, existing approaches tend to vacuously satisfy logical constraints through shortcuts, failing to fully exploit the knowledge. In this paper, we present a new framework for learning with logical constraints. Specifically, we address the shortcut satisfaction issue by introducing dual variables for logical connectives, encoding how the constraint is satisfied. We further propose a variational framework where the encoded logical constraint is expressed as a distributional loss that is compatible with the model's original training loss. The theoretical analysis shows that the proposed approach bears salient properties, and the experimental evaluations demonstrate its superior performance in both model generalizability and constraint satisfaction.","url_abs":"https://arxiv.org/abs/2403.00329v1","url_pdf":"https://arxiv.org/pdf/2403.00329v1.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":"learning-with-logical-constraints-but-without","repo_url":"https://github.com/softwiser-group/nesy-without-shortcuts","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2403.00329","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2403.00329"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+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/SoftWiser-group/NeSy-without-Shortcuts","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/softwiser-group/nesy-without-shortcuts","reach":{"status":"ok"}}],"summary":{"ran":7,"ran_draft_wrong":2,"ran_honours":3,"unverified":3},"by_repo_kind":{"official":{"samples":15,"ran":12,"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":15,"samples":[{"code_sha256_prefix":"8ac07200c1c79ca8","entry":"ResNet18","repo":"SoftWiser-group/NeSy-without-Shortcuts","repo_kind":"official","path":"models/resnet.py","file_url":"https://github.com/SoftWiser-group/NeSy-without-Shortcuts/blob/HEAD/models/resnet.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8ac07200c1c79ca8"}},{"code_sha256_prefix":"a89d570c0420fa68","entry":"ResNet34","repo":"SoftWiser-group/NeSy-without-Shortcuts","repo_kind":"official","path":"models/resnet.py","file_url":"https://github.com/SoftWiser-group/NeSy-without-Shortcuts/blob/HEAD/models/resnet.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a89d570c0420fa68"}},{"code_sha256_prefix":"5fbba8af66a4f573","entry":"add_default_parser_args","repo":"SoftWiser-group/NeSy-without-Shortcuts","repo_kind":"official","path":"logic_encoder/args.py","file_url":"https://github.com/SoftWiser-group/NeSy-without-Shortcuts/blob/HEAD/logic_encoder/args.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5fbba8af66a4f573"}},{"code_sha256_prefix":"583f9780bdd00a45","entry":"conv3x3","repo":"SoftWiser-group/NeSy-without-Shortcuts","repo_kind":"official","path":"models/resnet.py","file_url":"https://github.com/SoftWiser-group/NeSy-without-Shortcuts/blob/HEAD/models/resnet.py","link_basis":"harvester_set","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":"583f9780bdd00a45"}},{"code_sha256_prefix":"9713c177d53c82d7","entry":"dataset_with_indices","repo":"softwiser-group/nesy-without-shortcuts","repo_kind":"official","path":"hwf_exp/config.py","file_url":"https://github.com/softwiser-group/nesy-without-shortcuts/blob/HEAD/hwf_exp/config.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":"9713c177d53c82d7"}},{"code_sha256_prefix":"c4ef929d95634177","entry":"dataset_with_indices","repo":"SoftWiser-group/NeSy-without-Shortcuts","repo_kind":"official","path":"hwf_exp/config.py","file_url":"https://github.com/SoftWiser-group/NeSy-without-Shortcuts/blob/HEAD/hwf_exp/config.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c4ef929d95634177"}},{"code_sha256_prefix":"2129574ed34dcb74","entry":"dataset_with_indices","repo":"SoftWiser-group/NeSy-without-Shortcuts","repo_kind":"official","path":"image_exp/config.py","file_url":"https://github.com/SoftWiser-group/NeSy-without-Shortcuts/blob/HEAD/image_exp/config.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"2129574ed34dcb74"}},{"code_sha256_prefix":"238a5c2af722aa4b","entry":"get_hms","repo":"softwiser-group/nesy-without-shortcuts","repo_kind":"official","path":"hwf_exp/config.py","file_url":"https://github.com/softwiser-group/nesy-without-shortcuts/blob/HEAD/hwf_exp/config.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"238a5c2af722aa4b"}},{"code_sha256_prefix":"bb104479d26e39c3","entry":"get_hms","repo":"SoftWiser-group/NeSy-without-Shortcuts","repo_kind":"official","path":"hwf_exp/config.py","file_url":"https://github.com/SoftWiser-group/NeSy-without-Shortcuts/blob/HEAD/hwf_exp/config.py","link_basis":"harvester_set","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"bb104479d26e39c3"}},{"code_sha256_prefix":"22e236003b52f59c","entry":"lr_adapt","repo":"softwiser-group/nesy-without-shortcuts","repo_kind":"official","path":"hwf_exp/config.py","file_url":"https://github.com/softwiser-group/nesy-without-shortcuts/blob/HEAD/hwf_exp/config.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"22e236003b52f59c"}},{"code_sha256_prefix":"487902fc411efb97","entry":"lr_adapt","repo":"SoftWiser-group/NeSy-without-Shortcuts","repo_kind":"official","path":"hwf_exp/config.py","file_url":"https://github.com/SoftWiser-group/NeSy-without-Shortcuts/blob/HEAD/hwf_exp/config.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"487902fc411efb97"}},{"code_sha256_prefix":"b77041e9b261bc8f","entry":"vgg16","repo":"SoftWiser-group/NeSy-without-Shortcuts","repo_kind":"official","path":"models/vgg.py","file_url":"https://github.com/SoftWiser-group/NeSy-without-Shortcuts/blob/HEAD/models/vgg.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b77041e9b261bc8f"}},{"code_sha256_prefix":"f7b8450b915e3b4b","entry":"DenseNet100","repo":"SoftWiser-group/NeSy-without-Shortcuts","repo_kind":"official","path":"models/densenet.py","file_url":"https://github.com/SoftWiser-group/NeSy-without-Shortcuts/blob/HEAD/models/densenet.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":"f7b8450b915e3b4b"}},{"code_sha256_prefix":"7a6f63db4224099a","entry":"vgg11","repo":"SoftWiser-group/NeSy-without-Shortcuts","repo_kind":"official","path":"models/vgg.py","file_url":"https://github.com/SoftWiser-group/NeSy-without-Shortcuts/blob/HEAD/models/vgg.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":"7a6f63db4224099a"}},{"code_sha256_prefix":"3c7955d7089b595d","entry":"vgg13","repo":"SoftWiser-group/NeSy-without-Shortcuts","repo_kind":"official","path":"models/vgg.py","file_url":"https://github.com/SoftWiser-group/NeSy-without-Shortcuts/blob/HEAD/models/vgg.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":"3c7955d7089b595d"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}