永发信息网

Implement a SAT solver from scratch.

答案:2  悬赏:40  手机版
解决时间 2021-02-20 01:00
  • 提问者网友:
  • 2021-02-19 16:22
Implement a SAT solver from scratch.
最佳答案
  • 五星知识达人网友:山君与见山
  • 2021-02-19 17:46
Implement a SAT solver from scratch. (See Russell and Norvig, Ch. 7 for
details on the SAT problem.) Your solver should read a satis ability problem
in conjunctive normal form, in DIMACS format (see below), from standard
input. The output should be A satis ying variable assignment, if one exists; or
UNSATISFIABLE, if there is no solution.
Your code does not need to be heavily optimized but should be able to solve
problems with hundreds of clauses and up 20 variables in at most a few seconds.
(State of the art solvers can handle problems with millions of clauses and tens
of thousands of variables.)
DIMACS CNF format is widely accepted as the standard format for boolean
formulas in CNF. Benchmarks listed on satlib.org, for instance, are in the DI-
MACS CNF format. An input le starts with comments (each line starts with
c). The number of variables and the number of clauses is de ned by the line p
cnf variables clauses Each of the next lines speci es a clause: a positive literal
is denoted by the corresponding number, and a negative literal is denoted by
the corresponding negative number. The last number in a line should be zero.
Example 1: (x1 _ x2) ^ (:x1 _ :x2)
Input:
c example1.cnf
p cnf 2 2
1 2 0
-1 -2 0
Output:
1 -2
Example 2: (x1 _ x2) ^ :x1 ^ :x2
Input:
c example2.cnf
p cnf 2 3
1 2 0
-1 0
-2 0
Output:
UNSATISFIABLE
全部回答
  • 1楼网友:末日狂欢
  • 2021-02-19 18:25
不知
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯