-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-src.js
More file actions
63 lines (51 loc) · 2.05 KB
/
test-src.js
File metadata and controls
63 lines (51 loc) · 2.05 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
60
61
62
63
/*
* main-src.js
* -------
* The main driver of the program.
*/
var geo = require('./Logic/Objects/Geometry');
var ObjectDB = require('./Logic/Objects/ObjectDB');
var gfx = require('./Graphics/Geometry');
var Theorem = require('./Logic/Theorems/Theorem');
var ProofState = require('./Logic/Properties/ProofState');
// Let's try solving Exercise 1!
var Exercise1 = require('./Examples/Exercise1');
console.warn("Loaded", Exercise1.name, "!");
var objects = Exercise1.objects,
givenState = Exercise1.givens,
steps = Exercise1.steps,
goalState = Exercise1.goals;
var MidpointSplittingTheorem = require('./Logic/Theorems/MidpointSplittingTheorem');
var ReflexiveProperty = require('./Logic/Theorems/ReflexiveProperty');
var SSSPostulate = require('./Logic/Theorems/SSSPostulate');
var sgAC = new geo.LineSegment(new geo.Point('A'), new geo.Point('C'));
var sgBD = new geo.LineSegment(new geo.Point('B'), new geo.Point('D'));
var trABD = new geo.Triangle(new geo.Point('A'), new geo.Point('B'), new geo.Point('D'));
var trCBD = new geo.Triangle(new geo.Point('C'), new geo.Point('B'), new geo.Point('D'));
console.log("Given:", trABD.toString(), trCBD.toString() +
" and\n" + givenState.toString() + "\n");
console.log("Prove:\n" + goalState.toString());
console.log("== Solved? %s", givenState.contains('congruence', [trABD, trCBD]));
var thm, applicable; // variables for theorem being used and applicability
// Use Reflexive Property
thm = new ReflexiveProperty(objects, givenState);
applicable = thm.checkConditions(sgBD);
if (applicable) {
thm.applyResults(sgBD);
console.log(thm.toString());
}
// Use Midpoint Splitting Theorem
thm = new MidpointSplittingTheorem(objects, givenState);
applicable = thm.checkConditions(sgAC);
if (applicable) {
thm.applyResults(sgAC);
console.log(thm.toString());
}
// Use SSS
thm = new SSSPostulate(objects, givenState);
applicable = thm.checkConditions(trABD, trCBD);
if (applicable) {
thm.applyResults(trABD, trCBD);
console.log(thm.toString());
}
console.log("== Solved? %s", givenState.contains('congruence', [trABD, trCBD]));