HOME

TheInfoList



OR:

{{unreferenced, date=March 2017 A semantics encoding is a translation between
formal language In logic, mathematics, computer science, and linguistics, a formal language is a set of strings whose symbols are taken from a set called "alphabet". The alphabet of a formal language consists of symbols that concatenate into strings (also c ...
s. For programmers, the most familiar form of encoding is the compilation of a programming language into
machine code In computer programming, machine code is computer code consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). For conventional binary computers, machine code is the binaryOn nonb ...
or
byte-code Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normal ...
. Conversion between document formats are also forms of encoding. Compilation of
TeX Tex, TeX, TEX, may refer to: People and fictional characters * Tex (nickname), a list of people and fictional characters with the nickname * Tex Earnhardt (1930–2020), U.S. businessman * Joe Tex (1933–1982), stage name of American soul singer ...
or
LaTeX Latex is an emulsion (stable dispersion) of polymer microparticles in water. Latices are found in nature, but synthetic latices are common as well. In nature, latex is found as a wikt:milky, milky fluid, which is present in 10% of all floweri ...
documents to
PostScript PostScript (PS) is a page description language and dynamically typed, stack-based programming language. It is most commonly used in the electronic publishing and desktop publishing realm, but as a Turing complete programming language, it c ...
are also commonly encountered encoding processes. Some high-level preprocessors, such as
OCaml OCaml ( , formerly Objective Caml) is a General-purpose programming language, general-purpose, High-level programming language, high-level, Comparison of multi-paradigm programming languages, multi-paradigm programming language which extends the ...
's Camlp4, also involve encoding of a programming language into another. Formally, an encoding of a language A into language B is a mapping of all terms of A into B. If there is a ''satisfactory'' encoding of A into B, B is considered ''at least as powerful'' (or ''at least as expressive'') as A.


Properties

An informal notion of translation is not sufficient to help determine expressivity of languages, as it permits trivial encodings such as mapping all elements of A to the same element of B. Therefore, it is necessary to determine the definition of a "good enough" encoding. This notion varies with the application. Commonly, an encoding cdot A \longrightarrow B is expected to preserve a number of properties.


Preservation of compositions

; soundness : For every n-ary operator op_A of A, there exists an n-ary operator op_B of B such that :\forall T_A^1,T_A^2,\dots,T_A^n, p_A(T_A^1,T_A^2,\cdots,T_A^n)= op_B( _A^1 _A^2\cdots, _A^n ; completeness : For every n-ary operator op_A of A, there exists an n-ary operator op_B of B such that :\forall T_B^1,T_B^2,\dots,T_B^n, \exists T_A^1,\dots,T_A^n, op_B(T_B^1,\cdots,T_B^N) = p_A(T_A^1,T_A^2,\cdots,T_A^n)/math> (Note: as far as the author is aware of, this criterion of completeness is never used.) Preservation of compositions is useful insofar as it guarantees that components can be examined either separately or together without "breaking" any interesting property. In particular, in the case of compilations, this soundness guarantees the possibility of proceeding with separate compilation of components, while completeness guarantees the possibility of de-compilation.


Preservation of reductions

This assumes the existence of a notion of reduction on both language A and language B. Typically, in the case of a programming language, reduction is the relation which models the execution of a program. We write \longrightarrow for one step of reduction and \longrightarrow^* for any number of steps of reduction. ; soundness : For every terms T_A^1, T_A^2 of language A, if T_A^1 \longrightarrow^* T_A^2 then _A^1\longrightarrow^* _A^2/math>. ; completeness : For every term T_A^1 of language A and every terms T_B^2 of language B, if _A^1\longrightarrow^* T_B^2 then there exists some T_A^2 such that T_B^2 = _A^2/math>. This preservation guarantees that both languages behave the same way. Soundness guarantees that all possible behaviours are preserved while completeness guarantees that no behaviour is added by the encoding. In particular, in the case of compilation of a programming language, soundness and completeness together mean that the compiled program behaves accordingly to the high-level semantics of the programming language.


Preservation of termination

This also assumes the existence of a notion of reduction on both language A and language B. ; soundness : for any term T_A, if all reductions of T_A converge, then all reductions of _A/math> converge. ; completeness : for any term _A/math>, if all reductions of _A/math> converge, then all reductions of T_A converge. In the case of compilation of a programming language, soundness guarantees that the compilation does not introduce non-termination such as endless loops or endless recursions. The completeness property is useful when language B is used to study or test a program written in language A, possibly by extracting key parts of the code: if this study or test proves that the program terminates in B, then it also terminates in A.


Preservation of observations

This assumes the existence of a notion of observation on both language A and language B. In programming languages, typical observables are results of inputs and outputs, by opposition to pure computation. In a description language such as
HTML Hypertext Markup Language (HTML) is the standard markup language for documents designed to be displayed in a web browser. It defines the content and structure of web content. It is often assisted by technologies such as Cascading Style Sheets ( ...
, a typical observable is the result of page rendering. ; soundness : for every observable obs_A on terms of A, there exists an observable obs_B of terms of B such that for any term T_A with observable obs_A, _A/math> has observable obs_B. ; completeness : for every observable obs_A on terms of A, there exists an observable obs_B on terms of B such that for any term _A/math> with observable obs_B, T_A has observable obs_A.


Preservation of simulations

This assumes the existence of notion of simulation on both language A and language B. In a programming languages, a program simulates another if it can perform all the same (observable) tasks and possibly some others. Simulations are used typically to describe compile-time optimizations. ; soundness : for every terms T_A^1, T_A^2, if T_A^2 simulates T_A^1 then _A^2/math> simulates _A^1/math>. ; completeness : for every terms T_A^1, T_A^2, if _A^2/math> simulates _A^1/math> then T_A^2 simulates T_A^1. Preservation of simulations is a much stronger property than preservation of observations, which it entails. In turn, it is weaker than a property of preservation of
bisimulation In theoretical computer science a bisimulation is a binary relation between state transition systems, associating systems that behave in the same way in that one system simulates the other and vice versa. Intuitively two systems are bisimilar if ...
s. As in previous cases, soundness is important for compilation, while completeness is useful for testing or proving properties.


Preservation of equivalences

This assumes the existence of a notion of equivalence on both language A and language B. Typically, this can be a notion of equality of structured data or a notion of syntactically different yet semantically identical programs, such as structural congruence or structural equivalence. ; soundness : if two terms T_A^1 and T_A^2 are equivalent in A, then _A^1/math> and _A^2/math> are equivalent in B. ; completeness : if two terms _A^1/math> and _A^2/math> are equivalent in B, then T_A^1 and T_A^2 are equivalent in A.


Preservation of distribution

This assumes the existence of a notion of distribution on both language A and language B. Typically, for compilation of distributed programs written in Acute,
JoCaml JoCaml is an experimental general-purpose, high-level, multi-paradigm, functional and object-oriented programming language derived from OCaml. It integrates the primitives of the join-calculus to enable flexible, type-checked concurrent and ...
or E, this means distribution of processes and data among several computers or CPUs. ; soundness : if a term T_A is the composition of two agents T_A^1~, ~T_A^2 then _A/math> must be the composition of two agents _A^1, ~ _A^2/math>. ; completeness : if a term _A/math> is the composition of two agents T_B^1~, ~T_B^2 then T_B must be the composition of two agents T_A^1~, ~T_A^2 such that _A^1T_B^1 and _A^2T_B^2.


See also

*
Bisimulation In theoretical computer science a bisimulation is a binary relation between state transition systems, associating systems that behave in the same way in that one system simulates the other and vice versa. Intuitively two systems are bisimilar if ...
*
Compiler In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
*
Semantics Semantics is the study of linguistic Meaning (philosophy), meaning. It examines what meaning is, how words get their meaning, and how the meaning of a complex expression depends on its parts. Part of this process involves the distinction betwee ...
* Semantic dictionary encoding (SDE)


External links


The Program Transformation Wiki
Formal languages