Skip to content

Complex queries in sparql-like style #72

@CICS-Oleg

Description

@CICS-Oleg

Suppose we have the following sparql query:

CONSTRUCT{?e1 :not ?e2}
	WHERE{?e1 rdf:type ?c. ?e2 rdf:type ?c. ?c rdf:type :Eventuality. FILTER(?e1!=?e2)
	?trn rdf:type :ThematicRole. ?e1 ?trn ?vn. ?r rdf:type :false,:hold; rdf:subject ?e2; rdf:predicate ?trn; rdf:object ?vn.
	 NOT EXISTS{?tr rdf:type :ThematicRole. FILTER(?tr!=?trn) ?e1 ?tr ?tv1. NOT EXISTS{?e2 ?tr ?tv2}}
	 NOT EXISTS{?tr rdf:type :ThematicRole. FILTER(?tr!=?trn) ?e2 ?tr ?tv2. NOT EXISTS{?e1 ?tr ?tv1}}
	 NOT EXISTS{?tr rdf:type :ThematicRole. FILTER(?tr!=?trn) ?e1 ?tr ?tv1. ?e2 ?tr ?tv2. FILTER(?tv1!=?tv2)}}

Below a simplified analog in metta:

!(match &self (, ($e1 type Eventuality) ($e2 type Eventuality))
          (if (not (== $e1 $e2))
              (match &self (, ($e1 $trn $vn) ($e2 $trn $vn))
                (if (not (unify &self ($trn $trn) True Fasle))
                    (match &self (, ($e1 $trn $vn) ($r type false) 
                        ($r subject $e2) ($r predicate $trn) ($r object $vn)
                        (not (unify &self ($e1 $trn $tv1) True Fasle )))
                        (if (not (unify &self ($e1 $trn $tv1) TrueFasle ))
                            (match &self ($e2 $trn $tv2) 
                                (if (not (unify &self ($tv1 $tv2) True Fasle ))
                                    (add-atom &self ($e1 NOT $e2))))))
                    Empty)))))

Is there some way of simplifying the metta analog in the more or less sparlq style? I mean to avoid those nested if's and nice function for not_exist like this one:

(= (not_exist $pattern)
    (unify &self $pattern Fasle True))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions