A Type Theory with Partial Equivalence Relations as Types Abhishek - - PowerPoint PPT Presentation

a type theory with partial equivalence relations as types
SMART_READER_LITE
LIVE PREVIEW

A Type Theory with Partial Equivalence Relations as Types Abhishek - - PowerPoint PPT Presentation

A Type Theory with Partial Equivalence Relations as Types Abhishek Anand Mark Bickford Robert L. Constable Vincent Rahli May 13, 2014 PER types May 13, 2014 1/20 PRL Group Abhishek Anand Mark Bickford Robert L. Constable Richard Eaton


slide-1
SLIDE 1

A Type Theory with Partial Equivalence Relations as Types

Abhishek Anand Mark Bickford Robert L. Constable Vincent Rahli May 13, 2014

PER types May 13, 2014 1/20

slide-2
SLIDE 2

PRL Group

Abhishek Anand Mark Bickford Robert L. Constable Richard Eaton Vincent Rahli PER types May 13, 2014 2/20

slide-3
SLIDE 3

Stuart Allen’s Thesis

This work started with a careful reading of: Stuart Allen’s PhD thesis [All87]: A Non-Type-Theoretic Semantics for Type-Theoretic Language It describes a semantics for Nuprl where types are defined as Partial Equivalence Relations on terms (the PER semantics).

PER types May 13, 2014 3/20

slide-4
SLIDE 4

Stuart Allen’s Thesis

Among others, Nuprl has the following types: Equality: a = b ∈ T Dependent function: a:A → B[a] Dependent product: a : A × B[a] Intersection: ∩a:A.B[a] Partial: A Universe: Ui Subset: {a : A | B[a]} Quotient: T//E where E has to be an equivalence relation w.r.t. T.

PER types May 13, 2014 4/20

slide-5
SLIDE 5

Stuart Allen’s Thesis

In his thesis, the following page was misplaced:

PER types May 13, 2014 5/20

slide-6
SLIDE 6

Stuart Allen’s Thesis

What does it say? It suggests that the quotient and subset types could be replaced by a quotient-like type that only requires a partial equivalence relation.

PER types May 13, 2014 6/20

slide-7
SLIDE 7

Our Proposal

Here is our proposal—redefining Nuprl’s type theory around an extensional “Partial Equivalence Relation” type constructor that turns PERs into types. The domain: the closed terms of Nuprl’s computation system. Base is the type that contains all closed terms and whose equality ∼ is Howe’s computational equivalence relation [How89].

PER types May 13, 2014 7/20

slide-8
SLIDE 8

Our Proposal

Now, the per type constructor:

◮ per(R) is a type if R is a PER on Base. ◮ a = b ∈ per(R) if R a b. ◮ per(R1) = per(R2) ∈ Ui if R1 and R2 are equivalent

relations. We’ll need universes as well. Our type theory now has: Base, Ui, per.

PER types May 13, 2014 8/20

slide-9
SLIDE 9

Our Proposal

per types are now part of our implementation of Nuprl in Coq [AR14]. We verified:

H ⊢ per(R) = per(R′) ∈ Type BY [pertypeEquality] H, x : Base, y : Base ⊢ R x y ∈ Type H, x : Base, y : Base ⊢ R′ x y ∈ Type H, x : Base, y : Base, z : R x y ⊢ R′ x y H, x : Base, y : Base, z : R′ x y ⊢ R x y H, x : Base, y : Base, z : R x y ⊢ R y x H, x : Base, y : Base, z : Base, u : R x y, v : R y z ⊢ R x z H, x : t1 = t2 ∈ per(R) ⊢ C ⌊ext e⌋ BY [pertypeElimination] H, x : t1 = t2 ∈ per(R), [y : R t1 t2] ⊢ C ⌊ext e⌋ H ⊢ t1 = t2 ∈ per(R) BY [pertypeMemberEquality] H ⊢ per(R) ∈ Type H ⊢ R t1 t2 H ⊢ t1 ∈ Base H ⊢ t2 ∈ Base

PER types May 13, 2014 9/20

slide-10
SLIDE 10

Examples

Let us start with simple examples: Void = per(λ , .1 0) Unit = per(λ , .0 0) These use , Howe’s computational approximation relation [How89]. Our type theory now has: Base, Ui, per, .

PER types May 13, 2014 10/20

slide-11
SLIDE 11

Examples

Integers: Z = per(λa.λb.a ∼ b ⊓ ⇑(isint(a, tt, ff))) where A ⊓ B = ∩x:Base. ∩ y:halts(x).isaxiom(x, A, B) ⇑(a) = tt a halts(t) = Ax (let x := t in Ax) Our type theory now has: Base, Ui, per, , ∼, ∩.

PER types May 13, 2014 11/20

slide-12
SLIDE 12

Examples

Quotient types: T//E = per(λx, y.(x ∈ T) ⊓ (y ∈ T) ⊓ (E x y)) This is the definition we are using in Nuprl now—no longer a primitive. The partial type constructor is a quotient type—no longer a primitive. Our type theory now has: Base, Ui, per, , ∼, ∩, = ∈ .

PER types May 13, 2014 12/20

slide-13
SLIDE 13

Examples

What about the subset type? {a : A | B[a]} = per(λx, y.(x = y ∈ A) ⊓ B[x])

PER types May 13, 2014 13/20

slide-14
SLIDE 14

Examples

What about the subset type? {a : A | B[a]} = per(λx, y.(x = y ∈ A) ⊓ B[x]) This does not work! We do not get that B is functional over A.

PER types May 13, 2014 14/20

slide-15
SLIDE 15

Examples

  • ne solution—annotate families with levels:

{a : A | B[a]}i = per(λx, y.(x = y ∈ A)⊓B[x]⊓Fam(A, B, i)) where Fam(A, B, i) = ∩a, b:A.(B[a] = B[b] ∈ Ui) One drawback: the annotations.

PER types May 13, 2014 15/20

slide-16
SLIDE 16

Examples

another solution—introduce a type of type equalities (T = U): {a : A | B[a]} = per(λx, y.(x = y ∈ A) ⊓ B[x] ⊓ Fam(A, B)) where Fam(A, B) = ∩a, b:A.(B[a] = B[b]) This requires a more intensional version of our per type.

PER types May 13, 2014 16/20

slide-17
SLIDE 17

Examples

Using this method, we can also define the other type families such as: dependent functions, dependent products, . . . Both per and its intensional version are part of our implementation of Nuprl in Coq [AR14]. We proved, e.g., that the elimination rule for the per version

  • f our function type is valid.

PER types May 13, 2014 17/20

slide-18
SLIDE 18

Inductive types

We saw how to build inductive types in yesterday’s talk.

◮ Algebraic datatypes: {t : coDT | halts(size(t))}. ◮ Inductive types using Bar Induction.

PER types May 13, 2014 18/20

slide-19
SLIDE 19

Conclusion

{ Conciseness

◮ A small core of primitive types. ◮ Simple rules.

{ Flexibility

◮ Lets user define even more types. ◮ No need to modify/update the meta-theory.

{ Practicality?

◮ We’re already using it. ◮ We’re still experimenting with the intensional per type.

PER types May 13, 2014 19/20

slide-20
SLIDE 20

References I

Stuart F. Allen. A Non-Type-Theoretic Semantics for Type-Theoretic Language. PhD thesis, Cornell University, 1987. Abhishek Anand and Vincent Rahli. Towards a formally verified proof assistant. Accepted to ITP 2014, 2014. Douglas J. Howe. Equality in lazy computation systems. In Proceedings of Fourth IEEE Symposium on Logic in Computer Science, pages 198–203. IEEE Computer Society, 1989. PER types May 13, 2014 20/20