Prakash VL - 21 days ago 4x

Java Question

i have gone through PREDICATE and LAMBDA expression in java but i didn't understand how to link DM Predicate logic with this one for forming simple AI java Application?

Answer

In Discrete Mathematics predicate logic we can create functions which can process natural language by making it as a simple regular expression. I'm asking how to write same functions using java lambda and predicate.

Example - ''All of Jane's friends are generous'' = > Regular Expression is "For any X: IF friend(X,jane) THEN generous(X)".

''Jane has at least one friend who is generous'' => "For some X: friend(X,jane) AND generous(X)"

I'm asking how to implement these concept in JAVA?

First of all these are not "regular expressions". A regular expression is something very different:

Now it is possible to express a predicate in the form of a Java function that evaluates to `true`

or `false`

. And those functions could be coded using Java lambdas.

However what you have here in your examples are effectively rules rather than simple predicates. To implement rules and rule-based deduction (which I guess is your end goal) you actually need some kind of logic engine. Such a thing could be implemented in Java, but if you use a language like Prolog, it all comes for free.

If you are looking for rules engines implemented in / for Java, you could start with the open source engines listed here:

Source (Stackoverflow)

Comments