# Applications of Predicate Logic

(述語論理の応用)

## Discrete Mathematics I

### 8th lecture, November 16, 2018

http://www.sw.it.aoyama.ac.jp/2018/Math1/lecture8.html

### Martin J. Dürst # Today's Schedule

• Summary and homework from last lecture
• Applications of predicate logic
• Examples for various laws
• Quantifiers and variables
• Quantifiers and sums/products

# Announcement

There will be a minitest (ca. 30minutes) at the start of the next lecture. Please prepare well!

# Summary of Last Lecture

• There are many different kinds of symbolic logic: Propositional logic, predicate logic,...
• Predicates take arguments (propositions are predicates with zero arguments)
• Predicate logic allows more general statements and inferences than propositional logic
• Predicate logic uses universal quantifiers (∀) and existential quantifiers (∃)

# Last Week's Homework

Sorry, it was removed! :)

# Homework, Problem 3, Law 8

Sorry, it was removed! :)

# Homework, Problem 3, Law 12

Sorry, it was removed! :)

# Relation between Sums/Products and Quantifiers

Sum: i=1 1/i2 = 1 + 1/4 + 1/9 + 1/16 + 1/25 + ...

Product: i=1 1+1/(-2)i = ...

Universal quantification: (∀i ∈ℕ+: i>0) = i=1 i>0 = 1>0 ∧ 2>0 ∧ 3>0 ∧...

Existential quantification: (∃i ∈ℕ+: odd(i)) = i=1 odd(i) = odd(1)∨odd(2)∨odd(3)∨...

Quantification is a generalization of conjunction/disjunction to more than two operands in the same way that sum and product are a generalization of addition/multiplication to more than two operands.

two operands many operands
name symbol name symbol(s)
addition + sum
multiplication * product
conjunction universal quantification ∀/
disjunction existential quantification ∃/

# Factorial

Notation: n!

Definition: n! = 1 · 2 · ... (n-1) · n = ∏ni=1 i

(∏ is called product)

Question:

1! = 1

0! = 1

# Neutral Element of an Operation

• Neutral element of addition: 0
• Neutral element of multiplication: 1
• Neutral element of conjunction: true
• Neutral element of disjunction: false
• Neutral element of substraction:
does not exist, but 0 is a rigth identity (satisfying only ∀x: x = xe)

# Structure of a Program to Calculate Sums, ...

Concrete example (sum):

```int sum = 0;
for (i=0; i<end; i++)
sum += array[i];```

## General Structure

In programming language C:

```type result = neutral element;
for (i=0; i<end; i++)
result = result operator array[i];```

In programming language Ruby:

```array.inject(neutral element) do |memo, next|
memo operator next
end```

# Quantifiers for Empty Sets

i (i<0⋀i>5): odd(i) = T (because the unit element of conjunction is T)

i (i<0⋀i>5): odd(i) = F (because the unit element of disjunction is F)

# Extension of DeMorgans' Laws

Laws 1 and 2 introduced in the last lecture are generalizations of DeMorgans' laws:

• ¬∀x: P(x)
= ¬(P(x1)∧P(x2)∧P(x3)∧P(x4)∧...)
= (¬P(x1)∨¬P(x2)∨¬P(x3)∨¬P(x4)∨...)
= ∃x: ¬P(x)
• ¬∃x: P(x)
= ¬(P(x1)∨P(x2)∨P(x3)∨P(x4)∨...)
= (¬P(x1)∧¬P(x2)∧¬P(x3)∧¬P(x4)∧...)
= ∀x: ¬P(x)

# Formula Manipulation with Quantifiers

Simplify ¬(∃x: P(x) → ∀y: ¬Q(y))

¬(∃x: P(x) → ∀y: ¬Q(y)) [removing implication]

= ¬(¬∃x: P(x) ∨ ∀y: ¬Q(y)) [deMorgan's law]

= ¬¬∃x: P(x) ∧ ¬∀y: ¬Q(y) [law 1 of last lecture]

= ¬¬∃x: P(x) ∧ ∃y: ¬¬Q(y) [double negation]

= ∃x: P(x) ∧ ∃y: Q(y)

Actual example:

Let P(x) mean "it is raining in x", and Q(y) "it is snowing y"

Then the original formula says "It's wrong that if it rains somewhere, then it snows nowhere". The final formula says "There is a place where it rains and there is a place where it snows".

# Pascal's Triangle

Start with a single `1` in the first row, surrounded by zeroes (`(0 ... 0) 1 (0 ... 0)`).
Create row by row by adding the number above and to the left and the number above and to the right.

```                  1
1   1
1   2   1
1   3   3   1
1   4   6   4   1
1   5  10  10   5   1
1   6  15  20  15   6   1
1   7  21  35  35  21   7   1
1   8  28  56  70  56  28   8   1```

# Subsets and Pascal's Triangle

• For a set A with |A| = n, we can write
|{B|BA∧|B|=m}| as nCm
• nCn = 1 (the only subset of size n is A itself, {B|BA∧|B|=|A|=n} = {{A}})
• nC0 = 1 (the only subset of size 0 is {}, {B|BA∧|B|=1} = {{}})
• nCm = n-1Cm-1 + n-1Cm (n>0, 0<m<n)

# Subsets and Combinations

• Combinatorics is very important for Information Technology
• Combinatorics deals with counting the number of different things under various conditions or restrictions
• The word combinations refers to the choices of a given size from a set without repetitions and without considering order
• Combinations of a certain size m selected from a set of size n are the same as the subsets of a given size m in a powerset of size n
• The number of combinations is written nCm
• There are also permutations (considering order), repeated permutations (allowing an element to be selected more than once), and repeated combinations

# Direct Formula for Combinations

• nCm = n!/(m! (n-m)!)

(prove it as a homework)

# Homework Due November 22

Deadline: November 22, 2018 (Thursday), 19:00.

Format: A4 single page (using both sides is okay; NO cover page), easily readable handwriting (NO printouts), name (kanji and kana) and student number at the top right

Where to submit: Box in front of room O-529 (building O, 5th floor)

Problem 1: By using formula manipulation, show that the Wolfram axiom of Boolean logic (((AB)⊼C)⊼(A⊼((AC)⊼A))=C) is a tautology. For each simplification step, indicate which law(s) you used.

Hints: Simplify the left side to obtain the right side. There should be between 15 and 20 steps.

Problem 2: For ternary (three-valued) logic, create defining truth tables for conjunction, disjunction, and negation. The three values are T, F, and ?, where ? stands for "unknown" (in more words: "maybe true, maybe false, we don't know").

Hint: What's the result of "?∨T"? ? can be T or F, but in both cases the result will be T, so ?∨T=T.

# Homework Due November 29

Deadline: November 29, 2018 (Thursday), 19:00.

Format: A4 single page (using both sides is okay; NO cover page), easily readable handwriting (NO printouts), name (kanji and kana) and student number at the top right

Where to submit: Box in front of room O-529 (building O, 5th floor)

Prove nCm = n!/(m! (n-m)!) for 0≦n, 0≦mn using nCm = n-1Cm-1 + n-1Cm
(Hint: Prove first for m=0 and m=n, then for 0<m<n)

# Glossary

Pascal's triangle
パスカルの三角形
combinatorics

combination

permutation

repeated combination

repeated permutation