SlideShare uma empresa Scribd logo
1 de 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’

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Semelhante a 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
 

Semelhante a 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
 

Mais de Fatih Gökçe

Mais de 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
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 

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.