220 likes | 337 Vues
Logics for Data and Knowledge Representation. Introduction to Algebra. Chiara Ghidini, Luciano Serafini, Fausto Giunchiglia and Vincenzo Maltese. Roadmap. Set theory Basic notions Operations Properties Relations Functions. Describing the world. individuals. Cita. Monkey. sets.
E N D
Logics for Data and KnowledgeRepresentation Introduction to Algebra Chiara Ghidini, Luciano Serafini, Fausto Giunchiglia and Vincenzo Maltese
Roadmap • Set theory • Basic notions • Operations • Properties • Relations • Functions
Describing the world individuals Cita Monkey sets relations Eats Hunts Kimba Simba Lion Near 3
Sets SETS :: RELATIONS :: FUNCTIONS • A set is a collection of elements • The description of a set must be unambiguous and unique: it must be possible to decide whether an element belongs to the set or not. 3 1 5 7 9 The set of odd numbers < 10 The set of students in this room The set of lions in a certain zoo
Describing sets SETS :: RELATIONS :: FUNCTIONS A = {1, 3, 5, 7, 9} A = { x | x is an odd number < 10} A • Listing: the set is described by listing all its elements • Abstraction: the set is described through a common property of its elements • Venn Diagrams: graphical representation that supports the formal description 3 1 5 7 9
Basic notions on sets SETS :: RELATIONS :: FUNCTIONS • Empty Set: the set with no elements; A = { } A = • Membership: element a belongs to the set A; A = {a, b, c} a A • Non membership: element a doesn't belong to the set A A = {b, c} a A • Equality: the sets A and B contain the same elements; A = {b, c}; B = {b, c} A = B
Basic notions on sets (cont.) SETS :: RELATIONS :: FUNCTIONS • Inequality: the sets A and B contain the same elements; A = {c}; B = {b, c} A ≠ B • Subset: all elements of A belong to B; A = {c}; B = {b, c} A B • Proper subset: all elements of A belong to B and they are not the same A B and A ≠ B then A B • Power set: the set of all the subsets of A A = {a, b} P(A) = {, {a}, {b}, {a, b}} |A| = n then |P(A)| = 2n
Operations on sets SETS :: RELATIONS :: FUNCTIONS • Union: the set containing the the members of A or B • Intersection: the set containing the members of both A and B A B A B a c d b A B A B a c d b
Operations on sets (cont.) SETS :: RELATIONS :: FUNCTIONS • Difference: the set containing the members of A and not of B • Complement: given a universal set U, the complement of A is the set whose members are the members of U - A. A B A - B a c d b U _ A A
Exercises SETS :: RELATIONS :: FUNCTIONS • Given A = {t, z} and B = {v, z, t}, say whether the following statements are true or false: • A B • A B • z A B • v B • {v} B • v A- B • Given A = {a, b, c, d} and B = {c, d, f} • Find a set X such that A B = B X. Is this set unique? • Is there any set Y such that A Y = B ?
Properties of sets SETS :: RELATIONS :: FUNCTIONS • A A = A A A = A • A = A = A • A B = B A AB = B A (commutative) • (A B) C = A (B C) (AB) C = A(B C) (associative) • A (B C) = (A B) (A C) A (B C) = (A B) (A C) (distributive) _____ _ _ • A B = A B _____ _ _ A B = A B (De Morgan laws)
Cartesian product SETS :: RELATIONS :: FUNCTIONS • Cartesian product of A and B: the set of ordered couples (a, b) where a is a member of A and b a member of B A x B = {(a, b) : a A and b B} • Notice that A x B ≠ B x A • Example: A = {a, b, c}, B = {s, t} A x B = {(a, s), (a, t), (b, s), (b, t), (c, s), (c, t)}
Relations SETS :: RELATIONS :: FUNCTIONS • A (binary) relation R from set A to set B is a subset of A x BR A x B xRy indicates that (x, y) R • The domain of R is the set Dom(R) = {a A | ∃ b B s.t. aRb} • The co-domain of R is the set Cod(R) = {b B | ∃ a A s.t. aRb} A B a b (a,b) ∈ R
Relations (cont.) SETS :: RELATIONS :: FUNCTIONS • An n-ary relation Rn is a subset of A1 x … x An n is the arity of the relation • The inverse relation of R A x B is the relation R-1B x A where: R-1 = {(b, a) | (a, b) R} A B a b (b, a) ∈ R-1
Properties of relations SETS :: RELATIONS :: FUNCTIONS Let R be a binary relation on A, i.e. R A x A. R is said to be: • reflexiveiffaRa ∀ a A; • symmetriciffaRb implies bRa∀ a, b A; • transitiveiffaRb and bRc imply aRc ∀ a, b, c A; • anti-symmetric iffaRb and bRa imply a = b ∀ a, b A;
Equivalence relations SETS :: RELATIONS :: FUNCTIONS • Given R A x A, R is an equivalence relation iffit is reflexive, symmetric and transitive. • A partitionof a set A is a family F of non-empty subsets of A s.t.: • the subsets are pairwise disjoint • the union of all the subsets is the set A Notice that each element of A belongs to exactly one subset in F. • Given ≡ equivalence relation on A and a A, the equivalence classof a is the set [a] = {x | a ≡ x} Notice that if x [a] then [x] = [a] • The quotient set of A w.r.t. ≡ is the set {[x] | x A} which defines a partition of A.
Order relations SETS :: RELATIONS :: FUNCTIONS • Given R A x A, R is a (partial) order relation iffit is reflexive, anti-symmetric and transitive. • If the relation holds ∀ a, b A then it is a total order • If ∀ a, b A either aRbor bRaor a = b then it is a strict order
Functions SETS :: RELATIONS :: FUNCTIONS • A functionf from A to B is a binary relation that associates to each element a in A exactly one element b in B. f : A B • The image of an element a A is denoted with f(a) B Notice that it can be the case that the same element in B is theimage of several elements in A.
Functions (cont.) SETS :: RELATIONS :: FUNCTIONS • f: A B is injective if for distinct elements in A there is a distinct element in B: ∀ a, b A and a ≠ b then f(a) ≠ f(b) • f: A B is surjective if for each element in B there is at least one element in A: ∀ b B ∃ a A s.t.f(a) = b • f: A B is bijectiveif it is injective and surjective.
Functions (cont.) SETS :: RELATIONS :: FUNCTIONS • If f: A B is bijective we can define its inverse functionf-1: B A • Given two functions f: A B and g: B C, the compositionof f and g is the function g ○f : C such that: g ○f = {(a, g(f(a)) | a A}