learning a meta-solver for syntax-guided program synthesisxsi/data/iclr_poster.pdf · side channels...

1
Type equation here. Learning a Meta-Solver for Syntax-Guided Program Synthesis Xujie 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 -> d 1 OR d 1 | d 1 AND d 1 d 1 -> X OR Y | d 2 OR d 2 d 2 -> ...... Task 1 Logical Spec ! $ X XOR Y OR (X AND Z) Grammar # $ s -> d 1 XOR d 1 d 1 -> d 2 AND d 2 | d 2 OR d 2 | d 2 XOR d 2 d 2 -> ...... Task 2 Global graph embedding: Embedding of production rules d 1 -> X OR Y | d 2 AND d 2 d 1 _OR d 1 _AND ==> ℎ(' " ) ...... GRAPH EMBED Global graph embedding: Embedding of production rules d 1 _AND d 1 _OR ==> ℎ(' $ ) ...... GRAPH EMBED d 1 -> d 2 AND d 2 | d 2 OR d 2 | d 2 XOR d 2 d 1 _XOR S d 1 X d 1 Y OR ? ) (*+") d 1 _OR d 1 _AND Context vector , * Embedding matrix - . / 1 2 * ℎ(' " ,) (*+") ) d 1 ~ d 2 OR d 2 OR S d 1 d 1 AND ? ) (*+") Context vector , * XOR d 2 d 2 Embedding matrix - . / d 1 _AND d 1 _OR d 1 _XOR 1 2 * ℎ(' " ,) (*+") ) ~ d 1 XOR d 2 d 2 = 6∈8 9 ; 8 < [ ] | E ; 6 | METAL: Meta-Learning Framework Experimental Results Challenges 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 H IJK = ( (ℎ P I , P,H ) P∈S(H) ) Learn embedding via message passing I , = ( I VW I ) , =Z I[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 Learned solver Visualization of solved 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. (vulnerable) (side channel free) Semantic Constraint b ,…, d ( b ,…, d ) ≡ ( b ,…, d ) Grammar (Syntactic Constraint) S -> d 1 XOR d 1 | d 1 AND d 1 d 1 -> d 2 AND d 2 | NOT d 2 d 2 -> … d 3 -> 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 AST o Enable information exchange by shared tokens Global node Non-terminals Terminals Graph Representation !(#, %) Typed AST AST edge Global link Logical Spec # X OR Y AND Z Grammar % s -> d 1 OR d 1 | d 1 AND d 1 d 1 -> X | Y | d 2 OR d 2 d 2 -> ...... X X d 2 <spec> OR AND Y Z X S S_OR S_AND d 1 NT_D NT_D AND_D AND_D OR_D OR_D Y X d 1 T NT_D d 1 _or d 2 NT_D OR_D OR_D T_D T_D X Y Z AND OR X_D 2 1 112 12 ...... S_OR S_AND d1 AND_D AND_D OR_D OR_D d1T NI_D d1_or NI_D S_AND AND AND d1 Y X d1T NI_D T_D T_D Repeat ' times Global graph embedding: Node embeddings: Output ...... s d 1 z Embed production rules s -> d 1 OR d 1 | d 1 AND d 1 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 Input Cryptographic Algorithm Output Power Consumption Faulty Outputs EM Emissions Timing Design Details Sound Heat 0110 1001 1011 0010 1110 1001 1011 0110 0010 1110 1001 0000 0110 0100 1110 side channels leaking secrets SyGuS Solver End-user Programming Code Optimization Intelligent Tutor Code Auto-completion Data Transformation

Upload: others

Post on 26-Jul-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Learning a Meta-Solver for Syntax-Guided Program Synthesisxsi/data/iclr_poster.pdf · side channels leaking secrets SyGuSSolver End-user Programming Code Optimization Intelligent

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