3 # utility function to download a file
5 if [ -x "$(command -v wget)" ]; then
7 elif [ -x "$(command -v curl)" ]; then
10 echo "Can't figure out how to download from web. Please install wget or curl." >&2
15 CVC_DIR
=$
(dirname $
(dirname "$0"))
16 mkdir
-p $CVC_DIR/deps
20 mkdir
-p $BASE_DIR/tmp
/
23 LFSC_DIR
="$BASE_DIR/lfsc-checker"
26 # download and unpack LFSC
27 version
="15f53d6feb84e4ddb41deaf2b5630f5c1303b06d"
28 download
"https://github.com/cvc5/LFSC/archive/$version.tar.gz" $BASE_DIR/tmp
/lfsc.tgz
29 tar --strip 1 -xzf $BASE_DIR/tmp
/lfsc.tgz
-C $LFSC_DIR
31 # build and install LFSC
33 mkdir
-p build
&& cd build
34 cmake
-DCMAKE_INSTALL_PREFIX="$BASE_DIR" ..
40 # The LFSC signatures live in the main cvc5 repository
41 SIG_DIR
="$BASE_DIR/../proofs/lfsc/signatures"
43 # install signatures and scripts
44 mkdir
-p $BASE_DIR/share
/lfsc
45 cp -r $SIG_DIR $BASE_DIR/share
/lfsc
47 # based on https://github.com/CVC4/signatures/blob/master/lfsc/new/scripts/cvc4_gen_and_check.sh
48 cat << EOF > $BASE_DIR/bin/cvc5-lfsc-check.sh
51 echo "=== Generate proof: \$@"
52 $BASE_DIR/bin/cvc5-proof.sh \$@ > proof.plf
54 echo "=== Check proof with LFSC"
55 $BASE_DIR/bin/lfsc-check.sh proof.plf
57 chmod +x
$BASE_DIR/bin
/cvc5-lfsc-check.sh
59 # based on https://github.com/CVC4/signatures/blob/master/lfsc/new/scripts/cvc4_gen.sh
60 cat << EOF > $BASE_DIR/bin/cvc5-proof.sh
63 # call cvc5 and remove the first line of the output (should be "unsat")
64 \$@ --dump-proofs --proof-format=lfsc | tail -n +2
66 chmod +x
$BASE_DIR/bin
/cvc5-proof.sh
68 # based on https://github.com/CVC4/signatures/blob/master/lfsc/new/scripts/lfsc_check.sh
69 cat << EOF > $BASE_DIR/bin/lfsc-check.sh
72 cat \$@ | grep WARNING
73 CHECK=\$(cat \$@ | grep check)
74 [ -z "\$CHECK" ] && echo "; WARNING: Empty proof!!!"
76 SIG_DIR=$BASE_DIR/share/lfsc/signatures
77 SIGS="\$SIG_DIR/core_defs.plf \\
78 \$SIG_DIR/util_defs.plf \\
79 \$SIG_DIR/theory_def.plf \\
80 \$SIG_DIR/nary_programs.plf \\
81 \$SIG_DIR/boolean_programs.plf \\
82 \$SIG_DIR/boolean_rules.plf \\
83 \$SIG_DIR/cnf_rules.plf \\
84 \$SIG_DIR/equality_rules.plf \\
85 \$SIG_DIR/arith_programs.plf \\
86 \$SIG_DIR/arith_rules.plf \\
87 \$SIG_DIR/strings_programs.plf \\
88 \$SIG_DIR/strings_rules.plf \\
89 \$SIG_DIR/quantifiers_rules.plf"
90 $BASE_DIR/bin/lfscc \$SIGS \$@ >& lfsc.out
92 # recover macros for applications of arity 1,2,3, and simplify builtin syntax for constants
93 #sed -i.orig 's/(f_ite [^ \)]*)/f_ite/g' lfsc.out
94 sed -i.orig 's/(\\ [^ ]* (\\ [^ ]* (\\ [^ ]* (apply (apply (apply f_\([^ ]*\) [^ ]*) [^ ]*) [^ ]*))))/\1/g; s/(\\ [^ ]* (\\ [^ ]* (apply (apply f_\([^ ]*\) [^ ]*) [^ ]*)))/\1/g; s/(\\ [^ ]* (apply f_\([^ ]*\) [^ ]*))/\1/g; s/(var \([^ ]*\) [^ \)]*)/var_\1/g; s/(int \([^ \)]*\))/\1/g; s/emptystr/""/g; s/int\.//g' lfsc.out
99 chmod +x
$BASE_DIR/bin
/lfsc-check.sh
104 echo "========== How to use LFSC =========="
105 echo "Generate a LFSC proof with cvc5:"
106 echo " $CVC_DIR/deps/bin/cvc5-proof.sh cvc5 <options> <input file>"
107 echo "Check a generated proof:"
108 echo " $CVC_DIR/deps/bin/lfsc-check.sh <proof file>"
109 echo "Run cvc5 and check the generated proof:"
110 echo " $CVC_DIR/deps/bin/cvc5-lfsc-check.sh cvc5 <options> <input file>"