Type equation here.
Learning a Meta-Solver for Syntax-Guided Program SynthesisXujie Si*, Yuan Yang*, Hanjun Dai, Mayur Naik, Le Song (*equal contribution)
University of Pennsylvania & Georgia Institute of Technology Contact: {xsi,mhnaik}@cis.upenn.edu; {yyang754, hanjundai}@gatech.edu; [email protected]
Logical Spec !"X OR Y AND Z
Grammar #"s -> d1 OR d1 | d1 AND d1d1 -> X OR Y | d2 OR d2d2 -> ......
Task 1
Logical Spec !$X XOR Y OR (X AND Z)
Grammar #$s -> d1 XOR d1d1 -> d2 AND d2 | d2 OR d2
| d2 XOR d2d2 -> ......
Task 2
• Global graph embedding:
• Embedding of production rules
d1 -> X OR Y | d2 AND d2
d1_OR
d1_AND
==>
ℎ('")
......
GRAPH
EMBED
• Global graph embedding:
• Embedding of production rules
d1_AND
d1_OR==>
ℎ('$)
......
GRAPH
EMBED
d1 -> d2 AND d2 | d2 OR d2| d2 XOR d2
d1_XOR
S
d1
X
d1
YOR
?
)(*+")
d1_OR
d1_AND
Context vector ,*
Embedding matrix -./
⊙
1 2* ℎ('" , )(*+"))
d1
~d2
OR
d2OR
S
d1 d1
AND
?
)(*+")
Context vector ,*
XOR
d2 d2
Embedding matrix -./
⊙d1_AND
d1_OR
d1_XOR
1 2* ℎ('" , )(*+"))
~
d1
XORd2 d2
𝑟𝑒𝑤𝑎𝑟𝑑 =∑6∈89∪;8<[𝑓 𝑏 ≡ 𝜙 𝑏 ]
|𝐵E ∪ ;𝐵6|
METAL: Meta-Learning Framework
Experimental ResultsChallenges
Syntax-Guided Program Synthesis
Representation learning and transfer learning of structured data with rich semantics remain open problems. Our work addresses two fundamental challenges in this area:
q How to learn a neural representation of both syntax and semantic constraints?
q How to learn a transferable policy for program synthesis tasks with different syntax G and semantic 𝝓?
Cryptographic circuits synthesis
Synthesize programs using a grammar adaptive policy network
Jointly learn the representation of syntax and semantics
ℎHIJK = 𝑎𝑔𝑔𝑟𝑒𝑔𝑎𝑡𝑒( 𝐹(ℎPI , 𝑒P,H) P∈S(H) )
Learn embedding via message passing
𝐹 ℎI, 𝑒 = 𝜎(𝑊IVWℎI)
𝜋 𝑓 𝜙, 𝐺 =ZI[K
|\|
𝜋 𝑎I ℎ 𝐺 , Τ(I^K))
Learning to solve from scratch(overall: 214)
Meta-learning enables faster solving(train/test: 150/64)
o Collected 214 circuit synthesis tasks from the 2017 SyGuS Competition
o Compared with one baseline solver and two state-of-the-art solvers
o Code and data are available at: https://github.com/PL-ML/metal
EUSolver
CVC4
Esym
Learnedsolver
Visualization ofsolved tasks
The syntax-guided program synthesis (SyGuS) problem aims to find a function f that meets both syntactic and semantic constraints:• syntactic constraint: a context-free grammar G describing the
syntax that captures the candidate implementations of f.• semantic constraint: a logical formula 𝝓 that captures the
desired functionality of f.
Countermeasure Synthesis
Original circuit[Morioka & Satoh, CHES 2002]
Buffered circuit [Ghalaty et al, DATE 2014][Endo et al, IEEE TVLSI, 2014]
Synthesized countermeasure
Countermeasure Synthesis
Original circuit[Morioka & Satoh, CHES 2002]
Buffered circuit [Ghalaty et al, DATE 2014][Endo et al, IEEE TVLSI, 2014]
Synthesized countermeasure
𝜙 (vulnerable)
𝑓(s
ide
chan
nel f
ree)
Semantic Constraint∀𝑖𝑛b, … , 𝑖𝑛d
𝜙(𝑖𝑛b, … , 𝑖𝑛d) ≡ 𝑓(𝑖𝑛b, … , 𝑖𝑛d)
Grammar (Syntactic Constraint)S -> d1 XOR d1 | d1 AND d1d1 -> d2 AND d2 | NOT d2d2 -> …d3 -> in0 | … | in7
Graph construction objective:o Capture the syntax structure and property
(e.g. rule order invariance, symmetry)o Capture the semantic constraint by its ASTo Enable information exchange by shared tokens
Global nodeNon-terminalsTerminals
Graph Representation !(#, %)
Typed ASTAST edgeGlobal link
Logical Spec #X OR Y AND Z
Grammar %s -> d1 OR d1 | d1 AND d1d1 -> X | Y | d2 OR d2d2 -> ......
XX d2
<spec>
OR
AND
Y Z
X
S
S_OR S_AND
d1
NT_DNT_D
AND_DAND_DOR_DOR_D
YX
d1TNT_D
d1_or
d2
NT_D
OR_D
OR_DT_DT_D
X
Y
Z
AND
OR
X_D
<spec>
OR
AND
Y Z
X
S
NI_DNI_D
YXd2
OR_D
OR_D
T_DT_D
X
Y
Z
AND
OR
<spec>
OR
Y Z
X
S
S_OR
d1
NI_DNI_D
AND_D
AND_DOR_DOR_D
YX
d1T
NI_D
d1_or
d2
NI_D
OR_D
OR_D
T_DT_D
X
Y
Z
OR
<spec>
OR
AND
Y Z
X
S
S_OR S_AND
NI_DNI_D
AND_D
AND_DOR_DOR_D
d1_or
d2
NI_D
OR_D
OR_D
X
Y
Z
AND
OR
......
S_OR S_AND
d1
AND_D
AND_DOR_DOR_D
d1T
NI_D
d1_or
NI_D
S_AND
AND
AND
d1
YX
d1T
NI_D
T_DT_D
Repeat ' times
• Global graph embedding:
• Node embeddings:
Output
......
s
d1
z
• Embed production rules
s -> d1 OR d1| d1 AND d1
S_OR
S_AND
==>
ℎ(!)
......One step of message
passing update
Policy network is built in an auto-regressive way
A2C is used for model training, reward is the passing ratio of accumulated examples.
𝑏: counter example ;𝐵6: samples near b
Side Channels
Input CryptographicAlgorithm Output
PowerConsumption Faulty
OutputsEM
Emissions
Timing DesignDetailsSound Heat
What can we observe?
01101001101100101110
10011011011000101110
10010000011001001110
side channels leaking secrets
SyGuS Solver
End-user Programming
Code Optimization
Intelligent Tutor
Code Auto-completion
Data Transformation