You are on page 1of 11

CS498MV: Logical Foundations of Computer Science

Mahesh Viswanathan
vmahesh@cs.uiuc.edu
3232 Siebel Center
Spring 2012

Overview of Course Material

1.1

Introduction

Logic
Contrariwise . . . if it was so, it might be; and if it were so, it would be; but as it isnt, it aint.
Thats logic.
Lewis Carroll

Logic is the science of valid inference


It is a formal language (with precise meaning) to describe sets of objects, and valid reasoning
principles to argue about sentences in the formal language.

1.2

Main Strands of Class

Computer Science: A Birds Eye View


Computational Problem Does an input belong to a set?
Goal
Design algorithms/heuristics to solve problem efficiently
Understand what resources (memory/time/. . .) are necessary to solve the problem
Central Themes
Theme I
Computational problems can be solved by formulating them in logic and using its decision procedures
Theme II
Computational resources needed to solve a problem are intimately tied to the richness of a language
needed to specify it
Learning Goals
Mathematical and logical maturity
Principles of formal reasoning
Logic as the foundation of computer science

Staff, Office Hours, and Resources

Instructional Staff
Instructor: Mahesh Viswanathan (vmahesh)
Office Hours: 2:303:30 on Tuesdays and Thursdays, and by appointment
And you?
Electronic Bulletin Boards
Webpage: wiki.engr.illinois.edu/display/cs498mv/
Textbooks
Prerequisites: All material in CS 173, CS 225 and CS 373. In particular,
Familiarity with expressing properties in propositional logic and first order logic
Basic graph concepts and algorithms
Automata theory
Text-book: None!
Lecture Notes: Available on the web-page after every class
Additional References: See papers and books mentioned on the website

Grading Scheme

Homeworks and Grading


Roughly one homework every 2 weeks: Assigned on Tuesday and due the following Tuesday.
Homework grading done by me and you!
Both you and I will grade each homework
Your Philosophy: Constructive comments on fixing the solution and pointing out flaws
in reasoning
I will regrade to give feedback back to both student and grader

Grading Policy: Overview


Total Grade and Weight
Homeworks: 35%
Grading: 15%
Finals: 50%

A Brief History

Prehistory of Logic
Egyptians discovered empirical facts about geometry
Ancient Greeks: Move from empirical methods to a demonstrative science
Assume certain facts to be true without demonstration
Derive other facts from these using valid reasoning principles
Plato and Aristotle (400300 B.C.E)

Figure 1: Plato

Figure 2: Aristotle
Plato: What is truth? What is the relationship between the assumptions and conclusions of
a valid argument?
4

Aristotle: Syllogisms capturing logical argument


Major premise: All men are mortal. Minor premise: Socrates is a man. Conclusion:
Socrates is mortal.

Modern Logic
Logic evolves to become a mathematical discipline
Constructs, terms, and reasoning are purely symbolic
Rather than abstracting theorems from ordinary language, it constructs theorems through
mechanical methods
Tarski: Truth in a formalized language is a correspondence between a metalanguage and an
object language through an interpretation.

Syntax

5.1

Introduction

The Cat in the Hat

Syntax: The Cat in the Hat


Semantics: the picture

Another Example
Syntax

i+j
i


5

Semantics1

(i+j)!
i!j!

Semantics2 Number of ways of choosing i elements from a set of i + j elements


Turtle Rules
A Simple Programming Language
Syntax Any sequence made up of F , +, and
Examples: F , F + F F + F , F + F F + F + F + F F + F F + F F +
F + F + F F + F
Semantics Interpret symbols as instructions to draw a picture.
F Draw a line by moving forward 1 unit
+ Turn 60 degrees to left
Turn 60 degrees to right
Turtle Programs
F F + F F + F F + F F + F + F + F F + F F + F F + F + F + F F + F

The Koch Curve


The Curve
Start with program F , and repeatedly replace F by F + F F + F (forever)
F F +F F +F F +F F +F +F +F F +F F +F F +F +F +F F +F
...

Figure 3: The Koch Curve

5.2

Propositional Logic

Defining Syntax
Task
Defining syntax involves describing the sequence of symbols that are well formed
Turtle Rules: Any sequence of F , +, and .
Regular Expressions: Rules that describe (syntactically) correct expressions: If r1 and r2 are
regular expressions then so is r1 + r2 , . . .

Propositions
Basic Building Block
Propositions represent declarative sentences that are either true or false
Examples: Springfield is capital of Illinois, 1 + 1 = 2, 2 + 2 = 3
Non-examples: What is it?, Location of robot, x + 1 = 2

Symbols in Propositional Logic


Symbols
Formulas in propositional logic are sequences of symbols, where each symbol is one of the following:
1. An element of the infinite set {p1 , p2 , p3 , . . .} of propositions
2. The symbol called implication
3. The symbol called false
4. The symbols ( and ) called parenthesis

Well Formed Formulas


Formulas
The following are (well formed) formulas (wff) in propositional logic
1. Any proposition pi (by itself) is a wff.
2. is a wff.
3. If A and B are wffs then (A B) is a wff.
(No sequence of symbols, other than those desginated by the above rules, are well-formed.)
Example 1. 3- Examples include p1 , , (p1 p2 ), (((p1 p3 ) (p1 p4 )) p1 ). The
following are not examples of wffs: p1 , , p1

5.3

Notation

Logical Abbreviations
Short-hand
The following are useful macros in writing formulas
Negation A, read as not A, will denote the formula A
Disjunction A B, read as A or B, will denote the formula (A) B
Conjunction A B, read as A and B, will denote the formula (A B).
True >, read as true, will denote the formula or

Notational Simplifications
Notation
We will make the following notational simplifications when writing formulas
The outermost parentheses will be dropped. Thus we will write p3 ( p1 ) instead of
(p3 ( p1 ))
We will sometimes omit subscripts of propositions. Thus we will write p instead of p1 , or q
instead of p2 , r instead of p3 , or s instead of p4 , and so on.
The following precedence of operators will be assumed: , , , . Thus p q r will
mean (((p) q) r)

Semantics

6.1

Truth Valuations

Defining Semantics
Task
The semantics of something describes its meaning
Turtle Rules: F draws a line of 1 unit, + turns 60 degree left, . . .
Regular Expressions: L(r1 + r2 ) = L(r1 ) L(r2 ), . . .

Truth Valuations
Definition 2. There are two truth values: truth and falsity. We denote, truth by 1 and falsity by
0
Definition 3. A (truth) valuation is a function v that assigns truth values to each of the propositions.
The value of a proposition p under valuation v is given by v(p)
Formal Semantics of Propositional Logic
Definition 4. The value of a wff A under valuation v, denoted by v[[A]], is inductively defined as
follows
v[[pi ]] = v(pi )
v[[]] = 0

0 if v[[A]] = 1 and v[[B]] = 0
v[[A B]] =
1 otherwise
Definition 5. 2- The models of wff A are the set of valuations that satisfy A. More precisely,
[[A]] = {v | v[[A]] = 1}

Relevant Propositions
Theorem 6. Let v1 and v2 be truth valuations such that for all propositions p appearing
formula A, v1 (p) = v2 (p). Then v1 [[A]] = v2 [[A]].
Proof. By induction on the structure of A.

p appears in A if it appears syntactically in A.

in

v[[A]]
1
1
0
0

v[[B]]
1
0
1
0

v[[B A]]
1
1
0
1

v[[A (B A)]]
1
1
1
1

Figure 4: Truth table reasoning for A (B A)

6.2

Tautologies

Tautologies
Definition 7. A wff A is a tautology if and only if v[[A]] = 1, for every valuation v.
Example 8. A (B A) is a tautology, for any wffs A and B. This can be seen because
Satisfiability
Definition 9. A formula A is said to be satisfiable if and only if [[A]] 6= .
Example 10. (p q) r is satisfiable because: Consider the valuation v that assigns 1 to every
proposition. Now, v[[p q]] = 1 and v[[(p q) r]] = 1 as well.
Computational Problems
Satisfiability Given a formula A, is A satisfiable?
Validity Given a formula A, is A a tautology?
Algorithms
To check if A, over propositions {p1 , . . . pn }, is satisfiable (is a tautology), compute v[[A]] for every
truth assignment v to the propositions {p1 , . . . pn }.
Running time = O(2n ).
Question: Is this the best algorithm?

6.3

Logical Consequence

Logical Consequence
T
Definition 11. A wff A is said to be logical consequence of set of formulas iff B [[B]] [[A]].
We denote this by |= A. Observe that when = , it means that A is a tautology.
10

v[[A]]
0
1

v[[A]]
1
0

v[[A]]
0
1

Figure 5: Truth table reasoning for A |= A


A
1
1
0
0

B
1
0
1
0

AB
1
0
1
1

A
0
0
1
1

B
0
1
0
1

B A
1
0
1
1

Figure 6: Truth table reasoning for (A B) ((B) (A))


Example 12. A |= A because
Logical Equivalence
Definition 13. A wff A is said to be logically equivalent to B iff [[A]] = [[B]]. We denote this by
A B.
Example 14. A B is equivalent to (B) (A), where A and B are any formulas, because

11

You might also like