# Semantics (Technology)

For the longest time I’ve read papers on Distributed Systems and ran into weird
usages of the word **semantics**. Time and time again I had to look up what it
meant or use context to plunge forward. Well today curiosity got the best of me
and I decided to look up a formal definition of semantics as used in tech. It
was buried at the bottom of a dictionary entry. Here it is:

```
The meaning of a string in some language, as opposed to syntax which
describes how symbols may be combined independent of their meaning. The
semantics of a programming language is a function from programs to answers.
A program is a closed term and, in practical languages, an answer is a
member of the syntactic category of values. The two main kinds are
denotational semantics and operational semantics.
```

But apparently there are (3) main kinds of semantics! No wonder it’s confusing; I hadn’t heard of any of them. Here they are.

## Denotational Semantics

```
A technique for describing the meaning of programs in terms of mathematical
functions on programs and program components. Programs are translated into
functions about which properties can be proved using the standard
mathematical theory of functions, and especially domain theory.
```

## Operational Semantics

```
A set of rules specifying how the state of an actual or hypothetical
computer changes while executing a program. The overall state is typically
divided into a number of components, e.g. stack, heap, registers etc. Each
rule specifies certain preconditions on the contents of some components and
their new contents after the application of the rule. It is similar in
spirit to the notion of a Turing machine, in which actions are precisely
described in a mathematical way.
```

## Axiomatic Semantics

```
A set of assertions about properties of a system and how they are effected
by program execution. The axiomatic semantics of a program could include
pre- and post-conditions for operations. In particular if you view the
program as a state transformer (or collection of state transformers), the
axiomatic semantics is a set of invariants on the state which the state
transformer satisfies. E.g. for a function with the type:
sort_list :: [T] -> [T]
...we might give the precondition that the argument of the function is a
list, and a postcondition that the return value is a list that is sorted.
One interesting use of axiomatic semantics is to have a language that has a
finitely computable sublanguage that is used for specifying pre and post
conditions, and then have the compiler prove that the program will satisfy
those conditions.
```

Using context, it seems that in the context of distributed systems *semantics*
usually refers to operational or axiomatic semantics. But you’ll have to use
context to decide which meaning makes the most sense.