P∨Q is true when P or Q or both are true P∧Q is true when both P and Q are true P→Q is true when P is false or Q is true or both P↔Q is true when P and Q are both true, or both false. ¬P is true when P is false.
Note that the notation for negation isn't standardized. ¬p and pˉ are the most common, you might also see ∼p, −p, p′, Np, and !p
The negation of the English sentence "Bob’s smartphone has at least 32 GB of memory” is “Bob’s smartphone does not have at least 32 GB of memory”. This could be rewritten more simply as "Bob's cellphone has less than 32 GB of memory."
Note how in this specific case, "greater than or equal to 32 GB" becomes "less than 32GB" so we go from ≥ to <
P→Q "if P then Q". Often rephrased as P IMPLIES Q.
P is the hypothesis (or antecedent)
Q is the conclusion (or consequent)
An implication is true provided P is false or Q is true (or both), and false otherwise. In particular, the only way for P → Q to be false is for P to be true and Q to be false.
Quadratic Formula - If ax2+bx+c=0anda=, thenx=(−b±b2−4ac)/2a.
The converse of an implication P→Q is the implication Q→P. An example of a true implication and a false converse woul be, "If a shape is a square, then it is a rectangle". Or, "If a number greater than 2 is prime, then that number is odd" (Just because a number is odd does not mean it is prime).
There can be implications that's converse is also true. For example, the pythagorean theorem has a true converse. Is a2+b2=c2, then the triangle with sides a, b, and c is a right triangle.
The contrapositive of an implication P→Q is the statement ¬Q→¬P. An implication and its contrapositive are logically equivalent. The contrapositive can be helpful in deciding whether an implication is true: often it is easier to analyze the contrapositive.
If an implication and its converse are true, we say that P and Q are equivalent and write P↔Q ( the biconditional).
Example: Given an integer n, it is true that n is even if and only if n2 is even. That is, if n is even, then n2 is even, as well as the converse: if n2 is even, then n is even.
Scratchwork: We can factor −x3+4x to get −x3+4x=x(2−x)(2+x) .For x between 0 and 2, all the terms on the right side are nonnegative. We can organize our observations into a formal proof.
Proof: Assume 0≤x≤2. Then, x, 2−x, and 2+x are all nonnegative. Therefore, the product of these terms is also nonnegative. Adding 1 to this product gives a positive number, so:
x(2−x)(2+x)+1>0
Multiplying out on the left side proves that
−x3+4x+1>0
as claimed. ■
Note: Proofs typically begin with the word "Proof" and end with some sort of delimiter like □, ■, or "QED".
Theorem: If two numbers a and b are even, then their sum a+b is even. Proof: Assume the numbers a and b are even. This means that a=2k and b=2j for some integers j and k. The sum is then a+b=2k+2j=2(k+j). Since k+j is an integer, this means that a+b is even. ■
Notice we just assume P is true and repeatedly ask and answer the question, "What does that mean?". Eventually we conclude that it means the conclusion.
Propositional logic and its rules can be used to design computer circuits, to construct computer programs, to verify the correctness of those programs, and to solve many familiar puzzles. Software systems based on the rules of logic have been developed for constructing some, but not all, types of proofs automatically
A compound proposition that is always true, no matter the truth values of the propositional variables that occur in it, is a tautology. A compound proposition that is always false is a contradiction.
Below, we show that ¬(p→q) and p∧¬q are logically equivalent.
¬(p→q)≡¬(¬p∨q)≡¬(¬p)∧¬q≡p∧¬qconditional-disjunction equivalenceDe Morgan lawdouble negation law
Another example, we show that ¬(p∨(¬p∧q)) and ¬p∧¬q are logically equivalent by developing a series of logical equivalences.
¬(p∨(¬p∧q))≡¬p∧¬(¬p∧q)≡¬p∧[¬(¬p)∨¬q]≡¬p∧(p∨¬q)≡(¬p∧p)∨(¬p∧¬q)≡F∨(¬p∧¬q)≡(¬p∧¬q)∨F≡¬p∧¬qsecond De Morgan lawfirst De Morgan lawdouble negation lawsecond distributive lawbecause¬p∧p≡Fby the commutative law for disjunctionby the identity law for F
A compound proposition is satisfiable if there exists an assignment of truth values to its variables that makes it true (when its a tautology or contingency).
When a compound proposition is false for all assignments of truth values to its variables, it is unsatisfiable.
(p∨¬q)∧(q∨¬r)∧(r∨¬p)∧(p∨q∨r)∧(¬p∨¬q∨¬r) is an example of unsatisfiable. For it to be true, both (p∨¬q)∧(q∨¬r)∧(r∨¬p) and (p∨q∨r)∧(¬p∨¬q∨¬r) must both be true. But for the former, all three variables must have the same truth variable and for the latter at least one must be true and one must be false. This is a contradiction, so we can conclude that there does not exist an assignment of truth variables that makes the compound proposition true.
Many problems in diverse areas such as robotics, software testing, artificial intelligence planning, computer-aided design, machine vision, integrated circuit design, scheduling, computer networking, and genetics, can be modeled in terms of propositional satisfiability.
The n queens problem asks for a placement of n queens on an n×n chessboard so that no queen can attack another queen. This means that no two queens can be placed in the same row, column, or diagonal to one another.
(ith row jth column, starting from top left square)
To model this as a satisfiability problem, we introduce n2 variables p(i,j) for i=1,2,…,n and j=1,2,…,n. For a given placement of a queens on the chessboard, P(i,j) is true when there is a queen on the square in the ith row and jth column, and is false otherwise.
Note that squares (i,j) and (i′,j′) are on the same diagonal if either i+i′=j+j′ or i−i′=j−j′. Note in the picture above of our chessboard, p(6,2) and p(2,1) are true, and p(3,4) and p(5,4) are false.
For no two of the n queens to be in the same row, there must be one queen in each row. We can show that there is one queen in each row by verifying that every row contains at least one queen and that every row contains at most one queen.
We note that ⋁j=1np(i,j) asserts that row i contains at least one queen, and
Q1=i=1⋀nj=1⋁np(i,j)
asserts that every row contains at least one queen.
For every row to include at most one queen, it must be the case that p(i,j) and p(k,j) are not both true for integers j and k with 1≤j<k≤n. Observe that ¬p(i,j)∨¬p(i,k) asserts that at least one of ¬p(i,j) and ¬p(i,k) is true, which means that at least one of p(i,j) and p(i,k) is false. So to check that there is at most one queen in each row, we assert
Q2=i=1⋀nj=1⋀n−1k=j+1⋀n(¬p(i,j)∨¬p(k,j))
To assert that no column contains more than one queen, we assert that
Q3=j=1⋀ni=1⋀n−1k=i+1⋀n(¬p(i,j)∨¬p(k,j))
(This assertion, together with the previous assertion that every row contains a queen, implies that every column contains a queen.)
To assert that no diagonal contains two queens, we assert
The innermost conjunction in Q4 and in Q5 for a pair (i,j) runs through the positions on a diagonal that begin at (i,j) and runs rightward along this diagonal. The upper limits on these innermost conjunctions identify the last cell in the board on each diagonal.
Putting this all together, the solution to the n queens problem are the assignments of truth values to the variables p(i,j) for i=1,2,…,n and j=1,2,…,n that make
Q=Q1∧Q2∧Q3∧Q4∧Q5
true.
So to recap: Q1 is a conjunction of disjunctions which require for every row there is at least one queen.
The rest of the constraints are forbidding pairs of queens from being placed at certain locations. Q2 is forbidding placing two queens in the same row. That is, we for forbid p(i,j)∧p(i,k) for any i, j, k and j<k.
Q3 is to forbid placing two queens in the same column. This condition p(i,j)∧p(k,j) for i<k.
Q4 and Q5 are to forbid placing two queens in the same forward and backward diagonal respectively.
Sudoku is a number puzzle that consists of a n2×n2 grid for any positive integer n, with the n2×n2 grid made up of n2n×n subgrids. Some of the cells in the grid are assigned one of the numbers 1,2,3,...,n2
and all the other cells are blank. The puzzle is solved by assigning a number to each blank cell so that every row, column, and n×n subgrids contains each of the n2 numbers.
To encode sudoku as a constraint satisfaction problem, we let p(i,j,n) denote the proposition that is true when number n is in the ith row and jth column.
Then we construct the following compound propositions:
Every row contains every number
i=1⋀9n=1⋀9j=1⋁9p(i,j,n)
Every column contains every number
j=1⋀9n=1⋀9i=1⋁9p(i,j,n)
Every n×n block contains every number
r=0⋀2s=0⋀2n=1⋀9i=1⋁3j=1⋁3p(3r+i,3s+j,n)
Each cell contains no more than 1 number
(We take the conjunction over all valeus of n, n′, i, and j, where each variable ranges from 1 to n2 and n=n′ of p(i,j,n)→¬p(i,j,n′)
The puzzle is solved by finding an assigment of truth values for each of the proposition p(i,j,n) that make the conjunction of our compound propositions true.
For n=3 for example (a 9×9 grid, the most common sudoku configuration), there are 729 such propositions.
To construct the assertion that every row contains every number (in this case, n=3):
Assert that row i contains the number k
j=1⋁9p(i,j,k)
Assert row i contains all n numbers, we form the conjunction of the above disjunctions over all possible values of k.
k=1⋀9j=1⋁9p(i,j,k)
Finally, to assert every row contains every number, we take the conjunction of ⋀k=19⋁j=19p(i,j,k) over all nine rows. This gives us
Use the different forms of logical equivalences to replace sections of a statement. Keep making replacements until the proposition we start with is the one we want to compare equality of.
∼(∼p∧q)∧(p∨q)≡(∼(∼p)∨∼q)∧(p∨q)≡(p∨∼q)∧(p∨q)≡(p∨(∼q∧q)≡p∨(q∧∼q)≡p∨c≡pby De Morgan’s lawsby the double negative lawby the distributive lawby the commutative law for ∧by the negation lawby the identity law