A simulation tool for tccp programs Leticia Lavado joint work with - - PowerPoint PPT Presentation

a simulation tool for tccp programs
SMART_READER_LITE
LIVE PREVIEW

A simulation tool for tccp programs Leticia Lavado joint work with - - PowerPoint PPT Presentation

A simulation tool for tccp programs Leticia Lavado joint work with Laura Panizo Mar a del Mar Gallardo Dept. Lenguajes y Ciencias de la Computaci on Andaluc a Tech, University of M alaga September 13, 2016 Motivation


slide-1
SLIDE 1

A simulation tool for tccp programs

Leticia Lavado

joint work with

Laura Panizo Mar´ ıa del Mar Gallardo

  • Dept. Lenguajes y Ciencias de la Computaci´
  • n

Andaluc´ ıa Tech, University of M´ alaga

September 13, 2016

slide-2
SLIDE 2

Motivation

Simulation and Verification of tccp programs Reactive and concurrent systems Application domains: automotive, trains, medical applications. . . Complex to model and analyse

Concurrency features Synchronization Critical properties

Complex systems ➜ critical applications ➜ need to guarantee software safety and reliability tccp declarative language ➜ lack of simulation and analysis tools

Leticia Lavado (University of M´ alaga) September 13, 2016 2 / 24

slide-3
SLIDE 3

Our approach

A simulation tool Design and implementation a tool for simulating tccp programs

Modular design and architecture Based on an mechanism similar to abstract machines Simulation: to define a tccp interpreter based on tccp operational semantics

Leticia Lavado (University of M´ alaga) September 13, 2016 3 / 24

slide-4
SLIDE 4

Outline

Background: The tccp language Architecture of the proposal Implementation issues Evaluation Related Work Conclusions and Future Work

Leticia Lavado (University of M´ alaga) September 13, 2016 4 / 24

slide-5
SLIDE 5

Background

The tccp language (de Boer et al. 2000) tccp is a timed extension of ccp (Saraswat 1993) parametric w.r.t. an underlying constraint system store-as-constraint paradigm computation = parallel execution of agents that add or ask information to/for a monotonic global constraint store

constraint store

x > 2 y = 5 x > 0? y > 2?

time = global discrete clock

Leticia Lavado (University of M´ alaga) September 13, 2016 5 / 24

slide-6
SLIDE 6

Background

The tccp language (de Boer et al. 2000) tccp program P ∶∶= D.A where

D ∶∶= ⋃{p(⃗ x) ∶− A} A ∶∶= stop ∣ tell(c) ∣ ∑n

i=1 ask(ci) → Ai ∣ A1 ∥ A2 ∣ ∃xA ∣ p(⃗

x) ∣ now cthenA1 elseA2

small-step operational behaviour:

⟨A1,c1⟩ → ⟨A2,c2⟩ → ⟨A3,c3⟩ → ⟨A4,c4⟩... → is the transition relation (one-time unit)

Leticia Lavado (University of M´ alaga) September 13, 2016 6 / 24

slide-7
SLIDE 7

Background

Example: modelling a photocopier

initialize(MIdle):- ∃ E,C,A,T(tell(A=[free∣ ])|| tell(T=[MIdle∣ ]) || tell(E=[off∣ ]) || system(MIdle,E,C,A,T)). system(MIdle,E,C,A,T):- ∃ E’,C’,A’,T’(tell(E=[ ∣E’])|| tell(A=[ ∣A’]) || tell(C=[ ∣C’]) || tell(T=[ ∣T’]) || user(C,A) || ask(true) → photocopier(C,A’,MIdle,T,E’) || ask(A’=[free∣ ])→ system(MIdle,E’,C’,A’,T’))). user(C,A):- ask(A’=[free∣ ])→tell(C=[on∣ ]) || ask(A’=[free∣ ])→ tell(C=[off∣ ]) || ask(A’=[free∣ ])→tell(C=[c∣ ]) || ask(A’=[free∣ ])→ tell(true).

Leticia Lavado (University of M´ alaga) September 13, 2016 7 / 24

slide-8
SLIDE 8

Background

Example: modelling a photocopier

photocopier(C,A,MIdle,E,T):- ∃ Aux,Aux’,T’(tell(T=[Aux∣T’]) || ask(true) → now(Aux>0) then now(C=[on∣ ]) then tell(E=[going∣ ]) || tell(T’=[MIdle∣ ])|| tell(A=[free∣ ]) else now(C=[off∣ ]) then tell(E=[stop∣ ]) || tell(T’=[MIdle∣ ])|| tell(A=[free∣ ]) else now(C=[c∣ ]) then tell(E=[going∣ ]) || tell(T’=[MIdle∣ ]) || tell(A=[free∣ ]) else tell(Aux’=Aux-1) || tell(T’=[Aux’∣ ]) || tell(A=[free∣ ]) else tell(E=[stop∣ ]) || tell(A=[free∣ ]).

Leticia Lavado (University of M´ alaga) September 13, 2016 8 / 24

slide-9
SLIDE 9

Architecture of the proposal

Leticia Lavado (University of M´ alaga) September 13, 2016 9 / 24

slide-10
SLIDE 10

Architecture of the proposal

Executing scheme

Leticia Lavado (University of M´ alaga) September 13, 2016 10 / 24

slide-11
SLIDE 11

Architecture of the proposal

Abstract Machine instructions Given x ∈ V ar, and A be a tccp agent: A.x ➜ x in the scope of A p.⃗ x ➜ formal parameters ⃗ x of procedure p is consistent() add variable(A.x) add parameter(p.⃗ x, ⃗ x′) add constraint(A.c) entails(c) merge(local1,local2)

Leticia Lavado (University of M´ alaga) September 13, 2016 11 / 24

slide-12
SLIDE 12

Architecture of the proposal

Agent execution Modifying main memory tell: tell(c)

1

is consistent()

2

add constraint(c)

3

Return ⟨global,stop⟩

Leticia Lavado (University of M´ alaga) September 13, 2016 12 / 24

slide-13
SLIDE 13

Architecture of the proposal

Agent execution Modifying symbol table hidding: ∃xA

1

is consistent()

2

add variable(A.x)

3

Return execute(A)

procedure call: p(⃗ x) ∶ −A

1

is consistent()

2

add parameter(p.⃗ x,p. ⃗ x′)

3

Return ⟨global,A⟩

Leticia Lavado (University of M´ alaga) September 13, 2016 13 / 24

slide-14
SLIDE 14

Architecture of the proposal

Agent execution No modifying the store choice: ∑n

i=1 ask(ci) → Ai

1

is consistent()

2

If ¬entails(ci) for i = 1,...,n, → step 4, else select randomly ask(ci) → Ai such that entails(ci) → step 3

3

Return ⟨global,Ai⟩

4

Return ⟨global,∑n

i=1 ask(ci) → Ai⟩

now: now c then A else B

1

is consistent()

2

if entails(c) → execute(A), else → execute(B)

parallel: A1∣∣A2

1

is consistent()

2

execute(A1) = ⟨local1,nA1⟩

3

execute(A2) = ⟨local2,nA2⟩

4

Return ⟨merge(local1,local2),nA1∣∣nA2⟩

Leticia Lavado (University of M´ alaga) September 13, 2016 14 / 24

slide-15
SLIDE 15

Implementation issues

Main elements of the implementation Tools and architecture entities Parsers (ANTLR) Interpreters tccp and agent interpreter (Java) Constraint Solvers (PPL for numeric constraint solver) Store ➜ symbol table and main memory (Java)

Leticia Lavado (University of M´ alaga) September 13, 2016 15 / 24

slide-16
SLIDE 16

Implementation issues

Store implementation Symbol table = scope of agents Tree structure Each node stores the list of variables belong to its scope Contains identifiers and references to main memory

Leticia Lavado (University of M´ alaga) September 13, 2016 16 / 24

slide-17
SLIDE 17

Implementation issues

Store implementation Main memory = information of all variables Available types: constant, discrete variable, expression, functor and reference Data field: depends on the type of element PPL convex polyhedron that keeps the numeric linear constraints

Leticia Lavado (University of M´ alaga) September 13, 2016 17 / 24

slide-18
SLIDE 18

Implementation issues

Problems faced Logic, concurrent and synchronous nature of tccp

Store consistency - Constraint solving (logic and numeric constraints) Dynamic generation of fine-grained procedures Dynamic generation of local variables Concurrency in the store - Parallel execution of agents

Leticia Lavado (University of M´ alaga) September 13, 2016 18 / 24

slide-19
SLIDE 19

Evaluation

Running the photocopier program

Leticia Lavado (University of M´ alaga) September 13, 2016 19 / 24

slide-20
SLIDE 20

Evaluation

Photocopier Example: Store state after 7 steps

Leticia Lavado (University of M´ alaga) September 13, 2016 20 / 24

slide-21
SLIDE 21

Evaluation

Performance statistics 30 steps 100 steps 500 steps Symbol Table (nodes) 26 85 417 Global Memory (regiters) 78 239 1169 disc poly (dimensions) 6 6 6 Heap used (MB) 4 4.1 7 Heap allocated (MB) 16.3 16.3 16.3 Parser (ms) 192 196 197 Simulation (ms) 87 192 2,170

Leticia Lavado (University of M´ alaga) September 13, 2016 21 / 24

slide-22
SLIDE 22

Related Work

Concurrent, declarative and synchronous languages declarative and synchronous character

Lustre (SCADE Suite) SIGNAL (POLYCHRONY)

concurrent logic programming

PARLOG KL1

tccp tools

Mozart-Oz tccp Interpreter

Leticia Lavado (University of M´ alaga) September 13, 2016 22 / 24

slide-23
SLIDE 23

Conclusions and Future Work

Contributions An abstract machine for tccp An implementation of a tccp simulator Available tool ➜ http://morse.uma.es/tools/tccp Future work = extend to hy-tccp Extend the abstract machine to hy-tccp Extend tccp model checking algorithms to hy-tccp Analysing reachability, safety and other properties Abstract interpretation based tools for diagnosis and analysis

Leticia Lavado (University of M´ alaga) September 13, 2016 23 / 24

slide-24
SLIDE 24

Thanks for your attention! Questions?

Leticia Lavado (University of M´ alaga) September 13, 2016 24 / 24