Recursive structure of MOS scales: Difference between revisions

Inthar (talk | contribs)
Ganaram inukshuk (talk | contribs)
Lead section (tetrachards not necessary for recursion)
 
(63 intermediate revisions by one other user not shown)
Line 1: Line 1:
By looking at the "tetrachords" L…s of an [[MOS scale]] in word form and giving them the names "L" and "s", we get out another MOS scale. The MOS thus obtained preserves a number of important properties, such as which interval is the generator. To find properties of complex MOS word patterns, we can then just compare them to the simpler ones, whose properties we know.
:''This page assumes the reader is familiar with the concept of [[MOS scales]].''


== Recursive structure ==
This page discusses recursive properties of MOS scales.


=== Chunking operation ===
==Recursive structure==
 
===Chunking operation===
Let w be an arbitrary moment-of-symmetry scale in either its brightest mode (where L's come before s's) or darkest mode (where s's come before L's). Let x be the number of L's in the scale and let y be the number of s's in the scale. Such a scale will fall under one of three general cases or one of three special cases described below.
Let w be an arbitrary moment-of-symmetry scale in either its brightest mode (where L's come before s's) or darkest mode (where s's come before L's). Let x be the number of L's in the scale and let y be the number of s's in the scale. Such a scale will fall under one of three general cases or one of three special cases described below.


==== General cases ====
====General cases====
* '''Case 1:''' The scale is a single-period moment-of-symmetry scale where there are more L's than s's, and there is more than one s (or x > y > 1). Scale w can broken up into y substrings (or chunks) where each substring contains at least one L and exactly one s. Among these chunks, there are two unique chunks whose sizes differ by exactly one L: the larger of the two contains ceil(x/y) L's and exactly one s, and the smaller of the two contains floor(x/y) L's and exactly one s.
*'''Case 1:''' The scale is a single-period moment-of-symmetry scale where there are more L's than s's, and there is more than one s (or x > y > 1). Scale w can broken up into y substrings (or chunks) where each substring contains at least one L and exactly one s. Among these chunks, there are two unique chunks whose sizes differ by exactly one L: the larger of the two contains ceil(x/y) L's and exactly one s, and the smaller of the two contains floor(x/y) L's and exactly one s.
* '''Case 2:''' The scale is a single-period moment-of-symmetry scale where there are more s's than L's, and there is more than one L (or y > x > 1). Scale w can broken up into x substrings (or chunks) where each substring contains at least one s and exactly one L. Among these chunks, there are two unique chunks whose sizes differ by exactly one s: the larger of the two contains ceil(y/x) s's and exactly one L, and the smaller of the two contains floor(y/x) s's and exactly one L.
*'''Case 2:''' The scale is a single-period moment-of-symmetry scale where there are more s's than L's, and there is more than one L (or y > x > 1). Scale w can broken up into x substrings (or chunks) where each substring contains at least one s and exactly one L. Among these chunks, there are two unique chunks whose sizes differ by exactly one s: the larger of the two contains ceil(y/x) s's and exactly one L, and the smaller of the two contains floor(y/x) s's and exactly one L.
* '''Case 3:''' The scale is a multi-period moment-of-symmetry scale. Because a multi-period scale consists of a single MOS-like chunk that's repeated throughout the scale, x and y necessarily share a common factor c, where c is the greatest common factor of x and y, and c is the number of times that chunk is repeated. Therefore, when considering a multi-period moment-of-symmetry scale, only the first chunk, the first (x+y)/c steps of the scale, needs to be considered. This chunk will fall under case 1 or case 2, or one of the special cases.
*'''Case 3:''' The scale is a multi-period moment-of-symmetry scale. Because a multi-period scale consists of a single MOS-like chunk that's repeated throughout the scale, x and y necessarily share a common factor c, where c is the greatest common factor of x and y, and c is the number of times that chunk is repeated. Therefore, when considering a multi-period moment-of-symmetry scale, only the first chunk, the first (x+y)/c steps of the scale, needs to be considered. This chunk will fall under case 1 or case 2, or one of the special cases.


==== Special cases ====
====Special cases====
* The special case for case 1 is when there is only one s in the scale. The scale is a moment-of-symmetry scale where the entire scale is considered to be one chunk.
*The special case for case 1 is when there is only one s in the scale. The scale is a moment-of-symmetry scale where the entire scale is considered to be one chunk.
* The special case for case 2 is when there is only one L in the scale. The scale is a moment-of-symmetry scale where the entire scale is considered to be one chunk.
*The special case for case 2 is when there is only one L in the scale. The scale is a moment-of-symmetry scale where the entire scale is considered to be one chunk.
* There is a third special case where there is exactly one L and one s in the scale, producing "Ls" or "sL". Technically speaking, it's possible to reduce the previous two special cases even further into this special case.
*There is a third special case where there is exactly one L and one s in the scale, producing "Ls" or "sL". Technically speaking, it's possible to reduce the previous two special cases even further into this special case.


In both case 1 and 2, the L's and s's are distributed such that they are distributionally even (that is, they are distributed as evenly as possible), but the chunks of L's and s's are arranged so that they too are distributionally even. This can be demonstrated by reducing the larger chunks into L and the smaller chunks into s. This produces a new scale W that is also a moment-of-symmetry scale. This process can be repeated multiple times until the scale is reduced into one of the special cases. In case 3, it is possible to reduce a multi-period scale until it consists of a single unique MOS-like chunk repeated c times, where that chunk is one of the special cases.
In both case 1 and 2, the L's and s's are distributed such that they are maximally even (that is, they are distributed as evenly as possible), but the chunks of L's and s's are arranged so that they too are maximally even. This can be demonstrated by reducing the larger chunks into L and the smaller chunks into s. This produces a new scale W that is also a moment-of-symmetry scale. This process can be repeated multiple times until the scale is reduced into one of the special cases. In case 3, it is possible to reduce a multi-period scale until it consists of a single unique MOS-like chunk repeated c times, where that chunk is one of the special cases.


Note that in this reduction process, the order of L's and s's may reverse. This is normal.
Note that in this reduction process, the order of L's and s's may reverse. This is normal.


=== Reversing the reduction rules into production rules ===
=== Reversing the reduction rules into production rules===
Just as reducing a moment-of-symmetry scale using the aforementioned process produces another moment-of-symmetry scale, reversing the reduction rules into production rules will produce another scale w' that is also a moment-of-symmetry scale. One of the following sets of production rules can be used:
Just as reducing a moment-of-symmetry scale using the aforementioned process produces another moment-of-symmetry scale, reversing the reduction rules into production rules will produce another scale w' that is also a moment-of-symmetry scale. One of the following sets of production rules can be used:


* L -> LL...LLs (n+1 L's and one s), s -> LL...LLs (n L's and one s)
*L -> LL...LLs (n+1 L's and one s), s -> LL...LLs (n L's and one s)
* L -> ss...ssL (n+1 s's and one L), s -> ss...ssL (n s's and one L)
*L -> ss...ssL (n+1 s's and one L), s -> ss...ssL (n s's and one L)
* L -> Ls, s -> s (a special case of the first set of productions rules where n = 0)
*L -> Ls, s -> s (a special case of the first set of productions rules where n = 0)
* L -> sL, s -> L (a special case of the second set of productions rules where n = 0)
*L -> sL, s -> L (a special case of the second set of productions rules where n = 0)


Repeating these production rules will produce a scale that is more chromatic than the last, and every scale produced this way is another moment-of-symmetry scale.
Repeating these production rules will produce a scale that is more chromatic than the last, and every scale produced this way is another moment-of-symmetry scale.
Line 32: Line 34:
The recursive nature of moment-of-symmetry scales allows for two algorithms to be made: one that can determine whether an arbitrary scale of large and small steps is a valid moment-of-symmetry scale and another that can construct a moment-of-symmetry scale from any number of large and small steps, without any prior knowledge of the scale's structure.  
The recursive nature of moment-of-symmetry scales allows for two algorithms to be made: one that can determine whether an arbitrary scale of large and small steps is a valid moment-of-symmetry scale and another that can construct a moment-of-symmetry scale from any number of large and small steps, without any prior knowledge of the scale's structure.  


== Determining whether a scale has the MOS property ==
==Determining whether a scale has the MOS property==


=== General algorithm ===
===General algorithm ===


==== Stepwise version ====
====Stepwise version====
This is the general algorithm for determining whether a binary scale is distributionally even (that is, it is a valid MOS). This version of the algorithm that uses the production rules in reverse: L -> Ls and s ->s; and L -> sL and s -> L. It is required to perform this on the string that represents the scale in its brightest mode. This algorithm is recursive.
This is the general algorithm for determining whether a scale is maximally even (that is, it is a valid MOS). This version of the algorithm that uses the production rules in reverse: L -> Ls and s ->s; and L -> sL and s -> L. It is required to perform this on the string that represents the scale in its brightest mode. This algorithm is recursive.


# Count how many L's and s's there are within the string. Let x be the number of L's and y be the number of s's. One of two situations will happen:
#Count how many L's and s's there are within the string. Let x be the number of L's and y be the number of s's. One of two situations will happen:
## If both x and y are equal to 1, then the scale is distributionally even.
##If both x and y are equal to 1, then the scale is maximally even.
## If x and y share a common factor k (that is, x and y are not coprime), then the scale is a multi-period scale. Split the string into k substrings that are exactly (x+y)/k characters long. If all of the substrings are identical, then perform the algorithm corresponding to that substring to determine whether the substring is distributionally even. If it's not the case that all of the substrings are identical or the substring is not distributionally even, then the scale is not distributionally even.
##If x and y share a common factor k (that is, x and y are not coprime), then the scale is a multi-period scale. Split the string into k substrings that are exactly (x+y)/k characters long. If all of the substrings are identical, then perform the algorithm corresponding to that substring to determine whether the substring is maximally even. If it's not the case that all of the substrings are identical or the substring is not maximally even, then the scale is not maximally even.
# If there are more L's than s's AND there are either at least two adjacent s's or an s is at the beginning and end of the string, then scale is not distributionally even. If there are more s's than L's AND there are either at least two adjacent L's or an L is at the beginning and end of the string, then the scale is not distributionally even. This is because between every two instances of the character that appears the least must be at least one instance of the character that appears the most; this also applies if the character that appears the least appears at both ends of the string, as a different mode of the same string will put those two characters next to another.
#If there are more L's than s's AND there are either at least two adjacent s's or an s is at the beginning and end of the string, then scale is not maximally even. If there are more s's than L's AND there are either at least two adjacent L's or an L is at the beginning and end of the string, then the scale is not maximally even. This is because between every two instances of the character that appears the least must be at least one instance of the character that appears the most; this also applies if the character that appears the least appears at both ends of the string, as a different mode of the same string will put those two characters next to another.
# Split the string into a sequence of chunks as described: if there are more L's than s's (or if x > y), then each chunk will consist of at least one L followed by exactly one s; if instead there are more s's than L's (or y > x), then each chunk will consist of exactly one L followed by at least one s. Preserve the order of these chunks.
#Split the string into a sequence of chunks as described: if there are more L's than s's (or if x > y), then each chunk will consist of at least one L followed by exactly one s; if instead there are more s's than L's (or y > x), then each chunk will consist of exactly one L followed by at least one s. Preserve the order of these chunks.
# Count how many UNIQUE chunks there are. If there are more than two unique strings, then the scale is not distributionally even. If there are only two unique strings but their lengths differ by more than 1, then the scale is not distributionally even.
#Count how many UNIQUE chunks there are. If there are more than two unique strings, then the scale is not maximally even. If there are only two unique strings but their lengths differ by more than 1, then the scale is not maximally even.
# If there are more L's than s's, then for each chunk, replace all but the last two characters with s's, and replace the last two characters with a single L. This process represents L->sL and s->L. If there are more s's than L's, then for each chunk, replace only the first two characters with a single L. This process represents L->Ls and s->s, but reversed. The scale produced this way is the parent scale.
#If there are more L's than s's, then for each chunk, replace all but the last two characters with s's, and replace the last two characters with a single L. This process represents L->sL and s->L. If there are more s's than L's, then for each chunk, replace only the first two characters with a single L. This process represents L->Ls and s->s, but reversed. The scale produced this way is the parent scale.
# Repeat the algorithm recursively on the parent scale. If that scale is distributionally even, then the original scale is distributionally even.
#Repeat the algorithm recursively on the parent scale. If that scale is maximally even, then the original scale is maximally even.


==== Chunking version ====
====Chunking version ====
This is the general algorithm for determining whether a binary scale is distributionally even (that is, it is a valid MOS). This version of the algorithm reduces entire chunks into L's and s's based on the size of the chunks. It is recommended, but not required, to perform this on the string representing the scale in either its brightest or darkest mode. This algorithm is recursive.
This is the general algorithm for determining whether a scale is maximally even (that is, it is a valid MOS). This version of the algorithm reduces entire chunks into L's and s's based on the size of the chunks. It is recommended, but not required, to perform this on the string representing the scale in either its brightest or darkest mode. This algorithm is recursive.


# Count how many L's and s's there are within the string. Let x be the number of L's and y be the number of s's. One of two situations will happen:
#Count how many L's and s's there are within the string. Let x be the number of L's and y be the number of s's. One of two situations will happen:
## If either x or y is equal to 1, or both x and y are equal to 1, then the scale is distributionally even.
##If either x or y is equal to 1, or both x and y are equal to 1, then the scale is maximally even.
## If x and y share a common factor k (that is, x and y are not coprime), then the scale is a multi-period scale. Split the string into k substrings that are exactly (x+y)/k characters long. If all of the substrings are identical, then perform the algorithm corresponding to that substring to determine whether the substring is distributionally even. If it's not the case that all of the substrings are identical or the substring is not distributionally even, then the scale is not distributionally even.
##If x and y share a common factor k (that is, x and y are not coprime), then the scale is a multi-period scale. Split the string into k substrings that are exactly (x+y)/k characters long. If all of the substrings are identical, then perform the algorithm corresponding to that substring to determine whether the substring is maximally even. If it's not the case that all of the substrings are identical or the substring is not maximally even, then the scale is not maximally even.
# If there are more L's than s's AND there are either at least two adjacent s's or an s is at the beginning and end of the string, then scale is not distributionally even. If there are more s's than L's AND there are either at least two adjacent L's or an L is at the beginning and end of the string, then the scale is not distributionally even. This is because between every two instances of the character that appears the least must be at least one instance of the character that appears the most; this also applies if the character that appears the least appears at both ends of the string, as a different mode of the same string will put those two characters next to another.
#If there are more L's than s's AND there are either at least two adjacent s's or an s is at the beginning and end of the string, then scale is not maximally even. If there are more s's than L's AND there are either at least two adjacent L's or an L is at the beginning and end of the string, then the scale is not maximally even. This is because between every two instances of the character that appears the least must be at least one instance of the character that appears the most; this also applies if the character that appears the least appears at both ends of the string, as a different mode of the same string will put those two characters next to another.
# Split the string into a sequence of chunks, not by splitting the strings into chunks that contain L's and s's, but AT the character that appears the least. Because every chunk contains at least one L and at least one s, removing the character that appears the least will not make any difference to how the chunks are ordered in terms of size. If there are more L's than s's, then there should be exactly y chunks consisting of only L's, and if there are more s's than L's, then there should be exactly x chunks consisting of only s's. If there is exactly one more string than expected, this may be because the string was in a mode that split one of the chunks into two; in this case, combine the first and last chunks in the sequence back into one chunk to get the correct number of chunks.
#Split the string into a sequence of chunks, not by splitting the strings into chunks that contain L's and s's, but AT the character that appears the least. Because every chunk contains at least one L and at least one s, removing the character that appears the least will not make any difference to how the chunks are ordered in terms of size. If there are more L's than s's, then there should be exactly y chunks consisting of only L's, and if there are more s's than L's, then there should be exactly x chunks consisting of only s's. If there is exactly one more string than expected, this may be because the string was in a mode that split one of the chunks into two; in this case, combine the first and last chunks in the sequence back into one chunk to get the correct number of chunks.
# Count how many UNIQUE chunks there are. If there are more than two unique strings, then the scale is not distributionally even. If there are only two unique strings but their lengths differ by more than 1, then the scale is not distributionally even.
# Count how many UNIQUE chunks there are. If there are more than two unique strings, then the scale is not maximally even. If there are only two unique strings but their lengths differ by more than 1, then the scale is not maximally even.
# Produce a new scale consisting of L's and s's, based on the sequence of tokenized strings, as this will be the progenitor scale of the original; in the sequence, every instance of the larger string corresponds to an L in the progenitor scale, and every instance of the smaller string corresponds to an s in that scale. Call this algorithm recursively on that scale to determine whether that scale is also distributionally even. If that scale is distributionally even, then the original scale is distributionally even. Otherwise, the scale is not distributionally even.
#Produce a new scale consisting of L's and s's, based on the sequence of tokenized strings, as this will be the progenitor scale of the original; in the sequence, every instance of the larger string corresponds to an L in the progenitor scale, and every instance of the smaller string corresponds to an s in that scale. Call this algorithm recursively on that scale to determine whether that scale is also maximally even. If that scale is maximally even, then the original scale is maximally even. Otherwise, the scale is not maximally even.


=== Pseudocode ===
=== Pseudocode===
This is the pseudocode for the chunking operation described above.
This is the pseudocode for the chunking operation described above.
  VerifyDistributionallyEvenScale(string scale : scale encodes an arbitrary scale of only L's and s's) returns TRUE or FALSE {
  VerifyMaximallyEvenScale(string scale : scale encodes an arbitrary scale of only L's and s's) returns TRUE or FALSE {
   
   
  integer x = 0;
  integer x = 0;
Line 97: Line 99:
  } else {
  } else {
  string subscale = set.beginning_of_set
  string subscale = set.beginning_of_set
  return VerifyDistributionallyEvenScale(subscale)
  return VerifyMaximallyEvenScale(subscale)
  }
  }
  }
  }
Line 153: Line 155:
  subscale += "L"
  subscale += "L"
   
   
  return VerifyDistributionallyEvenScale(subscale)
  return VerifyMaximallyEvenScale(subscale)
  }
  }
  }
  }
Line 159: Line 161:
  }
  }


=== Examples ===
===Examples===
6L 1s, or LLLLLLs. This falls under one of the special cases and is a moment-of-symmetry scale.  
6L 1s, or LLLLLLs. This falls under one of the special cases and is a moment-of-symmetry scale.  


Line 176: Line 178:
3L 6s, or LssLssLss. Since 3 and 6 share a common factor of 3, this scale consists of Lss repeated three times, which falls under the special cases and is a multi-period moment-of-symmetry scale.
3L 6s, or LssLssLss. Since 3 and 6 share a common factor of 3, this scale consists of Lss repeated three times, which falls under the special cases and is a multi-period moment-of-symmetry scale.


=== Counterexamples ===
===Counterexamples===
LLLLsLs. This produces two unique chunks of LLLLs and Ls. However, the two chunks differ in size by two L's, and it is not distributionally even.
LLLLsLs. This produces two unique chunks of LLLLs and Ls. However, the two chunks differ in size by two L's, and it is not maximally even.


LLLLLss. This produces one chunk of LLLLLs. The lone s at the end can be considered a chunk consisting of zero L's and one s. Since the two chunks differ in size by 5 L's, this is not distributionally even.
LLLLLss. This produces one chunk of LLLLLs. The lone s at the end can be considered a chunk consisting of zero L's and one s. Since the two chunks differ in size by 5 L's, this is not maximally even.


LsssLsssL. The quantity of L's and s's are coprime, sharing a common factor of 3. However, dividing the scale into three equal-sized chunks shows that all three chunks are different (Lss, sLs, and ssL), so this is not distributionally even.
LsssLsssL. The quantity of L's and s's are coprime, sharing a common factor of 3. However, dividing the scale into three equal-sized chunks shows that all three chunks are different (Lss, sLs, and ssL), so this is not maximally even.


LLsLLLsLLLLs. This produces three unique chunks of LLs, LLLs, and LLLLs. This is not distributionally even.
LLsLLLsLLLLs. This produces three unique chunks of LLs, LLLs, and LLLLs. This is not maximally even.
 
== Finding the MOS pattern from xL ys ==


==Finding the MOS pattern from xL ys==
There is a linear-time algorithm for generating a MOS that works by traversing the closest approximation to ''y = b/a*x'', and the generator may be found from the integer point on this path that is closest to this line; this is essentially the Bresenham line algorithm. The following presents the slower recursive algorithms as is topical for this article.
=== General algorithm ===
=== General algorithm ===
This is the general algorithm for generating a moment of symmetry scale of the form xL ys represented as a string of L's and s's in its brightest mode. This algorithm will produce that scale without any prior knowledge of how the scale's steps are ordered. This algorithm is recursive. Let x be the number of L's and y the number of s's.  
This is the general algorithm for generating a moment of symmetry scale of the form xL ys represented as a string of L's and s's in its brightest mode. This algorithm will produce that scale without any prior knowledge of how the scale's steps are ordered. This algorithm is recursive. Let x be the number of L's and y the number of s's.  


# If either x or y is equal to 1 (base cases):  
#If either x or y is equal to 1 (base cases):  
## If both x and y are equal to 1, then the final scale is "Ls".
## If both x and y are equal to 1, then the final scale is "Ls".
## If only x is equal to 1, then the final scale is L followed by y s's.
## If only x is equal to 1, then the final scale is L followed by y s's.
## If only y is equal to 1, then the final scale is x L's followed by s.
## If only y is equal to 1, then the final scale is x L's followed by s.
# If neither x nor y is equal to 1 (recursive cases):
#If neither x nor y is equal to 1 (recursive cases):
## Let k be the greatest common factor of x and y.
##Let k be the greatest common factor of x and y.
## If x and y share a common factor k, where k is greater than 1, then recursively call this algorithm to find the scale for (x/k)L (y/k)s; the final scale will be (x/k)L (y/k)s duplicated k times.
##If x and y share a common factor k, where k is greater than 1, then recursively call this algorithm to find the scale for (x/k)L (y/k)s; the final scale will be (x/k)L (y/k)s duplicated k times.
## If x and y don't share a common factor that is greater than 1 (if x and y are coprime), then:
##If x and y don't share a common factor that is greater than 1 (if x and y are coprime), then:
### Let m1 = min(x, y) and m2 = max(x, y).
###Let m1 = min(x, y) and m2 = max(x, y).
### Let z = m2 mod m1 and w = m1 - z.
###Let z = m2 mod m1 and w = m1 - z.
### Let prescale be the mos string for zL ws. Recursively call this algorithm to find the scale for zL ws; the final scale will be based on this.
###Let prescale be the mos string for zL ws. Recursively call this algorithm to find the scale for zL ws; the final scale will be based on this.
### If x < y, reverse the order of characters in the prescale. This is only needed if there are more L's than s's in the final scale.
###If x < y, reverse the order of characters in the prescale. This is only needed if there are more L's than s's in the final scale.
### To produce the final scale, the L's and s's of the prescale must be replaced with substrings consisting of L's and s's. Let u = ceil(m2/m1) and v = floor(m2/m1).
###To produce the final scale, the L's and s's of the prescale must be replaced with substrings consisting of L's and s's. Let u = ceil(m2/m1) and v = floor(m2/m1).
#### If x > y, every instance of an L in the prescale is replaced with one L and u s's, and every s replaced with one L and v s's. This produces the final scale in its brightest mode.
#### If x > y, every instance of an L in the prescale is replaced with one L and u s's, and every s replaced with one L and v s's. This produces the final scale in its brightest mode.
#### If y > x, every instance of an L in the prescale is replaced with u L's and one s, and every s replaced with v L's and one s. This produces the final scale in its brightest mode.
####If y > x, every instance of an L in the prescale is replaced with u L's and one s, and every s replaced with v L's and one s. This produces the final scale in its brightest mode.


=== Python code ===
===Python code===
The code shown here is a Python function that implements the algorithm described above.<syntaxhighlight lang="python3" line="1">
The code shown here is a Python function that implements the algorithm described above.<syntaxhighlight lang="python3" line="1">
def CalculateMos(x, y):
def CalculateMos(x, y):
Line 275: Line 277:
   
   


=== Example ===
=== Example===
To find the generators for 5L 7s, we can start at step 2.3.1, as the mos is neither multi-period nor 1L 1s. Using these steps, we can recursively find the mos 2L 3s, which means we recursively find the mos 1L 1s.
To find the generators for 5L 7s, we can start at step 2.3.1, as the mos is neither multi-period nor 1L 1s. Using these steps, we can recursively find the mos 2L 3s, which means we recursively find the mos 1L 1s.


Line 286: Line 288:
To make sure that we have the correct mos, we can relate it back to 5L 2s, whose mos LLLsLLs. By replacing "Ls" with L, we can reduce our mos into that for 5L 2s.
To make sure that we have the correct mos, we can relate it back to 5L 2s, whose mos LLLsLLs. By replacing "Ls" with L, we can reduce our mos into that for 5L 2s.


== Finding a generator ==
==Finding a generator==
The recursive structure also allows a recursive algorithm to find the generator, as a substring of the mos pattern. The reason why this works is that the reduction both ''preserves'' and ''reflects'' the generator; see the ''proofs'' section.
The recursive structure also allows a recursive algorithm to find the generator, as a substring of the mos pattern. The reason why this works is that the reduction both ''preserves'' and ''reflects'' the generator; see the ''proofs'' section.


=== General algorithm ===
=== General algorithm===
This is the general algorithm for finding a moment of symmetry scale's generator and its [[octave complement]] for a mos xL ys as two, not-necessarily-equal halves of the mos pattern xL ys. If the mos is multi-period, its generator and period complement are returned as two halves of the period. This algorithm will produce these intervals without any prior knowledge of how the scale's steps are ordered. This algorithm is recursive. Let x be the number of L's and y the number of s's.  
This is the general algorithm for finding a moment of symmetry scale's generator and its [[octave complement]] for a mos xL ys as two, not-necessarily-equal halves of the mos pattern xL ys. If the mos is multi-period, its generator and period complement are returned as two halves of the period. This algorithm will produce these intervals without any prior knowledge of how the scale's steps are ordered. This algorithm is recursive. Let x be the number of L's and y the number of s's.  


# If either x or y is equal to 1 (base cases):  
#If either x or y is equal to 1 (base cases):  
## If both x and y are equal to 1, then the generator is "L" and its complement is "s".
##If both x and y are equal to 1, then the generator is "L" and its complement is "s".
## If only x is equal to 1, then the generator is "L" followed by y-1 s's, and the complement is "s".
##If only x is equal to 1, then the generator is "L" followed by y-1 s's, and the complement is "s".
## If only y is equal to 1, then the generator is "L" and the complement is x-1 L's followed by "s".
##If only y is equal to 1, then the generator is "L" and the complement is x-1 L's followed by "s".
# If neither x nor y is equal to 1 (recursive cases):
#If neither x nor y is equal to 1 (recursive cases):
## Let k be the greatest common factor of x and y.
##Let k be the greatest common factor of x and y.
## If x and y share a common factor k, where k is greater than 1, then recursively call this algorithm to find the generator and complement for (x/k)L (y/k)s; the intervals returned this way will apply to the period rather than the octave.
##If x and y share a common factor k, where k is greater than 1, then recursively call this algorithm to find the generator and complement for (x/k)L (y/k)s; the intervals returned this way will apply to the period rather than the octave.
## If x and y don't share a common factor that is greater than 1 (if x and y are coprime), then:
##If x and y don't share a common factor that is greater than 1 (if x and y are coprime), then:
### Let m1 = min(x, y) and m2 = max(x, y).
###Let m1 = min(x, y) and m2 = max(x, y).
### Let z = m2 mod m1 and w = m1 - z.
###Let z = m2 mod m1 and w = m1 - z.
### Let gen be the scale's generator and comp be the generator's octave complement for the mos zL ws. Recursively call this algorithm to find these intervals for zL ws; the final scale's generator and complement will be based on this.
###Let gen be the scale's generator and comp be the generator's octave complement for the mos zL ws. Recursively call this algorithm to find these intervals for zL ws; the final scale's generator and complement will be based on this.
### If x < y, reverse the order of characters in gen and comp, then swap gen and comp. This is only needed if there are more L's than s's in the scale.
###If x < y, reverse the order of characters in gen and comp, then swap gen and comp. This is only needed if there are more L's than s's in the scale.
### To produce the scale's generator and complement, the L's and s's of both intervals must be replaced with substrings consisting of L's and s's. Let u = ceil(m2/m1) and v = floor(m2/m1).
###To produce the scale's generator and complement, the L's and s's of both intervals must be replaced with substrings consisting of L's and s's. Let u = ceil(m2/m1) and v = floor(m2/m1).
#### If x > y, every instance of an L in both intervals is replaced with one L and u s's, and every s replaced with one L and v s's. This produces the final scale's generator and complement.
####If x > y, every instance of an L in both intervals is replaced with one L and u s's, and every s replaced with one L and v s's. This produces the final scale's generator and complement.
#### If y > x, every instance of an L in both intervals is replaced with u L's and one s, and every s replaced with v L's and one s. This produces the final scale's generator and complement.
#### If y > x, every instance of an L in both intervals is replaced with u L's and one s, and every s replaced with v L's and one s. This produces the final scale's generator and complement.


==== Notes on output ====
====Notes on output====
The algorithm described here returns what is known as the chroma-positive generator, or bright generator, and is usually what is meant by ''the'' generator of a scale. The octave-complement returned this way is the scale's chroma-negative generator, or dark generator. More specifically, the bright generator is in its perfect form, and the dark generator is in its augmented form. If the perfect dark generator is needed instead, a quick way to produce it is to replace one L in the dark generator with an s.
The algorithm described here returns what is known as the chroma-positive generator, or bright generator, and is usually what is meant by ''the'' generator of a scale. The octave-complement returned this way is the scale's chroma-negative generator, or dark generator. More specifically, the bright generator is in its perfect form, and the dark generator is in its augmented form. If the perfect dark generator is needed instead, a quick way to produce it is to replace one L in the dark generator with an s.


If the number of steps in the generators is needed, simply count the total number of L's and s's in each generator.
If the number of steps in the generators is needed, simply count the total number of L's and s's in each generator.


=== Python code ===
===Python code===
The code shown here is a Python function that implements the algorithm described above.<syntaxhighlight lang="python3" line="1">
The code shown here is a Python function that implements the algorithm described above.<syntaxhighlight lang="python3" line="1">
def CalculateMosGenerators(x, y):
def CalculateMosGenerators(x, y):
Line 398: Line 400:
</syntaxhighlight>
</syntaxhighlight>


=== Example ===
=== Example===
To find the generators for 5L 7s, we can start at step 2.3.1, as the mos is neither multi-period nor 1L 1s. Using these steps, we can recursively find the generators for the mos 2L 3s, which means we recursively find the generators for 1L 1s.
To find the generators for 5L 7s, we can start at step 2.3.1, as the mos is neither multi-period nor 1L 1s. Using these steps, we can recursively find the generators for the mos 2L 3s, which means we recursively find the generators for 1L 1s.


Line 422: Line 424:
  (0\1, 1\4) (1\4, 1\3) (1\3, 2\5) (2\5, 1\2)
  (0\1, 1\4) (1\4, 1\3) (1\3, 2\5) (2\5, 1\2)


== Proofs ==
==Proofs==
=== Preservation of generators ===
===Definition of MOS===
A periodic scale is ''MOS'' if it has [[maximum variety]] 2. This in particular implies that MOS scales are binary.
 
===Preservation of the MOS property===
(Assume that the MOS has length ''n''; the notation ''w''(X, Y) for a word ''w''(L, s) in L, s means w with step sizes X substituted for L and Y substituted for s.)
 
Suppose w(L, s) had three chunks L...s with r < r+i < r+j 'L's. Then we have a length r+2 subword that's only 'L's, one that has one s at the end and one that has two 's's on either side, which means that the original scale was not MOS. Therefore the reduced word has two step sizes that differ by 1. Repeating this argument for sequences of ''k'' > 1 chunks shows that any ''k''-step in the reduced word must come in at most 2 sizes, showing that the reduced word is indeed MOS.
 
=== Preservation of generators===
Assume there are more L's and s's, and that there is more than one s, and thus more than one chunk. Assume there is a generator. Assume the imperfect generator is bigger than the perfect generator. (If this isn't true, just use the inverted generator.) Because there are at least two chunk boundaries, and only one imperfect generator, there must be a chunk boundary with a perfect generator on top (the chunk boundary is on the left of the generator, e.g. <code>...|Ls|LLs|Ls...</code>). Because there's a chunk boundary to the left, there's an s just to the left of the left endpoint of the generator. If the rightmost step of this generator were an L, scooting the generator one step to the left would make it smaller, which contradicts the assumption that the imperfect generator is larger than perfect. Thus, the rightmost step of this generator is an s. That means the right endpoint of this generator falls on a chunk boundary. We already know the left endpoint also falls on a chunk boundary, so this perfect generator is still present as an interval in the reduced MOS.
Assume there are more L's and s's, and that there is more than one s, and thus more than one chunk. Assume there is a generator. Assume the imperfect generator is bigger than the perfect generator. (If this isn't true, just use the inverted generator.) Because there are at least two chunk boundaries, and only one imperfect generator, there must be a chunk boundary with a perfect generator on top (the chunk boundary is on the left of the generator, e.g. <code>...|Ls|LLs|Ls...</code>). Because there's a chunk boundary to the left, there's an s just to the left of the left endpoint of the generator. If the rightmost step of this generator were an L, scooting the generator one step to the left would make it smaller, which contradicts the assumption that the imperfect generator is larger than perfect. Thus, the rightmost step of this generator is an s. That means the right endpoint of this generator falls on a chunk boundary. We already know the left endpoint also falls on a chunk boundary, so this perfect generator is still present as an interval in the reduced MOS.


This interval is, in fact, the generator of the reduced scale. Indeed, you can build this generator on all of the chunk boundaries of the non-reduced scale. All but one of these will be perfect. The perfect ones will have their right endpoint be a chunk boundary, as we showed before, so this is an interval that's on all but one tone of the reduced scale. This is a generator.  
This interval is, in fact, the generator of the reduced scale. Indeed, you can build this generator on all of the chunk boundaries of the non-reduced scale. All but one of these will be perfect. The perfect ones will have their right endpoint be a chunk boundary, as we showed before, so this is an interval that's on all but one tone of the reduced scale. This is a generator.  


=== Reflection of generators ===
=== Reflection of generators===
Suppose there is a generator after chunking. Assume also that there are more L's than s's, and that the imperfect generator is larger than the perfect generator. This means that this interval, built on the chunk boundaries after expanding, will still be "a generator" on the chunk boundaries: it will be the same size on all but one of the chunk boundaries. Take one of the "perfect" (smaller) intervals. We showed previously that, before expansion, the step to its right was an L, just like its first step; therefore we can scoot it over for the entirety of the first chunk and keep it perfect. We now come to another chunk. If a "perfect" interval can be built on it then we can repeat. If the interval is imperfect, then we know that the step to its right is an s, which will make it smaller and thus perfect, and we can keep doing this for the remainder of the chunk. Therefore, the interval is a generator after expansion as well, since it is only imperfect in one position.
Suppose there is a generator after chunking. Assume also that there are more L's than s's, and that the imperfect generator is larger than the perfect generator. This means that this interval, built on the chunk boundaries after expanding, will still be "a generator" on the chunk boundaries: it will be the same size on all but one of the chunk boundaries. Take one of the "perfect" (smaller) intervals. We showed previously that, before expansion, the step to its right was an L, just like its first step; therefore we can scoot it over for the entirety of the first chunk and keep it perfect. We now come to another chunk. If a "perfect" interval can be built on it then we can repeat. If the interval is imperfect, then we know that the step to its right is an s, which will make it smaller and thus perfect, and we can keep doing this for the remainder of the chunk. Therefore, the interval is a generator after expansion as well, since it is only imperfect in one position.


=== Uniqueness and existence of the generator===
===Uniqueness and existence of the generator===
Every MOS can be reduced to nL 1s (or 1L ns). Each step of the reduction decreases either the number of L's or the number of s's (or both), so one of them must reach 1 at some point. ''(note that reducing further gets us to 1L 0s, which has a period, but no generator per se)''
Every MOS can be reduced to nL 1s (or 1L ns). Each step of the reduction decreases either the number of L's or the number of s's (or both), so one of them must reach 1 at some point. ''(note that reducing further gets us to 1L 0s, which has a period, but no generator per se)''


It is clear that the MOS nL 1s has a unique generator, L (or its inversion). However, the previous proof showed that reduction reflects generators, and so by induction all MOS scales have a single generator.
It is clear that the MOS nL 1s has a unique generator, L (or its inversion). However, the previous proof showed that reduction reflects generators, and so by induction all MOS scales have a single generator.


=== Reduced words from chunking are binary ===
==See also==
It now remains to show that reduction and expansion preserve the MOS property.
*[[Operations on MOSes]]
 
Suppose w(L, s) had three chunks L...s with r, r+1 and r+2 'L's. Then we have a length r+2 subword that's only 'L's, one that has one s at the end and one that has two 's's on either side, which means that the original scale was not MOS. Therefore the reduced word has two step sizes.
 
=== Binary generated scales are MOS ===
By ''generatedness'', we mean that every interval in the scale is of the form ''jg'' + ''kp'' where ''g'' is a generator, ''p'' is the period, and ''j, k'' ∈ '''Z'''. We have shown that the result of chunking and reduction is generated and binary and the result of expanding from a reduced word is generated and binary. We need only show that binary generated scales are MOS (i.e. have maximum variety 2).
 
Suppose that such a scale ''S'' (with ''n'' ≥ 2 notes) has ''a''-many L steps and ''b''-many s steps per period ''p'', where gcd(''a'', ''b'') = 1, and has generator ''g''. First assume that ''g'' and ''p'' are linearly independent, so the step ratio of ''S'' is irrational. Since ''S'' is generated, the interval sizes modulo ''p'' that occur in ''S'' are:
 
{(&minus;''n'' + 1)''g'', ..., &minus;''g'', 0, ''g'', ..., (''n'' &minus; 1)''g''}.
 
We thus have:
 
L = ''cg'' + ''dp''
 
s = ''eg'' + ''fp''
 
for appropriate integers ''c, d, e, f'', where |''c''| < ''n'' and |''e''| < ''n''. We must have that ''c'' = ±''b'' and ''e'' = ∓''a'', as by assumption ''a''L + ''b''s = (''ac'' + ''be'')''g'' + (''ad'' + ''bf'')''p'' = ''p''. In fact, [L, s] is another valid basis for the group generated by ''p'' and ''g'', since by binarity we have ''p, g'' ∈ span(L, s).
 
Assume ''c'' = ''b'' and ''e'' = &minus;''a''. Let χ = L &minus; s > 0; then χ is ''p''-equivalent to ''+ng''. Now by generatedness and binarity, any interval class that has at least two sizes must have sizes separated by ''ng'' (the separation corresponding to changing an L step to an s step). Since ''g'' and ''p'' are linearly independent, for each ''j'' ∈ {1, ..., ''n'' &minus; 1} there exists at most one ''k'' = ''k''(''j'') ∈ {1, ..., ''n'' &minus; 1}</sub> such that ''jg'' is ''p''-equivalent to one size of ''k''-step. Hence if an interval class that has two sizes must have the sizes ''jg'' and (''j'' &minus; ''n'')''g''; any other size must leave the range &minus;(''n'' &minus; 1)''g'', ..., 0, ..., (''n'' &minus; 1)''g''. Thus the class of ''k''-steps has at most two sizes for 1 ≤ ''k'' ≤ (''n'' &minus; 1). Each non-''p''-equivalent class must have ''exactly'' two sizes, since the inverse of the ''k''-step that is equivalent to ''jg'' is an (''n'' &minus; ''k'')-step equivalent to ''&minus;jg'', which must be distinct from an (''n'' &minus; ''k'')-step equivalent to a positive number of ''g'' generators, which does occur in the brightest (most generators stacked ''up'' rather than ''down'') mode of ''S''.
 
To show that maximum variety 2 holds for non-linearly-independent ''p'' and ''g'', note that every ''k''-step (which is a specific linear combination of L and s) in the scale with rational step ratio is a limit point of the same linear combination of L and s in versions of the binary scale with linearly independent ''p'' and ''g'', and thus there must be ''at most'' 2 sizes for each generic interval. Since χ, which separates the two sizes, is ''p''-equivalent to ''ng'' and remains ''p''-inequivalent to 0 in the limit since L/s ≠ 1/1, each generic interval has ''exactly'' 2 sizes.
 
== See also ==
* [[Operations on MOSes]]


[[Category:MOS scale]]
[[Category:MOS scale]]
[[Category:Pages with proofs]]