0% found this document useful (0 votes)
62 views11 pages

LOGIC CH 1 and 2

The document discusses the role of logic in computer science. It explains that logic is used to formally model situations encountered in computer science so they can be reasoned about rigorously. Some applications of logic in computer science include expert systems, knowledge-based software, semantic web development, and formal specification and verification of software. The document also covers propositional logic, explaining that propositions can be combined using logical connectives like negation, conjunction, disjunction, implication and biconditional. It defines tautologies and contradictions and their usage in proving the validity of arguments.

Uploaded by

habte
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views11 pages

LOGIC CH 1 and 2

The document discusses the role of logic in computer science. It explains that logic is used to formally model situations encountered in computer science so they can be reasoned about rigorously. Some applications of logic in computer science include expert systems, knowledge-based software, semantic web development, and formal specification and verification of software. The document also covers propositional logic, explaining that propositions can be combined using logical connectives like negation, conjunction, disjunction, implication and biconditional. It defines tautologies and contradictions and their usage in proving the validity of arguments.

Uploaded by

habte
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

University of Gondar

Faculty of informatics
Department of computer science
UOG, Logic in Cs Handout for 3rd Year CS Regular Students
Academic Year: 2014 E.C.
Chapter one
LOGIC
Scientists often gather data for observation, investigation and conducting experiments on it. So if
they are really satisfied with data, scientists may want to draw conclusion from those data to
show that a certain feature is right and others are wrong. To understand science then it would be
important to understand when and how to draw a specific conclusion from we already know. We
need to understand the difference between good and bad arguments, then the study of
argumentation is called logic.so logic is all about reasoning to identify what is good and bad in
the real world. There are lots of different logics:
 Probabilistic Logic – for reasoning about probability.
 Temporal Logic – for reasoning about time (and programs).
 Epistemic Logic – for reasoning about knowledge.

Aim of logic in computer science


 In computer science, we design and study systems through the use of formal
languages that can themselves be interpreted by a formal system.
 For example:-
 Boolean Circuits
 Programming Language
 Design Validation and Verification
 Artificial Intelligence (AI)
 Security
 Etc.
The aim of logic in computer science is to develop languages to model the situations we encounter
as computer science professionals, in such a way that we can reason about them formally.

1
Reasoning about situations means constructing arguments about them; we want to do this formally,
so that the arguments are valid and can be defended rigorously, or executed on a machine.
Applications of logic in computer science
Logic in computer science covers the overlap between the field of logic and that of computer
science. It has undoubtable importance in the following areas:-
 Expert Systems
 Knowledge Based Software Assistant
 Semantic Web development
 Formal Specification and Verification of Software
 Formal Specification of Data Structures
 Logic Programming and Deductive Databases
 Knowledge Representation and Common sense Reasoning.
Propositional logic
Logic can be used to represent and assess many of our most common patterns of reasoning and
rational thought using sentences commonly called statements or propositions. So a proposition in
logic is a declarative sentence that is either True or False, but not both.
For example, "Grass is green", and "2 + 5 = 5" are propositions.
The first proposition has the truth value of "true" and the second "false". But "Close the door", and
"Is it hot outside ?"are not propositions. Also "x is greater than 2",where x is a variable representing
a number, is not a proposition, because unless a specific value is given to x we can not say whether
it is true or false, nor do we know what x represents.
Simple statements which are true or false are basic propositions. Larger and more complex
propositions are constructed from basic propositions by combining them with connectives.
Thus propositions and connectives are the basic elements of propositional logic. Though there
are many connectives, we are commonly using the following five basic connectives.

NOT, AND, OR, IF_THEN (or IMPLY), IF_AND_ONLY_IF. They are also denoted by
the symbols: , , , , , respectively.

2
 Negation(NOT) – If p is a proposition, then the negation of p is denoted by , ~p ,which
when translated to simple English means-
“It is not the case that p” or simply “not p“.
The truth value of ~p is the opposite of the truth value of p .
The truth table of ~p is-

P ~P
T F
F T

Example:- The negation of “It is raining today”, is “It is not the case that is raining today”
or simply “It is not raining today”.

 Conjunction – For any two propositions p and q , their conjunction is denoted by p 𝖠 q,which
means “p and q “. The conjunction p 𝖠 q is True when both p and q are True, other wise
False.

The truth table of p 𝖠 q is-

 Disjunction – For any two propositions p and q, their disjunction is denoted by p ∨ q, which
means “ p or q “. The disjunction p ∨ q is True when either p or q is True, other wise False.

3
The truth table of p ∨ q is-

The disjunction of the propositions p – “Today is Friday” and q – “It is raining today”, p ∨ q is
“Today is Friday or it is raining today”. This proposition is true on any day that is a Friday or a
rainy day(including rainy Fridays) and is false on any day other than Friday when it also does not
rain.
 Implication – For any two propositions p and q , the statement “if then ”is called an
implication and it is denoted by p⇒q.In the implication p⇒q, p is called the
hypothesis or antecedet or premise and q is called the conclusion or consequence. The
implication is p⇒q is also called a conditional statement. The implication is false when p is
true and q is false otherwise it is true.
The truth table of p ⇒ q is-

You might wonder that why is p ⇒ q true when p is false. This is because the implication
guarantees that when p and q are true then the implication is true. But the implication does not
guarantee anything when the premise p is false. There is no way of knowing whether or not the
implication is false since p did not happen.
Example,
“If it is Friday then it is raining today” is a proposition which is of the form p ⇒ q. The above
proposition is true if it is not Friday (premise is false) or if it is Friday and it is raining, and it is
false when it is Friday but it is not raining.

4
 Biconditional or Double Implication – For any two propositions p and q , the statement
“p if and only if(iff) q” is called a biconditional and it is denoted by p ⇔ q.

The statement p ⇔q is also called a bi-implication.


The implication is true when p and q have same truth values, and is false otherwise. The
truth table of p ⇔q is-

Example, “It is raining today if and only if it is Friday today.” is a proposition which is of the
form p ⇔q. The above proposition is true if it is not Friday and it is not raining or if it is Friday
and it is raining, and it is false when it is not Friday or it is not raining.
Example, The conjunction of the propositions p – “Today is Friday” and q – “It is raining
today”, p𝖠 q is “Today is Friday and it is raining today”. This proposition is true only on rainy
Fridays and is false on any other rainy day or on Fridays when it does not rain.
Syntax of propositional logic
The “syntax” of a language refers to the “form” of the expressions (words, sentences, etc.).a
expression of propositional logic consists of a sequence of symbols. We distinguish three kinds
of symbols.
 Propositional variables. Commonly one uses Latin letters such as p, q, or r.
 Logical connectives:- non-alphabetic symbols: ¬, 𝖠 , ∨ , and→.
 Punctuation:-only „(‟ and „)‟.
Propositional well-formed formulas
Let P be a set of propositional symbols. We define the set of well-formed formulae over P
inductively as follows. (The term “well-formed formula” is sometimes abbreviated to “WFF”.)
1. An expression consisting of a single propositional symbol is a formula.
2. If α is a formula, then (¬α) is a formula.
3. If α is a formula, β is a formula, then each of (α 𝖠 β), (α ∨ β) and (α → β) is a formula.

5
Chapter two

Tautologies & contradiction


From given statements, we can use these logical connectives to form more intricate statements.
For example, the statement (P v Q) 𝖠 Q v R) is a statement formed from the given statements
P,Q,and R and the logical connectives (or ,and). We call (P v Q) 𝖠 (P v R) a compound statement.
More generally, a compound statement is a statement composed of one or more given statements
(called component statements in this context) and at least one logical connective. For example, for
a given component statement P, its negation ¬P is a compound statement. A compound statement
S is called a tautology if it is true for all possible combinations of truth values of the component
statements that comprise S. Example:( p→ q) ∨ ( q→ p) is a tautology.

A propositional expression is a contradiction if and only if for all possible assignments of truth
values to its variables its truth value is False.
Example: P Λ ¬ P is a contradiction

P Q ¬p p 𝖠 ¬q
T T F F
T F F F
F T T F
F F T F

Usage of tautologies and contradictions - in proving the validity of arguments; for rewriting
expressions using only the basic connectives.

6
Arguments
The most basic logical inferences are about combinations of sentences, expressed by such frequent
expressions as „not‟, „and‟, „or‟, „if, then‟. Such combinations allow you to describe situations, and
what properties these situations have or lack: something is „not this, but that‟. You could call this
reasoning about „classification‟, and it is the basis of any description of the world. At the same
time, these logical sentence combinations are also fundamental in another sense, as they structure
how we communicate and engage in thought processing. When you disagree with a claim that
someone makes, you often try to derive a consequence (‟if then‟) whose negation („not‟) is easier
to show. Then set of claims that are supported by evidence for reasoning about some situation in
the real world are called arguments in logic.

We can see arguments in action all around us:


In a restaurant, your Father has ordered Fish, your Mother ordered Vegetarian, and you ordered
Meat. Out of the kitchen comes some new person carrying the three plates. What will happen?
We have know this from experience. The waiter asks a first question, say “Who ordered the
meat?”, and puts that plate. Then he asks a second question “Who has the fish?”, and puts that
plate. And then, without asking further, he knows he has to put the remaining plate in front of your
Mother. What has happened here?
Starting at the end, when the waiter puts the third plate without asking, you see a major logical act
„in broad daylight‟: the waiter draws a conclusion. The information in the two answers received
allows the waiter to infer automatically where the third dish must go.

Consider the following statement from your doctor:


If you take my medication, you will get better.
But you are not taking my medication.
So, you will not get better.
Here the word „so‟ (or „therefore‟, „thus‟, etc.) suggests the drawing of a conclusion from two
pieces of information: traditionally called the „premises‟. We call this an act of inference. Now, as
it happens, this particular inference is not compelling. The conclusion might be false even though
the two premises are true. You might get better by taking that greatest medicine of all (but so hard
to swallow for modern people).so there may be some condition to be the conclusion is false even

7
though we have a true premises, such logical conditions are assessed or evaluated by defining
validity and strength of arguments.

Validity of Arguments
"Validity" and "strength" are technical terms that logicians and philosophers use to describe the
logical "glue" that binds premises and conclusions together. Valid arguments have the strongest
logical glue possible.
An argument is VALID if it has the following hypothetical or conditional property:
 If All the premises are true, then the conclusion cannot be false.
 It is logically impossible for the premises to be true and the conclusion false.
 The truth of the premises guarantees the truth of the conclusion.
Consider the following example.
1. All actors are robots.
2. Tom Cruise is an actor.
Therefore, Tom Cruise is a robot.

In this case in a hypothetical world where all actors are robots, and Tom Cruise also happens to
be an actor, then it's logically impossible for Tom Cruise NOT to be a robot.
Here's an example of an INVALID argument:

1. All actors are robots.


2. Tom Cruise is a robot.
Therefore, Tom Cruise is an actor.

The first premise is the same, "All actors are robots". But the second premise is different. Instead
of assuming that Tom Cruise is an actor, we're assuming that Tom Cruise is a robot.Now, if these
premises are both true, does it follow that Tom Cruise HAS to be an actor? No, it does not follow.
It would follow if we said that ONLY actors are robots, but the first premise doesn't say that.

8
All we can assume is that in this hypothetical world, anyone in the acting profession is a robot,
but robots might be doing lots of different jobs besides acting. They might be mechanics or
teachers or politicians or whatever. So in this hypothetical world the fact that Tom Cruise is a
robot doesn't guarantee that he's also an actor. And THAT is what makes this an invalid
argument.

An argument is INVALID just in case it's NOT VALID.

What this means is that even if all the premises are true, it's still possible for the conclusion to
be false. The truth of the premises doesn't guarantee the truth of the conclusion.That's ALL it
means to call an argument "invalid".

9
Inference rules:
In logic, a rule of inference, inference rule or transformation rule is a logical form consisting
of a function which takes premises, analyzes their syntax, and returns a conclusion
(or conclusions). The following are common rules that we use to infer some conclusion from the
premises.

Rule of inference Tautology Name


pq
p [ p  ( p  q)]  q Modus ponens
q
q
pq [q  ( p  q)]  p Modus tollen
p
pq
qr [( p  q)  (q  r)]  ( p  r) Hypothetical syllogism
pr
pq
p (( p  q)  p)  q Disjunctive syllogism
q
P
p  ( p  q) Addition
pq
pq
( p  q)  p Simplification
p
P
q (( p)  (q))  ( p  q) Conjunction
pq
pq
p  r [( p  q)  (p  r)]  ( p  r) Resolution
q  r

10
Proofing validity of arguments using truth table

We can check validity of arguments using truth table by


1. Constructing a truth table for the premises and the conclusion.
2. Find the rows in which all the premises are true (critical rows).
3. Check the conclusion of all critical rows
a. If in each critical row, the conclusion is true, then the argument is valid.
b. If there is a raw in which the conclusion is false, then the argument is invalid.

Exercise. Check the validity of the following argument using truth table

1. p→q 2. p → (q ∨ ~ r)
~p q → p ˄r
~p p→r

11

You might also like