------------------------------------------------------------ should do | reasoning/proving/logic | for the given code/algorithm/scheme ------------------------------------------------------------ either false (f) or true (t) but not both ------------------------------------------------------------ "November 2, 2005 is a Thursday." "At line 23 in this program, x is -2." "My program runs faster than yours." "Greased Lightning will win the race tomorrow." ? "This sentence is false." ?? "What time is it?" ?? ------------------------------------------------------------ | 0 | for false, | 1 | for true ------------------------------------------------------------ also incidentally, the restriction "not both" = | law of excluded middle | ------------------------------------------------------------ we build | compound propositions | a.k.a. propositional formulas ------------------------------------------------------------ | logic | operators a.k.a. | connectives | which are as follows: ------------------------------------------------------------ Engl.: | not / negation | ------------------------------------------------------------ Java: | ! | ------------------------------------------------------------ applies to one operand formula, which I call | negand | , as follows: ------------------------------------------------------------ e.g.: ! (s1.equals(s2)) // Java: | ! (s1.equals(s2)) | ------------------------------------------------------------ e.g.: ! done // Java: | !done | ------------------------------------------------------------ e.g.: ! (x < y) // Java: | !(x < y) | ------------------------------------------------------------ Engl.: | and / conjunction | ------------------------------------------------------------ Java: | && / & | ------------------------------------------------------------ applies to two operand formulas, called | conjuncts | , as follows: ------------------------------------------------------------ e.g.: (x < y) * (y < z) // Java: | (x < y) && (y < z) | ------------------------------------------------------------ e.g.: !done * (i < n) // Java: | !done && (i < n) | ------------------------------------------------------------ e.g.: !(!done * i < n) * (c == x) // Java: | !(!done && i < n) && (c == x) | ------------------------------------------------------------ Engl.: | or / disjunction | ------------------------------------------------------------ Java: | || / | | ------------------------------------------------------------ applies to two operand formulas, called | disjuncts | , as follows: ------------------------------------------------------------ e.g.: x=y | ------------------------------------------------------------ e.g.: (ix) &/&/ Java: | (xx) | ------------------------------------------------------------ e.g.: !(xy) &/&/ Java: | see an exercise (;-) | ------------------------------------------------------------ Engl.: | exclusive or / exclusive disjunction | ------------------------------------------------------------ Java: | ^ | ------------------------------------------------------------ C++: | ^ / xor | ------------------------------------------------------------ one says it is a | well-formed formula (WFF) | ------------------------------------------------------------ interpret using | precedences | of operators e.g. "|&*|" evaluated before "|+|" ------------------------------------------------------------ when learned Java, learned | semantics | i.e. interpretations&/meanings ------------------------------------------------------------ via | truth table | ------------------------------------------------------------ e.g. if |C1| stands for " | November 2, 2005 | is a | Thursday | ." ------------------------------------------------------------ and if |C2| stands for "This room is | MAK 1107 | ." ------------------------------------------------------------ is |C1 ∧ C2| true&? | no, it's false | ------------------------------------------------------------ " | November 2, 2005 | is a | Thursday | , and this room is | MAK 1107 | ." ------------------------------------------------------------ note |C1*C2 := | f | | generally, ------------------------------------------------------------ except |C1*C2 := | t | | when |C1 := t| and |C2 := t| ------------------------------------------------------------ note |D1/D2 := | t | | generally, ------------------------------------------------------------ except |D1/D2 := | f | | when |D1 := f| and |D2 := f| ------------------------------------------------------------ this is the case where |A| := | t | , |C| := | t | , |A?C| := | t | ------------------------------------------------------------ this is the case where |A| := | t | , |C| := | f | , |A?C| := | f | ------------------------------------------------------------ | yes | ------------------------------------------------------------ this is the case where |A| := | f | , |C| := | f | , |A?C| := | t | ------------------------------------------------------------ | yes, |z| could be |5| already | ------------------------------------------------------------ this is the case where |A| := | f | , |C| := | t | , |A?C| := | t | ------------------------------------------------------------ note |A?C := | t | | generally, ------------------------------------------------------------ except |A?C := | f | | when |A := t| and |C := f| ------------------------------------------------------------ e.g. |(i !Q | (P -> !Q) -> Q --+---++----+---------+--------------- t | f || t | t | f ------------------------------------------------------------ P | Q || ~Q | P -> ~Q | (P -> ~Q) -> Q --+---++----+---------+--------------- t | t || f | f | t t | f || t | t | f f | t || f | t | t f | f || t | t | f ------------------------------------------------------------ P | Q || P /\ Q | ~P | (P /\ Q) /\ ~P --+---++--------+----+--------------- t | t || t | f | f t | f || f | f | f f | t || f | t | f f | f || f | t | f ------------------------------------------------------------ P | Q | R || ~P | Q /\ R | ~P \/ (Q /\ R) --+---+---++----+--------+--------------- t | t | t || f | t | t t | t | f || f | f | f t | f | t || f | f | f t | f | f || f | f | f f | t | t || t | t | t f | t | f || t | f | t f | f | t || t | f | t f | f | f || t | f | t ------------------------------------------------------------
  • a propositional formula is called a | tautology | or | valid | ------------------------------------------------------------
  • a propositional formula that is always false is called a | contradiction | ------------------------------------------------------------
  • two propositional formulas are | logically equivalent | ------------------------------------------------------------ P | Q || ~P | (~P) \/ Q --+---++----+---------- t | t || f | t t | f || f | f f | t || t | t f | f || t | t ------------------------------------------------------------ its | converse | is |κ → α| , ------------------------------------------------------------ its | inverse | is |¬α → ¬κ| , ------------------------------------------------------------ and its | contrapositive | is |¬κ → ¬α| ------------------------------------------------------------ atomic propositions, truth-values logical connectives /\ \/ ~ --> (...) their truth tables evaluation of formulas truth tables of general formulas terminology: equivalence, converse, contrapositive ------------------------------------------------------------ ====================================================================


    (Copyright © 2009 by Hugh McGuire   — for thoughts about this, see   http://www.cis.gvsu.edu/~mcguire/teaching/copyright_thoughts.html .)