Let's say that we get a table with zeros and ones. We need to get it into disjunctive normal form or conjuctive normal form. We also have discrete variables $x_1,..,x_n$ that are either $1$ or $0$. How do you determine where to put negation and where not to put it.
for instance: we have a row: $$p = 0, q= 1, r = 0, \quad \text{table row result = 1}$$
Should I write this as: $$...\vee(\neg p \wedge q \wedge \neg r) \vee ...$$ or $$...\wedge(\neg p \vee q \vee \neg r) \wedge ...$$
What is the correct way ? What if the table row result would be zero?
Or the other way with negations? So my question is how do we know where the negations are?
When you are looking for a DNF, you focus on all rows where the table result is a $1$, and you generate a conjunction for that row exactly the way you did, and than you disjunct together all those conjunctions into one big disjunction.
On the other hand, when looking for a CNF, you focus on all the rows where the result is a $0$, and now you generate a disjunction that is equivalent to the negation of the conjunction you would have gotten normally. That is, if with your example of $p =0, q=1, r=0$ and table result $=0$, you would create the term $p \lor \neg q \lor r$. Finally, conjunct together all those disjunctions to get the CNF
Example:
\begin{array}{cc|c} p &q&f(p,q)\\ \hline 1&1&1\\ 1&0&0\\ 0&1&1\\ 0&0&0\\ \end{array}
DNF: focus on rows 1 and 3, and that gives you $(p \land q) \lor (\neg p \land q)$
CNF: focus on rows 2 and 4, and now you get $(\neg p \lor q) \land (p \lor q)$