// ex4.trp - Example 4 // // A TRIPLE example with parameterized models // @world1 { tom [plays -> tennis]. bob [plays -> baseball]. tom [marriedTo -> tina]. bob [marriedTo -> betty]. } @world2 { fred [watches -> football]. hank [plays -> hockey]. fred [marriedTo -> fran]. hank [marriedTo -> hariett]. } FORALL Mdl @sports(Mdl) { //Everything true in @Mdl is true here, too FORALL O,P,V O[P->V] <- O[P->V]@Mdl. //Assume that everyone who plays a sport also watches it FORALL O,V O[watches->V] <- O[plays->V]. //Assume that a wife watches the sport if her husband does FORALL Husband,Wife,Sport Wife[watches->Sport] <- Husband[watches->Sport] AND Husband[marriedTo -> Wife]. } //Queries (which wives watch which sports?) FORALL X,Z <- X[watches->Z]@sports(world1) AND EXISTS W ( W[marriedTo -> X]@sports(world1) ). FORALL X,Z <- X[watches->Z]@sports(world2) AND EXISTS W ( W[marriedTo -> X]@sports(world2) ). /* OUTPUT *** X = tina, Z = tennis X = betty, Z = baseball *** X = fran, Z = football X = hariett, Z = hockey */