Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/gpu/checker2/test.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / gpu / checker2 / test.om` 211 lines ยท 5445 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note gpu/checker2/test.om: comprehensive positive & negative-control test suite for checker2 LRAT & DIMACS CNF. 3 note Tests: valid UNSAT proofs (pigeonhole PHP(2,1), multi-step RUP with deletions, tautology, trailing hints, 4 note comments/whitespace) AND all 13 fail-closed refusal rules (CNF-HEADER, CNF-LITERAL, CNF-COUNT, 5 note LRAT-SYNTAX, LRAT-DELETE-UNKNOWN, LRAT-ID-ORDER, LRAT-ID-RANGE, LRAT-LITERAL, LRAT-RAT-UNSUPPORTED, 6 note LRAT-HINT-UNKNOWN, LRAT-HINT-NOT-UNIT, LRAT-NO-CONFLICT, LRAT-NO-EMPTY-CLAUSE). 7 note Compose: si/directives/om2.om gpu/checker2/lrat.om gpu/checker2/test.om 8 9 text t_ok1 "PASS valid UNSAT LRAT proofs (3-var chain, deletions, tautology, trailing hints, comments)\n" 10 text t_ok2 "PASS DIMACS CNF fail-closed refusals (HEADER, LITERAL, COUNT)\n" 11 text t_ok3 "PASS LRAT fail-closed refusals (SYNTAX, DELETE-UNKNOWN, ID-ORDER, ID-RANGE, LITERAL)\n" 12 text t_ok4 "PASS LRAT RUP trust-boundary refusals (RAT-UNSUPPORTED, HINT-UNKNOWN, HINT-NOT-UNIT, NO-CONFLICT, NO-EMPTY-CLAUSE)\n" 13 text t_all "ALL PASS gpu-checker2-lrat\n" 14 text t_fail "FAIL gpu-checker2-lrat\n" 15 16 note ---- Positive test fixtures ---- 17 18 note CNF 1: (1 2) (-1 2) (1 -2) (-1 -2) -- classic 2-variable UNSAT with comments 19 text cnf_unsat2 "c 2-var unsat formula\np cnf 2 4\n1 2 0\n-1 2 0\n1 -2 0\n-1 -2 0\n" 20 note LRAT 1: derive (2) via 1 2, delete 1 2, derive () via 5 3 4 21 text lrat_unsat2 "5 2 0 1 2 0\n5 d 1 2 0\n6 0 5 3 4 0\n" 22 23 note CNF 2: 3-var implication chain UNSAT: (1) (-1 2) (-2 3) (-3) 24 text cnf_chain3 "p cnf 3 4\n1 0\n-1 2 0\n-2 3 0\n-3 0\n" 25 note LRAT 2: includes a tautology clause (1 -1), trailing hint after conflict, and empty clause 26 text lrat_chain3 "5 1 -1 0 1 0\n6 2 0 1 2 0\n7 0 6 3 4 1 0\n" 27 28 note CNF 3: Pigeonhole PHP(2,1) -- 3 pigeons (vars 1,2,3) in 2 holes? No, 2 pigeons in 1 hole: (1) (2) (-1 -2) 29 text cnf_php21 "c PHP(2,1)\np cnf 2 3\n1 0\n2 0\n-1 -2 0\n" 30 text lrat_php21 "4 0 1 2 3 0\n" 31 32 note ---- Negative control fixtures ---- 33 34 text cnf_bad_hdr "p sat 2 2\n1 0\n-1 0\n" 35 text cnf_bad_lit "p cnf 2 1\n3 0\n" 36 text cnf_bad_cnt "p cnf 2 3\n1 0\n-1 0\n" 37 text cnf_bad_trail "p cnf 2 1\n1 0\n2\n" 38 39 text lrat_bad_syntax "5 2 0 1\n" 40 text lrat_del_unk "5 d 99 0\n" 41 text lrat_del_twice "5 d 1 0\n6 d 1 0\n" 42 text lrat_id_order "4 2 0 1 2 0\n" 43 text lrat_id_range "500 2 0 1 2 0\n" 44 text lrat_bad_lit "5 9 0 1 2 0\n" 45 text lrat_rat_neg "5 2 0 -1 2 0\n" 46 text lrat_hint_unk "5 2 0 99 0\n" 47 text lrat_hint_del "5 d 1 0\n6 2 0 1 2 0\n" 48 text lrat_not_unit "5 0 1 2 0\n" 49 text lrat_no_conf "5 2 0 1 0\n" 50 text lrat_no_empty "5 2 0 1 2 0\n" 51 52 fn c2_puts s view uchar * to void 53 k = write 1 s 0 len s 54 if lt k 0 55 exit 2 56 end 57 ret 58 end 59 60 fn test_valid_proofs to int 61 res = new C2LratRes 0 0 0 0 0 62 note 1. 2-var UNSAT with deletion 63 if ne c2_cnf_parse cnf_unsat2 C2_OK 64 ret 1 65 end 66 if ne c2_lrat_check lrat_unsat2 edit res C2_OK 67 ret 2 68 end 69 if ne get res ok 1 70 ret 3 71 end 72 if ne get res steps 2 73 ret 4 74 end 75 if ne get res dels 2 76 ret 5 77 end 78 note 2. 3-var chain with tautology & trailing hint after conflict 79 if ne c2_cnf_parse cnf_chain3 C2_OK 80 ret 6 81 end 82 if ne c2_lrat_check lrat_chain3 edit res C2_OK 83 ret 7 84 end 85 if ne get res ok 1 86 ret 8 87 end 88 if ne get res steps 3 89 ret 9 90 end 91 note 3. PHP(2,1) direct RUP 92 if ne c2_cnf_parse cnf_php21 C2_OK 93 ret 10 94 end 95 if ne c2_lrat_check lrat_php21 edit res C2_OK 96 ret 11 97 end 98 if ne get res steps 1 99 ret 12 100 end 101 ret 0 102 end 103 104 fn test_cnf_refusals to int 105 if ne c2_cnf_parse cnf_bad_hdr C2_E_CNF_HEADER 106 ret 20 107 end 108 if ne c2_cnf_parse cnf_bad_lit C2_E_CNF_LITERAL 109 ret 21 110 end 111 if ne c2_cnf_parse cnf_bad_cnt C2_E_CNF_COUNT 112 ret 22 113 end 114 if ne c2_cnf_parse cnf_bad_trail C2_E_CNF_COUNT 115 ret 23 116 end 117 ret 0 118 end 119 120 fn test_lrat_structural_refusals to int 121 res = new C2LratRes 0 0 0 0 0 122 if ne c2_cnf_parse cnf_unsat2 C2_OK 123 ret 30 124 end 125 if ne c2_lrat_check lrat_bad_syntax edit res C2_E_LRAT_SYNTAX 126 ret 31 127 end 128 if ne c2_lrat_check lrat_del_unk edit res C2_E_LRAT_DELETE_UNKNOWN 129 ret 32 130 end 131 if ne c2_lrat_check lrat_del_twice edit res C2_E_LRAT_DELETE_UNKNOWN 132 ret 33 133 end 134 if ne c2_lrat_check lrat_id_order edit res C2_E_LRAT_ID_ORDER 135 ret 34 136 end 137 if ne c2_lrat_check lrat_id_range edit res C2_E_LRAT_ID_RANGE 138 ret 35 139 end 140 if ne c2_lrat_check lrat_bad_lit edit res C2_E_LRAT_LITERAL 141 ret 36 142 end 143 ret 0 144 end 145 146 fn test_lrat_rup_refusals to int 147 res = new C2LratRes 0 0 0 0 0 148 if ne c2_cnf_parse cnf_unsat2 C2_OK 149 ret 40 150 end 151 note Negative hint (RAT step) must be refused outright 152 if ne c2_lrat_check lrat_rat_neg edit res C2_E_LRAT_RAT_UNSUPPORTED 153 ret 41 154 end 155 if ne get res ok 0 156 ret 42 157 end 158 if ne c2_lrat_check lrat_hint_unk edit res C2_E_LRAT_HINT_UNKNOWN 159 ret 43 160 end 161 note Hint referencing a deleted clause must be refused 162 if ne c2_lrat_check lrat_hint_del edit res C2_E_LRAT_HINT_UNKNOWN 163 ret 44 164 end 165 note Non-unit hint (clause 1 has 2 unassigned literals when deriving empty clause) 166 if ne c2_lrat_check lrat_not_unit edit res C2_E_LRAT_HINT_NOT_UNIT 167 ret 45 168 end 169 note Hints finish without conflict 170 if ne c2_lrat_check lrat_no_conf edit res C2_E_LRAT_NO_CONFLICT 171 ret 46 172 end 173 note Valid step but never derives empty clause 174 if ne c2_lrat_check lrat_no_empty edit res C2_E_LRAT_NO_EMPTY_CLAUSE 175 ret 47 176 end 177 ret 0 178 end 179 180 fn main to int 181 rc = test_valid_proofs 182 if ne rc 0 183 c2_puts t_fail 184 ret rc 185 end 186 c2_puts t_ok1 187 188 rc = test_cnf_refusals 189 if ne rc 0 190 c2_puts t_fail 191 ret rc 192 end 193 c2_puts t_ok2 194 195 rc = test_lrat_structural_refusals 196 if ne rc 0 197 c2_puts t_fail 198 ret rc 199 end 200 c2_puts t_ok3 201 202 rc = test_lrat_rup_refusals 203 if ne rc 0 204 c2_puts t_fail 205 ret rc 206 end 207 c2_puts t_ok4 208 209 c2_puts t_all 210 ret 0 211 end