-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHW2.java
More file actions
59 lines (54 loc) · 2.25 KB
/
HW2.java
File metadata and controls
59 lines (54 loc) · 2.25 KB
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
import checker.ProofChanger;
import checker.ProofInput;
import checker.Utils;
import expression.Expression;
import expression.ExpressionParser;
import expression.Implication;
import java.io.*;
import java.util.ArrayList;
public class HW2 {
public static void main(String[] args) throws IOException {
if (args.length == 0) {
System.out.println("Enter path to test file");
} else {
try {
BufferedReader reader = new BufferedReader(new FileReader(args[0]));
BufferedWriter writer = new BufferedWriter(new FileWriter(args[0] + ".log"));
Utils.Head head = Utils.readHead(reader.readLine());
Expression mainAssumption = head.assumptions.remove(head.assumptions.size() - 1);
for (int i = 0; i < head.assumptions.size(); i++) {
if (i != 0) writer.write(",");
writer.write(head.assumptions.get(i).toString());
}
writer.write("|-");
writer.write(new Implication(mainAssumption, head.toProve).toString());
writer.newLine();
new ProofChanger(new ProofInput() {
@Override
public Expression nextLine() throws IOException {
String s;
if ((s = reader.readLine()) == null){
return null;
}
return ExpressionParser.parse(s);
}
@Override
public ArrayList<Expression> getAssumptions() {
return head.assumptions;
}
@Override
public Expression getMainAssumption() {
return mainAssumption;
}
}, expression -> writer.write(expression.toString() + '\n')).change();
writer.close();
} catch (FileNotFoundException e) {
System.out.println("no file");
e.printStackTrace();
} catch (IOException e){
System.out.println("Output pronlem");
e.printStackTrace();
}
}
}
}