Talking To machines
Introduction
programming is not
black magic
You don't need to be able to...
- read lines and lines of abstract symbols
- simulate a computer in your head
- understand abstract mathematics
...to be a programmer!
Logic is all you need
All you need to be able to do is think logically.
Logic is all you need
What do we mean by logic, exactly?
if a person is pregnant, then they are female
is not the same as
if a person is female, then they are pregnant
Luckily for everyone, as this would mean that
women are pregnant all the time
Logic is all you need
What do we mean by logic, exactly?
if a person is pregnant, then they are female
is the same as
there is no pregnant person that is not female
This means that men cannot get pregnant.
Which happens to be true!
True and false
How can we tell the difference between
things that are true and things that are false?
Simpler language
Simple language makes logic easier to follow
if a person is pregnant, then they are female
(pregnant p) => (female p)
if a person is female, then they are pregnant
(female p) => (pregnant p)
Being before or after the arrow
changes the meaning of the sentence!
Arrows
(pregnant p) => (female p)
If the thing to the left of the arrow is true,
the thing to the right of the arrow must be true
If you are pregnant then you must be female
Arrows
(pregnant p) => (female p)
If the thing to the right of the arrow is true,
the thing to the left of the arrow
is not necessarily true
You can be female without being pregnant
Arrows
(pregnant p) => (female p)
(not (female p)) => (not (pregnant p))
If we want to swap the order of the things,
we need to need to negate them using not.
WHY?
If you are not female, then you cannot be pregnant. Because if you were pregnant, then you would be female!
Even simpler language
a => b
(not b) => (not a)
This rule is true for any a and b you can think of!
(monday today) => (tuesday tomorrow)
(not (tuesday tomorrow)) => (not (monday today))
Logical nonsense
a => b
(not b) => (not a)
What about these values for a and b?
(pregnant p) => (male p)
(not (male p)) => (not (pregnant p))
The conclusion is true given the premise. If our premises are false, then our conclusions might be too.
logic is not truth
A logical inference does not have to be
empirically true.
But if we start from truthful premises we
are guaranteed to end up with true conclusions!
programming machines
A programming language is nothing more
than an unambiguous notation for ideas
Computers are machines that carry out
logical operations
A program is a collection of definitions and
some logical inferences we can draw from them
Definitions of male, female and pregnancy.
Inferences about what gender can be pregnant.
talking to machines
Learning to program is learning how
to write down your ideas in the
simplest language possible
Learning to program is learning how
to think logically with the help of a machine
Welcome to the course!
Talking to Machines - Introduction
By pascalc
Talking to Machines - Introduction
- 762