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 条
  • [31] Reasoning about reasoning by nested conditioning: Modeling theory of mind with probabilistic programs
    Stuhlmueller, A.
    Goodman, N. D.
    COGNITIVE SYSTEMS RESEARCH, 2014, 28 : 80 - 99
  • [32] Reasoning about probabilistic sequential programs in a probabilistic logic
    M. Ying
    Acta Informatica, 2003, 39 : 315 - 389
  • [33] Panelist position statement: reasoning about the design of programs
    Jones, CB
    PHILOSOPHICAL TRANSACTIONS OF THE ROYAL SOCIETY A-MATHEMATICAL PHYSICAL AND ENGINEERING SCIENCES, 2005, 363 (1835): : 2395 - 2396
  • [34] Reasoning about probabilistic sequential programs in a probabilistic logic
    Ying, MS
    ACTA INFORMATICA, 2003, 39 (05) : 315 - 389
  • [35] Formal Reasoning About Lazy-STM Programs
    Li, Yong
    Zhang, Yu
    Chen, Yi-Yun
    Fu, Ming
    JOURNAL OF COMPUTER SCIENCE AND TECHNOLOGY, 2010, 25 (04) : 841 - 852
  • [36] Reasoning About TSO Programs Using Reduction and Abstraction
    Bouajjani, Ahmed
    Enea, Constantin
    Mutluergil, Suha Orhun
    Tasiran, Serdar
    COMPUTER AIDED VERIFICATION, CAV 2018, PT II, 2018, 10982 : 336 - 353
  • [37] ILC: A foundation for automated reasoning about pointer programs
    Jia, LM
    Walker, D
    PROGRAMMING LANGUAGES AND SYSTEMS, PROCEEDINGS, 2006, 3924 : 131 - 145
  • [38] Formal Reasoning About Lazy-STM Programs
    Yong Li
    Yu Zhang
    Yi-Yun Chen
    Ming Fu
    Journal of Computer Science and Technology, 2010, 25 : 841 - 852
  • [39] A beginner's course on reasoning about imperative programs
    Lau, KK
    TEACHING FORMAL METHODS, PROCEEDINGS, 2004, 3294 : 1 - 16
  • [40] Reasoning About Partial Functions in the Formal Development of Programs
    Jones, Cliff B.
    ELECTRONIC NOTES IN THEORETICAL COMPUTER SCIENCE, 2006, 145 : 3 - 25