创建随机的CNF公式
对于我的论文,我正在研究知识库的特定特性,以及这如何影响论证树的大小。我需要一个我已经拥有的prolog中的SAT求解器,但是我还需要一种创建随机从句的算法。 k-sat表示精确长度k的子句。为简单起见,我将k设置为3,最大4。我想将k(每个条款的文字数量)作为程序的参数。因此,如果我想要一个3个序列,具有1000个条款和300个文字,那么我的程序应创建一个具有100个长度3的知识库,其中所有这些文字都必须随机分散,以一定的负面比例(50) /50为简单起见)。我希望输出看起来像这样,输出:一组随机创建的子句:
v1:-v2,v3。
v2:-v3,-v4。
有人可以帮我吗?
For my thesis, I am looking at specific properties of knowledge bases and how this affects argumentation tree sizes. I need a sat solver in prolog which I already have, but I also need an algorithm that creates random clauses.
k-SAT means clauses of precisely length k. For simplicity, I will set k to 3, max 4. I want to give K (amount of literals per clause) as a parameter to the program. So if I want a 3-sat, with 1000 clauses and 300 literals, then my program should create a knowledge base with 100 clauses of length 3 where all of those literals randomly have to be spread out with a certain ratio of negative ones (50/50 for simplicity). I want the output to look like this, Output: a set of clauses randomly created:
V1 :- V2, V3.
V2 :- -V3, -V4.
could somebody help me with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
logTalk提供了用户 - 可扩展
nofollow noreferrer“>
nutyary nutyary 图书馆和QuickCheck Support在其lgtunit
开发器工具。您可以同时使用大多数Prolog Systems 。Logtalk provides a user-extensible
arbitrary
library and QuickCheck support in itslgtunit
developer tool. You can use both with most Prolog systems.尝试做类似的事情:
示例:
代码的详细说明
atom_concat/3
condentes两个原子形成第三个原子:字面(0.5,1,l)
随机生成字面p1
或- p1
:rando_clause/4
:以例如4个条款来创建一个随机知识基础:
或者,使用predenate
randoge> randoge_knwoLEDGE_BASE /5
:Try doing something like this:
Example:
Detailed explanation of the code
atom_concat/3
concatenates two atoms to form a third one:literal(0.5, 1, L)
randomly generates a literalp1
or-p1
:random_clause/4
:To create a random knowledge base with, for example, 4 clauses:
Or, using predicate
random_knwoledge_base/5
: