Susmit Jha1, Vasumathi Raman, Sanjit A. Seshia2 1SRI International

Slides:



Advertisements
Similar presentations
Texas Instruments International Conference Chicago, IL 2012 Adapted from NCTM Mathematics Teacher, March 2011, "AN EXCEL-LENT.
Advertisements

Directions: Form into Teams (up to 7 team members) Clear your tables and move chairs against the wall Only 4 people will participate per iteration Four.
Teaching Sight Words To Your Child…. Remember, before you begin…. Make 2 copies of the words on index cards.
Syntax-Guided Synthesis Rajeev Alur Joint work with R.Bodik, G.Juniwal, M.Martin, M.Raghothaman, S.Seshia, R.Singh, A.Solar-Lezama, E.Torlak, A.Udupa 1.
Syntax-Guided Synthesis Rajeev Alur Joint work with R.Bodik, G.Juniwal, M.Martin, M.Raghothaman, S.Seshia, R.Singh, A.Solar-Lezama, E.Torlak, A.Udupa 1.
ISOM MIS 215 Module 7 – Sorting. ISOM Where are we? 2 Intro to Java, Course Java lang. basics Arrays Introduction NewbieProgrammersDevelopersProfessionalsDesigners.
Luddite: An Information Theoretic Library Design Tool Jennifer L. Miller, Erin K. Bradley, and Steven L. Teig July 18, 2002.
TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A Sumit Gulwani (MSR Redmond) Component-based Synthesis Susmit Jha.
Synthesis of Loop-free Programs Sumit Gulwani (MSR), Susmit Jha (UC Berkeley), Ashish Tiwari (SRI) and Ramarathnam Venkatesan(MSR) Susmit Jha 1.
Chapter 2: Algorithm Discovery and Design
1 The game of poker You are given 5 cards (this is 5-card stud poker) The goal is to obtain the best hand you can The possible poker hands are (in increasing.
Algorithms. What is an algorithm?  An algorithm is a clear, concise, and correct step- by-step sequence of actions.
Dimensions in Synthesis Part 3: Ambiguity (Synthesis from Examples & Keywords) Sumit Gulwani Microsoft Research, Redmond May 2012.
Mughal Royalty of India
Sequencing 1 Shuffle the cards and place in a pile with the numbers facing down. Order the cards from 0 to 11. How fast can you do this?
©2009, Tom McKendree Biplanes ©2009, Tom McKendree.
Sequencing Shuffle the cards and place in a pile with the numbers facing down. Order the cards from 0 to 11. How fast can you do this?
P UTTING T HE F IVE P RACTICES OF E XEMPLARY L EADERSHIP I NTO P RACTICE.
Thinking Mathematically Problem Solving and Critical Thinking.
Sequencing 1 Shuffle the cards and place in a pile with the numbers facing down. Order the cards from 0 to 11. How fast can you do this?

Error Explanation with Distance Metrics Authors: Alex Groce, Sagar Chaki, Daniel Kroening, and Ofer Strichman International Journal on Software Tools for.
Introduction to Parsing
CSG3F3/ Desain dan Analisis Algoritma
Helping your child meet their termly maths target
CACheck: Detecting and Repairing Cell Arrays in Spreadsheets
How to do a card trick.
Analysis of Algorithms CS 477/677
Mile-long hurdle race Suppose that we want to program Karel to run a one-mile long hurdle race, where vertical wall sections represent hurdles. The hurdles.
More on Problem Solving
Properties of Operations
Linoleum Block Prints Art B Day 3 Mrs. Lyon.
Probabilistic Algorithms
Learning Invariants using Decision Trees and Implication Counterexamples Pranav Garg Amazon India.
Discrete ABC Based on Similarity for GCP
Prof. Dr. Holger Schlingloff 1,2 Dr. Esteban Pavese 1
A Very Basic Gibbs Sampler for Motif Detection
Synthesis from scenarios and requirements
By Christine Mac, Tanya de Nobrega, Paula Hulse, Keith Kennison
Reasoning about code CSE 331 University of Washington.
Introduction to Sketching
Fast Preprocessing for Robust Face Sketch Synthesis
Artificial Intelligence Problem solving by searching CSC 361
The Birds of a Feather Research Challenge
Lecture 8 Functional synthesis
Random-Number Generation
Objective of This Course
How Hard Can It Be?.
Fractal Wallhanging.
Four-Cut: An Approximate Sampling Procedure for Election Audits
Pedro Freitas MathsJam 2017
CS 188: Artificial Intelligence Fall 2007
Game Loop Update & Draw.
KS3 Mathematics A5 Functions and graphs
Matthew Renner, Trish Beeksma, Patch Kenny
KS3 Mathematics N5 Using Fractions
PowerPoint Slide Shuffler
CSE 2010: Algorithms and Data Structures Algorithms
Programming by Sketching
An explicit state model checker
CO Games Development 1 Week 8 Depth-first search, Combinatorial Explosion, Heuristics, Hill-Climbing Gareth Bellaby.
Procedural Puzzle Challenge Generation in Fujisan 富士山
Recursive construction and error correction of a simple combinatorial library. Recursive construction and error correction of a simple combinatorial library.
Notebooks Table of Contents
Announcements Assignment 7 due now or tommorrow Assignment 8 posted
_Synthesis__________________ __Of_______________________ ___First-Order_____Dynamic___ _____________Programming___ _______________Algorithms___ Yewen (Evan)
Markov Decision Processes
Jiasi Shen, Martin Rinard MIT EECS & CSAIL
Markov Decision Processes
Presentation transcript:

On ∃∀∃! Solving: A Case Study on Automated Synthesis of Magic Card Tricks Susmit Jha1, Vasumathi Raman, Sanjit A. Seshia2 1SRI International 2University of California, Berkeley

Formal Synthesis Given a high-level specification explicitly in a logical form or implicitly as an oracle, generate a formal artifact (program/controller/plan) that satisfies the specification. The space of possible artifacts often represented as a parametric space and synthesis reduces to efficiently searching over this space. Missing constants/holes in a program: A. Solar-Lezama, L. Tancau, R. Bodik, S. A. Seshia, and V. A. Saraswat, “Combinatorial sketching for finite programs.” in ASPLOS, 2006, pp. 404–415 Composition of component functions: S. Jha, S. Gulwani, S. A. Seshia, and A. Tiwari, “Oracle-guided component- based program synthesis,” in ICSE, 2010, pp. 215–224 Successful application in synthesizing programs, plans, controllers, invariants…

Card Trick: Example with 4 cards

Card Trick: Example with four cards

Card Trick: Example with four cards J --- Back Q K A --- Front Trick Summary: Irrespective of the choice from the users, we can ensure that the bottom most card (Jack) will always end up being the odd facing card.

Card Trick: Top Card to Bottom J --- Back Q K A --- Front A --- Back J Q K --- Front

Card Trick: Turn over the top card A --- Back J Q K --- Front A --- Back J Q K’ --- Front

Card Trick: Straight Cut (Audience Choice) A --- Back J Q K’ --- Front K’ --- Back A J Q --- Front Q --- Back K’ A J --- Front J -- Front Q K’ A --- Back A --- Back J Q K’ --- Front

Card Trick: Turn over top two together A --- Back J K Q’ --- Front K’ --- Back A Q’ J’ --- Front Q --- Back K’ J’ A’ --- Front J -- Front Q A’ K --- Back A --- Back J Q K’ --- Front K’ --- Back A J Q --- Front Q --- Back K’ A J --- Front J -- Front Q K’ A --- Back

Card Trick: Loop of Audience Choice Repeat{ // As many times as audience chooses Straight Cut // Audience Choice Turn over top two together }

Card Trick: After a few iterations K’ --- Back A Q’ J’ --- Front

Card Trick: Turn over the top card K’ --- Back A Q’ J’ --- Front K’ --- Back A Q’ J --- Front

Card Trick: Put it to bottom K’ --- Back A Q’ J --- Front J --- Back K’ A Q’ --- Front

Card Trick: Put top to bottom again J --- Back K’ A Q’ --- Front Q’ --- Back J K’ A --- Front

Card Trick: Turn Over the Top Card Q’ --- Back J K’ A --- Front Q’ --- Back J K’ A’ --- Front

Card Trick: Odd facing card ! Q’ --- Back J K’ A’ --- Front Q’ --- Back J K’ A’ --- Front

Card Trick: Example Magic Card Trick: Non-deterministic Program Specification/Property The card which was at the bottom of the stack in the beginning is always odd-facing card at the end ! Take 4 card all facing down Put top card to bottom Turn over top card Turn top card Repeat { //Audience choice on how many times Straight Cut (at position of Audience Choice ) Turn over top two together } Turn over top card and put it to bottom Magic Card Trick: Non-deterministic Program Inputs at different steps

Card Trick: Example Specification/Property SYNTHESIS Take 4 card all facing down Put top card to bottom Turn over top card Turn top card Repeat { //Audience choice on how many times Straight Cut (at position of Audience Choice ) Turn over top two together } Turn over top card and put it to bottom SYNTHESIS Specification/Property The card which was at the bottom of the stack in the beginning is always odd-facing card at the end ! Take 4 card all facing down Put top card to bottom Turn over top card Turn top card Repeat { //Audience choice on how many times Straight Cut (at position of Audience Choice ) Turn over top two together } Turn over top card and put it to bottom Take 4 card all facing down Put top card to bottom Turn over top card Turn top card Repeat { //Audience choice on how many times Straight Cut (at position of Audience Choice ) Turn over top two together } Turn over top card and put it to bottom Take 4 card all facing down Put top card to bottom Turn over top card Turn top card Repeat { //Audience choice on how many times Straight Cut (at position of Audience Choice ) Turn over top two together } Turn over top card and put it to bottom Components MAGIC CARD TRICKS

Component Based Synthesis Straight-line program : Sequence of actions Non-deterministic input to some actions in form of choice from audience ∃ 𝐴 𝑖 1 𝐴 𝑖 2 …∀ 𝑐 1 𝑐 2 … ∃! 𝑠 0 𝑠 1 … 𝜙 𝑑𝑒𝑠 𝐴,𝑐, 𝑠 ∧𝜙 𝑠 0 , 𝑠 𝑘

Composing Component Actions A magic trick is a straight-line program : Sequence of component actions Non-deterministic input to some actions in form of choice from audience State is function of previous state and choice of audience. ∃ 𝐴 𝑖 1 𝐴 𝑖 2 …∀ 𝑐 1 𝑐 2 … ∃! 𝑠 0 𝑠 1 … 𝜙 𝑑𝑒𝑠 𝐴,𝑐, 𝑠 ∧𝜙 𝑠 0 , 𝑠 𝑘

CEGIS: Counterexample guided synthesis Learn from example choices Generate a random sequence 𝐴 𝑖 1 𝐴 𝑖 2 … ∃ 𝐴 𝑖 1 𝐴 𝑖 2 …∃ 𝑠 0 𝑠 1 … [ ∧ 𝑐 𝑗 𝜙 𝑑𝑒𝑠 𝐴, 𝑐 𝑗 , 𝑠 ∧𝜙 𝑠 0 , 𝑠 𝑘 ] Obtain counterexample choice Use verification to obtain counterexample choices ∃ 𝑐 1 𝑐 2 … ∃ 𝑠 0 𝑠 1 … ¬ [ 𝜙 𝑑𝑒𝑠 𝐴,𝑐, 𝑠 ⇒𝜙 𝑠 0 , 𝑠 𝑘 ] Y Learn from example choices Final Magic Sequence Iterate till no counterexample choice left.

Results 1. Baby Hummer : A magic trick of length 10-15, 6 variants of the original trick. 2. Elmsley Shuffles: Repeating in-shuffles and out-shuffles 6-10 times, placing card from any initial position in deck to any target position through apparently random shuffles. 3. Mind-reading card-trick: Distributed magic trick where three audiences cut card decks randomly and select top cards, we find each audience’s card.

Future Work 1. Application to adversarial planning : Non-reactive Plan in presence of adversaries where plan is guaranteed to reach the goal irrespective of adversary’s choice. 2. Understanding magic tricks using program analysis tools. 3. A medium to introduce and teach formal methods to students. Take 4 card all facing down Put top card to bottom Turn over top card Turn top card Repeat { //Audience choice on how many times Straight Cut (at position of Audience Choice ) Turn over top two together } Turn over top card and put it to bottom What is the invariant of this loop?

Thanks. Conclusion: Illustrates the success of formal synthesis approach to automate discover of magic tricks which has been long seen as a creative art.