
Can i get an explanation for the for each loop, because it doesn’t make much sense to me. Particularly, what do STANDARDIZE-APART() and the second last line do?
which is FOL_BC_ASK(KB,[p1...,pn|REST(goals)],COMPOSE(@',@)) U ans
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
r is an FOL sentence in the knowledge base.
Among other things, an FOL sentence may contain quantifiers and variables.
For any FOL sentence, there is a simplified form of it, in a variety of forms like CNF (Conjunctive Normal Form) (Horn clauses are similar), which this algorithm operates on. A CNF-style simplification is restricted to a specific, limited set of operators and generally results in an expanded statement compared to the original (sometimes substantially longer). CNF does not use quantifiers, though variables are allowed.
Quantifiers are the operators “for-all” (universal), and “there-exists” (existential). Each quantifier takes a variable (or list of variables) and a single (sub) statement over which the variables introduced (in the list) are quantified. These variables are said to be bound, though just for the scope of the one sub statement (in the quantified expression). Thus, a quantifier implicitly introduces a new scope (for its variables).
CNF does not allow for explicitly expressed quantifiers nor does it provide for multiple or separate scopes for variables! So not only do the quantifiers have to be eliminated, but the scopes for the variables must be eliminated as well (or collapsed to a single scope). (The scopes are pretty easy to eliminate and so this is done first.)
When a single statement contains multiple quantifiers, it is perfectly acceptable in FOL for the same variable name to be reused in a quantifier having disjoint scope. Thus, the following single (though compound) statement is an acceptable one in FOL :
which says there is some x who is the father of Joe, and there is some x (a different x) who is the mother of Joe.
In the above statement, the variable x is introduced twice, though the two distinct uses of it are actually unrelated! However, because x is used twice, when we read and interpret or manipulate and transform this statement, we must remain aware of the two separate scopes (or else our transformations will sometimes fail to be equivalent). This is true in general of any FOL statement, meaning that we need to be aware of scoping for the purposes of interpretation and manipulation of a general FOL statement.
The following statement is equivalent from a logical perspective, but does not use x twice:
If we guarantee our (transformed) statements do not have overlapping variables (i.e. there are no two uses of the same variable name in disjoint scopes), we no longer need to consider the two separate scopes introduced by the two uses of quantification. We can effectively consider that there is only one single scope for the variables of such statements. This is the essence of the apart’ness of STANDARDIZE-APART, by ensuring variables across scopes don’t overlap (by giving them each unique names), we no longer need to consider multiple scopes separately within a single statement (that may have had multiple quantifiers).
(You’d do the same thing in Java if you merged two procedures or methods or statement blocks together into one: you’d want to make sure that the chosen variable names are unique between them so they don’t conflict.)
STANDARIZE-APART is doing conversion to CNF, which requires collapsing of multiple scopes into one, and, elimination of quantifiers (as well as replacement of certain operators like implication and equivalence with counterparts in terms of “and”, “or”, and “not”).
Existential quantifiers are eliminated in favor of skolem functions as follows: in Second (and Higher) Order Logic we can quantify over functions (e.g. there-exists(f) such that f() …), however, in First Order Logic, we cannot quantify over functions. Yet though we cannot quantify over functions in FOL, we can still use functions. In FOL, functions are simply assumed to exist. (CNF and horn-clause forms also honor the assumed existence of functions.) Skolemization is a replacement of existential quantification in which the existentially quantified variable (wherever it appears in the sub statement) is substituted with a newly made up and appropriately parametrized function (a new function is made up for each such existential quantifier replacement, and the supplied parameters have to do with context of other enclosing quantifiers). This newly introduced function is simply assumed to exist without needing an existential quantifier. Having eliminated the uses of the existentially quantified variable (in favor of the new function), we can now omit the existential quantification operator itself and just keep the modified sub statement.
Universal quantifiers are promoted to the outermost (scope) of the statement and can simply be eliminated (1) because scopes have been collapsed, and (2) because there are no longer any existential quantifiers (as those have already been eliminated by skolemization) and (3) since in various CNF/horn forms all variables are simply assumed to have universal quantification.
Unification is a composition technique in which we consider what we know if we combine two (otherwise separate) pieces of information about the same relationship, R. The pieces of information take the form of the variable and constant parameters to the relationship. Unlike standardization, unification doesn’t always succeed, which is to say that, it doesn’t always reveal more information.
The last line is a recursive invocation of backward chaining for the next level of the back chaining search, in which the one goal (e.g. a CNF statement) that has been addressed is substituted with the resulting sub goals. By addressed I mean unification succeeds, and unification succeeding means that we have at least nominally advanced the state of our search engine, and this advancement merits further search exploration (another level).