Bidirectional transformation: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Citation bot (talk | contribs)
Removed proxy/dead URL that duplicated identifier. Removed access-date with no URL. | Use this bot. Report bugs. | Suggested by BOZ | Linked from User:BOZ/sandbox-temp | #UCB_webform_linked 9/33
m expanded citation details
 
Line 1: Line 1:
{{Short description|Computer programs able to produce inputs from outputs}}
{{Short description|Computer programs able to produce inputs from outputs}}
{{use dmy dates |date=February 2024}}
In [[computer programming]], '''bidirectional transformations (bx)''' are programs in which a single piece of code can be run in several ways, such that the same data are sometimes considered as input, and sometimes as output. For example, a bx run in the forward direction might transform input I into output O, while the same bx run backward would take as input versions of I and O and produce a new version of I as its output.
In [[computer programming]], '''bidirectional transformations (bx)''' are programs in which a single piece of code can be run in several ways, such that the same data are sometimes considered as input, and sometimes as output. For example, a bx run in the forward direction might transform input I into output O, while the same bx run backward would take as input versions of I and O and produce a new version of I as its output.


[[Model transformation#Unidirectional versus bidirectional|Bidirectional model transformations]] are an important special case in which a model is input to such a program.
[[Model transformation#Unidirectional versus bidirectional|Bidirectional model transformations]] are an important special case in which a model is input to such a program.


Some bidirectional languages are [[Bijection|''bijective'']]. The bijectivity of a language is a severe restriction of its power,<ref name="nate-foster">{{Cite web |url=http://grace.gsdlab.org/images/e/e2/Nate-short.pdf |title=Archived copy |access-date=2011-02-07 |archive-url=https://web.archive.org/web/20110726133528/http://grace.gsdlab.org/images/e/e2/Nate-short.pdf |archive-date=2011-07-26 |url-status=dead }}</ref> because a bijective language is merely relating two different ways to present the very same information.
Some bidirectional languages are [[Bijection|''bijective'']]. The bijectivity of a language is a severe restriction of its power,<ref name="nate-foster">{{Cite web |url=http://grace.gsdlab.org/images/e/e2/Nate-short.pdf |title=Semantics of Bidirectional Languages |access-date=2011-02-07 |archive-url=https://web.archive.org/web/20110726133528/http://grace.gsdlab.org/images/e/e2/Nate-short.pdf |archive-date=2011-07-26 |url-status=dead |first=Nate |last=Foster}}</ref> because a bijective language is merely relating two different ways to present the very same information.


More general is a lens language, in which there is a distinguished forward direction ("get") that takes a concrete input to an abstract output, discarding some information in the process: the concrete state includes all the information that is in the abstract state, and usually some more. The backward direction ("put") takes a concrete state and an abstract state and computes a new concrete state. Lenses are required to obey certain conditions to ensure sensible behaviour.
More general is a lens language, in which there is a distinguished forward direction ("get") that takes a concrete input to an abstract output, discarding some information in the process: the concrete state includes all the information that is in the abstract state, and usually some more. The backward direction ("put") takes a concrete state and an abstract state and computes a new concrete state. Lenses are required to obey certain conditions to ensure sensible behaviour.
Line 14: Line 15:
Bidirectional transformations can be used to:
Bidirectional transformations can be used to:


* Maintain the consistency of several sources of information<ref name="grace-report">http://www.cs.cornell.edu/~jnfoster/papers/grace-report.pdf {{Bare URL PDF|date=March 2022}}</ref>
* Maintain the consistency of several sources of information<ref name="grace-report">{{cite web |url=http://www.cs.cornell.edu/~jnfoster/papers/grace-report.pdf |title=Bidirectional Transformations: A Cross-Discipline Perspective |first1=Krzysztof |last1=Czarnecki |first2=J. Nathan |last2=Foster |first3=Zhenjiang |last3=Hu |first4=Ralf |last4=Lämmel |first5=Andy |last5=Schürr |first6=James F. |last6=Terwilliger |access-date=19 February 2024}}</ref>
* Provide an 'abstract view' to easily manipulate data and write them back to their source
* Provide an 'abstract view' to easily manipulate data and write them back to their source


Line 37: Line 38:
* [[Boomerang (programming language)|Boomerang]] is a [[programming language]] that allows writing lenses to process text data formats bidirectionally
* [[Boomerang (programming language)|Boomerang]] is a [[programming language]] that allows writing lenses to process text data formats bidirectionally
* [[Augeas (software)|Augeas]] is a configuration management library whose lens language is inspired by the Boomerang project
* [[Augeas (software)|Augeas]] is a configuration management library whose lens language is inspired by the Boomerang project
* ''biXid'' is a programming language for processing [[XML]] data bidirectionally<ref name="bixid">{{Cite web |url=http://arbre.is.s.u-tokyo.ac.jp/~hahosoya/papers/bixid.pdf |title=Archived copy |access-date=2011-02-07 |archive-url=https://web.archive.org/web/20070702195028/http://arbre.is.s.u-tokyo.ac.jp/~hahosoya/papers/bixid.pdf |archive-date=2007-07-02 |url-status=dead }}</ref>
* ''biXid'' is a programming language for processing [[XML]] data bidirectionally<ref name="bixid">{{Cite web |url=http://arbre.is.s.u-tokyo.ac.jp/~hahosoya/papers/bixid.pdf |title=biXid: A Bidirectional Transformation Language for XML |access-date=2011-02-07 |archive-url=https://web.archive.org/web/20070702195028/http://arbre.is.s.u-tokyo.ac.jp/~hahosoya/papers/bixid.pdf |archive-date=2007-07-02 |url-status=dead |first1=Shinya |last1=KAWANAKA |first2=Haruo |last2=HOSOYA |date=2006 |doi=10.1145/1160074.1159830}}</ref>
* ''XSugar'' allows translation from XML to non-XML formats<ref name="xsugar">{{Cite web|url=http://www.brics.dk/xsugar/|title=XSugar - Dual Syntax for XML Languages}}</ref>
* ''XSugar'' allows translation from XML to non-XML formats<ref name="xsugar">{{Cite web|url=http://www.brics.dk/xsugar/|title=XSugar - Dual Syntax for XML Languages |website=brics.dk |access-date=19 February 2024}}</ref>


== See also ==
== See also ==
Line 50: Line 51:


== External links ==
== External links ==
* {{Webarchive|url=https://web.archive.org/web/20141012223700/http://grace.gsdlab.org/index.php?title=Main_Page|date=12 October 2014|title=GRACE International Meeting on Bidirectional Transformations}}
* {{cite web |archive-url=https://web.archive.org/web/20141012223700/http://grace.gsdlab.org/index.php?title=Main_Page|archive-date=12 October 2014|title=GRACE International Meeting on Bidirectional Transformations |url=http://grace.gsdlab.org/index.php?title=Main_Page}}
* [http://bx-community.wikidot.com/ Bidirectional Transformations: The Bx Wiki]
* {{cite web |url=http://bx-community.wikidot.com/ |title=Bidirectional Transformations |website=The Bx Wiki |access-date=19 February 2024}}
* Pacheco, Hugo, and Alcino Cunha. "[https://repositorium.sdum.uminho.pt/bitstream/1822/24674/1/icmt12-1.pdf Multifocal: A strategic bidirectional transformation language for XML schemas]." International Conference on Theory and Practice of Model Transformations. Springer, Berlin, Heidelberg, 2012.
* {{cite conference |last1=Pacheco |first1=Hugo |first2=Alcino |last2=Cunha |url=https://repositorium.sdum.uminho.pt/bitstream/1822/24674/1/icmt12-1.pdf |title=Multifocal: A strategic bidirectional transformation language for XML schemas |conference=International Conference on Theory and Practice of Model Transformations |location=Springer, Berlin, Heidelberg |date=2012 |doi=10.1007/978-3-642-30476-7_6}}


[[Category:Mathematical relations]]
[[Category:Mathematical relations]]

Latest revision as of 21:07, 19 February 2024

In computer programming, bidirectional transformations (bx) are programs in which a single piece of code can be run in several ways, such that the same data are sometimes considered as input, and sometimes as output. For example, a bx run in the forward direction might transform input I into output O, while the same bx run backward would take as input versions of I and O and produce a new version of I as its output.

Bidirectional model transformations are an important special case in which a model is input to such a program.

Some bidirectional languages are bijective. The bijectivity of a language is a severe restriction of its power,[1] because a bijective language is merely relating two different ways to present the very same information.

More general is a lens language, in which there is a distinguished forward direction ("get") that takes a concrete input to an abstract output, discarding some information in the process: the concrete state includes all the information that is in the abstract state, and usually some more. The backward direction ("put") takes a concrete state and an abstract state and computes a new concrete state. Lenses are required to obey certain conditions to ensure sensible behaviour.

The most general case is that of symmetric bidirectional transformations. Here the two states that are related typically share some information, but each also includes some information that is not included in the other.

Usage[edit]

Bidirectional transformations can be used to:

  • Maintain the consistency of several sources of information[2]
  • Provide an 'abstract view' to easily manipulate data and write them back to their source

Definition[edit]

Bidirectional transformations fall into various well-studied categories.[3]

A lens is a pair of functions , relating a source and a view . If these functions obey the three lens laws:

  • PutGet:
  • GetPut:
  • PutPut:

It is called a well-behaved lens.[4]

A related notion is that of a prism, in which the signatures of the functions are instead , . Unlike a lens, a prism may not always give a view; also unlike a lens, given a prism, a view is sufficient to construct a source. If lenses allow "focusing" (viewing, updating) on a part of a product type, prisms allow focusing (possible viewing, building) on a part of a sum type.

Both lenses and prisms, as well as other constructions such as traversals, are more general notion of bidirectional transformations known as optics.[4]

Examples of implementations[edit]

  • Boomerang is a programming language that allows writing lenses to process text data formats bidirectionally
  • Augeas is a configuration management library whose lens language is inspired by the Boomerang project
  • biXid is a programming language for processing XML data bidirectionally[5]
  • XSugar allows translation from XML to non-XML formats[6]

See also[edit]

References[edit]

  1. ^ Foster, Nate. "Semantics of Bidirectional Languages" (PDF). Archived from the original (PDF) on 26 July 2011. Retrieved 7 February 2011.
  2. ^ Czarnecki, Krzysztof; Foster, J. Nathan; Hu, Zhenjiang; Lämmel, Ralf; Schürr, Andy; Terwilliger, James F. "Bidirectional Transformations: A Cross-Discipline Perspective" (PDF). Retrieved 19 February 2024.
  3. ^ Foster, J. Nathan; Greenwald, Michael B.; Moore, Jonathan T.; Pierce, Benjamin C.; Schmitt, Alan (May 2007). "Combinators for Bidirectional Tree Transformations: A Linguistic Approach to the View-Update Problem". ACM Transactions on Programming Languages and Systems. 29. doi:10.1145/1232420.1232424. S2CID 53234629.
  4. ^ a b Riley, Mitchell (2018). "Categories of Optics". arXiv:1809.00738 [math.CT].
  5. ^ KAWANAKA, Shinya; HOSOYA, Haruo (2006). "biXid: A Bidirectional Transformation Language for XML" (PDF). doi:10.1145/1160074.1159830. Archived from the original (PDF) on 2 July 2007. Retrieved 7 February 2011.
  6. ^ "XSugar - Dual Syntax for XML Languages". brics.dk. Retrieved 19 February 2024.

External links[edit]