// ex7.trp - Example 7 // // A TRIPLE example using RDF // // Run with the -rdfdata command line argument: // // triple.sh -rdfdata Example6.rdf http://local.example.com/localNameSpace# localModelName ex7.trp lns := "http://local.example.com/localNameSpace#". rdf := "http://www.w3.org/1999/02/22-rdf-syntax-ns#". ex6 := "http://argos.isi.edu/example6#". @newModel { // The new model contains just the computers from the loaded data FORALL O,P,V O[P->V] <- O[P->V]@lns:localModelName AND O[rdf:type -> ex6:Computer]@lns:localModelName. // Add a predicate about whether the computer has enough memory // (512 or 1024 Megabytes) FORALL O,X O[enoughMemory -> plenty] <- EXISTS P,V O[P->V] AND ( ( (O[ex6:Memory -> X]@lns:localModelName) AND (X[ex6:Megabytes -> '1024']@lns:localModelName) ) OR ( (O[ex6:Memory -> X]@lns:localModelName) AND (X[ex6:Megabytes -> '512']@lns:localModelName) ) ). FORALL O,X O[enoughMemory -> notEnough] <- EXISTS P,V O[P->V] AND ( (O[ex6:Memory -> X]@lns:localModelName) AND (X[ex6:Megabytes -> '256']@lns:localModelName) ) . } // Show the computers that have the enoughMemory predicate FORALL X,Z <- X[enoughMemory -> Z]@newModel. FORALL X,Y,Z <- X[Y -> Z] AND X[enoughMemory -> Z]. /* OUTPUT *** X = 'http://argos.isi.edu/example6#':'An_Old_Computer', Z = notEnough X = 'http://argos.isi.edu/example6#':'My_Home_Computer', Z = plenty X = 'http://argos.isi.edu/example6#':'Newer_Computer', Z = plenty *** X = 'http://argos.isi.edu/example6#':'An_Old_Computer', Y = enoughMemory, Z = notEnough X = 'http://argos.isi.edu/example6#':'My_Home_Computer', Y = enoughMemory, Z = plenty X = 'http://argos.isi.edu/example6#':'Newer_Computer', Y = enoughMemory, Z = plenty */