CNFの命題式を使用して文字列をDIMACSに解析したいので、haskellのネストされたintリストです。この形式は、SAT 解決の他のオプションよりもパフォーマンスが高いと思われる haskell picosat バインディングに適しています。
問題は、これを実装したコードが複雑すぎることです。現在、見つけにくいバグの可能性を探しています。
(私のアプローチは、haskell hatt パッケージを使用し、パッケージを変更して、変数名に単一文字の代わりに文字列を使用し、hatt で式を解析し、結果の式を DIMACS 形式に変換することでした。)
CNF 記法で命題式を表す文字列を解析したい (以下の例を参照)。結果は、ネストされた int のリストになります。したがって、結果はhaskell picosat bindingssolveAllの一部に適しているはずです。
入力:
-- "&" ... conjunction
-- "|" ... disjunction
-- "-" ... not operator
let myCNF = "GP & (-GP | Ma) & (-Ma | GP) & (-Ma | TestP) & (-Ma | Alg) & (-Ma | Src) & (-Ma | Hi) & (-Ma | Wg | X | Y) & -Z"
結果:
-- DIMACS format
-- every Variable (e.g., "GP") gets a number, say GP gets the int num 1
-- in case of not GP (i.e., "-GP") the int number representing the variable is negative, thus -1
-- Note: I hope I didn't do a type
let myresult = [[1], [-1, 2], [-2, 1], [-2, 3], [-2, 3], [-2, 5], [-2, 6], [-2, 7, 8, 9], [-10]]
let myvars = ["GP", "Ma", "TestP", "Alg", "Src", "Hi", "Wg", "X", "Y", "Z"]
-- or alternativly the variables are stored in an associative array
let varOtherWay = (1, GP), (2, Ma) (3, TestP), (4, Alg), (5, Src), (6, Hi), (7, Wg), (8, X), (9, Y), (10, Z)