简体   繁体   中英

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

Here, x denotes the variable. This logical equivalence can be made true, by replacing x with a ^ b, so it becomes:

(a ^ ~b) or (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.

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). 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).

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

and they are usually able to produce models, ie, they will in fact generate a function f(...) that satisfies your initial formula. One example of suitable reasoning engines are so-called SMT solvers (see SMT-LIB ). A popular solver is Microsoft's Z3 (see Z3 ).

The example could be stated as follows in SMT-LIB format:

(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

(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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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