how to write and prove programs with constraints and
play

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


  1. How to write and prove programs with constraints and linear logic? Thierry Martinez Contraintes Project-Team INRIA Junior Seminar, 18 October 2011

  2. “Contraintes” project-team Topic Formal semantics for programming languages Methods Logic and constraints ▸ Solving/optimization of combinatorial problems Applications ▸ Systems Biology

  3. “Contraintes” project-team Topic Formal semantics for programming languages modeling Methods Logic and constraints ▸ Solving/optimization of combinatorial problems Applications ▸ Systems Biology

  4. Sudoku We probably all know the rules of the Sudoku... 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8

  5. Sudoku We probably all know the rules of the Sudoku... ▸ for every line i and every column j , the case ( i , j ) should have a value 1 ⩽ X ( i , j ) ⩽ 9. 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8

  6. Sudoku We probably all know the rules of the Sudoku... ▸ for every line i and every column j , the case ( i , j ) should have a value 1 ⩽ X ( i , j ) ⩽ 9. 0 1 2 3 4 5 6 7 8 ▸ for every line i 0 1 and every pair ( j , k ) of distinct columns, 2 we should have X ( i , j ) ≠ X ( i , k ) . 3 4 5 6 7 8

  7. Sudoku We probably all know the rules of the Sudoku... ▸ for every line i and every column j , the case ( i , j ) should have a value 1 ⩽ X ( i , j ) ⩽ 9. 0 1 2 3 4 5 6 7 8 ▸ for every line i 0 1 and every pair ( j , k ) of distinct columns, 2 we should have X ( i , j ) ≠ X ( i , k ) . 3 ▸ for every column i 4 and every pair ( j , k ) of distinct lines, 5 we should have X ( j , i ) ≠ X ( k , i ) . 6 7 8

  8. Sudoku We probably all know the rules of the Sudoku... ▸ for every line i and every column j , the case ( i , j ) should have a value 1 ⩽ X ( i , j ) ⩽ 9. 0 1 2 3 4 5 6 7 8 ▸ for every line i 0 1 and every pair ( j , k ) of distinct columns, 2 we should have X ( i , j ) ≠ X ( i , k ) . 3 ▸ for every column i 4 and every pair ( j , k ) of distinct lines, 5 we should have X ( j , i ) ≠ X ( k , i ) . 6 7 ▸ for every 3 × 3-block ( i , j ) 8 and every distinct cases ( m , n ) and ( m ′ , n ′ ) in this block, we should have X 3 ×( i , j )+( m , n ) ≠ X 3 ×( i , j )+( m ′ , n ′ ) .

  9. Sudoku We probably all know the rules of the Sudoku... ▸ ∀ 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 ) Logical formulas ▸ ∀ i j m n m ′ n ′ ∈ { 0 ... 2 } , ( m , n ) ≠ ( m ′ , n ′ ) ⇒ X 3 ×( i , j )+( m , n ) ≠ X 3 ×( i , j )+( m ′ , n ′ )

  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

  11. Domain and propagation x 2 3 5 8 9 4 7 2 3 7 5 9 7 2 1 8 1 5 8 6 1 9 3 9 7 2

  12. Domain and propagation x 2 2 2 3 3 3 5 5 5 8 8 8 9 9 9 4 7 2 3 7 5 9 7 2 1 8 1 5 8 6 1 9 3 9 7 2 Domain: x 1 2 3 4 5 6 7 8 9

  13. Domain and propagation x 2 2 2 3 3 3 5 5 5 8 8 8 9 9 9 4 7 2 3 7 5 9 7 2 1 8 1 5 8 6 1 9 3 9 7 2 Domain: x 1 2 3 4 5 6 7 8 9

  14. Domain and propagation x 2 3 5 8 9 4 4 7 2 3 7 7 5 9 7 2 1 8 8 1 5 8 6 6 1 9 3 9 9 7 2 Domain: x 1 2 3 4 5 6 7 8 9

  15. Domain and propagation x 2 3 5 8 9 4 4 7 2 3 7 7 5 9 7 2 1 8 8 1 5 8 6 6 1 9 3 9 9 7 2 Domain: x 1 2 3 4 5 6 7 8 9

  16. Domain and propagation 1 2 3 5 8 9 4 7 2 3 7 5 9 7 2 1 8 1 5 8 6 1 9 3 9 7 2 Domain: x 1 2 3 4 5 6 7 8 9

  17. Domain and propagation 1 2 3 5 8 9 4 7 2 3 7 2 3 5 9 7 2 1 8 1 5 5 8 6 1 9 3 9 7 2

  18. Domain and propagation 1 2 3 5 8 9 4 7 2 3 7 2 c 1 c 2 c 3 3 5 9 7 2 1 c 4 c 5 c 6 8 1 5 c 7 c 8 c 9 5 8 6 1 9 3 9 7 2 There exists x ∈ 1 ,..., 9 such that c x = 1. x 1 2 3 4 5 6 7 8 9

  19. Domain and propagation 1 2 3 5 8 9 4 7 2 3 7 2 c 1 c 2 c 3 3 5 5 9 9 7 7 2 2 1 1 c 4 c 5 c 6 8 1 5 c 7 c 8 c 9 5 8 6 1 9 3 9 7 2 There exists x ∈ 1 ,..., 9 such that c x = 1. x 1 2 3 4 5 6 7 8 9

  20. Domain and propagation 1 2 3 5 8 9 4 7 2 3 7 2 c 1 c 2 c 3 3 5 9 7 2 1 c 4 c 5 c 6 8 8 1 1 5 5 c 7 c 8 c 9 5 8 6 1 9 3 9 7 2 There exists x ∈ 1 ,..., 9 such that c x = 1. x 1 2 3 4 5 6 7 8 9

  21. Domain and propagation 1 2 3 3 5 8 9 4 7 2 3 7 2 1 c 1 c 2 c 3 3 5 5 9 7 2 1 c 4 c 5 c 6 8 1 5 c 7 c 8 c 9 5 8 6 1 1 9 3 9 7 2 There exists x ∈ 1 ,..., 9 such that c x = 1. x 1 2 3 4 5 6 7 8 9

  22. Domain and propagation 1 2 3 5 7 8 9 4 7 2 3 7 2 2 1 8 7 3 5 8 9 7 2 1 8 7 2 1 3 5 5 3 2 9 7 8 6 1 9 7 3 2 9 7 2

  23. Memory paradigm shift RAM model Values Addresses/ Variables ▸ Imperative paradigm: v x x assigns many, reads many v y y ▸ Functional paradigm: assigns once, reads many v z z v t t ⋮

  24. Memory paradigm shift RAM model Constraint memory model (Partial information) Values Addresses/ There exist x , y , z , t . . . such that Variables v x x v y y v z z v t t increasing ⋮ knowledge

  25. Memory paradigm shift RAM model Constraint memory model (Partial information) Values Addresses/ There exist x , y , z , t . . . such that Variables x ∈ { 1 ,..., 15 } v x x v y y v z z v t t increasing ⋮ knowledge

  26. Memory paradigm shift RAM model Constraint memory model (Partial information) Values Addresses/ There exist x , y , z , t . . . such that Variables x ∈ { 1 ,..., 15 } and v x x y ∈ { 5 ,..., 50 } v y y v z z v t t increasing ⋮ knowledge

  27. Memory paradigm shift RAM model Constraint memory model (Partial information) Values Addresses/ There exist x , y , z , t . . . such that Variables x ∈ { 1 ,..., 15 } and v x x y ∈ { 5 ,..., 50 } and v y y y ⩽ x v z z v t t increasing ⋮ knowledge

  28. Memory paradigm shift RAM model Constraint memory model (Partial information) Values Addresses/ There exist x , y , z , t . . . such that Variables x ∈ { 1 / 5 ,..., 15 } and v x x y ∈ { 5 ,..., 50 } and v y y y ⩽ x v z z v t t increasing ⋮ knowledge

  29. Memory paradigm shift RAM model Constraint memory model (Partial information) Values Addresses/ There exist x , y , z , t . . . such that Variables x ∈ { 1 / 5 ,..., 15 } and v x x y ∈ { 5 ,..., 50 � 15 } and v y y y ⩽ x v z z v t t increasing ⋮ knowledge

  30. Memory paradigm shift RAM model Constraint memory model (Partial information) Values Addresses/ There exist x , y , z , t . . . such that Variables x ∈ { 1 / 5 ,..., 15 } and v x x y ∈ { 5 ,..., 50 � 15 } and v y y y ⩽ x and z ∈ Q ∩ [ 5 , 9 ] v z z and more... v t t increasing ⋮ knowledge

  31. Propagation power y 1 2 3 x 5 7 8 9 4 7 2 3 7 z 2 2 1 8 7 3 5 8 9 7 2 1 8 7 2 1 3 5 5 3 2 9 7 8 6 1 9 7 3 2 9 7 2 x 1 2 3 4 5 6 7 8 9 y 1 2 3 4 5 6 7 8 9 z 1 2 3 4 5 6 7 8 9

  32. Propagation power y 1 2 3 x 5 7 8 9 4 7 2 3 7 z 2 2 1 8 7 3 5 8 9 7 2 1 8 7 2 1 3 5 5 3 2 9 7 8 6 1 9 7 3 2 9 7 2 x 1 2 3 4 5 6 7 8 9 y 1 2 3 4 5 6 7 8 9 z 1 2 3 4 5 6 7 8 9

  33. Propagation power 1 2 3 4 5 6 7 8 9 4 5 6 7 8 9 1 2 3 7 8 9 1 2 3 4 5 6 2 1 4 3 6 5 8 9 7 3 6 5 8 9 7 2 1 4 8 9 7 2 1 4 3 6 5 5 3 2 6 4 1 9 7 8 6 4 1 9 7 8 5 3 2 9 7 8 5 3 2 6 4 1

  34. Flow-network algorithm 1 x 1 v 1 1 1 1 1 1 x 2 v 2 1 1 1 1 ⋮ ⋮ source target 1 1 1 1 ⋮ ⋮ 1 x n v n Residual network of Ford-Fulkerson: reduced domain

  35. Concurrent programming framework Constraint Model Variable domains Dedicated Propagators acting concurrently Symbolic Constraints Scheduling Constraints (Graph theory) (Formal Language theory) Placement Constraints (Discrete Geometry theory)

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

  37. Propagation and search propagation X ( 1 , 1 ) = ? 1 3 5 propagation X ( 1 , 2 ) = ? Andorra Principle Do the deterministic bits first.

  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

  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

  40. What is a proof for a conjunction? ⋮ ⋮ A B A ∧ B

  41. What is a proof for a disjunction? ⋮ ⋮ A B A ∨ B A ∨ B A ∨ B A B

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend