3.1. Logic Programming
Logic programming deals with definitive clauses. Let
be propositional variables or statements that can be true or false. A
literal is a propositional variable
or a negated propositional variable
([
14], p. 269). A
clause is a finite disjunction (logical connective ‘or’, noted by ∨) of literals. A
Horn clause is a clause with at most one non-negated (positive) literal. Finally, a
definite clause, also called a
strict Horn clause, is a clause with exactly one non-negated (positive) literal. The disjunction form of a definite clause is
where
q is the unique non-negated (positive) literal. We can write this kind of clause in the implication form
where ← means ‘if’ and ∧ is the conjunction connective ‘and’. Thus, if the literals
are all true, then
q is true. The part on the left side of Equation (
2), before the ←, is called the
head of the clause, the part on the right side is called the
body ([
15], p. 4). So, in general, if the body of the clause is true, then its head is true too. This fundamental deduction step is called
modus ponens.
Logic programming uses
modus ponens to compute the logical consequences of some set of definite clauses using a powerful inference rule called resolution ([
16], pp. 21–22). Consider the following example:
The former clauses are related to each other by means of the literal ‘rectangle’, which occurs in the body of the first clause (a negative literal) and in the head of the second clause (a positive literal). Then, resolution will derive a third clause, called the resolvent, by eliminating this common literal, keeping all the other literals from both clauses. The output will be
That is, a square is a parallelogram with right angles and equal sides because a square is a rectangle with equal sides and a rectangle is a parallelogram with right angles.
This is the kind of inference that Prolog makes given a knowledge base (or database) of definite clauses that can express facts that are unconditionally true or rules that express conditions “if … then …” like the ones described above. The process of inference is called SLD-resolution with S for selection rule (from the left to the right of each clause), L for linear resolution (concerned with the shape of the proof trees obtained) and D for definitive clauses ([
16], p. 44).
3.2. Basic Concepts
Based on graph theory and computer-aided simulations, space syntax aims to find and explain the relation between spatial configurations and social activities.
Configuration is a concept that addresses the whole of a complex (settlement or building) rather than its parts and captures how the relations between two spaces, say A and B, might be affected by a third space C ([
3], pp. 23–24). For instance, if A and B are adjacent or permeable, then they have a symmetric configuration in the sense that, if A is the neighbour of B, then B is the neighbour of A, as illustrated by the left-hand side of
Figure 2.
However, if only A is connected with a third space C, as in the right-hand side of the same figure, A and B become asymmetrical in relation with C because we have to pass through A to get to B from C, but we do not have to pass through B to get to A from C. Thus,
asymmetry relates to
depth, that is, with the number of spaces (or steps) necessary to go from a certain space, say C, to another space, A (1 step), B (2 steps), and so on.
If we count the number of steps necessary to go from a certain space to every other space in a complex, we can obtain a measure of its total depth (TD), or mean depth (MD) by dividing that total by the number of spaces in the complex minus one, the original space ([
1], p. 108) ([
2], pp. 27–28). In the previous example, the total depth of C is 3, which is the sum of steps to reach A and B (1 + 2) from that origin. This is also the case of B, but the total depth of A is 2, noting that this (central) space is directly connected with either B or C spaces (1 + 1). Thus, the mean depth is 1 (2/2) for A and 1.5 (3/2) for either B or C, noting that the number of spaces minus one in this simple complex is 2 (3 − 1).
This simple illustration suggests that syntactic measures can be computed for every (convex) space in a settlement or building. Then, we may eventually find that some spaces have a lower depth than all other spaces (A in the same example), and others have a greater depth (B and C). The former are the most integrated spaces, where social life and/or economic activities such as retail might be concentrated in cities ([
4], p. 162), or the living room in most houses ([
1], pp. 155–158) ([
2], pp. 104–105) ([
3], pp. 25–27). The latter are typically the most segregated, quiet or remote spaces in a town, building or house. Thus,
integration is inversely related with depth. It is a global measure in the sense that it considers the configuration of a certain space in relation with all other spaces (or with spaces at a radius of
n steps from the original space). In addition, local measures such as control are based on the relations between each space and only the spaces directly connected to it ([
5], p. 14).
As an intelligent critique of modernism, space syntax stresses the deep tree-like configuration of modern estates ([
1], pp. 129–132, 262–263). Firstly, the modern city is structured around a hierarchical street system, eventually composed by Le Corbusier’s seven roads types ([
17], p. 157). Secondly, the number of spaces between each dwelling and the closest main street may be amplified by walls, stairs, galleries and other physical boundaries that are common in modern estates ([
18], pp. 52–53), and by the number of stories in high-rise complexes. In fact, the modern dwelling is conceptually a space of retreat such as a monk cell. To get there, we might take a deep initiatory path like the one took by Le Corbusier himself, daily, to his flat in Paris (24 N.C.):
Le Corbusier’s apartment is a maisonnette. It can be accessed from the outside gallery which overhangs the small courtyard; from this gallery, the visitor either take the service lift or follow the spiral staircase connecting the seventh floor to the lower landing, where the main lift stops. This rather complicated procedure requires a real initiation ceremony to reach Le Corbusier’s apartment ([
19], p. 36).
Thus, the configuration of a modern city is typically a deep tree. A tree is a special kind of graph, which contains a root such that there is a unique path from the root to any other node ([
16], p. 83). Thus, trees are necessarily noncyclic or acyclic, that is, they do not contain paths from a node to itself. The absence of ‘rings’ in trees give them a non-distributed rather than a distributed configuration where there is more than one independent route from one space to another, including one passing through a third space ([
1], p. 148). Distributedness can be illustrated by a recursive discrete process, where a primary cell or syntactic type is ‘glued’ together with cells of the same type by the space ‘between’ them, meaning that the global structure of the settlement is distributed amongst all primary cells ([
1], p. 11).
3.3. Grammar
Among several influences, space syntax was founded on anthropology, namely, on the works of Claude Lévi-Strauss, Robert Sutherland, Bronislaw Malinowski and Franz Boas [
1,
3]. In addition, anthropology was influenced by structural analysis, namely, by the seminal works of the prince N. S. Troubetzkoy [
20] on phonology. As stressed by Levi-Strauss ([
21], pp. 31, 33):
Linguistic occupies a special place among the social sciences, to whose ranks it unquestionably belongs. It is not a social science like the others, but, rather, the one in which by far the greatest progress has been made. It is probably the only one which can truly claim to be a science, and which was achieved both the formulation of an empirical method and an understanding of the nature of the data submitted to its analysis. (…) Structural linguistics will certainly play the same role with respect to the social sciences that nuclear physics, for example, had played for the physical sciences.
Originally, Prolog was developed exactly to process natural languages, namely, French, using linear resolution on definitive clauses ([
6], pp. 2, 6). Within this scope, the syntax of a language is specified by a grammar, which is a set of rules of the form ([
16], p. 134):
sentence --> noun_phrase,verb_phrase.
noun_phrase --> article,noun.
verb_phrase --> verb,noun_phrase.
The former chunk states that a sentence may consist of a noun phrase followed by a verb phrase, with the former composed of an article and a noun and the later by a (transitive) verb and another noun phrase.
This kind of (structural) grammatical analysis can be applied directly to spatial problems, namely, to describe concentric villages like Bororo ([
21], p. 141),
Figure 3. Here, a large amount of convex space is invested in a central zone, which is highly synchronised with a large number of objects placed at its periphery ([
1], pp. 92–93). This kind of concentric structure was found in many places, namely, in the village of Omarakana, the Trobriand Islands, Melanesia ([
22], Figure I, p. 649).
In fact, we can define a generic concentric village as a centre surrounded by a periphery where the former is composed of facilities and open spaces and the latter by several (up to three) types of housing estates, namely:
conc_village --> centre,periphery.
centre --> facility,open_space.
centre --> facility,facility,open_space.
centre --> facility,facility,open_space,open_space.
periphery --> housing.
periphery --> housing,housing.
periphery --> housing,housing,housing.
Then, we have to specify the terminal categories, such as words in a phrase, for the spaces that structure the Bororo village described in
Figure 3:
facility --> [men_house].
facility --> [dance_platform].
open_space --> [scrub_land].
housing --> [upper_class_houses].
housing --> [middle_class_houses].
housing --> [low_class_houses].
?-conc_village([men_house,dance_platform,scrub_land,
upper_class_houses,middle_class_houses,
low_class_houses],[]).
to get an affirmative answer, that is, the Bororo village respects the above-defined syntax of concentric villages because it is structured around a centre with two facilities (men’s house and dance floor) and an open space (scrub land) surrounded by three types of houses for upper, middle and low classes (respectively, 1, 2 and 3 in the same figure).
As stressed by Lévi-Strauss ([
21], pp. 151–152), the concentric dualism found in Bororo masks a triad because it is not self-sufficient and its frame of reference is always the environment: ‘the opposition between cleared ground (central circle) and waste land (peripheral circle) demands a third element, brush or forest, that is, virgin land, which circumscribes the binary whole at same time extending it’.
3.4. Syntactic Measures
3.4.1. Knowledge Base
A Prolog program is a knowledge base, or database, composed of a collection of facts and rules, which describe a set of relations of interest [
15]. Facts express unconditional truths ([
16], p. 5), namely, the connections between lines in an axial map (the longest and fewest lines that cover the street grid) or between spaces in a convex map ([
1], pp. 91–92) ([
3], p. 98).
In Portela’s axial map (
Figure 4), from left to right and top to bottom, we know that the west side of Avenida dos Descobrimentos is directly connected with 10 lines: Avenida da República, Rua Fernão de Magalhães, Rua Gonçalves Zarco, Rua Pedro Álvares Cabral, Rua Bartolomeu Dias, Rua Diogo Cão, Rua Infante Dom Henrique, Avenida dos Descobrimentos (south side) and two local circulations. These facts can be declared in a Prolog program (
https://swish.swi-prolog.org/p/portela.pl, accessed on 19 July 2023) with the following:
connected(av_descobrimentos_W,av_republica,1).
connected(av_descobrimentos_W,rua_fernao_magalhaes,1).
connected(av_descobrimentos_W,rua_gonc_zarco,1).
connected(av_descobrimentos_W,rua_pedro_alvares_cabral,1).
connected(av_descobrimentos_W,rua_bartolomeu_dias,1).
connected(av_descobrimentos_W,rua_diogo_cao,1).
connected(av_descobrimentos_W,rua_inf_dom_henrique,1).
connected(av_descobrimentos_W,av_descobrimentos_S,1).
connected(av_descobrimentos_W,circ_NW,1).
connected(av_descobrimentos_W,circ_SW,1).
Figure 4.
Axial map of Portela.
Figure 4.
Axial map of Portela.
These 10 clauses or atoms belong to the same
predicate because they have the same
name (‘connected’) and the same
arity, that is, the same number of arguments (three) enclosed in parentheses and separated by commas ([
16], pp. 25, 31). Here, the third argument is the topological distance between two adjacent lines, that is, one. In some applications, it may be greater than one in order to incorporate the metric distance or other cost (e.g., stairs or ramps) between two convex spaces [
23], but here we adopt the topological distance introduced in The Social Logic of Space ([
1], p. 103).
Clauses of the same predicate must be declared jointly in a Prolog program, so we must add the remaining connections concerned with the Portela’s axial map (
Figure 4) in our knowledge base in order to proceed, namely:
connected(av_republica,pcta_jose_relvas,1).
connected(av_republica,circ_W,1).
connected(av_republica,rua_palmira_bastos,1).
…
connected(av_descobrimentos_S,pcta_sto_antonio,1).
Then, after consulting this program (
https://swish.swi-prolog.org/p/portela.pl, accessed on 19 July 2023), we may ask it about the lines Y connected, for instance, with the west side of Avenida dos Descobrimentos by posing the query:
?-connected(av_descobrimentos_W,Y,1).
where the prefix ‘
?-’ indicates that this is a query rather than a fact. In Prolog, a
variable such as Y is written as a sequence of letters and digits, beginning with a capital letter or underscore. An answer to the previous query, e.g., Avenida da República, will be written
{Y -> av_republica} following the notation of Flach ([
16], p. 5). This means that Prolog found a value for the variable Y, that is, a solution given the knowledge base previously loaded and consulted. If asked, Prolog will try to find more values to Y given the knowledge base, namely,
{Y -> rua_fernao_magalhaes},
{Y -> rua_gonc_zarco} and so on. These are the axial lines 1 step away from the west side of Avenida dos Descobrimentos, that is, at a depth of 1 from this particular root.
3.4.2. Connectivity
For practical purposes, we must create a pair of rules, that is, of conditional truths that can only be drawn when their premises are known to be true ([
16], p. 5), which isolate the lines that are adjacent with a certain axis X in the sense that it can be connected with Y or, conversely, Y can be connected with X:
adjacent(X,Y,1):-connected(X,Y,1).
adjacent(X,Y,1):-connected(Y,X,1).
where the symbol: ‘-’ should be read as ‘if’. These rules mean ‘for any values of X and Y, X and Y are adjacent if X is directly connected with Y or Y is directly connected with X with topological distance 1’.
Now, we can compute the axial connectivity (AC) of some line, which is the number of other lines it intersects ([
1], p. 103), using the SWI-Prolog [
8] built-in predicate
aggregate_all in order to
count the number of adjacent lines:
connectivity(X,Y,AC):-aggregate_all(count,adjacent(X,Y,1),AC).
For instance, the following query returns {AC -> 10} because the west side of Avenida dos Descobrimentos is directly connected with 10 axial lines, as said:
?-connectivity(av_descobrimentos_W,Y,AC).
3.4.3. Control
Connectivity is the basic syntactic measure in the sense that others are based on it ([
4], p. 158). In particular, the measure of control (E) proposed by Hillier and Hanson ([
1], p. 109) and implemented below sums up the space denoted G to some space X by its immediate (adjacent) neighbours Z, where G is the reciprocal of the axial connectivity (AC) of each Z and the comma ‘
,’ between predicates should be read as ‘and’:
control(X,Y,E):-aggregate_all(sum(G),(adjacent(X,Z,1),
connectivity(Z,Y,AC),G is 1/AC),E).
This specific rule illustrates how Prolog can be very useful and pedagogical in describing the syntactic concepts. In fact, it suggests the direct relation of control with the original line’s connectivity, that is, with the number of its adjacent neighbours, and the inverse relation with the connectivity of the last ones. In fact, spaces with a strong control, that is, with an E greater than 1, are typically connected with several spaces, namely, ‘cul-de-sacs’ or streets with few connections. Therefore, in order to be controlling, a line must see many spaces, but these spaces should each see relatively little ([
5], p. 16).
3.4.4. Depth
Control is a local measure, since it only considers relations between a space and its immediate neighbours ([
1], p. 109). Another local measure, controllability picks out areas that may be easily visually dominated ([
5], p. 16). It is simply the ratio of connectivity to the total number of spaces 1 or 2 steps away from the original space. In order to compute this measure and the relative asymmetry, which is a global measure that considers the distance from a certain space to the others, we must first define a predicate for depth.
Obviously, axial connectivity is related with the concept of depth 1 in the sense that it is the number of lines 1 step away from the original line. In fact, we can define a rule such that Y is 1 deep from X if X and Y are adjacent:
depth(X,Y,1):-adjacent(X,Y,1).
Similarly, the lines 2 steps away from the original line are 1 step away from the lines adjacent to the root. The following rule explores this recursive nature of depth, that is, the spaces at depth 2 from X are the spaces Y at depth 1 from the spaces Z adjacent to X:
depth(X,Y,2):-adjacent(X,Z,1),depth(Z,Y,1),dif(X,Y).
where the SWI-Prolog [
8] built-in predicate
dif introduces a constraint that is true if and only if the 2-deep line Y is different from the original line X in order to avoid backward relations. The following query returns a list, denoted with square brackets ‘
[Y]’, with the lines 2 steps away from the west side of Avenida dos Descobrimentos:
?-distinct([Y],(depth(av_descobrimentos_W,Y,2))).
where the built-in predicate distinct assures that no previous solution of the second argument bound the list [Y] to the same value. In practice, this useful predicate eliminates the same answer twice. For example, 2-deep lines like Rua Palmira Bastos that can be accessed through two or more lines directly connected with the original space, the west side of Avenida dos Descobrimentos, are included once in the list [Y]. Depth 3 can be defined in the same recursive way by isolating the spaces 2 steps away from the spaces Z directly connected with the original space X, depth 4 by isolating the deep 3 spaces, and so on:
depth(X,Y,3):-adjacent(X,Z,1),depth(Z,Y,2),dif(X,Y).
depth(X,Y,4):-adjacent(X,Z,1),depth(Z,Y,3),dif(X,Y).
…
3.4.5. Justified Graph
It is important to note that a space or line may be accessible at several steps from the same origin. For instance, Rua Gonçalves Zarco is either 1 step away from the west side of Avenida dos Descobrimentos or 3 steps away because we can pass through Avenida da República and the west circulation (pedestrian path
circ_W, see
Figure 4) to get there. This occurs in every axial map with ‘rings’ or ‘islands’. Therefore, we must create a new rule to fix the minimum number of steps D to go from X to Y once again using the Prolog’s predicate
distinct that eliminates duplicated answers as described in the previous section:
graph(X,Y,D):-distinct([Y],depth(X,Y,D)).
We named this predicate ‘
graph’ because it analytically generates the justified graph, or j-graph, for some root X. The resulting j-graph is a ‘picture’ with the depth of all spaces in a complex from a point on it ([
3], pp. 22–23, 72–73). For instance, we can analytically describe the j-graph of the west side of Avenida dos Descobrimentos with the following query:
?-graph(av_descobrimentos_W,Y,D).
to obtain:
{Y -> av_republica, D -> 1}
{Y -> rua_fernao_magalhaes, D -> 1}
…
{Y -> pcta_jose_relvas, D -> 2}
{Y -> circ_W, D -> 2}
…
{Y -> rua_rio_janeiro_E, D -> 4}
3.4.6. Controllability
As suggested by the flowchart in
Figure 5, the predicates
graph (defined in the previous section) and
connectivity (defined in
Section 3.4.2) are the ‘building blocks’ to compute several measures, namely, the above-mentioned controllability (F) using the following code:
controllability(X,Y,Z,F):-connectivity(X,Y,AC),
aggregate_all(count, graph(X,Z,2), D2),
F is AC/(AC+D2).
Figure 5.
Flowchart of Prolog predicates for space syntax.
Figure 5.
Flowchart of Prolog predicates for space syntax.
3.4.7. Mean Depth
Another measure that can be computed with
graph from
Section 3.4.5 is mean depth (MD) referred to in
Section 3.2. It is calculated by summing up the depth values D from a certain root X and dividing by the number of spaces (lines) in the complex minus one ([
1], p. 108). The following implementation introduces two previous (auxiliary) predicates that compute the total depth (TD) and the number of nodes (N) in the complex except the root X:
totdepth(X,Y,TD):-aggregate_all(sum(D),graph(X,Y,D),TD).
nodes(X,Y,D,N):-aggregate_all(count,graph(X,Y,D),N).
meandepth(X,Y,D,MD):-totdepth(X,Y,TD),nodes(X,Y,D,N), MD is TD/N.
Mean depth is an important syntactic measure and its reciprocal can be used as a simple measure of the integration of each space in a complex as suggested by Heitor and Pinelo Silva [
4], p. 162):
integration(X,Y,D,I):-meandepth(X,Y,D,MD), I is 1/MD.
3.4.8. Relative Asymmetry
The value of the total or (even) mean depth can be affected by the number of nodes in a graph. Thus, Hillier and Hanson ([
1], p. 108) proposed a normalisation of MD, which eliminates the bias due to the number of nodes, that is:
asymmetry(X,Y,D,RA):-totdepth(X,Y,TD),nodes(X,Y,D,N),
RA is 2*(TD/N-1)/(N-1).
This formula will give a value between 0 and 1, with low values indicating a space that tends to integrate the whole complex or system, and high values for a space that tends to be segregated from the system. Thus, relative asymmetry (RA), also denoted by ‘i-value’ ([
3], p. 77), is a normalised measure of integration. The Prolog program (
https://swish.swi-prolog.org/p/portela.pl, accessed on 19 July 2023) for Portela has additional predicates to compute radius-r integration and other local measures.
3.4.9. Real Relative Asymmetry
The RA measure can be used to compare different systems with (approximately) the same number of spaces/lines. However, if the systems differ considerably in size, a second normalisation should be applied because a small system always looks more integrated than a large one ([
5], p. 14).
To deal with this empirical problem, Hillier and Hanson ([
1], pp. 109–113) proposed a second standardised measure, the real relative asymmetry (RRA), which is the RA value of the space divided by the RA value of the root of a graph shaped like a ‘diamond’ where there are
k nodes at middle level,
at one level above and below the middle level,
at one level above and below the
level, and so on until there is one node at the root and deepest nodes ([
24], pp. 350–351). The following implementation uses the formula proposed by Kruger and Vieira ([
25], p. 200) to estimate the RA value of the root of that diamond (
d-value):
dvalue(K,DV):-DV is 2*(K*(log((K+2)/3)/log(2)−1)+1)/((K−1)*(K−2)).
rra(X,Y,D,RRA):-asymmetry(X,Y,D,RA),nodes(X,Y,D,N),dvalue(N+1,DV),
RRA is RA/DV.
The inverse of RRA is itself a measure of integration (IHH), the so-called ‘Hillier and Hanson (integration value with) d-value normalisation’ ([
5], p. 25) that ‘captures the extent to which each spatial element contributes to drawing the whole configuration together into a more or less direct relationship’ ([
2], p. 27):
integrationHH(X,Y,D,IHH):-rra(X,Y,D,RRA), IHH is 1/RRA.
3.4.10. Relative Ringiness
RA and RRA are measures of asymmetry. In addition, distributedness can be evaluated using either control (or controllability) or relative ringiness (RR). The RR of some space is the number of independent rings that pass through that space over the maximum that can pass through it, which will be the total number of nodes in the system minus one ([
1], pp. 153–154). Detecting the number of rings that pass through some space is a very difficult task to be performed by a computer: for instance, the software DepthmapX 0.8.0 does not compute RR. As a programming language concerned with artificial intelligence, Prolog can do the task relatively well in most cases. In fact, the following code will produce accurate estimates for RR, namely, where the number of independent rings is lesser than axial connectivity:
graph2(X,Y,D):-distinct([Y],(depth(X,Y,D),D>1)).
ring(X,Y,Z,D):-adjacent(X,Y,1),graph2(Y,X,D),connectivity(X,Z,AC),
AC > 1.
rings(X,Y,Z,D,R):-aggregate_all(count,(ring(X,Y,Z,D)),C),
R is max(C-1,0).
ringiness(X,Y,Z,RR):-rings(X,Y,Z,D,R),nodes(X,Y,D,N), RR is R/N.