Back to Running
Metalog - Next to The
Metalog Language
Ok, you are now running Metalog.... and so what?
Let's start with a simple example, so to have an idea of how things work. Use the "File" menu, and then click on the "Open" option. This will open a panel, so to select a file to open. The Metalog distribution comes complete with a set of samples, so let's select the "examples" directory. Once there, select the "simple.ml" example. This will load the file into the Metalog editor, which is the main window below the menu. As you can see, the text looks like
comment: one of the simplest Metalog sessions.comment: we start defining what things are.
JOHN represents the person "John_Smith" from the company "http://www.example.com/staff".
IS represents the verb "is" from the collection "http://www.relationships.example.org/verbs".comment: now we say something.
JOHN IS "tall like a tower".comment: and now we ask something.
do you know whether JOHN IS SOMETHING?
What this Metalog file means should be obvious by just reading it, but let us see better.
The red lines are comments, and as you might guess, these parts are superfluous for Metalog, they are just there for better description.
Then, we have the green lines, the so-called "representation" parts. Representations are useful to denote shorthands: in these lines, we associate some entity (like JOHN) to its corresponding representation (the person "John_Smith" from the company "http://www.example.com/staff".). This means in a certain sense that, anywhere in the Metalog file, writing the whole the person "John_Smith" from the company "http://www.example.com/staff".is pretty much equivalent than writing its representation (the shorter JOHN).
After that, we find the blu lines, which can be either "assertions"
or "queries". An assertion is a line where we state something. For instance,
the first blu line in the Metalog file (JOHN IS "tall
like a tower".) states precisely what it says. A query, instead, is
a sentence where we are asking Metalog for answers. In fact, the second blu
line is a query (do you know whether JOHN IS
SOMETHING?). Queries can be easily distinguished because they end
with a question mark ("?"). All the other sentences,
instead, must end with a dot ("."), as you can see from this file.
So, somebody already wrote a query for us, and it is time to get the answers from Metalog: go to the "Reason" menu, and select the "Think!" option.
If all goes well, a new window should open, containing the answer to our query, and it should contain the following:
comment:-----------------------------------------------.
comment: query 1 (of 1).
comment: query: "do you know whether JOHN IS SOMETHING ?".
comment: Metalog result 1 (of 1).JOHN represents "John_Smith" from "http://www.example.com/staff".
IS represents "is" from "http://www.relationships.example.org/verbs".JOHN IS "tall like a tower".
This is a Metalog file exactly like the "simple.ml" file that we had opened. Its comment part reminds us what was the query that we were asking, and tells us that what follows is the first result (there might be more). Next, the representation part gives us some associations that are needed in the last line, the assertion where the answer is given: JOHN IS "tall like a tower".
Congratulations, you have just successfully got your first answer from Metalog!
Now, let us go back to the main Metalog windows (you can keep the window with the answer floating around, as it will not harm, or you can close it, at your choice). The main windows does not only display the current Metalog file that is in use, but also serves as an editor. So, you can directly modify the "simple.ml" file, if you want. As we feel curious, let's add at the end of the file another query, for instance
do you know WHO IS "tall like a tower"?
Not a very complex query, indeed, but we are here to practicse. So, write down that new query. Now, before you can ask Metalog the answer, you need to save the file first. In fact, note that iwhat you have written is not yet blu, but should still be black. And, also observe the title bar of the main window, that contains the location of the Metalog file that we have opened: there is an asterix ("*"), reminding us that we have modified the file, and not yet saved it.
Now we have two options, either save the file (always as "simple.ml"), or save it as another file. In the first case, go to the "File" menu and click "Save". If you prefer instead to create another file, go to the "File" menu but now select the "Save As" option: this will open a new panel, where you can select the name (and location) of a new Metalog file where to save what you have on the main window.
Either way, you have saved the file. Note how the asterix in the title part of the window went away. And also, reassuringly, the query that we had written should have now been turned into blu, signaling us that the system recognized it as a query:
do you know WHO IS "tall like a tower"?
Now, let us ask Metalog for answers again: go to the "Reason" menu, and activate the "Think!" option. Like in our previous attempt, we get a new window with the answers. This time, its content should read like:
comment:-----------------------------------------------.
comment: query 1 (of 2).
comment: query: "do you know whether JOHN IS SOMETHING ?".
comment: Metalog result 1 (of 1).JOHN represents "John_Smith" from "http://www.example.com/staff".
IS represents "is" from "http://www.relationships.example.org/verbs".JOHN IS "tall like a tower".
comment:-----------------------------------------------.
comment: query 2 (of 2).
comment: query: "do you know WHO IS "tall like a tower"?".
comment: Metalog result 1 (of 1).JOHN represents "John_Smith" from "http://www.example.com/staff".
IS represents "is" from "http://www.relationships.example.org/verbs".JOHN IS "tall like a tower".
The first part is exactly like the first previous answer that we had got from Metalog: just, the comment part now signals us that this is now the answer to the first query, but there are two (comment: query 1 (of 2).).
The second part is similar, with the comment part reminding us that this is the answer to the second query. Then, the answer follows (which, incidentally, is exactly the same as the previous answer... oh well, we knew it from the beginning, didn't we?).
Congratulations, you have just written on your own your first Metalog query, and got the answer!