-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
183 lines (181 loc) · 5.77 KB
/
index.html
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<html>
<head>
<title>FOLProof First-Order Logic Checker</title>
<link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="http://getbootstrap.com/assets/css/docs.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script type='text/javascript' src='folproof-parser.js'></script>
<script type='text/javascript' src='folproof-web.js'></script>
<script type='text/javascript' src='folproof-verifier.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
var debugMode = true;
$("#parentheses").bind("click change", function() { $("#proof-input").keyup(); });
$("#proof-input").keyup(function(v) {
var proof = $(this).val();
var paren = $("#parentheses").val();
try {
parser.trace = function() { if (console && console.log) console.log(arguments); };
var ast = parser.parse(proof);
var result = folproof.Verifier.verifyFromAST(ast);
$("#result").text(result.message);
if (!result.valid) {
var str = "<p>Step: " + result.errorStep;
if (result.errorSrcLine)
str += ", Src Line: " + result.errorSrcLoc.first_line;
str += "</p>";
$("#result").append(str);
$("#result-box").css({ background: "", 'border-left' : "", color : "" });
} else {
$("#result-box").css({ background: "#ccffcc", 'border-left' : "3px solid green", color : "" });
}
} catch (err) {
$("#result").text(err);
$("#result-box").css({ background: "", 'border-left' : "", color : "" });
//throw err;
}
var html = folproofWeb.render(ast, { parentheses : paren });
$("#render-panel").empty().append(html);
});
$("#proof-input").keyup(); // force invocation on load
$("button.examples").click(function() {
var i = $(this).val();
var proof = $("#proof-input");
proof.val($("#example" + i).text().substr(1))
proof.keyup();
});
});
</script>
<style type='text/css' rel='stylesheet'>
#proof-input { height: 32em; width: 100%; font-family: monospace;}
#render-panel { height: 21em; font-family: monospace; }
#result-box { height: 7em; margin-top: 0.8em;}
.justification { width: 50%; float: right; }
.FOL-box, .simple-box { border: 1px solid black; border-radius: 3px; padding: 2px;}
.folproof-error { color: red; font-weight: bold; }
.lineno { display: block; float: left; width: 1.8em; }
.rule { clear: both; }
#examples { display: none; }
</style>
</head>
<body>
<div class='container'>
<div class='row'>
<div class='col-md-12'>
<h1>FOLProof</h1>
<h4>Javascript First-Order Logic Proof Checker</h4>
Source: <a href='https://github.com/cdibbs/folproof/tree/master' title='folproof source on github'>https://github.com/cdibbs/folproof/tree/master</a>
<div class='bs-callout bs-callout-info'>
<h4>Instructions:</h4>
<p>
Enter your proof in the input box, below. As you type, the formatted proof
will appear on the right, along with a validation status, beneath that. To learn
the syntax, try playing with the examples, below, or see the
<a href='//github.com/cdibbs/folproof/blob/gh-pages/docs/language.md'>language reference.</a>
</p>
<p>
<strong>Note:</strong> Please be sure you have a modern browser, and that
Javascript is enabled.
</p>
<strong>Examples:<strong>
<button class='examples' value='0'>HW3 Problem 5</button>
<button class='examples' value='1'>HW3 Problem 4</button>
<button class='examples' value='2'>HW3 Problem 7</button>
<button class='examples' value='3'>Page 115</button>
</div>
</div>
</div>
<div class='row'>
<div id='leftcol' class='col-md-6'>
<textarea id='proof-input'>
1 A.x(P(x) -> ~Q(x)) : premise
2 | E.x(P(x) and Q(x)) : assumption
|| with x0
3 || P(x0) and Q(x0) : assumption
4 || P(x0) : and elim1 3
5 || P(x0) -> ~Q(x0) : A.x/x0 elim 1
6 || ~Q(x0) : -> e 5,4
7 || Q(x0) : and elim2 3
8 || contradiction : not elim 6,7
---
9 | contradiction : E.x/x0 elim 2,3-8
---
10 ~(E.x(P(x) and Q(x))) : not introduction 2-9
</textarea>
</div>
<div id='rightcol' class='col-md-6'>
</div>
<div id='rightcol' class='col-md-6'>
<div id='render-panel' class='highlight'>
</div>
<div id='options'>
<label>
Parentheses:
<select id='parentheses'>
<option value='minimal'>Minimal (order-of-ops overrides)</option>
<option value='user' selected='selected'>User-defined</option>
<option value='explicit'>Explicit order-of-ops</option>
</select>
</label>
</div>
<div id='result-box' class='bs-callout bs-callout-warning'>
<h4>Result:</h4>
<div id='result'>
</div>
</div>
</div>
</div>
</div>
<!-- these are hidden by CSS style rules... -->
<div id='examples'>
<div id='example0'>
1 A.x(P(x) -> ~Q(x)) : premise
2 | E.x(P(x) and Q(x)) : assumption
|| with x0
3 || P(x0) and Q(x0) : assumption
4 || P(x0) : and elim1 3
5 || P(x0) -> ~Q(x0) : A.x/x0 elim 1
6 || ~Q(x0) : -> e 5,4
7 || Q(x0) : and elim2 3
8 || contradiction : not elim 6,7
---
9 | contradiction : E.x/x0 elim 2,3-8
---
10 ~(E.x(P(x) and Q(x))) : not introduction 2-9
</div>
<div id='example1'>
# Extraneous step #s in the src are ignored. Be careful.
1 A.x(P(x,z))
| with y0
2 | P(y0,z) : A.x/y0 e 1
---
3 A.y(P(y,z)) : A.y/y0 i 2-2
</div>
<div id='example2'>
# Sloppy syntax is fine :-)
P(a)
| with x0
|| a = x0 : assumption
|| P(x0) : = e 2,1
-
| a = x0 -> P(x0) : -> i 2-3
-
A.x(a=x->P(x)) : A.x/x0 i 2-4
</div>
<div id='example3'>
1 A.x(Q(x) -> R(x)) : premise
2 E.x(P(x) and Q(x)) : premise
| with x0
3 | P(x0) and Q(x0) : assumption
4 | Q(x0) -> R(x0) : A.x/x0 e 1
5 | Q(x0) : and e2 3
6 | R(x0) : -> e 4,5
7 | P(x0) : and e1 3
8 | P(x0) and R(x0) : and i 7,6
9 | E.x(P(x) and R(x)) : E.x/x0 i 8
---
10 E.x(P(x) and R(x)) : E.x/x0 e 2, 3-9
</div>
</div>
</body>
</html>