Analyzing%20Ambiguity%20of%20Context-Free%20Grammars - PowerPoint PPT Presentation

About This Presentation
Title:

Analyzing%20Ambiguity%20of%20Context-Free%20Grammars

Description:

... applications where grammars are used as models of real-world physical structures. ... Intricate overall structural property of a grammar ... – PowerPoint PPT presentation

Number of Views:71
Avg rating:3.0/5.0
Slides: 61
Provided by: itu75
Category:

less

Transcript and Presenter's Notes

Title: Analyzing%20Ambiguity%20of%20Context-Free%20Grammars


1
Analyzing Ambiguity of Context-Free Grammars
Claus Brabrand brabrand(at)itu.dk IT Uni. of
Copenhagen
Anders Møller amoeller(at)brics.dk DAIMI,
University of Aarhus
Robert Giegerich robert(at)TechFak.Uni-Bielefeld.d
e University of Bielefeld, Germany
2
Abstract
Analyzing Ambiguity of Context-Free Grammars
It has been known since 1962 that the ambiguity
problem for context-free grammars is undecidable.
Ambiguity in context-free grammars is a recurring
problem in language design and parser generation,
as well as in applications where grammars are
used as models of real-world physical structures.
However, the fact that the problem is undecidable
does not mean that there are no useful
approximations to the problem. We observe that
there is a simple linguistic characterization of
the grammar ambiguity problem, and we show how to
exploit this to conservatively approximate the
problem based on local regular approximations and
grammar unfoldings. As an application, we
consider grammars that occur in RNA analysis in
bioinformatics, and we demonstrate that our
static analysis of context-free grammars is
sufficiently precise and efficient to be
practically useful.
3
Outline
  • Introduction (and Motivation)
  • Characterization of Ambiguity
  • (aka. "Vertical-" and "Horizontal-" Ambiguity)
  • Framework (for Analyzing Ambiguity)
  • Regular Approximation (AMN)
  • Assessment (Applications and Examples)
  • Related Work
  • Conclusion

4
Motivation (for CFG Ambiguity)
1
Programming Languages
what the programmer intended
STM EXP "" "if" "(" EXP ")" STM
"if" "(" EXP ")" STM "else" STM
"while" "(" EXP ")" "do" STM EXP EXP ""
TERM EXP "/" TERM TERM TERM
TERM "" FACT TERM "-" FACT
FACT FACT CONST VAR
P
Unambiguous
?
?
int f() if (b) if (c) f() else
y
?
G
?
parser
P'
Ambiguous
...
G
Programminglanguage (CFG)
ComputerScientist
2
Models of Real-World Physical Structures
beneficial...
Ambiguous
P "(" P ")" "(" O ")" O L P P R
S P S H L "." L "." R "." R
"." S "." S "." H "." H "."
"." "."
M
?
prediction of physical structure
?
?
G
?
parser
Unambiguous
lethal...
M'
G
ACGAT
physical structure model (CFG)
Engineer
5
Context-Free Grammar Ambiguity
  • Ambiguity ???? multiple derivation trees ?
  • However Undecidable!
  • i.e., no one can decide this line
  • However2

s
s
?
T
T
Ambiguity means there ?? such that
?
?

?
ambiguous
unambiguous
6
However Conservative Analysis!
  • Use conservative (over-)approximation
  • Yes! ? G guaranteed unambiguous!
  • Safely use any GLR parser on G
  • ...and never get two parses at runtime!

...just because its undecidable, doesnt mean
there arent (good) conservative approximations!
Indeed, the whole area of static analysis works
on side-stepping undecidability.
ambiguous
unambiguous
.
G
Yes!
7
Conservative Analysis (cont'd)
  • Undecidability means therell always be a
    slack
  • However, still useful!
  • Possible interpretations of Don't know?
  • Treat as error (reject grammar)
  • Please redesign your grammar (as in LR(k))
  • Treat as warning
  • Here are some potential problems

ambiguous
.
unambiguous
.
Don't know?
8
Problems with Existing Solutions
  • Hard to reason (locally) about ambiguity
  • Intricate overall structural property of a
    grammar
  • Are "left-to-right" (or "right-to-left")
    biased
  • Cannot handle "palindromic grammars"
  • (...a serious problem for RNA analysis)!
  • Error messages
  • Hard to "pin-point ambiguity" (in terms of
    grammar)
  • Also would like "shortest examples" for
    debugging
  • (...especially for grammar non-experts)!

1
2
3
conflicts 25 shift/reduce, 13 reduce/reduce
9
Outline
  • Introduction (and Motivation)
  • Characterization of Ambiguity
  • (aka. "Vertical-" and "Horizontal-" Ambiguity)
  • Framework (for Analyzing Ambiguity)
  • Regular Approximation (AMN)
  • Assessment (Applications and Examples)
  • Related Work
  • Conclusion

10
Characterization of Ambiguity
  • Theorem 1 (characterization)

G ? G ? G unambiguous
"G is horizontally and Vertically unambiguous"
  • Note
  • Ambiguity fully characterized
  • Still undecidable (...of course)
  • Structural problem ? Finite number of linguistic
    problems

11
TerminologyContext-Free Grammar
EXP ID EXP '' EXP EXP ''
EXP
?N ?? ?N
  • N finite set of nonterminals
  • ? finite set of terminals
  • s ? N start nonterminal
  • ? N ? P(E) production function, E N ?
    ?

G ? N, ?, s, ? ?
  • Assume (trivially)
  • Reachability (all n?N reachable from s)
  • Productivity (all n?N derive some string)

L E ? P(?) "language-of" operator, L(s)
12
Vertical Unambiguity
  • Vertical unambiguity
  • Example ("xy")

G
?n ? N ??, ?' ? ?(n) ? ? ?' ? L(?) ?
L(?') ?
S 'x' Y X 'y' Y 'y' X 'x'
Vertically ambiguous string
?
xy
13
Horizontal Unambiguity
  • Horizontal unambiguity
  • where
    is given by
  • Example ("xay")

G
?n ? N ?? ? ?(n) ? ?l ?r ? L(?l)
L(?r) ?
P(?) ? P(?) ? P(?)
"overlap"
X Y xay x,y?? ? a?? ?
x,xa?L(X) ? y,ay?L(Y)
S X Y V 'x' 'x' 'a' Y 'a'
'y' 'y'
Horizontallly ambiguous string
?
xay
14
Characterization of Ambiguity
  • Theorem 1 (characterization)
  • Lemma 1a (?)
  • Lemma 1b (?)

G ? G ? G unambiguous
"G is horizontally and Vertically unambiguous"
(aka. "soundness")
G ? G ? G unambiguous
(aka. "completeness")
G ? G ? G unambiguous
15
Outline
  • Introduction (and Motivation)
  • Characterization of Ambiguity
  • (aka. "Vertical-" and "Horizontal-" Ambiguity)
  • Framework (for Analyzing Ambiguity)
  • Regular Approximation (AMN)
  • Assessment (Applications and Examples)
  • Related Work
  • Conclusion

16
(Over-)Approximation (A )
  • (Over-)Approximation, A L
  • Approximated vertical unambiguity
  • Approximated horizontal unambiguity
  • A decidable ? emptiness of and
    decidable (on co-dom(A ))

L E ? P(?)
?? ? E L(?) ? A(?)
A E ? P(?)
G
A
?n ? N ??, ?' ? ?(n) ? ? ?' ? A(?) ? A(?')
?
G
A
?n ? N ?? ? ?(n) ? ?l ?r ? A(?l) A(?r)
?
?
17
Unambiguity Approximation
  • Proposition 2 (approximation soundness)
  • Proof
  • "Larger sets don't overlap ? smaller sets don't
    overlap"(contrapositively "Smaller sets
    conflict ? Larger sets conflict")

? ? G unambiguous
G
G
A
A
and hence by transitivity via (Theorem 1)
? ? ?
G
G
G
G
A
A
A(?) ? A(?') ? ? L(?) ? L(?') ?
A(?l) A(?r) ? ? L(?l) L(?r) ?
18
Compositionality (of A's)
  • Proposition 3 (compositionality)
  • Proof
  • Follows from definition proof omitted
  • Alsoapproximations are locally(!)
    compositional

A, A decidable (over-)approximations
? A ? A decidable (over-)approximation
A
ambiguous
A ? A
unambiguous
ambiguous
unambiguous
?
ambiguous
unambiguous
A
19
Are there any Approximations!?!
  • Are there any approximations?!?
  • YES! e.g., "The worst...
    ...approximation"
  • A?(?) ? everything (constant)
  • Almost useless
  • Can only acquit totally trivial grammars as
    unambiguous

but safe(!)
ambiguous
unambiguous
worst approximation
N 'x'
20
Outline
  • Introduction (and Motivation)
  • Characterization of Ambiguity
  • (aka. "Vertical-" and "Horizontal-" Ambiguity)
  • Framework (for Analyzing Ambiguity)
  • Regular Approximation (AMN)
  • Assessment (Applications and Examples)
  • Related Work
  • Conclusion

21
Regular Approximation (AMN)!
  • AMN(?) Mohri-NederhofG(?)
  • CFG ? REGDFA (Over-)Approximation
  • Properties of this
  • Good (over-)approximation!
  • Produces regular languages
  • almost everything is decidable (constructively,
    via automata)!
  • Note
  • Works on a language-level, L(G), ...
  • ...not on the structure-level of the grammar, G

Regular Approximation of Context-Free Grammars
through Transformation Mohri-Nederhof, 2000
Black-box
22
Example Odd/Even
  • Keeping track of parity (odd/even)

Start Even Odd
Even "(" "(" Even ")" ")"
? Odd
"(" "(" Odd ")" ")" "(" ")"

?
?
unambiguous grammar!
L(Even) (2n )2n n?0
L(Odd) (2n1 )2n1 n?0
A(Even)
A(Odd)
(2n )2m n,m?0
(2n1 )2m1 n,m?0
23
Outline
  • Introduction (and Motivation)
  • Characterization of Ambiguity
  • (aka. "Vertical-" and "Horizontal-" Ambiguity)
  • Framework (for Analyzing Ambiguity)
  • Regular Approximation (AMN)
  • Assessment (Applications and Examples)
  • Related Work
  • Conclusion

24
Assessment (implementation)
  • Java implementation
  • 7,400 lines of code (command line GU interface)

www.brics.dk/grammar/
25
Technology Transfer
  • Integrated in DotVocal's "Grammar Studio"

Ambiguity analysis Grammar Studio provides
developers a powerful algorithm to test the
vertical and horizontal ambiguities. Erasing any
ambiguity in a grammar means to improve the
effectiveness and by consequence the recognition
too.
26
Examples Palindromesand "Anti-palindromes"
  • Palindromic examples

P "a" P "a" "a"

P "a" P "a" "b" P "b" "b"
"a"
P "a" P "a"
unambiguous grammar!
unambiguous grammar!
unambiguous grammar!
R "a" R "b" "b" R "a" "a"
"b" "b" "a"
R "a" R "b" "b" R "a"

Note all are non-LR-Regular grammars !! ?
unambiguous grammar!
unambiguous grammar!
27
...inherent in RNA Analysis!!!
"Predicting behavior of genes"
"Complimentary base pairs" // 'G-C', 'A-U', and
'G-U' R 'G' R 'C' 'C' R 'G' 'A' R
'U' 'U' R 'A' 'G' R 'U' 'U' R 'G'
?
28
Examples RNA Analysis (G1)
  • RNA Analysis (G1)

gt java jar Grambiguity.jar G1.cfg vertical
ambiguity detected 'SaS' vs. 'SSa'
ambiguous string "." vertical ambiguity
detected 'Saa' vs. 'SSS' ambiguous
string "()" vertical ambiguity detected
'SaS' vs. 'SSS' ambiguous string
"." vertical ambiguity detected 'SSa' vs.
'SSS' ambiguous string "." vertical
ambiguity detected 'SSS' vs. 'Sempty'
ambiguous string "" horizontal ambiguity
detected 'SSS0..0' vs. 'SSS1..1'
ambiguous string "." ambiguous grammar 5
vertical ambiguities 1 horizontal ambiguity
/ ambiguous / Saa "(" S ")" aS
"." S Sa S "." SS S
S empty
G1
29
Examples RNA Analysis (G2)
  • RNA Analysis (G2)

vertical ambiguity detected 'SaS' vs.
'SSa' ambiguous string "." vertical
ambiguity detected 'SaPa' vs. 'SSS'
ambiguous string "()" vertical ambiguity
detected 'SaS' vs. 'SSS' ambiguous
string "." vertical ambiguity detected
'SSa' vs. 'SSS' ambiguous string
"." vertical ambiguity detected 'SSS' vs.
'Sempty' ambiguous string "" vertical
ambiguity detected 'PaPa' vs. 'PS'
ambiguous string "()" horizontal ambiguity
detected 'SSS0..0' vs. 'SSS1..1'
ambiguous string "." ambiguous grammar 6
vertical ambiguities 1 horizontal ambiguity
/ ambiguous / SaPa "(" P ")" aS
"." S Sa S "." SS S
S empty PaPa "("
P ")" S S
G2
30
Examples RNA Analysis (G3-G6)
  • RNA Analysis (G3,G4,G5,G6)

SaS "." S T T empty
TTa T "." aSa "(" S ")"
TaSa T "(" S ")"
G4
SaPa "(" P ")" aL "." L Ra
R "." LS L S LaPa "(" P ")"
aL "." L RRa R "." empty
PaPa "(" P ")" aNa "(" N ")"
NaL "." L Ra R "." LS
L S
G3
SLS L S L L LaFa "(" F
")" a "." FaFa "(" F ")"
LS L S
G6
unambiguous grammar!
SaS "." S aSaS "(" S ")" S
empty
G5
31
Examples RNA Analysis (G7G8)
  • RNA Analysis (G7,G8)

SaPa "(" P ")" aL "." L
Ra R "." LS L S
LaPa "(" P ")" aL "." L
RRa R "." empty
PaPa "(" P ")" aNa "(" N ")"
NaL "." L Ra R "."
LS L S
G7
(potential) vertical ambiguity detected
'PaPa' vs. 'PaNa' shortest ambiguous
string "(((.)" (potentially) ambiguous
grammar 1 (potential) vertical ambiguity 0
(potential) horizontal ambiguities
Note these are all spurious errors due to
imprecisions in the analysis ?
SaS "." S T T empty
TTa T "." aPa "(" P ")"
TaPa T "(" P ")" PaPa "(" P ")"
aNa "(" N ")" NaS "." S Ta
T "." TaPa T "(" P ")"
G8
Acquitted as unambiguoususing unfolding
technique!
(potential) vertical ambiguity detected
'PaPa' vs. 'PaNa' shortest ambiguous
string "(((.)" (potentially) ambiguous
grammar 1 (potential) vertical ambiguity 0
(potential) horizontal ambiguities
32
Examples "voss" "voss-light"
P "(" P ")" // P Closed structure "("
O ")" O L P // O Open structure
P R S P S H L "." L
// L Left bulge "." R "." R
// R Right bulge "." S "." S
// S Singlestrand "." H "." H
// H Hairpin 3loop "." "." "."
LR(k) LR(1) 3 r/r conflicts LR(3) 12 r/r
conflicts LR(5) 93 r/r conflicts LR(7) 249
r/r conflicts LR(9) 513 r/r conflicts ...
unambiguous grammar!
33
Example Java Expressions
Expassign Exp1 "" Exp exp1
Exp1 Exp1or Exp1 "" Exp2
exp2 Exp2 Exp2and
Exp2 "" Exp3 exp3 Exp3
Exp3eq Exp3 "" Exp4
neq Exp3 "!" Exp4 exp4
Exp4 Exp4lt Exp4 "lt" Exp5
leq Exp4 "lt" Exp5 gt
Exp4 "gt" Exp5 geq Exp4 "gt"
Exp5 exp5 Exp5
/ -- cont'd -- / Exp5add Exp5 ""
Exp6 sub Exp5 "-" Exp6
exp6 Exp6 Exp6mul Exp6
"" Exp7 div Exp6 "/" Exp7
exp7 Exp7 Exp7not "!" Exp7
exp8 Exp8 Exp8par
"(" Exp ")" con Con
Connum "0" id
"x"
unambiguous grammar!
34
Error Messages (Amb. Example)
  • Ambiguous Expressions

Eplus E "" E mult E "" E
x "x"
?
?
?
?
?
precedence "" vs. ""
vertical ambiguity detected 'Eplus' vs.
'Emult' ambiguous string xxx
horizontal ambiguity detected 'Eplus0..0' vs.
'Eplus1..2' ambiguous string xxx
horizontal ambiguity detected 'Eplus0..1' vs.
'Eplus2..2' ambiguous string xxx
horizontal ambiguity detected 'Emult0..0' vs.
'Emult1..2' ambiguous string xxx
horizontal ambiguity detected 'Emult0..1' vs.
'Emult2..2' ambiguous string xxx
ambiguous grammar 1 vertical ambiguity 4
horizontal ambiguities
assoc. of ""
assoc. of ""
35
Benchmark Grammars
UNAMBIGUOUS
LR(k)
..
LR(8)
LR(7)
LR(6)
LR(5)
LR(4)
LR(3)
G1
LR(2)
(5V1H)
LR(1)
LALR(1)
G8
Exp
Amb-Exp
G4
O/E
(1V4H)
G6
G5
G2
(6V1H)
P
Base
Voss
R
G7
Voss-light
G3
OUR
AMBIGUOUS
36
Benchmarks (from Schmitz 2007)
Unambiguous
37
Benchmarks (from Schmitz 2007)
Ambiguous
38
Outline
  • Introduction (and Motivation)
  • Characterization of Ambiguity
  • (aka. "Vertical-" and "Horizontal-" Ambiguity)
  • Framework (for Analyzing Ambiguity)
  • Regular Approximation (AMN)
  • Assessment (Applications and Examples)
  • Related Work
  • Conclusion

39
Related Work (Dynamic)
  • Dynamic disambiguation
  • Disambiguation-by-convention
  • Longest match, most specific match,
  • Customizable
  • Bison v. 1.5 dprec, merge
  • ASFSDF disambiguation filters
  • Dynamic ambiguity interception
  • GLR (Tomita, Early, Bison, ASFSDF, )
  • AMBER

40
Related Work (Static)
  • Static disambiguation
  • Disambiguation-by-convention
  • First match, most specific match,
  • Customizable
  • Yacc left, right, nonassoc, prec
  • Static ambiguity interception
  • Our work goes here
  • LL(k), LALR(1), LR(k), LR-regular,
  • Sylvain Schmitz (ICALP 2007) "Conservative
    Ambiguity Detection in Context-Free Grammars"
  • "An Experimental Ambiguity Detection Tool" (LDTA
    2007)
  • Subsumes LR-regular, Incomparable to our technique

S A A A 'a' A 'a' 'b'
?
41
Comparative Related Work
  • "Ambiguity Detection Methods for Context-Free
    Grammars"
  • H. J. S. Bas Basten (Master's thesis)
  • CWI, Universiteit van Amsterdam, Holland
  • "Ambiguity Detection for Context-Free Grammars in
    Eli"
  • Michael Kruse (Master's thesis)
  • Uni. Paderborn, Germany

42
Outline
  • Introduction (and Motivation)
  • Characterization of Ambiguity
  • (aka. "Vertical-" and "Horizontal-" Ambiguity)
  • Framework (for Analyzing Ambiguity)
  • Regular Approximation (AMN)
  • Assessment (Applications and Examples)
  • Related Work
  • Conclusion

43
Conclusion
  • Advantages (of our approach)
  • Characterization!
  • ? Possible to reason (locally) about ambiguity
  • ? (Composable) Analysis Framework
  • ? Complete decision procedure for regular
    grammars
  • ? Inherently parallelizable
  • ? DFA Counterexamples
  • ? and shortest (possibly) ambiguous string
  • ? Not "left-to-right" or "right-to-left" biased
  • ? Can handle palindromic grammars
  • ? Well-suited for RNA analysis )

44
Conclusion (cont'd)
Analyzing Ambiguity of Context-Free Grammars
It has been known since 1962 that the ambiguity
problem for context-free grammars is undecidable.
Ambiguity in context-free grammars is a recurring
problem in language design and parser generation,
as well as in applications where grammars are
used as models of real-world physical structures.
However, the fact that the problem is undecidable
does not mean that there are no useful
approximations to the problem. We observe that
there is a simple linguistic characterization of
the grammar ambiguity problem, and we show how to
exploit this to conservatively approximate the
problem based on local regular approximations and
grammar unfoldings. As an application, we
consider grammars that occur in RNA analysis in
bioinformatics, and we demonstrate that our
static analysis of context-free grammars is
sufficiently precise and efficient to be
practically useful.
45
Thank you
  • Questions, please?

46
BONUS SLIDES
47
Other Approximation Strategies
  • The EmptyString Approximation
  • The MayMust Approximation

48
Asymptotic (Time) Complexity
h
  • Mohri-Nederhof O(n2vh)
  • Vertical Amb O(n3v4h4)
  • Horizontal Amb O(n3v3h5)
  • Total O(n3v3h4(vh)) ? O(g5)

N1 e1,1 ea,1 e1,p ea,p
  • n N
  • v max ?(N), N?N
  • h max ?, ???(N), N?N
  • g nvh G



v

n
49
AMN is Decidable!
  • .
  • Constructively decidable (using DFAs)
  • O(XDFAYDFA)
  • Constructively decidable (using DFAs)
  • O(XDFAYDFA)
  • Constructively decidable
  • with potential counterexamples (as DFAs)i.e.,
    we can extract shortest (potentially ambiguous)
    strings!

X ? Y ?
X Y ?
?
AMN
AMN
50
Decision Algorithm for (X Y)
  • For X,Y regular languages (NFAs)
  • All overlappings, xay (as DFA's)
  • (essentially a variant of "DFA
    product-construction", '?')

a
a
?
x
y
XNFA
YNFA
X'NFA
Y'NFA
XYNFA
a
? a ? path
?
a
51
Example Expressions
  • Expressions

Note General problem with non-linear recursive
structures However, there's a trick...
Eterm T plus E "" T
Tx "x" par "(" E ")"
(potential) vertical ambiguity detected
'Eterm' vs. 'Eplus' shortest ambiguous
string "xx" (potential) horizontal
ambiguity detected 'Eplus0..0' vs.
'Eplus1..2' shortest ambiguous string
"xxx" (potential) horizontal ambiguity
detected 'Eplus0..1' vs. 'Eplus2..2'
shortest ambiguous string "xxx"
(potentially) ambiguous grammar 1 (potential)
vertical ambiguity 2 (potential) horizontal
ambiguities
52
Examples Expressions (cont'd)
  • Expressions

unfold trick (inside/outside) parentheses
E T E "" T T "x" "(" E ")"
E
Eterm T plus E "" T
Tx "x" par "(" E ")"
AST
? x(x(xx)x)x
G
G
Gu
E T E "" T T "x" "(" E ")" E
T E "" T T "x" "(" E ")"
?
unfold wrt. '(' and ')'
Gu
Eterm T plus E "" T
Tx "x" par "(" E ")"
Eterm T plus E "" T
Tx "x" par "(" E ")"
E
ASTu
?u x(x(xx)x)x
unambiguous grammar!
53
Proof (Lemma 1a) ?
  • Lemma 1a
  • contrapositively
  • Proof structure
  • Assume G ambiguous (i.e. ? 2 der. trees for ?)
  • Show
  • by induction in max height of the 2 derivation
    trees

G ? G ? G unambiguous
G ambiguous ? G ? G
G ? G
54
Proof (Lemma 1a) ? (Base)
  • Base case (height ? 1)
  • The ambiguity means that
  • However, this means that ? t0 t1
    .. t?-1 ?'(i.e. the two trees must be the
    same) and so the result holds vacuously

N
?
N
1
1
?
?
?
?

55
Proof (Lemma 1a) ? (I.H.)
  • Induction step (height ? n)
  • Assume induction hypothesis (for height ? n-1)
  • The ambiguity means

N
N
1
1
?i
?i


?
n-1 ?
? n-1
Ti
T'i
..
..
..
..
?i
?i
??-1 ?0
??-1
?0
?
56
Proof (Lemma 1a) ? (???)
  • Case (i.e. different production)
  • but then ?
  • i.e., we have a vertical ambiguity

N
N
1
1
?i
?i


?
n-1 ?
? n-1
Ti
T'i
..
..
..
..
?i
?i
??-1 ?0
??-1
?0
?
? ? ?
L(?) ? L(?) ? ? ? ?
G
57
Proof (Lemma 1a) ? (??,1)
  • Case (i.e., same prod. ?
    )
  • i.e. the top of the trees are the same
  • Case
  • ?ambiguity in subtreei (i.e. ambiguously
    derive same ?i)
  • Induction hypothesis (on these subtrees) ?

N
N
1
1
?i
?i


?
n-1 ?
? n-1
Ti
T'i
..
..
..
..
?i
?i
??-1 ?0
??-1
?0
?
? ?
?i ?i ?i
?i ?i ?i
Ti
T'i
?
G
G
58
Proof (Lemma 1a) ? (??,2)
  • Case (i.e., same prod. ?
    )
  • Case (i.e., )
  • Now let k min i ?i ?'i
  • ...then

? ?
?i ?i ?i
?i ?i ? ?i
? ?i ?i ?i
?
L(?0 .. ?k) L(?k1 .. ?? ) ? xay' ? ?
G
N
N
1
1
?k
?k
...
...
?
n-1 ?
? n-1
?k
?'k


xay'
x
y
x'
y'
59
Proof (Lemma 1b) ?
  • Lemma 1b
  • ...contrapositively
  • Proof Assume (vertical conflict)
  • But then derive (using reachability
    derivability of N)

G ? G ? G unambiguous
G ambiguous ? G ? G
N ? ? ? a, N ? ? ? a, L(?) ? L(?) ? a ? ?
for some N
s ? x N ? ? x ? ? ? x a ? ? x a y
G ambiguous
s ? x N ? ? x ? ? ? x a ? ? x a y
60
Proof (Lemma 1b) ? (contd)
  • Assume (horizontal conflict)
  • Then for some N?N
  • But then derive (using reachability
    derivability of N)

N ? ?l ?r , where L(?l) L(?r) ? ?
i.e.
?x,y ? ? ?a ? ? x,xa ? L(?l) ? y,ay ? L(?r)
s ? v N ? ? v ?l ?r ? ? v x ?r ? ? v x a y
? ? v x a y w
G ambiguous
s ? v N ? ? v ?l ?r ? ? v x a ?r ? ? v x a y ?
? v x a y w
61
Vertical Horizontal Unamb.
  • Theorem
  • Vertical unambiguity
  • Horizontal unambiguity

G ? G ? G unambiguous
G
?n ? N ??, ?' ? ?(n) ? ? ?' ? L(?) ?
L(?') ?
G
?n ? N ?? ? ?(n) ? ?l ?r ? L(?l)
L(?r) ?
P(?) ? P(?) ? P(?)
"overlap"
X Y xay x,y?? ? a?? ?
x,xa?L(X) ? y,ay?L(Y)
Write a Comment
User Comments (0)
About PowerShow.com