This file contains a demonstration of how to use PSF for algebraic
specifications and test it using term rewriting techniques.

1) Consider the following specification of the Booleans.
   (You might want to copy this specification to the file Booleans.psf
   in order to try the tools yourself)

data module Booleans
begin

  exports
    begin

      sorts
        BOOLEAN

      functions
        true : -> BOOLEAN
        false : -> BOOLEAN
        eq : BOOLEAN # BOOLEAN -> BOOLEAN
        not : BOOLEAN -> BOOLEAN
        and : BOOLEAN # BOOLEAN -> BOOLEAN
        or : BOOLEAN # BOOLEAN -> BOOLEAN

    end

  equations
    [01] eq(true,true) = true
    [02] eq(false,false) = true
    [03] eq(true,false) = false
    [04] eq(false,true) = false
    [05] not(true) = false
    [06] not(false) = true
    [07] and(true,true) = true
    [08] and(true,false) = false
    [09] and(false,true) = false
    [10] and(false,false) = false
    [11] or(true,true) = true
    [12] or(true,false) = true
    [13] or(false,true) = true
    [14] or(false,false) = false

end Booleans

2) Compile this specification:
   (The commands after example% should be typed literally by the user.)

example% psf Booleans.psf
   
   This creates a file Booleans.til

3) Test the specification with the term rewiter:

example% trs Booleans.til
--> or(true,true)
 or ( true ,  true )    =  true 
--> false
 false  =  false 
--> eq(or(true,false),not(true))
 eq ( or ( true ,  false ),  not ( true ))      =  false 
--> 

   The output shows, for example, that or(true,true) evaluates to true, which
   might give some confidence that the specification is OK.

4) Calculate the initial algebra (which is the semantics for algebraic
   specifications in PSF.
   (Option -c means that the contents of the calculated initial algebra should
   be showed. Option -s 10 indicates that we only want to see at most 10
   elements.)

example% initial -c -s 10 Booleans.til

*** Initial Algebra Report ***

'BOOLEAN': 2 element(s)
- true
- false

   This indicates that all Boolean expressions evaluate to either true or false.

5) In order to show the results for an incorrect specification, delete equation
   [14]. Compile and run initial again:

example% psf Booleans.psf
example% initial -c -s 10 Booleans.til

*** Initial Algebra Report ***

'BOOLEAN': 11 element(s)
*** WARNING : possibly infinite sort. Initial Algebra size reached limit
- true
- false
- or(false,false)
- eq(true,or(false,false))
- eq(false,or(false,false))
- eq(or(false,false),true)
- eq(or(false,false),false)
- eq(or(false,false),or(false,false))
- not(or(false,false))
- and(true,or(false,false))
- and(false,or(false,false))

   Now note that there are several Boolean expressions which can no longer
   be reduced.
