Executable English / Internet Business Logic Tutorial, Part 2

Theo Walker    internet.business.logic@gmail.com    


        This section of the tutorial is for learning the basics of creating your own agents. In Part 1 of the tutorial, we covered logging into the Executable English / Internet Business Logic system (IBL), navigating it, and asking an agent questions. By the end of this section, you will have written a fully working agent, and you will understand most of the concepts necessary to write your own additional simple agents. Part 3 of the tutorial will cover the creation of more complex agents. At the end of Part 3 of the tutorial, you will be able to write your own practical agent programs and use them for business purposes.

Part 4 covers some advanced topics, such as automatic generation of SQL database queries.

        Let's assume that you are looking at this tutorial in your browser. As you go through the tutorial, it's best to actually run the examples. There is no need to download anything, just have a second browser window open. Then, it will be easy to keep your place in the tutorial in one window, while running the examples in the second window.

        If you do not already have a second browser window available, hold down the Ctrl button and click on N.

        In your second browser window, go to www.executable-english.com/ibl_login.html

        The password "author" is the one we'll be using, since we need to create agents. It is already filled in, so click "GO".

You will be at the start page, which looks like this (except for the colored background).



Select "Tutorial" from the list, and select "Choose an Agent and Go to View or Change it..." from the menu at the top. The agent will appear like this:


        Refer back to the above copy of the agent that is inside of this tutorial when you need to. We will be recreating this agent, line by line, explaining each step. By the end of this tutorial, we will have an agent very much like the one you see above this text. For this, we will need to make a new agent.


        Choose "Go to the Start Page" from the menu at the top. Now, type in a name for an agent in the box at the bottom of the screen - any name will work well; you may use your own name if you choose to. (In this tutorial, the agent will be called simply "Smith".) Then select "Choose an Agent and Go to View or Change it...".


        This will bring you to the Agent page, which contains three boxes of text, as shown below.

The first box of text contains a note and is recognizable because it starts with a vertical bar "|" (made by holding Shift and typing a backslash "\".) Notes have no effect on the way the agent runs; they hold information that can only be seen when an author looks at the agent.

The second box of text contains a table. A table starts with a stylized line of English, followed by a double underline (typed as equals signs "="), usually followed by some columns of data. A table holds information which can be accessed by the agent and interpreted using rules. (A table can also be fetched over the internet, as needed, from a database such as MS Access or Oracle, but we will get to that in part 4 of the tutorial.)

The third box contains a rule. A rule consists of one or more lines of stylized English, followed by an underline (made by typing minus signs "-") followed by at least one line of English. Rules are used to make conclusions based on data from tables and on other rules.


        To begin working on your own agent, begin by deleting the all of the examples in the new agent, so that you have three blank boxes to work in. To delete the contents of a box of text, just left-click once inside the box and use the backspace and delete keys until the box is empty. Now, click on the first box, and type in a vertical bar "|" to begin a note. This note will serve as a heading to anyone who looks at the agent - a good heading would be "|My Internet Business Logic Tutorial Agent", or something along those lines.

        All we've done so far is enter a note. As we enter tables and rules, corresponding questions will appear on the Question Menu page. If you went to the Question Menu page right now, you wouldn't see any questions there. Let's put in a table before we check the Question Menu.

        A table starts with some stylized-English such as "this-person likes this-color". Below this is a row of equals signs. After the equals signs comes the data for the table. The data consists of instances of "this-person" and "this-color". Effectively, a table is shorthand for a series of sentences such as "Francesco likes red". So, to tell the agent that "Francesco likes red", we would first write the general line "this-person likes this-color", followed by a row of equals signs. "Francesco" goes under "this-person" and "Red" goes under "this-color". The agent now has the information that "Francesco likes Red" in it.

        So, since the agent knows that Francesco likes Red, we can ask the agent that question by going to the Question Menu. Do this on your own if you like; the agent will tell you that Francesco does indeed like Red. Putting in simple data like this and getting it out is a basic function that does not make much use of the IBL service. Rules make an agent much more useful. Before we get into writing rules, we will add more data in the form of another table; this way, we will be able to do more interesting tasks using the rules.

        Add another data table in the third box. (If you went to the Question Menu and then came back to the Agent page, the blank box has gone! Not to worry, just position the cursor at the bottom of the second box. Press the Enter key to get a blank line, then type some text. Select "View of Change the Agent". You would get a page with a third box.) The heading of the table should be "this-person likes to eat this-snack at this-time", followed by the line of equals signs. There are three 'this' place holders, so there will be three columns of data in the table. Tell the agent that Francesco likes to eat popcorn at 11:14 by putting "Francesco" under "this-person", "popcorn" under "this-snack", and "11:14" under "this-time". Your table should look something like the one in this screenshot:

        The agent now knows two things about Francesco. It knows that he likes Red, and that he likes to eat popcorn at 11:14. From these two facts, we can have the IBL draw a simple conclusion using a rule. A rule starts with one or more statements, followed by a line of minus signs "-". Below the line is a conclusion statement. We can make the IBL conclude that, if a person likes a color and a snack, they must like a "that-color" snack. For example, since Francesco likes Red and likes to eat popcorn, he must like Red popcorn. To make the IBL conclude this, we will write a rule.

         However, it would appear that we are out of room; we started with three boxes of text, and they are all full. We can still write the rule easily enough - all you need to do is go into an existing box of text (we used the third one), make a blank line below the table, and write the rule after the blank line. The IBL will automatically make a new box of text and insert the rule in it the next time you see the Agent page.

        When you write the rule, the first statement should be "some-person likes some-color". On the next line goes the statement "that-person likes to eat some-snack". Below that is a line of minus signs, and then the conclusion statement "that-person would like to eat that-color that-snack".

        You will notice that, while these tables use "this-" (example: this-person likes this-color) to point out their place holders, the rule uses "some-" and "that-" for the place holders in it. It is important to type these correctly. (For example, the IBL will not understand "some person" as a place holder -- it must be typed as "some-person".) However, if you make a mistake while writing an agent, the Check page can usually find it for you. Let's go to the Check page now to have the IBL check this agent. Choose "Go to the Check Page" from the menu at the top of the screen, and this screen should come up:


        It found an error in the agent: we never told the agent that some-person (Francesco) liked to eat some-snack (popcorn). We told the agent that Francesco likes to eat popcorn at 11:14. The agent won't assume that part of an expression is true just because the entire expression is true. This is important. If you tell your agent that Company X needs a new supply of ingots next January, you don't want your agent to tell you that Company X wants a new ingot supply now. In this case, however, we can assume that time is irrelevant - if you like a popcorn at 11:14, we'll have the agent assume that you like popcorn in general. In fact, we need to do this to have the rule work properly. "Go to View or Change the Agent" using the menu at the top, and we can fix the agent.
        We want to add a rule saying that if some person likes to eat some snack at some time, then that person likes to eat that snack. See if you can write this rule on your own (Hint: the rule will be very similar to the end of the last sentence!) The correctly written rule is in the screenshot below. Recall that, to write a rule or table when you're out of empty boxes, just leave a blank line in an existing box and write it under the blank line.

        We now have a fully working agent. If you wish, you can visit the Check page to verify that the IBL cannot find anything wrong. For now, let's ask it some questions. Select "Go to the Question Menu" using the menu at the top, and a page containing this should show up:

        If your page is missing some questions, check your agent against the one in the screenshot before this one. If not, proceed to ask it a question. An interesting thing to ask it about would be "some-person would like to eat some-color some-snack". Click on that question. Usually, when you ask a question, you would click on the blue text in the window that pops up and get a choices menu, like we did in the last tutorial. To get the agent to list all the possible answers to an unrestricted question, all you have to do is click "Ask" in the popup window. Click Ask; since there wasn't very much data in the tables of your agent, there will only be one answer:

        How did the agent you wrote arrive at this conclusion? To find out, go to the Explanation Page by selecting "Get an Explanation" from the menu at the top.

        The first part of the explanation will tell you the final step - what happened just before the agent concluded "Francesco would like to eat Red popcorn"? You may recognize this as one of the rules in the agent - some-person likes some-color, and that-person likes to eat some-snack; therefore, that-person would like to eat that-color that-snack. The line "Francesco likes to eat popcorn" is a link to the second part of the explanation. How did the IBL agent conclude that Francesco likes to eat popcorn? It used the rule we just wrote: some-person likes to eat some-snack at some-time; therefore, that-person likes to eat that-snack. The other facts needed, such as "Francesco likes Red" were taken directly from the tables.

So, the agent used its tables and rules to determine that Francesco would like to eat Red popcorn .

Thus far, we have only written facts about Francesco into the tables. Next, you may like to continue and put in the facts about Alberto, Naomi and Frederick that are listed in the reference copy of the Tutorial agent.

Once those facts are in, you could tell the agent how to find out if two people like the same snack. You could try this rule.

However the rule will produce the answer that Alberto likes the same snack as Alberto. What we want is to find two different people who like the same snack. While we are about it, if we can get the answer "Frederick likes to eat the same snack as Naomi", we really do not also want to see the answer "Naomi likes to eat the same snack as Frederick".

You can do this by refining the above rule, like this.

Then, you can put in a rule like this about ordering names alphabetically.

Now, if you go to the question menu, and ask who likes to eat the same snack, you should see the answer

You may have noticed that there is no rule in the agent that concludes with the sentence "some-name1 is less than some-name2". That sentence is predefined for you. In Part 3 of the tutorial we will look at other predefined sentences and how to use them.

You have now completed Part 2 of the IBL tutorial; you know the basics of how to make your own agents. While you may not be comfortable making one on your own yet, you can always use this tutorial as a reference guide, as well as the help available for every page of the IBL. There is a "Help" button at the top of each IBL page that will open a new window with a relevant help. 

In Part 1 of the tutorial, we saw how to run an agent that had already been written. In this part of the tutorial, you have seen how to write and run a simple agent. In Part 3 we will see step by step how to write and run a business case agent -- one that accepts estimates from various departments of an organization, and that produces various forecasts of revenue. In writing the business case agent, we will see how to use some more advanced features of the IBL.

If you wish to stop for now, choose "Go to the Start Page" from the menu at the top. From there, choose "End This Internet Business Logic Session." Otherwise, please proceed to Part 3 of the tutorial.