VAMPIRE=$1
TMP=`mktemp -d /tmp/symel.XXXXX`
if [ "$3" == "" ]; then
CFTIME=20
else
CFTIME=$3
fi
function doConseqEl()
{
rm -rf $TMP/ce
mkdir $TMP/ce
local CTMP=$TMP/ce
cp $1 $CTMP/allInv
cat $CTMP/allInv >> $CTMP/consElInp
$VAMPIRE --time_limit $CFTIME $3 --mode consequence_elimination --splitting off --unused_predicate_definition_removal off <$CTMP/consElInp | awk '
/^Pure cf clause/ { cl=$0; clN=NR }
/^Consequence found/ { print cl }
{ if(NR!=clN) { print; fflush() } }
' | tee $CTMP/consElOut >&2
if grep 'Consequence found' $CTMP/consElOut >/dev/null; then
cat $CTMP/allInv |egrep -v '('`grep 'Consequence found' $CTMP/consElOut | sed 's/^.*: //' | tr '\n' '|' | sed 's/|/,|/g' | sed 's/|$//'`')' > $2
else
cp $CTMP/allInv $2
fi
echo "Strategy \"$3\" eliminated" `grep 'Consequence found' $CTMP/consElOut | wc -l` >&2
}
echo "Extracting type information...">&2
grep tff $2 > $TMP/theory
cat $TMP/theory >&2
echo "Obtaining symbol eliminating inferences...">&2
$VAMPIRE --show_skolemisations on --time_limit 3 < $2 | tee $TMP/out >&2
echo "Prepare consequence elimination task...">&2
grep tff $TMP/out > $TMP/symelFof
cat $TMP/symelFof
cat $TMP/symelFof $TMP/theory > $TMP/symelAll
echo "Start consequence elimination on SEI...">&2
cp $TMP/symelAll $TMP/symel_nonred
doConseqEl $TMP/symel_nonred $TMP/symel_nonred "--selection 1003 --saturation_algorithm discount --backward_subsumption_resolution on --condensation on"
doConseqEl $TMP/symel_nonred $TMP/symel_nonred "--saturation_algorithm discount --forward_literal_rewriting on --backward_subsumption_resolution on --condensation on"
doConseqEl $TMP/symel_nonred $TMP/symel_nonred "--selection 1003 --saturation_algorithm discount"
doConseqEl $TMP/symel_nonred $TMP/symel_nonred "--selection -1 --saturation_algorithm discount --forward_literal_rewriting on"
STAT="% "`grep 'tff(inv.*)\.' $TMP/out | wc -l`" symbol eliminating formulas, "`grep 'tff(inv.*)\.' $TMP/symel_nonred|wc -l`" non-redundant ones"
echo $STAT
echo
echo $STAT >&2
grep Skolem $TMP/out | sed 's/^/%/'
echo
grep 'tff(inv.*)\.' $TMP/symel_nonred
rm -rf $TMP
echo "Done." >&2