-
Notifications
You must be signed in to change notification settings - Fork 8
/
myprove.sh
executable file
·77 lines (65 loc) · 2.45 KB
/
myprove.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
# Usage:
# Parse and prove a sentence:
# ./myprove.sh <input> [OPTION]
#
# Example:
# ./myprove.sh "太郎がロンドンに住んでいるなら、太郎はロンドンに住んでいる" -latex -show
# ./myprove.sh <file> -latex -show
#
# -latex
# Create a latex output file named "test.tex":
# -show
# Show the preterm, prolog input, etc:
input=$1
arg2=${2:-"none"}
arg3=${3:-"none"}
if [ -e $input ];then
all_results=`cat $input | ./DTStoProlog`
else
all_results=`echo $input | ./DTStoProlog`
fi
results=`echo $all_results \
| sed 's/-- Preterm ---------/##/g' \
| sed 's/-- Prolog input ---------/##/g' \
| sed 's/-- After resolving @ --------/##/g' \
| sed 's/-- After elimSigma --------/##/g' \
| sed 's/-- Coq formula --------/##/g' \
| sed 's/-- Coq code --------/##/g' \
| sed 's/-- Answer --------/##/g' \
| sed 's/-- Time --------/##/g'`
preterm=`echo $results | awk -F"##" '{print $2;}'`
prolog=`echo $results | awk -F"##" '{print $3;}'`
resolved=`echo $results | awk -F"##" '{print $4;}'`
normal=`echo $results | awk -F"##" '{print $5;}'`
coqformula=`echo $results | awk -F"##" '{print $6;}'`
signatureLine=`echo $results | awk -F"##" '{print $7;}'`
signature=`echo $signatureLine | sed 's/\./\.#/g' | tr '#' '\n' | sed 's/^ //g'`
answer=`echo $results | awk -F"##" '{print $(NF - 1)}'`
echo "answer:${answer}"
# output=`echo -e "Require Export coqlib.\n \
# $signature\n \
# Theorem trm: ${coqformula}. \
# firstorder. Qed." | coqtop 2>/dev/null`
coqscript="Require Export coqlib.\n$signature\nTheorem trm: ${coqformula}. firstorder. Qed."
if [ $arg2 = "-show" -o $arg3 = "-show" ]; then
echo -e "--- Preterm ---\n${preterm}"
echo -e "--- Prolog input ---\n${prolog}"
echo -e "--- Resolving @ ---\n${resolved}"
echo -e "--- Normalized ---\n${normal}"
# echo -e "--- Coq formula ---\n${coqformula}"
# echo -e "--- Coq signature ---\n${signature}"
echo -e "--- Coq script ---\n${signature}"
# echo -e "--- Coq script ---\n${coqscript}"
fi
# echo $output | awk '{if ($NF == "defined") {print "yes"} else {print "no"}}'
# echo $output | awk '{if ( $0 ~ /is defined/ ) {print "yes"} else {print "no"}}'
g1=`echo $prolog | sed 's/_//g'`
g2=`echo $resolved | sed 's/_//g'`
g3=`echo $normal | sed 's/_//g'`
if [ $arg2 = '-latex' -o $arg3 = '-latex' ]; then
swipl -s Prolog/prolog2latex.pl -g main -t halt --quiet -- "${g1}" "${g2}" "${g3}"
# platex test.tex > /dev/null 2>&1
# dvipdfmx test.dvi > /dev/null 2>&1
# open test.pdf
fi