Structural Induction · Structural induction as a proof methodology Structural induction is a proof...

52
Structural Induction Jason Filippou CMSC250 @ UMCP 07-05-2016 Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 1 / 26

Transcript of Structural Induction · Structural induction as a proof methodology Structural induction is a proof...

Page 1: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Structural Induction

Jason Filippou

CMSC250 @ UMCP

07-05-2016

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 1 / 26

Page 2: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Outline

1 Recursively defined structures

2 ProofsBinary TreesSets

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 2 / 26

Page 3: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Recursively defined structures

Recursively defined structures

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 3 / 26

Page 4: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Recursively defined structures

Recursively defined structures

Many structures in Computer Science are recursively defined, i.eparts of them exhibit the same characteristics and have the sameproperties as the whole!

They are also “well-ordered”, in the sense that they exhibit a“well-founded partial order”, like the order ≤ of Z or ⊆ for sets.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 4 / 26

Page 5: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Recursively defined structures

Structural induction as a proof methodology

Structural induction is a proof methodology similar tomathematical induction, only instead of working in the domain ofpositive integers (N) it works in the domain of such recursivelydefined structures!

It is terrifically useful for proving properties of such structures.

Its structure is sometimes “looser” than that of mathematicalinduction.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 5 / 26

Page 6: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs

Proofs

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 6 / 26

Page 7: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

Binary Trees

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 7 / 26

Page 8: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

Pictorially

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 8 / 26

Page 9: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

Pictorially

Height: 2 # Nodes: 7

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 9 / 26

Page 10: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

Pictorially

Height: 2 # Nodes: 7

Height: 1 # Nodes: 3

Height: 1 # Nodes: 3

Root r

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 10 / 26

Page 11: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

A recursive definition and statement on binary trees

Definition (Non-empty binary tree)

A non-empty binary tree T is either:

Base case: A root node r with no pointers, or

Recursive (or inductive) step: A root node r pointing to 2non-empty binary trees TL and TR

Claim: |V | = |E|+ 1

The number of vertices (|V |) of a non-empty binary tree T is thenumber of its edges (|E|) plus one.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 11 / 26

Page 12: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

A recursive definition and statement on binary trees

Definition (Non-empty binary tree)

A non-empty binary tree T is either:

Base case: A root node r with no pointers, or

Recursive (or inductive) step: A root node r pointing to 2non-empty binary trees TL and TR

Claim: |V | = |E|+ 1

The number of vertices (|V |) of a non-empty binary tree T is thenumber of its edges (|E|) plus one.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 11 / 26

Page 13: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

First structurally inductive proof

Proof (via structural induction on non-empty binary trees).

Let T be a non-empty binary tree and P the proposition we want to hold..

1 Inductive Base: If T consists of a single root node r (base case for anon-empty binary tree), then |V | = 1 and |E| = 0, so P (r) holds.

2 Inductive Hypothesis: In the recursive part of the definition for anon-empty binary tree, T may consist of a root node r pointing to 1 or 2non-empty binary trees TL and TR. Without loss of generality, we can assumethat both TL and TR are defined, and we assume P (TL) and P (TR).

3 Inductive Step: We prove now that P (T ) must hold. Denote by VL, EL, VR,ER the vertex and edge sets of the left and right subtrees respectively. Weobtain:

|V | = |VL|+ |VR|+ 1 (By definition of non-empty binary trees)

= (|EL|+ 1) + (|ER|+ 1) + 1 (By the Inductive Hypothesis)

= (|EL|+ |ER|+ 2) + 1 (By grouping terms)

= |E|+ 1 (By definition of non-empty binary trees)

So P (T ) holds.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 12 / 26

Page 14: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

Here’s one for you!

Definition (Height of a non-empty binary tree)

The height h(T ) of a non-empty binary tree T is defined as follows:

(Base case:) If T is a single root node r, h(r) = 0.

(Recursive step:) If T is a root node connected to two“sub-trees” TL and TR, h(T ) = max{h(TR), h(TL)}+ 1

Theorem (m(T ) as a function of h(T ))

A non-empty binary tree T of height h(T ) has at most 2h(T )+1 − 1nodes.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 13 / 26

Page 15: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

General Structure of structurally inductive proofs ontrees

1 Prove P (·) for the base-case of the tree.

This can either be an empty tree, or a trivial “root” node, say r.That is, you will prove something like P (null) or P (r).As always, prove explicitly!

2 Assume the inductive hypothesis for an arbitrary tree T , i.eassume P (T ).

Valid to do so, since at least for the trivial case we have explicitproof!

3 Use the inductive / recursive part of the tree’s definition to build anew tree, say T ′, from existing (sub-)trees Ti, and prove P (T ′)!

Use the Inductive Hypothesis on the Ti!

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 14 / 26

Page 16: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

General Structure of structurally inductive proofs ontrees

1 Prove P (·) for the base-case of the tree.

This can either be an empty tree, or a trivial “root” node, say r.That is, you will prove something like P (null) or P (r).

As always, prove explicitly!

2 Assume the inductive hypothesis for an arbitrary tree T , i.eassume P (T ).

Valid to do so, since at least for the trivial case we have explicitproof!

3 Use the inductive / recursive part of the tree’s definition to build anew tree, say T ′, from existing (sub-)trees Ti, and prove P (T ′)!

Use the Inductive Hypothesis on the Ti!

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 14 / 26

Page 17: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

General Structure of structurally inductive proofs ontrees

1 Prove P (·) for the base-case of the tree.

This can either be an empty tree, or a trivial “root” node, say r.That is, you will prove something like P (null) or P (r).As always, prove explicitly!

2 Assume the inductive hypothesis for an arbitrary tree T , i.eassume P (T ).

Valid to do so, since at least for the trivial case we have explicitproof!

3 Use the inductive / recursive part of the tree’s definition to build anew tree, say T ′, from existing (sub-)trees Ti, and prove P (T ′)!

Use the Inductive Hypothesis on the Ti!

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 14 / 26

Page 18: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

General Structure of structurally inductive proofs ontrees

1 Prove P (·) for the base-case of the tree.

This can either be an empty tree, or a trivial “root” node, say r.That is, you will prove something like P (null) or P (r).As always, prove explicitly!

2 Assume the inductive hypothesis for an arbitrary tree T , i.eassume P (T ).

Valid to do so, since at least for the trivial case we have explicitproof!

3 Use the inductive / recursive part of the tree’s definition to build anew tree, say T ′, from existing (sub-)trees Ti, and prove P (T ′)!

Use the Inductive Hypothesis on the Ti!

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 14 / 26

Page 19: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

General Structure of structurally inductive proofs ontrees

1 Prove P (·) for the base-case of the tree.

This can either be an empty tree, or a trivial “root” node, say r.That is, you will prove something like P (null) or P (r).As always, prove explicitly!

2 Assume the inductive hypothesis for an arbitrary tree T , i.eassume P (T ).

Valid to do so, since at least for the trivial case we have explicitproof!

3 Use the inductive / recursive part of the tree’s definition to build anew tree, say T ′, from existing (sub-)trees Ti, and prove P (T ′)!

Use the Inductive Hypothesis on the Ti!

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 14 / 26

Page 20: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Binary Trees

General Structure of structurally inductive proofs ontrees

1 Prove P (·) for the base-case of the tree.

This can either be an empty tree, or a trivial “root” node, say r.That is, you will prove something like P (null) or P (r).As always, prove explicitly!

2 Assume the inductive hypothesis for an arbitrary tree T , i.eassume P (T ).

Valid to do so, since at least for the trivial case we have explicitproof!

3 Use the inductive / recursive part of the tree’s definition to build anew tree, say T ′, from existing (sub-)trees Ti, and prove P (T ′)!

Use the Inductive Hypothesis on the Ti!

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 14 / 26

Page 21: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Sets

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 15 / 26

Page 22: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Recursive definitions of sets

Sets can be defined recursively!

Our goal is to find a “flat” definition of them (a “closed-form”description), much in the same way we did with recursive sequences andstrong induction.

Consider the following:

1 S1 is such that 3 ∈ S1 (base case) and if x, y ∈ S1, then x+ y ∈ S1

(recursive step).2 S2 is such that 2 ∈ S2 and if x ∈ S2, then x2 ∈ S2.3 S3 is such that 0 ∈ S3 and if y ∈ S3, then y + 1 ∈ S3.

Vote (> 1 possible)! 2 ∈ S1 S2 S3

16 ∈ S1 S2 S3

21 ∈ S1 S2 S3

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 16 / 26

Page 23: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Recursive definitions of sets

Sets can be defined recursively!

Our goal is to find a “flat” definition of them (a “closed-form”description), much in the same way we did with recursive sequences andstrong induction.

Consider the following:

1 S1 is such that 3 ∈ S1 (base case) and if x, y ∈ S1, then x+ y ∈ S1

(recursive step).

2 S2 is such that 2 ∈ S2 and if x ∈ S2, then x2 ∈ S2.3 S3 is such that 0 ∈ S3 and if y ∈ S3, then y + 1 ∈ S3.

Vote (> 1 possible)! 2 ∈ S1 S2 S3

16 ∈ S1 S2 S3

21 ∈ S1 S2 S3

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 16 / 26

Page 24: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Recursive definitions of sets

Sets can be defined recursively!

Our goal is to find a “flat” definition of them (a “closed-form”description), much in the same way we did with recursive sequences andstrong induction.

Consider the following:

1 S1 is such that 3 ∈ S1 (base case) and if x, y ∈ S1, then x+ y ∈ S1

(recursive step).2 S2 is such that 2 ∈ S2 and if x ∈ S2, then x2 ∈ S2.

3 S3 is such that 0 ∈ S3 and if y ∈ S3, then y + 1 ∈ S3.

Vote (> 1 possible)! 2 ∈ S1 S2 S3

16 ∈ S1 S2 S3

21 ∈ S1 S2 S3

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 16 / 26

Page 25: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Recursive definitions of sets

Sets can be defined recursively!

Our goal is to find a “flat” definition of them (a “closed-form”description), much in the same way we did with recursive sequences andstrong induction.

Consider the following:

1 S1 is such that 3 ∈ S1 (base case) and if x, y ∈ S1, then x+ y ∈ S1

(recursive step).2 S2 is such that 2 ∈ S2 and if x ∈ S2, then x2 ∈ S2.3 S3 is such that 0 ∈ S3 and if y ∈ S3, then y + 1 ∈ S3.

Vote (> 1 possible)! 2 ∈ S1 S2 S3

16 ∈ S1 S2 S3

21 ∈ S1 S2 S3

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 16 / 26

Page 26: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Recursive definitions of sets

Sets can be defined recursively!

Our goal is to find a “flat” definition of them (a “closed-form”description), much in the same way we did with recursive sequences andstrong induction.

Consider the following:

1 S1 is such that 3 ∈ S1 (base case) and if x, y ∈ S1, then x+ y ∈ S1

(recursive step).2 S2 is such that 2 ∈ S2 and if x ∈ S2, then x2 ∈ S2.3 S3 is such that 0 ∈ S3 and if y ∈ S3, then y + 1 ∈ S3.

Vote (> 1 possible)! 2 ∈ S1 S2 S3

16 ∈ S1 S2 S3

21 ∈ S1 S2 S3

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 16 / 26

Page 27: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Recursive definitions of sets

Sets can be defined recursively!

Our goal is to find a “flat” definition of them (a “closed-form”description), much in the same way we did with recursive sequences andstrong induction.

Consider the following:

1 S1 is such that 3 ∈ S1 (base case) and if x, y ∈ S1, then x+ y ∈ S1

(recursive step).2 S2 is such that 2 ∈ S2 and if x ∈ S2, then x2 ∈ S2.3 S3 is such that 0 ∈ S3 and if y ∈ S3, then y + 1 ∈ S3.

Vote (> 1 possible)! 2 ∈ S1 S2 S3

16 ∈ S1 S2 S3

21 ∈ S1 S2 S3

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 16 / 26

Page 28: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Recursive definitions of sets

Sets can be defined recursively!

Our goal is to find a “flat” definition of them (a “closed-form”description), much in the same way we did with recursive sequences andstrong induction.

Consider the following:

1 S1 is such that 3 ∈ S1 (base case) and if x, y ∈ S1, then x+ y ∈ S1

(recursive step).2 S2 is such that 2 ∈ S2 and if x ∈ S2, then x2 ∈ S2.3 S3 is such that 0 ∈ S3 and if y ∈ S3, then y + 1 ∈ S3.

Vote (> 1 possible)! 2 ∈ S1 S2 S3

16 ∈ S1 S2 S3

21 ∈ S1 S2 S3

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 16 / 26

Page 29: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Practice!

4 S4 is such that 1 ∈ S4 and if x, y ∈ S4, then x(−y) ∈ S4.

5 S5 is such that ∅ ∈ S5 and a ∈ S5 ⇒ {a} ∈ S5.

6 S6 is such that ∅ ∈ S6 and a, b ∈ S6 ⇒ a ∪ b ∈ S6.

7 S7 is such that {0} ∈ S7 and (x ∈ S7) ∧ (i ∈ N∗)⇒ x ∩ {i} ∈ S7.

8 S8 is such that i ∈ N∗ ⇒ {i} ∩ {i+ 1} ∈ S8.

|S4| = 0 1 2 +∞

|S5| = 0 1 2 +∞

|S6| = 0 1 2 +∞

|S7| = 0 1 2 +∞

|S8| = 0 1 2 +∞

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 17 / 26

Page 30: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Practice!

4 S4 is such that 1 ∈ S4 and if x, y ∈ S4, then x(−y) ∈ S4.

5 S5 is such that ∅ ∈ S5 and a ∈ S5 ⇒ {a} ∈ S5.

6 S6 is such that ∅ ∈ S6 and a, b ∈ S6 ⇒ a ∪ b ∈ S6.

7 S7 is such that {0} ∈ S7 and (x ∈ S7) ∧ (i ∈ N∗)⇒ x ∩ {i} ∈ S7.

8 S8 is such that i ∈ N∗ ⇒ {i} ∩ {i+ 1} ∈ S8.

|S4| = 0 1 2 +∞

|S5| = 0 1 2 +∞

|S6| = 0 1 2 +∞

|S7| = 0 1 2 +∞

|S8| = 0 1 2 +∞

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 17 / 26

Page 31: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Practice!

4 S4 is such that 1 ∈ S4 and if x, y ∈ S4, then x(−y) ∈ S4.

5 S5 is such that ∅ ∈ S5 and a ∈ S5 ⇒ {a} ∈ S5.

6 S6 is such that ∅ ∈ S6 and a, b ∈ S6 ⇒ a ∪ b ∈ S6.

7 S7 is such that {0} ∈ S7 and (x ∈ S7) ∧ (i ∈ N∗)⇒ x ∩ {i} ∈ S7.

8 S8 is such that i ∈ N∗ ⇒ {i} ∩ {i+ 1} ∈ S8.

|S4| = 0 1 2 +∞

|S5| = 0 1 2 +∞

|S6| = 0 1 2 +∞

|S7| = 0 1 2 +∞

|S8| = 0 1 2 +∞

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 17 / 26

Page 32: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Practice!

4 S4 is such that 1 ∈ S4 and if x, y ∈ S4, then x(−y) ∈ S4.

5 S5 is such that ∅ ∈ S5 and a ∈ S5 ⇒ {a} ∈ S5.

6 S6 is such that ∅ ∈ S6 and a, b ∈ S6 ⇒ a ∪ b ∈ S6.

7 S7 is such that {0} ∈ S7 and (x ∈ S7) ∧ (i ∈ N∗)⇒ x ∩ {i} ∈ S7.

8 S8 is such that i ∈ N∗ ⇒ {i} ∩ {i+ 1} ∈ S8.

|S4| = 0 1 2 +∞

|S5| = 0 1 2 +∞

|S6| = 0 1 2 +∞

|S7| = 0 1 2 +∞

|S8| = 0 1 2 +∞

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 17 / 26

Page 33: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Practice!

4 S4 is such that 1 ∈ S4 and if x, y ∈ S4, then x(−y) ∈ S4.

5 S5 is such that ∅ ∈ S5 and a ∈ S5 ⇒ {a} ∈ S5.

6 S6 is such that ∅ ∈ S6 and a, b ∈ S6 ⇒ a ∪ b ∈ S6.

7 S7 is such that {0} ∈ S7 and (x ∈ S7) ∧ (i ∈ N∗)⇒ x ∩ {i} ∈ S7.

8 S8 is such that i ∈ N∗ ⇒ {i} ∩ {i+ 1} ∈ S8.

|S4| = 0 1 2 +∞

|S5| = 0 1 2 +∞

|S6| = 0 1 2 +∞

|S7| = 0 1 2 +∞

|S8| = 0 1 2 +∞

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 17 / 26

Page 34: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Practice!

4 S4 is such that 1 ∈ S4 and if x, y ∈ S4, then x(−y) ∈ S4.

5 S5 is such that ∅ ∈ S5 and a ∈ S5 ⇒ {a} ∈ S5.

6 S6 is such that ∅ ∈ S6 and a, b ∈ S6 ⇒ a ∪ b ∈ S6.

7 S7 is such that {0} ∈ S7 and (x ∈ S7) ∧ (i ∈ N∗)⇒ x ∩ {i} ∈ S7.

8 S8 is such that i ∈ N∗ ⇒ {i} ∩ {i+ 1} ∈ S8.

|S4| = 0 1 2 +∞

|S5| = 0 1 2 +∞

|S6| = 0 1 2 +∞

|S7| = 0 1 2 +∞

|S8| = 0 1 2 +∞

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 17 / 26

Page 35: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Our first structurally inductive proof on sets

A proposition on a recursively defined set

Let S be a set defined as follows:

Base case: 4 ∈ SRecursive / Inductive step: If x ∈ S, then x2 ∈ S.

Then, prove that ∀x ∈ S, x is even.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 18 / 26

Page 36: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Our first structurally inductive proof on sets

A proposition on a recursively defined set

Let S be a set defined as follows:

Base case: 4 ∈ SRecursive / Inductive step: If x ∈ S, then x2 ∈ S.

Then, prove that ∀x ∈ S, x is even.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 18 / 26

Page 37: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Proof

Proof (via structural induction on S).

Let P be the proposition we want to prove. We proceed inductively:

Inductive base: In the base case of the definition of S, we havethat 4 ∈ S. Since 4 is an even number, P ({4}) holds.

Inductive hypothesis: The inductive definition of S successivelybuilds sets S′ from previous “versions” of S. We assume that∃S′ : |S′| ≥ 1 and P (S′).

Inductive step: We will prove that P (S′ ∪ {x2|x ∈ S′}) holds.Let x0 be an arbitrarily selected element of S′. From the inductivehypothesis, we know that x0 is even. From a known theorem, weknow that x2

0 is even. But this means that P ({x0}), and since x0

was arbitrarily selected within S′, P (S′ ∪ {x2|x ∈ S′}) holds.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 19 / 26

Page 38: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

A proof on the Cartesian Plane

An inequality proof

Let S be the subset of Z× Z = Z2 defined as follows:

Base case: (0, 0) ∈ SRecursive step:(a, b) ∈ S ⇒ (((a, b+1) ∈ S)∧((a+1, b+1) ∈ S)∧(a+2, b+1) ∈ S).Prove that ∀(a, b) ∈ S, a ≤ 2b.

Suggestion: To make sure you understand the exercise, first list 5elements in S.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 20 / 26

Page 39: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Cartesian plane exercise, proof

In class!

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 21 / 26

Page 40: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Set equality and structural induction

The set of positive multiples of 3

Let the set S be such that:

(Base case:) 3 ∈ S

(Recursive step:) (x ∈ S) ∧ (y ∈ S)⇒ (x + y) ∈ S

Then, S = {3n, ∀n ∈ N∗}.

What do I need to do in order to prove this statement?

A ⊆ S

Contradiction Cases Mathematical induction Structural Induction

S ⊆ A

Contradiction Cases Mathematical induction Structural Induction

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 22 / 26

Page 41: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Set equality and structural induction

The set of positive multiples of 3

Let the set S be such that:

(Base case:) 3 ∈ S

(Recursive step:) (x ∈ S) ∧ (y ∈ S)⇒ (x + y) ∈ S

Then, S = {3n, ∀n ∈ N∗}.

What do I need to do in order to prove this statement?

A ⊆ S

Contradiction Cases Mathematical induction Structural Induction

S ⊆ A

Contradiction Cases Mathematical induction Structural Induction

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 22 / 26

Page 42: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Set equality and structural induction

The set of positive multiples of 3

Let the set S be such that:

(Base case:) 3 ∈ S

(Recursive step:) (x ∈ S) ∧ (y ∈ S)⇒ (x + y) ∈ S

Then, S = {3n, ∀n ∈ N∗}.

What do I need to do in order to prove this statement?

A ⊆ S

Contradiction Cases Mathematical induction Structural Induction

S ⊆ A

Contradiction Cases Mathematical induction Structural Induction

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 22 / 26

Page 43: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Set equality and structural induction

The set of positive multiples of 3

Let the set S be such that:

(Base case:) 3 ∈ S

(Recursive step:) (x ∈ S) ∧ (y ∈ S)⇒ (x + y) ∈ S

Then, S = {3n, ∀n ∈ N∗}.

What do I need to do in order to prove this statement?

A ⊆ S

Contradiction Cases Mathematical induction Structural Induction

S ⊆ A

Contradiction Cases Mathematical induction Structural Induction

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 22 / 26

Page 44: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Proof

Proof (via weak induction on n and structural induction on S!)

Let A = {3n, ∀n ∈ N∗}. To prove S = A, we need to prove that S ⊆ A andA ⊆ S.

First, we prove that A ⊆ S. The proof is via weak induction on n. Let rbe a generic particular for N∗ and P (n) be the statement we want toprove.a We proceed inductively:

1 Inductive base: For r = 1, 3r = 3 · 1 ∈ S. Therefore, P (1) holds.2 Inductive hypothesis: We assume that for some value of r ≥ 1, P (r) holds,

i.e 3r ∈ S3 Inductive step: We want to prove P (r + 1), that is, 3(r + 1) ∈ S. We know

that 3r ∈ S and 3 ∈ S by the inductive base and hypothesis. By the definition

of S, this means that 3r + 3 ∈ S(Algebra)⇐⇒ 3(r + 1) ∈ S. So, P (r + 1) holds.

Since r ∈ N∗ was arbitrarily chosen, the result holds for all n ∈ N∗.

aWe can do this, since A is parameterized by n.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 23 / 26

Page 45: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Proof (continued)

Proof: S ⊆ A part.

We now prove that S ⊆ A.1 Inductive base: By the base case of the definition of S, we have

that 3 ∈ S. Since 3 = 3 · 1 and 1 ∈ N∗, we have that 3 ∈ A. So P (3).2 Inductive hypothesis: Assume that x, y ∈ S are also contained

by A, i.e x, y ∈ A. So P (x), P (y).3 Inductive step: We must show that P (x+ y), i.e x+ y ∈ A,

because if we do show this, we will have covered the recursive stepof A’s definition. From the inductive hypothesis, we have thatx, y ∈ A⇒ ∃i, j ∈ N∗ : x = 3i, y = 3j. Therefore,x+ y = 3 (i+ j)︸ ︷︷ ︸

z∈N

⇒ x+ y ∈ A. Therefore, P (x+ y).

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 24 / 26

Page 46: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Recursively defined languages!

Definition

A recursively defined language Let Σ = {a, b} be an alphabet. Wedefine the language L as follows:

(Base case:) ε ∈ L(Recursive step:) If x ∈ L, axa ∈ L and bxb ∈ L.a

aσ1σ2 is the concatenation of σ1 and σ2. Concatenation can be appliedto n strings, n = 1, 2, 3, . . . . σn is the concatenation of σ n− many times.

Claim

∀σ ∈ L, |σ| is even.a

a|σ| is the number of characters in σ.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 25 / 26

Page 47: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

Recursively defined languages!

Definition

A recursively defined language Let Σ = {a, b} be an alphabet. Wedefine the language L as follows:

(Base case:) ε ∈ L(Recursive step:) If x ∈ L, axa ∈ L and bxb ∈ L.a

aσ1σ2 is the concatenation of σ1 and σ2. Concatenation can be appliedto n strings, n = 1, 2, 3, . . . . σn is the concatenation of σ n− many times.

Claim

∀σ ∈ L, |σ| is even.a

a|σ| is the number of characters in σ.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 25 / 26

Page 48: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

General structure on inductive proofs on sets

1 In the inductive base, prove P (·) for all the base elements of therecursively defined set S.

This gives us that P (·) holds for sets up to some cardinality n0.

2 In the inductive hypothesis, assume ∃S : |S| ≥ n0 and P (S).

Reminds us of weak mathematical induction?

3 In the inductive step, use the recursive part of the definition of Sto prove that the new set constructed (call it S′) satisfies theproposition (so P (S′)).

The inductive hypothesis will undoubtedly be used.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 26 / 26

Page 49: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

General structure on inductive proofs on sets

1 In the inductive base, prove P (·) for all the base elements of therecursively defined set S.

This gives us that P (·) holds for sets up to some cardinality n0.

2 In the inductive hypothesis, assume ∃S : |S| ≥ n0 and P (S).

Reminds us of weak mathematical induction?

3 In the inductive step, use the recursive part of the definition of Sto prove that the new set constructed (call it S′) satisfies theproposition (so P (S′)).

The inductive hypothesis will undoubtedly be used.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 26 / 26

Page 50: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

General structure on inductive proofs on sets

1 In the inductive base, prove P (·) for all the base elements of therecursively defined set S.

This gives us that P (·) holds for sets up to some cardinality n0.

2 In the inductive hypothesis, assume ∃S : |S| ≥ n0 and P (S).

Reminds us of weak mathematical induction?

3 In the inductive step, use the recursive part of the definition of Sto prove that the new set constructed (call it S′) satisfies theproposition (so P (S′)).

The inductive hypothesis will undoubtedly be used.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 26 / 26

Page 51: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

General structure on inductive proofs on sets

1 In the inductive base, prove P (·) for all the base elements of therecursively defined set S.

This gives us that P (·) holds for sets up to some cardinality n0.

2 In the inductive hypothesis, assume ∃S : |S| ≥ n0 and P (S).

Reminds us of weak mathematical induction?

3 In the inductive step, use the recursive part of the definition of Sto prove that the new set constructed (call it S′) satisfies theproposition (so P (S′)).

The inductive hypothesis will undoubtedly be used.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 26 / 26

Page 52: Structural Induction · Structural induction as a proof methodology Structural induction is a proof methodology similar to mathematical induction, only instead of working in the domain

Proofs Sets

General structure on inductive proofs on sets

1 In the inductive base, prove P (·) for all the base elements of therecursively defined set S.

This gives us that P (·) holds for sets up to some cardinality n0.

2 In the inductive hypothesis, assume ∃S : |S| ≥ n0 and P (S).

Reminds us of weak mathematical induction?

3 In the inductive step, use the recursive part of the definition of Sto prove that the new set constructed (call it S′) satisfies theproposition (so P (S′)).

The inductive hypothesis will undoubtedly be used.

Jason Filippou (CMSC250 @ UMCP) Structural Induction 07-05-2016 26 / 26