# 6.2 Structures, relationships and terms

## Introduction

A structure is a way of expressing a relationship among entities. For example:

```gr(graph1, [Cat]).
```

Here, the structure "gr" expresses the fact that there is a relationship between the atom "graph1" and the CG "[Cat]".

## What is a structure?

A structure has the following syntax:

1. It starts with an identifier,
2. followed by an opening parenthesis, "("
3. followed by a comma-separated list of terms
4. and ends with a closing parenthesis, ")".

## Terms

The "terms" in the comma-separaed list between the parentheses can be any of the following:

Thus "term" is the name we give to any kind of data in Prolog+CG.

## Writing CGs

When writing CGs, you most often use structures to contain graphs. For example:

```// Type hierarchy
Entity > Animal, Act.
Animal > Wolf, Lamb.

// Catalog of instances
Act = Hunt, Graze.

// Graph facts
gr(graph1, [Wolf]<-AGNT-[Act: Hunt]).
gr(graph2, [Lamb]<-AGNT-[Act: Graze]).
```

Here, the structure "gr" is used twice to write graphs and associate them with an atom ("graph1" or "graph2").

## Further rules

• The comma-separated list of terms can be any length, including 1:

`mygraph([Cat]).`
• A structures induces a relationship between the terms in the comma-separated list. However, the nature of that relationship is not specified. What is said is that there is a relationship, not what kind it is, or what it means.

## Summary

Thus structures can be used to represent arbitrary relationships between terms. This is done by means of specific syntax, including an identifier, an opening parenthesis, a comma-separated list of terms, and a closing parenthesis. The comma-separated list of terms can be any length, including 1.

"Term" is the name we give to any kind of data in Prolog+CG. This includes all of the kinds listed above.

PrevLite: 6.1 Atoms, Strings, and Numbers
NextLite: 6.3 Variables

Prev: 6.1 Atoms, Strings, and Numbers
Up: 6 Prolog for CG users
Next: 6.3 Variables