!7 sS facts = [[ We want to find out what is more correct than what. "not correct" is a candidate. "maybe quite correct" is a candidate. "really really correct" is a candidate. "buggy" is a candidate. "total garbage" is a candidate. "incorrect" is a candidate. "almost correct" is a candidate. "absolutely correct" is a candidate. "very correct" is a candidate. [nfhwfngqkgoqtngs] (X is a candidate.) and (Y is a candidate.) and (X <> Y) and (I don't know if (X is more correct than Y.)) => (Ask (Is X # more correct than Y?)) // Note: The # is just a filler for parsing, we'll get rid of that in time. Also, you will be able to write stuff without brackets of course. [yrgkrfrcwubpevzu] While (no question) => (Apply nfhwfngqkgoqtngs) no question :- There is no statement with operator fxxathfdlfzgmaov. // Just a pretty-printing statement omrvwjslbkffaxoj hszwyiyetuuhcfwz acwmbrxqrlaplyqu ]]; sS concepts = [[ phkdhqkhzytkwdpb - (X) and (Y) and (Z) and (AA) => (AB) cdzttdbxadjreorm - We want to find out what is X than what. ogqdgzepqbunuuht - X is a candidate. psrgtxwtfzmfzhsx - Is X Y than Z? hszwyiyetuuhcfwz - Is X # Y than Z? acwmbrxqrlaplyqu - Is "X" Y than "Z"? qgxjwufpfzkqvmxb - X is Y than Z. ylvaoplzguvhegka - X is not Y than Z. zxucpbfzmexohoiv - It is not true that (X). buahjsodljsaxvaq - X <> Y fxxathfdlfzgmaov - Ask (X) mzdvauejerzefagk - I don't know if (X) omrvwjslbkffaxoj - Format operator X as template Y. hzmtabxcmkrtffgh - Apply X plprefzezbluijrw - no question cuutddpitkuswthu - While (X) => (Y) sicrogpdrtkiptun - X :- Y zhoulgsatpswstfa - There is no statement with operator X. ltyqczktgtjxrtlf - more correct zveeggveflecjwvr - total garbage wolealpbqkkqkvqq - not correct tomkbzlqlpeiekvu - maybe quite correct dnxyynujqydgcxcd - really really correct trajdgvqepyhsumb - buggy lwikikhkydtewtjc - incorrect muxjpepnjiyjghwj - almost correct wtnpjovqqiswlyay - absolutely correct bmliokweerblfxco - very correct ]]; static Map> evaluators = new HashMap; p-tt { centerConsole(); substance(); // customize parsing and printing set englishToConceptLanguage_unquote; set englishToConceptLanguage_simple_noXYZ; set formatXYZ_quotedVars; useConceptsAndStatements(concepts, facts); printLispStatements(); // create evaluators // X <> Y evaluators.put("buahjsodljsaxvaq", new F1() { Bool get(Lisp l) { ret l.size() == 2 && neq(l.get(0), l.get(1)); } }); // I don't know if (X) evaluators.put("mzdvauejerzefagk", new F1() { Bool get(Lisp l) { ret l.size() == 1 && notKnownIf(l.get(0)); } }); // There is no statement with operator X. evaluators.put("zhoulgsatpswstfa", new F1() { Bool get(Lisp l) { ret l.size() == 1 && hasTruthWithHead(l.raw(0)); } }); // :- rules for (final Lisp rule : lispTruth2("sicrogpdrtkiptun")) evaluators.put(rule.raw(0), new F1() { Bool get(Lisp l) { ret l.isLeaf() && matchCondition(rule.get(1)); } }); //applyRule("nfhwfngqkgoqtngs"); runInstruction("yrgkrfrcwubpevzu"); } svoid runInstruction(S instructionID) { Lisp rule = getLispTruth(instructionID); if (rule == null) { print("Instruction not found: " + instructionID); ret; } runInstruction(rule); } svoid runInstruction(Lisp rule) { if (rule.is("hzmtabxcmkrtffgh", 1)) applyRule(rule.raw(1)); else if (rule.is("cuutddpitkuswthu", 2)) { while (ping() && lispTrue(rule.get(0))) runInstruction(rule.get(1)); } else print("Unknown instruction type: " + rule); } svoid applyRule(S ruleID) { // process the rule Lisp rule = getLispTruth(ruleID); if (rule == null) { print("Rule not found: " + ruleID); ret; } L conditions = dropLast(rule.args); Lisp out = last(rule.args); //for (Lisp cond : conditions) print("Condition: " + cond); new Map matches; int n = matchConditions_random(conditions, matches); if (n == -1) { print("Yo! " + struct(matches)); out = lispReplaceVars(out, matches); if (lispTrue(out)) print("Already had: " + out); else { print("Defining: " + lispToEnglish_prettier(out)); lispAddLocalTruth(out); } } else print("Only " + n + " of " + n(conditions, "condition") + " met"); } // if match: returns -1 // if no match: returns how many conditions were met static int matchConditions_random(L conditions, Map m) { if (empty(conditions)) ret -1; Lisp condition = first(conditions); Map m2 = cloneMap(m); if (!matchCondition_random(condition, m2)) ret 0; int n = matchConditions_random(dropFirst(conditions), m2); if (n == -1) { m.putAll(m2); ret -1; } ret n+1; // failure } sbool matchCondition(Lisp condition) { O evaluator = evaluators.get(condition.head); if (evaluator != null) ret isTrue(callF(evaluator, lispReplaceVars(condition, m))); ret lispTrue(condition); } static bool matchCondition_random(Lisp condition, Map m) { L facts = lispTruth(); O evaluator = evaluators.get(condition.head); if (evaluator != null) ret isTrue(callF(evaluator, lispReplaceVars(condition, m))); L> candidates = new L; for (Lisp fact : facts) { Map m2 = cloneMap(m); if (lispMatchIC_xyzVars_sub(condition, fact, m2)) candidates.add(m2); } //print("Have " + n(candidates, "candidate")); if (empty(candidates)) false; m.putAll(random(candidates)); true; } sbool notKnownIf(Lisp l) { // check fact and negation ret !lispTrue(l) && !lispTrue(lisp("zxucpbfzmexohoiv", l); }