ENGRIPPA is an artificial intelligence engine which spawns virtual machines, intended as an alternative for artificial neural networks.
let vm = new __ENGRIPPA__( [ {json training set...}, ... ] ])
let result = vm.__exec( [ {json data set...}, ... ],flags )
console.log( result[0] )
All training sets must be separated into right hand side / left hand side assertions (rhs/lhs):
var training_set1 = {
lhs : `{ num : 0, mult : '*', num : 0 }`,
rhs : `{ product : 0 }`
}
An instantiation example
let training_set = [ training_set1 ]
let vm = new __ENGRIPPA__( training_set )
let result = vm.__exec( [ `{ num : 0, mult : '*', num : 0 }` ] )
console.log( result[0] ) // `{ product : 0 }` //
A basic multiplication table
let tt000 = {
lhs : `{ num : 0, mult : '*', num : 0 }`,
rhs : `{ product : 0 }` }
let tt001 = {
lhs : `{ num : 0, mult : '*', num : 1 }`,
rhs : `{ product : 0 }` }
let tt002 = {
lhs : `{ num : 0, mult : '*', num : 2 }`,
rhs : `{ product : 0 }` }
.
.
let tt144 = {
lhs : `{ num : 12, mult : '*', num : 12 }`,
rhs : `{ product : 144 }` }
let training_set = [ tt000,...,tt144 ]
let vm = new __ENGRIPPA__( training_set )
let tt_unk = `{ num : 12, mult : '*', num : 12 }`
let result = vm.__exec( [ tt_unk ] )
console.log( result[0] ) // `{ product : 144 }` //
A reverse multiplication table
let tt000 = {
lhs : `{ product : 0 }`,
rhs : `{ num : 0, mult : '*', num : 0 }` }
let tt001 = {
lhs : `{ product : 0 }`,
rhs : `{ num : 0, mult : '*', num : 1 }` }
let tt002 = {
lhs : `{ product : 0 }`,
rhs : `{ num : 0, mult : '*', num : 2 }` }
.
.
let tt144 = {
lhs : `{ product : 144 }`,
rhs : `{ num : 12, mult : '*', num : 12 }` }
let training_set = [ tt000,...,tt144 ]
let vm = new __ENGRIPPA__( training_set )
.
.
let tt_unk = `{ product : 144 }`
let result00 = vm.__exec( [ tt_unk ] )
let result01 = vm.__exec( [ tt_unk ],'converge' ) //iff many solutions//
console.log( result00 ) // [`{ num : 12, mult : '*', num : 12 }`, ... ] //
console.log( result01 ) // [`{ num : 12, mult : '*', num : 12 }`] //
A subtraction table
let tt000 = {
lhs : `[ num : 2, minus : '-', num : 1 ]`,
rhs : `{ result : 1 }`
}
let tt001 = {
lhs : `[ num : 5, minus : '-', num : 3 ]`,
rhs : `{ result : 2 }`
}
let training_set = [ tt000,tt001 ]
let vm = new __ENGRIPPA__( training_set )
A speech training example
let tt000 = {
lhs : `[{ freq : 0x46, amp : 0x6, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'Hello' }`
}
let tt001 = {
lhs : `[{ freq : 0x38, amp : 0x5, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'Hello' }`
}
let training_set = [ tt000,tt001 ]
let vm = new __ENGRIPPA__( training_set )
Concurrent training sessions
let tt000 = {
lhs : `[{ freq : 0x46, amp : 0x6, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'Hello' }`
}
let tt001 = {
lhs : `[{ freq : 0x55, amp : 0x7, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'World' }`
}
let training_set1 = [ tt000 ]
let training_set2 = [ tt001 ]
let vm = new __ENGRIPPA__( training_set1, training_set2 )
An automated trading example
let tt000 = {
lhs : `[
{ 'stock' : 'aapl', '5-yr-trend' : 150.4, '2-yr-trend' : 165.3, '1-yr-trend' : 173.3, '200-day-trend' : 177.2, '100-day-trend' : 181.5, '90-day-trend' : 184.3, '20-day-trend' : 186.0, '10-day-trend' : 188.0, '5-day-trend' : 188.8, '2-day-trend' : 191.0, '1-day-trend' : 192.5, '10-hr-trend' : 199.2, '5-hr-trend' : 199.4, '2-hr-trend' : 199.4 },
{ 'stock' : 'aapl', '5-yr-trend' : 150.4, '2-yr-trend' : 165.3, '1-yr-trend' : 173.3, '200-day-trend' : 177.2, '100-day-trend' : 181.5, '90-day-trend' : 184.3, '20-day-trend' : 186.0, '10-day-trend' : 188.0, '5-day-trend' : 188.8, '2-day-trend' : 191.0, '1-day-trend' : 192.5, '10-hr-trend' : 199.2, '5-hr-trend' : 199.4, '2-hr-trend' : 201.1 },
{ 'stock' : 'aapl', '5-yr-trend' : 150.4, '2-yr-trend' : 165.3, '1-yr-trend' : 173.3, '200-day-trend' : 177.2, '100-day-trend' : 181.5, '90-day-trend' : 184.3, '20-day-trend' : 186.0, '10-day-trend' : 188.0, '5-day-trend' : 188.8, '2-day-trend' : 191.0, '1-day-trend' : 192.5, '10-hr-trend' : 199.2, '5-hr-trend' : 199.6, '2-hr-trend' : 201.9 }
]`,
rhs : `{ msg : 'Watch' }`
}
let tt001 = {
lhs : `[
{ 'stock' : 'aapl', '5-yr-trend' : 150.4, '2-yr-trend' : 165.3, '1-yr-trend' : 173.3, '200-day-trend' : 177.2, '100-day-trend' : 181.5, '90-day-trend' : 184.3, '20-day-trend' : 186.0, '10-day-trend' : 188.0, '5-day-trend' : 188.8, '2-day-trend' : 191.0, '1-day-trend' : 192.5, '10-hr-trend' : 199.2, '5-hr-trend' : 199.4, '2-hr-trend' : 199.4 },
{ 'stock' : 'aapl', '5-yr-trend' : 150.4, '2-yr-trend' : 165.3, '1-yr-trend' : 173.3, '200-day-trend' : 177.2, '100-day-trend' : 181.5, '90-day-trend' : 184.3, '20-day-trend' : 186.0, '10-day-trend' : 188.0, '5-day-trend' : 188.8, '2-day-trend' : 191.0, '1-day-trend' : 192.5, '10-hr-trend' : 199.2, '5-hr-trend' : 199.4, '2-hr-trend' : 201.1 },
{ 'stock' : 'aapl', '5-yr-trend' : 150.4, '2-yr-trend' : 165.3, '1-yr-trend' : 173.3, '200-day-trend' : 177.2, '100-day-trend' : 181.5, '90-day-trend' : 184.3, '20-day-trend' : 186.0, '10-day-trend' : 188.0, '5-day-trend' : 188.8, '2-day-trend' : 191.0, '1-day-trend' : 192.5, '10-hr-trend' : 199.2, '5-hr-trend' : 199.6, '2-hr-trend' : 201.9+ }
]`,
rhs : `{ msg : 'Buy' }`
}
let training_set00 = [ tt000 ]
let training_set01 = [ tt001 ]
let vm = new __ENGRIPPA__( training_set00, training_set01 )
Dependancy graph: one-to-many
/* -------------------------
b
/
a - c
\
d
------------------------- */
let tt000 = {
lhs : `{ { a } : { b, c, d } }`,
rhs : `{ result : 'one-to-many' }`
}
Dependancy graph: many-to-one
/* -------------------------
b
\
c - a
/
d
------------------------- */
let tt000 = {
lhs : `{ { b, c, d } : { a } }`,
rhs : `{ result : 'many-to-one' }`
}
Dependancy graph example
/* -----------------------------
let a = {
b : { 1 : { d,e,f } },
c : { 1 : { d,e,f } },
d : { 1 : { d,e,f } },
}
---------------------------- */
let tt000 = {
lhs : `{ { a } : { b, c, d } : { 1 } : { d,e,f } }`,
rhs : `{ result : 'a-dependancy-graph-example' }`
}
A condensed multiplication table
/* -------------------------
let _tt000 = {
lhs : `{ num : 0, mult : '*', num : 0 }`,
rhs : `{ product : 0 }`,
}
let _tt001 = {
lhs : `{ num : 1, mult : '*', num : 0 }`,
rhs : `{ product : 0 }`,
}
.
.
let _tt075 = {
lhs : `{ real : 0, mult : '*', real : 12 }`,
rhs : `{ product : 0 }`,
}
------------------------- */
let tt000 = {
lhs : `{ [ num, int, real ] : { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12 }, op : { mult : '*' }, [ num, int, real ] : 0 }`,
rhs : `{ result : { product : 0 } }`
}
let tt001 = {
lhs : `{ [ num, int, real ] : 0, op : { mult : '*', div : '/' }, [ num, int, real ] : { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12 } }`,
rhs : `{ result : { product : 0 } }`
}
let tt002 = {
lhs : `{ [ num, int, real ] : { 0 }, op : { '*', '/', '+', '-' }, [ num, int, real ] : { 0 } }`,
rhs : `{ result : 0 }`
}
A cross network inference example
let tt000 = {
lhs : `{ num : 2, op : '+', num : 2 }`,
rhs : `{ sum : { num : 4 } }`
}
let tt001 = {
lhs : `{ num : 1, op : '+', num : 1 }`,
rhs : `{ sum : { num : 2 } }`
}
let training_set1 = [ tt000 ]
let training_set2 = [ tt001 ]
let vm = new __ENGRIPPA__( training_set1, training_set2 )
let tt_unk = `{ num : 1, op : '+', num : 1, op : '+', num : 1, op : '+', num : 1 }`
let result00 = vm.__exec( [ tt_unk ] )
console.log( result00 ) // [`{ sum : { num : 4 } }`] //
An ontology match (cross training) example (same domain)
let tt000 = {
lhs : `{ act : eat }`,
rhs : `{ outOf : { container : { cup, bowl } } }`
}
let tt001 = {
lhs : `{ act : eat, meal : small }`,
rhs : `{ outOf : { container : cup } } }`
}
let tt002 = {
lhs : `{ container : [ bowl, cup ] }`,
rhs : `{ meal : [ large, small ] }`
}
let training_set1 = [ tt000 ]
let training_set2 = [ tt001 ]
let training_set3 = [ tt002 ]
let vm = new __ENGRIPPA__( training_set1, training_set2, training_set3 )
let tt_unk = `{ act : eat, meal : large }`
let result00 = vm.__exec( [ tt_unk ] )
console.log( result00[0] ) // `{ outOf : { container : bowl } }` //
An ontology match (cross training) example (cross domain)
let tt000 = {
lhs : `{ act : tidy, object : dish }`,
rhs : `{ act : wash, object : dish, tool : 'dish soap' }`
}
let tt001 = {
lhs : `{ act : tidy }`,
rhs : `{ act : { wash, mow, sweep } } }`
}
let tt002 = {
lhs : `{ object : tool }`,
rhs : `{ object : { 'dish soap', mower } }`
}
let tt003 = {
lhs : `{ object : mower }`,
rhs : `{ act : mow, object : grass }`
}
let training_set1 = [ tt000 ]
let training_set2 = [ tt001 ]
let training_set3 = [ tt002 ]
let training_set4 = [ tt003 ]
let vm = new __ENGRIPPA__( training_set1, training_set2, training_set3, training_set4 )
let tt_unk = `{ act : tidy, object : grass }`
let result00 = vm.__exec( [ tt_unk ] )
console.log( result00[0] ) // `{ act : mow, object : grass, tool : mower }` //
To upgrade
let tt000 = {
lhs : `[{ freq : 0x46, amp : 0x6, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'Hello' }`
}
let tt001 = {
lhs : `[{ freq : 0x55, amp : 0x7, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'Hello' }`
}
let training_set1 = [ tt000 ]
let training_set2 = [ tt001 ]
let vm = new __ENGRIPPA__( training_set1 )
vm.__extend( training_set2 )
To patch
let tt000 = {
lhs : `[{ freq : 0x46, amp : 0x6, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'Hello' }`
}
let tt001 = {
lhs : `[{ freq : 0x55, amp : 0x7, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'World' }`
}
let training_set1 = [ tt000 ]
let training_set2 = [ tt001 ]
let vm = new __ENGRIPPA__( training_set1 )
vm.__patch( training_set2,training_set1 )
To view a library
let tt000 = {
lhs : `[{ freq : 0x46, amp : 0x6, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'Hello' }`
}
let tt001 = {
lhs : `[{ freq : 0x55, amp : 0x7, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'Hello' }`
}
let training_set1 = [ tt000, tt001 ]
let vm = new __ENGRIPPA__( training_set1 )
console.log( vm.__includes() ) // [ `{ module : 'training_set1' }, { module : 'training_set2' }` ] //
A string template example
let MSG = 'Hello'
let tt000 = {
lhs : `[{ freq : 0x46, amp : 0x6, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : ${MSG} }`
}
let tt001 = {
lhs : `[{ freq : 0x55, amp : 0x7, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : ${MSG} }`
}
let training_set1 = [ tt000, tt001 ]
let vm = new __ENGRIPPA__( training_set1 )
console.log( vm.__exec([tt000]) ) // [{ msg : 'Hello' }] //
To examine a runtime
let tt000 = {
lhs : `[{ freq : 0x46, amp : 0x6, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'Hello' }`
}
let tt001 = {
lhs : `[{ freq : 0x55, amp : 0x7, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'Hello' }`
}
let training_set1 = [ tt000, tt001 ]
let vm = new __ENGRIPPA__( training_set1 )
console.log( vm.__decompile() ) // [`let __0x0000 = { token : { freq : [ 0x46, 0x55 ] } }, let __0x0001 = { token : { amp : [ 0x6, 0x7 ] } }`, ... ] //
To unload a library
let tt000 = {
lhs : `[{ freq : 0x46, amp : 0x6, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'Hello' }`
}
let tt001 = {
lhs : `[{ freq : 0x55, amp : 0x7, time_slice : 0x0 }, ... ]`,
rhs : `{ msg : 'Hello' }`
}
let training_set1 = [ tt000, tt001 ]
let vm = new __ENGRIPPA__( training_set1 )
let f = vm.__serialize()
console.log( f ) // [{ '__decompile' : `let __0x0000 = { token : { freq : [ 0x46, 0x55 ] } }, let __0x0001 = { token : { amp : [ 0x6, 0x7 ] } }`, ... ] //
To load a library
let f = [{ '__decompile' : `let __0x0000 = { token : { freq : [ 0x46, 0x55 ] } }, let __0x0001 = { token : { amp : [ 0x6, 0x7 ] } }`, ... ]
let vm = new __ENGRIPPA__()
vm.__deserialize(f)
console.log( vm.__decompile() ) // [`let __0x0000 = { token : { freq : [ 0x46, 0x55 ] } }, let __0x0001 = { token : { amp : [ 0x6, 0x7 ] } }`, ... ] //