SlideShare a Scribd company logo
M.-A. Plourde, S. Hallé
Marc-Antoine Plourde and Sylvain Hallé
Université du Québec à Chicoutimi
CANADA
A Generic And Flexible Data
Structure Generator
CRSNG
NSERC
synthia
synthia
M.-A. Plourde, S. Hallé
A software sytem
I
M.-A. Plourde, S. Hallé
A software sytem
I
♠ ♣
* #
♦
?
M.-A. Plourde, S. Hallé
A software sytem
I
M.-A. Plourde, S. Hallé
A software sytem
I
2
3
4
π
M.-A. Plourde, S. Hallé
A software sytem
I
abc
M.-A. Plourde, S. Hallé
A software sytem
I
M.-A. Plourde, S. Hallé
A software sytem
I
,
M.-A. Plourde, S. Hallé
A software sytem
I
, +
⊇?
,
M.-A. Plourde, S. Hallé
A software sytem
I
, +
⊇?
, OK
+ abc
foo
,
M.-A. Plourde, S. Hallé
A software sytem
I
, +
⊇?
, OK
+ abc
foo
,
M.-A. Plourde, S. Hallé
A software sytem
I
M.-A. Plourde, S. Hallé
A software sytem
I
Size 10 20 30 40 50 60 70 80 90 . . .
. . .
M.-A. Plourde, S. Hallé
Generating "synthetic" inputs
M.-A. Plourde, S. Hallé
Generating "synthetic" inputs
script
M.-A. Plourde, S. Hallé
Generating "synthetic" inputs
script
M.-A. Plourde, S. Hallé
Generating "synthetic" inputs
script
M.-A. Plourde, S. Hallé
Generating "synthetic" inputs
M.-A. Plourde, S. Hallé
synthia
synthia
Enter Synthia
A Java library to facilitate the generation of
synthetic objects of various kinds
Intended to be reusable from one scenario to the
next
Provides high-level abstractions of common
functionalities
M.-A. Plourde, S. Hallé
Pickers
The library is centered on the concept of Picker; it
is an interface defining a method called pick.
P
picker
interface Picker<T> {
public T pick();
}
pick? t
M.-A. Plourde, S. Hallé
Some built-in Pickers
Random integer in interval [m,n]
[m,n]
42
42
42
¼
42
p
λ
42
3
Uniform float in interval [0,1]
Integer in Poisson distribution of parameter λ
Integer in Gaussian distribution N(0,1)
Biased coin flip with probability p
M.-A. Plourde, S. Hallé
Some built-in Pickers
Random integer in interval [m,n]
[m,n]
42
42
42
¼
42
p
λ
42
3
Uniform float in interval [0,1]
Integer in Poisson distribution of parameter λ
Integer in Gaussian distribution N(0,1)
Biased coin flip with probability p
seed
M.-A. Plourde, S. Hallé
Seedable Pickers
[m,n]
Pseudo-random pickers implement an interface
called Seedable, whose method setSeed can be
used to set the starting seed of the algorithm.
setSeed(42)
Each Seedable picker guarantees to generate the
same objects in the same order for a given starting
seed.
M.-A. Plourde, S. Hallé
Other built-in Pickers
[a,b,c,d]
Playback outputs objects by iterating on a
predefined list, optionally looping around.
Constant is a special Playback producing a single
value.
c
list of objects
loop
value
M.-A. Plourde, S. Hallé
Resettable and Duplicable Pickers
Pickers implement two other interfaces, each
defining a single additional method.
Duplicable: method duplicate creates a copy of
the current picker and places the new copy in
current internal state of the original
Resettable: method reset puts a picker back into
the state it was at construction
This is also true of Seedable (i.e. pseudo-random)
pickers!
M.-A. Plourde, S. Hallé
P
A picker can be instantiated by giving
references to other picker instances.
The picker calls these other pickers to
decide how to generate its own
objects.
Graphically, this results in a "wiring diagram" of
interconnected pickers.
Wiring diagram
M.-A. Plourde, S. Hallé
Tick
s δ
For example: the Tick picker is parameterized by
two pickers producing numbers.
M.-A. Plourde, S. Hallé
Tick
s δ
For example: the Tick picker is parameterized by
two pickers producing numbers.
start value increment
M.-A. Plourde, S. Hallé
0 1
0, 1, 2, 3, 4, 5, ...
Tick
s δ
For example: the Tick picker is parameterized by
two pickers producing numbers.
M.-A. Plourde, S. Hallé
42 1
7, 8, 9, 10, 11, 12, ...
[0,10]
Tick
s δ
For example: the Tick picker is parameterized by
two pickers producing numbers.
M.-A. Plourde, S. Hallé
0 [1,2]
0, 1, 3, 4, 6, 7, ...
Tick
s δ
For example: the Tick picker is parameterized by
two pickers producing numbers.
M.-A. Plourde, S. Hallé
http://www.retrolinear.com/services/analog-synth-restoration.aspx
"Pickers parameterized by other pickers": powerful
concept making Synthia very flexible to generate
objects following various patterns.
Wiring diagram
Similar in nature
to synthesizers of
the 1970s, with
modules connected
by patch cables!
M.-A. Plourde, S. Hallé
Create list/set/array of given size with
objects from upstream picker
Other built-in Pickers
Freeze first value of upstream picker
Scramble ordering of objects from upstream
picker
Enumerate tuples with all combinations of
elements from upstream pickers
Pick element from list with probabilities
{ a,b,c,d }
[a,b,c,d]
M.-A. Plourde, S. Hallé
Geometric Pickers
2D point in Cartesian coordinates (x,y)
2D point in polar coordinates (r,θ)
Sides of a triangle of unit perimeter
Polyomino of given size
r θ
x y
b 1
m 2
Affine transform mx+b
M.-A. Plourde, S. Hallé
Behavioral pickers
Some pickers produce objects following a complex
sequence, useful to simulate the "behavior" of some
component. The possible sequences can be defined
using...
Markov
chain
Behavior
tree
Formal
grammar
M.-A. Plourde, S. Hallé
P p m Knit interleaves objects produced by
multiple instances of a picker P to form
a single sequence of objects
Behavioral pickers
P P P
a
b
c
d
e
f
g
h
i a h d e i b f g
c
p m
42 42
1 2 3
M.-A. Plourde, S. Hallé
A Java code example
r θ
HyperspherePicker h = new HyperspherePicker(r, a);
M.-A. Plourde, S. Hallé
r θ
[1,2]
42
RandomInteger r = new RandomInteger(1, 2);
HyperspherePicker h = new HyperspherePicker(r, a);
A Java code example
M.-A. Plourde, S. Hallé
r θ
b 0
m 2π
[1,2]
42
RandomInteger r = new RandomInteger(1, 2);
AffineTransformFloat a =
new AffineTransformFloat(f, 2*PI, 0);
HyperspherePicker h = new HyperspherePicker(r, a);
A Java code example
M.-A. Plourde, S. Hallé
r θ
b 0
m 2π
42
[1,2]
42
RandomInteger r = new RandomInteger(1, 2);
RandomFloat f = new RandomFloat().setSeed(42);
AffineTransformFloat a =
new AffineTransformFloat(f, 2*PI, 0);
HyperspherePicker h = new HyperspherePicker(r, a);
A Java code example
M.-A. Plourde, S. Hallé
r θ
b 0
m 2π
42
[1,2]
42
RandomInteger r = new RandomInteger(1, 2);
RandomFloat f = new RandomFloat().setSeed(42);
AffineTransformFloat a =
new AffineTransformFloat(f, 2*PI, 0);
HyperspherePicker h = new HyperspherePicker(r, a);
for (int i = 0; i < 100; i++) {
Utilities.print(System.out, h.pick());
}
A Java code example
M.-A. Plourde, S. Hallé
r θ
b 0
m 2π
42
[1,2]
42
RandomInteger r = new RandomInteger(1, 2);
RandomFloat f = new RandomFloat().setSeed(42);
AffineTransformFloat a =
new AffineTransformFloat(f, 2*PI, 0);
HyperspherePicker h = new HyperspherePicker(r, a);
for (int i = 0; i < 100; i++) {
Utilities.print(System.out, h.pick());
}
A Java code example
M.-A. Plourde, S. Hallé
RandomInteger r = new RandomInteger(1, 2);
RandomFloat f = new RandomFloat().setSeed(42);
AffineTransformFloat a =
new AffineTransformFloat(f, 2*PI, 0);
HyperspherePicker h = new HyperspherePicker(r, a);
for (int i = 0; i < 100; i++) {
Utilities.print(System.out, h.pick());
}
r θ
b 0
m 2π
42
[1,2]
42
A Java code example
M.-A. Plourde, S. Hallé
r θ
π/6
s δ
42
[0, ,π, ]
π/2
π/2
3
s δ
/6
1
[0,1]
42
RandomFloat f1 = new RandomFloat().setSeed(42);
RandomFloat f2 = new RandomFloat().setSeed(40);
AffineTransformFloat af =
new AffineTransformFloat(f1, 2, 1);
Freeze<Float> r = new Freeze<Float>(af);
Choice<Double> a = new Choice<Double>(f2)
.add(0d, 0.25).add(PI / 2, 0.25)
.add(PI, 0.25).add(3*PI / 2, 0.25);
HyperspherePicker hp =
new HyperspherePicker(radius, angle);
A Java code example
M.-A. Plourde, S. Hallé
Other examples
s δ
-1 10-4
x y
1000
s δ
0 .1
s δ
0 k
1
0
0
M.-A. Plourde, S. Hallé
Other examples
11.205.232.45 - - [26-Oct-1985 01:21:00 EDT 0] "GET J0.html HTTP/2" 200 1000
11.130.222.207 - - [26-Oct-1985 01:21:04 EDT 0] "GET Xv.html HTTP/2" 200 1000
11.130.222.207 - - [26-Oct-1985 01:21:09 EDT 0] "GET 9y.html HTTP/2" 200 1000
11.16.2.198 - - [26-Oct-1985 01:21:17 EDT 0] "GET Xv.html HTTP/2" 200 1000
11.130.222.207 - - [26-Oct-1985 01:21:27 EDT 0] "GET t0.html HTTP/2" 200 1000
45.86.208.44 - - [26-Oct-1985 01:21:29 EDT 0] "GET b7.html HTTP/2" 200 1000
10.112.251.183 - - [26-Oct-1985 01:21:34 EDT 0] "GET b7.html HTTP/2" 200 1000
11.130.222.207 - - [26-Oct-1985 01:21:40 EDT 0] "GET 9y.html HTTP/2" 200 1000
11.16.2.198 - - [26-Oct-1985 01:21:41 EDT 0] "GET 9y.html HTTP/2" 200 1000
45.86.208.44 - - [26-Oct-1985 01:21:45 EDT 0] "GET 9y.html HTTP/2" 200 1000
M.-A. Plourde, S. Hallé
Other features
Since Synthia can generate inputs for a system, it is
natural to use it in a software testing context. The
library offers a few features for this purpose:
Test input shrinking: generate inputs that violate a
condition, and automatically find "smaller" inputs
that also violate it
Object mutation: special pickers receive objects
and apply a "modification" to them
Monkey testing: generate sequences of actions
sent to a reactive system
Provenance tracking: explain the origins of a value
generated by a wiring diagram
M.-A. Plourde, S. Hallé
Explainability
We point to a part of a result produced by a picker,
and Synthia can provide an explanation for it.
M.-A. Plourde, S. Hallé
Explainability
We point to a part of a result produced by a picker,
and Synthia can provide an explanation for it.
[1,2]
42
s δ [0,1,-1]
x y
4
x ≠ y
0
M.-A. Plourde, S. Hallé
Explainability
[1,2]
42
s δ [0,1,-1]
x y
4
x ≠ y
0
[(2,-1),(3,0),(4,1),(5,-1)]
We point to a part of a result produced by a picker,
and Synthia can provide an explanation for it.
M.-A. Plourde, S. Hallé
[1,2]
42
s δ [0,1,-1]
x y
4
x ≠ y
0
[(2,-1),(3,0),(4,1),(5,-1)]
Explainability
We point to a part of a result produced by a picker,
and Synthia can provide an explanation for it.
M.-A. Plourde, S. Hallé
1∘1
1
3
3
3
1
[0,1,-1] 3
1
1
0
2 2
1
1
-1
[1,2]
42
s δ [0,1,-1]
x y
4
x ≠ y
0
[(2,-1),(3,0),(4,1),(5,-1)]
Explainability
We point to a part of a result produced by a picker,
and Synthia can provide an explanation for it.
M.-A. Plourde, S. Hallé
Automatic shrinking
Pickers implementing the Shrinkable interface can
produce a picker returning "smaller" objects.
interface Shrinkable<T> extends Picker<T> {
public Shrinkable<T> shrink(T t);
}
P
t
shrink( )
t P'
t'
t' t
M.-A. Plourde, S. Hallé
Automatic shrinking
Pickers implementing the Shrinkable interface can
produce a picker returning "smaller" objects.
P
1
shrink( )
t1
t1
P
2
shrink( )
t2
t2
...
shrink( )
tn-1
P
n
tn
M.-A. Plourde, S. Hallé
Automatic shrinking
Pickers implementing the Shrinkable interface can
produce a picker returning "smaller" objects.
P
1
shrink( )
t1
t1
P
2
shrink( )
t2
t2
...
shrink( )
tn-1
P
n
tn
M.-A. Plourde, S. Hallé
Automatic shrinking
Pickers implementing the Shrinkable interface can
produce a picker returning "smaller" objects.
P
1
shrink( )
t1
t1
P
2
shrink( )
t2
t2
...
shrink( )
tn-1
P
n
tn
M.-A. Plourde, S. Hallé
Grammar-based shrinking
Synthia can interact with a reactive component by
producing sequences of actions following a
grammar (or Markov chain, behavior tree).
<S> := <number> <op> <number> <inop> ;
<inop> := <op> <number> <inop> | = ;
<number> := <integer> <digit> <rest> | <integer> ;
<integer> := <nzdigit> <rest> ;
<rest> := <digit> <rest> | ε ;
<digit> := 0 | <nzdigit> ;
<nzdigit> := 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ;
<op> := + | − | × | ÷ ;
A sequence leading to a failure can be
automatically shrunk and still follow the grammar.
M.-A. Plourde, S. Hallé
Eat your own dog food
Public disclosure: the authors of Synthia use
Synthia themselves!
Examples:
Test Suite Generation for Boolean Conditions with
Equivalence Class Partitioning, FormaliSE 2022
Boolean formulas
A Modular Runtime Enforcement Model using Multi-
Traces, FPS 2021
Behavioral sequences of events
Automated Repair of Layout Bugs in Web Pages with
Linear Programming, ICWE 2021
Web pages with injected layout faults
M.-A. Plourde, S. Hallé
Code examples
Synthia comes with many detailed code examples
highlighting its features.
https://liflab.github.io/synthia/javadoc
M.-A. Plourde, S. Hallé
Conclusion
Many other features left uncovered: picker
duplication, object mutation, value enumeration,
etc.
Many other data types not showcased: graphs,
complex Java objects, etc.
Simple and "clean" set of abstract interfaces allow
a modular and versatile design.
Used in computer experiments in multiple scientific
publications
https://github.com/liflab/synthia

More Related Content

PPT
Functional Programming In Java
PPTX
SociaLite: High-level Query Language for Big Data Analysis
PDF
New Functional Features of Java 8
PDF
Java 8 new features or the ones you might actually use
PPTX
Using-Python-Libraries.9485146.powerpoint.pptx
PDF
掀起 Swift 的面紗
PDF
Python_Fundamentals_for_Everyone_Usefull
PPT
Profiling and optimization
Functional Programming In Java
SociaLite: High-level Query Language for Big Data Analysis
New Functional Features of Java 8
Java 8 new features or the ones you might actually use
Using-Python-Libraries.9485146.powerpoint.pptx
掀起 Swift 的面紗
Python_Fundamentals_for_Everyone_Usefull
Profiling and optimization

Similar to Synthia: a Generic and Flexible Data Structure Generator (Long Version) (20)

PDF
python-2021.pdf
PDF
Os lab final
PDF
Refactoring to Macros with Clojure
DOCX
Java level 1 Quizzes
PDF
.NET Fest 2018. Антон Молдован. One year of using F# in production at SBTech
PDF
Using Flow-based programming to write tools and workflows for Scientific Comp...
PDF
A Map of the PyData Stack
PDF
Please the following is the currency class of perious one- class Curre.pdf
PDF
[2024] An Introduction to Functional Programming with Go [Y Combinator Remix]...
PPTX
Android audio system(audioflinger)
PDF
The STL
PDF
N flavors of streaming
PDF
Rbootcamp Day 1
PDF
A Generic Explainability Framework for Function Circuits
PDF
Big Data Analytics Part2
PPTX
Robust and Tuneable Family of Gossiping Algorithms
PDF
[Codemotion 2015] patrones de diseño con java8
PDF
Introduction to new features in java 8
python-2021.pdf
Os lab final
Refactoring to Macros with Clojure
Java level 1 Quizzes
.NET Fest 2018. Антон Молдован. One year of using F# in production at SBTech
Using Flow-based programming to write tools and workflows for Scientific Comp...
A Map of the PyData Stack
Please the following is the currency class of perious one- class Curre.pdf
[2024] An Introduction to Functional Programming with Go [Y Combinator Remix]...
Android audio system(audioflinger)
The STL
N flavors of streaming
Rbootcamp Day 1
A Generic Explainability Framework for Function Circuits
Big Data Analytics Part2
Robust and Tuneable Family of Gossiping Algorithms
[Codemotion 2015] patrones de diseño con java8
Introduction to new features in java 8
Ad

More from Sylvain Hallé (20)

PDF
A Tree-Based Definition of Business Process Conformance (Talk @ EDOC 2024)
PDF
Monitoring Business Process Compliance Across Multiple Executions with Stream...
PDF
A Stream-Based Approach to Intrusion Detection
PDF
Event Stream Processing with BeepBeep 3
PDF
Smart Contracts-Enabled Simulation for Hyperconnected Logistics
PDF
Test Suite Generation for Boolean Conditions with Equivalence Class Partitioning
PDF
Test Sequence Generation with Cayley Graphs (Talk @ A-MOST 2021)
PDF
Efficient Offline Monitoring of LTL with Bit Vectors (Talk at SAC 2021)
PDF
Detecting Responsive Web Design Bugs with Declarative Specifications
PDF
Streamlining the Inclusion of Computer Experiments in Research Papers
PDF
Writing Domain-Specific Languages for BeepBeep
PDF
Real-Time Data Mining for Event Streams
PDF
Technologies intelligentes d'aide au développement d'applications web (WAQ 2018)
PDF
Mining event streams with BeepBeep 3
PDF
LabPal: Repeatable Computer Experiments Made Easy (ACM Workshop Talk)
PDF
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
PDF
Event Stream Processing with Multiple Threads
PDF
A Few Things We Heard About RV Tools (Position Paper)
PDF
Solving Equations on Words with Morphisms and Antimorphisms
PDF
Runtime monitoring de propriétés temporelles par (streaming) XML
A Tree-Based Definition of Business Process Conformance (Talk @ EDOC 2024)
Monitoring Business Process Compliance Across Multiple Executions with Stream...
A Stream-Based Approach to Intrusion Detection
Event Stream Processing with BeepBeep 3
Smart Contracts-Enabled Simulation for Hyperconnected Logistics
Test Suite Generation for Boolean Conditions with Equivalence Class Partitioning
Test Sequence Generation with Cayley Graphs (Talk @ A-MOST 2021)
Efficient Offline Monitoring of LTL with Bit Vectors (Talk at SAC 2021)
Detecting Responsive Web Design Bugs with Declarative Specifications
Streamlining the Inclusion of Computer Experiments in Research Papers
Writing Domain-Specific Languages for BeepBeep
Real-Time Data Mining for Event Streams
Technologies intelligentes d'aide au développement d'applications web (WAQ 2018)
Mining event streams with BeepBeep 3
LabPal: Repeatable Computer Experiments Made Easy (ACM Workshop Talk)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
Event Stream Processing with Multiple Threads
A Few Things We Heard About RV Tools (Position Paper)
Solving Equations on Words with Morphisms and Antimorphisms
Runtime monitoring de propriétés temporelles par (streaming) XML
Ad

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Big Data Technologies - Introduction.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Machine learning based COVID-19 study performance prediction
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Review of recent advances in non-invasive hemoglobin estimation
Encapsulation_ Review paper, used for researhc scholars
The Rise and Fall of 3GPP – Time for a Sabbatical?
Big Data Technologies - Introduction.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Network Security Unit 5.pdf for BCA BBA.
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Empathic Computing: Creating Shared Understanding
Diabetes mellitus diagnosis method based random forest with bat algorithm
20250228 LYD VKU AI Blended-Learning.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Machine learning based COVID-19 study performance prediction
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
The AUB Centre for AI in Media Proposal.docx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication

Synthia: a Generic and Flexible Data Structure Generator (Long Version)

  • 1. M.-A. Plourde, S. Hallé Marc-Antoine Plourde and Sylvain Hallé Université du Québec à Chicoutimi CANADA A Generic And Flexible Data Structure Generator CRSNG NSERC synthia synthia
  • 2. M.-A. Plourde, S. Hallé A software sytem I
  • 3. M.-A. Plourde, S. Hallé A software sytem I ♠ ♣ * # ♦ ?
  • 4. M.-A. Plourde, S. Hallé A software sytem I
  • 5. M.-A. Plourde, S. Hallé A software sytem I 2 3 4 π
  • 6. M.-A. Plourde, S. Hallé A software sytem I abc
  • 7. M.-A. Plourde, S. Hallé A software sytem I
  • 8. M.-A. Plourde, S. Hallé A software sytem I ,
  • 9. M.-A. Plourde, S. Hallé A software sytem I , + ⊇? ,
  • 10. M.-A. Plourde, S. Hallé A software sytem I , + ⊇? , OK + abc foo ,
  • 11. M.-A. Plourde, S. Hallé A software sytem I , + ⊇? , OK + abc foo ,
  • 12. M.-A. Plourde, S. Hallé A software sytem I
  • 13. M.-A. Plourde, S. Hallé A software sytem I Size 10 20 30 40 50 60 70 80 90 . . . . . .
  • 14. M.-A. Plourde, S. Hallé Generating "synthetic" inputs
  • 15. M.-A. Plourde, S. Hallé Generating "synthetic" inputs script
  • 16. M.-A. Plourde, S. Hallé Generating "synthetic" inputs script
  • 17. M.-A. Plourde, S. Hallé Generating "synthetic" inputs script
  • 18. M.-A. Plourde, S. Hallé Generating "synthetic" inputs
  • 19. M.-A. Plourde, S. Hallé synthia synthia Enter Synthia A Java library to facilitate the generation of synthetic objects of various kinds Intended to be reusable from one scenario to the next Provides high-level abstractions of common functionalities
  • 20. M.-A. Plourde, S. Hallé Pickers The library is centered on the concept of Picker; it is an interface defining a method called pick. P picker interface Picker<T> { public T pick(); } pick? t
  • 21. M.-A. Plourde, S. Hallé Some built-in Pickers Random integer in interval [m,n] [m,n] 42 42 42 ¼ 42 p λ 42 3 Uniform float in interval [0,1] Integer in Poisson distribution of parameter λ Integer in Gaussian distribution N(0,1) Biased coin flip with probability p
  • 22. M.-A. Plourde, S. Hallé Some built-in Pickers Random integer in interval [m,n] [m,n] 42 42 42 ¼ 42 p λ 42 3 Uniform float in interval [0,1] Integer in Poisson distribution of parameter λ Integer in Gaussian distribution N(0,1) Biased coin flip with probability p seed
  • 23. M.-A. Plourde, S. Hallé Seedable Pickers [m,n] Pseudo-random pickers implement an interface called Seedable, whose method setSeed can be used to set the starting seed of the algorithm. setSeed(42) Each Seedable picker guarantees to generate the same objects in the same order for a given starting seed.
  • 24. M.-A. Plourde, S. Hallé Other built-in Pickers [a,b,c,d] Playback outputs objects by iterating on a predefined list, optionally looping around. Constant is a special Playback producing a single value. c list of objects loop value
  • 25. M.-A. Plourde, S. Hallé Resettable and Duplicable Pickers Pickers implement two other interfaces, each defining a single additional method. Duplicable: method duplicate creates a copy of the current picker and places the new copy in current internal state of the original Resettable: method reset puts a picker back into the state it was at construction This is also true of Seedable (i.e. pseudo-random) pickers!
  • 26. M.-A. Plourde, S. Hallé P A picker can be instantiated by giving references to other picker instances. The picker calls these other pickers to decide how to generate its own objects. Graphically, this results in a "wiring diagram" of interconnected pickers. Wiring diagram
  • 27. M.-A. Plourde, S. Hallé Tick s δ For example: the Tick picker is parameterized by two pickers producing numbers.
  • 28. M.-A. Plourde, S. Hallé Tick s δ For example: the Tick picker is parameterized by two pickers producing numbers. start value increment
  • 29. M.-A. Plourde, S. Hallé 0 1 0, 1, 2, 3, 4, 5, ... Tick s δ For example: the Tick picker is parameterized by two pickers producing numbers.
  • 30. M.-A. Plourde, S. Hallé 42 1 7, 8, 9, 10, 11, 12, ... [0,10] Tick s δ For example: the Tick picker is parameterized by two pickers producing numbers.
  • 31. M.-A. Plourde, S. Hallé 0 [1,2] 0, 1, 3, 4, 6, 7, ... Tick s δ For example: the Tick picker is parameterized by two pickers producing numbers.
  • 32. M.-A. Plourde, S. Hallé http://www.retrolinear.com/services/analog-synth-restoration.aspx "Pickers parameterized by other pickers": powerful concept making Synthia very flexible to generate objects following various patterns. Wiring diagram Similar in nature to synthesizers of the 1970s, with modules connected by patch cables!
  • 33. M.-A. Plourde, S. Hallé Create list/set/array of given size with objects from upstream picker Other built-in Pickers Freeze first value of upstream picker Scramble ordering of objects from upstream picker Enumerate tuples with all combinations of elements from upstream pickers Pick element from list with probabilities { a,b,c,d } [a,b,c,d]
  • 34. M.-A. Plourde, S. Hallé Geometric Pickers 2D point in Cartesian coordinates (x,y) 2D point in polar coordinates (r,θ) Sides of a triangle of unit perimeter Polyomino of given size r θ x y b 1 m 2 Affine transform mx+b
  • 35. M.-A. Plourde, S. Hallé Behavioral pickers Some pickers produce objects following a complex sequence, useful to simulate the "behavior" of some component. The possible sequences can be defined using... Markov chain Behavior tree Formal grammar
  • 36. M.-A. Plourde, S. Hallé P p m Knit interleaves objects produced by multiple instances of a picker P to form a single sequence of objects Behavioral pickers P P P a b c d e f g h i a h d e i b f g c p m 42 42 1 2 3
  • 37. M.-A. Plourde, S. Hallé A Java code example r θ HyperspherePicker h = new HyperspherePicker(r, a);
  • 38. M.-A. Plourde, S. Hallé r θ [1,2] 42 RandomInteger r = new RandomInteger(1, 2); HyperspherePicker h = new HyperspherePicker(r, a); A Java code example
  • 39. M.-A. Plourde, S. Hallé r θ b 0 m 2π [1,2] 42 RandomInteger r = new RandomInteger(1, 2); AffineTransformFloat a = new AffineTransformFloat(f, 2*PI, 0); HyperspherePicker h = new HyperspherePicker(r, a); A Java code example
  • 40. M.-A. Plourde, S. Hallé r θ b 0 m 2π 42 [1,2] 42 RandomInteger r = new RandomInteger(1, 2); RandomFloat f = new RandomFloat().setSeed(42); AffineTransformFloat a = new AffineTransformFloat(f, 2*PI, 0); HyperspherePicker h = new HyperspherePicker(r, a); A Java code example
  • 41. M.-A. Plourde, S. Hallé r θ b 0 m 2π 42 [1,2] 42 RandomInteger r = new RandomInteger(1, 2); RandomFloat f = new RandomFloat().setSeed(42); AffineTransformFloat a = new AffineTransformFloat(f, 2*PI, 0); HyperspherePicker h = new HyperspherePicker(r, a); for (int i = 0; i < 100; i++) { Utilities.print(System.out, h.pick()); } A Java code example
  • 42. M.-A. Plourde, S. Hallé r θ b 0 m 2π 42 [1,2] 42 RandomInteger r = new RandomInteger(1, 2); RandomFloat f = new RandomFloat().setSeed(42); AffineTransformFloat a = new AffineTransformFloat(f, 2*PI, 0); HyperspherePicker h = new HyperspherePicker(r, a); for (int i = 0; i < 100; i++) { Utilities.print(System.out, h.pick()); } A Java code example
  • 43. M.-A. Plourde, S. Hallé RandomInteger r = new RandomInteger(1, 2); RandomFloat f = new RandomFloat().setSeed(42); AffineTransformFloat a = new AffineTransformFloat(f, 2*PI, 0); HyperspherePicker h = new HyperspherePicker(r, a); for (int i = 0; i < 100; i++) { Utilities.print(System.out, h.pick()); } r θ b 0 m 2π 42 [1,2] 42 A Java code example
  • 44. M.-A. Plourde, S. Hallé r θ π/6 s δ 42 [0, ,π, ] π/2 π/2 3 s δ /6 1 [0,1] 42 RandomFloat f1 = new RandomFloat().setSeed(42); RandomFloat f2 = new RandomFloat().setSeed(40); AffineTransformFloat af = new AffineTransformFloat(f1, 2, 1); Freeze<Float> r = new Freeze<Float>(af); Choice<Double> a = new Choice<Double>(f2) .add(0d, 0.25).add(PI / 2, 0.25) .add(PI, 0.25).add(3*PI / 2, 0.25); HyperspherePicker hp = new HyperspherePicker(radius, angle); A Java code example
  • 45. M.-A. Plourde, S. Hallé Other examples s δ -1 10-4 x y 1000 s δ 0 .1 s δ 0 k 1 0 0
  • 46. M.-A. Plourde, S. Hallé Other examples 11.205.232.45 - - [26-Oct-1985 01:21:00 EDT 0] "GET J0.html HTTP/2" 200 1000 11.130.222.207 - - [26-Oct-1985 01:21:04 EDT 0] "GET Xv.html HTTP/2" 200 1000 11.130.222.207 - - [26-Oct-1985 01:21:09 EDT 0] "GET 9y.html HTTP/2" 200 1000 11.16.2.198 - - [26-Oct-1985 01:21:17 EDT 0] "GET Xv.html HTTP/2" 200 1000 11.130.222.207 - - [26-Oct-1985 01:21:27 EDT 0] "GET t0.html HTTP/2" 200 1000 45.86.208.44 - - [26-Oct-1985 01:21:29 EDT 0] "GET b7.html HTTP/2" 200 1000 10.112.251.183 - - [26-Oct-1985 01:21:34 EDT 0] "GET b7.html HTTP/2" 200 1000 11.130.222.207 - - [26-Oct-1985 01:21:40 EDT 0] "GET 9y.html HTTP/2" 200 1000 11.16.2.198 - - [26-Oct-1985 01:21:41 EDT 0] "GET 9y.html HTTP/2" 200 1000 45.86.208.44 - - [26-Oct-1985 01:21:45 EDT 0] "GET 9y.html HTTP/2" 200 1000
  • 47. M.-A. Plourde, S. Hallé Other features Since Synthia can generate inputs for a system, it is natural to use it in a software testing context. The library offers a few features for this purpose: Test input shrinking: generate inputs that violate a condition, and automatically find "smaller" inputs that also violate it Object mutation: special pickers receive objects and apply a "modification" to them Monkey testing: generate sequences of actions sent to a reactive system Provenance tracking: explain the origins of a value generated by a wiring diagram
  • 48. M.-A. Plourde, S. Hallé Explainability We point to a part of a result produced by a picker, and Synthia can provide an explanation for it.
  • 49. M.-A. Plourde, S. Hallé Explainability We point to a part of a result produced by a picker, and Synthia can provide an explanation for it. [1,2] 42 s δ [0,1,-1] x y 4 x ≠ y 0
  • 50. M.-A. Plourde, S. Hallé Explainability [1,2] 42 s δ [0,1,-1] x y 4 x ≠ y 0 [(2,-1),(3,0),(4,1),(5,-1)] We point to a part of a result produced by a picker, and Synthia can provide an explanation for it.
  • 51. M.-A. Plourde, S. Hallé [1,2] 42 s δ [0,1,-1] x y 4 x ≠ y 0 [(2,-1),(3,0),(4,1),(5,-1)] Explainability We point to a part of a result produced by a picker, and Synthia can provide an explanation for it.
  • 52. M.-A. Plourde, S. Hallé 1∘1 1 3 3 3 1 [0,1,-1] 3 1 1 0 2 2 1 1 -1 [1,2] 42 s δ [0,1,-1] x y 4 x ≠ y 0 [(2,-1),(3,0),(4,1),(5,-1)] Explainability We point to a part of a result produced by a picker, and Synthia can provide an explanation for it.
  • 53. M.-A. Plourde, S. Hallé Automatic shrinking Pickers implementing the Shrinkable interface can produce a picker returning "smaller" objects. interface Shrinkable<T> extends Picker<T> { public Shrinkable<T> shrink(T t); } P t shrink( ) t P' t' t' t
  • 54. M.-A. Plourde, S. Hallé Automatic shrinking Pickers implementing the Shrinkable interface can produce a picker returning "smaller" objects. P 1 shrink( ) t1 t1 P 2 shrink( ) t2 t2 ... shrink( ) tn-1 P n tn
  • 55. M.-A. Plourde, S. Hallé Automatic shrinking Pickers implementing the Shrinkable interface can produce a picker returning "smaller" objects. P 1 shrink( ) t1 t1 P 2 shrink( ) t2 t2 ... shrink( ) tn-1 P n tn
  • 56. M.-A. Plourde, S. Hallé Automatic shrinking Pickers implementing the Shrinkable interface can produce a picker returning "smaller" objects. P 1 shrink( ) t1 t1 P 2 shrink( ) t2 t2 ... shrink( ) tn-1 P n tn
  • 57. M.-A. Plourde, S. Hallé Grammar-based shrinking Synthia can interact with a reactive component by producing sequences of actions following a grammar (or Markov chain, behavior tree). <S> := <number> <op> <number> <inop> ; <inop> := <op> <number> <inop> | = ; <number> := <integer> <digit> <rest> | <integer> ; <integer> := <nzdigit> <rest> ; <rest> := <digit> <rest> | ε ; <digit> := 0 | <nzdigit> ; <nzdigit> := 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ; <op> := + | − | × | ÷ ; A sequence leading to a failure can be automatically shrunk and still follow the grammar.
  • 58. M.-A. Plourde, S. Hallé Eat your own dog food Public disclosure: the authors of Synthia use Synthia themselves! Examples: Test Suite Generation for Boolean Conditions with Equivalence Class Partitioning, FormaliSE 2022 Boolean formulas A Modular Runtime Enforcement Model using Multi- Traces, FPS 2021 Behavioral sequences of events Automated Repair of Layout Bugs in Web Pages with Linear Programming, ICWE 2021 Web pages with injected layout faults
  • 59. M.-A. Plourde, S. Hallé Code examples Synthia comes with many detailed code examples highlighting its features. https://liflab.github.io/synthia/javadoc
  • 60. M.-A. Plourde, S. Hallé Conclusion Many other features left uncovered: picker duplication, object mutation, value enumeration, etc. Many other data types not showcased: graphs, complex Java objects, etc. Simple and "clean" set of abstract interfaces allow a modular and versatile design. Used in computer experiments in multiple scientific publications https://github.com/liflab/synthia