Page 80 - DCAP310_INTRODUCTION_TO_ARTIFICIAL_INTELLIGENCE_AND_EXPERT_SYSTEMS
P. 80
Introduction to Artificial Intelligence & Expert Systems
Notes 3 < 1 || (1 < 2 && 2 < 3)
which is false || (true && true) i.e. true.
With respect to the same assignment for <, but 3, 2, 1 for x, y, z, the value would be that of
3 < 2 || (2 < 1 && 1 < 3) which would be false. As long as we have assigned meanings to all
variables and predicates in the expression, we can derive a false or true value. Now, we give an
example where function symbols, as well as predicate symbols, are present.
((u + v) < y) || ((y < (v + w)) && v < x) ^ ^ function symbols would be an example of an
expression with both function and predicate symbols. If we assign + and < their usual meanings
and u, v, w, x, y the values 1, 2, 3, 4, 5 respectively, this would evaluate to the value of ((1 + 2)
< 4) || ((4 < (2 + 3)) && 2 < 4) which is, of course, true. It is common to be concerned with a fixed
interpretation (of domains, predicates, and functions) and allow the assignment to vary over
individuals in a domain. If a formula evaluates to true for all assignments, it is called valid with
respect to the interpretation.
If a formula is valid with respect to every interpretation, it is called valid. A special case of
validity is where sub-expressions are substituted for proposition symbols in a tautology. These
are also called tautologies.
The traditional conditional construct in Lisp is cond. However, if is much simpler and is
directly comparable to conditional constructs in other programming languages, so it is considered
to be primitive in Common Lisp and is described first. Common Lisp also provides the dispatching
constructs case and typecase, which are often more convenient than cond.
Special Form
if test then [else]
The if special form corresponds to the if-then-else construct found in most algebraic
programming languages. First the form test is evaluated. If the result is not nil, then the form
then is selected; otherwise the form else is selected. Whichever form is selected is then evaluated,
and if returns whatever is returned by evaluation of the selected form.
(if test then else) == (cond (test then) (t else))
but if is considered more readable in some situations.
The else form may be omitted, in which case if the value of test is nil then nothing is done and
the value of the if form is nil. If the value of the if form is important in this situation, then the
and construct may be stylistically preferable, depending on the context. If the value is not
important, but only the effect, then the when construct may be stylistically preferable.
Self Assessment
State whether the following statements are true or false:
4. Predicate logic builds heavily upon the ideas of proposition logic to provide a more
powerful system for expression and reasoning.
5. Predicate logic does not deal with the combination of predicates using the propositional
operators.
6. The traditional conditional construct in Lisp is cond.
5.3 Input, Output and Local Variables
Variables in programming languages are simply containers which hold values. Access to
variables and the contents of them is through their name, also know as their identifiers.
74 LOVELY PROFESSIONAL UNIVERSITY