Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Propositional Logic A gentle introduction Ifeanyi Oraelosi - Trainer, Andela

Slide 3

Slide 3 text

Before we begin...

Slide 4

Slide 4 text

1. A robot may not injure a human being or, through inaction, allow a human being to come to harm. 2. A robot must obey the orders given it by human beings, except where such orders would conflict with the First Law. 3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Law. Isaac Asimov The Three Laws of Robotics

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

What is Discrete Mathematics? What’s its relevance to software development?

Slide 8

Slide 8 text

What is Discrete Mathematics? The study of mathematical structures that are fundamentally discrete. ● Typical textbook definition ● Not useful - especially to more pragmatic people like software developers.

Slide 9

Slide 9 text

What is Discrete Mathematics? ● A branch of mathematics (obviously!). ● Objects of study have distinct values e.g integers, booleans as opposed to objects with continuous values like real numbers (floating-point numbers). ● Involves the study of algorithms, their implementations and efficiencies.

Slide 10

Slide 10 text

What is Discrete Mathematics? Branches: ● Logic: valid reasoning and inference. [software testing and debugging] ● Set Theory: collections of objects [relational databases] ● Number Theory: properties of numbers [cryptography] ● Graph Theory: graphs and networks [social networks]

Slide 11

Slide 11 text

We should return to the main topic but...

Slide 12

Slide 12 text

“For the things we have to learn before we can do them, we learn by doing them.” Aristotle

Slide 13

Slide 13 text

We need learning guides - problems.

Slide 14

Slide 14 text

Big Teaser. A cockroach in the specs. After a grueling four hours of writing tests for PunchStopper, a new crowdsourcing application, Mirabel decides to implement the features. Fortunately, the first test passes but the application vomits errors in the bash terminal. Mirabel does some investigating and arrives at the following premises: - If the code on line 115 is wrong then the code on line 245 is wrong too. - The code on line 67 is wrong or the code on line 245 is correct but the first test will fail if the code on line 67 is wrong. - The first test passed. By applying the rules of inference,can you arrive at a conclusion?

Slide 15

Slide 15 text

Teaser for the day. Knights and Knaves #1 A very special island is inhabited only by knights and knaves. Knights always tell the truth, and knaves always lie. You meet two inhabitants: Tunde and Eniola. Tunde tells you that Eniola is a knave. Eniola says, `Neither Tunde nor I are knaves.' Can you determine who is a knight and who is a knave?

Slide 16

Slide 16 text

What is a proposition? Definition of a proposition.

Slide 17

Slide 17 text

What is a proposition? A proposition is a declarative sentence (a sentence that declares a fact) that is either true or false, but not both.

Slide 18

Slide 18 text

What is a proposition? Examples: - npm is better than gem - Is this class boring? - x + 5 = 4 - Programmers are lazy and arrogant. - She likes rational arguments.

Slide 19

Slide 19 text

Propositional variables, constants and connectives. Basic terminology for propositional logic.

Slide 20

Slide 20 text

Propositional variables, constants and connectives. Propositional variable A variable, often an alphabetical symbol, that represents a proposition. Examples: - n could represent the proposition “npm is better than gem” - p could represent the proposition “Programmers are lazy and arrogant.”

Slide 21

Slide 21 text

Propositional variables, constants and connectives. Propositional constant The truth value of a proposition; either of the booleans “true” (T) or “false” (F). Example: - The truth value of the variable n which represents the proposition “npm is better than gem” is true. The can be rephrased as n is true.

Slide 22

Slide 22 text

Propositional variables, constants and connectives. Propositional connective A symbol that connects two or more propositions in a grammatically valid way to create a compound proposition. Also known as logical operators. Examples: - n ∧ p is the compound proposition “npm is better than gem and programmers are lazy and arrogant”. - n ∨ p is the compound proposition “npm is better than gem or programmers are lazy and arrogant or

Slide 23

Slide 23 text

Truth tables

Slide 24

Slide 24 text

Truth tables. The formal specification for a propositional connective. A truth table lists all possible combinations of the values of the variables and gives the corresponding values of the compound proposition.

Slide 25

Slide 25 text

Truth tables. Format: variable a variable b connective + variables truth value for a truth value for b truth value for connective truth value for a truth values for b truth value for connective ... ... ...

Slide 26

Slide 26 text

Truth tables. Example: Truth table for logical conjunction (”and”) n p n ∧ p F F F F T F T F F T T T

Slide 27

Slide 27 text

Truth tables. Example: Truth table for logical disjunction (”or”) n p n ∨ p F F F F T T T F T T T T

Slide 28

Slide 28 text

We’ll treat logical connectives in detail in the next presentation.

Slide 29

Slide 29 text

“But I don't want to go among mad people,' said Alice. 'Oh, you can't help that,' said the cat. 'We're all mad here.” Lewis Caroll