COGENT Online
CONTENTS
COGENT Help

Buffer/Stack

Introduction

A buffer is an information store. It is a place where information can be put for later retrieval. Buffers are appropriate for both short term storage (as in modelling working memory, for example) and long term storage (as in large knowledge bases). They can be configured, through subclasses and properties, so as to behave in a variety of different ways (allowing, for example, decay of elements or capacity restrictions).

A stack is a kind of buffer which provides very limited access to its ordered elements. The elements of a stack are ordered in the sequence in which those elements were added to the stack. Access to the stack is only allowed through the most recent or "top" element of the stack. There are basically three operations which may be performed on a stack: the top-most element may be matched; an element may be "pushed" onto the top of the stack (thus obscuring the previous top element); and an element may be popped off the top of the stack (thus revealing a previously hidden element).

Despite the flexibility of COGENT's standard propositional buffer type, instances of the type cannot be used to implement a stack. Firstly, only the top-most element may be accessed in a real stack, but a proposition buffer, even with LIFO access, still allows access to all buffer elements. Secondly, elements can be deleted from any position within a propositional buffer, whereas only the top-most element can be deleted from a stack (and this operation is known as a pop). Thirdly, when multiple elements are added to a propositional buffer on the same cycle, COGENT provides no guarantee about the order in which those elements will be added. The stack buffer type provides a storage mechanism that addresses each of these issues.

One common use of stacks is in maintaining sequences of goals and subgoals, as, for example, in models of problem solving.

Stack Messages

Like all buffers, stacks can be matched by the conditions of rules. However, a stack match will only match against the top-most element of the stack.

An element may be pushed onto a stack by sending the stack a message of the form "push(Element)". The top-most element may be popped from a stack by sending the stack a message of the form "pop". Thus, the RHS of a rule which pops the top element off Goal Stack and replaces it with subgoal might look like:

If multiple push and/or pop messages are sent to the same stack from the RHS of one rule, then those push/pop messages are processed in the order in which they appear on the RHS of the rule. If multiple push and/or pop messages are sent to the same stack from multiple rules, then messages within the same rule will be processed in order, but the order of processing of messages from different rules is not deterministic.

This use of the ordering of stack related actions within rules differs from standard rule processing. In general, the ordering of rule actions does not affect the order of execution of those actions: non-stack related "send" actions are effectively processed in parallel.

The Current Contents Tab

The current contents of stack buffers may be viewed in text mode by opening the current contents tab, or in a graphical mode by opening the current stack tab. In the text mode, the elements in the stack are displayed with the top-most element at the top of the text view. In graphical mode, the stack is displayed pictorially, with an arrow pointing to the top-most element.

If, when printing, the View->Show current contents menu item is checked, the text and graphical views of the current stack state are included in the print out.

Stack Buffer Properties

Like all COGENT buffers, stacks have an initialisation property which specified when they are initialised (e.g., at the beginning of each trial or block). Stacks typically have an unlimited capacity, but COGENT allows the capacity of a stack to be fixed (using the standard buffer capacity limitation properties). COGENT also allows the specification of actions to be taken when stack capacity is reached. Two further properties specify whether stack elements can decay, and, if so, the rate of that decay. Unlike Propositional buffers, there is no Duplicates property and no Access property.

The Buffer Element Editor

Recall that all information must be represented in COGENT via Prolog terms. Buffer elements are no exception, but they are perhaps the simplest sorts of box elements in COGENT. This is reflected in the simplicity of the buffer element editor. Apart from the comment line, it contains a single text field into which the buffer element should be typed. The contents of this field should be a valid Prolog term. If not, however, COGENT does automatic syntax checking (and attempted correction) of editor elements, and so any error will be noted and (possibly) corrected.


COGENT Online
CONTENTS
COGENT Help