[論文レビュー] A Quantitative Understanding of Pattern Matching
本稿では、ペアのパターンマッチを伴う$λ$-計算に対して、資源に配慮した型システム$τ\mathscr{U}$と$τ\mathscr{E}$を導入する。非冪等交差型と装飾付き型推論順序を用いることで、$τ\mathscr{E}$はヘッド正規化列の長さおよび正規形のサイズの正確な上限を提供する。時間(還元ステップ)と空間(項のサイズ)を別々のカウンタ(β、代入、マッチングステップ)で区別することで、両者の区別を明確にする。
This paper shows that the recent approach to quantitative typing systems for programming languages can be extended to pattern matching features. Indeed, we define two resource aware type systems, named U and E, for a lambda-calculus equipped with pairs for both patterns and terms. Our typing systems borrow some basic ideas from [BKRDR15], which characterises (head) normalisation in a qualitative way, in the sense that typability and normalisation coincide. But in contrast to [BKRDR15], our (static) systems also provides quantitative information about the dynamics of the calculus. Indeed, system U provides upper bounds for the length of normalisation sequences plus the size of their corresponding normal forms, while system E, which can be seen as a refinement of system U, produces exact bounds for each of them. This is achieved by means of a non-idempotent intersection type system equipped with different technical tools. First of all, we use product types to type pairs, instead of the disjoint unions in [BKRDR15], thus avoiding an overlap between "being a pair" and "being duplicable", resulting in an essential tool to reason about quantitativity. Secondly, typing sequents in system E are decorated with tuples of integers, which provide quantitative information about normalisation sequences, notably time (c.f. length) and space (c.f. size). Another key tool of system E is that the type system distinguishes between consuming (contributing to time) and persistent (contributing to space) constructors. Moreover, the time resource information is remarkably refined, because it discriminates between different kinds of reduction steps performed during evaluation, so that beta reduction, substitution and matching steps are counted separately.
研究の動機と目的
- λ-計算と現代の関数型言語の間の概念的ギャップを埋めるために、パターンマッチを構文的糖衣ではなく、ネイティブにモデル化すること。
- 定量的型システムをパターンマッチに拡張し、単なる終了保証に加え、計算資源の正確な上限を提供すること。
- 正規化列における時間(還元ステップ)と空間(項のサイズ)を区別することで、資源会計を精緻化すること。
- β還元、代入、マッチングといった異なる種類の還元ステップを個別に追跡できる型システムを構築すること。
- 装飾付き順序を用いて、型推論の導出と評価の動的挙動との間に明確な形式的リンクを確立すること。
提案手法
- システム$τ\mathscr{U}$は、非冪等交差型と積型を用いてペアを型付けし、「ペアであること」と「複製可能であること」の重複を回避する。
- $τ\mathscr{E}$の型推論順序は、時間(βステップ)、空間(代入ステップ)、マッチングステップ、最終サイズを表すタプル$(b, e, m, f)$で装飾される。
- システムは、時間に影響を与えるコンストラクタ(消費型)と、空間に影響を与えるコンストラクタ(恒久型)を区別し、正確な資源追跡を可能にする。
- 還元ステップは個別にカウントされる:β還元、代入、パターンマッチングはそれぞれ装飾の異なる成分で追跡される。
- 型システムは、導出のサイズが正規化列の長さに一致し、構造が正規形のサイズを符号化するという、新しい形式の型推論導出を用いる。
- 主な技術的イノベーションは、還元規則に従って変化するカウンタを備えたマルチセット型システムの使用であり、正確な上限を保証する。
実験結果
リサーチクエスチョン
- RQ1定量的型システムは、$λ$-計算においてパターンマッチをネイティブに扱えるように拡張可能か?
- RQ2このようなシステムは、ヘッド正規化列の長さと、その結果得られる正規形のサイズの両方について正確な上限を提供可能か?
- RQ3β還元、代入、マッチングといった異なる種類の還元ステップを、型システム内で個別に区別し、カウント可能か?
- RQ4消費型コンストラクタと恒久型コンストラクタの区別を、型システム内で形式化可能か? これにより、時間と空間の上限を精緻化できるか?
- RQ5型推論導出のサイズを用いて、ステップ数と最終項のサイズの両方を正確に予測可能か?
主な発見
- システム$τ\mathscr{U}$は、ヘッド正規化列の長さおよびその正規形のサイズの上界を提供する。
- システム$τ\mathscr{E}$は、正規化列の長さおよび正規形のサイズの両方について正確な上限を提供し、過剰近似がない。
- システム$τ\mathscr{E}$は、β還元、代入、パターンマッチングという3種類の還元ステップを区別し、それぞれが時間カウンタに寄与する。
- $τ\mathscr{E}$の時間カウンタは、各ステップタイプの寄与を個別に追跡するように精緻化されており、正確な動的解析を可能にする。
- $τ\mathscr{E}$における型推論導出のサイズは、ヘッド正規化列の長さに正確に一致し、最終的な装飾は正規形のサイズを反映する。
- 直積型を直和型の代わりに用いることで、「ペアであること」と「複製可能であること」の概念的重複を回避し、定量的推論をより明確にする。
より良い研究を、今すぐ始めましょう
論文の読解から最終レビューまで、研究時間を劇的に削減しましょう。
クレジットカード登録不要
このレビューはAIが作成し、人間の編集者が確認しました。