Monday 24 June 2013

Pumping Lemma for Context Free Languages

  The Pumping Lemma is used to prove a language is not context free.

  If a PDA machine can be constructed to exactly accept
  a language, then the language is proved a Context Free Language.

  If a Context Free Grammar can be constructed to exactly generate the
  strings in a language, then the language is Context Free.

  To prove a language is not context free requires a specific definition of
  the language and the use of the Pumping Lemma for Context Free Languages.

  A note about proofs using the Pumping Lemma:

  Given: Formal statements A and B.
         A implies B.
  If you can prove B is false, then you have proved A is false.

        A  B | A implies B
        -----+------------
        F  F |     T
        F  T |     T   (you can prove anything to be true with a false premise)
        T  F |     F
        T  T |     T

  For the Pumping Lemma, the statement "A" is "L is a Context Free Language",
  The statement "B" is a statement from the Predicate Calculus.
  (This is a plain text file that uses words for the upside down A that
   reads 'for all'  and the backwards E that reads 'there exists')

   Formal statement of the Pumping Lemma:

   L is a Context Free Language implies 
   (there exists n)(for all z)[z in L and |z|>=n implies
     {(there exists u,v,w,x,y)(z = uvwxy and |vwx|<=n and |vx|>=1 and
                                            i  i
                           (for all i>=0)(uv wx y is in L) )}]

  The two commonest ways to use the Pumping Lemma to prove a language
  is NOT context free are:

  a) show that there is no possible n for the (there exists n),
     this is usually accomplished by showing a contradiction such
     as  (n+1)(n+1) < n*n+n

  b) show there is no way to partition some z into u,v,w,x,y such that
       i  i
     uv wx y is in L, typically for a value i=0 or i=2.
     Be sure to cover all cases by argument or enumerating cases.
     [This gives a contradiction to the (for all z) clause.]


  Some Context free languages and corresponding grammars:

      i i
  L={a b  | i>=1}   S->ab | aSb

      2i 3i
  L={a  b   | i>=1}  S-> aabbb | aaSbbb    [any pair of constants for 2,3] 

      i j i
  L={a b c  | i,j>=1}   S->aBc | aSc   B->b | bB

      i i j
  L={a b c  | i,j>=1}   S->DC   D->ab | aDb    C->c | cC

      i i j j
  L={a b a b  | i,j>=1}  S->CC  C->ab | aCb

       i  i
  L={ua wb y | i>=1 and u,w,y any fixed strings}  S->uDy  D->awb | aDb

       R                        R
  L={ww  | w in Sigma star and w  is w written backwards}  S->xx | xSx
                                                           for all x in Sigma

  Some languages that are NOT Context Free Languages

  L={ww | w in Sigma star}

      i i i
  L={a b c  | i>=1}

      i j k
  L={a b c  | k > j > i >=1}

      f(i)  i
  L={a     b  | i>=1}  where f(i)=i**2   f(i) is the ith prime,
                       f(i) not bounded by a constant times i
                       meaning f(i) is not linear

      i j i j
  L={a b c d  | i, j>=1}

Review of basics of proofs:

You may be proving a lemma, a theorem, a corollary, etc

A proof is based on:
  definition(s)
  axioms
  postulates
  rules of inference  (typical normal logic and mathematics)

To be accepted as "true" or "valid"
   Recognized people in the field need to agree your
      definitions are reasonable
      axioms, postulates, ... are reasonable
      rules of inference are reasonable and correctly applied

"True" and "Valid" are human intuitive judgments but can be
based on solid reasoning as presented in a proof.


Types of proofs include:
  Direct proof  (typical in Euclidean plane geometry proofs)
     Write down line by line  provable statements,
     (e.g. definition, axiom, statement that follows from applying
      the axiom to the definition, statement that follows from
      applying a rule of inference from prior lines, etc.)

  Proof by contradiction:
     Given definitions, axioms, rules of inference
     Assume Statement_A
     use proof technique to derive a contradiction
     (e.g.  prove not Statement_A or prove Statement_B = not Statement_B,
            like 1 = 2  or  n > 2n)

  Proof by induction (on Natural numbers)
     Given a statement based on, say n, where n ranges over natural numbers
     Prove the statement for n=0 or n=1 
     a) Prove the statement for n+1 assuming the statement true for n
     b) Prove the statement for n+1 assuming the statement true for n in 1..n

  Prove two sets A and B are equal, prove part 1, A is a subset of B
                                    prove part 2, B is a subset of A

  Prove two machines M1 and M2 are equal,
        prove part 1 that machine M1 can simulate machine M2
        prove part 2 that machine M2 can simulate machine M1

Limits on proofs:

Godel incompleteness theorem:
  a) Any formal system with enough power to handle arithmetic will
     have true theorems that are unprovable in the formal system.
     (He proved it with Turing machines.)
  b) Adding axioms to the system in order to be able to prove all the
     "true" (valid) theorems will make the system "inconsistent."
     Inconsistent means a theorem can be proved that is not accepted
     as "true" (valid).
  c) Technically, any formal system with enough power to do arithmetic
     is either incomplete or inconsistent.

No comments:

Post a Comment