in programming language theory, semantics is the field concerned with the rigorous mathematical study of the meaning of programming languages. it does so by evaluating the meaning of syntactically legal strings defined by a specific programming language, showing the computation involved. in such a case that the evaluation would be of syntactically illegal strings, the result would be non-computation. semantics describes the processes a computer follows when executing a program in that specific language. this can be shown by describing the relationship between the input and output of a program, or an explanation of how the program will execute on a certain platform, hence creating a model of computation. formal semantics, for instance, helps to write compilers, better understand what a program is doing and to prove, e.g., that the following if statement if 1 = 1 then s1 else s2 has the same effect as s1 alone. ==overview== the field of formal semantics encompasses all of the following: *the definition of semantic models *the relations between different semantic models *the relations between different approaches to meaning *the relation between computation and the underlying mathematical structures from fields such as logic, set theory, model theory, category theory, etc. it has close links with other areas of computer science such as programming language design, type theory, compilers and interpreters, program verification and model checking. ==approaches== there are many approaches to formal semantics; these belong to three major classes: * denotational semantics, whereby each phrase in the language is interpreted as a denotation, i.e. a conceptual meaning that can be thought of abstractly. such denotations are often mathematical objects inhabiting a mathematical space, but it is not a requirement that they should be so. as a practical necessity, denotations are described using some form of mathematical notation, which can in turn be formalized as a denotational metalanguage. for example, denotational semantics of functional languages often translate the language into domain theory. denotational semantic descriptions can also serve as compositional translations from a programming language into the denotational metalanguage and used as a basis for designing compilers. * operational semantics, whereby the execution of the language is described directly (rather than by translation). operational semantics loosely corresponds to interpretation, although again the "implementation language" of the interpreter is generally a mathematical formalism. operational semantics may define an abstract machine (such as the [[secd machin
Formal_methods Formal_specification_languages Logic_in_computer_science Programming_language_semantics