MTH 225 Lecture-Module #02:
Basics of Symbolic Logic


how can we really know that some given code/algorithm/scheme really works / is correct?
should do  for the given code/algorithm/scheme



symbolic logic intended for careful reasoning
about correctness of material

also used significantly in Databases
e.g. see textbooks used for Database courses required for CS,IS
    Database queries use "AND", "EXISTS"

also to inculcate rigorous reasoning: doing sound inferences with clear bases


Section 1.1 of our textbook presents the material of this Lecture-Module

propositions

logic formulas are constructed starting with basic 'atomic' propositions
which are statements that are

e.g.:


incidentally, instead of "f"/"t", you might see numeric representations
    for false,  for true

also incidentally, the restriction "not both" = 
derived partly from history of mathematics, logic Russell Whitehead
CS came out of Math ...
contrast fuzzy logic Lotfi Zadeh very useful applications

general logical operators/connectives

anyway, with atomic propositions
we build  a.k.a. propositional formulas
as expressions using atomic propositions and then further constructed formulas
via grouping delimiters — i.e. parentheses/brackets — and  operators a.k.a.  which are as follows:
1.
math:   "‾" / "¬" / "~"
Engl.:  
Java:   
applies to one operand formula, which I call , as follows:
  ¬ negand
e.g.:  ¬ (s1.equals(s2))    // Java:  
e.g.:  ¬ done               // Java:  
e.g.:  ¬ (x < y)            // Java:  

2.
math:   "∧" / "/\"
Engl.:  
Java:   
applies to two operand formulas, called , as follows:
  conjunct1conjunct2
e.g.:  (x < y) ∧ (y < z)                // Java:  
e.g.:  ¬done ∧ (i < n)                  // Java:  
e.g.:  ¬(¬done ∧ i < n) ∧ (c == x)      // Java:  

3.
math:   "∨" / "\/"
Engl.:  
Java:   
applies to two operand formulas, called , as follows:
  disjunct1disjunct2
e.g.:  x<y ∨ x≥y                                     // Java:  
e.g.:  (i<n ∧ a[i]==null) ∨ (¬done ∧ a[i]≠null)      // Java:  
e.g.:  ¬(i<n ∨ a[i]==null) ∧ (¬done ∨ a[i]≠null)     // Java:  

4.
math:   "→" / "⇒" / "-->" / "if-then"
Engl.:  
Java:   
applies to two operand formulas
    called  and 
as follows:
  antecedentconsequent
e.g.:  x<y → x≤y                            // Java:  
e.g.:  (i==n ∨ done) → ((i==n ∧ done) ∨ (¬done ∧ i<n))   // Java:  
e.g.:  ((i==n → done) ∧ (done → i==n)) ∨ ¬done         // Java:  

5.
math:   "↔" / "⇔" / "<-->" / "iff"
Engl.:  
Java:   
applies to two operand formulas as follows:
  formula1formula2
e.g.:  (x<y) ↔ (y>x)                   // Java:  
e.g.:  ¬(x<y ∧ y<z) ↔ (¬(x<y) ∨ ¬(y<z))         // Java:  
e.g.:  (¬(x<y) ↔ (x≥z)) → (¬((x<z) ↔ (y=z)) ∧ x>y)    // Java:  

6.
math:   "⊕" / "(+)"
Engl.:  
Java:   
C++:   

    ·
    ·
    ·

the following strings are not formulas:
∧ " ∧ ¬ ¬ ∨ (x < y) ¬ (y < z) "
∧ " ) x≠y ∧ y<z ¬ "
if expression is constructed properly using connectives,
one says it is a 


for representing entire formulas, I use greek letters "φ", "δ", "κ", ...
        possibly subscripted
e.g. I might use φ1 to stand for the entire formula "(¬(x<y) ↔ (x≥z)) → (¬((x<z) ↔ (y=z)) ∧ x>y)"

incidentally, regarding grouping delimiters (parentheses∨brackets),
may write e.g. "¬done ∨  x<y ∧ y≥z" rather than "(¬done) ∨ (i<n ∧ x==result)":
as in algebra/Java with arithmetic expressions such as "- x + y * z",
if parentheses aren't being used to specify order of evaluation of operations,
interpret using  of operators e.g. "*" evaluated before "+"
these precedences of the logical operators here from strongest to weakest are as follows:
  ¬  ∧  ∨  →  ↔
(agreeing with operators which are also clearly in Java:  !  &&  || )
thus "¬done  ∨  i<n ∧ x==result" not interpreted as "¬((done ∨ i<n) ∧ x==result)"
nor "(¬done ∨ i<n) ∧ x==result"
but if desired for clarity may use some parentheses even if they may be technically unnecessary
e.g.: "¬done ∨ (i<n ∧ x==result)" (as Java compiler might suggest ;-)

semantics i.e. interpretations/meanings of compound propositions

when learned Java, learned  i.e. interpretations/meanings for symbols  &&   ||
point of logic is to be precise about everything
so meaning of each operator specified rigorously
via 
which is a table listing possible values of operands
and then resultant values of formulas constructed using operator(s)
as follows:

1.
truth-table for negation:
ν | ¬ν
--+---
t | f   i.e.  ¬t := f
f | t   i.e.  ¬f := t
2.
truth-table for conjunction:
κ1 | κ2 || κ1 ∧ κ2
---+----++---------
t  | t  ||    t    i.e.  t ∧ t := t
t  | f  ||    f    i.e.  t ∧ f := f
f  | t  ||    f    i.e.  f ∧ t := f
f  | f  ||    f    i.e.  f ∧ f := f
intent is connective reflects English interpretation
e.g. if  κ1  stands for " is a ."
    and if  κ2  stands for "This room is ."
is  κ1 ∧ κ2  true? 
"κ1 ∧ κ2" may be interpreted as shorthand for all the English:
" is a , and this room is ."
if necessary, fall back on your Java experience putting a boolean expr. in a context
e.g.  if ( x<y && y<z ) ...

to memorize these 'outputs',
note  κ1∧κ2 :=   generally,
except  κ1∧κ2 :=   when  κ1 := t  and  κ2 := t

3.
truth-table for disjunction:
δ1 | δ2 || δ1 ∨ δ2
---+----++---------
t  | t  ||    t
t  | f  ||    t
f  | t  ||    t
f  | f  ||    f
to memorize these 'outputs',
note  δ1∨δ2 :=   generally,
except  δ1∨δ2 :=   when  δ1 := f  and  δ2 := f

4.
truth-table for implication:
α | κ || α → κ
--+---++-------
t | t ||   t
t | f ||   f
f | t ||   t
f | f ||   t
for understanding of that:
consider the following Java code:
    if ( x < y )
        z = 5;
    System.out.println(z);
and consider the following statement:
  "When
  the value of x is less than y     α
  then                              →
  the output will be 5."            κ
if all that code gets used as it indicates,
then the statement clearly holds true
this is the case where  α  := ,  κ  := ,  α→κ  := 

alternatively, suppose it happens that the value of  x  is less than  y
but then the output isn't 5
then the statement is false
this is the case where  α  := ,  κ  := ,  α→κ  := 
and there would be something very wrong with Java or the system

if the value of  x  is not less than  y  and the output is not  5
can one consider that the statement is still accurate?

this is the case where  α  := ,  κ  := ,  α→κ  := 

what if the value of  x  is not less than  y
but the output is  5  anyway;
can that statement still be considered true?

this is the case where  α  := ,  κ  := ,  α→κ  := 

to memorize these 'outputs' of "",
note  α→κ :=   generally,
except  α→κ :=   when  α := t  and  κ := f

5.
truth-table for biimplication:
φ1 | φ2 || φ1 ↔ φ2
---+----++----------
t  | t  ||    t
t  | f  ||    f
f  | t  ||    f
f  | f  ||    t
intuitively, "φ1 ↔ φ2" means "φ1  has same value as  φ2"
and also "1 → φ2) ∧ (φ2 → φ1)"
and also "1 ∧ φ2) ∨ (¬φ2 ∧ ¬φ1)"

to memorize, note "=="

anyway,
those were truth-tables for five basic connectives ¬, ∧, ∨, →, ↔
with those,
can evaluate any formula constructed with them e.g.  i<n ∧ y≥z → ¬done ∧ ...
when given truth-values of atoms e.g.  (i<n):=, (y≥z):=, done:=, ...
as follows:


at this point actually to simplify matters,
instead of using 'real' atomic boolean expressions such as  i<n  and  y≥z,
I'm going to use just boolean variables such as  done  and  computer_won
in fact I'll use variables with just one-letter names: P, Q, R, P2, Q2, R2, ...
rem. these would be  boolean  variables in Java:
    boolean P, Q, R, P2, Q2, ...;
regarding choosing uppercase "P","Q",... vs. lowercase "p","q",...,
our textbook uses lowercase through Section 1.2 and then uppercase starting in Section 1.3;
I'll use uppercase throughout


(i) first way to do this evaluation is to
replace the atoms with their values and then evaluate sub-formulas using truth-tables for connectives
e.g. formula:  (¬P) ∨ (Q ∧ R)
with  P:=, Q:=, R:=
(¬P ) ∨ (Q  ∧ R )
  :=
(¬) ∨ ()
  :=
() ∨ ()
  :=

another example of evaluation:
values are specified for atoms:  P:=, R:=, Q:=, S:=
(S  → (P  ∧ ¬R ))  ∧  ((P  → (R  ∨ Q )) ∧ S )
  :=
( → ( ∧ ¬))  ∧  (( → ()) ∧ )
  :=
( → ())  ∧  (( → ()) ∧ )
  :=
( → ())  ∧  (() ∧ )
  :=
()  ∧  ()
  :=


this process may be ≈compressed by substituting in the values of the atoms,
and then for each connective writing underneath it the value calculated for it
e.g. doing the preceding examples this way:
(¬P) ∨ (Q ∧ R)
(¬f) ∨ (t ∧ f)


(S → (P ∧ (¬R))) ∧ ((P → (R ∨ Q)) ∧ S)
(t → (f ∧ (¬f))) ∧ ((f → (f ∨ t)) ∧ t)

this way may be more 'compressed' but may be harder to understand


(ii) second way to evaluate a formula when given values of atoms is as follows:
construct a ≈truth-table that has only one row
but additional columns for formula's sub-parts
e.g. for  (¬P) ∨ (Q ∧ R)
with  P:=, Q:=, R:= :


another e.g. for  (P → ¬Q) → Q 
with  P:=, Q:= :



this second method (ii) for evaluating a formula generalizes:
general truth-table for arbitrary formula like that but with rows for all possible values of atomic variables
e.g. for  (P → ¬Q) → Q :


e.g. for  (P ∧ Q) ∧ ¬P :


as shown with these examples,
columns for atomic variables should use standard pattern for "t"s and "f"s

another e.g. for  (¬P) ∨ (Q ∧ R) :


uses of logic connectives

¬, ∧, ∨, NAND∨NOR useful for circuits
↔ standard for comparing
how → useful→ to do deductions — see later

properties ascribed to propositional formulas

  • a propositional formula is called a  or 
    if it is always true
    with propositional formulas, could ≈easily determine this
    by constructing a truth-table
    if the final column for formula is "t t t ...", then always true
    e.g.  ¬P ∨ P
    P || ¬P | ¬P ∨ P
    --++----+--------
    t ||  f |    t
    f ||  t |    t
    
    another example:
    P | Q || P ∧ Q | (P ∧ Q) → P
    --+---++-------+---------------
    t | t ||   t   |          t
    t | f ||   f   |          t
    f | t ||   f   |          t
    f | f ||   f   |          t
    
    significant regarding theorems we may be proving or using later...

  • a propositional formula that is always false is called a 
    e.g. above  (P ∧ Q) ∧ ¬P

  • two propositional formulas are 
    if they have same values when atoms  (P,Q,R,...)  have same values
    i.e. if they have same final truth-table columns
    e.g.  ¬P ∨ Q  equivalent to  P → Q :

    note you need to use standard pattern for "t"s and "f"s for atomic variables
    to be able to check equivalence

    if formula φ1 equivalent to formula φ2,
    write "φ1 ≡ φ2"
    e.g.:    (¬P ∨ Q)  ≡  (P → Q) :

    incidentally,
    φ1 ≡ φ2  holds
    if and only if
    the formula  (φ1 ↔ φ2)  is a tautology


  • given an implication formula ι := "α → κ",
    its  is    κ → α  ,
    its  is    ¬α → ¬κ  ,
    and its  is    ¬κ → ¬α

    contrapositive of ι actually is equivalent to ι
    this is useful for proofs (which we'll be starting ...)

    but values of converse and inverse of ι hardly related to values of ι
    e.g.:
    P | Q || P → Q | Q → P
    --+---++--------+------
    t | t ||   t    |   t
    t | f ||   f    |   t
    f | t ||   t    |   f
    f | f ||   t    |   t
    
    P | Q || P → Q | ¬P | ¬Q | ¬P → ¬Q
    --+---++--------+----+----+--------
    t | t ||   t    | f  | f  |   t
    t | f ||   f    | f  | t  |   t
    f | t ||   t    | t  | f  |   f
    f | f ||   t    | t  | t  |   t
    
    but 'rhetoric' such as advertising, political campaigning sometimes uses converse/inverse
    so you should evaluate claims carefully... (;-)





    summary of this lecture-module


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