S-CUBE LP: The Chemical Computing model and HOCL Programming

23
www.s-cube-network.eu S-Cube Learning Package The Chemical Computing model and HOCL Programming INRIA, CNR, SZTAKI Zsolt Németh, SZTAKI

description

 

Transcript of S-CUBE LP: The Chemical Computing model and HOCL Programming

Page 1: S-CUBE LP: The Chemical Computing model and HOCL Programming

www.s-cube-network.eu

S-Cube Learning Package

The Chemical Computing model and HOCL Programming

INRIA, CNR, SZTAKI

Zsolt Németh, SZTAKI

Page 2: S-CUBE LP: The Chemical Computing model and HOCL Programming

Learning Package Categorization

S-Cube

Service Infrastructure

Multi-level and self-adaptation

Supporting adaptation of

service-based applications

Page 3: S-CUBE LP: The Chemical Computing model and HOCL Programming

Learning Package Overview

The vision of chemical computing

Gamma

The γ-calculus

The Higher Order Chemical Language

Page 4: S-CUBE LP: The Chemical Computing model and HOCL Programming

Problem statement and motivation

Most algorithms are sequential even if the problem solving is

inherently parallel

Many algorithms are expressed in a cumbersome way

Declarative vs. imperative style of programming

Clear mathematical model for defining semantics

mxset: m:=a[1]

i:=1

*{i<n →

i:= i+1

m:=max(m, a[i])}

mxset: if tail(l)=nil

then head(l)

else max(head(l),mxset(tail(l)))

Page 5: S-CUBE LP: The Chemical Computing model and HOCL Programming

Notion of chemical computing

Solution

Data

Procedure

Page 6: S-CUBE LP: The Chemical Computing model and HOCL Programming

Notion of chemical computing

Page 7: S-CUBE LP: The Chemical Computing model and HOCL Programming

Why chemical

Concise problem description

Locality

– decisions on actual and timely conditions

– decisions on partial information

Self-evolving, autonomic, adaptive behaviour

Inherently parallel and concurrent

Highly dynamic

Coordinating problems

– large number of entities

– changing conditions

Beware! This model is not computational chemistry!

A large class of problems in SOA require unconventional approaches

– service composition, service coordination, service adaptation, workflow, etc.

Page 8: S-CUBE LP: The Chemical Computing model and HOCL Programming

Learning Package Overview

The vision of chemical computing

Gamma

The γ-calculus

The Higher Order Chemical Language

Page 9: S-CUBE LP: The Chemical Computing model and HOCL Programming

GAMMA

GAMMA (General Abstract Model for Multiset Manipulation)

multiset M

R(x1, x2,…xn) guard

A(x1, x2,…xn) action

(Ri, Ai) reaction

replace (x1, x2,…xn) in M

if R(x1, x2,…xn)

by A(x1, x2,…xn)

a large set of problems expressed in a concise way

– prime search, sorting, string processing, geometric problems, graph

algorithms, process control, etc.

Page 10: S-CUBE LP: The Chemical Computing model and HOCL Programming

GAMMA

The first language to capture the notion of chemical

programming

Now of merely historic value

Based on the idea of GAMMA

– the γ-calculus

- different of GAMMA

- higher order

- reaction rules = active molecules, part of the solution

- active molecules vanish in reactions

– Higher Order Chemical Language

- a language based on the γ-calculus

Page 11: S-CUBE LP: The Chemical Computing model and HOCL Programming

Learning Package Overview

The vision of chemical computing

Gamma

The γ-calculus

The Higher Order Chemical Language

Page 12: S-CUBE LP: The Chemical Computing model and HOCL Programming

The -calculus

captures the chemical notion

a declarative, functional formalism

inherently concurrent, indeterministic model of computation

shows similarities to the λ-calculus

1 2

7

5

8

γx,y.x+y

Page 13: S-CUBE LP: The Chemical Computing model and HOCL Programming

The -calculus

basic data structure: multiset (chemical solution)

– passive molecules: booleans, integers, tuples, naming molecules

– active molecules: -abstraction

reaction: an active molecule captures others and transforms

execution: perform reactions until a stable (inert) chemical solution is resulted

reactions are independent concurrent and indeterministic

1 2

7

5

8

2

7 8

6

2

7 8

γx,y.x+y

γx,y.x+y

1 5

Page 14: S-CUBE LP: The Chemical Computing model and HOCL Programming

Active molecules: -abstraction

P.M

– P is a pattern that selects elements for the reaction (head)

– M is the action (body)

– capture x and replace by its square: x . x*x

Conditional reactions: PC.M

– C is a condition; the reaction takes place if C is true

– capture x and if positive, replace by its square root: x x>0 . sqr(x)

Page 15: S-CUBE LP: The Chemical Computing model and HOCL Programming

Active molecules: -abstraction

Atomic capture: x1,x2,…xn.M

– a single reaction may capture multiple molecules

– capture x,y and replace them by their sum: x,y . x+y

Reaction: active molecules capture other molecules

– formal parameters are substituted in the body

– notion of free and bound variables

– x.M, N → M[x:=N]

– x,y . x+y, 2, 3 → 2+3

– 2, x,y . x+y, 3 → 2+3

– 3, 2, x,y . x+y → 2+3

– x,y . x.x+y, 2, 3 → x.x+2

– x,y . x.x+y, 2, 3 → x.x+3

Page 16: S-CUBE LP: The Chemical Computing model and HOCL Programming

The -calculus

-terms are

– Commutative: M1,M2≡M2,M1

– Associative: (M1,M2),M3≡M1,(M2,M3)

– Realize Brownian motion

Reactions

– Locality: if M1→M2, then M,M1→M,M2

– Solution: if M1→M2, then <M1>→<M2>

1 2

7

5

8

γx,y.x+y

1

2 7

5

8 γx,y.x+y

1

2 7

5

8 γx,y.x+y

5 7

3 γx.x*x

6

Page 17: S-CUBE LP: The Chemical Computing model and HOCL Programming

Learning Package Overview

The vision of chemical computing

Gamma

The γ-calculus

The Higher Order Chemical Language

Page 18: S-CUBE LP: The Chemical Computing model and HOCL Programming

A chemical language: HOCL

• Higher Order Chemical Language (HOCL)

• Higher order: active molecules (procedures)

– capture other active molecules

– produce other active molecules

• Multiset rewriting

• Program: solution of atoms

• < A1, A2, …An>

Page 19: S-CUBE LP: The Chemical Computing model and HOCL Programming

HOCL

• replace P by M if C in <>

– P: pattern, captured molecules

– M: action, produced molecules

– C: condition

max = replace x,y by x if x ≥ y in

<1, 2, 3, 4, 5, 6, 7, 8, 9, max>

primes = replace x,y by y if x div y in

<1, 2, 3, 4, 5, 6, 7, 8, 9, primes>

Page 20: S-CUBE LP: The Chemical Computing model and HOCL Programming

HOCL execution

max = replace x,y by x if x ≥ y in <1, 2, 3, 4, 5, 6, 7, 8, 9, max>

<1, 2, 3, 4, 5, 6, 7, 8, 9, max>

<1, 3, 4, 5, 6, 7, 8, 9, max>

<1, 3, 4, 5, 6, 8, 9, max>

<1, 4, 5, 6, 8, 9, max>

<4, 5, 6, 8, 9, max>

<4, 6, 8, 9, max>

<6, 8, 9, max>

<8, 9, max>

<9, max>

Page 21: S-CUBE LP: The Chemical Computing model and HOCL Programming

The Dutch flag example

let r = replace <i,red>,<j,white> by <i,white>,<j,red> if i>j in

let w = replace <i,white>,<j, blue> by <i, blue>,<j,white> if i>j in

let b = replace <i,red>,<j,blue> by <i,blue>,<j,red> if i>j in

<<1,blue>,<2,white>,<3,white>,<4,red>,<5,blue>,<6,white>,r,w,b>

blue

white

red 3

6

2

5

4

1

white

blue

white

b w

r

Page 22: S-CUBE LP: The Chemical Computing model and HOCL Programming

References

Jean-Pierre Banatre and Daniel LeMetayer. Programming by multiset transformation. Commun. ACM,

36(1):98–111, 1993.

Jean-Pierre Banatre, Pascal Fradet, and Yann Radenac. Generalized multisets for chemical programming.

Math. Struct. in Comp. Science, 16:557–580, 2006.

Jean-Pierre Banatre, Pascal Fradet, and Yann Radenac. Programming self-organizing systems with the

higher-order chemical language. International Journal of Unconventional Computing, 3(3):161–177, 2007

Page 23: S-CUBE LP: The Chemical Computing model and HOCL Programming

Acknowledgements

The research leading to these results has

received funding from the European

Community’s Seventh Framework

Programme [FP7/2007-2013] under grant

agreement 215483 (S-Cube).