1 {-
    2     Haskell version of ...
    3 
    4 ! The Checker module for the Boyer benchmark 
    5 ! Started by Tony Kitto on March 30th 1988 
    6 
    7 ! Changes Log                                              
    8 ! 07-04-88 ADK Tautp function removed to main body
    9 ! 08-04-88 ADK bug fix = Truep returns True for (t) 
   10 !                        Falsep returns True for (f)  
   11 
   12 Haskell version::
   13 
   14     23-06-93 JSM initial version
   15 
   16 -}
   17 
   18 module Checker (tautologyp) where
   19 
   20 import Lisplikefns
   21 
   22 tautologyp :: (Lisplist, Lisplist, Lisplist) -> Bool
   23 tautologyp (Nil, _, _) = False
   24 tautologyp (term@(Atom x), truelst, _) = truep (term, truelst)
   25 tautologyp (term@(Cons (x, y)), truelst, falselst) = 
   26     if truep (term, truelst) then True
   27     else if falsep (term, falselst) then False
   28     else case x of
   29         Atom "if" -> if truep (car y, truelst) then
   30                         tautologyp (cadr y, truelst, falselst)
   31                      else if falsep (car y, falselst) then 
   32                         tautologyp (caddr y, truelst, falselst)
   33                      else
   34                         (tautologyp (cadr y, Cons (car y, truelst), falselst)) &&
   35                         (tautologyp (caddr y, truelst, Cons (car y, falselst)))
   36         _         -> False
   37 
   38 truep :: (Lisplist, Lisplist) -> Bool
   39 truep (Nil, _) = False
   40 truep (Cons (Atom "t", Nil), _) = True
   41 truep (term, l) = lispmember (term, l)
   42 
   43 falsep :: (Lisplist, Lisplist) -> Bool
   44 falsep (Nil, _) = False
   45 falsep (Cons (Atom "f", Nil), _) = True
   46 falsep (term, l) = lispmember (term, l)
   47 
   48 lispmember :: (Lisplist, Lisplist) -> Bool
   49 lispmember (e, Cons (x, xs)) | e == x    = True
   50                              | otherwise = lispmember (e, xs)
   51 
   52 lispmember (_, _) = False
   53 
   54