How to write and prove programs with constraints and linear logic? - - PowerPoint PPT Presentation

how to write and prove programs with constraints and
SMART_READER_LITE
LIVE PREVIEW

How to write and prove programs with constraints and linear logic? - - PowerPoint PPT Presentation

How to write and prove programs with constraints and linear logic? Thierry Martinez Contraintes Project-Team INRIA Junior Seminar, 18 October 2011 Contraintes project-team Topic Formal semantics for programming languages Methods Logic


slide-1
SLIDE 1

How to write and prove programs with constraints and linear logic?

Thierry Martinez Contraintes Project-Team INRIA Junior Seminar, 18 October 2011

slide-2
SLIDE 2

“Contraintes” project-team

Topic Formal semantics for programming languages Methods Logic and constraints Applications

▸ Solving/optimization of combinatorial problems ▸ Systems Biology

slide-3
SLIDE 3

“Contraintes” project-team

Topic Formal semantics for programming modeling languages Methods Logic and constraints Applications

▸ Solving/optimization of combinatorial problems ▸ Systems Biology

slide-4
SLIDE 4

Sudoku

We probably all know the rules of the Sudoku...

0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

slide-5
SLIDE 5

Sudoku

We probably all know the rules of the Sudoku...

0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

▸ for every line i and every column j,

the case (i,j) should have a value 1 ⩽ X(i,j) ⩽ 9.

slide-6
SLIDE 6

Sudoku

We probably all know the rules of the Sudoku...

0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

▸ for every line i and every column j,

the case (i,j) should have a value 1 ⩽ X(i,j) ⩽ 9.

▸ for every line i

and every pair (j,k) of distinct columns, we should have X(i,j) ≠ X(i,k).

slide-7
SLIDE 7

Sudoku

We probably all know the rules of the Sudoku...

0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

▸ for every line i and every column j,

the case (i,j) should have a value 1 ⩽ X(i,j) ⩽ 9.

▸ for every line i

and every pair (j,k) of distinct columns, we should have X(i,j) ≠ X(i,k).

▸ for every column i

and every pair (j,k) of distinct lines, we should have X(j,i) ≠ X(k,i).

slide-8
SLIDE 8

Sudoku

We probably all know the rules of the Sudoku...

0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

▸ for every line i and every column j,

the case (i,j) should have a value 1 ⩽ X(i,j) ⩽ 9.

▸ for every line i

and every pair (j,k) of distinct columns, we should have X(i,j) ≠ X(i,k).

▸ for every column i

and every pair (j,k) of distinct lines, we should have X(j,i) ≠ X(k,i).

▸ for every 3 × 3-block (i,j)

and every distinct cases (m,n) and (m′,n′) in this block, we should have X3×(i,j)+(m,n) ≠ X3×(i,j)+(m′,n′).

slide-9
SLIDE 9

Sudoku

We probably all know the rules of the Sudoku... Logical formulas

▸ ∀i j ∈ {0...8},1 ⩽ X(i,j) ⩽ 9 ▸ ∀i j k ∈ {0...8},j ≠ k ⇒ X(i,j) ≠ X(i,k) ▸ ∀i j k ∈ {0...8},j ≠ k ⇒ X(j,i) ≠ X(k,i) ▸ ∀i j m n m′ n′ ∈ {0...2},(m,n) ≠ (m′,n′) ⇒

X3×(i,j)+(m,n) ≠ X3×(i,j)+(m′,n′)

slide-10
SLIDE 10

Constraints

▸ Constraints = atomic formulas, X(1,1) ≠ X(1,2) ▸ Model = conjunction of constraints

⋀constraints ⇒ solution

▸ Constraints formalized as relations:

“X(1,1) ≠ X(1,2)” = {(X(i,j))0⩽i⩽8,0⩽j⩽8 ∣ X(1,1) ≠ X(1,2)}

▸ The set of solutions is the intersection

⋂{relations} = {set of solutions}

▸ Explicit representation is intractable

slide-11
SLIDE 11

Domain and propagation

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 x

slide-12
SLIDE 12

Domain and propagation

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 x 2 3 5 8 9 1 2 3 4 5 6 7 8 9 2 3 5 8 9 Domain: x

slide-13
SLIDE 13

Domain and propagation

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 x 2 3 5 8 9 1 4 6 7 2 3 5 8 9 2 3 5 8 9 Domain: x

slide-14
SLIDE 14

Domain and propagation

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 x 1 4 6 7 2 3 5 8 9 9 6 8 7 4 Domain: x

slide-15
SLIDE 15

Domain and propagation

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 x 1 2 3 4 5 6 7 8 9 9 6 8 7 4 Domain: x

slide-16
SLIDE 16

Domain and propagation

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 1 1 2 3 4 5 6 7 8 9 Domain: x

slide-17
SLIDE 17

Domain and propagation

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 5 3 2 1

slide-18
SLIDE 18

Domain and propagation

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 5 3 2 1 2 3 5 6 7 8 9 1 4

c1 c2 c3 c4 c5 c6 c7 c8 c9

There exists x ∈ 1,...,9 such that cx = 1. x

slide-19
SLIDE 19

Domain and propagation

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 5 3 2 1 5 9 7 2 1 2 3 7 8 9 1 4 5 6

c1 c2 c3 c4 c5 c6 c7 c8 c9

There exists x ∈ 1,...,9 such that cx = 1. x

slide-20
SLIDE 20

Domain and propagation

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 5 3 2 1 8 1 5 2 3 1 4 5 6 7 8 9

c1 c2 c3 c4 c5 c6 c7 c8 c9

There exists x ∈ 1,...,9 such that cx = 1. x

slide-21
SLIDE 21

Domain and propagation

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 5 3 2 1 1 5 3 2 1 3 4 5 6 7 8 9 1

c1 c2 c3 c4 c5 c6 c7 c8 c9

There exists x ∈ 1,...,9 such that cx = 1. x

slide-22
SLIDE 22

Domain and propagation

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 5 3 2 1 3 1 2 7 2 8 7 2 9 3 8 7 7 2 7

slide-23
SLIDE 23

Memory paradigm shift

RAM model Addresses/ Variables Values x vx y vy z vz t vt ⋮

▸ Imperative paradigm:

assigns many, reads many

▸ Functional paradigm:

assigns once, reads many

slide-24
SLIDE 24

Memory paradigm shift

RAM model Constraint memory model (Partial information) Addresses/ Variables Values x vx y vy z vz t vt ⋮ There exist x, y, z, t. . . such that

increasing knowledge

slide-25
SLIDE 25

Memory paradigm shift

RAM model Constraint memory model (Partial information) Addresses/ Variables Values x vx y vy z vz t vt ⋮ There exist x, y, z, t. . . such that x ∈ {1,...,15}

increasing knowledge

slide-26
SLIDE 26

Memory paradigm shift

RAM model Constraint memory model (Partial information) Addresses/ Variables Values x vx y vy z vz t vt ⋮ There exist x, y, z, t. . . such that x ∈ {1,...,15} and y ∈ {5,...,50}

increasing knowledge

slide-27
SLIDE 27

Memory paradigm shift

RAM model Constraint memory model (Partial information) Addresses/ Variables Values x vx y vy z vz t vt ⋮ There exist x, y, z, t. . . such that x ∈ {1,...,15} and y ∈ {5,...,50} and y ⩽ x

increasing knowledge

slide-28
SLIDE 28

Memory paradigm shift

RAM model Constraint memory model (Partial information) Addresses/ Variables Values x vx y vy z vz t vt ⋮ There exist x, y, z, t. . . such that x ∈ {1 / 5,...,15} and y ∈ {5,...,50} and y ⩽ x

increasing knowledge

slide-29
SLIDE 29

Memory paradigm shift

RAM model Constraint memory model (Partial information) Addresses/ Variables Values x vx y vy z vz t vt ⋮ There exist x, y, z, t. . . such that x ∈ {1 / 5,...,15} and y ∈ {5,...,50

15} and

y ⩽ x

increasing knowledge

slide-30
SLIDE 30

Memory paradigm shift

RAM model Constraint memory model (Partial information) Addresses/ Variables Values x vx y vy z vz t vt ⋮ There exist x, y, z, t. . . such that x ∈ {1 / 5,...,15} and y ∈ {5,...,50

15} and

y ⩽ x and z ∈ Q ∩ [5,9] and more...

increasing knowledge

slide-31
SLIDE 31

Propagation power

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 5 3 2 1 3 1 2 7 2 8 7 2 9 3 8 7 7 2 7 x y z 4 6 1 2 3 5 7 8 9 x 4 6 1 2 3 5 7 8 9 y 1 3 4 6 2 5 7 8 9 z

slide-32
SLIDE 32

Propagation power

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 5 3 2 1 3 1 2 7 2 8 7 2 9 3 8 7 7 2 7 x y z 4 6 1 2 3 5 7 8 9 x 4 6 1 2 3 5 7 8 9 y 1 3 2 4 5 6 7 8 9 z

slide-33
SLIDE 33

Propagation power

9 6 8 7 4 7 2 1 5 3 9 7 1 9 5 2 7 2 3 1 2 8 8 5 3 9 5 3 2 1 3 1 2 7 2 8 7 2 9 3 8 7 7 2 7 4 9 6 8 5 8 4 9 6 5 6 3 1 4 3 4 6 8 8 1 4 5 3 9 6 6 5 4 1 4 6 9 5 1 4 6

slide-34
SLIDE 34

Flow-network algorithm

source x1 x2 ⋮ ⋮ xn v1 v2 ⋮ ⋮ vn target

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Residual network of Ford-Fulkerson: reduced domain

slide-35
SLIDE 35

Concurrent programming framework

Constraint Model Variable domains Dedicated Propagators acting concurrently Symbolic Constraints

(Graph theory)

Placement Constraints

(Discrete Geometry theory)

Scheduling Constraints

(Formal Language theory)

slide-36
SLIDE 36

NP-completeness

9 6 8 3 2 1 3 6 1 2 2 1 6 3 9 6 2 8 3 1 7 3 7 1 9 6 2 8 1 2 4 7 5 3 9 6 6 3 2 8 1 7 3 6 1 5 2 1 2 7 6 3 Propagators are polynomial. Finding a solution is NP-complete.

slide-37
SLIDE 37

Propagation and search

X(1,1) =? propagation 1 3 5 X(1,2) =? propagation

Andorra Principle

Do the deterministic bits first.

slide-38
SLIDE 38

Conjunction and disjunction

▸ In constraint programming, “and” between constraint ▸ “or” to express choices: in Sudoku,

X(1,1) = 1 ∨ X(1,1) = 2 ∨ ⋅⋅⋅ ∨ X(1,1) = 9

slide-39
SLIDE 39

Logic programming: logic as a programming language

▸ Abstracting programming traits: concurrency, non

determinism...

▸ Every computation is the search for a proof

Programs = Logical formulas Execution = Proof search

slide-40
SLIDE 40

What is a proof for a conjunction?

⋮ A ⋮ B A ∧ B

slide-41
SLIDE 41

What is a proof for a disjunction?

⋮ A A ∨ B ⋮ B A ∨ B A ∨ B A B

slide-42
SLIDE 42

The logical implication as synchronization mechanism

⋮ A ⋮ A ⇒ B B

slide-43
SLIDE 43

Logic operators as programming constructs

▸ “and”, ∧: parallel composition ▸ “or”, ∨: non-deterministic choice ▸ “implies”, ⇒: synchronization between parallel tasks (wait) ▸ “exists”, ∃: introducing local variables ▸ elementary formulas: constraints, for adding knowledge about

variables To implement propagators, need to update domains (imperative features).

slide-44
SLIDE 44

The Linear Concurrent Constraint Programming project

▸ Linear logic (Girard, 87): logic where formulas are resources ▸ Linear implication A ⊸ B is a process which transforms and

consumes A to produce B

▸ Synchronization mechanism relying on linear implication

updates the knowledge by removing some hypotheses

slide-45
SLIDE 45

Linear logic as a concurrent programming language

▸ Constraints = messages, with partial knowledge ▸ Logic variables = communication channel ▸ Existential operator (∃) = channel locality ▸ Universal operator (∀) = generic synchronization

(∀x(a(x) ⊸ ...))

slide-46
SLIDE 46

Semantics of programming languages

Program Mathematical model interpretation Observation Property execution proof

slide-47
SLIDE 47

Semantics of programming languages

Program Mathematical model Logical formula interpretation Observation Property execution proof

slide-48
SLIDE 48

Semantics of programming languages

interpretation Logical formula Observation Property execution proof

slide-49
SLIDE 49

Semantics of programming languages

interpretation Logical formula Observable property execution proof

slide-50
SLIDE 50

Semantics of programming languages

interpretation Logical formula Observable property execution = proof search

slide-51
SLIDE 51

Warehouse bin-packing

Box placements in containers:

▸ variables = box positions ▸ constraints = weight distribution, gravity. . .

Industrial partnerships with PSA, Fiat...

slide-52
SLIDE 52

Optimizing energy in underground trains timetable

Reduce energy consumption by slight timetable shifting:

▸ variables = time shift ▸ constraints = energy limit

Industrial partnership with General Electrics

slide-53
SLIDE 53

Analysis of large graphs of reaction networks in Systems Biology

Model analysis for conservation laws, dead-locks, comparisons between models.

▸ variables = molecules / vertices ▸ constraints = graph structure

Industrial partnership with Dassault Systme

slide-54
SLIDE 54

Thesis

The design and the implementation of LCC Design Selection of the right logical fragment of linear logic for modular programming, re-use of code, imperative traits... Implementation The LCC compiler (and a compiler for a modular extension of Prolog), with efficient algorithms for proof search Output Compiler for a new programming language for concurrent, imperative and constraint programming. Mono-paradigm: semantics driven by proof theory.

slide-55
SLIDE 55

That’s all folks!

Thank you! Let’s go for questions.