CSCE 222 Lecture 14

From Notes
Jump to navigation Jump to search

« previous | Friday, February 25, 2011 | next »


MORE RUBY ACTION!!!

class Integer
  def factorial
    (1..self).inject(:*)
  end
end

... running anything in time is a BAD idea!!!


Relations

Let and be sets.

Binary Relations

R(from A to B) is a subset

is a relation on iff

Infix notation: means

Example

Less-than Relation:

Applied on set of integers :

Properties

reflexive (diagonal relation)
is not reflexive. To make reflexive, take union with reflexive sets (union called reflexive closure):
symmetric
reflexive relations are also symmetric, since and are symmetric.
transitive
Absolute value is transitive: If and , then and , so and
equivalent
Relation is reflexive, symmetric, and transitive