Automata, Grammars and Languages - PowerPoint PPT Presentation

1 / 47
About This Presentation
Title:

Automata, Grammars and Languages

Description:

Ex: defining 'big Oh' ... Ex: continuity of a function at a point ('epsilon-delta defn') Abe Lincoln's quote canfool(p,t) = can fool person p at time t ... – PowerPoint PPT presentation

Number of Views:49
Avg rating:3.0/5.0
Slides: 48
Provided by: peterj54
Category:

less

Transcript and Presenter's Notes

Title: Automata, Grammars and Languages


1
Automata, Grammars and Languages
  • Discourse 02
  • Preliminaries

2
Sets
  • Set primitive notion of aggregatefrom which
    all of mathematics and logic can be constructed
  • One small hierarchy of concepts in this course

derives
Grammar
real
sequence
string
function
rational
relation
integer
tuple
set
3
Sets (contd)
  • Predicate P(x) a statement about a variable x
    that is true or false when x is replaced by a
    particular object
  • P(x) x is odd
  • Main predicate for set-membership x ? A
  • Some axioms of set theory
  • Axiom of Extension a set is determined by its
    extension
  • Axiom of Specification For every set A and
    predicate P(x) there is a set
    of all elements of A for which P is
    true.
  • Ex x?Z x is positive and not prime
    4,6,8,9,10,12,

4
Sets (contd)
  • Operations and relations on sets
  • subset
  • proper subset
  • union
  • intersection
  • complement
  • difference
  • size of set
  • Special sets
  • empty set
  • natural numbers

  • integers
  • Sets of sets
  • Power set

5
Logical Implication (Material implication)
  • R ? S If you do not pay us 1M by midnight (R),
    we will shoot your ambassador (S)

6
Logical Implication (contd)
  • P ? Q If you pay us 1M by midnight (P), we
    will not shoot your ambassador (Q)

7
Quantifiers
  • ?
  • ?
  • Ex defining big Oh relationship between
    functions
  • Ex continuity of a function at a point
    (epsilon-delta defn)
  • Abe Lincolns quote canfool(p,t) can fool
    person p at time t

8
Quantifiers (contd)
  • Relationship between ? and ?
  • Ex cannot fool all of the people all of the
    time
  • Ex non-continuity at a point

9
Sets Predicates (U universe)
  • Sets
  • P x P(x)
  • A?B
  • A?B
  • A - B
  • P ? ?
  • P U
  • U - P
  • x? P
  • P?Q
  • PQ
  • Logical Predicates
  • P(x)
  • A(x) ? B(x)
  • A(x) ? B(x)
  • A(x) ? ? B(x)
  • (?x) P(x)
  • (?x) P(x)
  • ? P(x)
  • P(x) true
  • (?x) P(x) ? Q(x)
  • (?x) P(x) ? Q(x)

10
Tuples
  • 3,7 unordered pair 2-tuple
  • (3,7) ordered pair (3,7) ? 3,7,3 (7,3)
    ? 3,7,7
  • Generalize to n-tuple (a1, a2, a3,, an)
  • Defn. Cartesian Product
  • A x B ? (a,b) a?A ? b?B
  • Generalization A1x A2 x x An

11
Binary Relations
  • Defn a binary relation R from A to B is a
    subset of A ? B
  • Defn a function f from A to B, written f A ?
    B, is a relation f ? A ? B that is
    single-valued, i.e.,
  • Defn one-to-one (injection), onto (surjection),
    one-to-one correspondence (bijection)
  • See Definition 4.12, p. 175, text. Also see
    below.

12
Binary Relations 3 views
predicate
set
relation
(postfix)
(infix)
(prefix)
(a,b) ? R
aRb
R (a,b)
lt (3,10)
3 lt 10
(3,10) ? lt
isFatherof (Charles, Andrew)
(Charles,Andrew) ? isFatherof
Charles isFatherof Andrew
13
Why Relations? Generalize Functions.
  • Ex functions
  • Ex division with remainder E ? N?N?N?N
  • Ex circle C ? R?R
  • Ex Relational Database
  • Grammar derives relation

14
Relational Calculus
S
R
?
?
?
a
?
?
c
?
?
b
?
?
?
?
B
C
A
15
Relational Inverse
  • R ? A ? B
  • ________________
  • lt
  • ?
  • FatherOf
  • DivisorOf
  • Hits
  • R -1 ? B ? A
  • _______________
  • gt
  • ?
  • ChildOf
  • MultipleOf
  • Is hit by

R
R-1
A B
B A
16
The Calculus
A
A
  • Proposition. If

17
Proving a Proposition about Relations
  • Thm.
  • Pf (a)
  • Let Then
  • and
  • by definition of ?. So
  • and so
    Since (c, a) was chosen arbitrarily,
  • (b)
  • Let Then
  • and So
  • implying
    Hence
  • Since (c,a) was chosen arbitrarily, (b)
    follows. ?

18
Relational Properties R ? A?B
Relational calculus predicate calculus
name
19
Family Relationships
is Child of
Grandparent
Great n Grandparent
Parent (of child with offspring!)
Parent
Sibling
Sibling or self!
Sibling
Self (erasexual reproduction only )
20
Family Relationships (contd)
i
Nephew, niece or child
c
h
Uncle, Aunt or
f
g
b
Child (w. offspring)
a
e
d
1st Cousin Once Removedor
1st Cousin Once Removed or
Parent or Grandparent
Ancestor
Transitive closure of P
21
Binary Relations on A to itself (A)
  • Ex

Theorem
22
Properties of
Name Defn. Relational Calculus
R reflexive
R symmetric
R transitive
R an equivalence relation ? reflexive,
symmetric transitive
23
A False Proof About Relations
  • Theorem? Clearly any symmetric and transitive
    relation R must be reflexive.
  • Pf? Assume that R is symmetric and
    transitive. Then
  • By transitivity
  • Since a was chosen arbitrarily, it follows
    that
  • Whats wrong?

If (?a)(?b) aRb is true, then the argument is
correct!
24
Binary R ? A?A Digraphs 0-1 Matrices
25
Binary Relations, Digraphs, Matrices (contd)
26
Binary Relations, Digraphs, Matrices (contd)
27
Binary Relations, Digraphs, Matrices (contd)
a
b
d
c
Repeats!
28
Binary Relations, Digraphs, Matrices (contd)
29
Transitive Closure (finite graph)
30
Transitive Closure ? Reachability
  • Defn a reaches b in relation (digraph) R iff
  • Prop a reaches b in R iff aRb
  • Thm Let be a relation
    where Then
  • Pf Longest possible path in G(R) that will
    not repeat an edge is of length n. This path
    will result in an edge in Rn.
  • Ex may need to go all the way up to Rn

31
Strings and Languages
  • In this course, a language is simply a set of
    strings a programming language is much more
    complex
  • alphabet ? - a finite set of symbols
  • String (word) over ? - finite sequence of symbols
  • - the empty or null string
  • w - length of string w
  • What is a string precisely? String w of length n
    is a function
  • String ops
  • concatenation
  • powers

32
Strings and Languages (contd)
  • ?? w w is a string over ? (note
    ? ? ?? )
  • Language L over ? a subset L ? ??
  • Ex
  • Ex ? ASCII codes ( blank \040 ?
    ? )

33
Strings and Languages (contd)
  • Language ops
  • Set operators
  • Concatenation
  • Powers
  • Ex
  • Ex

34
Strings and Languages (contd)
  • Language ops (contd)
  • Defn Kleene Closure (Star)
  • Note
  • Defn
  • Ex
  • Ex

35
Strings and Languages (contd)
  • Theorem
  • Pf
  • Ex

36
Strings and Languages (contd)
  • Ex
  • Ex
  • Ex

37
Methods of Proof
  • Construction exhibit the object guaranteed by
    the theorem.
  • Ex Construction of a regular expression, given
    a FA.
  • Contradiction To show P Assume ?P and derive
    a contraction or clear falsity (reduction ad
    absurdum)
  • Ex our proof of undecidability of the halting
    problem assumed halt program existed and
    derived an absurd contradiction
  • Induction to prove P(n) holds for all
    non-negative integers n

38
Induction
?
39
A Rule of Inference
base
step
conclusion
k ? 0
Prove P(0)
P(k)
k n
T
k ? k1
F
P(n)
Prove P(k) ?P(k1)
  • halts ?n
  • algorithm ? ?n P(n)

40
Kinds of Induction
  • Simple induction
  • _________________
  • Equivalent
  • ______________________________
  • Course-of-Values Induction
  • ___________________

41
Ex Induction Argument Balanced Parens
  • Defn The strings having balanced parentheses
    over (,) are defined (inductively) by
  • The empty string ? is balanced
  • If w is balanced, so is (w)
  • If w, x are balanced, so is wx
  • Nothing else is balanced except by the above
    rules
  • Remark a grammar for balanced strings is
  • Examples
  • Balanced
  • Unbalanced

42
Parentheses (contd)
  • Defn (C) A string w over (,) has the prefix
    property C iff
  • Note the prefix property can be checked in a L-R
    scan of the string using a counter (this is what
    calculators do)
  • Thm A string w is balanced iff it has the
    prefix property.
  • Comment this iff (?, a logical equivalence)
    means we have to prove 2 directions
  • If a string is balanced, it has the prefix
    property (?) (Lemma 1 below)
  • If a string has the prefix property, then it is
    balanced (?) (Lemma 2)

43
Parentheses (contd)
( ( ( ) ( ) ) (
( ( ) ) ) )
( ) ) (
44
Parentheses (contd)
  • Thm A word w is balanced iff it has the prefix
    property.
  • Lemma 1 w balanced ? w has prefix property C.
  • Pf Induction on w
  • Base w0 ? w? ? w satisfies C.
  • Step Let wn. Assume
  • (IH) all strings shorter than n that are
    balanced satisfy C.
  • Let w be balanced. Two cases are possible
  • Case wuv where u,v are balanced. By IH, u,
    v satisfy C. Then
  • and so w satisfies C(a).
  • Next consider a prefix s of wuv. If s is a
    prefix of u then
  • because by IH,
    then w satisfies C(b) for
  • this prefix.

45
Parentheses (contd)
  • If s ut where t is a prefix of v then
  • by IH, and so
  • and so w satisfies C(b) in this case.
  • Case w(u) where u is balanced. By IH u
    satisfies C, and
  • so clearly so does (u) ?

46
Parentheses (contd)
  • Lemma 2 w satisfies C ? w is balanced.
  • Pf Induction on w
  • Base w? is balanced by definition.
  • Step Let wn gt0. Assume
  • (IH) all strings shorter than n that
    satisfy C are balanced.
  • Let w have prefix property C. Let x be the
    shortest prefix
  • of w such that
    Such a prefix exits since
  • w has this property.
  • Case xw Then w (u) where u satisfies C.
    By IH, u is
  • balanced, and so then so is w.
  • Case xvw with v??. Now x satisfies C(a) by
    assumption
  • and satisfies C(b) since w does. So by IH x
    is balanced.

47
Parentheses (contd)
  • We claim that v has property C. Since
  • and then
  • and so v satisfies C(a). Suppose there were
    a prefix y of v such that
    Then
  • Which would violate the prefix property of
    w. Thus it must
  • be that So v
    satisfies C(b).
  • By IH, v is balanced.
  • Since both x and v are balanced, wxv is
    balanced. ?
Write a Comment
User Comments (0)
About PowerShow.com