2. Agenda
Linear Logic
Viewpoint of Linear Logic
Definition and Examples
Computations
Typed Lambda Calculus
Linear Lisp Machine
3. Book
LECTURES ON LINEAR LOGIC
A. S. Troelstra
CSLI Lectures Notes Number 29
You can download pdf file of this book from
http://standish.stanford.edu/bin/object?00000065
Chapter 6 is mainly used.
4. Viewpoint of Linear Logic
In linear logic, we can use each hypothesis
just once.
Strictly speaking, it’s not correct...
This formula is not valid in linear logic.
(A -> B -> C) -> (A -> B) -> A -> C
Because we need to use predicate “A” twice.
This formula is valid.
(A -> B) -> (B -> C) -> A -> C
Because each subformula is used only once.
5. Natural Deduction
In this explanation, we use natural
deduction to construct proof trees.
With contexts (i.e. lists of hypotheses).
Syntax
Γ├ A
“Formula A is derived from context Γ.”
Axioms
A├ A
Not Γ, A├ A
6. Linear Logic with
Natural Deduction
Many handbooks for linear logic use
sequent calculus.
But some of you may not know about sequent
calculus, so I won’t use.
The book I read also explains about natural
deduction.
In linear sequent calculus, there are neither
contraction nor weakening rules.
7. Linear Implication
We use -○ for implication in linear logic.
A -○ B means that “B is proved with just one
formula A”.
We use following formulae as examples.
(A -○ B) -○ (B -○ C) -○ A -○ C
(A -○ B -○ C) -○ (A -○ B) -○ A -○ C
9. Example
(A -○ B) -○ (B -○ C) -○ A -○ C
A –○ B├ A -○ B A├ A
B -○ C├ B -○ C A -○ B, A├ B
A -○ B, B -○ C, A├ C
A -○ B, B -○ C├ A -○ C
A -○ B├ (B -○ C) -○ A -○ C
├ (A -○ B) -○ (B -○ C) -○ A -○ C
10. Failure about proof 1
A -○ B -○ C├ A -○ B -○ C A├ A A-○ B├ A -○ B ├ A ??
A -○ B -○ C, A├ B -○ C A -○ B├ B
A -○ B -○ C, A -○ B, A├ C
A -○ B -○ C, A -○ B├ A -○ C
A -○ B -○ C├ (A -○ B) -○ A -○ C
├ (A -○ B -○ C) -○ (A -○ B) -○ A -○ C
11. Failure about proof 2
A -○ B -○ C├ A -○ B -○ C ├ A ?? A-○ B├ A -○ B A├ A
A -○ B -○ C├ B -○ C A -○ B, A├ B
A -○ B -○ C, A -○ B, A├ C
A -○ B -○ C, A -○ B├ A -○ C
A -○ B -○ C├ (A -○ B) -○ A -○ C
├ (A -○ B -○ C) -○ (A -○ B) -○ A -○ C
12. Other structures
(logical operators)
NOT
Or falsefood (with implication).
AND
OR
There are two types for each operator.
Contextual
Context-free
13. Contextual and Context-free
These kinds are based on operators’ rules.
If a rule has a restriction for contexts of
hypotheses in the rule, then the operator is
contextual, otherwise context-free.
Linear implication is context-free one.
Contextual implication is also definable, but its
rules are hard to describe in natural deduction.
14. Falsehood
Context-free
0
Γ, A -○ 0├ 0
Γ├ A
NOT A = A -○ 0.
Above rule can be
viewed as “double
negation elimination”.
Contextual
⏊
Γ, ⏊├ A
I can’t explain why this
is “contextual” and left
one is “context-free”...
15. Example
((A -○ 0) -○ 0) -○ A
...very simple...
(A -○ 0) -○ 0├ (A -○ 0) -○ 0 A -○ 0├ A -○ 0
(A -○ 0) -○ 0, A -○ 0├ 0
(A -○ 0) -○ 0├ A
├ ((A -○ 0) -○ 0) -○ A
16. AND
Context-free
A★B
Γ├ A Δ├ B
Γ, Δ├ A★B
Γ├ A★B Δ, A, B├ C
Γ, Δ├ C
Contextual
A∩B
Γ├ A Γ├ B
Γ ├ A∩B
Γ├ A∩B Γ├ A∩B
Γ├ A Γ├ B
17. Example 1
(A -○ B)★C -○ A -○ B★C
A -○ B├ A -○ B A├ A
A, A -○ B├ B C├ C
(A -○ B)★B├ (A -○ B)★B A, A -○ B, C├ B★C
(A -○ B)★C, A├ B★C
(A -○ B)★C├ A -○ B★C
├ (A -○ B)★C -○ A -○ B★C
18. Example 2
(A -○ B)∩(A -○ C) -○ A -○ B∩C
(A -○ B)∩(A -○ C)├ (A -○ B)∩(A -○ C) (A -○ B)∩(A -○ C)├ (A -○ B)∩(A -○ C)
(A -○ B)∩(A -○ C)├ A -○ B A├ A (A -○ B)∩(A -○ C)├ A -○ C A├ A
(A -○ B)∩(A -○ C), A├ B (A -○ B)∩(A -○ C), A├ C
(A -○ B)∩(A -○ C), A├ B∩C
(A -○ B)∩(A -○ C)├ A -○ B∩C
├ (A -○ B)∩(A -○ C) -○ A -○ B∩C
19. OR
Context-free
A+B
OR is hard to describe
in natural deduction,
like contextual
implication.
Dual operator of ★.
~(A★B) = ~A+~B
~A = A -○ 0
Contextual
A∪B
Dual operator of ∩.
~(A∩B) = ~A∪~B
Γ├ A
Γ├ A∪B
Γ├ A∪B
A, Δ├ C B, Δ├ C
Γ, Δ├ C
20. Example
(C -○ A)∪(C -○ B) -○ C -○ A∪B
C -○ A├ C -○ A C├ C C -○ B├ C -○ B C├ C
C -○ A, C├ A C -○ B, C├ B
(C -○ A)∪(C -○ B)├ (C -○ A)∪(C -○ B) C -○ A, C├ A∪B C -○ B, C├ A∪B
(C -○ A)∪(C -○ B), C├ A∪B
(C -○ A)∪(C -○ B)├ C -○ A∪B
├ (C -○ A)∪(C -○ B) -○ C -○ A∪B
21. Special Operator : Storage !A
A storage formula !A denotes any number
of formula A.
Γ├ !B Δ, !B, !B├ A Γ├ !B Δ├ A
Γ, Δ├ A Γ, Δ├ A
Γ├ !B Δ, B├ A !Γ├ B
Γ, Δ├ A !Γ├ !B
!Γ means that all hypotheses in Γ are storage
formulae.
22. Example
(A -○ B -○ C) -○ (A -○ B) -○ !A -○ C
A -○ B -○ C├ A -○ B -○ C A├ A A -○ B├ A -○ B A├ A
!A├ !A A -○ B -○ C, A├ B -○ C !A├ !A A -○ B, A├ B
A -○ B -○ C, !A├ B -○ C A -○ B, !A├ B
!A├ !A A -○ B -○ C, A -○ B, !A, !A├ C
A -○ B -○ C, A -○ B, !A├ C
A -○ B -○ C, A -○ B├ !A -○ C
A -○ B -○ C├ (A -○ B) -○ !A -○ C
├ (A -○ B -○ C) -○ (A -○ B) -○ !A -○ C
24. Curry-Howard Isomorphism
Relationship between typed lambda terms
and logical formulae.
typing rule derivation rule (axiom)
typed lambda term proof
Here, we use intuitional linear logic, which
does not have double negation elimination
rule.
25. Linear Lambda Terms
Γ, x : A├ t : B
Γ├ λxA. t : A -○ B
Γ├ s : A -○ B Δ├ t : A
Γ, Δ├ (s t) : B
...Other rules are omitted.
(They are same forms as formulae.)
26. Example 1
λfA-○B. λgB-○C. λaA. (g (f a))
: (A -○ B) -○ (B -○ C) -○ A -○ C
λs(A-○B)★C.λaA.let (xA-○B★yC)=s in (x a)★y
: (A -○ B)★C -○ A -○ B★C
λs(A-○B)∩(A-○C).λaA.((π0 s) a)∩((π1 s) a)
: (A -○ B)∩(A -○ C) -○ A -○ B∩C
λs(C-○A)∪(C-○B).λcC. match s with
| fC-○A=>(κ0 (f c)) | gC-○B=>(κ1 (g c)).
: (C -○ A)∪(C -○ B) -○ C -○ A∪B
27. Example 2
λfA-○B-○C.λgA-○B.λx!A.let (s!A,t!A)=copy(x) in
(let aA = load(s) in (f a)
let bA = load(t) in (g b))
: (A -○ B -○ C) -○ (A -○ B) -○ !A -○ C
λfA-○B-○C.λgA-○B.λx!A.let (s!A,t!A)=copy(x) in
let aA = load(s) in let bA = load(t) in
((f a) (g b))
: (A -○ B -○ C) -○ (A -○ B) -○ !A -○ C
...etc
28. Linear Lisp
Lively Linear Lisp – ‘Look Ma, No Garbage!’
Henry G. Baker
Nimble Computer Corporation
ACM SIGPLAN Notices 27, 8(Aug. 1992),
89-98.
29. Linear Lisp (Machine)
Linear Lisp has
nil, cons cells and symbols.
11 (atomic) operations.
And some logical function.
Linear Lisp does not require garbage
collection.
Linear Lisp is not based on linear logic...
Only “NO DATA SHARING IN PROGRAMS”.
30. Operations (1/3)
rn : n-th register (variable)
(<-> r1 r2)
swap r1, r2
(<-> r1 (CAR r2))
(<-> r1 (CDR r2))
r1 and r2 must be distinct, and r2 must not be
ATOM (neither nil nor symbol).
33. Proposition
Reference counts of all cons cell in linear
lisp programs are 1.
Cons cells are created when CONS (or PUSH)
operations are executed, and destroyed when
POP operations are executed.
So if one cons cell is not accessible, then it is
destroyed soon.
34. CAUTION!
Previous proposition is not one on the
paper.
In the paper, auther uses “free register”,
which is infinite long list and elements of the
list are all nil.
Reference counts of all lists are always identically 1.
All cons cells are always accessible – i.e. live.
No garbage is created.
The name of the paper would be based on these
propositions.
35. Other operations
We can construct some operations with
above operations.
(FREE r1)
r1 becomes nil.
(COPY r1 r2)
If r2 is nil, r2 becomes the same as r1.
Not sharing cell.
(EQUAL r1 r2)
Recursive list equality.
39. Traditional Lisp Interpreter
Auther says that we can program a
traditional lisp interpreter, but there is no
such a program in the paper.
Instead of it, there is a metacircular linear lisp
interpreter.
It needs quote, back-quote, and macros...
The interpreter is inefficient, due to the
extra expense of copying.
40. And ...
The rest of paper is about how to use
linear lisp in multiprocessing...
But I don’t want to talk about that.
So, that’s all for my talk.