Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: >>>BLoCK PROLOG 1st QUERY<<<
Replies: 2   Last Post: Feb 9, 2013 1:14 AM

 Messages: [ Previous | Next ]
 Graham Cooper Posts: 4,495 Registered: 5/20/10
>>>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
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.

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

Date Subject Author
2/8/13 Graham Cooper
2/8/13 Graham Cooper
2/9/13 Graham Cooper