Академический Документы
Профессиональный Документы
Культура Документы
doi:10.1177/0265813515610671
Robert Woodbury
School of Interactive Arts and Technology Simon Fraser University Surrey 250 - 13450
102nd Avenue Surrey, BC V3T 0A3 Canada;
e-mail: rw@sfu.ca
Received 07 April 2014; in revised form 28 October 2014
Abstract. Shape schema grammars generalize parametric shape grammars so that both
rules and the objects to which they apply are expressed with shape schemata. This paper
defines shape schema grammars. It starts with a notation for schemata in general and
shape schemata in particular. Schema equality is shown to have at least three possible
definitions, of which schema consistency is the most useful. A limited notion of shape
schema maximality potentially reduces the size and redundancy of a given schema. Shape
schema subpart is a multifunction returning all of the possible ways that one shape
schema can be embedded in another. Shape schema difference and addition complete the
basic mathematical operations over shape schemata required to define shape schema rules,
grammars and languages.
1 Introduction
This paper introduces shape schema grammars, in which rules and the representations
over which they operate remain schemata throughout a computation. First, a few
observations. Virtually all published shape grammars are parametric shape grammars.
Apparently conventional shape grammars are not very appealing in practice. Yet all of
the published general shape grammar interpreters are conventional, notwithstanding
a few heuristic-based programs such as (McCormack and Cagan, 2002). Apparently
parametric shape grammars are difficult to implement. The distance between the
representations researchers want to use and those they can use in practice is ever larger:
virtually all of the published design grammar interpreters work across representations
that lack, in some way, the property of emergence in their representations (Mller
et al., 2006) (though this can be argued in systems such as Genesis (Heisserman,
1994; Heisserman and Woodbury, 1993; Heisserman, 1991) and SEED-Config (Akin
et al., 1997; Flemming and Woodbury, 1995)). Consequently, researchers can (and
do) devise grammars but cannot readily use those grammars to generate designs,
having to write special-purpose, often unvalidated, code to do so (Flemming,
1987; McCormack and Cagan, 2002). Since, in general, little can be known of a
design space (the language of a grammar) from examination of the grammar alone,
grammatical design researchers are limited in the insight they can gain from their
work. Yet researchers who have used a grammar interpreter in creating grammatical
understandings of designed artifacts will attest to the usefulness of doing so, see
(Flemming, 1987).
An Introduction to Shape Schema Grammars 153
2 Notation
S
N denotes the natural numbers, the set f1, 2, . . .g. N0 is the set N f0gthe natural
numbers starting at 0. For n 2 N, n is the set f1, . . . ng. 0 is the empty set .
154 R Woodbury
Further we presume a nite set of types Type, the classes Real, Bool f0, 1g, Collection
and Schema, and variables over these classes. We use the following notation:
3 Schemata
A schema s^ comprises a type, an object and a set of constraints and is described as the
following
thO, Ei
where t is the type of the schema, O the object of the schema and E the constraints of the
schema (we use E for Equations as the obvious C nds use elsewhere). The type is drawn
from Type. For every type t 2 Type there is a xed structure for O, either a single variable,
An Introduction to Shape Schema Grammars 155
a tuple of schemata (each with a type) or a set (of possibly variable cardinality) of
schemata of the same type, yielding respectively a basic, tuple or set type.
Schemata whose objects are taken from O are called sub-schemata of s^. A path is a
tuple of indices and is interpreted with respect to a schema by using successive elements
of the path to access corresponding sub-schemata of the schema. In this paper, paths
are short, so we use successive subscripts, that is, a^ ij to denote the object at the end of
^ ji or a:i:j.
the path a:hi, ^ Further, for typographical clarity, we use the single notation a^ij
to denote both a^ij , the object at the end of the path, and abij , the schema named by the
path. The contained variables of a schema a^ comprise the variables accessible by
following paths from a. ^ An equivalent denition of the contained variables of a
non-basic schema a^ are the variables found in the sub-schema of a^ that are typed to
basic types. We omit the nal element of any path accessing a contained variable
(which should be O to access the object of the basic schema at the end of the path).
The constraints of a schema are expressions over its contained variables and may
employ other variables local to E.
Types thus act as templates by which schemata can be created by assigning specic
structures to O. A schema acts as a template by which instances can be created by
assigning specic values to the variables of the schema that are consistent with the
constraints of the schema. Instances of a basic type are called basic instances, and
similarly with tuple and set types.
By convention, instances can be written without constraints, so that realh5i is an
instance of a real schema with value 5. Schemata with null constraint sets can also be
written without constraints, so that realhai is a real schema with no constraints, i.e., a
real schema whose value can be any real. A ground schema has only one instance, i.e.,
all of its contained variables admit only a single value.
As objects, schemata behave intensionally, that is, identity between schemata is
token identity as dened by Carpenter, (1992, Ch. 8). As such, there is no formal
notion of schema equality beyond token identity. This is in contrast to extensional
behaviour in which two identical schemata would be taken to represent the same object
in the world. In contrast, standard shapes are almost completely extensional: a
maximal line represents and is the only representation for an actual line in a shape.
In Section 4.5 the operation of necessary reduction will be shown to recover a limited
notion of extensionality for shape schemata.
Schemata are accessed with the following functions.
t^s the type of s^.
O^s the object dened in s^.
E^s the set of constraints dened in s^.
E ^s the set of constraints obtained by concatenating E^s and E v for all v 2 O^s.
^s an instance of the schema s^. ^s can also be written as s_. Every instance of a
schema s^ must satisfy E ^s.
I ^s the instance set of s^the set of all instances of the schema s^. I ^s is a universe
because its members are pointsets.
A schema is satisable if it has at least one instance, or equivalently, if its constraints
are solvable, or equivalently, if its set of instances is non-null, that is, I ^s 6 .
The set of all schema of a particular type t is called the universe of t and is
denoted by b Ut . The powerset of a universe b Ut (comprising all sets of a type t) is
b
denoted 2 . The n-ary Cartesian product of b
Ut
Ut is denoted b U n and the set of all
t
tuples of b
Ut is denoted b
UtN .
156 R Woodbury
4 Shape schemata
Shape schemata are built from line, point and real schemata.
A real schema has the form
realhr, Ei
where r is a real variable and E is a set of constraints over the variable r. For example,
s^ realhr, f0 < r, r 4gi
denotes a real schema for which I ^s comprises all values greater than zero and less
than or equal to four.
A point schema has the form
^ yi,
pointhhx, ^ Ei
where x^ and y^ are real schemata and {x, y} acts as an index set. The point schema p^
expands to
p^ pointhhrealhr, Ri, realhs, Sii, Ei
where E p
^ R [ S [ E. The set E can contain constraints naming both r and s, while
the set R can refer only to r and S only to s.
A line schema has the form
d Ei
d endg,
linehfstart,
d and end
where start d are point schemata. It expands analogously to point schema as
d and end
above. As will be explained later, the point schemata start d are geometrically
unoriented in a line schema. Nonetheless, the elements of the index set {start, end}
serve to access the rst and second elements of a line schema.
The function p, ^ describes a set of constraints that places a point schema on a
^ l
line schema.
^ fp^ l^start tl^end l^start g
^ l
p,
^ gives the parameter t from the above equation.
^ l
The function tp,
We overload to also express constraints that place a line schema on another line
schema.
^ ftp^1 , l
p^1 , p^2 , l ^ tp^2 , lg
^
shapehfl^1 , . . . , l^n g, Ei
where l^1 , . . . , l^n are line schemata and n acts as an index set. Note well that the line
schemata in a shape schema form a set, not a tuple: their order does not matter in
dening the shape schema.
An Introduction to Shape Schema Grammars 157
A shape schema instance is a shape. A line schema instance is a line. A point schema
instance is a point.
Figure 1. (i) Line schemata are drawn with open circles as their startpoints and open diamonds at their
endpoints, and with shading along the right-hand side of the line (going from start- to endpoint). The actual
start- and endpoint of a schema are the centroids of the circle and diamond respectively. (ii) Line schema
instances have filled endpoints. Patterns and weights identify particular line schemata and their instances, for
example, the grey schema corresponds to the grey instance. In the upper instance, line instance b_ (an instance of
^ is a sub-line of line instance a_ (an instance of a^ ) and is shown graphically as embedded within it. In the lower
b)
instance, the embedding relationship is reversed: line instance a_ is embedded in line instance b._ Both cases may
^
be possible for a given a^ and b.
158 R Woodbury
Figure 2. Drawing line schemata with an open circle at the startpoint and an open diamond at the endpoint
supports reading line schemata displayed with coincident start and endpoints. Line schema a^ goes from p^ to q^ , b^
from q^ to ^r, c^ from s^ to q^ , and d^ from r^ to p^ .
Figure 3. The endpoints of the line schema a^ are constrained to lie within the dotted areas shown.
Figure 4. Line schemata are asymmetric with respect to their start- and endpoints. (i) The line schema a^ starts
at p^ and ends at q^ . Another line schema b^ is orthogonal to a^ , starts at r^, one-third of the distance between the
startpoint and endpoint of a^ and q^ and is one-half of the length of a^ . (ii) Reversing the start- and endpoints of a^ ,
yields a line schema a^ 0 producing a different instance set for its related schemata: I b^ end 6 Ib^ 0end .
An Introduction to Shape Schema Grammars 159
Figure 5. Schema may be visualized by drawing the schema as if it were an instance. All subfigures (i), (ii), (iii)
and (iv) render the same schema.
representative instance s_ of s^. Figure 5 shows four dierent visualizations of the same
shape schema.
rulehhl,^ r^i, Ei
160 R Woodbury
where l^ and r^ are shape schemata and {l, r} is an index set. The constraints of a shape
schema rule describe how l^ and the r^ are related to each other. Further, for a given rule
schema w^ the functions lhsw^ returns the left hand side, and rhsw^ returns the right
hand side of the rule.
Building on the Stinys notation (Stiny, 1991), we use the following shorthand to
denote the universes and Cartesian products of the above types.
A rule schema r^ is a b
Ui, j rule schema when both r^lhs and r^rhs are in b
Ui, j .
a^ b^ iff I a ^
^ I b
Two schemata are consistent when, under some identication of sub-schemata, the
instance sets of the two schemata intersect.
a^ b^ if I a ^ 6
^ \ I b
These denitions require the specication of how the sub-structures of the argument
schemata are to be identied. The three kinds of schemata (basic, tuple and set) each
have their own identication method.
Basic The single item of a basic schema is given by its contained variable. Therefore
two basic schema are identiable if they are of the same type.
Tuple Two tuple schemata are identiable if they are of the same type, if their cardinality
is the same and if each of the members of the tuples can be pairwise identied.
Set Two set schemata a^ and b^ are identiable if they are of the same type, if they are of
the same cardinality, and if some permutation b ^ of b^ can be identied with the tuple
^ ^
tuplea generated from a in the order given.
From the rules above can be generated sets of identication equations ID ida, ^
^ b
between two schemata according to the following. Let
denote the identication of
two variables.
An Introduction to Shape Schema Grammars 161
a^ b^ if E a ^ [ ida,
^ [ E b ^
^ b is solvable
Uln X b
We overload as the multifunction : b n
UBool ! b
Uln where
l^ linehfpointa, ^ Ea
^ pointbg, ^
^ [ Ebi
An Introduction to Shape Schema Grammars 163
Figure 6. Necessary reduction Rule 1 removes line schema b^ and combines its constraints with those of a^ .
Line schemata a^ and b^ are offset from their actual coincidence for visual clarity.
Figure 7. The four ways that two line schemata can combine with necessary reduction Rule 2. Line schemata
a^ and b^ are offset from their actual coincidence for visual clarity. Of course, at most one of these conditions can
occur for two given shape schemata, and there may be no necessary reduction at all.
replaces a^ and b^ whenever all of the following apply: other pointa ^ is necessarily
^ other pointb
coincident with b, ^ is necessarily coincident with a^ and other pointa
^ is
necessarily coincident with l.^ The last condition is needed when a^ and b^ necessarily
overlap on a single point, that is, when they share only a single extreme point
necessarily in common. As in Rule 1, the constraints of both line schemata are kept.
The necessary reduction of a shape schema s^, written nr^s, is gained by recursive
pairwise reduction of its constituent line schemata.
164 R Woodbury
Figure 8. Missed reduction. a^ and b^ will not reduce even though the segment from b^ start r^ to b^ mid is necessarily
coincident with a^ . In this case s^ is necessarily on the line represented by a^, but either s^ is between p^ and q^ , or q^ is
between b^ mid and s^. Line schemata a^ and b^ are offset from their actual coincidence and the constraint region of s^ has
finite thickness for visual clarity.
Earlier, we noted that full extensionality over shape schemata is dicult to achieve.
Consider the two shape schemata in Figure 8. Both the startpoint and the midpoint
of b^ are explicitly constrained to be on a^ (and are therefore necessarily coincident with
^ The endpoint of b^ can either be on or not on a.
a). ^ Clearly the part of b^ from b^start to
b^mid is doubly represented, yet a^ and b^ are not necessarily reducible. This pair of line
schemata could be represented as the two schemata a^ and c^ linehfb^mid , b^end gi.
Discovering this and similar reductions seemingly can only be done by doing
algebraic theorem proving over the constraint set of a schema.
Necessary reduction partitions a shape schema into a set of mutually necessarily
irreducible line schemata.
In addition to necessary maximality we can dene another notion of constraint
maximality or just maximality in which coincidence is substituted for necessary
coincidence in the denition above, forming constraint reduction rules or just
reduction rules. There may be multiple constraint maximal representations of a shape
schema, that is, taken together, the constraint reduction rules are a multifunction.
Collectively the constraint maximal representations of a shape schema cover
(perhaps multiply) all instances of the original schema.
In essence, the discussion on schema subpart below describes the constraint maximal
representation for shape schemata.
For instances of line schemata c_ linehfc_start , c_end gi and t_ linehft_start , t_end gi where
c_start , c_end , t_start and t_end are taken as point instances
c_ v t_ if c_start t_ and c_end t_
For instances of shape schemata c_ shapehfc_1 , . . . , c_m gi, t_ shapehft_1 , . . . , t_n gi where
c_i and t_i are taken as line instances
c_ v t_ if _ v reductiont_
reductionc
where reductionx is the maximal line representation of the shape instance x and v is
the usual shape grammatical notion of subpart (Stiny, 1980).
Implicit in the instance subpart relations for lines and shapes are total orderings that
resolve exactly how one instance is a subpart of the other (Krishnamurti, 1980). In the
case of lines, the order of the endpoints of one line embedded in another is
unambiguously given by the coordinate values of the points involved. In the case of
shapes in U 1, 2 , the set of lines comprising a shape is partitioned by a collinearity
equivalence relation (which is totally ordered) and, within each such equivalence
class, is totally ordered by the order that points appear along the carrier line of the
equivalence class (Krishnamurti, 1980). These orderings need to be captured in a
representation of the subpart relation over line and shape schemata if that subpart
relation is to be used in rule application. For example, consider two line schemata c^
and t^ for which c^ v t^. At the instance level it is either the case that
t_start c_start c_end t_end or t_start c_end c_start t_end , where is with respect to the
distance (or, equivalently, the point-on-line parameter) along t_ measured from t_start to
t_end . For shape schemata, distinctions are created by the reductions of both schemata.
Further, Figure 9 shows that it may be the case that s^ v t^ and t^ v s^ both hold. The
number of subpart matches for Figure 9(iii) needs explanation. In Appendix A, Table 1
summarizes the top-level categories that occur in the matching process, while
Figures 20, 21 and 22 demonstrate each category. The remainder of the appendix
explains each category in detail.
The subpart relation over shape schemata is the partial multifunction
v: bUi, j X b
Ui, j ! b Uv
that captures the existence of at least one occurrence of instance subpart between instances
of the schemata involved. Its result as a subpart schema describes classes of such instances
each of which admit a single common representation, as a schema, for all of its instances.
Subpart schemata returned by v must capture the order information necessary to
unambiguously characterise a class of instance reductions up to collinear equivalence
classes and maximal line orderings in an equivalence class. This bears explanation.
Consider a pair of unreduced shapes c and t such that reductionc v reductiont
and such that c 2 I c ^ and t 2 I t^. s^ v c,
^ t^ captures explicitly as constraints the
information that describes how the lines of c and t are reduced to maximal lines, and
how maximal lines from c are embedded in maximal lines from t. In order to abstract
across a class of instances, we must do this as orderings, i.e., without reliance on
coordinate values. Thus, from a shape perspective, in the shape schema subpart
relation s^ v c, ^ t^ we need to characterise the following:
1. how lines from c^ and t^ are reduced to maximal lines,
2. which maximal lines from t^ suer which maximal lines from c^ embedded within
them, and
166 R Woodbury
Figure 9. The shape schema subpart relation can go both ways: s^ v ^t and ^t v s^ may both hold. (i) s^ is
constrained to be an equilateral triangle, of fixed or variable size. ^t comprises three unconstrained line schemata.
(ii). One of 48 possible s^ v ^t. (iii) One of 1578 possible ^t v s^. Due to shape reduction and line schema
orientation, the number of subpart matches can grow explosively.
An Introduction to Shape Schema Grammars 167
Figure 10. Line schema reduction is not unique. The set of line schemata in (i) can be reduced in different
ways, two of which are shown in (ii) and (iii). In (ii) the reduced line comprises ^j, ^l, m
^ and k^ in that order, each
constrained so that adjacent pairs overlap. Line schema n^ is constrained to lie anywhere on the result. In (iii) the
reduced line comprises ^j, n^ and k^ in that order, each constrained so that adjacent pairs overlap. Line schemata ^l
and m^ are constrained to lie anywhere on the result. Clearly, these are only two of many possibilities. For
instance, all the line schemata could be reoriented (start- and end-points exchanged) with each reorientation
combination yielding a new result.
functions version
scope Apath
Before going into detail, we abstract the process for the candidate as follows.
3 3 2 2
^ ! c B ! c L ! c M ! c m^ ! c L0 ! c B0 ! C
Oc
Figure 11. Step 1 in determining an s^ 2 v ^c, ^t: given p 2, group line schemata from c^ and ^t. Note that the
figure represents only one arbitrary choice of p and only one configuration that can result from this step.
In the above, a right arrow (!) signies an operation or sequence of operations. The
3
notation W ! X signies that the set W is composed of one or more X0 s (W must be
2
a set of sets). The notation Y ! Z means that Y is a member of Z. The specic
^ stands for candidate; the t^
variable names are mnemonic in the most part: the c^ in Oc
^
in Ot stands for target; B stands for Blocks from the candidate or target lines; L
stands for sets of coLinear Lines; M and m^ stand for a Maximal line; C stands for
Candidate; and T stands for Target. Variable names other than these are used in local,
specic situations.
Step 1. See Figure 11. Choose collections of line schemata from c^ and t^. Each collection from c^
will form a set of maximal lines that will be embedded in single maximal lines formed from the
collections from t^. Associate each collection from c^ with a collection from t^. Specically, take
the following steps starting with Step 1a.
170 R Woodbury
^ into a tuple
Step 1a. Partition Oc
cB ^
tupleOc
p
of length p Ot^ blocks. Each of the blocks in c B will form a set of maximal lines
that will be embedded in a single maximal line from t^. Since c B partitions Oc,
^ all lines
in c^ will be considered for the match.
Step 1b. Choose a subset
tB Ot^
q
of Ot^ of q elements such that q p. Only the elements of t B will participate in the
subpart relation.
Partition t B into a set
t B t B
p
of p blocks. Each block in t B will form a single maximal line that will receive a set of
maximal lines from a block from c B.
Permute t B into the tuple
tB
t B
For a given value of p, any c B can be combined with any t B. That is, elements of the
Cartesian product of c B and t B now describe the line schemata from c^ that will be
embedded in reductions of line schemata from t^, but do not describe how these
embeddings will occur.
Step 2 deals with the individual blocks of lines partitioned above in Step 1a. Each c L 2 c B is a
collection of line schemata that will reduce to an ordered tuple of collinear maximal line
schemata. For each c L 2 c B create a corresponding c L0 by the following steps.
Step 2a. Divide each c L 2 c B into two sets c Ls and c Ln , where c Ls is a non null subset of c B and
c Ln c L c Ls . Here s stands for spanning tuplethe lines in the s sets comprise possibly several
spanning maximal lines. In contrast, n stands for nospan, signifying that these lines will be
entirely embedded within maximal lines made from lines in s sets. See Figure 12. Line schemata
in the set c Ls will be combined into an ordered tuple of maximal lines, while those from c Ln will
be embedded within these maximal lines.
Step 2b. Partition c Ls into a collection c Ls of length l. See Figure 13.
c Ls c Ls
l
Each of the blocks c Ms 2 c Ls will act as a spanning tuple to form a single maximal line
and has length m.
For each c Ms there is a corresponding c Mn . Assign each line schema in c Ln to a
particular c Mn . Each such line schema will be embedded in a reduced line generated
from the chosen c Ms .
r
Step 2c. For each c Ms choose a right permutation c Ms r c Ms . This right permutation
establishes the order of the lines in the spanning tuple. See Figure 14. Clearly, when m 1, the
right permutation has no eect.
r r
Step 2d. Orient the line schemata in c Ms to produce c Ms as follows:
r
r c Ms l > 1, m > 1
c Ms r
c Ms otherwise
An Introduction to Shape Schema Grammars 171
Figure 12. Step 2a in determining an s^ 2 v ^c, ^t. Divide each c L 2 c B into two blocks c Ls and c Ln . In this and the
rest of the Rule 2 figures, the sizes of c Ls and c Ln are chosen to illustrate rule. They are not related to the figures
showing Rule 1. Throughout the Rule 2 figures, the names c^ x refer to the same (but possibly reoriented) line
schemata.
Figure 13. Step 2b in determining an s^ 2 v ^c, ^t. Partition c Ls into a collection c Ls of length l comprising blocks
c M. In this case l 2. For each c Ms create a corresponding set c Mn . Assign each element of c Ln to one of the sets
c Mn .
Figure 14. Step 2c in determining an s^ 2 v ^c, ^t. For each c Ms choose a right permutation to establish an
r
order c Ms of the line schemata in c Ms .
172 R Woodbury
r r
Figure 15. Step 2d in determining an s^ 2 v ^c, ^t. Orient the line schemata in each c Ms to produce c Ms . If
r
there is only one c Ms in c Ls and it is itself a singleton, do nothing.
r
See Figure 15. Blocks c Ms for which the length of both c Ms and the enclosing c Ls is
one, that is, m 1 ^ l 1, need not be oriented as they stand by themselves for
maximal lines, the orientations of which are accounted for later.
r
Step 2e. See Figure 16. Generate from each of the c Ms a maximal line schema m,
^ according
r
to the following (for readability in the following equations we write c Ms as M):
m^ start M1start
m^ end Mmend
[
m
Em^ EM ^ j [
j1
The eect of the above is that each pair of successive line schemata are constrained to
r
overlap; all of the line schemata in c Ms are constrained to lie on m; ^ and the
endpoint of any line must not overlap the startpoint of the successor of its successor.
Embed the line schemata from c Mn into m: ^
[
^
Em ^ [
Ea
^ c Mn
a2
^
fa ^ a^ 2c Mn g [
mj
^
Em
Step 2f. See Figure 17. From the line schemata m^ in Step 2e, create the set c L0 fm^ j jj 2 lg of
line schemata. The line schemata composing c L0 will each be embedded in a line schema
generated from a corresponding element of t B.
Choose a right permutation of c L0
r 0
cL r c L0
This right permutation establishes the orientation in which the the maximal line
schemata in c L0 will be embedded in the maximal line schema computed from the
corresponding element of t B.
r 0
Step 2g. See
Figure 17. Orient the line schemata in cL to produce c B0 as follows:
r
0 c L0 l>1
cB r
0
cL otherwise
An Introduction to Shape Schema Grammars 173
r
Figure 16. Step 2e in determining an s^ 2 v ^c, ^t. Form a single line schema from each c Ms in the order and
orientation computed above and embed the corresponding c Mn in the line schema. For clarity we preserve
names in the form c^ x from previous figures.
Figure 17. Steps 2f and 2g in determining an s^ 2 v ^c, ^t. c L0 is a collection of collinear lines, each of which will
r
become a maximal line. c L0 is a unique ordering of the lines. c B0 orients these lines, each in one of their two
possible orientiations. The result will be embedded in the target.
r
Blocks c L0 for which l 1 need not be oriented as they stand by themselves for
maximal lines, the orientations of which are accounted for later.
0
The tuples of line schemata composing the tuple C hc Bi ji 2 pi will be embedded
as ordered and oriented into lines reduced from t B.
Step 3. Each t M 2 t B is a collection of length t m of line schemata that will be reduced to a
single maximal line schema m^ by using all of t M as a spanning tuple (for readability we omit the
index from t m and write, simply, m).
174 R Woodbury
r
Figure 18. Steps 3a, b & c in determining an s^ 2 v ^c, ^t. Each t M is ordered as tM and then the individual
r
schemata are oriented as t M.
r
Step 3c. See Figure 18. Generate from each of the t M a maximal line schema m, ^ according
r
to the following (for readability we write t M as M and the length t m of t M as m):
m^ start M1start
m^ end Mlend
[
l
^
Em EMj [
j1
All of the line schemata in tM are constrained to lie on m^ , each pair of successive line
schemata are constrained to overlap and the endpoint of any line must not overlap the
startpoint of the successor of its successor.
Step 3d. Orient each t m^ to produce t B0 t m.
^
The line schemata composing the tuple
T ht B0i ji 2 pi
will have the line schemata from C embedded in them.
Step 4. Identifying Ti with Ci, i 2 p gives the line schemata from c^ (whose elements have been
reduced to ordered tuples of oriented maximal line schemata) that will be embedded in
reductions of line schemata from t^ (some of whose elements have been reduced to maximal
line schemata), and describes how these embeddings will occur. It remains only to embed the
line schemata in each Ci in the line from the corresponding Ti.
176 R Woodbury
[
p [
li
^
Ez Cij t^i [
i1 j1
[
p l[
i 1
Cjend , Cj1start , t^
i1 j1
linehhl^m1end , k^end i, i
g
The function difference : b Um ! b Us creates from a given subpart schema z^ a shape
schema s^ representing the dierence between pairs t^i 2 z^T and Ci 2 z^C . Every line
schema in Ci must be removed from the line schema t^i , leaving behind a set of line
schemata. The constraint set E of the subpart relation carries all of the constraints of
the original shape, the rule and the matching process.
Us X b
The function : b Us ! b
Us is the schema produced by unioning Oa ^
^ and Ob,
^
^ and E b and taking the necessary reduction of the result.
unioning E a
^ nrshapehOa [ Ob, E a [ E bi
^ b
a,
An Introduction to Shape Schema Grammars 177
rulehhl,^ r^i, Ei
where l^ (left hand side) and r^ (right hand side) are shape schemata and E is a set of
^ is the left hand side and rhsw
constraints. Further, recall that lhsw ^ is the right hand
side of a rule w. ^
Shape schema rules are matched to target shapes. The partial multifunction
match : bUs X b U ! ! b
Um produces a match schema recording how a rule w^ matches
to a shape s^.
^ matchhhz,
match^s, w ^ Ei, where
^ rhswi,
^ s^, and
z^ v lhsw,
^
E E^s [ Ew
A match of a shape schema rule can be applied to produce a result. The function
apply : b
Um ! bUs takes a match schema and returns a shape schema that is the
^ to the subpart schema
result of applying the matched rule right hand side rhsm
^
subpartm.
^ shapehL, Ei, where
applym
^ rhsm
L subpartm, ^ and
^
E Em
A shape schema rule r^ applies to a shape schema s^ when there is a match of r^ into s^, and
is applied when the resulting match schema is applied. More formally, if s^ and t^ are
shape schemata and t^ is the result of applying rule r^ to s^ then
t^ applymatch^s, r^
The sentential forms FG, i^ of a shape schema grammar G with respect to an initial
shape i^ comprise i^ plus the shape schemata at the end of all of the derivation sequences
of G with respect to i,^ or equivalently, the shape schemata reachable by zero or more
recursive application of the rules of the grammar to the initial shape.
[
^
FG, i^ fig ft^ji^) t^g
G
178 R Woodbury
The derivation space of a shape schema grammar G with respect to an initial shape i^
comprises the derivation relation of the grammar, that is, pairs of schema where the
second is derivable from the rst.
fh^s, t^ij^s ) t^ and s^ 2 FG, i^g
G
An equivalent denition is the transitive closure tc() of the individual derivation
steps
tcfh^s, t^ij^s ! t^ and s^ 2 FG, i^g
G
The language of a shape schema grammar with respect to an initial shape are those
sentential forms to which no more rules apply.
We omit both the usual terminal and non-terminal alphabet distinctions as well as
the initial shape in dening grammars. In the grammatical literature in general and in
the shape grammar literature in particular, labels from these alphabets are largely used
as a declarative control mechanism to determine which of the sentential forms of the
grammar are well-formed in some sense. The initial shape is used to encapsulate
together a grammar and its language. Our motivation is to allow grammar
composition and explicit control of execution. Other authors have taken similar
approaches. For example, Heissermans Boundary Solid Grammars (Heisserman,
1994) uses a state to determine when a grammatical process is complete. Carlson,
(1993) does away with all control mechanisms internal to a grammar and the
initial shape within a grammar itself, and provides an algebra for expressing
complex composition and control of grammars.
8 Implementation
The author implemented a shape schema grammar interpreter, rst in clp(R) (Jaar. and
Lassez, 1987), and then in Sicstus Prolog with constraint logic programming extensions.
A research assistant wrote a graphical interface in Java and JLog (Holst, 2014). Its
algorithms are navethey are very close to the mathematical specication above. The
reader might infer correctly that the matching displays exponential time complexity.
However, this is inherent in the problem itself: there can be exponentially many ways
that schema match, so an algorithm that nds all matches will itself be exponential. Thus
the algorithm is intractableit does not run in polynomial time with respect to its inputs.
The implementation is useful for matching small rules into small shape schemata (less
than about eight lines each). It suces for demonstrating matches such as those shown in
Figure 9, much in the spirit of Stinys numerous papers and book (Stiny, 2008).
At this point, the lack of apparent order relations over point, line and shape
schemata hinders progress towards an ecient implementation. I conjecture that no
such order relation exists and therefore that progress will be made by seeking
restrictions on generality that yield ecient match algorithms. For instance, limiting
or eliminating the reduction step in matching greatly reduces algorithm complexity.
9 Conclusion
In addition to dening a more general mechanism for parametric grammatical action,
shape schema grammars provide the rst general algorithm for parametric
grammatical action over shape-like objects. The fact of a general algorithm is the
An Introduction to Shape Schema Grammars 179
Acknowledgements
I would like to acknowledge the support given by the Canadian NSERC Discovery Grants program, the
GRAND Network of Centres of Excellence, the Australian Research Council Small Grants Scheme,
Simon Fraser University, the Chair of Information Architecture at the Swiss Federal Institute of
Technology (Zurich) and The University of Adelaide. I would also like to thank Teng-Wen Chang and
Kewu Li for their work on an early, partial prototype of the implementation; Glendon Holst for porting
the code to Sicstus Prolog, and designing and implementing the Java/JLog interface; Karine Kozlova for
programming assistance; and Kellogg Booth and Sinisa Kolaric for edits and suggestions.
References
Akin O Z, Aygen T-W, Chang S-F, Chien B, Choi M, Donia S J, Fenves U, Flemming J H, Garrett N,
Gomez H, Kiliccote H, Rivard R, Sen J Snyder, Tsai W-J, Woodbury R, Zhang Y, 1997, SEED: A
Software Environment to support the Early phases of building Design. The International Journal of
Design Computing. Accessed on 28 Oct 2014 at http://pandora.nla.gov.au nph-wb/19990704130000/
http://www.arch.usyd.edu.au/kcdc journal/vol1/papers/emming/index.html
Carlson C, 1993, Grammatical Programming: An Algebraic Approach to the Description of Design Spaces.
PhD thesis, Department of Architecture, Carnegie-Mellon University.
Carpenter B, 1992, The Logic of Typed Feature Structures with applications to unication grammars, logic
programs and constraint resolution. Cambridge Tracts in Theoretical Computer Science. Cambridge
University Press.
Flemming U, 1987, More than the sum of parts: the grammar of Queen Anne houses Environment and
Planning B: Planning and Design 14 323350.
Flemming U, Woodbury R F, 1995, Software Environment to support Early phases in building Design
SEED: Overview ASCE Journal of Architectural Engineering 1(4) 147152.
Heisserman J, Woodbury R, 1993, Generating languages of solid models, in Proceedings of Second
ACM/IEEE Symposium on Solid Modeling and Applications pp 103112.
Heisserman J A, 1991, Generative Geometric Design and Boundary Solid Grammars PhD thesis,
Department of Architecture, Carnegie-Mellon University.
Heisserman J A, 1994, Generative geometric design IEEE Computer Graphics and Applications 14(2)
3745.
Holst G, 2014, JLOG/JScriptLogProlog in Java. Accessed on 3 April 2014 at http://sourceforge.net/
projects/jlogic/
Jaar J, Lassez J-L, 1987, Constraint logic programming, in Proceedings of the 14th ACM SIGACT-
SIGPLAN Symposium on Principles of Programming Languages, POPL 87, New York, NY, USA
pp 111119. ACM.
Krishnamurti R, 1980, The arithmetic of shapes Environment and Planning B: Planning and Design 7
463484.
Li K, Woodbury R, Radford A, 1998, A comparison of shape grammars, parametric shape grammars and
shape schema grammars in Proceedings of the Second International Conference on Mathematics and
Design Ed J Barrallo (San Sebastian, Spain) pp 2734 The University of the Basque Country.
McCormack J P, Cagan J, 2002, Supporting designers hierarchies through parametric shape
recognition Environment and Planning B: Planning and Design 29(6) 913931.
Muller P, Wonka P, Haegler S, Ulmer A, Gool L V, 2006, Procedural modeling of buildings ACM
Trans. Graph 25(3) 614623.
Stiny G, 1980, Introduction to shape and shape grammars Environment and Planning B: Planning and
Design 7(3) 343352.
Stiny G, 1991, The algebras of design Research in Engineering Design 2(3) 171181.
Stiny G, 2008, Shape: Talking About Seeing and Doing. The MIT Press.
Woodbury R F, 2002, A denition of shape schema grammars in Western Computer Graphics
Symposium, Vernon, BC, pp 103112.
180 R Woodbury
Figure 20. All three candidates are placed into a single target. This yields 135 possible candidate
arrangements.
Figure 21. With two target lines selected, the third will not receive a candidate. All of the candidate lines
must be distributed across these two targets. There are a total of 30 possible candidate arrangements.
An Introduction to Shape Schema Grammars 181
Figure 22. Three target lines. With only one possible target arrangement comprising the three lines of the
target, each line of the candidate must be allocated to a line of the target. This yields a single candidate
arrangement.
Figure 23. The six cases for one target line. All candidates must be placed in a single line, yielding six different
basic cases. The table enumerates the number of possibilities at each stage of generating the candidate (the
matches to the single target are given in Table 1). In all cases there is only a single member c L to consider: the
collection of all candidate lines that will go into one target line.
182 R Woodbury
Table 1. Column 1 (# of Targets) is the number of target lines for a particular match. All candidate lines will be
arranged into the same number of groups. In this example it can have values of only 1, 2 or 3, corresponding to
choosing a single line, two lines or three lines into which to embed subparts. Column 2 is the number of
candidate arrangements of the three candidate lines if they are (1) all grouped together into a single candidate,
(2) divided into two candidates or (3) divided into three candidates. Column 3 is the number of target
configurations. If there is only one target line, it can be any of the three lines. Two target lines leaves one line
unused and there are three ways of selecting that line. Three target lines can be chosen in only one way: by
choosing all lines. Column 4 is the number of permutations of candidates into targets. Column 5 shows the
number of ways that candidates can be embedded into targets by re-orienting the targets. There are 2n such
ways, where n is the number of target lines.
Total 1578
Table 2. A single target line implies six cases distinguished by the number of spans (distinct lines) in the
candidate, and how lines overlap and are embedded in the spans.
Case 2a 2b 2b 2c 2d 2f 2g Subtotal
r r r 0 r 0
c Ls c Ls c Mn c Ms c Ms cL cL
(i) 3 1 1 1 1 1 1 3
(ii) 3 1 1 1 4 1 1 12
(iii) 3 2 2 1 1 1 4 24
(iv) 1 1 1 3 8 1 1 24
(v) 1 3 1 1 4 1 4 48
(vi) 1 1 1 1 1 3 8 24
Total 135
Table 3. With two target lines, the candidate must be partitioned into two and each partitition assigned to a
target. There are three ways of achieving such a partition. In case (i) the only additional choice is which line to
select for the sole span. In case (ii), the only choice is the orientations of the lines comprising the sole maximal
line that forms the candidate. In case (iii) the sole choice comes when the two maximal lines are oriented. Case
numbers refer to those in Figure 21.
Case 2a 2b 2b 2c 2d 2f 2g Subtotal
r r r 0 r 0
c Ls c Ls c Mn c Ms c Ms cL cL
(i) 3 1 2 1 1 1 1 6
(ii) 3 1 1 1 4 1 1 12
(iii) 3 1 1 1 1 1 4 12
Total 30
An Introduction to Shape Schema Grammars 183
Figure 24. The candidate cases for two target lines. One target must receive two lines and the other target a
single line.