Infosys Microsoft Alliance and Solutions blog

« RESTing SOAP | Main | "Oslo" Repository's Design Support for Schema and Data Versioning »

Teach the Code to Hack Itself...

And the more it hacks itself, the more secure it becomes. Compilers are hard task masters. They cut out a distinct path for the application execution and force it to run that way, come hell or high water. Letting an application change its behavior by teaching it to understand itself has been a fairly less explored subject.

One main reason being, mainstream software developers typically confine themselves to the assortment of data structures provided by their favorite language. Say, a nice C# developer sticks to Hash Tables, Dictionaries and Generic entities or a hybrid collection of all these to represent all sorts of rules, constraints or any knowledge pertaining to the domain. But such objects aren’t mature enough to represent the kind of rules which can dynamically define the behavior of the application.

Let’s talk in non-technology terms. Here’s the most famous syllogism from the college-days.

Rule 1: All men are mortal

Rule 2: Socrates is a man

Question: Tell me about Socrates.

Answer: Socrates is mortal

How do you represent this when coded in your favorite language? If a software can be intelligent enough to automatically infer the Answer based on Rules 1 and 2, that would be its first step to modify its own behavior based on the business rules.

Let’s take the Outlook example we discussed in a previous post. We need to represent a rule where the software monitors a user’s actions of moving his emails from “Barack Obama” to the outlook archive “Obamaniac”. The software finds that the user always does this move, decides that this is his pattern of behavior, and it automatically creates an Outlook rule which moves all mails from “Barack Obama” to the “Obmaniac” folder.

One very useful method of representing such rules is the First-Order Logic. Mathematically, the rule for our Outlook example could be represented as below using First Order Logic. ( ThereExists= There Exists,And=And,ForAll= For All)

FOL
This would mean, “There exists a mail x, such that, at any given time t, the mail x is being moved to folder f”. The algorithm could involve a simple counting of the number of instances of MoveToFolder(x,t,f) being invoked, and if the count becomes more than 10 within the time range defined by t, then it gets identified as a pattern and Outlook creates a new rule for moving all mails x to folder f.

Implementing first-order logic in code is never simple. Prolog is one excellent language to represent first-order logic, but is too general purpose for our interest. What could be helpful, is something which, in principle, is similar to Prolog, but is more driven by the domain.

In the next post, we’ll explore the idea of domain driven representation of logic.

Comments

"Let’s take the Outlook example we discussed in a previous post."

It will be great if a link is provided to the previous post.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Please key in the two words you see in the box to validate your identity as an authentic user and reduce spam.

Subscribe to this blog's feed

Follow us on

Blogger Profiles

Infosys on Twitter