# Axiomatic definition of Loglan'82

Skocz do: nawigacji, wyszukiwania

On these pages we are sketching, in an incremental way, an axiomatic semantics of Loglan'82.
Axiomatic definitions of sublanguages of Loglan'82

Here we shall present an increasing sequence of sublanguages $\mathcal{L}_0\subset\mathcal{L}_1\subset\mathcal{L}_2\subset \mathcal{L}_3\subset\mathcal{L}_4\subset \dots$Loglan'82. For each language $\mathcal{L}_i$ we shall present its grammar and some axioms and inference rules that define its semantics.

## Program

Program in Loglan'82 has the following structure

Program
definiendum definiens
program program <name>;
<declarations>

begin

<instructions>

end

where name is any identifier, i.e. a finite sequence of letters and digits beginning with a letter.

The declarations and instructions are finite sequences of declarations and instructions respectively, empty squence included.

This allow us to define the first sublanguage $\mathcal{L}_{0,0}$ of Loglan'82.

### Language $\mathcal{L}_{0,0}$

$\mathcal{L}_{0,0} \stackrel{df}{=}\{p\in \mathcal{A}^*: p=\textbf{program}\ \textit{id}; \textbf{begin end} \}$

Programs of the language $\mathcal{L}_{0,0}$ are empty programs, they posses just a name. Their list of instructions as well as list of declarations are empty. The effect of execution of such program is do nothing.

### Language $\mathcal{L}_{0,1}$

Now we shall define a new language $\mathcal{L}_{0.1}$. First, we say that any expression of the form:
writeln;
write(integer);
is an output instruction.

$\mathcal{L}_{0.1} \stackrel{df}{=}\{p\in \mathcal{A}^*: p=\textbf{program} \textit{ id}; \textbf{begin} \lt\textit{output instructions}\gt \textbf{end} \}$

where name is any identifier, i.e. a finite sequence of letters and digits beginning with a letter.

The declarations and instructions are finite sequences of declarations and instructions respectively, empty squence included.

Example 0.1

 program print; begin write("hallo world!"); writeln; write("Today is: May"); write(22); write(2014); writeln end

Semantics

Each output instruction appends a string of characters to the standard output.

## $\mathcal{L}_{1}$ Declarations of variables. Assignment instructions

Now we shall introduce the linear programs. Each program of this group contains declarations of variable and the instructions of a program are the assignment instructions only.
The language $\mathcal{L}_{1}$ is the closure of languages $\mathcal{L}_{1,c} \cup \mathcal{L}_{1,s}\cup \mathcal{L}_{1,b}\cup \mathcal{L}_{1,i}\cup \mathcal{L}_{1,r}$ The structure of a program is as follow:

Program
definiendum definiens
program program <name>;
<declarations of variables>

begin

<instructions> i.e.
sequence of
<output instructions or assignment instructions >

end

where name is any identifier, i.e. a finite sequence of letters and digits beginning with a letter.

The declarations and instructions are finite sequences of declarations and instructions respectively, empty squence included. The structure of assignment instruction is $variable := expression$ An assignment instruction is well formed if the types of the variable and of expression are equal and if all variables are declared in the program.

Axioms

 $\qquad\qquad \{x:=\tau\}( \alpha ) \equiv \alpha(x/\tau) \qquad \qquad$

 $\textbf{begin }\, K;\, M \textbf{ end}\, \alpha \equiv K M\, \alpha$

How to use these axioms?
We present a lemma that is universally true for all the sublanguages of the language $\mathcal{L}_{1}$.

 Lemma Let $T$ be a type. Let $x, y, z$ be variables of type $T$. The following algorithmic formula is tautology $(x=a \land y=b)\implies \{z:=x;\,x:=y;\,y:=z \}(x=b \land y=a)$ Proof. By the axiom of composed instruction and propositional calculus our formula $(x=a \land y=b) \implies \{\underbrace{z:=x;\, x:=y;}_{K}\, \underbrace{y:=z}_{M}\}\underbrace{(x=b \land y=a)}_{\alpha}$ is equivalent to $(x=a \land y=b) \implies \overbrace{\{z:=x;\, x:=y\}}^{K} \overbrace{\underbrace{\{ y:=z\}}_{y:=z}}^{M}\underbrace{(x=b \land y=a)}_{\alpha(y)}$ Using the axiom of assignment instruction we get an equivalent formula $(x=a \land y=b)\implies \{z:=x;\,x:=y;\}\underbrace{(x=b \land z=a)}_{\alpha(y/z)}$ Again the axiom of composed instruction $(x=a \land y=b)\implies \{z:=x\} \{x:=y;\}(x=b \land z=a)$ Now, by applying twice the axiom of assignment instruction we get $(x=a \land y=b)\implies \{z:=x\} (y=b \land z=a)$ and $(x=a \land y=b)\implies (y=b \land x=a)$ The last formula is tautology. All formulas are equivalent. Hence, our first formula is proved.

Note, the meaning of the lemma is if initially the value of x is a and the value of y is b, then after execution of these three instructions the variables swapped their values x=b and y=a

### Language $\mathcal{L}_{1,c}$

Declarations are declarations of variables of type char. Type char is a finite set of characters. Obviously it contains all letters, digits and delimiters.There are no operations on characters and the only relation in this set is the identity relation =.

Consequently the only characters expressions are character constants and character variables.

Example

 program characters; var c1,c2,c3:char begin c1:='p'; c2:='d'; writeln(c1,c2); c3:=c1; c1:=c2; c2:=c3; writeln(c1,c2) end

Exercise
Guess what will print this program.

Axioms of data structure (type) char.

 $\forall_{x \in char}(x=’a’\lor \dots \lor x=’z’ \lor x='A' \lor \dots x='Z' \lor \dots)$

The reader is kindly requested to complete the above line.

 $(('a'\neq\, 'b') \land ('a'\neq\, 'c')\land \dots )$

Also this line can be completed without problems.

### Language $\mathcal{L}_{1,s}$

Declarations are declarations of variables of type string. Type string is an infinite set of finite words over the alfabet of characters. There are no operations on strings and the only relation ...

Consequently the only string expressions are string constants and string variables.

Example

program Strings;

  var x,y: string;


begin

  x := 'ba';
y := x


end

### Language $\mathcal{L}_{1,b}$

Declarations are declarations of variables of type boolean. Type char is a finite set of characters. Obviously it contains all letters, digits and delimiters.There are no operations on characters and the only relation in this set is the identity relation =.

Consequently the only characters expressions are charcter constants and character variables.

Example

program Booleans;

  var x,y: boolean;


begin

  x := 'false';
y := x OR


end

Example

program P2 ;

var x,y: integer;

begin

y:=74;
x:= y+ 8;

end

Grammar
program <name>;

var id: char; var id1: char;

begin

id1 := character expression;
id :=character expression

end

Context free grammar character expression ::= character constant | character variable character constant ::= 'a'| ... |'z'|'A'| ... |'Z'|'+'|'&'| ... character variable :: Well formed expressions

A character expression <mat>\tau[/itex] occurring in a program $P$, is well formed iff either it is a character constant or it is a variable declared in the program.

Axiom

$\{x:=\tau\}( \alpha ) \Leftrightarrow \alpha(x/\tau)$

## $\mathcal{L}_{4}$ Iteration instructions

We extend the language by admitting the instruction while and its cousins

## $\mathcal{L}_{5}$ Definitions

This language allows to use subprograms - non-recursive ones

## $\mathcal{L}_{6}$ Primitive recursion

Theorem of Julia Robinson, Stephen Kleene on reducing primitive recursion to while programs

## $\mathcal{L}_{7}$ Functions and procdures

The general case of modules that define algorithms for multiple use

## $\mathcal{L}_{8}$ Functionals

Functions that allow other functions as parameters

obvious

bbb

## $\mathcal{L}_{14}$ Software engineering

A case study of bank simulation