Computer Science Asked on October 21, 2021
Assume I have two Krom formulas $psi_1, psi_2$. Krom formulas are propositional formulas in CNF that have 2 literals in every clause. Each literal can be negated or unnegated. In other words, $psi_1,psi_2$ are 2-CNF formulas. For instance:
$(x_1 vee neg x_2) land (neg x_2 vee x_3 ) land (x_3 vee x_4)$
I want to decide whether $psi_1,psi_2$ are logically equivalent, i.e., $psi_1 leftrightarrow psi_2$. Equivalently, I want to test whether $F=(psi_1 vee negpsi_2)wedge (neg psi_1 vee psi_2)$ is true for all assignments of $x_1,dots,x_n$.
Is this problem tractable?
Yes, equivalence can be checked in polynomial time (in fact, in quadratic time).
I will describe how to test whether $psi_1 lor neg psi_2$ is true for all assignments. You can do the same for $neg psi_1 lor psi_2$, and use this to test whether $F$ is a tautology, i.e., whether $psi_1,psi_2$ are logically equivalent.
I will do this by checking whether $psi_1 lor neg psi_2$ is false for any assignment, or in other words, whether $neg(psi_1 lor neg psi_2)$ is satisfiable. Notice that
$$neg(psi_1 lor neg psi_2) = neg psi_1 land psi_2,$$
so it suffices to test satisfiability of $neg psi_1 land psi_2$ where $psi_1,psi_2$ are Krom (2-CNF) formulas.
Suppose that $psi_1 = c_1 land cdots land c_k$ where $c_i$ is the $i$th clause in $psi_1$. Then
$$neg psi_1 = (neg c_1) lor cdots lor (neg c_k).$$
Therefore
$$begin{align*} neg psi_1 land psi_2 &= ((neg c_1) lor cdots lor (neg c_k)) land psi_2\ &= (neg c_1 land psi_2) lor cdots lor (neg c_k land psi_2). end{align*}$$
Now, $neg psi_1 land psi_2$ is satisfiable iff $neg c_i land psi_2$ is satisfiable for some $i$. So, we can iterate over $i$ and test satisfiability of each $neg c_i land psi_2$; if any of them are satisfiable, then $neg psi_1 lor psi_2$ is satisfiable and $F$ is not a tautology and $psi_1,psi_2$ are not logically equivalent.
How to test satisfiability of $neg c_i land psi_2$? Well, $c_i$ has the form $(ell_1 lor ell_2)$ where $ell_1,ell_2$ are two literals, so $neg c_i land psi_2$ has the form $neg ell_1 land neg ell_2 land psi_2$. This is also a Krom (2-CNF) formula, so you can test its satisfiability using the standard polynomial-time algorithm. You do a linear number of such tests, so the total running time is polynomial. In fact, it is quadratic, as testing satisfiability can be done in linear time.
Answered by D.W. on October 21, 2021
Recall 2-SAT solution which uses strongly connected components: we build a graph with vertices $x_1,ldots,x_n, lnot x_1, ldots, lnot x_n$, and we replace each clause $x_i lor x_j$ with edges $lnot x_i to x_j$ and $lnot x_j to x_i$. An example from here:
To satisfy the formula, it's necessary and sufficient to assign vertices so that there are no contradictions in the graph (no edge $true to false$). We'll use these graphs for equivalence checking.
Proof:
$Leftarrow$: evident, since after transitive closure of graphs we'll have the same implications in both formulas.
$Rightarrow$: By contradiction. Wlog we assume that there exists a path $v_1 leadsto v_2$ in $G_1$ which doesn't exist in $G_2$. It means that assignment $v_1 := true$, $v_2 := false$ is feasible in $F_2$ (since there is no path $v_1 leadsto v_2$) but is infeasible in $F_1$.
Namely, the following assignment satisfies $F_2$:
This assignment has no contradiction, since there can be no edge $u to v$ of form $true to false$:
Technical note: for each variable $x_i$ there are two vertices: $v_i$ and $lnot v_i$ - and one may wonder if it'll lead to some problems with assignments. The answer is that after step 4), $v_i$ and $lnot v_i$ will lie in two different components (moreover, they are symmetric: $u to v$ in one component means $lnot u to lnot v$ in another one). Therefore, whatever decision we make for $u$ in one component, we can make the opposite decision for $lnot u$ in another one.
Answered by user114966 on October 21, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP