Congruence in univalent type theory Luis Scoccola lscoccol@uwo.ca - - PowerPoint PPT Presentation

congruence in univalent type theory
SMART_READER_LITE
LIVE PREVIEW

Congruence in univalent type theory Luis Scoccola lscoccol@uwo.ca - - PowerPoint PPT Presentation

Congruence in univalent type theory Luis Scoccola lscoccol@uwo.ca University of Western Ontario June 11, 2019 Goals for the talk Congruence and congruence closure for propositional equality. Solution of Selsam & de Moura for a


slide-1
SLIDE 1

Congruence in univalent type theory

Luis Scoccola lscoccol@uwo.ca

University of Western Ontario

June 11, 2019

slide-2
SLIDE 2

Goals for the talk

◮ Congruence and congruence closure for propositional equality. ◮ Solution of Selsam & de Moura for a non-univalent type theory. ◮ Proposed approach for congruence in the univalent case. ◮ Issues with congruence closure.

slide-3
SLIDE 3

Informal definitions

Definition

A relation R satisfies congruence if ∀f xi R yi for 0 ≤ i ≤ n ⇒ f (x1, . . . , xn) R f (y1, . . . , yn). The congruence closure of R is the smallest equivalence relation that satisfies congruence and contains R.

Example

During a proof, determine whether x = y follows from applying reflexivity, symmetry, transitivity, or congruence lemmas to the equalities in our context.

slide-4
SLIDE 4

Congruence in dependent type theory

Propositional equality is an equivalence relation: refl : x = x inv : x = y → y = x concat : x = y → y = z → x = z Can also prove congruence lemma (for non-dependent function): congrf : (f : A → B) → (x =A y) → f (x) =B f (y). But if f : (a : A) → B(a), the above doesn’t type check.

slide-5
SLIDE 5

A solution: Heterogeneous equality

Definition

Heterogeneous equality is the inductive family heq : (A, A′ : U) → A → A′ → U generated by refl : (A : U) → (a : A) → heq(a, a). Selsam & de Moura implement full congruence closure procedure in Lean 3 using heq. Need to assume an axiom to prove the congruence lemmas:

  • fheq : (A : U) → (x, y : A) → heq(x, y) → x =A y.

The axiom ofheq implies that paths in U transport trivially: (e : A =U A) → a = transportX→X(e, a). U can’t be univalent.

slide-6
SLIDE 6

Congruence in univalent type theory?

Use pathovers.

Definition

Given a type B : U and a type family X : B → U, the type family pathover : (b, b′ : B) → (b = b′) → X(b) → X(b′) → U is defined by path induction. We write x =B

e x′ for pathover(b, b′, e, x, x′).

slide-7
SLIDE 7

The congruence lemma

I will describe an inductive algorithm that produces: ◮ A pathover type for each dependent family. ◮ A congruence lemma for each dependent function. This is implemented as a tactic in Lean 3. We have to be careful with one thing: Congruence lemmas depend on previous congruence lemmas.

slide-8
SLIDE 8

The congruence lemma (cont.)

Example

Congruence lemma for cons : (n : N) → A → vecA(n) → vecA(succ(n)), should have type congrcons (n, m : N) (x, y : A) (xs : vecA(n)) (ys : vecA(m)) (e1 : n = m) (e2 : x = y) (e3 : xs =e1 ys) : cons(n, x, xs) =vecA

congrsucc(e1) cons(m, y, ys)

where congrsucc : (n, m : N) → (n = m) → succ(n) = succ(m).

slide-9
SLIDE 9

The algorithm

Given context Γ, and dependent function h : (x0 : A0) → (x1 : A1(x0)) → · · · → (xn : An(x1, . . . , xn−1)) → An+1(x1, . . . , xn), in context Γ. (1) Decompose the type of h as type families applied to dependent functions: write Ai(xi−1) ≡ Ci(f i(xi−1)) such that ◮ Ci is not an application; ◮ f i is a sequence f 1

i , . . . , f k(i) i

  • f dependent functions.
slide-10
SLIDE 10

The algorithm (cont.)

(2) Define the pathovers for the type families Ci: IdCi :≡ λxi, x′

i, ei, c, c′.congrCi(xi, x′ i, ei)∗c = c′

(3) Define the congruence for all the functions f k

i : Recursively.

Caveat: Each function might be a composite, so return the composite of the congruences.

slide-11
SLIDE 11

The algorithm (cont.)

(4) Define the congruence for h: congrh : (x0 : C0) → (x1 : C1(f 1(x0))) → · · · → (xn : Cn(f n(xn−1))) (x′

0 : C0) → (x′ 1 : C1(f 1(x′ 0))) → · · · → (x′ n : Cn(f n(x′ n−1)))

(e0 : IdC0) → (e1 : IdC1(congrf 1(e0)) → · · · → (en : IdCn(congrf n(en−1)) → IdCn+1(congrf n+1(en)), By path induction on the pathovers e0, · · · , en, using refl.

slide-12
SLIDE 12

Congruence lemma

Also gives us a useful characterization of the identity types of: ◮ structures; ◮ iterated sigmas.

slide-13
SLIDE 13

Congruence closure

Work in progress: ◮ Must keep a congruence data structure for each type family. ◮ Coherence problems (e.g. congruence of concatenation is concatenation of congruences). ◮ Some of them can be dealt with by working in a cubical type theory (e.g. composite of congruences is definitionally equal to congruence of composites, inverse of inverse is identity). ◮ Different equalities between the same pair of elements: cannot use union-find data structure for congruence closure. Use graphs instead, but this is inefficient. These are not problems if we limit congruence closure to type families that depend on sets.

slide-14
SLIDE 14

Thank you for listening!