370 likes | 479 Views
Interface Theories With Component Reuse. Laurent Doyen EPFL Thomas Henzinger EPFL Barbara Jobstmann EPFL Tatjana Petrov EPFL. Outline. Motivation Interface theories and component-based design New operator: component reuse Shared refinement: Stateless Interfaces
E N D
Interface Theories With Component Reuse Laurent Doyen EPFL Thomas Henzinger EPFL Barbara Jobstmann EPFL Tatjana Petrov EPFL
Outline • Motivation • Interface theories and component-based design • New operator: component reuse • Shared refinement: Stateless Interfaces • Shared refinement: Stateful Interfaces • Conclusions and future work 2
Interfaces Odd(x)? x int y boolean Signature Divide x int Assertional z real y int, y!=0 • analogy with type systems • static checking at compile-time • well-formed: usable in some environment 3
Interface Automaton FIFO enq deq E F Size2Buffer (enq,deq), (!enq,!deq) (enq,deq), (!enq,!deq) (enq,deq), (!enq,!deq) enq (enq,!deq) (enq,!deq) deq EF EF EF E F (enq,deq) (!enq,deq) Transition guards Assumption: !(deq,!enq) Guarantee: (E,!F) 4
Component-Based Design I1 I2 I1 I12 I2 I11 I21 I22 I13 I11 I112 I111 5
Interface Theories If A and B are compatible and A' A and B' B, then A’ and B' are compatible and A'||B' A||B. A B A’ B’ 6
Component-Based Design I1 I2 I1 I12 I2 I11 I21 I22 I13 I11 I112 I22 Π I112 I111 7
Interface Theories • Parallel composition and feedback, Contravariant refinement relation => independent implementiability => stepwise refinement [de Alfaro, Henzinger, 2001] • Shared refinement => greatest lower bound in the refinement lattice => associativity => distributivity 8
Stateless Interface • Predicates over input and output variables • Wellformedness • Inputs and outputs disjoint • Assumption satisfiable • Guarantee satisfiable Guarantee over outputs Assumption about inputs Divide x int z real y int, y!=0 9
Parallel Composition A y mod 3 = 0 even(x) B z mod 4 = 0 x > 0 A||B A y even(x) & (x>0) y mod 3 = 0 & z mod 4 = 0 x B z 10
Parallel Composition A y mod 3 = 0 even(x) B z mod 4 = 0 odd(x) INCOMPATIBLE ! A||B A y y mod 3 = 0 & z mod 4 = 0 x FALSE B z 11
Connection A x z y x=0 => y=0 TRUE Ac x z y forall x,z. (TRUE & (x=z)) => (x=0 => y=0) TRUE & (x=z) y=0 12
Connection Ac z y = 0 TRUE INCOMPATIBLE ! 13
Refinement Relation A even(y) even(x) B y mod 4 = 0 x int B refines A 14
Refinement Relation C y mod 3 = 0 even(x) B y mod 4 = 0 x int Implementation must obey output guarantee → B does not refine C 15
Refinement Relation D even(y) even(x) B y mod 4 = 0 odd(x) Implementation must accept all permissible inputs → B does not refine D 16
Shared Refinement A y mod 3 = 0 even(x) even(x) OR x>0 A Π B y mod 12 = 0 B y mod 4 = 0 x>0 (A Π B) can be used in any design as an implementation of A, and as an implementation of B 17
Shared Refinement A odd(y) even(x) B y mod 4 = 0 x>0 18
Shared Refinement A odd(y) even(x) even(x) OR x>0 A Π B FALSE B y mod 4 = 0 x>0 NOT SHARED-REFINABLE ! 19
Shared Refinement: Properties Greatest lower bound in the refinement lattice Associativity: Distributivity: A1 A2 a1 g1 a2 g2 A1 Π A2 a1 OR a2 g1 & g2 A1 x A2 (A Π B) Π C = A Π (B Π C) A || (B Π C) = (A || B) Π (A || C) A Π (B || C) = (A Π B) || (A Π C) 20
Shared Refinement: Properties Greatest lower bound in the refinement lattice A B A Π B for all C, if C ≤ A and C ≤ B then C ≤ A Π B 21
Shared Refinement: Properties Greatest lower bound in the refinement lattice A B A Π B C 22
Shared Refinement: Properties Associativity A3 A1 B2 B1 A1 Π B1 Π B2 Π A3 23
Stateful Interface FIFO enq deq E F Size2Buffer (enq,deq), (!enq,!deq) (enq,deq), (!enq,!deq) (enq,deq), (!enq,!deq) enq (enq,!deq) (enq,!deq) deq EF EF EF E F (enq,deq) (!enq,deq) Transition guards Assumption: !(deq,!enq) Guarantee: (E,!F) 24
Interface Theories • Define • Refinement relation • Composition of interfaces so that… • Ensure If A and B is are compatible and A' A and B' B, then A’ and B' are compatible and A'||B' A||B. • [de Alfaro, Henzinger, 2001] 25
Stateful Interface • Wellformedness • Satisfiable assumption in each state = non-stopping • Satisfiable guarantee in each state • Deterministic Size2Buffer (enq,deq), (!enq, !deq) (enq,deq), (!enq, !deq) (enq,deq), (!enq, !deq) enq deq (enq ,!deq) (enq, !deq) E EF EF EF F (enq ,deq) (!enq, deq) 26
Stateful Interfaces: Refinement • Alternating simulation relation [Alur, Henzinger, Kupferman, Vardi, 1998] • N refines M if there exists a relation R between the states such that if (p,q) is in R, then • a(p) => a(q) • g(q) => g(p) • a(p) & g(q) & (p → p’) & (q → q’) => (p’,q’) in R 27
Stateful Interfaces: Refinement p1 x even A y int x: int y : int q1 ≤ p1 q1 x int y odd p2 p3 x int x even y int y odd q3 ≤ p3 q2 ≤ p2 q2 q3 x even x int y odd y int 28
Stateful Interfaces: Refinement SlowBuffer (!enq ,!deq) enq or deq T T (!enq ,!deq) Size2Buffer (enq,deq), (!enq,!deq) (enq,deq), (!enq,!deq) (enq,deq), (!enq,!deq) enq enq deq deq (enq,!deq) (enq,!deq) E E EF EF EF F F (enq,deq) (!enq,deq) 29
Shared Refinement I1 I2 I1 I12 I2 I11 I21 SlowBuffer I13 I11 Size2Buffer Size2Buffer Π SlowBuffer I111 30
Stateful Interface !e!d e!d,!ed,ed T T e!d !e!d !e!d !e!d !ed !e!d !ed EF EF EF e!d !ed Size2Buffer Π SlowBuffer ed !e!d ed e!d !e!d !e!d ed EF EF EF !ed !ed ed !ed !ed ed ed e!d e!d EF EF EF !ed !ed 31
Shared Refinement: Properties Greatest lower bound in the refinement lattice Associativity: Distributivity: (A Π B) Π C = A Π(B Π C) A || (B Π C) ≤ (A || B) Π(A || C) (A Π B) || (A ΠC) ≤ A Π (B || C) 32
Shared Refinement: Properties Distributivity A || (B Π C) ≤ (A || B) Π (A || C) A B A C (A||B) Π (A||C) 33
Shared Refinement: Properties Distributivity A || (B Π C) ≤ (A || B) Π (A || C) A B A C (A||B) Π (A||C) A B Π C A || (B Π C) 34
View-Points Timing T Power P Functional F F Π T Π P 35
Conclusions • We extended the existing theory Possible Applications • Implementation of view-points • Refactoring of systems • Use of standard components 36
Future Work • Implementation of an automatic checker for shared refinability • Asynchronous case • Relationship to modal interfaces [Benveniste et al.: Residual for Component Specifications, 2007] 37