简体   繁体   中英

Evaluating Logical predicates in Java

I'm developing a Java application that manages a very large model of entities and their relationships. Such as "A uses B", "B is implemented in C", "C is located at D". All these entities and their properties are stored in a noSQL database.

What I would like to do is have logical predicates such as:

  • B is used by A when A uses B
  • A is dependant on C when A uses B and B is implemented in C

Then when a user opens the detail screen for A, he not only sees all A's properties but also sees:

  • A uses B
  • A is dependant on C
  • A calls D

I can hardcode all those predicates, but I would like to be able to configure it. Does anyone have any idea how to approach that?

I can't use SQL. I don't have something like Prolog to invoke. There is a prolog emulator for Java, but I'm afraid it wants to load the entire datamodel in memory first, before evaluating predicates.

Any help is appreciated.

There are several Java implementations of Prolog (eg Lean Prolog, JIProlog, tuProlog, Jekejeke Prolog, Minerva, ...). Some provide a bi-directional interface between Prolog and Java. At least one of them, JIProlog, supports external Prolog databases of clauses, apparently allowing using those clauses without loading all of them into memory. If exporting the data from your noSQL database to a Prolog file is a feasible option, this might be a solution worth exploring.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM