Rule ordering

    Conditional
    Ordering
     

    Suppose that the only things x can be many things, and in most cases we do nothing, bu with lists, we do something special.

    Here is a bad program that deals with this situation:

    if isinstance(x,str) or\
       isinstance(x,dict) or\
       isinstance(x,float) or\
       isinstance(x,int) or \
       isinstance(x,tuple):
        y = None
    elif isinstance(x,list):
        y = x[0]
    
    Long, hard-to-read, and prone to bugs. I forgot the type "long" (Python's long integer type) so this will erroneously do:
    y=x[0]
    
    for long integers, raising an exception and terminating execution.

    A better program:

    if isinstance(x,list):
        y = x[0]
    else:
        y = None
    
    The else clause here is called an elsewhere condition.

    In general programs are most elegant if they treat the most general case further down the list of cases:

    if isinstance(x,float):
       y=x/5.0
    elif isinstance
    else:
      y = x/5
    
    The second clause actually covers two cases, "int" (integer) and "long"(long integer).

    An if-then-else clause works because

    Nasal
    assimilation
     

    Consider the English prefix in/im as in:

    • impossible
    • impracible
    • immersible
    • inevitable
    • indelible
    • incredible
    • incessant
    Generalization? Does an elsewhere condition help?

    Along the same lines, and resembling the "kamman" poroblem, here is a simple example with fake data.

      kan kan "do"
      kan+tat kantat "doable"
      kan+sen kansen "undo"
      kan+gus kangus "do again"
      kan+pat kampat [!] "do repeatedly"

    We call "kan" the stem and "tat/sen/gus/pat" suffixes.

    Notice that in one case the "stem" changes shape.

    This is called "nasal assimilation", nasal because it is happening with a nasal sound ("m", "n" and "ng") in English). Assimilation because the nasal is "assimilating" to the following sound. Assimilating means "becoming more alike like". An "m" is more like a "p" than an "n" because "m" and "p" have the same place of articulation (labial=lips).

    A simple description of what is going on:
     
      "kan" is pronounced "kan" everywhere except in front of "p"  

    But it turns out in our fictional language there are many stems that show this change. They end in "n" most places, but they end in "m" before suffixes that start with "p".

    A slightly more sophisticated description. We will say "kan" ends not with "n" but with "N", a new sound.

    The pronunciation of "N" is determine by rule.
     
      "N" is pronounced "m" in front of p and "n" everywhere else.  

    We will write this as two rules in special notation.

    (a) N --> m \ ___p
    (b) N --> n 
    
    Rule (a) means N turns into ("is realized as") "m" in the context immediately preceding "p". The "____" stands for where the "N" goes, immediately before the "p". Note the (b) rule has no defining context, just like an "else" clause in a program. It means N turns into "n" everywhere (else).

    So this rule means the same as the following programming language statement:

    if N immediately precedes p:
       N --> m
    else:
       N --> n
    

    Note that in our notation, the ORDER is significant. If the rules were written in the reverse order, it would mean something else:

    (a) N --> n 
    (b) N --> m \ ___p
    
    means "N" becomes "n" everywhere. So rule (b) now no longer has any effect
    Rule
    Ordering
    Feeding
     

    Consider the following rules:

    (1)    Vowel Raising
           e --> i \ ___C_0 i
    
    (2)    Palatalization
           t --> c \ ___i
    
    1. Rule 1 (Vowel Raising) states that e becomes (is rewritten as) i in the environment:
      1. Right context (Rule 1) Ci (0 or more consonants followed by "i")
      2. Right context (Rule 2): i (the vowel "i")

      A sample derivation of forms to which these rules apply:

          UR:    temi
          (1)    timi
          (2)    cimi     [intermediate level]
          SR:    cimi
      

      Not only are these rules sequential, they are ordered, such that rule 1 must apply before rule 2. Rule 1 has a feeding relationship to rule 2; that is, rule 1 increases the number of forms that can undergo rule 2 by creating more instances of i.

      Consider what would happen if they were applied in the reverse order. Given the input form temi:

      1. Rule 2 does not apply....
      2.  temi -> *time 
        (Rule 1)
    English
    Flap
    Rule
     

    Let's look at the words writer and rider in Canadian English.

    Examples:

      write + er = writer

      r ai t + er
      r ^i dx er
    "dx" here stands for a FLAP, a quick flap of the tongue against the alveolar ridge. This is a voiceless sound.

    Next

      ride + er = rider

      r ai d + er
      r ai dx er

    The difference between the two words is in the vowel:

      r ai dx er
      r ^i dx er

    There are two things going on. First a process called flapping:

      Flap Rule: t,d - > dx \ V _ V
    This turns t and d into flaps between vowels If the flap rule is correct, this means that in general there should be no contrast between t and d between vowels in Canadian English. They all get turned into flaps. This seems to be correct, even for most varieties of American English.
      sudden: s uh dx n
      listen: l ih s dx ax n

    Next: There is a general process of vowel raising before voiceless consonants in Canadian English:

      Raising Rule: ai => ^i / _ [-vcd]
    Examples:
      knife n ^i f knives n ai v z
      house h ^w s houses h aw z ix z

      The crucial thing for present purposes: On one very simple account, flapping and vowel raising need to be ordered. Vowel raising needs to happen BEFORE flapping. When vowel raising applies rider still has a voiced sound in it and the vowel does not raise. Afterward, flapping takes away the voicing, but it's too late for raising to occur.

      Notice if the rules apply freely or if they apply in the opposite order this rather simple account goes away. This is one of the most famous, if not the most famous, arguments for rule ordering.

    Allomorphy  
    Latin Verbs

        praise love advise see
      2sg laudas amas mones vides
      3sg laudat amat monet videt
      1pl laudamus amamamus monemus videmus
      2pl laudatis amatis monetis videtis
      3pl laudant amant monent vident
      imp lauda ama mone vide

    But uh oh. Now look at the 1st sg forms....

    What allomorphy/morpheme-changing rules make this data look nice....?

      1sg laudo amo moneo video
    Dutch T-deletion

    3rd person singular present tense verb form: t

      slaap + t = slaapt
      bijt + t = bijt

    Suffix changes shape....

    Dutch
    Vowel
    Shortening

      slaap + en = slapen

    Stem changes shape....

    Dutch Consonant
    Doubling

      bel + en = bellen
    Allophony  

      English
      Flap
      Rule

        t - > D \ V _ V

      Examples:

        write + er = writer

        r ai t + er
        r ai D er

      Looks like allomorphy again, but it isn't.

        sudden: s uh D n
        listen: l ih s D ax n


    Implementing rule ordering

    Scanning
    Direction

    One scanning strategy: Scan right to left looking for rule environments. At each segment, try to apply all the rules IN ORDER.

    Another: scan left to right.

    Abstract
    example

      a - > b \ ab __ ba

    Apply to:

      abababababa

    Three outcomes:

    1. abbbabbbaba: LEFT-TO-RIGHT scanning. Apply first to leftmost eligible position; each successive app applies to the output of the previous and further right in the string.
    2. ababbbabbba: RIGHT-TO-LEFT scanning. Apply first to rightmost eligible position; each successive app applies to the output of the previous and further left in the string.
    3. abbbbbbbbba: Identify all possible rule applications in the ORIGINAL string and carry out simultaneously.

    Bad news: Phonologists have advocated all 3 strategies.

    Soln: Each rule marked for its application strategy.

    Scanning
    Direction
    Example
    II

    Example: Invent a rule that uses right contexts created by another rule:

    c - > e ___ c
    
    Our palatalization rule creates c's.

    c    t    i
       Target RC 
     -- > (Palatalization Rule)
     c    c     i
     -- > (C Deletion Rule)
         c      i
    

    Notice that if the rules applied left to right C-deletion couldnt apply.

    Turkish
    Vowel
    Harmony

    Plural: lAr; sometimes realized as "lar", sometimes as "ler" depending on PREceding vowel.

    Possessive: Im:; sometimes realized as "am", sometimes as "im" depending on PREceding vowel.

    Only left-to-right works:

      adress + lAr + Im = adreslerim
      apartman + lAR + IM = apartmanlarim
      adres + Im + A = adresime