SlideShare una empresa de Scribd logo
1 de 21
Descargar para leer sin conexión
Relations as Executable Specifications
Taming Partiality and Non-determinism Using Invariants
Nuno Macedo

Hugo Pacheco

Alcino Cunha

HASLab — High Assurance Software Laboratory
INESC TEC & Universidade do Minho, Braga, Portugal

RAMiCS 13
September 20, 2012, Cambridge
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Introduction

• Relational calculus provides a more natural way to specify

programs;

• Many programs are partial and non-deterministic;

• A point-free (PF) version has been used in a variety of

computer science areas;

• Such specifications are not amenable for execution.

Nuno Macedo, Hugo Pacheco, Alcino Cunha

2 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Motivating Example
(id

id)◦ ◦ (head◦

length◦ ) : Nat → [Nat]

• Calculates a list with length n and the same n at its head;
• Not total nor functional;

• Very inefficient given a naive semantics;

• head◦ could be generating all lists by increasing length and

never reach n.

(id4id)

(id4id)
Nuno Macedo, Hugo Pacheco, Alcino Cunha

head 4length

(head 4length )
3 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Motivating Example

• We can predict the behavior of partial expressions by

calculating the exact domain and range;

• They can also be used to narrow non-deterministic executions.
●{(l, l0 ) 2 [Nat] ⇥ [Nat]|head l = length l0 ^ l = l0 }

(id4id)

●{l 2 [Nat]|head l = length l}

Nuno Macedo, Hugo Pacheco, Alcino Cunha

(id4id)

head 4length

(head 4length )

●{n 2 Nat|n 6= 0}

4 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Taming Partiality and Non-determinism

• We propose a PF relational framework where data-types are

enhanced with invariants;

• The simplicity of the PF calculus allows us to develop

practical type-inference and type-checking algorithms;

• Those invariants can then used to run the specifications more

efficiently;

• Bidirectional transformations are our application scenario.

Nuno Macedo, Hugo Pacheco, Alcino Cunha

5 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

PF Relational Calculus
Identity
Top
Bottom
Converse
Composition
Intersection
Union
Split
Projections
Either
Injections
Constants
Conditional

id : A → A
:A→B
⊥:A→B
·◦ : (A → B) → (B → A)
· ◦ · : (B → C ) → (A → B) → (A → C )
· ∩ · : (A → B) → (A → B) → (A → B)
· ∪ · : (A → B) → (A → B) → (A → B)
· · : (A → B) → (A → C ) → (A → B × C )
π1 : A × B → A and π2 : A × B → B
· · : (B → A) → (C → A) → (B + C → A)
i1 : A → (A + B) and i2 : B → (A + B)
! : A → 1 and · : B → (A → B)
· ? :(A → A) → (A → A + A)

• The simple equational rules are harnessed in a strategic

rewrite system that simplifies expressions.

Nuno Macedo, Hugo Pacheco, Alcino Cunha

6 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Membership Semantics
a id a
a R◦ b
b S ◦R a
b R ∩S a
b R ∪S a
(b, c) R S a
a π1 (a, b)
b π2 (a, b)
a R S (Left b)
a R S (Right c)
(Left a )
i1 a
(Left a )
i2 b
(Right b ) i1 a
(Right b ) i2 b
b
a
b ⊥ a
1 ! a
b b a

Nuno Macedo, Hugo Pacheco, Alcino Cunha

=a≡a
=b R a
= ∃ c. b S c
=b R a∧b
=b R a∨b
=b R a∧c
=a≡a
=b≡b
=a R b
=a S c
=a≡b
= False
= False
=a≡b
= True
= False
= True
=b≡b

∧c R a
S a
S a
S a

7 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Execution Semantics
| id |
| R◦ |
|S ◦R|
|R ∩S|
|R ∪S|
|R S|
| π1 |
| π2 |
|R S|
|R S|
| i1 |
| i2 |
| |
|⊥|
|!|
|b|

a
b
a
a
a
a
(a, b)
(a, b)
(Left b)
(Right c)
a
b
a
a
a
a

Nuno Macedo, Hugo Pacheco, Alcino Cunha

= {a}
= {a | a ← A, a R ◦ b }
= {b | c ← | R | a, b ← | S | c }
= {b | b ← | R | a, b S a}
= |R| a ∪ |S| a
= {(b, c) | b ← | R | a, c ← | S | a}
= {a}
= {b }
= |R| b
= |S| c
= {Left a}
= {Right b }
=B
= {}
= {1}
= {b }
8 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Predicates as Coreflexives

• Domain δR and range ρR are predicates that can be defined

as coreflexives;

• Coreflexives Φ : A → A are relations smaller than the identity;
• If a satisfies the predicate Φ then a Φ a;

• For pairs A × B related by R : A → B, the invariant is lifted as

[R] : A × B → A × B;

• Invariants on coproducts are simply the coproduct Φ + Ψ;
• R : Φ → Ψ denotes δR = Φ and ρR = Ψ.

Nuno Macedo, Hugo Pacheco, Alcino Cunha

9 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Inferring Checkable Invariants

• Domain and range can be directly computed as

δR = R ◦ ◦ R ∩ id and ρR = R ◦ R ◦ ∩ id;

• May result in inefficient membership tests (due to

composition);

• By expanding the definition, we define an equivalent definition

with most compositions removed;

• Others will fall in the special case

b (f ◦ ◦ R ◦ g ) a ≡ (f b) R (g a);

• The rewriting system further simplifies the formula and issues

a warning if problematic expressions remain.

Nuno Macedo, Hugo Pacheco, Alcino Cunha

10 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Example
(id

id)◦ ◦ (head◦

length◦ ) : Nat → [Nat]

ρ((id id)◦ ◦ (head◦ length◦ ))
={Range definition}
ρ((id id)◦ ◦ ρ(head◦ length◦ ))
={Range definition}
ρ((id id)◦ ◦ [length◦ ◦ head])
={Range definition}
δ([length◦ ◦ head] ◦ (id id))
={Domain definition, Simplifications : PF Laws}
(head◦ ◦ length) ∩ id

(id id)◦ ◦(length◦ head◦ ):inN ◦(⊥+id)◦outN → (head◦ ◦length)∩id

Nuno Macedo, Hugo Pacheco, Alcino Cunha

11 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Optimizing Non-deterministic Executions

• After determining the domain and range, they can be

propagated down to primitives,

• This reduces the generation of irrelevant intermediate values;
| id : Φ → Ψ | a = | Ψ | a

| π1 : [U ] → Ψ | (a, b) = | Ψ | a

| R ◦ S : Φ → Ψ | a = {b | c ← | S : Φ → δR | a,
b ← | R : ρS → Ψ | c }

| R ∩ S : Φ → Ψ | a = {b | b ← | R : Φ ∩ δS → ρ(Ψ ◦ S ◦ a) | a}

Nuno Macedo, Hugo Pacheco, Alcino Cunha

12 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Recursive Relations with Invariants

• We support the well-know recursion patterns of

catamorphisms (folds) and anamorphisms (unfolds);

• Execution is not problematic, as it is performed by unfolding

their definitions;

• However, there is no known normal form for invariants over

recursive types;

• The rewrite system tries to simplify the generic domain/range

expression.

Nuno Macedo, Hugo Pacheco, Alcino Cunha

13 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Recursive Relations: Example
unzip : [A × B ] → [A] × [B ]
ρunzip
={Range definition}
(unzip ◦ unzip◦ ) ∩ id
={Simplifications : unzip is functional, Liftify : range of unzip is a product}
◦
[π2 ◦ unzip ◦ unzip◦ ◦ π1 ]
={Catamorphism fusion : π1 ◦ g = nil (cons ◦ (π1 × id)) ◦ F π1 }
[(
|nil (cons ◦ (π1 × id))| ◦ (
) |nil (cons ◦ (π2 × id))| ◦ ]
)
={Definitions : map}
[(map π1 ) ◦ (map π2 )◦ ]
={Simplifications : map converse, map fusion (see below )}
◦
[map (π1 ◦ π2 )]
={Simplifications : PF Laws}
[map ]

unzip : id → [map
Nuno Macedo, Hugo Pacheco, Alcino Cunha

]

14 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Bidirectional Transformations

• Bidirectional transformations are transformations between

data-structures that may be applied in both directions;

• Defining the transformations individually is expensive and

error-prone;

• BXs should be inferred a single specification;

• We propose a solution using the relational calculus.

Nuno Macedo, Hugo Pacheco, Alcino Cunha

15 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Bidirectional Transformations

• Lenses are one of the most famous BX frameworks;
• A lens S

V between sources S and more abstract views V
consists of transformations Get : S → V and Put : V × S → S;
• It is said to be well-behaved if:
• Get ◦ Put ⊆ π1 (acceptability);
• Put ◦ (Get id) ⊆ id (stability);

• Usually there are multiple valid Puts, but existing frameworks

are deterministic.

Nuno Macedo, Hugo Pacheco, Alcino Cunha

16 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Bidirectional Transformations
• In principle, it is possible to lift any functional expression to a

well-behaved lens;

• Existing frameworks either:
• Have maximum updatability but
disregard some operators;
• Refine the type-system to allow
operators with smaller updatability;
• Support any operator but disregard
updatability;

?

?

?

• We refine the type-system and

guarantee maximum updatability.

Nuno Macedo, Hugo Pacheco, Alcino Cunha

17 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Generic Non-deterministic Lenses
• Using relational calculus we can define a generic Put that is

the largest relation that satisfies the properties;

• A transformation get : A → B can be lifted to a well-behaved

non-deterministic lens get : δget
Put = (π2

ρget, with

(get◦ ◦ π1 )) ◦ [get◦ ] ?

• Emerges naturally from the lens laws:
• [get◦ ] ? (v , s) tests if v was changed, returning either the
original s (acceptability), or any source s such that s = get v
(stability);
• Maximum updatability: δPut = ρget × δget.

Nuno Macedo, Hugo Pacheco, Alcino Cunha

18 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Generic Non-deterministic Lenses
• Type-checking over δget and ρget directly could be

undecidable and due to the central role of the converse, Put
can not be directly executed;

• Both these issues can be addressed by the optimizations

already presented;

• Forward transformations are functional so problematic cases

are very limited:

• Regarding type-checking, only particular ranges of splits are

possibly undecidable;
• The backward transformation can be efficiently executed;

• Recursive expressions are also supported as they preserve the

functionality of their algebras.

Nuno Macedo, Hugo Pacheco, Alcino Cunha

19 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Generic Non-deterministic Lenses: Example

π1

id : id

◦
[π1 ]

◦
• The range is [π1 ] : A × (A × B) → A × (A × B), so Put only

takes views (a, (b, c)) where a ≡ b;

◦
id)◦ will run, and π1 could
generate all pairs until reaching (a, c);

• When the view is updated, (π1

• With our optimization, the output of π1 is restricted to have c

in the second element.

Nuno Macedo, Hugo Pacheco, Alcino Cunha

20 / 21
Introduction

Relational Calculus

Optimizations

Recursion

Bidirectional Transformations

Conclusions

Conclusions
• We have presented mechanisms for the efficient execution PF
relational expressions over data-types with invariants;
• Regarding BX, we identify an open problem in the
composition of lenses;
• By modeling lenses in this framework we were able to
implement an expressive PF BX language with maximum
updatability;
• Researching possible normal forms for invariants over recursive
types;
• Exploring mechanisms for a better control of the
non-determinism through user-defined quality measures.

Nuno Macedo, Hugo Pacheco, Alcino Cunha

21 / 21

Más contenido relacionado

La actualidad más candente

An Analysis of Graph Cut Size for Transductive Learning
An Analysis of Graph Cut Size for Transductive LearningAn Analysis of Graph Cut Size for Transductive Learning
An Analysis of Graph Cut Size for Transductive Learningbutest
 
Gentle Introduction to Dirichlet Processes
Gentle Introduction to Dirichlet ProcessesGentle Introduction to Dirichlet Processes
Gentle Introduction to Dirichlet ProcessesYap Wooi Hen
 
Injecting image priors into Learnable Compressive Subsampling
Injecting image priors into Learnable Compressive SubsamplingInjecting image priors into Learnable Compressive Subsampling
Injecting image priors into Learnable Compressive SubsamplingMartino Ferrari
 
RuleML 2015 Constraint Handling Rules - What Else?
RuleML 2015 Constraint Handling Rules - What Else?RuleML 2015 Constraint Handling Rules - What Else?
RuleML 2015 Constraint Handling Rules - What Else?RuleML
 
Approximate Thin Plate Spline Mappings
Approximate Thin Plate Spline MappingsApproximate Thin Plate Spline Mappings
Approximate Thin Plate Spline MappingsArchzilon Eshun-Davies
 
Logistic Regression(SGD)
Logistic Regression(SGD)Logistic Regression(SGD)
Logistic Regression(SGD)Prentice Xu
 
"On the Bayesian Interpretation of Black–Litterman" by Dr. Gordon Ritter, Sen...
"On the Bayesian Interpretation of Black–Litterman" by Dr. Gordon Ritter, Sen..."On the Bayesian Interpretation of Black–Litterman" by Dr. Gordon Ritter, Sen...
"On the Bayesian Interpretation of Black–Litterman" by Dr. Gordon Ritter, Sen...Quantopian
 
DESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGIC
DESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGICDESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGIC
DESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGICVLSICS Design
 
Multilayer Neural Networks
Multilayer Neural NetworksMultilayer Neural Networks
Multilayer Neural NetworksESCOM
 
Dr Chris Drovandi (QUT) - Bayesian Indirect Inference Using a Parametric Auxi...
Dr Chris Drovandi (QUT) - Bayesian Indirect Inference Using a Parametric Auxi...Dr Chris Drovandi (QUT) - Bayesian Indirect Inference Using a Parametric Auxi...
Dr Chris Drovandi (QUT) - Bayesian Indirect Inference Using a Parametric Auxi...QUT_SEF
 
Bagging-Clustering Methods to Forecast Time Series
Bagging-Clustering Methods to Forecast Time SeriesBagging-Clustering Methods to Forecast Time Series
Bagging-Clustering Methods to Forecast Time SeriesTiago Mendes Dantas
 
Kernelization algorithms for graph and other structure modification problems
Kernelization algorithms for graph and other structure modification problemsKernelization algorithms for graph and other structure modification problems
Kernelization algorithms for graph and other structure modification problemsAnthony Perez
 
chap 6 - Example şift
chap 6 - Example şiftchap 6 - Example şift
chap 6 - Example şiftermis26
 
Query Modeling Using Non-relevance Information - TREC 2008 Relevance Feedbac...
Query Modeling Using Non-relevance Information  - TREC 2008 Relevance Feedbac...Query Modeling Using Non-relevance Information  - TREC 2008 Relevance Feedbac...
Query Modeling Using Non-relevance Information - TREC 2008 Relevance Feedbac...Edgar Meij
 
CVPR2010: Advanced ITinCVPR in a Nutshell: part 6: Mixtures
CVPR2010: Advanced ITinCVPR in a Nutshell: part 6: MixturesCVPR2010: Advanced ITinCVPR in a Nutshell: part 6: Mixtures
CVPR2010: Advanced ITinCVPR in a Nutshell: part 6: Mixtureszukun
 

La actualidad más candente (20)

An Analysis of Graph Cut Size for Transductive Learning
An Analysis of Graph Cut Size for Transductive LearningAn Analysis of Graph Cut Size for Transductive Learning
An Analysis of Graph Cut Size for Transductive Learning
 
Gentle Introduction to Dirichlet Processes
Gentle Introduction to Dirichlet ProcessesGentle Introduction to Dirichlet Processes
Gentle Introduction to Dirichlet Processes
 
Injecting image priors into Learnable Compressive Subsampling
Injecting image priors into Learnable Compressive SubsamplingInjecting image priors into Learnable Compressive Subsampling
Injecting image priors into Learnable Compressive Subsampling
 
RuleML 2015 Constraint Handling Rules - What Else?
RuleML 2015 Constraint Handling Rules - What Else?RuleML 2015 Constraint Handling Rules - What Else?
RuleML 2015 Constraint Handling Rules - What Else?
 
Approximate Thin Plate Spline Mappings
Approximate Thin Plate Spline MappingsApproximate Thin Plate Spline Mappings
Approximate Thin Plate Spline Mappings
 
Logistic Regression(SGD)
Logistic Regression(SGD)Logistic Regression(SGD)
Logistic Regression(SGD)
 
Efficient Solving Techniques for Answer Set Programming
Efficient Solving Techniques for Answer Set ProgrammingEfficient Solving Techniques for Answer Set Programming
Efficient Solving Techniques for Answer Set Programming
 
"On the Bayesian Interpretation of Black–Litterman" by Dr. Gordon Ritter, Sen...
"On the Bayesian Interpretation of Black–Litterman" by Dr. Gordon Ritter, Sen..."On the Bayesian Interpretation of Black–Litterman" by Dr. Gordon Ritter, Sen...
"On the Bayesian Interpretation of Black–Litterman" by Dr. Gordon Ritter, Sen...
 
Fulltext
FulltextFulltext
Fulltext
 
DESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGIC
DESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGICDESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGIC
DESIGN OF QUATERNARY LOGICAL CIRCUIT USING VOLTAGE AND CURRENT MODE LOGIC
 
Chapter 9 newer
Chapter 9   newerChapter 9   newer
Chapter 9 newer
 
Approximate Tree Kernels
Approximate Tree KernelsApproximate Tree Kernels
Approximate Tree Kernels
 
Multilayer Neural Networks
Multilayer Neural NetworksMultilayer Neural Networks
Multilayer Neural Networks
 
Dr Chris Drovandi (QUT) - Bayesian Indirect Inference Using a Parametric Auxi...
Dr Chris Drovandi (QUT) - Bayesian Indirect Inference Using a Parametric Auxi...Dr Chris Drovandi (QUT) - Bayesian Indirect Inference Using a Parametric Auxi...
Dr Chris Drovandi (QUT) - Bayesian Indirect Inference Using a Parametric Auxi...
 
Bagging-Clustering Methods to Forecast Time Series
Bagging-Clustering Methods to Forecast Time SeriesBagging-Clustering Methods to Forecast Time Series
Bagging-Clustering Methods to Forecast Time Series
 
Ef24836841
Ef24836841Ef24836841
Ef24836841
 
Kernelization algorithms for graph and other structure modification problems
Kernelization algorithms for graph and other structure modification problemsKernelization algorithms for graph and other structure modification problems
Kernelization algorithms for graph and other structure modification problems
 
chap 6 - Example şift
chap 6 - Example şiftchap 6 - Example şift
chap 6 - Example şift
 
Query Modeling Using Non-relevance Information - TREC 2008 Relevance Feedbac...
Query Modeling Using Non-relevance Information  - TREC 2008 Relevance Feedbac...Query Modeling Using Non-relevance Information  - TREC 2008 Relevance Feedbac...
Query Modeling Using Non-relevance Information - TREC 2008 Relevance Feedbac...
 
CVPR2010: Advanced ITinCVPR in a Nutshell: part 6: Mixtures
CVPR2010: Advanced ITinCVPR in a Nutshell: part 6: MixturesCVPR2010: Advanced ITinCVPR in a Nutshell: part 6: Mixtures
CVPR2010: Advanced ITinCVPR in a Nutshell: part 6: Mixtures
 

Destacado

Gardena t2
Gardena t2Gardena t2
Gardena t2preheppy
 
eLEDGER - the ONE MINUTE pitch
eLEDGER - the ONE MINUTE pitcheLEDGER - the ONE MINUTE pitch
eLEDGER - the ONE MINUTE pitcheLEDGER Team
 
Infografika inbound marketing
Infografika inbound marketingInfografika inbound marketing
Infografika inbound marketingSEOwind
 
Robot educador 2
Robot educador 2Robot educador 2
Robot educador 2mixerboy12
 
Chapter 17 (Radio & Telephone)
Chapter 17 (Radio & Telephone)Chapter 17 (Radio & Telephone)
Chapter 17 (Radio & Telephone)allclasses
 
Photographic genres: Documentary
Photographic genres: DocumentaryPhotographic genres: Documentary
Photographic genres: Documentaryzoehface
 
D2 d turning information into a competive asset - 23 jan 2014
D2 d   turning information into a competive asset - 23 jan 2014D2 d   turning information into a competive asset - 23 jan 2014
D2 d turning information into a competive asset - 23 jan 2014Henk van Roekel
 
Vegan mood board (task 3)
Vegan mood board (task 3)Vegan mood board (task 3)
Vegan mood board (task 3)Jamie Kessel
 
Access como crear una base de datos para tu empresa producto y inv entario
Access como crear una base de datos para tu empresa producto y inv entarioAccess como crear una base de datos para tu empresa producto y inv entario
Access como crear una base de datos para tu empresa producto y inv entariomixerboy12
 
Jevgenija zalescevskaja proekt1
Jevgenija zalescevskaja proekt1Jevgenija zalescevskaja proekt1
Jevgenija zalescevskaja proekt1jevgenija1312
 
SoMIRAC nf text complexity
SoMIRAC nf text complexitySoMIRAC nf text complexity
SoMIRAC nf text complexityjserravallo
 
Creativity
Creativity Creativity
Creativity VS E
 
CAP computer Aided Program for pronunciation
CAP computer Aided Program for pronunciationCAP computer Aided Program for pronunciation
CAP computer Aided Program for pronunciationSamira Rahmdel
 

Destacado (20)

Gardena t2
Gardena t2Gardena t2
Gardena t2
 
Ec
EcEc
Ec
 
eLEDGER - the ONE MINUTE pitch
eLEDGER - the ONE MINUTE pitcheLEDGER - the ONE MINUTE pitch
eLEDGER - the ONE MINUTE pitch
 
Infografika inbound marketing
Infografika inbound marketingInfografika inbound marketing
Infografika inbound marketing
 
Client factfile
Client factfileClient factfile
Client factfile
 
Robot educador 2
Robot educador 2Robot educador 2
Robot educador 2
 
Chapter 17 (Radio & Telephone)
Chapter 17 (Radio & Telephone)Chapter 17 (Radio & Telephone)
Chapter 17 (Radio & Telephone)
 
Photographic genres: Documentary
Photographic genres: DocumentaryPhotographic genres: Documentary
Photographic genres: Documentary
 
D2 d turning information into a competive asset - 23 jan 2014
D2 d   turning information into a competive asset - 23 jan 2014D2 d   turning information into a competive asset - 23 jan 2014
D2 d turning information into a competive asset - 23 jan 2014
 
pictures used
pictures usedpictures used
pictures used
 
Nxt sensores
Nxt sensoresNxt sensores
Nxt sensores
 
Shopcherriescom
ShopcherriescomShopcherriescom
Shopcherriescom
 
Vegan mood board (task 3)
Vegan mood board (task 3)Vegan mood board (task 3)
Vegan mood board (task 3)
 
Access como crear una base de datos para tu empresa producto y inv entario
Access como crear una base de datos para tu empresa producto y inv entarioAccess como crear una base de datos para tu empresa producto y inv entario
Access como crear una base de datos para tu empresa producto y inv entario
 
Magazine analysis
Magazine analysisMagazine analysis
Magazine analysis
 
Jevgenija zalescevskaja proekt1
Jevgenija zalescevskaja proekt1Jevgenija zalescevskaja proekt1
Jevgenija zalescevskaja proekt1
 
SoMIRAC nf text complexity
SoMIRAC nf text complexitySoMIRAC nf text complexity
SoMIRAC nf text complexity
 
Creativity
Creativity Creativity
Creativity
 
Test
TestTest
Test
 
CAP computer Aided Program for pronunciation
CAP computer Aided Program for pronunciationCAP computer Aided Program for pronunciation
CAP computer Aided Program for pronunciation
 

Similar a Relations as Executable Specifications

NIPS2007: structured prediction
NIPS2007: structured predictionNIPS2007: structured prediction
NIPS2007: structured predictionzukun
 
A Configurable CEGAR Framework with Interpolation-Based Refinements
A Configurable CEGAR Framework with Interpolation-Based RefinementsA Configurable CEGAR Framework with Interpolation-Based Refinements
A Configurable CEGAR Framework with Interpolation-Based RefinementsAkos Hajdu
 
SVD and the Netflix Dataset
SVD and the Netflix DatasetSVD and the Netflix Dataset
SVD and the Netflix DatasetBen Mabey
 
Linear regression
Linear regressionLinear regression
Linear regressionansrivas21
 
Solvers and Applications with CP
Solvers and Applications with CPSolvers and Applications with CP
Solvers and Applications with CPiaudesc
 
Conducting and reporting the results of a cfd simulation
Conducting and reporting the results of a cfd simulationConducting and reporting the results of a cfd simulation
Conducting and reporting the results of a cfd simulationMalik Abdul Wahab
 
GAN(と強化学習との関係)
GAN(と強化学習との関係)GAN(と強化学習との関係)
GAN(と強化学習との関係)Masahiro Suzuki
 
PowerLyra@EuroSys2015
PowerLyra@EuroSys2015PowerLyra@EuroSys2015
PowerLyra@EuroSys2015realstolz
 
CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingMark Kilgard
 
Efficient HPR-based Rendering of Point Clouds
Efficient HPR-based Rendering of Point CloudsEfficient HPR-based Rendering of Point Clouds
Efficient HPR-based Rendering of Point CloudsRoger Hernando Buch
 
Towards a General Approach for Symbolic Model-Checker Prototyping
Towards a General Approach for Symbolic Model-Checker PrototypingTowards a General Approach for Symbolic Model-Checker Prototyping
Towards a General Approach for Symbolic Model-Checker PrototypingEdmundo López Bóbeda
 
Lec10: Medical Image Segmentation as an Energy Minimization Problem
Lec10: Medical Image Segmentation as an Energy Minimization ProblemLec10: Medical Image Segmentation as an Energy Minimization Problem
Lec10: Medical Image Segmentation as an Energy Minimization ProblemUlaş Bağcı
 
Design of Engineering Experiments Part 5
Design of Engineering Experiments Part 5Design of Engineering Experiments Part 5
Design of Engineering Experiments Part 5Stats Statswork
 
High-Dimensional Network Estimation using ECL
High-Dimensional Network Estimation using ECLHigh-Dimensional Network Estimation using ECL
High-Dimensional Network Estimation using ECLHPCC Systems
 
ZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their ApplicationsZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their ApplicationsAlex Pruden
 
Symbolic Computation via Gröbner Basis
Symbolic Computation via Gröbner BasisSymbolic Computation via Gröbner Basis
Symbolic Computation via Gröbner BasisIJERA Editor
 
Compressed Sensing using Generative Model
Compressed Sensing using Generative ModelCompressed Sensing using Generative Model
Compressed Sensing using Generative Modelkenluck2001
 

Similar a Relations as Executable Specifications (20)

slides.07.pptx
slides.07.pptxslides.07.pptx
slides.07.pptx
 
NIPS2007: structured prediction
NIPS2007: structured predictionNIPS2007: structured prediction
NIPS2007: structured prediction
 
A Configurable CEGAR Framework with Interpolation-Based Refinements
A Configurable CEGAR Framework with Interpolation-Based RefinementsA Configurable CEGAR Framework with Interpolation-Based Refinements
A Configurable CEGAR Framework with Interpolation-Based Refinements
 
MUMS: Bayesian, Fiducial, and Frequentist Conference - Model Selection in the...
MUMS: Bayesian, Fiducial, and Frequentist Conference - Model Selection in the...MUMS: Bayesian, Fiducial, and Frequentist Conference - Model Selection in the...
MUMS: Bayesian, Fiducial, and Frequentist Conference - Model Selection in the...
 
SVD and the Netflix Dataset
SVD and the Netflix DatasetSVD and the Netflix Dataset
SVD and the Netflix Dataset
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Solvers and Applications with CP
Solvers and Applications with CPSolvers and Applications with CP
Solvers and Applications with CP
 
Conducting and reporting the results of a cfd simulation
Conducting and reporting the results of a cfd simulationConducting and reporting the results of a cfd simulation
Conducting and reporting the results of a cfd simulation
 
GAN(と強化学習との関係)
GAN(と強化学習との関係)GAN(と強化学習との関係)
GAN(と強化学習との関係)
 
PowerLyra@EuroSys2015
PowerLyra@EuroSys2015PowerLyra@EuroSys2015
PowerLyra@EuroSys2015
 
CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and Culling
 
Efficient HPR-based Rendering of Point Clouds
Efficient HPR-based Rendering of Point CloudsEfficient HPR-based Rendering of Point Clouds
Efficient HPR-based Rendering of Point Clouds
 
Towards a General Approach for Symbolic Model-Checker Prototyping
Towards a General Approach for Symbolic Model-Checker PrototypingTowards a General Approach for Symbolic Model-Checker Prototyping
Towards a General Approach for Symbolic Model-Checker Prototyping
 
Lec10: Medical Image Segmentation as an Energy Minimization Problem
Lec10: Medical Image Segmentation as an Energy Minimization ProblemLec10: Medical Image Segmentation as an Energy Minimization Problem
Lec10: Medical Image Segmentation as an Energy Minimization Problem
 
nlp2.pdf
nlp2.pdfnlp2.pdf
nlp2.pdf
 
Design of Engineering Experiments Part 5
Design of Engineering Experiments Part 5Design of Engineering Experiments Part 5
Design of Engineering Experiments Part 5
 
High-Dimensional Network Estimation using ECL
High-Dimensional Network Estimation using ECLHigh-Dimensional Network Estimation using ECL
High-Dimensional Network Estimation using ECL
 
ZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their ApplicationsZK Study Club: Sumcheck Arguments and Their Applications
ZK Study Club: Sumcheck Arguments and Their Applications
 
Symbolic Computation via Gröbner Basis
Symbolic Computation via Gröbner BasisSymbolic Computation via Gröbner Basis
Symbolic Computation via Gröbner Basis
 
Compressed Sensing using Generative Model
Compressed Sensing using Generative ModelCompressed Sensing using Generative Model
Compressed Sensing using Generative Model
 

Último

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Relations as Executable Specifications

  • 1. Relations as Executable Specifications Taming Partiality and Non-determinism Using Invariants Nuno Macedo Hugo Pacheco Alcino Cunha HASLab — High Assurance Software Laboratory INESC TEC & Universidade do Minho, Braga, Portugal RAMiCS 13 September 20, 2012, Cambridge
  • 2. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Introduction • Relational calculus provides a more natural way to specify programs; • Many programs are partial and non-deterministic; • A point-free (PF) version has been used in a variety of computer science areas; • Such specifications are not amenable for execution. Nuno Macedo, Hugo Pacheco, Alcino Cunha 2 / 21
  • 3. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Motivating Example (id id)◦ ◦ (head◦ length◦ ) : Nat → [Nat] • Calculates a list with length n and the same n at its head; • Not total nor functional; • Very inefficient given a naive semantics; • head◦ could be generating all lists by increasing length and never reach n. (id4id) (id4id) Nuno Macedo, Hugo Pacheco, Alcino Cunha head 4length (head 4length ) 3 / 21
  • 4. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Motivating Example • We can predict the behavior of partial expressions by calculating the exact domain and range; • They can also be used to narrow non-deterministic executions. ●{(l, l0 ) 2 [Nat] ⇥ [Nat]|head l = length l0 ^ l = l0 } (id4id) ●{l 2 [Nat]|head l = length l} Nuno Macedo, Hugo Pacheco, Alcino Cunha (id4id) head 4length (head 4length ) ●{n 2 Nat|n 6= 0} 4 / 21
  • 5. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Taming Partiality and Non-determinism • We propose a PF relational framework where data-types are enhanced with invariants; • The simplicity of the PF calculus allows us to develop practical type-inference and type-checking algorithms; • Those invariants can then used to run the specifications more efficiently; • Bidirectional transformations are our application scenario. Nuno Macedo, Hugo Pacheco, Alcino Cunha 5 / 21
  • 6. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions PF Relational Calculus Identity Top Bottom Converse Composition Intersection Union Split Projections Either Injections Constants Conditional id : A → A :A→B ⊥:A→B ·◦ : (A → B) → (B → A) · ◦ · : (B → C ) → (A → B) → (A → C ) · ∩ · : (A → B) → (A → B) → (A → B) · ∪ · : (A → B) → (A → B) → (A → B) · · : (A → B) → (A → C ) → (A → B × C ) π1 : A × B → A and π2 : A × B → B · · : (B → A) → (C → A) → (B + C → A) i1 : A → (A + B) and i2 : B → (A + B) ! : A → 1 and · : B → (A → B) · ? :(A → A) → (A → A + A) • The simple equational rules are harnessed in a strategic rewrite system that simplifies expressions. Nuno Macedo, Hugo Pacheco, Alcino Cunha 6 / 21
  • 7. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Membership Semantics a id a a R◦ b b S ◦R a b R ∩S a b R ∪S a (b, c) R S a a π1 (a, b) b π2 (a, b) a R S (Left b) a R S (Right c) (Left a ) i1 a (Left a ) i2 b (Right b ) i1 a (Right b ) i2 b b a b ⊥ a 1 ! a b b a Nuno Macedo, Hugo Pacheco, Alcino Cunha =a≡a =b R a = ∃ c. b S c =b R a∧b =b R a∨b =b R a∧c =a≡a =b≡b =a R b =a S c =a≡b = False = False =a≡b = True = False = True =b≡b ∧c R a S a S a S a 7 / 21
  • 8. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Execution Semantics | id | | R◦ | |S ◦R| |R ∩S| |R ∪S| |R S| | π1 | | π2 | |R S| |R S| | i1 | | i2 | | | |⊥| |!| |b| a b a a a a (a, b) (a, b) (Left b) (Right c) a b a a a a Nuno Macedo, Hugo Pacheco, Alcino Cunha = {a} = {a | a ← A, a R ◦ b } = {b | c ← | R | a, b ← | S | c } = {b | b ← | R | a, b S a} = |R| a ∪ |S| a = {(b, c) | b ← | R | a, c ← | S | a} = {a} = {b } = |R| b = |S| c = {Left a} = {Right b } =B = {} = {1} = {b } 8 / 21
  • 9. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Predicates as Coreflexives • Domain δR and range ρR are predicates that can be defined as coreflexives; • Coreflexives Φ : A → A are relations smaller than the identity; • If a satisfies the predicate Φ then a Φ a; • For pairs A × B related by R : A → B, the invariant is lifted as [R] : A × B → A × B; • Invariants on coproducts are simply the coproduct Φ + Ψ; • R : Φ → Ψ denotes δR = Φ and ρR = Ψ. Nuno Macedo, Hugo Pacheco, Alcino Cunha 9 / 21
  • 10. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Inferring Checkable Invariants • Domain and range can be directly computed as δR = R ◦ ◦ R ∩ id and ρR = R ◦ R ◦ ∩ id; • May result in inefficient membership tests (due to composition); • By expanding the definition, we define an equivalent definition with most compositions removed; • Others will fall in the special case b (f ◦ ◦ R ◦ g ) a ≡ (f b) R (g a); • The rewriting system further simplifies the formula and issues a warning if problematic expressions remain. Nuno Macedo, Hugo Pacheco, Alcino Cunha 10 / 21
  • 11. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Example (id id)◦ ◦ (head◦ length◦ ) : Nat → [Nat] ρ((id id)◦ ◦ (head◦ length◦ )) ={Range definition} ρ((id id)◦ ◦ ρ(head◦ length◦ )) ={Range definition} ρ((id id)◦ ◦ [length◦ ◦ head]) ={Range definition} δ([length◦ ◦ head] ◦ (id id)) ={Domain definition, Simplifications : PF Laws} (head◦ ◦ length) ∩ id (id id)◦ ◦(length◦ head◦ ):inN ◦(⊥+id)◦outN → (head◦ ◦length)∩id Nuno Macedo, Hugo Pacheco, Alcino Cunha 11 / 21
  • 12. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Optimizing Non-deterministic Executions • After determining the domain and range, they can be propagated down to primitives, • This reduces the generation of irrelevant intermediate values; | id : Φ → Ψ | a = | Ψ | a | π1 : [U ] → Ψ | (a, b) = | Ψ | a | R ◦ S : Φ → Ψ | a = {b | c ← | S : Φ → δR | a, b ← | R : ρS → Ψ | c } | R ∩ S : Φ → Ψ | a = {b | b ← | R : Φ ∩ δS → ρ(Ψ ◦ S ◦ a) | a} Nuno Macedo, Hugo Pacheco, Alcino Cunha 12 / 21
  • 13. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Recursive Relations with Invariants • We support the well-know recursion patterns of catamorphisms (folds) and anamorphisms (unfolds); • Execution is not problematic, as it is performed by unfolding their definitions; • However, there is no known normal form for invariants over recursive types; • The rewrite system tries to simplify the generic domain/range expression. Nuno Macedo, Hugo Pacheco, Alcino Cunha 13 / 21
  • 14. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Recursive Relations: Example unzip : [A × B ] → [A] × [B ] ρunzip ={Range definition} (unzip ◦ unzip◦ ) ∩ id ={Simplifications : unzip is functional, Liftify : range of unzip is a product} ◦ [π2 ◦ unzip ◦ unzip◦ ◦ π1 ] ={Catamorphism fusion : π1 ◦ g = nil (cons ◦ (π1 × id)) ◦ F π1 } [( |nil (cons ◦ (π1 × id))| ◦ ( ) |nil (cons ◦ (π2 × id))| ◦ ] ) ={Definitions : map} [(map π1 ) ◦ (map π2 )◦ ] ={Simplifications : map converse, map fusion (see below )} ◦ [map (π1 ◦ π2 )] ={Simplifications : PF Laws} [map ] unzip : id → [map Nuno Macedo, Hugo Pacheco, Alcino Cunha ] 14 / 21
  • 15. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Bidirectional Transformations • Bidirectional transformations are transformations between data-structures that may be applied in both directions; • Defining the transformations individually is expensive and error-prone; • BXs should be inferred a single specification; • We propose a solution using the relational calculus. Nuno Macedo, Hugo Pacheco, Alcino Cunha 15 / 21
  • 16. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Bidirectional Transformations • Lenses are one of the most famous BX frameworks; • A lens S V between sources S and more abstract views V consists of transformations Get : S → V and Put : V × S → S; • It is said to be well-behaved if: • Get ◦ Put ⊆ π1 (acceptability); • Put ◦ (Get id) ⊆ id (stability); • Usually there are multiple valid Puts, but existing frameworks are deterministic. Nuno Macedo, Hugo Pacheco, Alcino Cunha 16 / 21
  • 17. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Bidirectional Transformations • In principle, it is possible to lift any functional expression to a well-behaved lens; • Existing frameworks either: • Have maximum updatability but disregard some operators; • Refine the type-system to allow operators with smaller updatability; • Support any operator but disregard updatability; ? ? ? • We refine the type-system and guarantee maximum updatability. Nuno Macedo, Hugo Pacheco, Alcino Cunha 17 / 21
  • 18. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Generic Non-deterministic Lenses • Using relational calculus we can define a generic Put that is the largest relation that satisfies the properties; • A transformation get : A → B can be lifted to a well-behaved non-deterministic lens get : δget Put = (π2 ρget, with (get◦ ◦ π1 )) ◦ [get◦ ] ? • Emerges naturally from the lens laws: • [get◦ ] ? (v , s) tests if v was changed, returning either the original s (acceptability), or any source s such that s = get v (stability); • Maximum updatability: δPut = ρget × δget. Nuno Macedo, Hugo Pacheco, Alcino Cunha 18 / 21
  • 19. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Generic Non-deterministic Lenses • Type-checking over δget and ρget directly could be undecidable and due to the central role of the converse, Put can not be directly executed; • Both these issues can be addressed by the optimizations already presented; • Forward transformations are functional so problematic cases are very limited: • Regarding type-checking, only particular ranges of splits are possibly undecidable; • The backward transformation can be efficiently executed; • Recursive expressions are also supported as they preserve the functionality of their algebras. Nuno Macedo, Hugo Pacheco, Alcino Cunha 19 / 21
  • 20. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Generic Non-deterministic Lenses: Example π1 id : id ◦ [π1 ] ◦ • The range is [π1 ] : A × (A × B) → A × (A × B), so Put only takes views (a, (b, c)) where a ≡ b; ◦ id)◦ will run, and π1 could generate all pairs until reaching (a, c); • When the view is updated, (π1 • With our optimization, the output of π1 is restricted to have c in the second element. Nuno Macedo, Hugo Pacheco, Alcino Cunha 20 / 21
  • 21. Introduction Relational Calculus Optimizations Recursion Bidirectional Transformations Conclusions Conclusions • We have presented mechanisms for the efficient execution PF relational expressions over data-types with invariants; • Regarding BX, we identify an open problem in the composition of lenses; • By modeling lenses in this framework we were able to implement an expressive PF BX language with maximum updatability; • Researching possible normal forms for invariants over recursive types; • Exploring mechanisms for a better control of the non-determinism through user-defined quality measures. Nuno Macedo, Hugo Pacheco, Alcino Cunha 21 / 21