#!/bin/bash

# USAGE: judge <symbolfile> <solver output> <solver exit code>

BIN=`dirname $0`

if egrep "^s SATISFIABLE$" $2 1>/dev/null
then
  if test $3 -eq 10
  then
    echo "ANSWER"
    egrep "^v " $2 \
    | tr -d "\n" \
    | $BIN/interpret-1.11 $1 | sed 's/ /. /g'; echo ""
    rval=10
  else
    echo "UNKNOWN"
    rval=1
  fi
else
  if egrep "^s UNSATISFIABLE$" $2 1>/dev/null
  then
    if test $3 -eq 20
    then
      echo "INCONSISTENT"
      rval=20
    else
      echo "UNKNOWN"
      rval=1
    fi
  else
    echo "UNKNOWN"
    rval=1
  fi
fi

rm -f $1
rm -f $2

exit $rval
