Return-Path:
Return-Path: <john.harrison-request@uk.ac.cam.cl>
Received: from ted.cs.uidaho.edu by swan.cl.cam.ac.uk with SMTP (PP-6.0)
          id <16961-0@swan.cl.cam.ac.uk>; Mon, 27 Jan 1992 09:46:43 +0000
Received: by ted.cs.uidaho.edu (16.6/1.34) id AA10581;
          Mon, 27 Jan 92 01:26:36 -0800
Sender: info-hol-request@edu.uidaho.cs.ted
Errors-To: info-hol-request@edu.uidaho.cs.ted
Received: from ux6.tfl.dk by ted.cs.uidaho.edu (16.6/1.34) id AA10577;
          Mon, 27 Jan 92 01:26:31 -0800
Received: by ux6.tfl.dk (/\==/\ Smail3.1.24.1 #24.2)
          id <m0l8Sdy-000Ds6C@ux6.tfl.dk>; Mon, 27 Jan 92 10:28 MET
Message-Id: <m0l8Sdy-000Ds6C@ux6.tfl.dk>
Date: Mon, 27 Jan 92 10:28 MET
From: kimdam@dk.tfl (Kim Dam Petersen)
To: info-hol@edu.uidaho.cs.ted
Subject: Re: Generic graphs (was: Overloading of constant names)

>
[ ... text deleted ... ]
>
> I'm asking this because I would like to use abstract theories but
> found the above naming constraint very annoying.  For instance,
> I want to define a type :graph and, for any G:graph, get its
> adjacency relation by saying adj(G).  Later I want to talk about
> graphs in which edges are weighted, so I want to define another
> type :w_graph.  But then, to get the adjacency relation of a
> weighted graph WG, I would have to say something like w_adj(WG).
> instead of simply adj(WG).  If I want to consider yet another
> new type :cw_graph of connected weighted graphs, I would have to
> introduce yet another set of constant names.  Is there a way out?
>
> - Ching Tsun
>

If you want to make an abstract theory, you may represent the node and
edge types by polymorphic types.  Hence, you should define
the polymorphic type ":(*node,*edge)graph".  You may then specify that "G"
is a graph having nodes of type ":node" and edges of type ":edge" by
the type constraint "G: (node,edge) graph".

Using the polymorphic representation you may derive properties that
holds for any graph of type ":(*node,*edge)graph".

I leave the actual definition of a polymorphic graph to you.

I hope this is useful to you.

Regards,

    Kim Dam Petersen

