Induction Proofs Equivalent Statements in Proofs cs 466Prasad





































- Slides: 37
Induction Proofs Equivalent Statements in Proofs cs 466(Prasad) L 6 Proof 1
cs 466(Prasad) L 6 Proof 2
q p cs 466(Prasad) L 6 Proof 3
Language Equivalence Proofs cs 466(Prasad) L 6 Proof 4
• Soundness: All strings derivable in the grammar G have the “characteristic” property of strings in L. • Thou shall not lie. • Typically the proof proceeds by associating an invariant with each variable that characterizes the strings it derives. cs 466(Prasad) L 6 Proof 5
• Completeness: All strings in L are derivable in G. • Thou shall speak the whole truth. • Typically the proof presents an algorithm for generating a string template of L using the rules of the grammar G. cs 466(Prasad) L 6 Proof 6
• How do we generate Derivation cs 466(Prasad) Rule Application L 6 Proof 7
• Let #w(x) = Number of occurrences of x in w. Prove that • Proof : By induction on the length of the derivation of a sentence. – Basis: cs 466(Prasad) l=4 L 6 Proof 8
• Induction Hypothesis: • Induction Step: By context-freeness of the grammar: cs 466(Prasad) L 6 Proof 9
• By induction hypothesis: (Note that Sudkamp’s text illustrates an alternative approach. Its proof uses a property of sentential forms and shows that the rules in the grammar preserve it. ) cs 466(Prasad) L 6 Proof 10
Example Two proofs for the same result. cs 466(Prasad) L 6 Proof 11
Prove that if then cs 466(Prasad) L 6 Proof 12
Informal Argument + +x*xx x E E x + E E E x x Parse tree * cs 466(Prasad) * x x Abstract syntax tree Strictly Binary Trees: # nodes = (2 * #leaves) – 1 # ops + # vars = (2 * #vars) – 1 # ops + 1 = #vars #(+) + #(*) +1 = #(x) L 6 Proof 13
Proof Alternatives cs 466(Prasad) L 6 Proof 14
• Proof 1: By induction on the length of the derivation of a sentence. • Basis: n=1 s=x 0+0+1=1 • Induction Hypothesis: cs 466(Prasad) L 6 Proof 15
• Induction step: k=n+1 Possible patterns for w cs 466(Prasad) L 6 Proof 16
By induction hypothesis: cs 466(Prasad) L 6 Proof 17
LHS RHS cs 466(Prasad) L 6 Proof 18
By induction hypothesis: cs 466(Prasad) L 6 Proof 19
LHS RHS cs 466(Prasad) L 6 Proof 20
• Proof 2: By induction on the length of the derivation of a sentential form. • Prove the general result so that the desired result for sentences follows given that cs 466(Prasad) L 6 Proof 21
• Basis: n=1 w = +EE w = *EE w= x 1+0+1=0+2 0+1+1=0+2 0+0+1=1+0 • Induction Hypothesis: cs 466(Prasad) L 6 Proof 22
• Induction step: k=n+1 • Changes in the counts due to one-step rewrites: cs 466(Prasad) L 6 Proof 23
• In each case, the relationship (to be proved) among the counts of +, *, x and E for a sentential form holds. In other words, each rule application to a sentential form preserves this relationship. • The desired result is obtained by observing that sentences do not contain any variable (non-terminal). cs 466(Prasad) L 6 Proof 24
GENERAL STRATEGY FOR SENTENCE-BASED PROOF • Variable of Induction: Length of derivation of sentence. • Induction Hypothesis: Usually the same as the result to be proved. • Basis Case: Explicitly verify for sentences derivable in (length =) 1 step. • That is, verify for subset of start symbol (LHS) productions that have only terminals on the RHS. cs 466(Prasad) L 6 Proof 25
• Induction Step: • (n+1) steps is divided into 1 step + n steps to create the sub-problems. • This ensures that sub-problems created using can use induction hypothesis about sentences. • The first step must use E-productions with at least one non-terminal on the RHS. Thus, there as many cases as there are E-productions with nonterminals on the RHS. cs 466(Prasad) L 6 Proof 26
GENERAL STRATEGY FOR SENTENTIAL FORM-BASED PROOF • Variable of Induction: Length of derivation of sentential form. • Induction Hypothesis: Usually a generalization of the result to be proved, involving non-terminals. (The result about the sentences is a special case when number of non-terminals is set to 0. ) • Basis Case: Explicitly verify for sentential forms derivable in (length =) 0 steps and 1 step. • That is, verify for start symbol S and all start symbol (LHS) productions. cs 466(Prasad) L 6 Proof 27
• Induction Step: • (n+1) steps is divided into n steps + 1 step to create sub-problems. • The sub-problems created using can use induction hypothesis about sentential forms. • The last step can use all productions applicable to non-terminals in w. So, we need to show that each rule application preserves the induction hypothesis / invariant, e. g. , maintain balance of counts. cs 466(Prasad) L 6 Proof 28
Language of Palindromes A man, a plan, a canal, Panama! Able was I ere I saw Elba. Rats live on no evil star. He goddam mad dog, eh? Madam, I'm Adam. A Santa stops pots at NASA. A Toyota's a Toyota. Tarzan raised a Desi Arnaz rat. Aibohphobia (The fear of palindromes!) cs 466(Prasad) L 6 Proof 29
cs 466(Prasad) L 6 Proof 30
cs 466(Prasad) L 6 Proof 31
cs 466(Prasad) L 6 Proof 32
n = 2 is redundant. Palindromic property + Pattern specified cs 466(Prasad) L 6 Proof 33
cs 466(Prasad) L 6 Proof 34
cs 466(Prasad) L 6 Proof 35
cs 466(Prasad) L 6 Proof 36
cs 466(Prasad) L 6 Proof 37





































