00:00

Understanding Structural Induction and Strong Induction in Recursively Defined Structures

Structural induction, a form of strong induction, is applied to recursively defined structures to prove properties. It involves defining base cases and induction implications for instances generated by the recursive definition. A detailed example involving binary trees and arithmetic expressions illustrates the process. The concept is further explored in the context of well-ordered sets and minimal elements. Structural induction provides a powerful tool for proving properties in complex recursively defined systems.

ciolacu
Download Presentation

Understanding Structural Induction and Strong Induction in Recursively Defined Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Structural Induction Based on Strong Induction

  2. Recursive Definitions Binary tree: 1. Null is an empty binary tree. 2. If Tleftand Trightare binary trees, then <x, Tleft, Tright> is a binary tree 3. The root of <> has value x and left subtree Tleftand right subtree Tright. Arithmetic expression: 1. Any integer n 2. For an expression E, -E is an expression 3. For expressions E, G, E+G, E-G, E*G, E/G (G!=0) are expressions

  3. Structural induction is strong induction applied to recursively defined structures. To prove a property P(t) by structural induction we need to prove a base case (or cases) and an induction implication The base cases are derived from the base definition or the simplest instance (like the empty tree or a tree with null subtrees). The induction implication for an instance t generated by n applications of the recursive definition assumes P(s) for any tree s generated by 1 <=k < n applications of the recursive definition. This is strong induction!

  4. Example. A node of a tree is any non-null subtree: <x, tl,tr> and we call x the value at that node. A leaf node is a node <x, tl,tr> for which tland trare both null. An internal node is any node that is not a leaf node. We call the number of leaf nodes of a tree T, leaves(T) and the number of internal nodes internals(T).

  5. Theorem: For any binary tree T = <x, tl, tr>, leaves(T) <= internals(T) + 1. Call this P(T) Proof by strong induction. Base cases: Consider T0= null (empty tree). leaves(T0) = 0 = internals(T0) and 0 <= 0+1. T1is generated by 1 application of the recursive def , so leaf nodes are null and root node is a leaf. tl= null = tr, then leaves(T1) = 1 and internals(T1) = 0 and 1<=0+1

  6. Induction: Assume T is generated by n>= 2 applications of the recursive def. 1. Assume P(S) for any tree, S, generated with k < n applications of the recursive def. 2.2. T = <x, tl, tr > and 2.3 tlgenerated using l applications of def, trusing r applications of def 2.4 T generated by n = l+r+1 applications of rule, def 2.5 l < n, r < n 2.6 leaves(tl)<= internals(tl)+1, leaves(tr)<= internals(tr)+1. 1 and 2.5 2.7 leaves(T) = leaves(tl) + leaves(tr) 2.8 internals(T) = internals(tl) + internals(tr) + 1 since root is not a leaf 2.9 leaves(T) <= internals(tl)+1 + internals(tr)+1. 2.6,2.7 2.10 leaves(T) <= internals(T)+1 ] 2.8, 2.9 For any tree T, P(T). Strong induction since root is not a leaf

  7. Structural Induction • The previous example has the idea of structural induction • More formally, we define a well-ordered set S with an order relation, < if for any T ⊆ S, T has a minimal element, e, such that ∀t ∈ T, t!=e => ~(t<e). (Note: there may be more than one minimal element). (In English: e is minimal in T if there is no element in T smaller than e.) • Set of binary trees is well ordered where t1 < t2 means t1 is a subtree of t2. • A minimal element of all trees is the empty tree • Z>=0 is well ordered, where the smaller-than relation is <=. • A minimal element of Z>=0is 0. Minimal element of {2, 4, 6} is 2

  8. • Definition 5.6 (Proof by structural induction)(from text) • Suppose that we want to prove that P(x) holds for every x ∈ S, where S is the (well-ordered) set of structures generated by a recursive definition, and P is some property. To give a proof by structural induction of ∀ x ∈ S : P(x), we prove the following: • Base cases: for every x defined by a base case in the definition of S, prove P(x). (base cases are minimal elements) • Inductive cases: for every x defined in terms of y1, y2,…, yk∈ S by an inductive case in the definition of S, prove that P(y1) ∧ P(y2) ∧ ⋯ ∧ P(yk) ⇒ P(x). In other words yi< x for each i.

  9. Our previous proof of the statement below was essentially structural induction For any binary tree T = <x, tl, tr>, leaves(T) <= internals(T) + 1. Call this P(T) Proof by structural induction: Base cases are the same: Consider T0= null (empty tree). leaves(T0) = 0 = internals(T0) and 0 <= 0+1. T1is generated by 1 application of the recursive def , so leaf nodes are null and root node is a leaf. tl= null = tr, then leaves(T1) = 1 and internals(T1) = 0 and 1<=0+1 In the proof we would take as the induction assumption P(t) for all t, t a subtree of T. That is any t < T by the ordering over trees. (This gets the explicit use of strong induction out of it.)

  10. 1. we make the induction assumption P(t) for all t, t a subtree of T. That is any t < T by the ordering over trees. (This gets the explicit use of strong induction out of it.) 2. T = <x, tl, tr > for some tl, tr 3. leaves(T) = leaves(tl) + leaves(tr) 4. internals(T) = internals(tl) + internals(tr) + 1 5. leaves(tl)<= internals(tl)+1, leaves(tr)<= internals(tr)+1 6. leaves(T) = internals(tl) + 1 + internals(tr) + 1 7. leaves(T) = internals(T) + 1 8. P(t) for all t < T => P(T) (ordering or trees) 9. For any binary tree P(T) by base cases and 8 and 8 and structural induction definition of binary tree since root is not a leaf since root is not a leaf tl, trboth subtrees of T and 1 3, 5 substitution 4, 6 substitution 1 – 7

  11. Example: Define a heap as a binary tree <x, tl, tr>, such that for any node in the tree: <y, tyl, tyr>, where tyl= <z, tzl, tzr> or null and tyr= <w, twl, twr> or null then tylis null or y>= z and tyris null or y >= w. Note: this is a local property that simply says the value at a node is greater than or equal the value at the node of either child nodes unless the child is null. Theorem: For any heap H = <x, tl, tr>, x is greater than or equal to the value at any node in the tree. (call this P(H) Prove by structural induction.

  12. Base case : <x, tl, tr> is a leaf node (children are null) True since there are no values at the children. Induction case: Assume true for any tree <y, tyl, trr> < H = <x, tl, tr> (That is for any subtree of H) If tl= null, then x >= any value in tl. Otherwise, tl= <y, tyl, trr> and y >= value at every node in tl. Since x >= y by local heap property, x >= value at every node in tl. A similar argument shows that x >= every value in tr. If P(T) for all subtrees T of H, then P(H). By structural induction, P(H) for any heap.

More Related