Download Session 3. Logic in Language and Digital Circuits

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Quantum logic wikipedia , lookup

Transcript
Session 3. Logic in Language and Digital Circuits
3.1 Introduction
Here we shall explore logic in two orthogonal directions: Digital Circuits and the
Sentences of the English language.
Why should we study “logic” (whatever this is)? Well’ there’s two good reasons. First
the study of the problems of logic by Alan Turing and Alonzo Church has led to the
construction of the computers we so enjoy. Second there is an interest in
programming these computers to (i) explore the idea of automating the process of
human reasoning and (ii) the necessity to “prove” that programs we may write are
correct.
Logic is about “formalizing” our human reasoning processes, to provide a mechanical
system which can reproduce the processes involved in human reasoning, just like the
mechanical system which we use to do a multiplication or long-division, on paper.
3.2 Historical Notes
Leibnitz (1646-1716) had a “dream” of being able to convert the processes by which
we humans reason into a system of mechanical operations which could be executed
with pencil and paper. A complex argument (in words, as you would expect e.g. in a
court of law) could be solved by some series of mechanical operations. Leibnitz’ work
was continued by George Boole who demonstrated that an algebra based on just two
states ‘1’ and ‘0 could provide such operations. At this time mathematics was welldeveloped. It was Frege(1848-1925) who advanced this “dream” who aimed to derive
all of mathematics from principles of pure logical reason. There are more steps,
leading from Hilbert and Russell to Alan Turing, (who accidentally invented our
computers), but we shall stop, in this session, with Frege.
3.3 Basic Concepts of Logic
Logic deals with propositions. These are statements (in English) which communicate
facts, judgements or beliefs. Since beliefs are states of mind, propositions take
representations, in your mind, of the complex states and relationships, and express
these in English sentences.
We use English to express our beliefs as propositions (e.g., “The cat is Black”,
“Holmes and Watson were on the case”), for the purpose of communicating
information between each other. Or else we may form arguments (e.g., “Either
Holmes or Watson was on the case, but not both”. “Holmes was on the case”.
“Therefore Watson was not on the case”).
Unfortunately English is complex, and not all sentences can convey beliefs. E.g., the
sentence “What is your name?” does not, but the sentence “Grass is blue” DOES! (It
may not agree with reality, but it does convey a misinformed belief. Those sentences
in the English language that do convey beliefs are called declarative sentences.
Definition 1. A declarative sentence S is one which is
grammatically correct and can be put in place of x in the
sentence “Is it true that x?” so that the resulting sentence is a
grammatically correct English sentence.
For example, if we take S = < I have a lovely bunch of coconuts>, then “Is it true that
I have a lovely bunch of coconuts” is fine. Therefore S is a declarative sentence.
3.4 Contradictions
These declarative sentences which express our beliefs are not arbitrary: They give a
description of our perceived world as it is, or how we would like it to be. The key here
is the plurality of our beliefs – we do not just hold a single belief (e.g. “basket balls
fall down”) but we have lots of beliefs (“basket balls fall down”, “basket balls
bounce”, “each bounce gets them up to a smaller height”). So we have a system of
beliefs. This system allows us to make decisions and to make predictions. But there is
one restriction. The system of beliefs must be consistent. E.g. it would not be possible
to accept the beliefs “basket balls fall down” AND “basket balls fall up”. That’s a
contradiction. One of the tasks of LOGIC is to decide whether a system of beliefs
(expressed as English sentences) is consistent or inconsistent. Consider the following
system of declarative sentences:
“If Holmes solved the crime then Lestrade took the criminal. If the
criminal escaped, then Lestrade did not take him. On this particular
day, Holmed solved the crime, but Lestrade did not manage to take
him.
Is this system consistent ? In other words, can we say what happened? To Holmes,
Lestrade and the criminal? We shall see!
3.5 Formal Systems – Formalization
Formalization means construction of some language together with rules for
manipulating declarative sentences within that language. That language will not be
dependent on the meaning (i.e. relevance to we Humans) of those sentences, since a
computational system is not “alive” it has no understanding. Think of doing an
arithmetic multiplication line 13 x 26. We all can do this, using pencil and paper. But
we do not need to know that we are buying 13 Kiwi-fruits each costing 26p from
Waitrose on a Friday evening.
3.6 Propositional Calculus
We remarked above that logic concerns a system of declarative sentences. In other
works we are concerned with many sentences, conversations if you like. So we must
have some way of connecting two sentences. These ways are called connectives. You
may not be surprised to learn that the connectives are AND, OR, NOT and IF. (OK
NOT is a bit special – it operates on just one sentence). The logical symbols used in
linguistics are shown here:
English Word
AND
OR
NOT
IF
Logical Symbol


¬

So let’s consider the sentence “Henry was a king and he had two wives”. This can be
written as the connection between two declarative sentences,
<Henry was a king>  <Henry had six wives>
So we can write this connection, starting from the two atomic sentences and ending
with the constructed:
P = <Henry was a king>
Q = <Henry had six wives>
PQ
It’s clear that P  Q means “Henry was a king” AND “Henry had six wives” which is
equivalent to the original sentence “Henry was a king and he had two wives”.
We shall use the symbols tabulated above, together with the brackets “(“ and “)” and a
set of variables P,Q,R,… (representing atomic sentences) to form the alphabet of
propositional logic. We can now give a definition of when a string of symbols in a
declarative sentence or sentences IS a sentence of Propositional Logic:
S is a set of propositional variable is
1. A variable from the set S is a sentence
2. If P and Q are sentences, then so are
a. (¬P)
b. P  Q
c. P  Q
d. P  Q
e. No other strings are sentences
In other words, the NOT, the AND, OR and IF connectives define the grammar of our
logic, together with the variables (P,Q,R,…). The set of characters defined in this way
is called the “set of well-formed sentences” or “language” of propositional logic. So,
for example, “P  Q” is a well-formed sentence, but “P  Q)” is not, because
there’s a “(“ missing.
This is important, since we will need, later to ask the question about a sequence of
symbols, such as “P  Q”, is this a sentence of propositional logic ? This question,
we hope, can be always be answered “yes” or “no”, within this system. To answer this
question, we may proceed in two equivalent ways: (i) we may construct a proof using
our system of logic to decide the issue, or (ii) we may hope to write a computer
program to answer the question, before the program terminates. To write such a
program would be a mammoth task, but once we have written it, we can solve all
problems within this formal system. Without any human effort. We shall have
attained Leibnitz’ “dream!
If you find this question a little odd, you may like to consider a computer compiler
program. If you make a syntax error (such as forgetting a “(“ then you’ll get compile
errors. In other words your program does not belong to the “set of well-formed
programs” and cannot be executed by the computer.
What about meaning (semantics) ? Well, when we write “P= <Henry was a king>”
then we are assigning a value to the variables. Whether or not the sentence <Henry
was a King> has meaning depends on you and I (and everyone else). We must agree
on our mutual understanding of this sentence. For example, if we are both at Hampton
Court, and both point to Henry and say “yep he’s a king” then the sentence P has
meaning.
3.7 Arguments
It turns out that the language we have introduced will allow us to represent, and prove
the validity of arguments, such as this one:
If Socrates is a man, therefore Socrates is mortal.
Socrates is a man.
Therefore, Socrates is mortal.
Similarly, it will allow us to reject false arguments, such as this one:
Socrates is a man.
Therefore Socrates is Mortal.
While this latter argument may seem “obviously true” to you and I, it is not logically
true within our system. Simply, it relies on our implicit understanding of mortality. In
other words, formal logic is intended to judge the validity of arguments by their form
and not by their meaning.
So how do we formalize an argument? Well the first of the Socrates examples above
can be reduced to the formal statements:
If P then Q
P
therefore
Q
It turns out, as we shall discover in class, that this argument can be translated into our
formal language as
((P  Q)  P)  Q
In other words, if “P is true implies Q is true” AND “P is True” THEN it is the case
that Q is true.
The central concept here is that we are only interested in the distinction between
“true” and “false”. Using elementary mathematical algebra, we may end up adding 3
+ 4 to give 7 (without realizing that this calculation is actually being performed by a
shopper who has been asked to buy 3 apples for Fred and 4 for Fredina). So in our
logic we are not concerned with the details of what P and W refer to or “mean”. The
system of logic we build is called truth-functional and the connectives listed above
are known as truth-functors.
The operations of Classical logic, consisting of the truth functors shown above can be
represented as “truth-tables”. I guess you may have encountered these in your study of
digital electronics, but here we suggest the “truth-table” functors have a much wider
zone of application than you have encountered. So here’s the generic truth-tables, set
alongside the digital electronic truth tables you have encountered. There are some
new ones, which we shall discover in our class activities:
P Q P  Q
0 0
0
0 1
0
1 0
0
1 1
1
AND
P
0
0
1
1
OR
Q P Q
0
0
1
1
0
1
1
1
P
0
0
1
1
IF
Q
0
1
0
1
P Q
1
0
1
1
P
0
1
NOT
¬P
1
0
3.8 Completeness
How may of these truth functors do we need to have a complete formal system ? We
have specified four. It turns out, we only need one. The NAND-gate (or the NOR
gate) is sufficient to provide a complete formal system. We’ll discuss this in class.
3.9 Consistency
We shall study a set sentences using a truth-table approach. For example, if we have
three sentences, P,Q,R then our truth table with have 2x2x2 input lines “000”, “001”,
“010”,… “111”. Each of these input lines is called a valuation.
Definition 2. A sentence is called a tautology if the truth table evaluates to
true “1” for all valuations.
Definition 3. A set of sentences is called a consistent if the truth table
evaluates to true “1” for at least one valuation.
We shall study several examples of consistency in the class workshop.
3.10 Soundness and Completeness
We have suggested that there is a logical system in which we can build proofs. But we
should also like to know that this system can (i) only produce theorems which exist
within this system. It’s a sort of closure. For example arithmetic takes “3 + 5” and
gives us “8” which exists within the system of integers; “3 + 5” does not give us
“rabbit” (which is not a number – it’s a breeding, and increasing number!). And also
(ii) that this system is complete, which means that all provable theorems can be
expressed within the symbols (algebra) of the system. Heavy stuff, to be discussed in
class.
3.11 Extending Propositional to Predicate Calculus
Propositional Calculus is limited. This is precisely the problem Frege struggled with.
Here’s an example. Consider the simple argument
All men are mortal
Socrates is a man
Therefore
Socrates is mortal
In propositional logic, this has the form
P
Q
Therefore
R
(P  Q)  R
But, as you will see, this is NOT a valid argument: The truth table does not give a ‘1’
for every validation. Yet we would like to agree (and formally assert) that an
argument like this is valid. Our current system of propositional logic is apparently not
powerful enough.
The extension of propositional logic to first-order logic, provided by Frege, was
intended to move beyond the limitations of propositional logic. It succeeded.
Unfortunately, in this class, we have neither time nor energy to delve into the details
of first-order logic, except to note that it is a natural progression from propositional
logic on the path to realizing Leibnitz’ dream, which, as we noted, led to the invention
of the computer by Alan Turing.
3.12 Activities (Separate Document)
The activities provided for this class explore the Propositional Calculus. They are
intended to explore the relationship between formal logic and its expression in the
dimensions of the English language and Digital Electronics Circuits.