Coinduction in Agda via Copatterns and Sized Types Andreas Abel - - PowerPoint PPT Presentation

coinduction in agda via copatterns and sized types
SMART_READER_LITE
LIVE PREVIEW

Coinduction in Agda via Copatterns and Sized Types Andreas Abel - - PowerPoint PPT Presentation

Coinduction in Agda via Copatterns and Sized Types Andreas Abel Department of Computer Science and Engineering Chalmers and Universitt Gteborg Dagstuhl Seminar 16131 Language Based Verification Tools for Functional Programs 30 March 2016


slide-1
SLIDE 1

Coinduction in Agda via Copatterns and Sized Types

Andreas Abel

Department of Computer Science and Engineering Chalmers and Universität Göteborg

Dagstuhl Seminar 16131 Language Based Verification Tools for Functional Programs 30 March 2016

Andreas Abel (GU) Coinduction via Copatterns Dagstuhl 16131 1 / 7

slide-2
SLIDE 2

Agda’s new coinduction

Type-based termination using sized types (1996-). Overcome limits of syntactic termination checking. Workarounds for inductive case: measures, well-founded relations. Don’t work for coinductive case (productivity checking). Copattern matching was invented for type-based productivity checking. Corecursion via copattern matching dualizes recursion via pattern matching. Foundations: new article Abel/Pientka JFP 2016.

Andreas Abel (GU) Coinduction via Copatterns Dagstuhl 16131 2 / 7

slide-3
SLIDE 3

Languages (infinite tries)

Lang ∼ = Bool × (A → Lang) Coinductive tries Lang defined via observations/projections ν and δ: Lang is the greatest type consistent with these rules: l : Lang ν l : Bool l : Lang a : A δ l a : Lang Empty language ∅ : Lang. Language of the empty word ε : Lang defined by copattern matching: ν ε = true δ ε a = ∅

Andreas Abel (GU) Coinduction via Copatterns Dagstuhl 16131 3 / 7

slide-4
SLIDE 4

Corecursion

Empty language ∅ : Lang defined by corecursion: ν ∅ = false δ ∅ a = ∅ Language union k ∪ l is pointwise disjunction: ν (k ∪ l) = ν k ∨ ν l δ (k ∪ l) a = δ k a ∪ δ l a Language composition k · l à la Brzozowski: ν (k · l) = ν k ∧ ν l δ (k · l) a = (δ k a · l) ∪ δ l a if ν k (δ k a · l)

  • therwise

Not accepted because ∪ is not a constructor.

Andreas Abel (GU) Coinduction via Copatterns Dagstuhl 16131 4 / 7

slide-5
SLIDE 5

Sized coinductive types

Lang i ∼ = Bool × (∀j<i. A → Lang j) l : Lang i ν l : Bool l : Lang i j < i a : A δ l {j} a : Lang j ∅ : ∀i. Lang i by copatterns and induction on i: ν (∅ {i}) = false δ (∅ {i}) {j} a = ∅ {j}

Andreas Abel (GU) Coinduction via Copatterns Dagstuhl 16131 5 / 7

slide-6
SLIDE 6

Type-based guardedness checking

Union preserves size/guardeness: k : Lang i l : Lang i k ∪ l : Lang i ν (k ∪ l) = ν k ∨ ν l δ (k ∪ l) {j} a = δ k {j} a ∪ δ l {j} a Composition is accepted and also guardedness-preserving: k : Lang i l : Lang i k · l : Lang i ν (k · l) = ν k ∧ ν l δ (k · l) {j} a = (δ k {j} a · l) ∪ δ l {j} a if ν k (δ k {j} a · l)

  • therwise

Andreas Abel (GU) Coinduction via Copatterns Dagstuhl 16131 6 / 7

slide-7
SLIDE 7

Bisimilarity

Equality of infinite tries is defined coinductively. _ ∼ = _ is the greatest relation consistent with l ∼ = k ν l = ν k l ∼ = k a : A δ l a ∼ = δ k a Equivalence relation. Congruence for language constructions. k ∼ = k′ l ∼ = l′ (k ∪ k′) ∼ = (l ∪ l′) Prove language laws: (k ∪ l) · m ∼ = (k · m) ∪ (l · m)

Andreas Abel (GU) Coinduction via Copatterns Dagstuhl 16131 7 / 7