SlideShare ist ein Scribd-Unternehmen logo
1 von 43
Approximating Context-Free Grammar Ambiguity Claus Brabrand [email_address] BRICS, Department of Computer Science University of Aarhus, Denmark
// Abstract “ Approximating Context-Free Grammar Ambiguity” Context-free grammar ambiguity is undecidable. However, just because it’s undecidable, doesn’t mean there aren’t (good) approximations!  Indeed, the whole area of static analysis works on  “side-stepping   undecidability” . We exhibit a characterization of context-free ambiguity which induces a whole framework for approximating the problem. In particular, we give an approximation, A MN , based on the [Mohri-Nederhof, 2000] regular approximation of context-free grammars and show how to boost the precision even further.
// Outline ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
// Context-Free Grammar ,[object Object],[object Object],[object Object],[object Object],G =    N,   , s,      ,[object Object],[object Object],[object Object],L  : G     P (  *)   language  of G,  L (G)
// Relevant CFG Decision Problems ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
// Ambiguity: Undecidable! ,[object Object],[object Object],[object Object], T s  T’ s  = unambiguous  ambiguous ,[object Object],?
// “Side-Stepping Undecidability” ,[object Object],[object Object],However, just because it’s undecidable, doesn’t mean there aren’t (good)  approximations !  Indeed, the whole area of static analysis works on  “ side-stepping   undecidability ” . unambiguous  ambiguous safe   (over-) approximation unambiguous  ambiguous safe   (under-) approximation unambiguous  ambiguous unsafe  approximation
// Motivation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],unambiguous  ambiguous Yes! .
// Motivation (cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],unambiguous  ambiguous No? . .
// Vertical Ambiguity ,[object Object],[object Object], n     N  :   ,   ’      (n) :         ’     L (  )     L (  ’) =   x a y Z  :  x  A  y :  x  B  y  A  :  a B  :  a Ambiguous string: ~ “ reduce/reduce conflict ”  in [Yacc]  G
// Horizontal Ambiguity ,[object Object],[object Object],[object Object], n     N :         (n):   i    [1..|  |-1]:  L (  0  ..   i-1 )  L (  i  ..   |  |-1  ) =   :  P (  *)     P (  *)     P (  *)  X  Y  =  { x a y | x,y  *     a  +    x,x a  L (X)    y, a y  L (Y) } x a y Z  :  A B  A  :  x  a :  x B  :  a  y :  y Ambiguous string: ~ “ shift/reduce conflict ”  in [Yacc]  G      
// Characterization of Ambiguity ,[object Object],[object Object],[object Object],G     G     G  unambiguous G     G     G  unambiguous G     G     G  unambiguous
// Proof (Lemma 1a): “  ” ,[object Object],[object Object],[object Object],[object Object],[object Object],G     G     G  unambiguous G  ambiguous     G     G G     G
// Proof (Lemma 1a): “  ” (Base) ,[object Object],[object Object],[object Object],[object Object],N  ’ 1  N  1   L (  )     L (  ’)    {  }      p p’ = G
// Proof (Lemma 1a): “  ” (I.H.) ,[object Object],[object Object],[object Object],N n-1     N    n-1  i  ’ i’ …  …  i …  …  ’ i’ p p’ 1 1  |  -1| =   ’ 0  ’ |  ’-1|  0 .. .. .. ..  =  
// Proof (Lemma 1a): “  ” (p  p’) ,[object Object],[object Object],[object Object],L (  )     L (  ’)    {  }      p    p’ G N n-1     N    n-1  i  ’ i’ …  …  i …  …  ’ i’ p p’ 1 1  |  -1| =   ’ 0  ’ |  ’-1|  0 .. .. .. ..  =  
// Proof (Lemma 1a): “  ” (p=p’,1) ,[object Object],[object Object],[object Object],[object Object],[object Object], i :   i  =   ’ i p = p’  i :   i  =   ’ i  N n-1     N    n-1  i  i …  …  i …  …  i’ p p’ 1 1  |  -1| =   0  |  -1|  0 .. .. .. ..  =   G G
// Proof (Lemma 1a): “  ” (p=p’,2) ,[object Object],[object Object],[object Object],[object Object],[object Object],N n-1     N    n-1  i .   …  .  i p  i :   i       ’ i p = p’ p 1 1  i :   i  =   ’ i     i :   i  =   ’ i   j  i:   j       ’ j =   j  j  ’ i .   …  .  i  j  ’ j i     k  < j L (  0  ..   k )  L (  k+1  ..   |  |  )       k k ,[object Object],[object Object],G  
// Proof (Lemma 1b): “  ” ,[object Object],[object Object],[object Object],[object Object],s   * x N       x         * x  a       * x  a  y s   * x N       x   ’       * x  a       * x  a  y N         *  a , N      ’   *  a ,  L (  )     L (  ’ )    { a }      G     G     G  unambiguous G  ambiguous     G     G
// Proof (Lemma 1b): “  ” (cont’d) ,[object Object],[object Object],[object Object],s   * v N       v            * v x         * v x  a   y       * v x  a   y  w s   * v N       v            * v  x   a          * v  x   a  y      * v  x   a  y w N          ,  L (  )  L (  )       x,y      * :   a       +  : x,x a      L (  )    y, a y     L (  ) i.e.  
// (Over-)Approximation (A) ,[object Object],[object Object],[object Object],[object Object],      E* :   L (  )     A (  )   n    N :   ,   ’      (n) :  A (  )     A (  ’) =   A A  n    N:         (n):   i    [1..|  |-1]:  A (  0  ..   i-1 )  A (  i  ..   |  |-1 ) =    G G    
// Ambiguity Approximation ,[object Object],[object Object],[object Object],      G  unambiguous A (  )     A (  ) =        L (  )     L (  ) =   A (  )  A (  ) =        L (  )  L (  ) =   A A          A A G G G G G G    
// Compositionality (of A’s) ,[object Object],[object Object],[object Object],[object Object],A ,  A’   decidable  (over-)approximations     A    A’ decidable  (over-)approximation unambiguous  ambiguous unambiguous  ambiguous unambiguous  ambiguous A A’ A      A’ 
// Choice(s) of A? ,[object Object],[object Object],[object Object],[object Object],[object Object],unambiguous  ambiguous worst approximation
// Choice(s) of A? (cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Black-box
// Decidability (of A MN ) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],X    Y =   X  Y =         G unambiguous A MN A MN    
[object Object],[object Object],// Decision Algorithm for (X  Y)  X NFA Y NFA [X;Y] NFA     a     path :  X NFA Y NFA [X;Y] NFA a a x y x a y a a X Y Y X X    Y   
// Three Approximation Answers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],True answer
// Regaining Lost Precision! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],L (C CFG ) =  L (D DFA )     L (G CFG ) L (C CFG ) =  
// Three Approximation Answers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],True answer
[object Object],[object Object],[object Object],[object Object],// Asymptotic (Time) Complexity N 1   : e 1,1  … e a,1 : … : e 1,p  … e a,p h n v ,[object Object],[object Object],[object Object],[object Object]
// Related Work (Dynamic) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
// Related Work (Static) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
// Implementation ,[object Object],In progress…!
// Assessment ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],In progress…!
// Example: Expression chains ,[object Object],E  ->  E + T ->  T T  ->  T * F ->  F F  ->  ( E ) ->  x
// Example: Balancing Structures ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],S -> A  A A -> x A x -> y xxyxx xyx Example string:
// Future Work ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],E -> E    E
// Conclusion But wait, there’s more… “ Approximating Context-Free Grammar Ambiguity” Context-free grammar ambiguity is undecidable. However, just because it’s undecidable, doesn’t mean there aren’t (good) approximations!  Indeed, the whole area of static analysis works on  “side-stepping   undecidability” . We exhibit a characterization of context-free ambiguity which induces a whole framework for (over-)approximation. In particular, we give an approximation based on the [Mohri-Nederhof, 2000] regular approximation of context-free grammars and show how to boost the precision even further.
// Lessons Learned ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[bonus slides]
// Membership: Decidable! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],      L (G)
[object Object],[object Object],[object Object],[object Object],// Parsing Greedily Left-to-Right x   y   x’   y’   x   y   - (“too little”):  Not possible (due to greediness) ... may occur in 2 cases: - (“too much”): Only this is a problem!    X     X;( prefix(Y) {  } )         X  Y   x’   y’

Weitere ähnliche Inhalte

Was ist angesagt?

Static-talk
Static-talkStatic-talk
Static-talk
giunti
 
Presentation F Sharp
Presentation F Sharp Presentation F Sharp
Presentation F Sharp
guestbfe8bf
 
Unambiguous functions in logarithmic space - CiE 2009
Unambiguous functions in logarithmic space - CiE 2009Unambiguous functions in logarithmic space - CiE 2009
Unambiguous functions in logarithmic space - CiE 2009
Michael Soltys
 
Skiena algorithm 2007 lecture11 breadth deapth first search
Skiena algorithm 2007 lecture11 breadth deapth first searchSkiena algorithm 2007 lecture11 breadth deapth first search
Skiena algorithm 2007 lecture11 breadth deapth first search
zukun
 

Was ist angesagt? (20)

Static-talk
Static-talkStatic-talk
Static-talk
 
Graph Algorithms
Graph AlgorithmsGraph Algorithms
Graph Algorithms
 
Presentation F Sharp
Presentation F Sharp Presentation F Sharp
Presentation F Sharp
 
Unambiguous functions in logarithmic space - CiE 2009
Unambiguous functions in logarithmic space - CiE 2009Unambiguous functions in logarithmic space - CiE 2009
Unambiguous functions in logarithmic space - CiE 2009
 
Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3
 
Lec10
Lec10Lec10
Lec10
 
Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2
 
Ch06
Ch06Ch06
Ch06
 
Dsp iit workshop
Dsp iit workshopDsp iit workshop
Dsp iit workshop
 
Ch4a
Ch4aCh4a
Ch4a
 
NFA Non Deterministic Finite Automata by Mudasir khushik
NFA Non Deterministic Finite Automata by Mudasir khushikNFA Non Deterministic Finite Automata by Mudasir khushik
NFA Non Deterministic Finite Automata by Mudasir khushik
 
Justesen codes alternant codes goppa codes
Justesen codes alternant codes goppa codesJustesen codes alternant codes goppa codes
Justesen codes alternant codes goppa codes
 
Bch and reed solomon codes generation in frequency domain
Bch and reed solomon codes generation in frequency domainBch and reed solomon codes generation in frequency domain
Bch and reed solomon codes generation in frequency domain
 
2.5 graph dfs
2.5 graph dfs2.5 graph dfs
2.5 graph dfs
 
Skiena algorithm 2007 lecture11 breadth deapth first search
Skiena algorithm 2007 lecture11 breadth deapth first searchSkiena algorithm 2007 lecture11 breadth deapth first search
Skiena algorithm 2007 lecture11 breadth deapth first search
 
L3 cfg
L3 cfgL3 cfg
L3 cfg
 
CCG
CCGCCG
CCG
 
Automata
AutomataAutomata
Automata
 
Multimedia Communication Lec02: Info Theory and Entropy
Multimedia Communication Lec02: Info Theory and EntropyMultimedia Communication Lec02: Info Theory and Entropy
Multimedia Communication Lec02: Info Theory and Entropy
 
Context free grammar
Context free grammarContext free grammar
Context free grammar
 

Ähnlich wie Ambiguity Pilambda

Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Nikhil Sharma
 
Algorithm chapter 5
Algorithm chapter 5Algorithm chapter 5
Algorithm chapter 5
chidabdu
 
2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou
vafopoulos
 
09 logic programming
09 logic programming09 logic programming
09 logic programming
saru40
 
MinFill_Presentation
MinFill_PresentationMinFill_Presentation
MinFill_Presentation
Anna Lasota
 

Ähnlich wie Ambiguity Pilambda (20)

Meta-learning and the ELBO
Meta-learning and the ELBOMeta-learning and the ELBO
Meta-learning and the ELBO
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Divergence clustering
Divergence clusteringDivergence clustering
Divergence clustering
 
Ecc2
Ecc2Ecc2
Ecc2
 
Clase3 Notacion
Clase3 NotacionClase3 Notacion
Clase3 Notacion
 
Deep generative model.pdf
Deep generative model.pdfDeep generative model.pdf
Deep generative model.pdf
 
Igv2008
Igv2008Igv2008
Igv2008
 
Algorithm chapter 5
Algorithm chapter 5Algorithm chapter 5
Algorithm chapter 5
 
A discussion on sampling graphs to approximate network classification functions
A discussion on sampling graphs to approximate network classification functionsA discussion on sampling graphs to approximate network classification functions
A discussion on sampling graphs to approximate network classification functions
 
2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou
 
10.1.1.226.4381
10.1.1.226.438110.1.1.226.4381
10.1.1.226.4381
 
Variational autoencoders for speech processing d.bielievtsov dataconf 21 04 18
Variational autoencoders for speech processing d.bielievtsov dataconf 21 04 18Variational autoencoders for speech processing d.bielievtsov dataconf 21 04 18
Variational autoencoders for speech processing d.bielievtsov dataconf 21 04 18
 
Declarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere MortalsDeclarative Datalog Debugging for Mere Mortals
Declarative Datalog Debugging for Mere Mortals
 
Class 29: Inheritance
Class 29: InheritanceClass 29: Inheritance
Class 29: Inheritance
 
New Families of Odd Harmonious Graphs
New Families of Odd Harmonious GraphsNew Families of Odd Harmonious Graphs
New Families of Odd Harmonious Graphs
 
Secure Domination in graphs
Secure Domination in graphsSecure Domination in graphs
Secure Domination in graphs
 
09 logic programming
09 logic programming09 logic programming
09 logic programming
 
MinFill_Presentation
MinFill_PresentationMinFill_Presentation
MinFill_Presentation
 
Approx
ApproxApprox
Approx
 
Divergence center-based clustering and their applications
Divergence center-based clustering and their applicationsDivergence center-based clustering and their applications
Divergence center-based clustering and their applications
 

Mehr von Fatih Gökçe

Mehr von Fatih Gökçe (7)

Comparison Of Adjectives
Comparison Of AdjectivesComparison Of Adjectives
Comparison Of Adjectives
 
Diagrams
DiagramsDiagrams
Diagrams
 
Comparative Sunum
Comparative SunumComparative Sunum
Comparative Sunum
 
Commas
CommasCommas
Commas
 
Audrey Mentortexts
Audrey MentortextsAudrey Mentortexts
Audrey Mentortexts
 
Apostrophe
ApostropheApostrophe
Apostrophe
 
Ambiguity Pilambda
Ambiguity PilambdaAmbiguity Pilambda
Ambiguity Pilambda
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Ambiguity Pilambda

  • 1. Approximating Context-Free Grammar Ambiguity Claus Brabrand [email_address] BRICS, Department of Computer Science University of Aarhus, Denmark
  • 2. // Abstract “ Approximating Context-Free Grammar Ambiguity” Context-free grammar ambiguity is undecidable. However, just because it’s undecidable, doesn’t mean there aren’t (good) approximations! Indeed, the whole area of static analysis works on “side-stepping undecidability” . We exhibit a characterization of context-free ambiguity which induces a whole framework for approximating the problem. In particular, we give an approximation, A MN , based on the [Mohri-Nederhof, 2000] regular approximation of context-free grammars and show how to boost the precision even further.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39. // Conclusion But wait, there’s more… “ Approximating Context-Free Grammar Ambiguity” Context-free grammar ambiguity is undecidable. However, just because it’s undecidable, doesn’t mean there aren’t (good) approximations! Indeed, the whole area of static analysis works on “side-stepping undecidability” . We exhibit a characterization of context-free ambiguity which induces a whole framework for (over-)approximation. In particular, we give an approximation based on the [Mohri-Nederhof, 2000] regular approximation of context-free grammars and show how to boost the precision even further.
  • 40.
  • 42.
  • 43.