小编Reb*_*cca的帖子

如何将命题逻辑树转换为合取范式(CNF)树

我有一个像字符串的字符串

     s="(=> P (OR (AND A (NOT B)) (AND B (NOT A))))";
Run Code Online (Sandbox Code Playgroud)

并将其转换为该字符串的CNF,例如

(或(非P)(或AB))(或(非P)(或(非B)(非A)))

我需要构造一个TreeTree来保留值吗?

     struct TreeNode {
            string val;         // The data in this node.
            TreeNode *left;   // Pointer to the left subtree.
            TreeNode *right;  // Pointer to the right subtree.
            //TreeNode *farther;//should I use farther or not in convert to CNF?
      };
Run Code Online (Sandbox Code Playgroud)

如何使它成为合取范式的CNF?请提供一些算法细节。从我的角度来看,也许使用递归函数可以更好地解决此问题,但是我仍然想不出如何使用递归。或者您有解决此问题的其他建议?

c c++ recursion prefix-tree conjunctive-normal-form

5
推荐指数
1
解决办法
2623
查看次数

标签 统计

c ×1

c++ ×1

conjunctive-normal-form ×1

prefix-tree ×1

recursion ×1