5. Propositional equivalence vs definitional equality
∀x.∀y.(x =
&&
y) ⇒ (even(x) = even(y)) (2 + 2 = 4) ⇒ (even(2 + 2) = even(4))
(2 + 2 =
))
5) ⇒ (even(2 + 2) = even(5))
Proposition Computation
∀X.∀Y .(X ≡
&&
Y ) ⇒ (X ⇔ Y ) (A ≡
((
B) ⇒ (A ⇔ B)
Propositional Decidable! [DiCosmo et al]
(for some settings)
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 2 / 15
6. Propositional equivalence vs definitional equality
∀x.∀y.(x =
&&
y) ⇒ (even(x) = even(y)) (2 + 2 = 4) ⇒ (even(2 + 2) = even(4))
(2 + 2 =
))
5) ⇒ (even(2 + 2) = even(5))
Proposition Computation
∀X.∀Y .(X ≡
&&
Y ) ⇒ (X ⇔ Y ) (A ≡
((
B) ⇒ (A ⇔ B)
Propositional Decidable! [DiCosmo et al]
(for some settings)
We want to go further:
(A ≡ B) ⇒ (π : A ⇔ π : B)
The goal is to identify isomorphic types
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 2 / 15
7. The basic setting
Simply types with conjunction and implication
A, B, C ::= τ | A ⇒ B | A ∧ B
An equivalence relation between types (based on the isomorphisms1
)
1. A ∧ B ≡ B ∧ A (comm)
2. A ∧ (B ∧ C) ≡ (A ∧ B) ∧ C (asso)
3. (A ∧ B) ⇒ C ≡ A ⇒ B ⇒ C (curry)
4. A ⇒ (B ∧ C) ≡ (A ⇒ B) ∧ (A ⇒ C) (distrib)
1Bruce, Di Cosmo, Longo, MSCS 2(2), 231–247, 1992
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 3 / 15
8. The basic setting
Simply types with conjunction and implication
A, B, C ::= τ | A ⇒ B | A ∧ B
An equivalence relation between types (based on the isomorphisms1
)
1. A ∧ B ≡ B ∧ A (comm)
2. A ∧ (B ∧ C) ≡ (A ∧ B) ∧ C (asso)
3. (A ∧ B) ⇒ C ≡ A ⇒ B ⇒ C (curry)
4. A ⇒ (B ∧ C) ≡ (A ⇒ B) ∧ (A ⇒ C) (distrib)
We want
[A≡B]
r : A
r : B
1Bruce, Di Cosmo, Longo, MSCS 2(2), 231–247, 1992
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 3 / 15
9. Associative and commutative conjunction
Γ r : A Γ s : B
Γ r, s : A ∧ B
(∧i )
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 4 / 15
10. Associative and commutative conjunction
Γ r : A Γ s : B
Γ r, s : A ∧ B
(∧i )
A ∧ B ≡ B ∧ A
A ∧ (B ∧ C) ≡ (A ∧ B) ∧ C
So
r, s s, r
r, s, t r, s , t
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 4 / 15
11. Associative and commutative conjunction
Γ r : A Γ s : B
Γ r, s : A ∧ B
(∧i )
A ∧ B ≡ B ∧ A
A ∧ (B ∧ C) ≡ (A ∧ B) ∧ C
So
r, s s, r
r, s, t r, s , t
What about the elimination?
Γ r, s : A ∧ B
Γ π1 r, s : A
(∧e )
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 4 / 15
12. Associative and commutative conjunction
Γ r : A Γ s : B
Γ r, s : A ∧ B
(∧i )
A ∧ B ≡ B ∧ A
A ∧ (B ∧ C) ≡ (A ∧ B) ∧ C
So
r, s s, r
r, s, t r, s , t
What about the elimination?
Γ r, s : A ∧ B
Γ π1 r, s : A
(∧e )
But A ∧ B = B ∧ A!!
Γ r, s : B ∧ A
Γ π1 r, s : B
(∧e )
Moreover r, s = s, r so π1 r, s = π1 s, r !!
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 4 / 15
13. Associative and commutative conjunction
Γ r : A Γ s : B
Γ r, s : A ∧ B
(∧i )
A ∧ B ≡ B ∧ A
A ∧ (B ∧ C) ≡ (A ∧ B) ∧ C
So
r, s s, r
r, s, t r, s , t
What about the elimination?
Γ r, s : A ∧ B
Γ π1 r, s : A
(∧e )
But A ∧ B = B ∧ A!!
Γ r, s : B ∧ A
Γ π1 r, s : B
(∧e )
Moreover r, s = s, r so π1 r, s = π1 s, r !!
Workaround: Church-style – Project w.r.t. a type
If r : A then πA r, s → r
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 4 / 15
14. Associative and commutative conjunction
Γ r : A Γ s : B
Γ r, s : A ∧ B
(∧i )
A ∧ B ≡ B ∧ A
A ∧ (B ∧ C) ≡ (A ∧ B) ∧ C
So
r, s s, r
r, s, t r, s , t
What about the elimination?
Γ r, s : A ∧ B
Γ π1 r, s : A
(∧e )
But A ∧ B = B ∧ A!!
Γ r, s : B ∧ A
Γ π1 r, s : B
(∧e )
Moreover r, s = s, r so π1 r, s = π1 s, r !!
Workaround: Church-style – Project w.r.t. a type
If r : A then πA r, s → r
This induces non-determinism
If
r : A
s : A
then
πA r, s → r
πA r, s → s
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 4 / 15
15. Associative and commutative conjunction
Γ r : A Γ s : B
Γ r, s : A ∧ B
(∧i )
A ∧ B ≡ B ∧ A
A ∧ (B ∧ C) ≡ (A ∧ B) ∧ C
So
r, s s, r
r, s, t r, s , t
What about the elimination?
Γ r, s : A ∧ B
Γ π1 r, s : A
(∧e )
But A ∧ B = B ∧ A!!
Γ r, s : B ∧ A
Γ π1 r, s : B
(∧e )
Moreover r, s = s, r so π1 r, s = π1 s, r !!
Workaround: Church-style – Project w.r.t. a type
If r : A then πA r, s → r
This induces non-determinism
If
r : A
s : A
then
πA r, s → r
πA r, s → s
We are interested in the proof theory and
both r and s are valid proofs of A
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 4 / 15
16. Curryfication
(A ∧ B) ⇒ C ≡ A ⇒ B ⇒ C
induces
r s, t rst
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 5 / 15
17. Curryfication
(A ∧ B) ⇒ C ≡ A ⇒ B ⇒ C
induces
r s, t rst
(λxA
.r)s → r[s/x]
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 5 / 15
18. Curryfication
(A ∧ B) ⇒ C ≡ A ⇒ B ⇒ C
induces
r s, t rst
If s : A, (λxA
.r)s → r[s/x]
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 5 / 15
19. Distributivity of implication over conjunction
A ⇒ (B ∧ C) ≡ (A ⇒ B) ∧ (A ⇒ C)
induces
λxA
. r, s λxA
.r, λxA
.s
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 6 / 15
20. Distributivity of implication over conjunction
A ⇒ (B ∧ C) ≡ (A ⇒ B) ∧ (A ⇒ C)
induces
λxA
. r, s λxA
.r, λxA
.s and λxA
.πB (r) πA⇒B (λxA
.r)
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 6 / 15
21. Distributivity of implication over conjunction
A ⇒ (B ∧ C) ≡ (A ⇒ B) ∧ (A ⇒ C)
induces
λxA
. r, s λxA
.r, λxA
.s and λxA
.πB (r) πA⇒B (λxA
.r)
Example
λxA∧B
.x : (A ∧ B) ⇒ (A ∧ B)
λxA∧B
.x : ((A ∧ B) ⇒ A) ∧ ((A ∧ B) ⇒ B)
(≡)
π(A∧B)⇒A(λxA∧B
.x) : (A ∧ B) ⇒ A
(∧e )
π(A∧B)⇒A(λxA∧B
.x) λxA∧B
.πA(x)
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 6 / 15
22. Distributivity of implication over conjunction
Multiple choices
A ⇒ (B ∧ C) ≡ (A ⇒ B) ∧ (A ⇒ C)
λxA
. r, s λxA
.r, λxA
.s ⇒i , ∧i ∧i , ⇒i
λxA
.πB (r) πA⇒B (λxA
.r) ⇒i , ∧e ∧e, ⇒i
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 7 / 15
23. Distributivity of implication over conjunction
Multiple choices
A ⇒ (B ∧ C) ≡ (A ⇒ B) ∧ (A ⇒ C)
λxA
. r, s λxA
.r, λxA
.s ⇒i , ∧i ∧i , ⇒i
λxA
.πB (r) πA⇒B (λxA
.r) ⇒i , ∧e ∧e, ⇒i
r, s t rt, st ⇒e, ∧i ∧i , ⇒e
πA⇒B (r)s πB (rs) ∗
⇒e, ∧e ∧e, ⇒e
∗ if r : A ⇒ (B ∧ C)
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 7 / 15
24. Distributivity of implication over conjunction
Multiple choices
A ⇒ (B ∧ C) ≡ (A ⇒ B) ∧ (A ⇒ C)
λxA
. r, s λxA
.r, λxA
.s ⇒i , ∧i ∧i , ⇒i
λxA
.πB (r) πA⇒B (λxA
.r) ⇒i , ∧e ∧e, ⇒i
r, s t rt, st ⇒e, ∧i ∧i , ⇒e
πA⇒B (r)s πB (rs) ∗
⇒e, ∧e ∧e, ⇒e
∗ if r : A ⇒ (B ∧ C)
πA⇒B (r)s πB (rs) suffices . . . plus η and δ (surjective pairing)
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 7 / 15
25. α-equivalence
Rules
If A ≡ B, r r[A/B]
If r =α r , r r
Example
Let A ≡ B
A⇒(C1∧C2)
λxA
.r, λyB
.s
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 8 / 15
26. α-equivalence
Rules
If A ≡ B, r r[A/B]
If r =α r , r r
Example
Let A ≡ B
A⇒(C1∧C2)
λxA
.r, λyB
.s ∗
λxA
.r, λxA
.s[x/y][A/B]
λxA
. r, s[x/y][A/B]
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 8 / 15
27. The full operational semantics
Symmetric relation:
r, s s, r (comm)
r, s , t r, s, t (asso)
rst r s, t (curry)
If r : A ⇒ C, πA⇒B (r)s πB (rs) (dist)
If A ≡ B, r r[A/B] (α–Types)
If r =α s, r s (α–Terms)
If r s, then K[r] K[s] for any context K[·]
Reductions:
If s : A, (λxA
.r)s r[s/x] (β)
If r : A, πA r, s r (πn)
If r : A, πA(r) r (π1)
Extensionality:
If
x /∈ FV (r),
r : A ⇒ B,
r ∗
λyA
.r
, r λxA
.rx (η)
If
r : A ∧ B,
r ∗
r1, r2
with r1 : A, r2 : B
, r πA(r), πB (r) (δ)
r s
r → s
r → s
λxA
.r → λxA
.s
r → s
tr → ts
r
¬η
→ s
rt → st
r → s
t, r → t, s
r
¬δ
→ s
πA(r) → πA(s)
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 9 / 15
28. Normalisation
r is in normal form, if it can only continue reducing by relation
Normal form
Red(r) = {s | r ∗
r → s ∗
s}
r in normal form if Red(r) = ∅
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 10 / 15
29. Normalisation
r is in normal form, if it can only continue reducing by relation
Normal form
Red(r) = {s | r ∗
r → s ∗
s}
r in normal form if Red(r) = ∅
Theorem (Strong normalisation)
If Γ r : A then r strongly normalising
Proof. Reducibility method
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 10 / 15
30. Finding an interpretation
The standard interpretation does not work
A ∧ B = {r | πA(r) ∈ A and πB (r) ∈ B }
Counter-example: r = xA
, yB
, Ω ∈ A ∧ B
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 11 / 15
31. Finding an interpretation
The standard interpretation does not work
A ∧ B = {r | πA(r) ∈ A and πB (r) ∈ B }
Counter-example: r = xA
, yB
, Ω ∈ A ∧ B
A ∧ B = {r : A ∧ B | πA(r) ∈ A and πB (r) ∈ B }
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 11 / 15
32. Finding an interpretation
The standard interpretation does not work
A ∧ B = {r | πA(r) ∈ A and πB (r) ∈ B }
Counter-example: r = xA
, yB
, Ω ∈ A ∧ B
A ∧ B = {r : A ∧ B | πA(r) ∈ A and πB (r) ∈ B }
How to prove that r ∈ A and s ∈ B implies r, s ∈ A ∧ B ?
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 11 / 15
33. Finding an interpretation
The standard interpretation does not work
A ∧ B = {r | πA(r) ∈ A and πB (r) ∈ B }
Counter-example: r = xA
, yB
, Ω ∈ A ∧ B
A ∧ B = {r : A ∧ B | πA(r) ∈ A and πB (r) ∈ B }
How to prove that r ∈ A and s ∈ B implies r, s ∈ A ∧ B ?
πA(r, s)→r
πB (r, s)→s
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 11 / 15
34. Finding an interpretation
The standard interpretation does not work
A ∧ B = {r | πA(r) ∈ A and πB (r) ∈ B }
Counter-example: r = xA
, yB
, Ω ∈ A ∧ B
A ∧ B = {r : A ∧ B | πA(r) ∈ A and πB (r) ∈ B }
How to prove that r ∈ A and s ∈ B implies r, s ∈ A ∧ B ?
πA(r, s)→r
πB (r, s)→s
but. . .
let A = A1 ∧ A2
B = A2 ∧ B2
πA1∧A2
(r1, r2
A1∧A2
, s1, s2
A2∧B2
) → r1, s1
We need something more subtle
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 11 / 15
35. Finding an interpretation
Conjunction free
Conjunction-free type S, R ::= τ | S ⇒ R
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 12 / 15
36. Finding an interpretation
Conjunction free
Conjunction-free type S, R ::= τ | S ⇒ R
Lemma
∀A, A ≡
m
i=1
Si1 ⇒ · · · ⇒ Sini
⇒ τ
Example
(A ∧ B) ⇒ C ≡ A ⇒ B ⇒ C
A ⇒ (B ∧ C) ≡ (A ⇒ B) ∧ (A ⇒ C)
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 12 / 15
37. Finding an interpretation
Interpreting canonical types
n
i=1
(Sij )
mi
j=1 ⇒ τ = r | ∀i,
sij ∈ Sij
j = 1, . . . , mi
implies π(Sij )
mi
j=1⇒τ
(r)si ∈ SN
with n ≥ 1, and m ≥ 0
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 13 / 15
38. Finding an interpretation
Interpreting canonical types
n
i=1
(Sij )
mi
j=1 ⇒ τ = r | ∀i,
sij ∈ Sij
j = 1, . . . , mi
implies π(Sij )
mi
j=1⇒τ
(r)si ∈ SN
with n ≥ 1, and m ≥ 0
Example
(S ⇒ τ) ∧ τ =
r s ∈ S implies πS⇒τ (r)s ∈ SN
and πτ (r) ∈ SN
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 13 / 15
39. Finding an interpretation
Interpreting canonical types
n
i=1
(Sij )
mi
j=1 ⇒ τ = r | ∀i,
sij ∈ Sij
j = 1, . . . , mi
implies π(Sij )
mi
j=1⇒τ
(r)si ∈ SN
with n ≥ 1, and m ≥ 0
Example
(S ⇒ τ) ∧ τ =
r s ∈ S implies πS⇒τ (r)s ∈ SN
and πτ (r) ∈ SN
Lemma
If r : A then r ∈ A
Corollary
If r : A then r ∈ SN
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 13 / 15
40. Computing with this calculus
Pairs
πNat(3, 4) → 3 and πNat(3, 4) → 4
But it is possible to encode pairs behaving in an standard way
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 14 / 15
41. Computing with this calculus
Pairs
πNat(3, 4) → 3 and πNat(3, 4) → 4
But it is possible to encode pairs behaving in an standard way
Booleans
(λxA
.λyA
.x)rs (λxA
.λyA
.x)(r, s)
(λxA
.λyA
.x)(s, r)
(λxA
.λyA
.x)sr →∗
s
Hence
true ∼ false
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 14 / 15
42. Computing with this calculus
Pairs
πNat(3, 4) → 3 and πNat(3, 4) → 4
But it is possible to encode pairs behaving in an standard way
Booleans
(λxA
.λyA
.x)rs (λxA
.λyA
.x)(r, s)
(λxA
.λyA
.x)(s, r)
(λxA
.λyA
.x)sr →∗
s
Hence
true ∼ false
A ⇒ A ⇒ A
is a singleton!
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 14 / 15
43. Computing with this calculus
Pairs
πNat(3, 4) → 3 and πNat(3, 4) → 4
But it is possible to encode pairs behaving in an standard way
Booleans
(λxA
.λyA
.x)rs (λxA
.λyA
.x)(r, s)
(λxA
.λyA
.x)(s, r)
(λxA
.λyA
.x)sr →∗
s
Hence
true ∼ false
A ⇒ A ⇒ A
is a singleton!
But (A ⇒ B) ⇒ B ⇒ B is not
So, it is possible to encode booleans too
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 14 / 15
44. Summarising
What have we done?
We introduced a new calculus where
isomorphic propositions have the same proofs
Why?
If A ≡ B, a proof of A
should not be distinguishable from a proof of B
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 15 / 15
45. Summarising
What have we done?
We introduced a new calculus where
isomorphic propositions have the same proofs
Why?
If A ≡ B, a proof of A
should not be distinguishable from a proof of B
Future work
Add more connectives
Introduce polymorphism (not trivial)
Move to dependant types (provable isomorphisms?)
Alejandro Díaz-Caro and Gilles Dowek Simply Typed Lambda-Calculus Modulo Type Isomorphisms - TYPES2014 15 / 15