Main Page   Modules   Compound List   File List   Compound Members   File Members  

peano.c File Reference

The implementation for Peano Arithmetic. More...

#include "peano.h"

Include dependency graph for peano.c:

Include dependency graph

Functions

void error (const char *s, const int n)
Natnum_t Natnum_malloc ()
Natnum_t Z ()
Natnum_t S (const Natnum_t n)
Natnum_t recsum (const Natnum_t s0, const Natnum_t s1)
Natnum_t itsum (const Natnum_t s0, const Natnum_t s1)
Natnum_t loopsum (Natnum_t s0, Natnum_t s1)
int Zeq (Natnum_t n)
const Natnum_t pred (const Natnum_t n)
int eq (Natnum_t n0, Natnum_t n1)
unsigned nn2uns (Natnum_t nn)
Natnum_t uns2nn (unsigned u)

Detailed Description

The implementation for Peano Arithmetic.

Operations on Natnum_t objects are defined.

struct Natnum is a cell containing just a pointer. A linked list with of those cells, followed by a null pointer represents the integer : iterations of , the sucessor function applied to , the zero constructor.


Function Documentation

int eq Natnum_t    n0,
Natnum_t    n1
 

equlity test

Notice that equality is defined with respect to the intended representation

void error const char *    s,
const int    n
[static]
 

a local error procedure

A procedure for producing an error message and aborting the program

Parameters:
s  pointer to error message
n  an interger constant to be returned to the operating system

Natnum_t itsum const Natnum_t    s0,
const Natnum_t    s1
 

tail recursive function for computing sum over Natnum

Natnum_t loopsum Natnum_t    s0,
Natnum_t    s1
 

The sum of two Natnum object, using iteration

It implements invariant assertion.

Natnum_t Natnum_malloc   [static]
 

An allocator for Natnum

It uses malloc to allocate space for Natnum, possibly aborting the program

Returns:
pointer to newly allocated Natnum

unsigned nn2uns Natnum_t   
 

Converting a Natnum_t to binary representation

const Natnum_t pred const    Natnum_t
 

the predecessor of a given number

Natnum_t recsum const Natnum_t    s0,
const Natnum_t    s1
 

recursive function for computing sum over Natnum

it computes sum of two Natnum objects, using recursion with suspended computation (computation with draft on stack)

Natnum_t S const Natnum_t    n
 

A constructor for an object representing the successor of a given number

Parameters:
n  a number
Returns:
the successor of n

Natnum_t uns2nn unsigned   
 

From binary to Natnum_t

Natnum_t Z  
 

int Zeq Natnum_t   
 

whether a number is zero


Generated on Wed Jun 11 08:35:43 2003 for Peano Arithmetic by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002