Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
>>>BLoCK PROLOG 1st QUERY<<<
Posted:
Feb 8, 2013 10:11 PM
|
|
The Query was > lady kim?
http://www.blockprolog.com/PROLOG-LIST.png
http://www.blockprolog.com/PROLOG-RESULT.png
-----------------
This is using a REVOLUTIONARY PROLOG UNIFY ENGINE.
This one line of SQL does the work of 100 lines of C++ or 20 lines of very slow LISP.
$qc = $row['COUNT(*)']; $sql2="SELECT HEADS.id AS 'HID', QUERY.buds AS 'QB' FROM QUERY INNER JOIN HEADS ON QUERY.ref=HEADS.ref AND QUERY.term=HEADS.term GROUP BY HID HAVING COUNT(HID)=$qc-SUM(QB)";
This is a completely new Algorithm, the only improvement to PROLOG in 40 years.
A 4TH ATOMIC TYPE is needed to do the SQL UNIFY!
a term may be a function itself.
QUERY HEADS term ----> term BUD ----> VAR
where BUDS are created at each level of the parameter hierarchy.
This enables the SQL to count if the exact required number of matches to the predicates in the database HEADS, was reached! And also match to any lower level VARIABLES and still keep count!
e.g.
FACTS f [a [b c]] f A
QUERY f [a [b d]]
This Generates the Query into the TABLE QUERY
QUERY: 1 : f QUERY: 21 : a QUERY: 221 : b QUERY: 222 : d BUDDS: 1 BUDDS: 21 BUDDS: 2 BUDDS: 221 BUDDS: 22 BUDDS: 2 BUDDS: 222 BUDDS: 22 BUDDS: 2
A QUERY BUDD matches to a FACT VAR (since it's whole tree is missing some!)
TABLE QUERY ref term buds 1 f 0 21 a 0 221 b 0 222 d 0 1 * 0 21 * 0 2 * 2 221 * 0 22 * 1 222 * 0
All the BUDDS are Added to the Query because a VAR could be at any of those positions!
THEN, by subtracting the buds number should that bud TABLE JOIN to a VAR (also '*') from the total number of QUERY TERMS = 4
so if there was a VARIABLE at REF=22 in a FACT only 4-1 = 3 ROWS are needed in the SQL RESULTS to guarantee no terms where mis-matched!
We just sum all the BUDS VALUES and subtract them from the simpler row count value.
"GROUP BY HID HAVING COUNT(HID)=$qc-SUM(QB)";
Thus... extremely fast B-Tree indexed matching of the WHOLE QUERY to the WHOLE DATABASE in 1 line of SQL!
Herc -- www.BLoCKPROLOG.com
|
|
|
|