List A cons : A ! List A ! List A data Vec (A : Set) : ℕ ! Set where nil : Vec A zero cons : {n : ℕ} ! A ! Vec A n ! Vec A (suc n) v2l : {A : Set} {n : ℕ} ! Vec A n ! List A v2l nil = nil v2l (cons x xs) = cons x (v2l xs) appV2appL : AppV ! AppL appV2appL appV xs ys = v2l (appV (l2v xs) (l2v ys))
List A cons : A ! List A ! List A data Vec (A : Set) : ℕ ! Set where nil : Vec A zero cons : {n : ℕ} ! A ! Vec A n ! Vec A (suc n) v2l : {A : Set} {n : ℕ} ! Vec A n ! List A v2l nil = nil v2l (cons x xs) = cons x (v2l xs) appV2appL : AppV ! AppL appV2appL appV xs ys = v2l (appV (l2v xs) (l2v ys)) nothing happening?
List A cons : A ! List A ! List A data Vec (A : Set) : ℕ ! Set where nil : Vec A zero cons : {n : ℕ} ! A ! Vec A n ! Vec A (suc n) v2l : {A : Set} {n : ℕ} ! Vec A n ! List A v2l nil = nil v2l (cons x xs) = cons x (v2l xs) appV2appL : AppV ! AppL appV2appL appV xs ys = v2l (appV (l2v xs) (l2v ys)) nothing happening?
List A consL : A ! List A ! List A data Vec (A : Set) : ℕ ! Set where nilV : Vec A zero consV : {n : ℕ} ! A ! Vec A n ! Vec A (suc n) v2l : {A : Set} {n : ℕ} ! Vec A n ! List A v2l nilV = nilL v2l (consV x xs) = consL x (v2l xs) something happening! qualified constructor names
List A consL : A ! List A ! List A data Vec (A : Set) : ℕ ! Set where nilV : Vec A zero consV : {n : ℕ} ! A ! Vec A n ! Vec A (suc n) v2l : {A : Set} {n : ℕ} ! Vec A n ! List A v2l nilV = nilL v2l (consV x xs) = consL x (v2l xs) something happening! qualified constructor names
List A consL : A ! List A ! List A data Vec (A : Set) : ℕ ! Set where nilV : Vec A zero consV : (n : ℕ) ! A ! Vec A n ! Vec A (suc n) v2l : {A : Set} (n : ℕ) ! Vec A n ! List A v2l zero nilV = nilL v2l (suc n)(consV n x xs) = consL x (v2l n xs) something happening! explicit index args
List A consL : A ! List A ! List A data Vec (A : Set) : ℕ ! Set where nilV : Vec A zero consV : (n : ℕ) ! A ! Vec A n ! Vec A (suc n) v2l : {A : Set} (n : ℕ) ! Vec A n ! List A v2l zero nilV = nilL v2l (suc n)(consV n x xs) = consL x (v2l n xs) something happening! explicit index args
List A cons : A ! List A ! List A data Vec (A : Set) : ℕ ! Set where nil : Vec A zero cons : {n : ℕ} ! A ! Vec A n ! Vec A (suc n) Deriving Inductive Types
: ̣. X ➔ (A ➔ X ➔ X) ➔ X. Vec : ̣ ➔ ℕ ➔ ̣ = λ A n. ∀ X : ℕ ➔ ̣. X zero ➔ (∀ n : ℕ. A ➔ X n ➔ X (suc n)) ➔ X n. nilL : ∀ A : ̣. List A = Λ A X. λ cN cC. cN. nilV : ∀ A : ̣. Vec A zero = Λ A X. λ cN cC. cN. |nilL| = |nilV| = λ cN cC. cN Church-encoding
A X. λ cN cC. cN. nilV : ∀ A : ̣. Vec A zero = Λ A X. λ cN cC. cN. |nilL| = |nilV| = λ cN cC. cN Church-encoding Intersection Types for induction principles Mendler-encoding for efficient predecessors Actually… List : ̣ ➔ ̣ = λ A. ∀ X : ̣. X ➔ (A ➔ X ➔ X) ➔ X. Vec : ̣ ➔ ℕ ➔ ̣ = λ A n. ∀ X : ℕ ➔ ̣. X zero ➔ (∀ n : ℕ. A ➔ X n ➔ X (suc n)) ➔ X n.
: ̣. X ➔ (A ➔ X ➔ X) ➔ X. Vec : ̣ ➔ ℕ ➔ ̣ = λ A n. ∀ X : ℕ ➔ ̣. X zero ➔ (∀ n : ℕ. A ➔ X n ➔ X (suc n)) ➔ X n. nilL : ∀ A : ̣. List A = Λ A X. λ cN cC. cN. nilV : ∀ A : ̣. Vec A zero = Λ A X. λ cN cC. cN. |nilL| = |nilV| = λ cN cC. cN
: ̣. X ➔ (A ➔ X ➔ X) ➔ X. Vec : ̣ ➔ ℕ ➔ ̣ = λ A n. ∀ X : ℕ ➔ ̣. X zero ➔ (∀ n : ℕ. A ➔ X n ➔ X (suc n)) ➔ X n. nilL : ∀ A : ̣. List A = Λ A X. λ cN cC. cN. nilV : ∀ A : ̣. Vec A zero = Λ A X. λ cN cC. cN. A and X erased |nilL| = |nilV| = λ cN cC. cN
: ̣. X ➔ (A ➔ X ➔ X) ➔ X. Vec : ̣ ➔ ℕ ➔ ̣ = λ A n. ∀ X : ℕ ➔ ̣. X zero ➔ (∀ n : ℕ. A ➔ X n ➔ X (suc n)) ➔ X n. consL : ∀ A : ̣. A ➔ List A ➔ List A = Λ A. λ x xs. Λ X. λ cN cC. cC x (xs -X cN cC). consV : ∀ A : ̣. ∀ n : ℕ. A ➔ Vec A n ➔ Vec A (suc n) = Λ A n. λ x xs. Λ X. λ cN cC. cC -n x (xs -X cN cC). |consL| = |consV| = λ x xs cN cC. cC x (xs cN cC) application args n and X erased
: ̣. X ➔ (A ➔ X ➔ X) ➔ X. Vec : ̣ ➔ ℕ ➔ ̣ = λ A n. ∀ X : ℕ ➔ ̣. X zero ➔ (Π n : ℕ. A ➔ X n ➔ X (suc n)) ➔ X n. consL : ∀ A : ̣. A ➔ List A ➔ List A = Λ A. λ x xs. Λ X. λ cN cC. cC x (xs -X cN cC). consV : ∀ A : ̣. Π n : ℕ. A ➔ Vec A n ➔ Vec A (suc n) = Λ A. λ n. λ x xs. Λ X. λ cN cC. cC n x (xs -X cN cC). NO!!! arg n not erased |consL| ≠ |consV| NO!!!
Vec A n ➔ List A = elimVec nilL (λ x ih. consL x ih). Nothing Happening! v2lId : ∀ A : ̣. ∀ n : Nat. Π xs : Vec A n. v2l xs ≃ xs = elimVec β (λ x ih. ρ ih - β). v2l! : ∀ A : ̣. ∀ n : Nat. Vec A n ➔ List A = Λ A n. λ xs. φ (v2lId xs) - (v2l xs) {xs}. extrinsic het. eq.
Vec A n ➔ List A = elimVec nilL (λ x ih. consL x ih). Nothing Happening! v2lId : ∀ A : ̣. ∀ n : Nat. Π xs : Vec A n. v2l xs ≃ xs = elimVec β (λ x ih. ρ ih - β). v2l! : ∀ A : ̣. ∀ n : Nat. Vec A n ➔ List A = Λ A n. λ xs. φ (v2lId xs) - (v2l xs) {xs}. |v2l!| = λ xs. xs
type the identity function (e.g. v2l!, l2v!, appV2appL!, etc.). The type abstraction Id A B represents the existence of an identity function (after erasure) from A to B. Id A B = Π a : A. Σ b : B. b ≃ a. elimId f : A ➔ B |elimId f| = λ x. x f : Id A B extrinsic het. eq.
type the identity function (e.g. v2l!, l2v!, appV2appL!, etc.). The type abstraction Id A B represents the existence of an identity function (after erasure) from A to B. Id A B = Π a : A. Σ b : B. b ≃ a. elimId f : A ➔ B |elimId f| = λ x. x f : Id A B
type the identity function (e.g. v2l!, l2v!, appV2appL!, etc.). The type abstraction Id A B represents the existence of an identity function (after erasure) from A to B. Id A B = Π a : A. Σ b : B. b ≃ a. elimId f : A ➔ B |elimId f| = λ x. x f : Id A B
type the identity function (e.g. v2l!, l2v!, appV2appL!, etc.). The type abstraction Id A B represents the existence of an identity function (after erasure) from A to B. Id A B = Π a : A. Σ b : B. b ≃ a. elimId f : A ➔ B |elimId f| = λ x. x f : Id A B
I. X i ➔ X' i) (Y ➔ Y') Data (Fixpoint Type) Reuse ∀ i : I. Id (IFix I F imapF i) (Fix G imapG) Id-closed combinators allow for data and functions to be reused incrementally, and typing ensures the results of reuse will be zero- cost (i.e., erase to the identity function). Program (Function Type) Reuse Id (∀ i : I. X i ➔ X' i) (Y ➔ Y')
I. X i ➔ X' i) (Y ➔ Y') Data (Fixpoint Type) Reuse ∀ i : I. Id (IFix I F imapF i) (Fix G imapG) Id-closed combinators allow for data and functions to be reused incrementally, and typing ensures the results of reuse will be zero- cost (i.e., erase to the identity function). Program (Function Type) Reuse Id (∀ i : I. X i ➔ X' i) (Y ➔ Y') left-component ( ) erased
∀ A : ̣. ∀ n : Nat. Vec A n ➔ ∀ m : Nat. Vec A m ➔ Vec A (add n m). AppL : ̣ = ∀ A : ̣. List A ➔ List A ➔ List A. // Id (∀ A : ̣. •) (∀ A : ̣. •) copyType (Λ A. // Id (∀ n : Nat. Vec A n ➔ •) (List A ➔ •) allArr2arr len l2v (λ xs. // Id (∀ m : Nat. Vec A m ➔ •) (List A ➔ •) allArr2arr len l2v (λ xs. // Id (Vec A (add (len xs) (len ys))) (List A) v2l)))
∀ A : ̣. ∀ n : Nat. Vec A n ➔ ∀ m : Nat. Vec A m ➔ Vec A (add n m). AppL : ̣ = ∀ A : ̣. List A ➔ List A ➔ List A. // Id (∀ A : ̣. •) (∀ A : ̣. •) copyType (Λ A. // Id (∀ n : Nat. Vec A n ➔ •) (List A ➔ •) allArr2arr len l2v (λ xs. // Id (∀ m : Nat. Vec A m ➔ •) (List A ➔ •) allArr2arr len l2v (λ xs. // Id (Vec A (add (len xs) (len ys))) (List A) v2l)))
∀ A : ̣. ∀ n : Nat. Vec A n ➔ ∀ m : Nat. Vec A m ➔ Vec A (add n m). AppL : ̣ = ∀ A : ̣. List A ➔ List A ➔ List A. // Id (∀ A : ̣. •) (∀ A : ̣. •) copyType (Λ A. // Id (∀ n : Nat. Vec A n ➔ •) (List A ➔ •) allArr2arr len l2v (λ xs. // Id (∀ m : Nat. Vec A m ➔ •) (List A ➔ •) allArr2arr len l2v (λ xs. // Id (Vec A (add (len xs) (len ys))) (List A) v2l)))
∀ A : ̣. ∀ n : Nat. Vec A n ➔ ∀ m : Nat. Vec A m ➔ Vec A (add n m). AppL : ̣ = ∀ A : ̣. List A ➔ List A ➔ List A. // Id (∀ A : ̣. •) (∀ A : ̣. •) copyType (Λ A. // Id (∀ n : Nat. Vec A n ➔ •) (List A ➔ •) allArr2arr len l2v (λ xs. // Id (∀ m : Nat. Vec A m ➔ •) (List A ➔ •) allArr2arr len l2v (λ xs. // Id (Vec A (add (len xs) (len ys))) (List A) v2l)))
∀ A : ̣. ∀ n : Nat. Vec A n ➔ ∀ m : Nat. Vec A m ➔ Vec A (add n m). AppL : ̣ = ∀ A : ̣. List A ➔ List A ➔ List A. // Id (∀ A : ̣. •) (∀ A : ̣. •) copyType (Λ A. // Id (∀ n : Nat. Vec A n ➔ •) (List A ➔ •) allArr2arr len l2v (λ xs. // Id (∀ m : Nat. Vec A m ➔ •) (List A ➔ •) allArr2arr len l2v (λ xs. // Id (Vec A (add (len xs) (len ys))) (List A) v2l)))
for making dependently typed languages more usable, via code reuse without runtime penalty. Conclusion Tutorial tomorrow on dependently typed programming in Cedille! … wrapping up my postdoc at University of Iowa, please talk to me about any positions :)
for making dependently typed languages more usable, via code reuse without runtime penalty. Conclusion Tutorial tomorrow on dependently typed programming in Cedille! … wrapping up my postdoc at University of Iowa, please talk to me about any positions :)
for making dependently typed languages more usable, via code reuse without runtime penalty. Conclusion Tutorial tomorrow on dependently typed programming in Cedille! … wrapping up my postdoc at University of Iowa, please talk to me about any positions :)
Cedille • Enriching direction of reuse • Case study: Reuse between untyped and intrinsically typed STLC terms • Comparisons to related work like ornaments and dependent interoperability In The Paper
List A cons : A ! List A ! List A data Vec (A : Set) : ℕ ! Set where nil : Vec A zero cons : {n : ℕ} ! A ! Vec A n ! Vec A (suc n) v2l : {A : Set} {n : ℕ} ! Vec A n ! List A v2l nil = nil v2l (cons x xs) = cons x (v2l xs) appV2appL : AppV ! AppL appV2appL appV xs ys = v2l (appV (l2v xs) (l2v ys)) nothing happening?