/*-------------------------------------------------------------------------
    program: toggling a switch
    file:    switch1
    date:    December 97
    updated: Pablo Lopez (lopez@lcc.uma.es)
             Dept. of CS
             University of Malaga, SPAIN

    notes:   This code is a Forum version of a Lolli example originally
             proposed by Joshua S. Hodas and Dale Miller in
             "Logic Programming in a Fragment of Intuitionistic Linear Logic"
             Information and Computation, 110(2), pp. 327-365, 1994.

    sample goals:
        switch1(on, toggle, S).
        switch1(S1, toggle # toggle,S2).
        switch1(on, toggle & (toggle # toggle # toggle), S).
-------------------------------------------------------------------------*/

module switch1.

toggle # state(on) *- state(off). 

toggle # state(off) *- state(on).

state(S) # final(S).

switch1(Initial,Toggles,End) <= state(Initial) # final(End) # Toggles.

go(S) <= switch1(on, toggle # toggle # toggle # toggle # toggle # toggle # 
                     toggle # toggle # toggle # toggle # toggle # toggle #
                     toggle # toggle # toggle # toggle # toggle # toggle,
                 S).
