Contract lenses: Reasoning about bidirectional programs via calculation

被引:1
|
作者
Zhang, Hanliang [1 ]
Tang, Wenhao [2 ]
Xie, Ruifeng [3 ]
Wang, Meng [1 ]
Hu, Zhenjiang [3 ]
机构
[1] Univ Bristol, Bristol BS8 1QU, England
[2] Univ Edinburgh, Edinburgh EH8 9AB, Scotland
[3] Peking Univ, Beijing, Peoples R China
关键词
Bidirectional transformation - Clear specifications - Combinator - Construction approaches - Correct-by-construction - Correctness by construction - Equational reasoning - Multiple representation - Optimisations - Program calculation;
D O I
10.1017/S0956796823000059
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Bidirectional transformations (BXs) are a mechanism for maintaining consistency between multiple representations of related data. The lens framework, which usually constructs BXs from lens combinators, has become the mainstream approach to BX programming because of its modularity and correctness by construction. However, the involved bidirectional behaviors of lenses make the equational reasoning and optimization of them much harder than unidirectional programs. We propose a novel approach to deriving efficient lenses from clear specifications via program calculation, a correct-by-construction approach to reasoning about functional programs by algebraic laws. To support bidirectional program calculation, we propose contract lenses, which extend conventional lenses with a pair of predicates to enable safe and modular composition of partial lenses. We define several contract-lens combinators capturing common computation patterns including $\textit{fold}, \textit{filter},\textit{map}$, and $\textit{scan}$, and develop several bidirectional calculation laws to reason about and optimize contract lenses. We demonstrate the effectiveness of our new calculation framework based on contract lenses with nontrivial examples.
引用
收藏
页数:41
相关论文
共 50 条
  • [1] REASONING ABOUT PROGRAMS
    WALDINGER, RJ
    LEVITT, KN
    ARTIFICIAL INTELLIGENCE, 1974, 5 (03) : 235 - 316
  • [2] Reasoning about Nondeterminism in Programs
    Cook, Byron
    Koskinen, Eric
    ACM SIGPLAN NOTICES, 2013, 48 (06) : 219 - 229
  • [3] Reasoning about Graph Programs
    Plump, Detlef
    ELECTRONIC PROCEEDINGS IN THEORETICAL COMPUTER SCIENCE, 2016, (225): : 35 - 44
  • [4] Statistical Reasoning About Programs
    Boehme, Marcel
    2022 ACM/IEEE 44TH INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING: NEW IDEAS AND EMERGING RESULTS (ICSE-NIER 2022), 2022, : 76 - 80
  • [5] REASONING ABOUT PROGRAMS WITH EFFECTS
    MASON, I
    TALCOTT, C
    LECTURE NOTES IN COMPUTER SCIENCE, 1990, 456 : 189 - 203
  • [6] Reasoning About Choreographic Programs
    Cruz-Filipe, Luis
    Graversen, Eva
    Montesi, Fabrizio
    Peressotti, Marco
    COORDINATION MODELS AND LANGUAGES, COORDINATION 2023, 2023, 13908 : 144 - 162
  • [7] Reasoning about programs via operational semantics: requirements for a support system
    Hughes, John R. D.
    Jones, Cliff B.
    AUTOMATED SOFTWARE ENGINEERING, 2008, 15 (3-4) : 299 - 312
  • [8] Reasoning about programs via operational semantics: requirements for a support system
    John R. D. Hughes
    Cliff B. Jones
    Automated Software Engineering, 2008, 15 : 299 - 312
  • [9] REASONING ABOUT PROBABILISTIC PARALLEL PROGRAMS
    RAO, JR
    ACM TRANSACTIONS ON PROGRAMMING LANGUAGES AND SYSTEMS, 1994, 16 (03): : 798 - 842
  • [10] Reasoning about Recursive Probabilistic Programs
    Olmedo, Federico
    Kaminski, Benjamin Lucien
    Katoen, Joost-Pieter
    Matheja, Christoph
    PROCEEDINGS OF THE 31ST ANNUAL ACM-IEEE SYMPOSIUM ON LOGIC IN COMPUTER SCIENCE (LICS 2016), 2016, : 672 - 681