简体   繁体   English

命题逻辑

[英]Propositional logic

I have the following problem: 我有以下问题:

I have two propositional formulas that must become logically equivalent. 我有两个命题公式必须在逻辑上等效。 Only, one of them contains a 'variable', in the sense that the variable may be replaced by any propositional formula. 从某种意义上说,变量可以被任何命题公式代替,只有其中一个包含“变量”。 The problem now, is that I need to find the actual replacement for the variable, such that the logical equivalence becomes true. 现在的问题是,我需要找到该变量的实际替换项,以使逻辑等价成为真。 Example: 例:

(a ^ ~b) or x = a (a ^〜b)或x = a

Here, x denotes the variable. 在此,x表示变量。 This logical equivalence can be made true, by replacing x with a ^ b, so it becomes: 通过将x替换为^ b可以使此逻辑等价成立,因此它变为:

(a ^ ~b) or (a ^ b) = a (a ^〜b)或(a ^ b)= a

So this is the problem. 所以这就是问题所在。 I need an algorithm that gets as input the "equation with one variable x" and gives as output value for the variable x such that the equation becomes a logical equivalence. 我需要一种算法,该算法将输入“带有一个变量x的方程”作为输入,并给出变量x的输出值,以使方程成为逻辑上的等价物。

There will always be one variable. 总会有一个变量。 (in fact I may get problems with more than one variable, but I want to solve the simple case first). (实际上我可能会遇到多个变量的问题,但我想先解决简单的情况)。 And the formulas in question can have any form (they are not in CNF or DNF). 并且所讨论的公式可以具有任何形式(它们不在CNF或DNF中)。 Also, the formulas can actually be FALSE or TRUE, and there are cases when there is no solution (eg for "a or x = false", there is no solution) or more than one solution (eg for "a and x = false" any false proposition would be a valid answer). 同样,公式实际上可以是FALSE或TRUE,并且在某些情况下没有解决方案(例如,对于“ a或x = false”,没有解决方案)或不止一个解决方案(例如,对于“ a and x = false” “任何错误的主张都是有效的答案)。

All I have is a tableaux reasoner that tells me whether a formula is satisfiable or not. 我所拥有的只是一个平稳的推理机,它告诉我公式是否可以满足。 So I can test a solution. 所以我可以测试一个解决方案。 But my problem is to just give me a solution. 但是我的问题是只给我一个解决方案。

I believe what you're looking for is a reasoning engine that can handle uninterpreted functions. 我相信您正在寻找的是可以处理未解释功能的推理引擎。 Such engines can handle problems that contain functions, eg, 这样的引擎可以处理包含功能的问题,例如

(a ^ ~b) or f(a,b) = a (a ^〜b)或f(a,b)= a

and they are usually able to produce models, ie, they will in fact generate a function f(...) that satisfies your initial formula. 并且它们通常能够生成模型,即实际上它们会生成满足您的初始公式的函数f(...)。 One example of suitable reasoning engines are so-called SMT solvers (see SMT-LIB ). 合适的推理引擎的一个示例是所谓的SMT求解器(请参阅SMT-LIB )。 A popular solver is Microsoft's Z3 (see Z3 ). 流行的求解器是Microsoft的Z3(请参阅Z3 )。

The example could be stated as follows in SMT-LIB format: 该示例可以用SMT-LIB格式说明如下:

(set-option :produce-models true)
(declare-const a Bool)
(declare-const b Bool)
(declare-fun f (Bool Bool) Bool)

(assert (= (or (xor a (not b)) (f a b)) a))
(check-sat)
(get-model)
(exit)

and Z3 produces the model Z3制作模型

(define-fun f ((x!1 Bool) (x!2 Bool)) Bool 
  (ite (and (= x!1 false) (= x!2 true)) false false))

which satisfies the original problem. 满足了原来的问题。 In general, the solution only satisfies the problem. 通常,该解决方案只能满足该问题。 To get complete solutions, quantifiers may be used. 为了获得完整的解决方案,可以使用量词。 Not all SMT solvers support them, but Z3 for example uses a complete reasoning engine for quantifiers over finite domains (like Booleans) and is able to produce models for such formulas. 并非所有SMT求解器都支持它们,但是Z3例如使用完整的推理引擎来对有限域(例如布尔值)上的量词进行量化,并能够生成此类公式的模型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM