#!/bin/bash
#
# Use STP to create CNF from SMT input, and use Riss to solve it

SOLVERDIR="$(dirname "${BASH_SOURCE[0]}" )"

# clean last call
rm -f output_0.cnf
"$SOLVERDIR"/stp-2.1.2  --SMTLIB2 --output-CNF --exit-after-CNF "$1"

# In case a file was created, call the SAT solver
if [ -f output_0.cnf ]
then
	SOLVERCODE=0
	"$SOLVERDIR"/riss -verb=0 -quiet output_0.cnf > /dev/null 2>&1 || SOLVERCODE=$?

	if [ "$SOLVERCODE" -eq 10 ]; then
		echo "sat"
	elif [ "$SOLVERCODE" -eq 20 ]; then
		echo "unsat"
	fi
fi
