How to convert SAT formula to 3SAT format? - algorithm

I have a hard time understanding what is a NP Completion. Since one of my professor didn't explain well to me on this example problem they give us. If anybody know this solution, please explain it to me so I can able to learn.
Here the equation that I was having trouble on! Please take a look.

If you have a clause C that has too few literals, it can be replaced by (C ∨ x) ∧ (C ∨ x′) where x is a fresh variable.
If you have a clause C that has too many literals, you can first split it as C = C0 ∨ C1, putting one half of the literals in C0 and the other half of the literals in C1, then return to conjunctive normal form by replacing C with (C0 ∨ x) ∧ (C1 ∨ x′).

Related

Knight and knaves

I have these in my lecture notes, its about the rules where knights always tell the truth and knaves always lie:
If A says “The statement ‘there is gold on the island’ and the statement ‘I
am a knight’ are either both true or both false” he is asserting A ≡ G
where A is the assertion A is a knight and G the assertion there is gold
on the Island.
Any assertion by a knave has the same truth value as A therefore:
A ≡ (A ≡ G)
(A ≡ A) ≡ G
true ≡ G
Since A ≡ (A ≡ G), it can only be the first case or third case. Hence, G is
true and A can be true or false
The notes end here, I just don't understand why is it not possible for A to lie about being a knight and about gold being on the island, I mean it just shows that A is a knave, it should still be legal, even though the truth table says its illegal for the that to happen(last row), I just can't internalize why.

Converting Not All Equal 2-Sat Pr0blem to an equivalent 2-SAT pr0blem

I'm looking over previous exam papers, and have come across this question which has confused me.
Question:
Convert the Not-All-Equal 2-SAT problem given by the clauses {x1, x2}, {x2, x3}, {x3, x4}, {x4, x5}, {x5, x1} to an equivalent 2-SAT problem. (Hint: the 2-SAT problem contains 10 clauses).
From my understanding, is this simply finding the negation for each literal in every clause? So for example, {x1, x2} = {-x1, -x2}, and this is done for each clause?
Is this correct?
That is correct. Specifically, replace all clauses (x ∨ y) with (x ∨ y) ∧ (~x ∨ ~y). That literally says "x or y have to be true, and x or y have to be false", or equivalently "satisfy (x ∨ y) while making sure that one of x and y is false".
To prove the equivalence, let us first assume that the NAE 2-SAT problem is satisfiable. Let A be a satisfying assignment and let {x, y} be one arbitrary clause. Since exactly one of x and y are true, this implies that (x ∨ y) ∧ (~x ∨ ~y) is true. Hence, the corresponding two clauses in the 2-SAT formula are satisfied. Since {x, y} was chosen arbitrarily, we conclude that A satisfies all the clauses in the 2-SAT formula.
Conversely, let us assume that the NAE 2-SAT is not satisfiable. That is, for any assignment, there exists some clause {x, y} for which x and y are either both true or both false. Let A be an arbitrarily chosen assignment and let {x, y} be a clause that A does not satisfy (in the NAE 2-SAT). Since x = y, this implies that (x ∨ y) ∧ (~x ∨ ~y) is false (because one of the halves of the conjunction will be false). Hence, A does not satisfy the 2-SAT formula. Since A was chosen arbitrarily, we conclude that no assignment satisfies the 2-SAT formula.

How to prove excluded middle is irrefutable in Coq?

I was trying to prove the following simple theorem from an online course that excluded middle is irrefutable, but got stuck pretty much at step 1:
Theorem excluded_middle_irrefutable: forall (P:Prop), ~~(P \/ ~ P).
Proof.
intros P. unfold not. intros H.
Now I get:
1 subgoals
P : Prop
H : P \/ (P -> False) -> False
______________________________________(1/1)
False
If I apply H, then the goal would be P \/ ~P, which is excluded middle and can't be proven constructively. But other than apply, I don't know what can be done about the hypothesis P \/ (P -> False) -> False: implication -> is primitive, and I don't know how to destruct or decompose it. And this is the only hypothesis.
My question is, how can this be proven using only primitive tactics (as characterized here, i.e. no mysterious autos)?
Thanks.
I'm not an expert on this subject, but it was recently discussed on the Coq mailing-list. I'll summarize the conclusion from this thread. If you want to understand these kinds of problems more thoroughly, you should look at double-negation translation.
The problem falls within intuitionistic propositional calculus and can thus be decided by tauto.
Theorem excluded_middle_irrefutable: forall (P:Prop), ~~(P \/ ~ P).
tauto.
Qed.
The thread also provides a more elaborate proof. I'll attempt to explain how I would have come up with this proof. Note that it's usually easier for me to deal with the programming language interpretation of lemmas, so that's what I'll do:
Theorem excluded_middle_irrefutable: forall (P:Prop), ~~(P \/ ~ P).
unfold not.
intros P f.
We are asked to write a function that takes the function f and produces a value of type False. The only way to get to False at this point is to invoke the function f.
apply f.
Consequently, we are asked to provide the arguments to the function f. We have two choices, either pass P or P -> False. I don't see a way to construct a P so I'm choosing the second option.
right.
intro p.
We are back at square one, except that we now have a p to work with!
So we apply f because that's the only thing we can do.
apply f.
And again, we are asked to provide the argument to f. This is easy now though, because we have a p to work with.
left.
apply p.
Qed.
The thread also mentions a proof that is based on some easier lemmas. The first lemma is ~(P /\ ~P).
Lemma lma (P:Prop) : ~(P /\ ~P).
unfold not.
intros H.
destruct H as [p].
apply H.
apply p.
Qed.
The second lemma is ~(P \/ Q) -> ~P /\ ~Q:
Lemma lma' (P Q:Prop) : ~(P \/ Q) -> ~P /\ ~Q.
unfold not.
intros H.
constructor.
- intro p.
apply H.
left.
apply p.
- intro q.
apply H.
right.
apply q.
Qed.
These lemmas suffice to the show:
Theorem excluded_middle_irrefutable: forall (P:Prop), ~~(P \/ ~ P).
intros P H.
apply lma' in H.
apply lma in H.
apply H.
Qed.

How many possible assignments does a a CNF sentence have?

I'm having some trouble understanding the following:
When we look at satisfiability problems in conjunctive normal form, an underconstrained problem is one with relatively few clauses constraining the variables. For eg. here is a randomly generated 3-CNF sentence with five symbols and five clauses.
(Each clause contains 3 randomly selected distinct symbols, each of which is negated with 50% probability.)
(¬D ∨ ¬B ∨ C) ∧ (B ∨ ¬A ∨ ¬C) ∧ (¬C ∨ ¬B ∨ E) ∧ (E ∨ ¬D ∨ B) ∧ (B ∨ E ∨ ¬C)
16 of the 32 possible assignments are models of this sentence, so, on an average, it would take just 2 random guesses to find the model.
I don't understand the last line- saying that there are 32 possible assignments. How is it 32? And how are only 16 of them models of the sentence? Sorry, but i'm finding this concept a bit confusing. Thanks.
There are 2^5=32 possible assignments of the two values true and false to 5 variables:
1: 00000
2: 00001
3: 00010
...
31: 11110
32: 11111
16 of those assignments satisfy (I didn't check) the given formula, thus are models of it.

Proving the Associativity of OR

I need help proving the following:
(a ∨ b) ∨ c = a ∨ (b ∨ c)
I don't want the answer... just a hint that will help me understand the process of proving this.
Thank you.
Why not just prove it by doing all possible values of a, b and c = True, False? -- there are only 2^3 = 8 different cases.
Here's a start, for a=T, b=F, c=T
(a v b) v c = a ∨ (b ∨ c)
(T v F) v T = T v (F v T)
T v T = T v T
T = T
(However, this isn't really a programming question...)
What is your axiom set?
Not knowing the set, you could build a truth table

Resources