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 条
  • [41] Faulty Logic: Reasoning about Fault Tolerant Programs
    Meola, Matthew L.
    Walker, David
    PROGRAMMING LANGUAGES AND SYSTEMS, PROCEEDINGS, 2010, 6012 : 468 - 487
  • [42] Reasoning about plan revision in BDI agent programs
    Alechina, Natasha
    Dastani, Mehdi
    Logan, Brian
    Meyer, John-Jules Ch
    THEORETICAL COMPUTER SCIENCE, 2011, 412 (44) : 6115 - 6134
  • [43] A Sequential Model for Reasoning about Bargaining in Logic Programs
    Chen, Wu
    Zhang, Dongmo
    Wu, Maonian
    LOGIC PROGRAMMING AND NONMONOTONIC REASONING (LPNMR 2013), 2013, 8148 : 239 - 244
  • [44] Formal Reasoning About Lazy-STM Programs
    李勇
    张昱
    陈意云
    付明
    Journal of Computer Science & Technology, 2010, 25 (04) : 841 - 852
  • [45] REASONING ABOUT COMPLEXITY OF OBJECT-ORIENTED PROGRAMS
    SCHMIDT, HW
    ZIMMERMANN, W
    PROGRAMMING CONCEPTS, METHODS AND CALCULI, 1994, 56 : 553 - 572
  • [46] Reasoning about CBV functional programs in Isabelle/HOL
    Longley, J
    Pollack, R
    THEOREM PROVING IN HIGHER ORDER LOGICS, PROCEEDINGS, 2004, 3223 : 201 - 216
  • [47] The early search for tractable ways of reasoning about programs
    Jones, CB
    IEEE ANNALS OF THE HISTORY OF COMPUTING, 2003, 25 (02) : 26 - 49
  • [48] Continuously Reasoning about Programs using Differential Bayesian Inference
    Heo, Kihong
    Raghothaman, Mukund
    Si, Xujie
    Naik, Mayur
    PROCEEDINGS OF THE 40TH ACM SIGPLAN CONFERENCE ON PROGRAMMING LANGUAGE DESIGN AND IMPLEMENTATION (PLDI '19), 2019, : 561 - 575
  • [49] Example-Based Reasoning about the Realizability of Polymorphic Programs
    Mulleners, Niek
    Jeuring, Johan
    Heeren, Bastiaan
    PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL, 2024, 8 (ICFP): : 317 - 337
  • [50] Representing and reasoning about concurrent actions with abductive logic programs
    Renwei Li
    Luís Moniz Pereira
    Annals of Mathematics and Artificial Intelligence, 1997, 21 : 245 - 303