00001 package edu.ksu.cis.bandera.abstraction.pvs;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 import java.io.*;
00036 import java.util.*;
00037
00038 class Main {
00039
00040
00041 public static void main(String[] args) {
00042
00043 PrintWriter f_pvs, f_prf, f_el;
00044
00045
00046
00047 try {
00048
00049
00050 FileInputStream spec = new FileInputStream(args[0]);
00051 if(spec==null)
00052 { System.err.println("Error: Unable to open specification file");
00053 return;
00054 }
00055 parser parser_obj = new parser(new Yylex(spec));
00056 parser_obj.parse();
00057 if(parser_obj.npredicates != parser_obj.tokens.size()) {
00058 System.err.println("Error: wrong tokens set!"); return;
00059 }
00060 spec.close();
00061
00062 f_pvs = new PrintWriter(new OutputStreamWriter(
00063 new FileOutputStream("abstraction.pvs")));
00064 f_prf = new PrintWriter(new OutputStreamWriter(
00065 new FileOutputStream("abstraction.prf")));
00066 f_el = new PrintWriter(new OutputStreamWriter(
00067 new FileOutputStream("abstraction.el")));
00068
00069 if(f_pvs == null || f_prf == null || f_el == null)
00070 { System.err.println("Error: Unable to open tmp file");
00071 return;
00072 }
00073
00074 if (parser_obj.basic_type==sym.INT) PVS.begin_int(f_pvs);
00075 else PVS.begin_float(f_pvs);
00076 parser_obj.tree.print_PVS(f_pvs);
00077
00078 PVS.check(f_pvs,parser_obj.npredicates);
00079
00080 PVS.rest(f_pvs,parser_obj.npredicates,parser_obj.basic_type);
00081
00082 PVS.prf(f_prf,parser_obj.npredicates,parser_obj.basic_type);
00083
00084 f_el.println("(prove-pvs-file \"abstraction\")");
00085
00086 f_prf.close();
00087 f_pvs.close();
00088 f_el.close();
00089
00090
00091 PVS.execAndWait("pvs -batch -q -l abstraction.el -v 1");
00092
00093 PrintWriter f_spec = new PrintWriter(new OutputStreamWriter(
00094 new FileOutputStream(parser_obj.name+"Abstraction.basl")));
00095
00096 if(f_spec == null)
00097 { System.err.println("Error: Unable to open tmp file");
00098 return;
00099 }
00100
00101
00102 if(parser_obj.basic_type==sym.INT)
00103 f_spec.print("abstraction "+parser_obj.name+" extends integral\n begin\n");
00104 else
00105 f_spec.print("abstraction "+parser_obj.name+" extends real\n begin\n");
00106
00107 f_spec.print(" TOKENS = { ");
00108 for(int i=0;i<parser_obj.npredicates-1;i++)
00109 f_spec.print(parser_obj.tokens.elementAt(i)+" , ");
00110 f_spec.print(parser_obj.tokens.elementAt(parser_obj.npredicates-1)+" }; ");
00111
00112 PVS.check_BASL(f_spec,parser_obj.npredicates,parser_obj.tokens);
00113
00114 f_spec.print("\n\n abstract("+parser_obj.variable+")\n begin\n");
00115 parser_obj.tree.print_BASL(f_spec);
00116 f_spec.print(" end\n\n");
00117
00118
00119 PVS.rest_BASL(f_spec,parser_obj.npredicates,parser_obj.basic_type,
00120 parser_obj.tokens);
00121 f_spec.close();
00122
00123
00124
00125 } catch (Exception e) {
00126 e.printStackTrace();
00127 }
00128 }
00129 }