Skip to content
Snippets Groups Projects
pvs2dk.sh 1.43 KiB
Newer Older
hondet's avatar
hondet committed
#!/bin/sh
Gabriel's avatar
Gabriel committed

# usage: pvs2dk.sh [options]
#   -f p, --file p              translate theory from file p
#   -t h, --theory h            translate theory t
#   -o p, --output p            write translation to file p

hondet's avatar
hondet committed
set -euf
Gabriel's avatar
Gabriel committed

theory=""
file=""
output=""

hondet's avatar
hondet committed
ansi () {
	printf "\e[${1}m${2}\e[0m"
}

hondet's avatar
hondet committed
HELP () {
hondet's avatar
hondet committed
	printf "NAME: pvs2dk --- Translate PVS specifications to Dedukti
hondet's avatar
hondet committed

SYNOPSIS:

hondet's avatar
hondet committed
$0 -f FILE -t THEORY -o OUTPUT
hondet's avatar
hondet committed

 Options:
hondet's avatar
hondet committed
   -f PVS file containing the theory to translate
hondet's avatar
hondet committed
   -t Name of the theory to translate
   -o Target file of the translation

DESCRIPTION:

hondet's avatar
hondet committed
Translate a PVS theory to lambdapi, an implementation of λΠ/R. It
translates only declarations, definitions and propositions, proofs are
not translated.
Gabriel's avatar
Gabriel committed

PVS filepaths are ALWAYS relative to the root of PVS. This restriction
is imposed by PVS (which uses a environment variable PVSPATH).

hondet's avatar
hondet committed
EXAMPLES
Gabriel's avatar
Gabriel committed

hondet's avatar
hondet committed
pvs2dk -f lib/prelude.pvs -t booleans -o booleans.lp
	Translate the theory $(ansi 4 booleans) in file $(ansi 4 booleans.pvs)
	to the file $(ansi 4 booleans.lp)
\n"
hondet's avatar
hondet committed
	exit 1
}

while getopts 'f:t:o:h' o; do
Gabriel's avatar
Gabriel committed
    case "$o" in
        f) file="$(realpath "${OPTARG}")" ;;
        t) theory="${OPTARG}" ;;
        o) output="${OPTARG}" ;;
hondet's avatar
hondet committed
				h) HELP ;;
				?) HELP ;;
Gabriel's avatar
Gabriel committed
    esac
done
hondet's avatar
hondet committed
output="$(realpath "$(dirname "${output}")")/$(basename "${output}")"
Gabriel's avatar
Gabriel committed

pvscmd="(prettyprint-dedukti \"${file}#${theory}\" \"${output}\")"
hondet's avatar
hondet committed
(cd "${PVSPATH:?'PVSPATH not set'}" || exit 1
Gabriel's avatar
Gabriel committed
 ./pvs -raw -E "${pvscmd}" --quit)