positively dependent types
play

Positively Dependent Types Dan Licata and Robert Harper Carnegie - PowerPoint PPT Presentation

Positively Dependent Types Dan Licata and Robert Harper Carnegie Mellon University 1 Dans thesis New dependently typed programming language for programming with binding and scope Applications: Domain-specific logics for reasoning about


  1. Positively Dependent Types Dan Licata and Robert Harper Carnegie Mellon University 1

  2. Dan’s thesis New dependently typed programming language for programming with binding and scope Applications: Domain-specific logics for reasoning about code Mechanized metatheory 2

  3. Dan’s thesis New dependently typed programming language for programming with binding and scope Applications: Domain-specific logics for reasoning about code Mechanized metatheory Based on polarized type theory 2

  4. Polarity [Girard ’93] Sums A + B are positive data: Introduced by choosing inl or inr Eliminated by pattern-matching ML functions A → B are negative computation: Introduced by pattern-matching on A Eliminated by choosing an A to apply to 3

  5. Focusing [Andreoli ’92] Sums A + B are positive data: Introduced by choosing inl or inr Eliminated by pattern-matching ML functions A → B are negative computation: Introduced by pattern-matching on A Eliminated by choosing an A to apply to 4

  6. Focusing [Andreoli ’92] Sums A + B are positive data: Focus = make choices Introduced by choosing inl or inr Eliminated by pattern-matching ML functions A → B are negative computation: Introduced by pattern-matching on A Eliminated by choosing an A to apply to 4

  7. Focusing [Andreoli ’92] Sums A + B are positive data: Introduced by choosing inl or inr Eliminated by pattern-matching ML functions A → B are negative computation: Introduced by pattern-matching on A Eliminated by choosing an A to apply to 5

  8. Focusing [Andreoli ’92] Sums A + B are positive data: Inversion = respond to all Introduced by choosing inl or inr possible choices Eliminated by pattern-matching ML functions A → B are negative computation: Introduced by pattern-matching on A Eliminated by choosing an A to apply to 5

  9. Higher-order focusing Zeilberger’s higher-order formalism: Type theory organized around distinction between positive data and negative computation Positive Data Negative Computation products (eager) products (lazy) sums functions natural numbers streams inductive types coinductive types 6

  10. Higher-order focusing Zeilberger’s higher-order formalism: Type theory organized around distinction between positive data and negative computation Pattern matching represented abstractly by meta-level functions from patterns to expressions, using an iterated inductive definition 7

  11. Higher-order focusing Applications so far: 8

  12. Higher-order focusing Applications so far: Curry-Howard for pattern matching [Zeilberger POPL’08; cf. Krishnaswami POPL’09] 8

  13. Higher-order focusing Applications so far: Curry-Howard for pattern matching [Zeilberger POPL’08; cf. Krishnaswami POPL’09] Logical account of evaluation order [Zeilberger APAL] 8

  14. Higher-order focusing Applications so far: Curry-Howard for pattern matching [Zeilberger POPL’08; cf. Krishnaswami POPL’09] Logical account of evaluation order [Zeilberger APAL] Analysis of operationally sensitive typing phenomena [Zeilberger PLPV’09] 8

  15. Higher-order focusing Applications so far: Curry-Howard for pattern matching [Zeilberger POPL’08; cf. Krishnaswami POPL’09] Logical account of evaluation order [Zeilberger APAL] Analysis of operationally sensitive typing phenomena [Zeilberger PLPV’09] Positive function space for representing variable binding [LZH LICS’08] 8

  16. Positive function space Permits LF-style representation of binding: framework provides α -equivalence, substitution Eliminated by pattern matching = structural induction modulo α 9

  17. Positive function space Permits LF-style representation of binding: framework provides α -equivalence, substitution Eliminated by pattern matching = structural induction modulo α But no dependent types... 9

  18. Positively dependent types Contributions: 1. Extend higher-order focusing with a simple form of dependency 2. Formalize the language in Agda 10

  19. Positively dependent types Key idea: Allow dependency on positive data, but not negative computation 11

  20. Positively dependent types Key idea: Allow dependency on positive data, but not negative computation Enough for simple applications: Lists indexed by their lengths ( Vec[n:nat] ) Judgements on higher-order abstract syntax represented with positive functions 11

  21. Positively dependent types Key idea: Allow dependency on positive data, but not negative computation Avoids complications of negative dependency: Equality is easy for data, hard for computation Computations are free to be effectful 12

  22. Positively dependent types 1. Type and term levels share the same data (like Agda, Epigram, Cayenne, NuPRL, …) 2. But have different notions of computation (like DML, Omega, ATS, …) 13

  23. Polarized type theory Intuitionistic logic: A + ::= nat | A + ⊗ B + | 1 | A + ⊕ B + | 0 | ↓ A - A - ::= A + → B - | A - & B - | ⊤ | ↑ A + 14

  24. Polarized type theory Intuitionistic logic: A + ::= nat | A + ⊗ B + | 1 | A + ⊕ B + | 0 | ↓ A - A - ::= A + → B - | A - & B - | ⊤ | ↑ A + Allow dependency on values of purely positive types (no ↓ A - ) 14

  25. Polarized type theory Intuitionistic logic (see paper): A + ::= nat | A + ⊗ B + | 1 | A + ⊕ B + | 0 | ↓ A - A - ::= A + → B - | A - & B - | ⊤ | ↑ A + Minimal logic (this talk): A + ::= nat | A + ⊗ B + | 1 | A + ⊕ B + | 0 | ¬ A + Purely positive types: no ¬A + ( = ↓ (A + → #) ) 15

  26. Outline 1. Simply typed higher-order focusing 2. Positively dependent types 16

  27. Outline 1. Simply typed higher-order focusing 2. Positively dependent types 17

  28. Higher-order focusing Specify types by their patterns Type-independent focusing framework Focus phase = choose a pattern Inversion phase = pattern-matching 18

  29. Higher-order focusing Specify types by their patterns Type-independent focusing framework Focus phase = choose a pattern Inversion phase = pattern-matching 19

  30. Patterns Proof pattern gives us the outline of a proof, but leaves holes for refutations B false A false ¬B true ¬A true ¬B ⊕ ¬C true ¬A ⊗ (¬B ⊕ ¬C) true 20

  31. Patterns A 1 false, ..., A n false ⊩ A true 21

  32. Patterns A 1 false, ..., A n false ⊩ A true Δ Δ ⊩ A true : there is a proof pattern for A, leaving holes for refutations of A 1 ... A n 21

  33. Pattern rules A false ⊩ ¬A true Δ ₁ ⊩ A true Δ ₂ ⊩ B true ∙ ⊩ 1 true Δ ₁ Δ ₂ ⊩ A ⊗ B true Δ ⊩ A true Δ ⊩ B true (no rule for 0) Δ ⊩ A ⊕ B true Δ ⊩ A ⊕ B true 22

  34. Proof terms B false ⊩ ¬B true B false ⊩ ¬B ⊕ ¬C true A false ⊩ ¬A true A false, B false ⊩ ¬A ⊗ (¬B ⊕ ¬C) true ≈ ( κ ₁ , inl κ ₂ ) continuation variables

  35. Proof terms κ 2 B false ⊩ ¬B true inl κ ₁ B false ⊩ ¬B ⊕ ¬C true A false ⊩ ¬A true (_,_) A false, B false ⊩ ¬A ⊗ (¬B ⊕ ¬C) true ≈ ( κ ₁ , inl κ ₂ ) continuation variables

  36. Higher-order focusing Specify types by their patterns Type-independent focusing framework Focus phase = choose a pattern Inversion phase = pattern-matching 24

  37. Focused proofs iterated inductive definition Δ ⊩ A true Γ ⊢ Δ Δ ⊩ A true Γ , Δ ⊢ # Γ ⊢ A true Γ ⊢ A false A false ∊ Δ Γ ⊢ A false A false ∊ Δ Γ ⊢ A true Γ ⊢ Δ Γ ⊢ #

  38. Focused proofs iterated inductive definition Δ ⊩ A true Γ ⊢ Δ Δ ⊩ A true Γ , Δ ⊢ # Γ ⊢ A true Γ ⊢ A false focus inversion A false ∊ Δ Γ ⊢ A false A false ∊ Δ Γ ⊢ A true Γ ⊢ Δ Γ ⊢ #

  39. K :: Γ K :: Γ A false A false Example continuation p E Δ ⊩ ¬A ⊗ (¬B ⊕ ¬C) true Γ , Δ ⊢ # K deriv. of Γ ⊢ ¬A ⊗ (¬B ⊕ ¬C) false 26

  40. K :: Γ K :: Γ A false A false Example continuation p E Δ ⊩ ¬A ⊗ (¬B ⊕ ¬C) true Γ , Δ ⊢ # K deriv. of Γ ⊢ ¬A ⊗ (¬B ⊕ ¬C) false { E 1 ( κ ₁ , inl κ ₂ ) ↦ Γ , κ ₁ : A false, κ 2 : B false, ⊢ # K E 2 ( κ ₁ , inr κ 3 ) ↦ Γ , κ ₁ : A false, κ 3 : C false, ⊢ # 26

  41. Outline 1. Simply typed higher-order focusing 2. Positively dependent types 27

  42. Higher-order focusing all the changes are here Specify types by their patterns Type-independent focusing framework Focus phase = choose a pattern Inversion phase = pattern-matching 28

  43. Positively dependent types 1. Allow indexing by closed patterns = values of purely positive types 29

  44. Patterns Δ ⊩ nat true nat : z s ∙ ⊩ nat true Δ ⊩ nat true 30

  45. Patterns Δ ⊩ nat true nat : z s ∙ ⊩ nat true Δ ⊩ nat true vec[ p :: ∙ ⊩ nat true ]: nil ∙ ⊩ vec[z] true Δ 1 ⊩ bool true Δ 2 ⊩ vec[ p ] true cons Δ 1 Δ 2 ⊩ vec[s p ] true 30

  46. Positively dependent types 1. Allow indexing by closed patterns = values of purely positive types 2. Syntax of ( Σ x:A.B) specified by pattern-matching: gives type-level computation (large eliminations) 31

  47. Dependent pairs p A type [] ⊩ A true τ (p) type Σ A τ type 32

  48. Dependent pairs p A type [] ⊩ A true τ (p) type Σ A τ type p ∙ ⊩ A true Δ ⊩ τ (p) true pair Δ ⊩ Σ A τ true 32

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend