Skip to main content
QUICK REVIEW

[논문 리뷰] A Quantitative Understanding of Pattern Matching

Sandra Alves, Delia Kesner|arXiv (Cornell University)|2019. 12. 04.
Logic, programming, and type systems참고 문헌 33인용 수 4
한 줄 요약

이 논문은 쌍에 대한 패턴 매칭을 지원하는 $λ$-계산법에 대해 자원 인지형 타입 체계 $τ\mathscr{U}$와 $τ\mathscr{E}$를 제안한다. 비가역적 교차 타입과 장식된 타입 순서를 사용함으로써, $τ\mathscr{E}$는 헤드 정규화 순서의 길이와 정규형의 크기에 대한 정확한 경계를 제공하며, 별도의 카운터를 통해 베타, 치환, 매칭 단계에 대한 시간(감소 단계)과 공간(항의 크기)을 구분한다.

ABSTRACT

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}$는 세 가지 종류의 감소 단계—베타 감소, 치환, 패턴 매칭—을 구분하며, 각각 시간 카운터에 기여함.
  • $τ\mathscr{E}$의 시간 카운터는 각 단계 유형의 기여도를 별도로 추적하여 정밀한 동적 분석을 가능하게 함.
  • $τ\mathscr{E}$에서 타입 유도의 크기는 정확히 헤드 정규화 순서의 길이와 일치하며, 최종 장식은 정규형의 크기를 반영함.
  • 합집합 타입 대신 곱 타입을 사용함으로써 '쌍이 되는 것'과 '복제 가능한 것' 간의 개념적 겹침을 피함으로써 자원의 정량적 분석에 더 깔끔한 이론적 기초를 제공함.

더 나은 연구,지금 바로 시작하세요

논문 읽기부터 검토까지, 연구 시간을 획기적으로 줄여보세요.

카드 등록 없음 · 무료 플랜 제공

이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.