(set *semantic-net* (vector 1000)) (define query [is Object Concept] -> (if (belongs? Object Concept) yes no)) (define belongs? Object Concept -> (element? Concept (fix (fn spread-activation) [Object]))) (define spread-activation [ ] -> [ ] [Vertex | Vertices] -> (union (accessible-from Vertex) (spread-activation Vertices))) (define accessible-from Vertex -> [Vertex | (union (is_links Vertex) (type_links Vertex))]) (define is_links Vertex -> (trap-error (get Vertex is_a (value *semantic-net*)) (/. E []))) (define type_links Vertex -> (trap-error (get Vertex type_of (value *semantic-net*)) (/. E []))) (define assert [Object is_a Type] -> (put Object is_a (adjoin Type (is_links Object)) (value *semantic-net*)) [Type1 type_of Type2] -> (put Type1 type_of (adjoin Type2 (type_links Type1)) (value *semantic-net*)))