BX from Synchronous
Grammars
Yingfei Xiong, 2013
In cooperation with
Yangyi Wu, Yiming Wu
Synchronous Grammar
• Invented by the natural language processing
community at 60s
• Initially for language translation
• Normal Grammar (postfix expressions)
• N -> N N ‘*’ | N N ‘+’’ | int
• Synchronous Grammar (prefix postfix)
• ‘*’ N N <- N -> N N ‘*’
• ‘+’ N N <- N -> N N ‘+’
• int <- N -> int
Translation with Synchronous
Grammar
• Syntax-directed translation
• Rules on one side => actions on the other side
• N -> N N ‘*’ { print(‘*’ N N); }
• N -> N N ‘+’ { print(‘+’ N N); }
• N -> int {print(int);}
BX with Synchronous Grammar
•
•
•
•
•
•
Composer Composers <- Compsers -> Composer Composers
Composer <- Composers -> Composer
Name ‘,’ Years ‘,’ Country <- Composer -> Name ‘,’ Country
alpha alpha <- Name -> alpha alpha
year ‘-’ year <- Years -> year ‘-’ year
alpha <- Country -> alpha
BX with Synchronous Grammar
• Perdita Steven’s framwork
• R: source and target can be produced by the grammar
• 𝑅 𝑚′ , 𝑛 = 𝑛′
• 𝑅 𝑚, 𝑛′ = 𝑚′
A backward transformation
m
N’
parse
parse
AST_m
AST_n’
Backward merge
AST’
print
m’
BX properties
• Hippocraticness
• Holds when the grammar is unambiguous
• Correctness
• Holds since the syntax-directed translation is just the
inverse of parsing on the same side
• Undoability
• Not hold as usual, since there might be information loss
during changes
Symmetric Lenses
• 𝑝𝑢𝑡𝑟 ∶ 𝑋 × 𝐶 → 𝑌 × 𝐶
• 𝑝𝑢𝑡𝑙 ∶ 𝑌 × 𝐶 → 𝑋 × 𝐶
• We can construct a symmetric lenses by letting C be
the merged AST
Extension: dictionary lenses
• Composer* <- Composers -> Composer*
• key Name ‘,’ Years ‘,’ Country <- Composer -> Name
‘,’ Country
• alpha alpha <- Name -> alpha alpha
• year ‘-’ year <- Years -> year ‘-’ year
• alpha <- Country -> alpha
Expressiveness
• Comparing with Boomerang
• Boomerang is a regular language, unable to handle
cases such as “matching the parentheses”
• Conjecture: Any lenses expressible by Boomerang is
expressible in this approach
• Work-in-progress
• Several basic lens combinators have been translated into
combinators on grammars
• Working on dictionary lenses
Conclusion
• A novel way of constructing BX
• Less learning effort
• Reuse existing asserts: theories, algorithms and
grammars
• Potentially more expressive than Boomerang
© Copyright 2026 Paperzz