SlideShare a Scribd company logo
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

More Related Content

What's hot

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
butest
 
Gentle Introduction to Dirichlet Processes
Gentle Introduction to Dirichlet ProcessesGentle Introduction to Dirichlet Processes
Gentle Introduction to Dirichlet Processes
Yap 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 Subsampling
Martino 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 Mappings
Archzilon Eshun-Davies
 
Logistic Regression(SGD)
Logistic Regression(SGD)Logistic Regression(SGD)
Logistic Regression(SGD)
Prentice Xu
 
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
Förderverein Technische Fakultät
 
"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
 
Fulltext
FulltextFulltext
Fulltext
guestc03e0b
 
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
VLSICS Design
 
Chapter 9 newer
Chapter 9   newerChapter 9   newer
Chapter 9 newer
Sonam Maurya
 
Approximate Tree Kernels
Approximate Tree KernelsApproximate Tree Kernels
Approximate Tree Kernels
Niharjyoti Sarangi
 
Multilayer Neural Networks
Multilayer Neural NetworksMultilayer Neural Networks
Multilayer Neural Networks
ESCOM
 
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 Series
Tiago Mendes Dantas
 
Ef24836841
Ef24836841Ef24836841
Ef24836841
IJERA Editor
 
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
Anthony Perez
 
chap 6 - Example şift
chap 6 - Example şiftchap 6 - Example şift
chap 6 - Example şift
ermis26
 
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: Mixtures
zukun
 

What's hot (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
 

Viewers also liked

Gardena t2
Gardena t2Gardena t2
Gardena t2
preheppy
 
Ec
EcEc
Ec
jyabe
 
eLEDGER - the ONE MINUTE pitch
eLEDGER - the ONE MINUTE pitcheLEDGER - the ONE MINUTE pitch
eLEDGER - the ONE MINUTE pitch
eLEDGER Team
 
Infografika inbound marketing
Infografika inbound marketingInfografika inbound marketing
Infografika inbound marketing
SEOwind
 
Client factfile
Client factfileClient factfile
Client factfile
Jamie Kessel
 
Robot educador 2
Robot educador 2Robot educador 2
Robot educador 2
mixerboy12
 
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: Documentary
zoehface
 
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
Henk van Roekel
 
pictures used
pictures usedpictures used
pictures used
Jamie Kessel
 
Nxt sensores
Nxt sensoresNxt sensores
Nxt sensores
mixerboy12
 
Shopcherriescom
ShopcherriescomShopcherriescom
Shopcherriescom
Shop cherries
 
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 entario
mixerboy12
 
Magazine analysis
Magazine analysisMagazine analysis
Magazine analysis
Jamie Kessel
 
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 complexity
jserravallo
 
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 pronunciation
Samira Rahmdel
 

Viewers also liked (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 to Relations as Executable Specifications

slides.07.pptx
slides.07.pptxslides.07.pptx
slides.07.pptx
balewayalew
 
NIPS2007: structured prediction
NIPS2007: structured predictionNIPS2007: structured prediction
NIPS2007: structured prediction
zukun
 
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
Akos Hajdu
 
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...
The Statistical and Applied Mathematical Sciences Institute
 
SVD and the Netflix Dataset
SVD and the Netflix DatasetSVD and the Netflix Dataset
SVD and the Netflix Dataset
Ben Mabey
 
Linear regression
Linear regressionLinear regression
Linear regression
ansrivas21
 
Solvers and Applications with CP
Solvers and Applications with CPSolvers and Applications with CP
Solvers and Applications with CP
iaudesc
 
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
Malik Abdul Wahab
 
GAN(と強化学習との関係)
GAN(と強化学習との関係)GAN(と強化学習との関係)
GAN(と強化学習との関係)
Masahiro Suzuki
 
PowerLyra@EuroSys2015
PowerLyra@EuroSys2015PowerLyra@EuroSys2015
PowerLyra@EuroSys2015
realstolz
 
CS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and CullingCS 354 Transformation, Clipping, and Culling
CS 354 Transformation, Clipping, and Culling
Mark 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 Clouds
Roger Hernando Buch
 
240527_Thanh_LabSeminar[Transitivity Recovering Decompositions: Interpretable...
240527_Thanh_LabSeminar[Transitivity Recovering Decompositions: Interpretable...240527_Thanh_LabSeminar[Transitivity Recovering Decompositions: Interpretable...
240527_Thanh_LabSeminar[Transitivity Recovering Decompositions: Interpretable...
thanhdowork
 
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
Edmundo 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 Problem
Ulaş Bağcı
 
nlp2.pdf
nlp2.pdfnlp2.pdf
nlp2.pdf
nyomans1
 
Design of Engineering Experiments Part 5
Design of Engineering Experiments Part 5Design of Engineering Experiments Part 5
Design of Engineering Experiments Part 5
Stats Statswork
 
High-Dimensional Network Estimation using ECL
High-Dimensional Network Estimation using ECLHigh-Dimensional Network Estimation using ECL
High-Dimensional Network Estimation using ECL
HPCC 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 Applications
Alex Pruden
 
Symbolic Computation via Gröbner Basis
Symbolic Computation via Gröbner BasisSymbolic Computation via Gröbner Basis
Symbolic Computation via Gröbner Basis
IJERA Editor
 

Similar to 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
 
240527_Thanh_LabSeminar[Transitivity Recovering Decompositions: Interpretable...
240527_Thanh_LabSeminar[Transitivity Recovering Decompositions: Interpretable...240527_Thanh_LabSeminar[Transitivity Recovering Decompositions: Interpretable...
240527_Thanh_LabSeminar[Transitivity Recovering Decompositions: Interpretable...
 
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
 

Recently uploaded

How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 

Recently uploaded (20)

How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 

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