Lesson 14: Relations and algebras Mathematical Logic; advanced course Contents Theory of sets (revision) Relations and mappings (revision) – – – – – Relation Binary relation on a set Mapping Partition & equivalence Orderings Algebras – Algebras with one operation – Algebras with two operations – Lattices 9.4.2015 Relace a algebry 2 Theory of sets Language: • Special symbols: – Binary predicates: (is an element of), (is a proper subset of), (is a subset of) – Binary function symbols: (intersection – „průnik“), (union – „sjednocení“) Cantor – naive set theory (without axiomatizing) Nowadays there are many formal axiomatizations, but none of them is complete. Examples: von Neumann-Bernays-Gödel, Zermelo-Fränkel + axiom of choice 9.4.2015 Relace a algebry 3 Naive theory of sets Ø – an empty set Cardinality of a set A: |A| Relations between sets (axioms): Equality A B, iff (x : x A x B) Inclusion A B, iff (x : x A x B) 9.4.2015 Relace a algebry 4 Naive theory of sets – set theoretical operations Intersection U Union U Difference U A B {x; x A and x B} A B {x; x A or x B} A B {x; x A and x B} Symetrical difference A B ( A B) ( A B) A B A B A B A B U Complement with respect to universe U U A' U A 9.4.2015 A A' Relace a algebry 5 Naive theory of sets – set theoretical operations Power set 2 A {X ; X A} Cartesian product A B {(a, b) : a A, b B} Cartesian power An A A A n A1=A, A0={Ø} 9.4.2015 Relace a algebry 6 Zermelo-Fränkel set-theory Axiom of extensionality: Two sets are identical if and only if they have the same elements. Axiom of an empty set: There is a set with no elements. Axiom of pairing: If x, y are sets, then so is {x,y}, a set containing x and y as its only elements. Axiom of union: Every set has a union. That is, for any set x there is a set y whose elements are precisely the elements of the elements of x. Axiom of infinity: There exists a set x such that {} is in x and whenever y is in x, so is the union y U {y}. Axiom of separation (or subset axiom): Given any set and any proposition P(x), there is a subset of the original set containing precisely those elements x for which P(x) holds. Axiom of replacement: Given any set and any mapping, formally defined as a proposition P(x,y) where P(x,y) and P(x,z) implies y = z, there is a set containing precisely the images of the original set's elements. Axiom of power set: Every set has a power set. That is, for any set x there exists a set y, such that the elements of y are precisely the subsets of x. Axiom of regularity (or axiom of foundation): Every non-empty set x contains some element y such that x and y are disjoint sets. Axiom of choice: (Zermelo's version) Given a set x of mutually disjoint nonempty sets, there is a set y (a choice set for x) containing exactly one element from each member of x. 9.4.2015 Relace a algebry 7 Relations n-ary relation between the sets A1, A2, ..., An r A1 A2 An Examples: – D = a set of possible days – M = a set of VŠB rooms – Z = a set of VŠB employees A ternary relation meeting (when, where, who): r D M 2 9.4.2015 Z Relace a algebry 8 Binary relations r A B Inverse relation: r 1 {(x, y) B A : ( y, x) r} Composition of relations r A B, s B C r s {( x, y) A C : (z B) ( x, z) r and ( z, y) s } A 9.4.2015 r B B s C Relace a algebry A ros C 9 Binary relations Binary relation r on a set A is called: Reflexive: x A: (x,x) r Irreflexive: x A: (x,x) r Symmetric: x,y A: (x,y) r (y,x) r Antisymmetric: x,y A: (x,y) r and (y,x) r x=y Asymmetric: x,y A: (x,y) r (y,x) r Transitive: x,y,z A: (x,y) r and (y,z) r (x,z) r Cyclic: x,y,z A: (x,y) r and (y,z) r (z,x) r Continuous: x,y A: x=y or (x,y) r or (y,x) r 9.4.2015 Relace a algebry 10 Binary relations The important types of binary relations: Tolerance – reflexive, symmetric Quasi-ordering – reflexive, transitive Equivalence – reflexive, symmetric, transitive Partial ordering – reflexive, antisymmetric, transitive 9.4.2015 Relace a algebry 11 Binary relations Examples: Tolerance: – „being similar to“ on a set of people, – „being no more than one year older or younger“ on the set of people, ... Quasi-ordering: – on a set of sets: the sets X and Y are related iff |X||Y|, – divisibility relation on the set of integers, – „not to be older“ on a set of people, ... Equivalence: – „being of the same age“ on the set of people, – identity on the set of natural numbers, ... Ordering: – Set-theoretical inclusion on a set of sets, – divisibility relation on the set of natural numbers, ... 9.4.2015 Relace a algebry 12 Mappings (functions) f A B is called a mapping from a set A into a set B (partial mapping), iff: (x A, y1,y2 B) ( (x,y1) f and (x,y2) f y1 = y2 ) f is called a mapping of a set A into a set B (total mapping, written as: f: AB), iff: – f is mapping from A to B – (x A)(y B) ( (x,y) f) If f is a mapping and (x,y) f, then we write f(x)=y 9.4.2015 Relace a algebry 13 Mapping (functions) Examples: rAB A B sAB A B tAB A B u = {(x,y)ZZ; x=y2}, v = {(x,y)NN; x=y2}, w = {(x,y)ZZ; y=x2} r, u – are not mappings s, v – are partial mappings from A to B, (not total) t, w – are total mappings 9.4.2015 Relace a algebry 14 Mapping (functions) Mapping f: AB is called Injection (one to one total mapping A into B), iff: x1,x2 A, y B: (x1,y) f and (x2,y) f x1 = x2 Surjection (mapping A onto B), iff: y B x A: (x,y) f Bijection (one to one mapping A onto B) (mutually single-valued), iff it is injection and surjection. 9.4.2015 Relace a algebry 15 Mapping (functions) Examples: f:AB A B g:AB h:AB i:AB A A A j: ZZ, j(n)=n2, l: NN, l(n)=n+1, B B B k: ZN, k(n)=|n|, m: RR, j(x)=x3 f, j – are neither injections nor surjections h, k – are surjections, not injections g, l – are injections , not surjections I,m – are injections and surjections simultaneously bijections 9.4.2015 Relace a algebry 16 Partitions and equivalences Partition on a set A is a system such that: X = { Xi; i I } A – Xi A for i I – Xi Xj = Ø for i,j I, i j – UX=A Xi – classes of the partition Fine graining of partition X = { Xi; i I } is a system such that: A Y = { Yj; j J }, iff: – j J, i I so that Yj Xi 9.4.2015 Relace a algebry 17 Partitions and equivalences Let r be an equivalence relation on a set A, X is a partition on A, then it holds: Xr = {[x]r; x A} – a partition on A (rozklad) induced by equivalence r; – a quotient set (faktorová množina) of the set A according to the equivalence r rX = {(x,y); x and y belong to the same class of the partition X} – equivalence on A (induced by the partition X) Example: r ZZ; r = {(x,y); 3 divides x-y } X={X1, X2, X3} – X1={…-6, -3, 0, 3, 6, …} – X2={…-5, -2, 1, 4, 7, …} – X3={…-4, -1, 2, 5, 8, …} 9.4.2015 Relace a algebry 18 Orderings If r is an order relation on A, then a couple (A,r) is called an ordered set (uspořádaná množina) – Examples: (N, ), (2M, ) Cover relation (relace pokrytí) Let (A, ) be an ordered set, (a,b)A a –< b („b covers a“), iff: a < b and c A: a c a c b – Examples: (N, ), –< ={(n,n+1); n N} 9.4.2015 Relace a algebry 19 Orderings Hasse diagram – graphical picturing – Example: (A, ), A={a,b,c,d,e} r = {(a,b), (a,c), (a,d), (b,d)} idA idA={(a,a): aA} d b c e a 9.4.2015 Relace a algebry 20 Orderings An element a of an ordered set (A, ) is called: The least: for xA: a x The greatest: for xA: x a Minimal: for xA: (x a x = a) Maximal: for xA: (a x x = a) d Example: – – – – The least: does not exist The greatest: does not exist Minimal: a, e Maximal: d, c, e b c e a 9.4.2015 Relace a algebry 21 Orderings A mapping of the ordered sets (A, ), (B, ) is called isomorphic, iff there is a bijection f: AB such that: x,yA: x y, iff f(x) f(y) A mapping of the ordered sets (A, ), (B, ) is called isotone f: AB, when the following holds: x,yA: x y f(x) f(y) Examples: f: NZ, f(x)=kx, k Z, k 0 is isotone g: NZ, g(x)=kx, k Z, k 0 is not isotone 9.4.2015 Relace a algebry 22 Orderings Let (A, ) be an ordered set, M A, then LA(M)={xA; mM: x m } – The set of lower bounds (dolní závory) of M in A UA(M)={xA; mM: m x } – The set of upper bounds (horní závory) of M in A InfA(M) – The greatest element of the set LA(M) – Infimum of the set M in A SupA(M) – The least element of the set UA(M) – Supremum of the set M in A 9.4.2015 Relace a algebry 23 Lattice defined as an ordered set A set (A, ) is called a lattice (lattice ordered set), iff: x,yA s,i A : s = sup({x,y}), i = inf({x,y}) Notation: – x y = sup({x,y}) – x y = inf({x,y}) (spojení – „meet“) (průsek – „join“) If sup(M) and inf(M) exist for every M A, then (A, ) is called a complete lattice 9.4.2015 Relace a algebry 24 Algebra Algebra (abstract algebra) is a couple: (A, FA): A Ø – an underlying set of algebra (nosič) FA = {fi: Ap(fi)A; iI} – a set of operations on A p(fi) – the arity of an operation fi Examples: – (N, +2, 2) the set of natural numbers with the addition and multiplication operations – (2M, , ) the set of all subsets of a set M with the intersection and union operations – (F, , ) The set (F) of the propositional logic formulas with the conjunction and disjunction operations 9.4.2015 Relace a algebry 25 Algebras with one binary operation Grupoid G=(G,) : G G G If a set G is finite, then the grupoid G is called finite Order of a grupoid = |G| Examples of grupoids: G1=(R,+), G2=(R,), G3=(N,+) ... 9.4.2015 Relace a algebry 26 Algebras with one binary operation We can express the finite grupoid G=(G,) by Cayley table Example: G = {a,b,c} a b c a a b c b a c c c a a b For example: a b = b, b a = a, c c = b ... 9.4.2015 Relace a algebry 27 Algebras with one binary operation Let G=(G,) be a grupoid, then G is: Commutative, if – (a,bG)(a b = b a) Associative, if – (a,b,cG)((a b) c = a (b c)) With a neutral element, if – (e G aG)(a e = a = e a) With an aggressive element, if – (o G aG)(a o = o = o a) With an inverse elements, if – (aG b G)(a b = e = b a) 9.4.2015 Relace a algebry 28 Algebras with one binary operation Examples: (R,), (N,+) – commutative and associative (R,), a b = (a+b) / 2 – commutative, not associative (R,), a b = ab – neither commutative nor associative (R,) – 1 = the neutral element, 0 = the aggressive element 9.4.2015 Relace a algebry 29 Algebras with one binary operation Let G=(G,G) be a grupoid. HG is called closed with respect to the operation G, if (a,bH)(a G b H) A Grupoid H=(H,H) is a subgrupoid of a grupoid G=(G,G), if it holds: Ø H G is closed a,bH: a H b = a G b Examples: (N,+N) is a subgrupoid of (Z,+Z) 9.4.2015 Relace a algebry 30 Algebras with one binary operation Let G1=(G1, 1), G2=(G2, 2) be grupoids. G1 G2 =(G1 G2, ) – direct product G1 and G2, where: (a1, a2) (b1, b2) = (a1 1 b1, a2 2 b2) Examples: G1=(Z,+), G2=(Z,). G1 G2 =(Z Z, ), (a1, a2) (b1, b2) = (a1 + b1, a2 b2) (1,2)(3,4) = (1+3, 2 4) = (4,8) and so on. 9.4.2015 Relace a algebry 31 Algebras with one binary operation Let G =(G, G), H =(H, H) be grupoids and h:GH be a mapping. Then h is a homomorphism of the grupoid G into the grupoid H, if a,bG: h(a G b) = h(a) H h(b) Types of homomorphism: Monomorphism – h is injective Epimorphism – h is surjective Isomorphism – h is bijective Endomorphism – H=G Automorphism – is bijective and H=G Examples: (R,+), h(x)= -x , h is automorfismus (R,+) into itself h(x+y) = -(x+y) = (-x) + (-y) = h(x) + h(y) 9.4.2015 Relace a algebry 32 Algebras with one binary operation r is called a congruence on a grupoid G=(G,G), iff: r is a binary relation on G: r GG r is an equivalence (a1, a2), (b1, b2) r (a1 G b1, a2 G b2) r The factor grupoid of a grupoid G induced by the congruence r: G/r=(G/r,G/r), [a]r G/r [b]r = [a G b]r [0] [1] [2] [0] [0] [1] [2] Example: r ZZ; r = {(x,y); 3 divides x-y } [1] [1] [2] [0] r is a congruence on (Z,+) [2] [2] [0] [1] 9.4.2015 Relace a algebry 33 Algebras with one binary operation Types of grupoids: Semigroup – an associative grupoid Monoid – a semigroup with the neutral element Group – a monoid with the inverse elements Abelian group – a commutative group Examples: (Z, –) – grupoid, not a semigroup (N – {0}, +) – semigroup, not a monoid (N,) – monoid, not a group (Z, +) – Abelian group 9.4.2015 Relace a algebry 34 Algebras with two binary operation Algebra (A,+,·) is called a Ring (okruh), if: (A,+) is commutative group (A,·) is monoid For a,b,cA it holds: a·(b+c)=a·b+a·c, (b+c)·a=b·a + c·a If |A|>1, then (A,+,·) is called a non-trivial ring. Let 0 A is the neutral element of group (A,+). Then 0 is called the ring zero (A,+,·). Let 1A is the neutral element of monoid (A,·). Then 1 is called the ring unit (A,+,·). 9.4.2015 Relace a algebry 35 Algebras with two binary operation A ring (A,+,·) is called a field (pole), if: (A - {0},·) is a commutative group Examples: (Z,+,·) – a ring, not a field (R,+,·), (C,+,·) – fields 9.4.2015 Relace a algebry 36 Lattice – algebraic structure Lattice L = (L, , ) : L LL, : L LL x, y, z L it holds: xx=x xx=x idempotention xy=yx xy=yx commutativity x (y z) = (x y) z x (y z) = (x y) z x (x y) = x x (x y) = x 9.4.2015 Relace a algebry associativity absorption 37 Lattice – algebraic structure Let (A, , ) be a lattice, (B, ) be a lattice ordered set Let us define a relation on A : a b, iff a b = b Let us define the relations and on B a b = sup{a,b}, a b = inf{a,b}, Then it holds: (A, ) is a lattice ordered set, where: sup{a,b}= a b, inf{a,b}= a b (B, , ) is a lattice (A, , ) = (A, , ) 9.4.2015 Relace a algebry 38 Lattice – algebraic structure A lattice (L, , ) is called: Modular, if it holds: x, y, z L : x z x (y z) = (x y) z Distributive, if it holds: x, y, z L : x (y z) = (x y) (x z) x (y z) = (x y) (x z) Complementary, if it holds: : There is the least element 0 L and the greatest element 1L x L x’ L : x x’ = 0, x x’ = 1 x’ is called a complement of an element x 9.4.2015 Relace a algebry 39 Lattice – algebraic structure Each distributive lattice is modular Examples: M5 (diamond) – a modular lattice which is not distributive N5 (pentagon) – is not modular 1 1 c 9.4.2015 a b M5 0 b c Relace a algebry a N5 0 40 Lattice – algebraic structure Lattice (L, , ) is called a Boolean lattice, if it is: Complementary, distributive, with the least element 0 L and with the greatest element 1 L Boolean algebra: (L, , , –, 0, 1), – : LL is an operation of complement in L Example: (2A, , ), A = {1,2,3,4,5,6,7} 9.4.2015 Relace a algebry 41