Title: Variables and Instantiation
1Variables and Instantiation
- Either a variable or a constant may be used to
express a predicate - Gt_zero(x) \/ EQ_zero(x) x is a
variable - Carnivorous(y) -gt eats(y, meat) y is a
variable meat is a constant - Instantiation
- Let an expression, E, contain a variable, y.
Then substituting a specific term ( or constant),
t, for the variable y in E will create a new
Expression E. E is the instantiation of E and t
is an instant of y - Manager(x,y) substitute Bob for x and Sam for
y, we get Manager(Bob, Sam) to create a specific
instance of this predicate which states Bob is
the manager of Sam. - Eats(Tom, w) substitute apple for w and we get
Tom eats apple. - tested(z) -gt runs(z) substitute MS-Word for z,
we get the statement tested MS-Word implies that
MS-Word runs.
2Quantifiers
- With the concept of instantiation,
------quantification becomes easier to discuss - Consider the statements
- All computers have cpus
- Some computers are defective
- Every program is tested at Microsoft
- At least one student remembers Pascal
- Note that these statements indicate how many of
the specific items in the universe of discourse
are True. This notion of instances of truth is
captured by Quantifiers - Some
- Every
- All
- At least one
3Fuzzy Logic Temporal Logic
- Fuzzy Logic the notion of quantification (all,
some, etc.) is different from the notion of
degree of truth which asserts the probability
of truth, P(x is True). But the truth may be
measured in other than the binary T/F. - Joe is sick a lot can be looked upon as a
predicate, sick(Joe), which has a probability of
70 truth. - Temporal Logic quantifiers here are also
different from another kind of quantification
that addresses how often P(x) is True - It is sometimes the case that Joe is sick can
be looked upon as a predicate, sick(Joe), that is
True at some instance of time and False at other
instance of time. - We will not pursue Fuzzy logic or Temporal logic
in this course even though they have applications
to many real world problems.
4Notion of Quantification
- Quantification A mechanism to express the whole
universe of discourse or a part of the universe
of discourse - Existential Quantifier part of
- often expressed with
- Universal Quantifier whole
- often expressed with
5Existential Quantifier
- The Existential Quantifier, , asserts that at
least one object in a collection of objects (or
the universe of discourse) has the stated
property or relationship. - The general Existential Quantifier expression
- identifier class list predicate
- e.g. z N zgt 1000
where - z is the identifier
or variable - N is the class list
or universe of discourse - z gt 1000 is the
predicate - e.g. some programs are written in
JAVA - p programs
prog_lang(p, Java)
We often short hand the expression and do not
include the class list or the
6Universal Quantifier
- The Universal Quantifier, , asserts that all
objects in a collection of items or in the
universe of discourse have the stated property or
relationship. - The general Universal Quantifier expression
- identifier class list predicate
- e.g. X integers x2 gt 0 \/ x2 0
- (square of integers are greater
than or equal to zero) -
- p programs run(p) \/
run(p) - ( every program either runs or
does not run) -
We often short hand the expression and do not
include the class list or the
7Bound and Free Variables
- In either Existential or Universal
quantification, the variable in the statement and
the variable associated with the quantifier is
treated as a unit. - (z) S(z,y) - the variable z is
treated as a unit with the statement S. - the variable, z, is considered bounded and the
statement S is considered as the scope of the
quantifier while the variable, y, is considered
as free
This notion of a variable that is bound by the
quantifier within the scope of the statement is
similar to variables bound within the scope of a
program routine or subroutine.
8Quantifiers are Unary Operators
- Quantifiers must be treated just as the unary
operator, just like the operator. - Consider S1(x) to be x is alive, and s2(x) to
be x is dead. then - (x) S1(x) \/ S2(x) says everyone
is alive or x is dead - (x) ( S1(x) \/ S2(x) ) says everyone is
alive or dead - Note that in the first case, x in S1(x) is bound
and S1 is the scope of the quantifier. The x in
S2(x) is a free variable. One may view the x in
S2(x) as a different variable from the x in
S1(x). You may want to add parenthesis for
clarity. - In the second case the x in both S1 and S2 are
bound by the quantifier and S1 and S2 jointly
form the scope.
9Collision in Bound/Free Scoping
- Consider x M(x,y)
- x is a bound variable and local to the predicate
M. y on the other hand is a free variable and
different from x. - We can replace the variable x with z and have
essentially the same statement, z M(z,y). - Can we replace x with y and have y M(y,y) ?
- This may cause a PROBLEM.
- The previously free variable y becomes bound and
the two previously different variable becomes the
same. - Consider the predicate M to mean mother-Of
- x M(x,y) says y has a mother
- y M(y,y) says y is ys own mother
10Phrasing Universal Quantifier
- Consider the statement
- All Apple hardware are computers.
- How would you phrase this using predicate
calculus ? -
11Phrasing Universal Quantifier
- Phrasing All Apple hardware are computers as
follows - If x is an Apple hardware, then it is a
computer. - (x) (apple_hardware(x) -gt computer(x) )
- Note we used for all quantifier to capture
the all Apple hardware concept.
12Phrasing Existential Quantifier
- Consider the statement
- Some Apple hardware are computers.
- How would you phrase this in predicate calculus?
-
13Phrasing Existential Quantifier
- Phrasing Some Apple hardware are computers as
follows - There exists an Apple hardware which is a
computer. - There exists an Apple hardware and that hardware
is a computer - (x) (apple_hardware(x) /\ computer(x) )
- Can this use an implies operator?
14Phrasing with Quantifiers
- How may one phrase the following?
- Only MS programs crash.
- (x) ( MS_program(x) -gt crash (x) )
-
- OR is the following better?
- (x) ( crash(x) -gt MS_program(x) )
15Composite or Nesting of Quantifiers
- Consider the statement
- every program calls another program.
- How can we express this ?
- Program x calls program y Calls (x, y)
- There exists a program called by x y
Calls(x,y) - Every program calls another program x y
Calls(x,y)
How would you state the following all programs
are recursive Or all programs call itself ?