0% found this document useful (0 votes)
28 views3 pages

1 What Is Logic in Computer Science?

This document provides an overview of the first lecture for the course CS 2742 (Logic in Computer Science). It introduces the topic of logic in computer science and explains why mathematical logic is studied instead of natural languages. Some key applications of logic in computer science are also listed. The remainder of the document focuses on propositional logic, defining basic concepts like propositions, propositional variables, logical connectives, and truth tables. It provides examples of how propositions can be combined using logical connectives to form more complex propositional formulas.

Uploaded by

ZhichaoWang
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)
28 views3 pages

1 What Is Logic in Computer Science?

This document provides an overview of the first lecture for the course CS 2742 (Logic in Computer Science). It introduces the topic of logic in computer science and explains why mathematical logic is studied instead of natural languages. Some key applications of logic in computer science are also listed. The remainder of the document focuses on propositional logic, defining basic concepts like propositions, propositional variables, logical connectives, and truth tables. It provides examples of how propositions can be combined using logical connectives to form more complex propositional formulas.

Uploaded by

ZhichaoWang
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/ 3

CS 2742 (Logic in Computer Science)

Lecture 1
Antonina Kolokolova
Sep 8th, 2011

What is logic in Computer Science?

Why do we study mathematical logic? Natural languages (such as English) are too ambiguous:
Every student knows this and Any student knows this have the same meaning.
Shed be happy if she passes every course and Shed be happy if she passes
any course mean very different things.
Mathematical logic is a kind of language, where everything is designed to have a precise
meaning. This is the language of unambiguous reasoning. So this course is somewhat like
a foreign language course: there will be a lot of vocabulary to memorize. Also, like in a
language course, you need to practice speaking logic language for it to become natural.
Logic comes into computer science in many different ways:
Digital circuit logic
Proof of correctness of programs, verification
Automated reasoning in artificial intelligence

The material in this set of notes came from many sources, in particular Discrete mathematics with
applications by Susanne Epp, several books by Raymond Smallian, course notes of U. of Toronto CS 238
by Vassos Hadzilacos.

Database query languages


...
We will try to cover, briefly, at least some of these applications.

Propositional logic

The basic unit of our reasoning is a sentence that can have a truth value, that is it can be
either true or false. We call such a sentence a proposition. For example, it is raining is
a proposition. It is true or false at any particular point in time and space. So is I am a
dolphin (which happens to be false, as far as I know), or 2 is a prime number. When
referring to a proposition, we often will give it a short name (a variable); for example, we
can use a variable p to denote the sentence it is raining. Now, if we say p is true we will
mean that it is, indeed, raining. Such variables denoting propositions are called propositional
variables. A propositional variable can have a truth value of exactly one of true or false.
Simple propositions can be combined. For example, we can say if it is raining, then it must
be cloudy. Here, we mean that raining (that is, our proposition p) implies that it is also
cloudy. If we use a propositional variable q to mean it is cloudy then in the language of
propositional logic we say that p implies q. Implication is one of logical connectives that
allow us to make more complicated statements, propositional formulas, out of propositions.
The following table lists several common logical connectives.
Meaning
both p and q are true
at least one of p, q is true
opposite of p is true
if p is true then q is true

Name
conjunction
disjunction
negation
implication

Notation
pq
pq
p
pq

Pronunciation
p and q
p or q
not p
p implies q

We will also use logical connectives (p q is p only if q, where if q is true then p must
also be true) and meaning that p and q are either both true or both false, p if and only if
q (sometimes pronounced as p iff q). Note that the last one has the meaning opposite to
the exclusive-OR ; we would not be using much.
Instead of p and q we could have whole propositional formulas which are themselves made
out of propositions, logical connectives and parentheses (to specify what logical connectives
apply to). For example, if we denote I am a dolphin by a propositional variable r, then
the following is a propositional formula: (p q) r, which reads as It is not raining or it
is cloudy and, besides, I am a dolphin. Here, the precedence order is first , then , then
, and then : that is, q p q r is parenthesized as (q) ((p) (q r)). It
may help to think of , and as unary , and + in arithmetic formulas: we will show
2

in this course that there is a deep connection between them. So parenthesizing p q r is


just like parenthesizing 5 + 3 8.
Note that or in mathematical logic has a bit different meaning from English either/or:
here, both propositions can be true, whereas in English we often mean or as an exclusive:
either the first one is true, or the second, but not both. For example, it is raining or I am
a dolphin is a perfectly valid propositional formula which is true if either it is raining, or I
am a dolphin, or both it is raining and I am a dolphin.
Similarly, the implication is only false if its left hand side (i.e., p) is true while the right hand
side (q) is false. That is, if it is raining then it is cloudy is false only when it is raining
out of blue sky. If it is not raining this propositional formula is true no matter whether it is
cloudy or not.
One way to think of the implication p q is to consider all possible scenarios for the values
of p and q. If both p and q are true, then p q is true. If p is true and q is false, then p q
is false. Finally, if p is false then p q is true both when q is true and when q is false.
We will talk later that some of the logical connectives here are redundant: we can express
the same functionality as p q, for example, using just and . So p q is false only
when p is true and q is false, that is, when p q is true. Then saying (p q) will be false
when p is true and q is false, and true everywhere else, just like p q. As an example, think
of saying if it rains it must be cloudy as having the same meaning as it cant happen that
both its not cloudy and raining.
Puzzle 1 (Twins puzzle) There are two identical twins, John and Jim. One of them
always lies, another always says the truth. Suppose you run into one of them and want to
find out whether you met John or Jim. Which 3-word question with a yes/no answer should
you ask to learn the name of the twin in front of you? You dont know which one of them
is the liar.

You might also like