User:Sam Staton/Sandbox

In this section we review the semantics of functional recursive programs which were the initial subject matter of denotational semantics. (These functional recursive programs are a special case of procedural recursive programs in languages like Java and C# in that nothing ever changes.)

The problem is as follows. We need to give a semantics to programs such as the definition of the factorial program as

function fact(X)
Y:=1;
while (X>0) do (Y:=X*Y; X:=X-1);
return Y;
end function

The meaning of this factorial program should be a function on the natural numbers. To give a compositional

In the semantics of recursion, a domain is typically a partial order, which can be understood as an order of definedness. For instance, the set of partial functions on the natural numbers can be given an order as follows:

given partial functions f and g, let "f≤g" mean that "f agrees with g on all values for which f is defined".

It is usual to assume some properties of the domain, such as the existence of limits of chains (see cpo) and a bottom element. The partial order of partial functions has a bottom element, the totally undefined function. It also has least upper bounds of chains. Various additional properties are often reasonable and helpful: the article on domain theory has more details.

We are particularly interested in the continuous functions between domains. These are functions that preserve the order structure, and that preserve least upper bounds.

In this setting, types are denoted by domains, and the elements of the domains roughly capturing the elements of the types. A denotational semantics is given to a program phrase with free variables in terms of a continuous function from the denotation of its environment type to the denotation of its type. For example, the phrase n*g(n-1) has type Nat, and it has two free variables: n, of type Nat, and g of type Nat -> Nat. Thus its denotation will be a continuous function

.

Under this order on the partial functions, the denotation of the factorial program can be given as follows. First, we must develop denotations for the basic constructions such as if-then-else, ==, and multiplication. One must also develop a denotational semantics for function abstraction and application. The program phrase

λ n:N. if (n==0)then 1 else n*g(n-1)

can then be given a denotation as a continuous function between the domains of partial functions

.

The denotation of the factorial program is defined to be the least fixed point of this function F. It is thus an element of the domain .

The reason that such a fixed point exists is because F is a continuous function. A version of Tarski's fixed point theorem says that continuous functions on domains have least fixed points.

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.