Linear Logic Programming Carsten Sch urmann ITU, currently CMU - - PowerPoint PPT Presentation

linear logic programming
SMART_READER_LITE
LIVE PREVIEW

Linear Logic Programming Carsten Sch urmann ITU, currently CMU - - PowerPoint PPT Presentation

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic Linear Logic Programming Carsten Sch urmann ITU, currently CMU May 4, 2011 Carsten Sch urmann ITU, currently CMU Linear Logic Programming Intuitionistic Logic Linear


slide-1
SLIDE 1

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Linear Logic Programming

Carsten Sch¨ urmann ITU, currently CMU May 4, 2011

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-2
SLIDE 2

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Block’s World. SHRDLU [Winograd ’70]

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-3
SLIDE 3

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Block’s world continued

Person: PICK UP A BIG RED BLOCK. Computer: OK. (does it) Person: GRASP THE PYRAMID. Computer: I DON’T UNDERSTAND WHICH PYRAMID YOU MEAN. Person: FIND A BLOCK WHICH IS TALLER THAN THE ONE YOU ARE HOLDING AND PUT IT INTO THE BOX. Computer: BY "IT", I ASSUME YOU MEAN THE BLOCK WHICH IS TALLER THAN THE ONE I AM HOLDING. Computer: OK. (does it) Person: WHAT DOES THE BOX CONTAIN? Computer: THE BLUE PYRAMID AND THE BLUE BLOCK.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-4
SLIDE 4

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Krukals’ Algorithm

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-5
SLIDE 5

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Krukals’ Algorithm

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-6
SLIDE 6

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Krukals’ Algorithm

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-7
SLIDE 7

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Krukals’ Algorithm

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-8
SLIDE 8

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Krukals’ Algorithm

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-9
SLIDE 9

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Krukals’ Algorithm

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-10
SLIDE 10

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Krukals’ Algorithm

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-11
SLIDE 11

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Kerberos Authentication

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-12
SLIDE 12

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Single Transferable Vote [Kiniry et al 07]

/** * Distribute the surplus votes. * * @param candidateWithSurplus the candidate whose surplus is to be distributed. * @design The highest surplus must be distributed if the total surplus could * save the deposit of a candidate or change the relative position of * the two lowest continuing candidates, or would be enough to elect the * highest continuing candidate. * @see requirements 14-18, section 5, item 2, page 18 * @see requirement 8, section 4, item 2, page 15 */ /*@ requires getSurplus(candidateWithSurplus) > 0; @ requires state == COUNTING; @ requires numberOfContinuingCandidates > remainingSeats; @ requires (numberOfContinuingCandidates > remainingSeats + 1) || @ (sumOfSurpluses + lowestContinuingVote > nextHighestVote) || @ (numberOfEqualLowestContinuing > 1); @ requires remainingSeats > 0; @ requires (remainingSeats > 1) || @ ((highestContinuingVote < @ sumOfOtherContinuingVotes + sumOfSurpluses) && @ (numberOfEqualHighestContinuing == 1)); @ requires getSurplus (candidateWithSurplus) == highestSurplus; @ requires (sumOfSurpluses + highestContinuingVote >= quota) || @ (sumOfSurpluses + lowestContinuingVote > nextHighestVote) || @ (numberOfEqualLowestContinuing > 1) || @ ((sumOfSurpluses + lowestContinuingVote >= depositSavingThreshold) && @ (lowestContinuingVote < depositSavingThreshold)); @ ensures getSurplus (candidateWithSurplus) == 0; @*/ /** @see requirement 9, section 4, item 3, page 16 */ /*@ ensures countNumber == \old (countNumber) + 1; @ ensures (state == COUNTING) || (state == FINISHED); @*/ /** @see requirement 2, section 3, item 3, page 12 */ /*@ @ ensures totalVotes == nonTransferableVotes + @ (\sum int i; 0 <= i && i < totalCandidates; @ candidateList[i].getTotalVote());

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-13
SLIDE 13

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Summary

What do all of these examples have in common?

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-14
SLIDE 14

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Summary

What do all of these examples have in common?

◮ Graph-structured ◮ Algorithmic ◮ Consume and generate resources

Assume you ought to implement these things. What do you do?

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-15
SLIDE 15

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Summary

What do all of these examples have in common?

◮ Graph-structured ◮ Algorithmic ◮ Consume and generate resources

Assume you ought to implement these things. What do you do?

◮ Object-oriented programming langauge, such as Java, C# ◮ Imperative programming language, such as C, C++ ◮ Functional programming language, such as SML, Haskell,

OCaml

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-16
SLIDE 16

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Summary

What do all of these examples have in common?

◮ Graph-structured ◮ Algorithmic ◮ Consume and generate resources

Assume you ought to implement these things. What do you do?

◮ Object-oriented programming langauge, such as Java, C# ◮ Imperative programming language, such as C, C++ ◮ Functional programming language, such as SML, Haskell,

OCaml This week, we use Celf, based on (intuitionistic) linear logic.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-17
SLIDE 17

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Objectives

◮ Intuitionistic Linear/Affine Logic ◮ Backward Chaining Proof Search

◮ Programming with Logic ◮ Recursion principles for programming, e.g. SML, Prolog ◮ Inductive datatypes

◮ Forward Chaining Proof Search

◮ True concurrency ◮ Actor like programming, i.e. Erlang, CHR ◮ “new kind of datatype”, for example, for graphs

◮ Be able to program in Celf, e.g. Kruskal’s algorithm

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-18
SLIDE 18

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Outline

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-19
SLIDE 19

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Let’s get started. http://www.smlserver.org/celf/

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-20
SLIDE 20

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

About Celf

◮ Written in SML/NJ ◮ Compiled with Smltojs to JavaScript ◮ Runs locally in your webbrowser. ◮ Right now cut-and-paste. ◮ Install your local version from

http://www.twelf.org/celf

◮ Run celf <filename> ◮ Thanks to Dr. Anders Schack-Nielsen

[IJCAR’08]

◮ Thanks to Martin Elsman

[ML’10]

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-21
SLIDE 21

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Functions vs. Relations

◮ Usually we think of program as functions ◮ Clearly specified input/output behavior

plus x y = y if x = 0 s (plus x′ y) if x = s x′

◮ In logic programming we use judgments (propositions)

plus X Y Z read as “X plus Y is Z” and rules. p z plus z Y Y plus X Y Z p s plus (s X) Y (s Z)

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-22
SLIDE 22

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Running plus: Step 0

D : plus (s (s z)) (s z) V

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-23
SLIDE 23

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Running plus: Step 1

p s D : plus (s (s z)) (s z) (s V ) D : plus (s z) (s z) V

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-24
SLIDE 24

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Running plus: Step 2

p s (p s D) : plus (s (s z)) (s z) (s (s V )) p s D : plus (s z) (s z) (s V ) D : plus z (s z) V

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-25
SLIDE 25

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Running plus: Step 3

p s (p s p z) : plus (s (s z)) (s z) (s (s (s z))) p s p z : plus (s z) (s z) (s (s z)) p z : plus z (s z) (s z)

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-26
SLIDE 26

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Running plus

p s (p s p z) : plus (s (s z)) (s z) (s (s (s z))) p s p z : plus (s z) (s z) (s (s z)) p z : plus z (s z) (s z) Adequately, more logically: p z plus z (s z) (s z) p s plus (s z) (s z) (s (s z)) p s plus (s (s z)) (s z) (s (s (s z)))

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-27
SLIDE 27

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Running a Logic Program

#query * 1 * 1 plus (s (s z)) (s z) X.

◮ What do the numbers mean? ◮ Help!

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-28
SLIDE 28

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Running a Logic Program

#query * 1 * 1 plus (s (s z)) (s z) X.

◮ What do the numbers mean? ◮ Help!

#query d e l a ty. d : bound on number of let-bindings before aborting forward-chaining, * means no bound e : expected number of solutions, * means don’t know l : number of solutions to look for, * means infinite a : number of times to execute the query ty : type to search for proof of

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-29
SLIDE 29

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Exercise 1:

Declare lists in Celf as follows list : type. nil : list. cons : nat -> list -> list.

  • 1. Write a program that appends two lists.

append: list -> list -> list -> type.

  • 2. Write a program that reverses a list.

rev: list -> list -> type.

  • 3. Write a program that sums up all elements of a list.

sum : list -> nat -> type.

  • 4. Compute the n-th Fibonacci numbers

fib : nat -> nat -> type.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-30
SLIDE 30

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Formalities:

plus : nat -> nat -> nat -> type. p z : plus z Y Y. p s : plus X Y Z -> plus (s X) Y (s Z).

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-31
SLIDE 31

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Formalities:

plus : nat -> nat -> nat -> type. p z : plus z Y Y. p s : plus X Y Z -> plus (s X) Y (s Z). Definite Clauses D ::= P | G → D | ∀x : A.D Goals G ::= P Atoms P ::= a M1 . . . Mn Programs Σ ::= · | Σ, a : K | Σ, c : D

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-32
SLIDE 32

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Objects, Proofs, and Substitution

Objects Think about them as natural numbers, trees.

◮ nat, list are datatypes ◮ z, s, nil, cons are constructors.

Proofs They look like objects, because they are. Lookup We write Σ(c) = D to lookup the type, axiom, formula associated with the name of a constructor. Substitutions We write [T/x]T ′ for the in place substitution of object T for variable x in term T ′.

◮ Substitutions are capture avoiding. ◮ Tacit renaming of variables.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-33
SLIDE 33

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Backward-Chaining (Focused) Proof Search

Goal formulas Σ ⊢ G bwd G is derivable form Σ by backward chaining search. Definite clauses Σ; [D] ⊢ P bwd P is derivable from Σ by focusing/decomposing D. Disclaimer: We describe rules that guess instantiation of universal

  • variables. A real implementation would use unification to compute

them.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-34
SLIDE 34

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Backward-Chaining (Focused) Proof Search

Σ ⊢ G bwd Σ(c) = D Σ; [D] ⊢ P bwd g/atm Σ ⊢ P bwd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Σ[D] ⊢ P bwd Σ; [[T/x]D] ⊢ P bwd d/all Σ; [∀x : A.D] ⊢ P bwd Σ; [D] ⊢ P bwd Σ ⊢ G bwd d/arr Σ; [G → D] ⊢ P bwd d/atm Σ; [P] ⊢ P bwd

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-35
SLIDE 35

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Higher-Order Logic Programming

Ideas similar to what you can find in λ-Prolog. So far, the Σ is given ahead of time. Now, we extend our language to extend Σ dynamically

◮ Extension 1: Goals can introduce clauses D → G ◮ Extension 2: Goals can declare new parameters ∀x : A.G

We will write Γ for the dynamically introduced signature (called contexts), and Σ for the static signatures (continued to be called programs). Refine judgment and rules to Σ; Γ ⊢ D bwd Σ; Γ; [D] ⊢ P bwd

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-36
SLIDE 36

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Higher-order Logic Programming

plus : nat -> nat -> nat -> type. #query * 1 * 1 plus z Y Y -> (plus X Y Z -> plus (s X) Y (s Z)) -> plus (s (s z)) (s z) V

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-37
SLIDE 37

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Higher-order Logic Programming

plus : nat -> nat -> nat -> type. #query * 1 * 1 plus z Y Y -> (plus X Y Z -> plus (s X) Y (s Z)) -> plus (s (s z)) (s z) V Definite Clauses D ::= P | G → D | ∀x : A.D Goals G ::= P | D → G | ∀x : A.G Atoms P ::= a M1 . . . Mn Programs Σ ::= · | Σ, a : K | Σ, c : D Contexts Γ ::= Γ, x : A | Γ, c : D

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-38
SLIDE 38

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Higher-order Backward-Chaining (Focused) Proof Search

Σ; Γ ⊢ G bwd Σ; Γ; [D] ⊢ P bwd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . (Σ; Γ)(c) = D Σ; Γ; [D] ⊢ P bwd Σ; Γ ⊢ P bwd Σ; Γ; [P] ⊢ P bwd Σ; Γ, x : A ⊢ G bwd Σ; Γ ⊢ ∀x : A.G bwd Σ; Γ; [[T/x]D] ⊢ P bwd Σ; Γ; [∀x : A.D] ⊢ P bwd Σ; Γ, D ⊢ G bwd Σ; Γ ⊢ D → G bwd Σ; Γ; [D] ⊢ P bwd Σ; Γ ⊢ G bwd Σ; Γ; [G → D] ⊢ P bwd

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-39
SLIDE 39

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Inversion and Focusing [Andreoli ’91]

Motivation A rule can be invertible: J1 J2 rule J iff

  • 1. if J implies J1
  • 2. and J implies J2.

Focusing No backtrack over sequences of invertible rules Thus Focusing removes derivations from the search space!

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-40
SLIDE 40

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Foreshadowing

Right inversion Σ; Γ ⊢ G bwd Left focusing Σ; Γ; [D] ⊢ P bwd Asynchronous connective A connective is asynchronous, if it has a right inversion and a left-focusing rule. Synchronous connective A connective is synchronous, if it does not have a right inversion rule, one needs to work on the hypotheses first. Choice is non-deterministic.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-41
SLIDE 41

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Exercises 2

In these exercises you are asked to explore the higher-order features

  • f Celf. The means that you are allowed to declare new predicates,

but you are not allowed to define constructors for them.

  • 1. Write a program that returns if a given numbers occurs at

least twice in a given list. twice: list -> nat -> type.

  • 2. Generalize the previous program and write one that checks for

n duplicates. duplicates: list -> nat -> nat -> type. The last argument stands for the multiplicity.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-42
SLIDE 42

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Philosphical Considerations

◮ Judgments-as-relations-as-types ◮ Derivations-as-objects ◮ Dynamic generation of clauses

◮ Weakening: We don’t have to use them ◮ Contraction: We may use them more than once ◮ Exchange: We may use them irrespective of order

◮ But life is not that simple

◮ Consider money ◮ Consider locations in a Petri net ◮ Consider authorization certificates ◮ Consider ballots in an election

◮ We want resources!

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-43
SLIDE 43

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Meet the Connectives

Example: You want to spend one dollar, three quarters, two dimes and one nickel on a sandwich that costs two

  • dollars. Can you do it?

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-44
SLIDE 44

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Meet the Connectives

Example: You want to spend one dollar, three quarters, two dimes and one nickel on a sandwich that costs two

  • dollars. Can you do it?

Rules: n n m1 d n d d m2 q q q q q m3 $ $ r1 coke $ $ r2 sandwich To show: u $ v1 q v2 q v3 q w1 d w2 d z n . . . sandwich

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-45
SLIDE 45

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Meet the Connectives

Rules: n n m1 d n d d m2 q q q q q m3 $ $ r1 coke $ $ r2 sandwich To show: u $ v1 q v2 q v3 q w1 d w2 d z n m2 q . . . sandwich

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-46
SLIDE 46

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Meet the Connectives

Rules: n n m1 d n d d m2 q q q q q m3 $ $ r1 coke $ $ r2 sandwich To show: u $ v1 q v2 q v3 q w1 d w2 d z n m2 q m3 $ . . . sandwich

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-47
SLIDE 47

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Meet the Connectives

Rules: n n m1 d n d d m2 q q q q q m3 $ $ r1 coke $ $ r2 sandwich To show: u $ v1 q v2 q v3 q w1 d w2 d z n m2 q m3 $ r2 sandwich

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-48
SLIDE 48

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Linear Logic and Resources

◮ A ⊸ B is true if we can prove B while consuming the

resource A exactly once.

◮ A ⊗ B is true if we split our supply of linear resources into two

piles, prove A with one and B with the other.

◮ 1 is the unit for ⊗ ◮ A&B is true, if either A and B are true (independently) using

all resources

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-49
SLIDE 49

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Γ; ∆ ⊢ A Propositional Dual Intuitionistic Linear Logic

Γ; ∆, A ⊢ B ⊸ I Γ; ∆ ⊢ A ⊸ B Γ; ∆1 ⊢ A ⊸ B Γ; ∆2 ⊢ A ⊸ E Γ; ∆1, ∆2 ⊢ B

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-50
SLIDE 50

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Γ; ∆ ⊢ A Propositional Dual Intuitionistic Linear Logic

Γ; ∆, A ⊢ B ⊸ I Γ; ∆ ⊢ A ⊸ B Γ; ∆1 ⊢ A ⊸ B Γ; ∆2 ⊢ A ⊸ E Γ; ∆1, ∆2 ⊢ B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Γ; ∆1 ⊢ A Γ; ∆2 ⊢ B ⊗I Γ; ∆1, ∆2 ⊢ A ⊗ B Γ; ∆1 ⊢ A ⊗ B Γ; ∆2, A, B ⊢ C ⊗E Γ; ∆1, ∆2 ⊢ C

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-51
SLIDE 51

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Γ; ∆ ⊢ A Propositional Dual Intuitionistic Linear Logic

Γ; ∆, A ⊢ B ⊸ I Γ; ∆ ⊢ A ⊸ B Γ; ∆1 ⊢ A ⊸ B Γ; ∆2 ⊢ A ⊸ E Γ; ∆1, ∆2 ⊢ B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Γ; ∆1 ⊢ A Γ; ∆2 ⊢ B ⊗I Γ; ∆1, ∆2 ⊢ A ⊗ B Γ; ∆1 ⊢ A ⊗ B Γ; ∆2, A, B ⊢ C ⊗E Γ; ∆1, ∆2 ⊢ C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1I Γ; · ⊢ 1 Γ; ∆1 ⊢ 1 Γ; ∆2 ⊢ C 1E Γ; ∆1, ∆2 ⊢ C

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-52
SLIDE 52

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Γ; ∆ ⊢ A Propositional Dual Intuitionistic Linear Logic

Γ; ∆, A ⊢ B ⊸ I Γ; ∆ ⊢ A ⊸ B Γ; ∆1 ⊢ A ⊸ B Γ; ∆2 ⊢ A ⊸ E Γ; ∆1, ∆2 ⊢ B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Γ; ∆1 ⊢ A Γ; ∆2 ⊢ B ⊗I Γ; ∆1, ∆2 ⊢ A ⊗ B Γ; ∆1 ⊢ A ⊗ B Γ; ∆2, A, B ⊢ C ⊗E Γ; ∆1, ∆2 ⊢ C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1I Γ; · ⊢ 1 Γ; ∆1 ⊢ 1 Γ; ∆2 ⊢ C 1E Γ; ∆1, ∆2 ⊢ C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Γ; ∆ ⊢ A Γ; ∆ ⊢ B &I Γ; ∆ ⊢ A&B Γ; ∆ ⊢ A&B &E1 Γ; ∆ ⊢ A Γ; ∆ ⊢ A&B &E2 Γ; ∆ ⊢ B

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-53
SLIDE 53

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Linear Higher-order Logic Programming

◮ Asynchronous connectives (negative) A

◮ Synchronous connectives (positive) A

+

◮ Collapse definite clauses and goals into one category A

G → D = Πx : !G.D G ⊸ D = Πx : ↓ G.D A

::= P | Πp : A

+.A − | A −

1 &A

2

A

+

::= !A

− | ↓ A − | 1

P ::= a M1 . . . Mn Σ ::= · | Σ, a : K | Σ, c : A

Γ, ∆ ::= · | Γ, x : A

− Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-54
SLIDE 54

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Proof Search Focusing Style

Γ; ∆ ⊢ A

Γ; ∆; [A

−] ⊢ P

(Σ; Γ)(c) = A

Γ; ∆; [A

−] ⊢ P

Γ; ∆ ⊢ P Γ; ∆; [P] ⊢ P Γ; ∆; [A

−] ⊢ P

Γ; ∆, A

− ⊢ P Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-55
SLIDE 55

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Proof Search Focusing Style

Γ; ∆ ⊢ A

Γ; ∆; [A

−] ⊢ P

(Σ; Γ)(c) = A

Γ; ∆; [A

−] ⊢ P

Γ; ∆ ⊢ P Γ; ∆; [P] ⊢ P Γ; ∆; [A

−] ⊢ P

Γ; ∆, A

− ⊢ P

Γ; ∆ ⊢ A

1

Γ; ∆ ⊢ A

2

Γ; ∆ ⊢ A

1 &A

2

Γ; ∆; [A

i ] ⊢ P

i = 1, 2 Γ; ∆; [A

1 &A

2 ] ⊢ P

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-56
SLIDE 56

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Proof Search Focusing Style

Γ; ∆ ⊢ A

Γ; ∆; [A

−] ⊢ P

(Σ; Γ)(c) = A

Γ; ∆; [A

−] ⊢ P

Γ; ∆ ⊢ P Γ; ∆; [P] ⊢ P Γ; ∆; [A

−] ⊢ P

Γ; ∆, A

− ⊢ P

Γ; ∆ ⊢ A

1

Γ; ∆ ⊢ A

2

Γ; ∆ ⊢ A

1 &A

2

Γ; ∆; [A

i ] ⊢ P

i = 1, 2 Γ; ∆; [A

1 &A

2 ] ⊢ P

p : A

+ → Γ; ∆ ⊢ A −

Γ; ∆ ⊢ Πp : A

+.A −

p : A

+ → Γ; ∆; [A −] ⊢ P

Γ; ∆; [Πp : A

+.A −] ⊢ P Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-57
SLIDE 57

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

p : A

+ → Γ; ∆ ⊢ B −

p : A

+ → Γ; ∆; [D] ⊢ P

Γ, x : A

−; ∆ ⊢ B −

x : !A

− → Γ; ∆ ⊢ B −

Γ; ∆; [[T/x]A

2 ] ⊢ P

x occurs in A

2

x : !A

1 → Γ; ∆; [A

2 ] ⊢ P

Γ; ∆; [A

2 ] ⊢ P

Γ; · ⊢ A

1

x does not

  • ccur in A

2

x : !A

1 → Γ; ∆; [A

2 ] ⊢ P

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-58
SLIDE 58

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

p : A

+ → Γ; ∆ ⊢ B −

p : A

+ → Γ; ∆; [D] ⊢ P

Γ, x : A

−; ∆ ⊢ B −

x : !A

− → Γ; ∆ ⊢ B −

Γ; ∆; [[T/x]A

2 ] ⊢ P

x occurs in A

2

x : !A

1 → Γ; ∆; [A

2 ] ⊢ P

Γ; ∆; [A

2 ] ⊢ P

Γ; · ⊢ A

1

x does not

  • ccur in A

2

x : !A

1 → Γ; ∆; [A

2 ] ⊢ P

Γ; ∆, x : A

− ⊢ B −

x : ↓ A

− → Γ; ∆ ⊢ B −

Γ; ∆1; [A

2 ] ⊢ P

Γ; ∆2 ⊢ A

1

x : ↓ A

1 → Γ; ∆1, ∆2; [A

2 ] ⊢ P

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-59
SLIDE 59

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

p : A

+ → Γ; ∆ ⊢ B −

p : A

+ → Γ; ∆; [D] ⊢ P

Γ, x : A

−; ∆ ⊢ B −

x : !A

− → Γ; ∆ ⊢ B −

Γ; ∆; [[T/x]A

2 ] ⊢ P

x occurs in A

2

x : !A

1 → Γ; ∆; [A

2 ] ⊢ P

Γ; ∆; [A

2 ] ⊢ P

Γ; · ⊢ A

1

x does not

  • ccur in A

2

x : !A

1 → Γ; ∆; [A

2 ] ⊢ P

Γ; ∆, x : A

− ⊢ B −

x : ↓ A

− → Γ; ∆ ⊢ B −

Γ; ∆1; [A

2 ] ⊢ P

Γ; ∆2 ⊢ A

1

x : ↓ A

1 → Γ; ∆1, ∆2; [A

2 ] ⊢ P

Γ; ∆ ⊢ B

x : 1 → Γ; ∆ ⊢ B

Γ; ∆; [A

−] ⊢ P

x : 1 → Γ; ∆; [A

−] ⊢ P Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-60
SLIDE 60

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Buy a Sandwich with Change

Signature Σ = m1 : n ⊸ n ⊸ d m2 : n ⊸ d ⊸ d ⊸ q m3 : q ⊸ q ⊸ q ⊸ q ⊸ $ r1 : $ ⊸ coke r2 : $ ⊗ $ ⊸ sandwich . . . · ⊢ $ ⊗ q ⊗ q ⊗ q ⊗ d ⊗ d ⊗ n ⊸ sandwich

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-61
SLIDE 61

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Now in Celf

dollar : type. quarter : type. dime : type. nickel : type. cent : type. coke : type. sandwich : type. nn->d : nickel -o nickel -o dime. ndd->q : nickel -o dime -o dime -o quarter. qqqq->$ : quarter -o quarter -o quarter -o quarter

  • o dollar.

$->coke : dollar -o coke. $$->sandw: dollar -o dollar -o sandwich.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-62
SLIDE 62

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Now in Celf

Running a query: #query * ? * 1 dollar -o quarter -o quarter -o quarter -o nickel -o dime -o dime -o dollar -o sandwich.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-63
SLIDE 63

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Now in Celf

Running a query: #query * ? * 1 dollar -o quarter -o quarter -o quarter -o nickel -o dime -o dime -o dollar -o sandwich. Problem 1: ? = 96 $$->sandw X7 (qqqq->$ X3 X1 X2 (ndd->q X4 X5 X6)) $$->sandw X7 (qqqq->$ X1 X3 X2 (ndd->q X4 X5 X6)) $$->sandw X7 (qqqq->$ X2 X3 X1 (ndd->q X4 X5 X6)) $$->Sandw X7 (qqqq->$ X3 X2 X1 (ndd->q X4 X5 X6)) etc. Problem 2: Adequacy?

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-64
SLIDE 64

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

A Mystery Program

el : nat -> type. mystery : list -> type. mystery/nil : mystery nil. mystery/cons : mystery (cons N L)

  • - el N
  • - mystery L.

What could this program do?

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-65
SLIDE 65

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

A Mystery Program

el : nat -> type. mystery : list -> type. mystery/nil : mystery nil. mystery/cons : mystery (cons N L)

  • - el N
  • - mystery L.

What could this program do? Compute permutations! #query * ? * 1 el z -o el (s z) -o mystery L. #query * ? * 1 el z -o el (s z) -o el (s (s z))

  • o mystery L.

#query * ? * 1 el z -o el N

  • o mystery (cons z (cons (s z) nil)).

#query * ? * 1 el N -o el z

  • o mystery (cons z (cons (s z) nil)).

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-66
SLIDE 66

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Affine Logic

So far, exact change was necessary to buy a sandwich.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-67
SLIDE 67

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Affine Logic

So far, exact change was necessary to buy a sandwich. How can we express that we can buy a sandwhich, but still have some money leftover?

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-68
SLIDE 68

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Affine Logic

So far, exact change was necessary to buy a sandwich. How can we express that we can buy a sandwhich, but still have some money leftover? Linear Logic must use resources exactly once Affine Logic may use resources at most once Relevance Logic must use all resources at least once

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-69
SLIDE 69

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Now in Celf

nn->d : nickel -@ nickel -@ dime. ndd->q : nickel -@ dime -@ dime -@ quarter. qqqq->$ : quarter -@ quarter -@ quarter -@ quarter

  • @ dollar.

$->coke : dollar -@ coke. $$->sandw: dollar -@ dollar -@ sandwich. #query * 96 * 1 quarter -@ quarter -@ quarter -@ nickel -@ dime -@ dime -@ dollar -@ sandwich. #query * 96 * 1 cent -@ quarter -@ quarter -@ quarter -@ nickel -@ dime -@ dime -@ dollar -@ sandwich.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-70
SLIDE 70

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Affine Logic

Linear Logic must use resources exactly once Affine Logic may use resources at most once Judgment Γ; ∆; Φ ⊢ A Γ unrestricted, ∆ linear, Φ affine axu Γ, A; ·; Φ ⊢ A axl Γ; A; Φ ⊢ A axa Γ; ·; Φ, A ⊢ A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Γ; ∆; Φ, A ⊢ B − @ I Γ; ∆; Φ ⊢ A − @ B Γ; ∆1; Φ1 ⊢ A − @ B Γ; ∆2; Φ2 ⊢ A − @ E Γ; ∆1, ∆2; Φ1; Φ2 ⊢ B

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-71
SLIDE 71

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Affine Linear Higher-order Logic Programming

◮ Asynchronous connectives (negative) A

◮ Synchronous connectives (positive) A

+

◮ Extending what we had.

A

::= P | Πp : A

+.A − | A −

1 &A

2

A

+

::= !A

− | ↓ A − | @A −

P ::= a M1 . . . Mn Σ ::= · | Σ, a : K | Σ, c : A

Γ, ∆ ::= · | Γ, x : A

− Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-72
SLIDE 72

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Proof Search Focusing Style

Γ; ∆; Φ ⊢ A

Γ; ∆; Φ; [A

−] ⊢ P

(Σ; Γ)(c) = A

Γ; ∆; Φ; [A

−] ⊢ P

Γ; ∆; Φ ⊢ P Γ; ∆; Φ; [P] ⊢ P Γ; ∆; Φ; [A

−] ⊢ P

Γ; ∆; Φ, A

− ⊢ P

Γ; ∆; Φ; [A

−] ⊢ P

Γ; ∆; Φ, A

− ⊢ P

Γ; ∆; Φ ⊢ A

1

Γ; ∆; Φ ⊢ A

2

Γ; ∆; Φ ⊢ A

1 &A

2

Γ; ∆; Φ; [A

i ] ⊢ P

i = 1, 2 Γ; ∆; Φ; [A

1 &A

2 ] ⊢ P

p : A

+ → Γ; ∆; Φ ⊢ A −

Γ; ∆; Φ ⊢ Πp : A

+.A −

p : A

+ → Γ; ∆; Φ; [A −] ⊢ P

Γ; ∆; Φ; [Πp : A

+.A −] ⊢ P Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-73
SLIDE 73

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

p : A

+ → Γ; ∆; Φ ⊢ B −

p : A

+ → Γ; ∆; [D] ⊢ P

Γ, x : A

−; ∆; Φ ⊢ B −

x : !A

− → Γ; ∆; Φ ⊢ B −

Γ; ∆; Φ; [[T/x]A

2 ] ⊢ P

x occurs in A

2

x : !A

1 → Γ; ∆; Φ; [A

2 ] ⊢ P

Γ; ∆; Φ; [A

2 ] ⊢ P

Γ; ·; · ⊢ A

1

x does not

  • ccur in A

2

x : !A

1 → Γ; ∆; Φ; [A

2 ] ⊢ P

Γ; ∆; Φ, x : A

− ⊢ B −

x : ↓ A

− → Γ; ∆; Φ ⊢ B −

Γ; ∆1; Φ1; [A

2 ] ⊢ P

Γ; ∆2; Φ2 ⊢ A

1

x : ↓ A

1 → Γ; ∆1, ∆2; Φ1; Φ2; [A

2 ] ⊢ P

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-74
SLIDE 74

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

p : A

+ → Γ; ∆; Φ ⊢ B −

p : A

+ → Γ; ∆; [D] ⊢ P

Γ, x : A

−; ∆; Φ ⊢ B −

x : !A

− → Γ; ∆; Φ ⊢ B −

Γ; ∆; Φ; [[T/x]A

2 ] ⊢ P

x occurs in A

2

x : !A

1 → Γ; ∆; Φ; [A

2 ] ⊢ P

Γ; ∆; Φ; [A

2 ] ⊢ P

Γ; ·; · ⊢ A

1

x does not

  • ccur in A

2

x : !A

1 → Γ; ∆; Φ; [A

2 ] ⊢ P

Γ; ∆; Φ, x : A

− ⊢ B −

x : ↓ A

− → Γ; ∆; Φ ⊢ B −

Γ; ∆1; Φ1; [A

2 ] ⊢ P

Γ; ∆2; Φ2 ⊢ A

1

x : ↓ A

1 → Γ; ∆1, ∆2; Φ1; Φ2; [A

2 ] ⊢ P

Γ; ∆; Φ, x : A

− ⊢ B −

x : @A

− → Γ; ∆; Φ ⊢ B −

Γ; ∆1; Φ1; [A

2 ] ⊢ P

Γ; ∆2; Φ2 ⊢ A

1

x : @A

1 → Γ; ∆1, ∆2; Φ1, Φ2; [A

2 ] ⊢ P

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-75
SLIDE 75

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Example: Subsets

element : nat -> type. sublist : list -> type. sublist/nil : sublist nil. sublist/cons : sublist (cons N L) @- element N @- sublist L. Question: How many solutions will Celf compute? #query * * * 1 element z -@ element (s z) -@ element (s (s z)) -@ sublist L.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-76
SLIDE 76

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Example: Subsets

element : nat -> type. sublist : list -> type. sublist/nil : sublist nil. sublist/cons : sublist (cons N L) @- element N @- sublist L. Question: How many solutions will Celf compute? #query * * * 1 element z -@ element (s z) -@ element (s (s z)) -@ sublist L. Answer: 16.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-77
SLIDE 77

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Structural Operational Semantics

Definition Register R ::= r0 | r1 | r2 Instruction I ::= return R | add R1 R2 I | const N R I Example Compute the circumference of a rectangle.

a b

const a r1 const b r2 const z r3 add r2 r3 add r2 r3 add r1 r3 add r1 r3 return r3

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-78
SLIDE 78

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Exercises 3

  • 1. Extend the calculator by predecessor function

prec : register -> cmd -> cmd.

  • 2. Extend the calculator by a construct for swapping the content
  • f two registers:

swap : register -> register -> cmd -> cmd.

  • 3. Extend the calculator by a comparison operator that either

executes the first block of instructions if the content of the register is 0 or the second otherwise. eqz : register -> cmd -> cmd -> cmd.

  • 4. Implement a label to jump to operation.

label : (cmd -> cmd) -> cmd.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-79
SLIDE 79

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Concurrent Monadic Linear Logic

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-80
SLIDE 80

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Tuning the Operational Semantics

So far backward-chaining operational semantics only. Excels for single conclusion inference rules.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-81
SLIDE 81

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Tuning the Operational Semantics

So far backward-chaining operational semantics only. Excels for single conclusion inference rules. But how do you express that you would like to buy a coke and a sandwich? (exact change only)

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-82
SLIDE 82

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Tuning the Operational Semantics

So far backward-chaining operational semantics only. Excels for single conclusion inference rules. But how do you express that you would like to buy a coke and a sandwich? (exact change only) u1 $ u2 $ v1 q v2 q v3 q w1 d w2 d z n . . . sandwich . . . coke

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-83
SLIDE 83

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Tuning the Operational Semantics

So far backward-chaining operational semantics only. Excels for single conclusion inference rules. But how do you express that you would like to buy a coke and a sandwich? (exact change only) u1 $ u2 $ v1 q v2 q v3 q w1 d w2 d z n . . . sandwich . . . coke Idea: Maybe tensor is invertible?

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-84
SLIDE 84

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Non-Invertibility of Tensor

Recall Γ; ∆1; Φ1 ⊢ A Γ; ∆2; Φ2 ⊢ B ⊗I Γ; ∆1, ∆2; Φ1, Φ2 ⊢ A ⊗ B Assume Γ; ∆1, ∆2; Φ1, Φ2 ⊢ A ⊗ B To Show Γ; ∆1; Φ1 ⊢ A Using Γ; ∆1; Φ1 ⊢ A ⊗ B Γ; ∆2, A, B; Φ2 ⊢ C ⊗E Γ; ∆1, ∆2; Φ1, Φ2 ⊢ C But How? Tensor is not right-invertible. We have to think of something else.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-85
SLIDE 85

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Tensor as a synchronous (positive connective)

Solution: We introduce a new type of connective. ∃!x :!A

1 .A

+

2

= ∃x : A

1 .A

+

2

∃p : A

+

1 .A

+

2

= A

+

1 ⊗ A

+

2

Categories: A

::= P | Πp : A

+.A − | A −

1 &A

2

A

+

::= !A

− | ↓ A − | 1 | @A −| ∃p : A +

1 A

+

2

P ::= a M1 . . . Mn Σ ::= · | Σ, a : K | Σ, c : A

Γ, ∆ ::= · | Γ, x : A

− Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-86
SLIDE 86

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Handling Tensor

Generalization of the rules p : A

+ → Γ; ∆; Φ ⊢ B −

p1 : A

+

1 → p2 : A

+

2 → Γ; ∆; Φ ⊢ B

[p1, p2] : ∃p1 : A

+

1 .A

+

2 → Γ; ∆; Φ ⊢ B

p : A

+ → Γ; ∆; [B −] ⊢ P

p1 : A

+

1 → p2 : A

+

2 → Γ; ∆; Φ; [B

−] ⊢ P

[p1, p2] : ∃p : A

+

1 .A

+

2 → Γ; ∆; Φ; [B

−] ⊢ P Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-87
SLIDE 87

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

The question remains:

Example: You have three dollars. A can of coke costs one dollar, and a sandwich two. Can you buy both?

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-88
SLIDE 88

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

The question remains:

Example: You have three dollars. A can of coke costs one dollar, and a sandwich two. Can you buy both? Rules: $ r1 coke $ $ r2 sandwich To show: u $ v $ w $ . . . coke . . . sandwich

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-89
SLIDE 89

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

The question remains:

Example: You have three dollars. A can of coke costs one dollar, and a sandwich two. Can you buy both? Rules: $ r1 coke $ $ r2 sandwich To show: u $ v $ w $ . . . coke . . . sandwich Idea: Think left! (as we already did :-)

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-90
SLIDE 90

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Think Left

Example: You have three dollars. A can of coke costs one dollar, and a sandwich two. Can you buy both? Rules: $ r1 coke $ $ r2 sandwich To show: u $ v $ w $ r2 sandwich . . . coke . . . sandwich

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-91
SLIDE 91

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Think Left

Example: You have three dollars. A can of coke costs one dollar, and a sandwich two. Can you buy both? Rules: $ r1 coke $ $ r2 sandwich To show: u $ r1 coke v $ w $ r2 sandwich . . . coke . . . sandwich

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-92
SLIDE 92

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Now we are done!

u $ r1 coke v $ w $ r2 sandwich . . . coke . . . sandwich Quiesence We cannot do another step on the left. Truth We have derived what we needed to derive. Concurrency The rules could fire in an arbitrary order. Finally Switch back to right, find coke and sandwich.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-93
SLIDE 93

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Summary

Solution: We introduce a new type of connective. A

::= P | Πp : A

+.A − | A −

1 &A

2 | {A

+}

A

+

::= !A

− | ↓ A − | 1 | @A − | ∃p : A +

1 .A

+

2

P ::= a M1 . . . Mn Σ ::= · | Σ, a : K | Σ, c : A

Γ, ∆ ::= · | Γ, x : A

Comment 1: {A

+} switches to forward chaining mode. Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-94
SLIDE 94

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Summary

Solution: We introduce a new type of connective. A

::= P | Πp : A

+.A − | A −

1 &A

2 | {A

+}

A

+

::= !A

− | ↓ A − | 1 | @A − | ∃p : A +

1 .A

+

2

P ::= a M1 . . . Mn Σ ::= · | Σ, a : K | Σ, c : A

Γ, ∆ ::= · | Γ, x : A

Comment 1: {A

+} switches to forward chaining mode.

Comment 2: {A

+} is a monad that encapsulates true concurrency. Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-95
SLIDE 95

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Summary

Solution: We introduce a new type of connective. A

::= P | Πp : A

+.A − | A −

1 &A

2 | {A

+}

A

+

::= !A

− | ↓ A − | 1 | @A − | ∃p : A +

1 .A

+

2

P ::= a M1 . . . Mn Σ ::= · | Σ, a : K | Σ, c : A

Γ, ∆ ::= · | Γ, x : A

Comment 1: {A

+} switches to forward chaining mode.

Comment 2: {A

+} is a monad that encapsulates true concurrency.

Comment 3: {A

+} corresponds to the focusing rule switching from

negative to positive. It is dual to ↓ A

−. Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-96
SLIDE 96

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Summary

Solution: We introduce a new type of connective. A

::= P | Πp : A

+.A − | A −

1 &A

2 | {A

+}

A

+

::= !A

− | ↓ A − | 1 | @A − | ∃p : A +

1 .A

+

2

P ::= a M1 . . . Mn Σ ::= · | Σ, a : K | Σ, c : A

Γ, ∆ ::= · | Γ, x : A

Comment 1: {A

+} switches to forward chaining mode.

Comment 2: {A

+} is a monad that encapsulates true concurrency.

Comment 3: {A

+} corresponds to the focusing rule switching from

negative to positive. It is dual to ↓ A

−. Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-97
SLIDE 97

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Buy a Coke and a Sandwich with 3 Dollars

Signature Σ = r1 : $ ⊸ {coke} r2 : $ ⊗ $ ⊸ {sandwich} . . . · ⊢ $ ⊗ $ ⊗ $ ⊸ {coke ⊗ sandwich}

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-98
SLIDE 98

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Buy a Coke and a Sandwich with 3 Dollars

Signature Σ = r1 : $ ⊸ {coke} r2 : $ ⊗ $ ⊸ {sandwich} . . . u1 : $, u2 : $, u3 : $ ⊢ {coke ⊗ sandwich} ⊸ I · ⊢ $ ⊗ $ ⊗ $ ⊸ {coke ⊗ sandwich}

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-99
SLIDE 99

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Buy a Coke and a Sandwich with 3 Dollars

Signature Σ = r1 : $ ⊸ {coke} r2 : $ ⊗ $ ⊸ {sandwich}

u1 : $ ⊢ $ u2 : $, u3 : $ ⊢ $ ⊗ $ v1 : coke ⊢ coke v2 : sandwich ⊢ sandwich v1 : coke, v2 : sandwich ⊢ coke ⊗ sandwich v1 : coke, v2 : sandwich ⊢ coke ⊗ sandwich u2 : $, u3 : $, v1 : coke ⊢ coke ⊗ sandwich u1 : $, u2 : $, u3 : $ ⊢ {coke ⊗ sandwich} · ⊢ $ ⊗ $ ⊗ $ ⊸ {coke ⊗ sandwich}

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-100
SLIDE 100

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Forward-Chaining

Γ; ∆; Φ ⊢ A

+

Γ; ∆; Φ ⊢ {A

+}

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Γ, A

−; ∆; Φ; [A −] ⊢ B +

Γ, A

−; ∆; Φ ⊢ B +

Γ; ∆; Φ; [A

−] ⊢ B +

Γ

−; ∆, A; Φ ⊢ B +

Γ; ∆; Φ; [A

−] ⊢ B +

Γ

−; ∆; Φ, A ⊢ B +

Γ; ∆; Φ > > B

+

Γ; ∆; Φ ⊢ B

+ Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-101
SLIDE 101

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Monadic Left-focusing/Right Focusing

p : A

+ → Γ; ∆; Φ; [A −] ⊢ B +

Γ; ∆; Φ; [Πp : A

+.A −] ⊢ B +

Γ; ∆; Φ; [A

i ] ⊢ B

+

i = 1, 2 Γ; ∆; Φ; [A

1 &A

2 ] ⊢ B

+

p : A

+ → Γ; ∆; Φ ⊢ B +

Γ; ∆; Φ; [{A

+}] ⊢ B +

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Γ; ·; Φ > > 1 Γ; ·; Φ ⊢ A

Γ; ·; Φ > > !A

Γ; ∆; Φ ⊢ A

Γ; ∆; Φ > > ↓ A

Γ; ∆; Φ ⊢ A

Γ; ∆; Φ > > @A

Γ; ∆1; Φ1 > > A

+

1

Γ; ∆2; Φ2 > > A

+

2

Γ; ∆1, ∆2; Φ1, Φ2 > > A

+

1 ⊗ A

+

2

Γ; ∆; Φ > > [T/x]A

+

2

Γ; ∆; Φ > > ∃x :!A

−.A +

2

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-102
SLIDE 102

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Now in Celf

dollar : type. coke : type. sandwich : type. $->coke : dollar -o {coke}. $$->sandw : dollar -o dollar -o {sandwich}. #query * 1 * 1 dollar -o dollar -o dollar

  • o {coke * sandwich}.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-103
SLIDE 103

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Block’s World

Robot arm Can hold a block or be empty Blocks can be free, or have another block on top. Table A block maylie on the table.

◮ clear A ∧ on A B ∧ empty ⊃ clear B ∧ holds A ◮ clear A ∧ table A ∧ empty ⊃ holds A ◮ holds A ∧ clear B ⊃ on A B ∧ clear A ∧ empty ◮ holds A ⊃ clear A ∧ table A ∧ empty

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-104
SLIDE 104

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

The π-Calculus

Expressions: P ::= 0 | (P1 | P2) | νx.P |!P | a(y).P | ab.P Structural congruence

◮ P | Q ≡ Q | P

(P | Q) | R ≡ P | (Q | R) P | 0 ≡ P

◮ (νx)(νy)P ≡ (νy)(νx)P

(νx)0 ≡ 0

◮ !P ≡ P |!P ◮ (νx)(P | Q) ≡ (νx)P|Q if x is not free in Q.

Reduction semantics

◮ a(y).P | ab.Q −

→ P | Q[b/y].

◮ If P −

→ Q then P | R − → Q | R.

◮ If P −

→ Q then (νx)P − → (νx)Q.

◮ If P ≡ P′ and P′ −

→ Q′ where Q′ ≡ Q then also P − → Q.

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming

slide-105
SLIDE 105

Intuitionistic Logic Linear Logic Concurrent Monadic Linear Logic

Session Types

Carsten Sch¨ urmann ITU, currently CMU Linear Logic Programming