370 likes | 584 Views
Induction Proofs. Equivalent Statements in Proofs. q. p. Language Equivalence Proofs. Soundness : All strings derivable in the grammar G have the “characteristic” property of strings in L. Thou shall not lie.
E N D
Induction Proofs Equivalent Statements in Proofs L6Proof
q p L6Proof
Language Equivalence Proofs L6Proof
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. L6Proof
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. L6Proof
How do we generate Derivation Rule Application L6Proof
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: l = 4 L6Proof
Induction Hypothesis: • Induction Step: By context-freeness of the grammar: L6Proof
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.) L6Proof
Example Two proofs for the same result. L6Proof
Prove that if then L6Proof
x x x Informal Argument + + x * x x * x E x x Abstract syntax tree E + E Strictly Binary Trees: # nodes = (2 * #leaves) – 1 # ops + # vars = (2 * #vars) – 1 # ops + 1 = #vars #(+) + #(*) +1 = #(x) E E * Parse tree L6Proof
Proof Alternatives L6Proof
Proof 1: By induction on the length of the derivation of a sentence. • Basis: n = 1 s = x 0 + 0 + 1 = 1 • Induction Hypothesis: L6Proof
Induction step: k=n+1 Possible patterns for w L6Proof
By induction hypothesis: L6Proof
LHS RHS L6Proof
By induction hypothesis: L6Proof
LHS RHS L6Proof
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 L6Proof
Basis: n = 1 w = +EE 1 + 0 + 1 = 0 + 2 w = *EE 0 + 1 + 1 = 0 + 2 w = x 0 + 0 + 1 = 1 + 0 • Induction Hypothesis: L6Proof
Induction step: k=n+1 • Changes in the counts due to one-step rewrites: L6Proof
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). L6Proof
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. L6Proof
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 are as many cases as there are E-productions with non-terminals on the RHS. L6Proof
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 allstart symbol (LHS) productions. L6Proof
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. L6Proof
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!) L6Proof
n = 2 is redundant. Palindromic property + Pattern specified L6Proof