{"id":16733335,"url":"https://github.com/msakai/tppmark2020","last_synced_at":"2025-07-15T17:33:15.265Z","repository":{"id":139185104,"uuid":"313057496","full_name":"msakai/tppmark2020","owner":"msakai","description":"My attempt to solve TPPmark problem of the 16th Theorem Proving and Provers meeting (TPP 2020).","archived":false,"fork":false,"pushed_at":"2024-11-20T15:53:26.000Z","size":1151,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T20:17:29.550Z","etag":null,"topics":["qbf","sat"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msakai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-15T15:09:14.000Z","updated_at":"2024-11-20T15:53:31.000Z","dependencies_parsed_at":"2023-10-02T05:56:00.641Z","dependency_job_id":null,"html_url":"https://github.com/msakai/tppmark2020","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/msakai/tppmark2020","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msakai%2Ftppmark2020","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msakai%2Ftppmark2020/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msakai%2Ftppmark2020/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msakai%2Ftppmark2020/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msakai","download_url":"https://codeload.github.com/msakai/tppmark2020/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msakai%2Ftppmark2020/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265450153,"owners_count":23767558,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["qbf","sat"],"created_at":"2024-10-12T23:49:25.906Z","updated_at":"2025-07-15T17:33:15.216Z","avatar_url":"https://github.com/msakai.png","language":"Haskell","readme":"# TPPmark2020\n\nAttempt for solving TPPmark problem of [the 16th Theorem Proving and Provers meeting (TPP 2020)](https://aabaa.github.io/tpp2020/).\n\n## Explanation\n\nMain program is [TPPmark2020.hs](TPPmark2020.hs).\n\n### 問1.\n\n\u003e 124本のベクトルからなる集合 X = {(x,y,z) | x,y,z ∈ {0,±1,±√2}} \\ {(0,0,0)} の各要素を白または黒に塗り分けることを考えます．\n\u003e このとき，次の2条件 a), b) を満たすようにベクトルを白または黒に塗り分けることはできないことを証明してください． \n\u003e - a) 2つの直交するベクトルのうち，少なくとも1本は黒色である． \n\u003e - b) 互いに直交し合う3つのベクトルのうち，少なくとも1本は白色である． \n\u003e \n\u003e Consider painting each element of the set X = {(x,y,z) | x,y,z ∈ {0,±1,±√2}} \\ {(0,0,0)} of 124 vectors white or black.\n\u003e Prove that the vectors cannot be painted white or black in such a way that the following two conditions a) and b) are met. \n\u003e - a) Whenever two of the vectors are orthogonal, at least one is black. \n\u003e - b) Whenever three of the vectors are mutually orthogonal, at least one is white. \n\nXの要素p毎の論理変数 white(p) (真であるときに白、偽であるときに黒であることを表す) と\n\n* ¬white(p1) ∨ ¬white(p2) for p1,p2∈X, p1 and p2 are orthogonal\n* white(p1) ∨ white(p2) ∨ white(p3) for p1,p2,p3∈X, p1, p2 and p3 are mutually orthogonal\n\nという制約条件からなる命題論理式をSATソルバを用いて解くことで、そのような塗り分けが可能かどうかを判定することができる。\n\n`solveQ1` が論理式を生成してSATソルバで解く関数であり、 [Q1.cnf](Q1.cnf) が得られた論理式である。\nSATソルバは一瞬でUNSATという結果を返すため、そのような塗り分けは不可能なことが示せた。\n\n### 問2. \n\n\u003e 条件 c) を満たしつつ，条件 a) と b) の少なくとも一方は成り立たないように，ベクトルの集合 X からできるだけ多くの要素を減らしてください． （ヒント: 33本までは減らせることが知られています．）\n\u003e - c) 集合内に互いに直交し合う3つのベクトルの集合が少なくとも1つは存在する．\n\u003e \n\u003e Reduce as many elements as possible from the set of vectors X such that at least one of the conditions a) and b) does not hold while condition c) is satisfied. (Hint: It is known that you can reduce the number to 33.)\n\u003e - c) There is at least one set of three mutually orthogonal vectors in the set. \n\n#### QBFを用いた解の発見\n\nまず、 X の各要素pが減らした結果の集合 X'⊆X に含まれるか否かを論理変数 X'(p) によって表すこととする。\n\n次に、条件 a), b), c) は以下のような命題論理式で表すことができる。\n* a(X', white) := ⋀\u003csub\u003e(p1,p2) ∈ \"orthogonal vectors of X\"\u003c/sub\u003e (X'(p1) ∧ X'(p2) → ¬white(p1) ∨ ¬white(p2))\n* b(X', white) := ⋀\u003csub\u003e(p1,p2,p3)∈\"three mutually orthogonal vectors of X\"\u003c/sub\u003e (X'(p1) ∧ X'(p2) ∧ X'(p3) → white(p1) ∨ white(p2) ∨ white(p3))\n* c(X') := ⋁\u003csub\u003e(p1,p2,p3)∈\"three mutually orthogonal vectors of X\"\u003c/sub\u003e (X'(p1) ∧ X'(p2) ∧ X'(p3))\n\n\nすると、問題は c(X') ∧ (∀white. ¬a(X', white) ∨ ¬b(X', white)) を満たす X'(p) の割当てのうち、真になっている X'(p) が最小のものを探す問題となる。\n\nまた、「33本までは減らせる」ことがヒントとして与えられているので、 基数制約 |X'| ≤ 33 も制約条件に加える。\n\nTotalizer符号化[1]による基数制約の符号化、Tseitin符号化[2][3]、および冠頭標準形への変換を行ってQDIMACS形式の論理式 [Q2_33.qdimacs](Q2_33.qdimacs) を生成し、QBFソルバ[caqe](https://github.com/ltentrup/caqe/tree/0543174f6c8c624ba37db80d13479c0408d7384e/)を用いて解いたところ、|X'| = 33 である以下の解が得られた。\n\n1. (-√2, -1, -1)\n2. (-√2, -1, 0)\n3. (-√2, -1, 1)\n4. (-√2, 0, -√2)\n5. (-√2, 0, -1)\n6. (-√2, 0, 0)\n7. (-√2, 1, -1)\n8. (-√2, 1, 0)\n9. (-1, -√2, 0)\n10. (-1, -1, √2)\n11. (-1, 0, -√2)\n12. (-1, 0, 1)\n13. (-1, 0, √2)\n14. (-1, 1, -√2)\n15. (-1, 1, √2)\n16. (-1, √2, -1)\n17. (0, -√2, -√2)\n18. (0, -√2, -1)\n19. (0, -√2, 1)\n20. (0, -1, -√2)\n21. (0, -1, 0)\n22. (0, -1, 1)\n23. (0, 0, 1)\n24. (0, 1, -√2)\n25. (1, -√2, -1)\n26. (1, -√2, 0)\n27. (1, 1, 0)\n28. (1, 1, √2)\n29. (1, √2, -1)\n30. (1, √2, 1)\n31. (√2, -√2, 0)\n32. (√2, -1, -1)\n33. (√2, 0, -1)\n\n次に基数制約を |X'| ≤ 32 に変更した(QDIMACSファイルは[Q2_32.qdimacs](Q2_32.qdimacs))ところ、数時間程度では解を得ることが出来なかった。\n\nプログラムでは `solveQ2` 関数が該当箇所である。\n\n#### MUSを用いた最適性の証明\n\n以下のような節グループの集まりを考える。\n\n* グループ D = CNF(a(X', white) ∧ b(X', white))\n* グループ G\u003csub\u003ep\u003c/sub\u003e = {X'(p)} for p ∈ X\n\nG = {G\u003csub\u003ep\u003c/sub\u003e}\u003csub\u003ep∈X\u003c/sub\u003e の部分集合 G' ⊆ G で D ∪ ⋃G' が充足不能なものを、この問題の Group oriented Unsatisfiable Subset (GUS) と呼ぶ。\n\nすると、\n\n* {X' ⊆ X | c(X') ∧ (∀white. ¬a(X', white) ∨ ¬b(X', white))}\n* = {X' ⊆ X | c(X') ∧ ¬(∃white. a(X', white) ∧ b(X', white))}\n* ⊆ {X' ⊆ X | ¬(∃white. a(X', white) ∧ b(X', white))}\n* = {X' ⊆ X | ∀X''⊆X. X' ⊆ X'' ⇒ ¬(∃white. a(X'', white) ∧ b(X'', white))}\n* = {X' ⊆ X | D ∪ ⋃{G\u003csub\u003ep\u003c/sub\u003e}\u003csub\u003ep∈X'\u003c/sub\u003e is UNSAT}.\n* = {X' ⊆ X | {G\u003csub\u003ep\u003c/sub\u003e}\u003csub\u003ep∈X'\u003c/sub\u003e is GUS}.\n\nのように、問題の条件を満たす X' の集合は GUS の条件を満たす X' の集合に包含されるため、 GUS のサイズがすべて33以上であれば、上述の |X'| = 33 が最適解であることがわかる。\n\nまた、GUS すべてについて確認せずとも、GUS のうち極小なものである Group oriented Minimal Unsatisfiable Subset (GMUS) [4] についてのみ確認すれば十分である。\n\nそこで、まず CAMUS アルゴリズム[5]を用いてすべての MUS のハイパーグラフの横断である MCS (Minimal Correction Subset) を列挙する。\n\n* GCNF形式ファイル: [Q2.gcnf](Q2.gcnf)\n* 実行ログ: [Q2_toysat_mcs.txt](Q2_toysat_mcs.txt)\n\nその結果、以下のようなベクトルの部分集合(に対応するグループ)の33個のMCSが得られた。\n\n1. {(0, -1, -√2), (0, 1, √2)}\n2. {(-√2, 0, -1), (√2, 0, 1)}\n3. {(-1, √2, 1), (1, -√2, -1)}\n4. {(-√2, -1, 0), (√2, 1, 0)}\n5. {(-1, √2, -1), (1, -√2, 1)}\n6. {(-1, 1, -√2), (1, -1, √2)}\n7. {(-1, -√2, 1), (1, √2, -1)}\n8. {(-1, 1, √2), (1, -1, -√2)}\n9. {(-√2, -1, -1), (√2, 1, 1)}\n10. {(-1, -1, -√2), (1, 1, √2)}\n11. {(-1, -√2, -1), (1, √2, 1)}\n12. {(-1, -1, √2), (1, 1, -√2)}\n13. {(-√2, 1, 1), (√2, -1, -1)}\n14. {(-√2, -1, 1), (√2, 1, -1)}\n15. {(0, -√2, -1), (0, √2, 1)}\n16. {(0, -√2, 1), (0, √2, -1)}\n17. {(-√2, 1, -1), (√2, -1, 1)}\n18. {(-1, √2, 0), (1, -√2, 0)}\n19. {(-1, 0, √2), (1, 0, -√2)}\n20. {(-1, 0, -√2), (1, 0, √2)}\n21. {(-√2, 0, 1), (√2, 0, -1)}\n22. {(0, -1, √2), (0, 1, -√2)}\n23. {(-√2, 1, 0), (√2, -1, 0)}\n24. {(-1, -√2, 0), (1, √2, 0)}\n25. {(0, 0, -√2), (0, 0, -1), (0, 0, 1), (0, 0, √2)}\n26. {(0, -√2, 0), (0, -1, 0), (0, 1, 0), (0, √2, 0)}\n27. {(-√2, 0, √2), (-1, 0, 1), (1, 0, -1), (√2, 0, -√2)}\n28. {(-√2, 0, 0), (-1, 0, 0), (1, 0, 0), (√2, 0, 0)}\n29. {(-√2, 0, -√2), (-1, 0, -1), (1, 0, 1), (√2, 0, √2)}\n30. {(-√2, √2, 0), (-1, 1, 0), (1, -1, 0), (√2, -√2, 0)}\n31. {(0, -√2, -√2), (0, -1, -1), (0, 1, 1), (0, √2, √2)}\n32. {(-√2, -√2, 0), (-1, -1, 0), (1, 1, 0), (√2, √2, 0)}\n33. {(0, -√2, √2), (0, -1, 1), (0, 1, -1), (0, √2, -√2)}\n\nここで、これらの MCS は互いに素であるため、そのハイパーグラフ横断である各MUSは各MCSから要素を一つづつ集めたものになり、したがってすべて33要素となる。\n\nよって、|X'| = 33 が最適解であることを示せた。\n\n### 問3.\n\n\u003e より一般的に n 次元 (n \u003e 3) の場合に拡張してください．\n\u003e このとき問題は，条件 c') を満たしつつ，条件 a) と b') の少なくとも一方は成り立たないように， n 次元ベクトルの集合を見つけることとなります．\n\u003e - a) 2つの直交するベクトルのうち，少なくとも1本は黒色である． \n\u003e - b') 互いに直交し合うn本のベクトルのうち，少なくとも1本は白色である． \n\u003e - c') 集合内に互いに直交し合う n 本のベクトルの集合が少なくとも1つは存在する．\n\u003e \n\u003e 一般の場合はとても難しいです．特定の n (\u003e 3) に対して，このようなベクトルの集合を構成する回答も歓迎します．\n\u003e \n\u003e More generally, extend it to the case of n dimensions (n \u003e 3). \n\u003e The problem is to find a set of n-dimensional vectors such that at least one of the conditions a) and b') does not hold while condition c') is satisfied.\n\u003e - a) Whenever two of the vectors are orthogonal, at least one is black.\n\u003e - b') Whenever n vectors are mutually orthogonal, at least one is white.\n\u003e - c') There exists at least one set of n vectors in the set that are mutually orthogonal to each other.\n\u003e \n\u003e The general case is very difficult. The constitution of such a set of vectors for a particular n (\u003e 3) is also welcome.\n\nn = 4 の場合について、基数制約は加えずに問2と同様のQBFを用いたアプローチを試みた(QDIMACSファイルは[Q3_4.qdimacs](Q3_4.qdimacs))が、解を得ることが出来なかった。\n\nプログラム中の `solveQ3` 関数が該当箇所である。\n\n# References\n\n* [1] O. Bailleux and Y. Boufkhad, “Efficient cnf encoding of boolean cardinality constraints,” in Principles and Practice of Constraint Programming –\nCP 2003, F. Rossi, Ed. Berlin, Heidelberg: Springer Berlin Heidelberg, 2003, pp. 108–122.\n* [2] G. Tseitin, “On the complexity of derivation in propositional calculus,” Studies in Constr. Math. and Math. Logic, 1968.\n* [3] D. Plaisted and S. Greenbaum, “A Structure-preserving Clause Form Translation,” in Journal on Symbolic Computation, volume 2, 1986.\n* [4] Matti Järvisalo, Daniel le Berre and Olivier Roussel, “Rules of the 2011 SAT Competition,” http://www.satcompetition.org/2011/rules.pdf\n* [5] M. H. Liffiton, K. A. Sakallah, “Algorithms for computing minimal unsatisfiable subsets of constraints,” Journal of Automated Reasoning 40 (1), 1–33 (Jan 2008)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsakai%2Ftppmark2020","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsakai%2Ftppmark2020","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsakai%2Ftppmark2020/lists"}