27
Ordered sets Trees Lattices Formal concept analysis Lattices and classification SET07106 Mathematics for Software Engineering School of Computing Edinburgh Napier University Module Leader: Uta Priss 2010 Copyright Edinburgh Napier University Lattices and classification Slide 1/25

Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

  • Upload
    others

  • View
    11

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Lattices and classification

SET07106 Mathematics for Software Engineering

School of ComputingEdinburgh Napier UniversityModule Leader: Uta Priss

2010

Copyright Edinburgh Napier University Lattices and classification Slide 1/25

Page 2: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Outline

Ordered sets

Trees

Lattices

Formal concept analysis

Copyright Edinburgh Napier University Lattices and classification Slide 2/25

Page 3: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Reminder: properties of binary relations

I antisymmetric: a 6= b : (a, b) =⇒ not (b, a)

I reflexive: for all elements: (a, a)

I transitive: (a, b), (b, c) =⇒ (a, c)

A partially ordered set (poset) is a reflexive, antisymmetric andtransitive binary relation.

Copyright Edinburgh Napier University Lattices and classification Slide 3/25

Page 4: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Directed acyclic graphs

directed acyclic graph:antisymmetric:

directed cyclic graph:

Copyright Edinburgh Napier University Lattices and classification Slide 4/25

Page 5: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Partially ordered set (poset)

Hasse diagram:antisymmetricand transitive:

antisymmetric, reflexive and transitive:

Copyright Edinburgh Napier University Lattices and classification Slide 5/25

Page 6: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Order relation ≤

The binary relation of a partially ordered set is written as ≤.

I antisymmetric: a 6= b : a ≤ b =⇒ not b ≤ a

I reflexive: for all elements: a ≤ a

I transitive: a ≤ b, b ≤ c =⇒ a ≤ c

For example:

I antisymmetric: 5 ≤ 7 =⇒ not 7 ≤ 5

I reflexive: 6 ≤ 6

I transitive: 3 ≤ 4, 4 ≤ 7 =⇒ 3 ≤ 7

If a 6= b, one can also write a < b or a > b.

Copyright Edinburgh Napier University Lattices and classification Slide 6/25

Page 7: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Order relation ≤

The binary relation of a partially ordered set is written as ≤.

I antisymmetric: a 6= b : a ≤ b =⇒ not b ≤ a

I reflexive: for all elements: a ≤ a

I transitive: a ≤ b, b ≤ c =⇒ a ≤ c

For example:

I antisymmetric: 5 ≤ 7 =⇒ not 7 ≤ 5

I reflexive: 6 ≤ 6

I transitive: 3 ≤ 4, 4 ≤ 7 =⇒ 3 ≤ 7

If a 6= b, one can also write a < b or a > b.

Copyright Edinburgh Napier University Lattices and classification Slide 6/25

Page 8: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Order relation ≤

The binary relation of a partially ordered set is written as ≤.

I antisymmetric: a 6= b : a ≤ b =⇒ not b ≤ a

I reflexive: for all elements: a ≤ a

I transitive: a ≤ b, b ≤ c =⇒ a ≤ c

For example:

I antisymmetric: 5 ≤ 7 =⇒ not 7 ≤ 5

I reflexive: 6 ≤ 6

I transitive: 3 ≤ 4, 4 ≤ 7 =⇒ 3 ≤ 7

If a 6= b, one can also write a < b or a > b.

Copyright Edinburgh Napier University Lattices and classification Slide 6/25

Page 9: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Examples of posets

I Scheduling problems: PERT charts, flow charts

I Dependency graphs: software installers, compilers, variabledependencies

I C++ class hierarchy (a hierarchy where every node can havemultiple parents)

I Part-whole relationships (e.g. food and ingredients)

Copyright Edinburgh Napier University Lattices and classification Slide 7/25

Page 10: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Tree order

A tree is a poset where each child node has exactly one parentnode. A tree has a single root node.

A binary tree is a tree where each node has either exactly twochildren or no children.

Copyright Edinburgh Napier University Lattices and classification Slide 8/25

Page 11: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

binary tree:tree:

Copyright Edinburgh Napier University Lattices and classification Slide 9/25

Page 12: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Examples of tree orders

I B-tree search structures in operating systems and databases

I Directory structures in operating systems (without symboliclinks)

I Java class hierarchy

I XML document structure

I Library classification systems

I Genealogy

Copyright Edinburgh Napier University Lattices and classification Slide 10/25

Page 13: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Exercise

Find all trees with 6 nodes.

Hint: there are 6 different ones.

Copyright Edinburgh Napier University Lattices and classification Slide 11/25

Page 14: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Linearly (or totally) ordered set

A linearly ordered set is a poset where each two nodes arecomparable, i.e. for a, b, either a = b or a < b or b < a.

For example:1 < 2 < 3 < ... < 15 < 16 < 17 < ....

A < B < C < D < ... < Z < a < b < ... < z

Copyright Edinburgh Napier University Lattices and classification Slide 12/25

Page 15: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Lattice

A lattice is a poset where each two nodes have a greatest commonchild node and a least common parent node.

Copyright Edinburgh Napier University Lattices and classification Slide 13/25

Page 16: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Lattices and posets

lattices:poset, not a lattice:

Copyright Edinburgh Napier University Lattices and classification Slide 14/25

Page 17: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Example: divisor lattices

2

1 1

506

2 51

70

72

1

27

5 3

935141025103

Copyright Edinburgh Napier University Lattices and classification Slide 15/25

Page 18: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Exercise

Draw the divisor lattices for 18, 36 and 108.

Copyright Edinburgh Napier University Lattices and classification Slide 16/25

Page 19: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Examples of lattices

I The subset relation ⊂ among sets.

I The integers: 1 < 2 < 3 < 4 < .... (This lattice is infinite.)

I Boolean logic.

I Concept lattices (see the next slides).

Copyright Edinburgh Napier University Lattices and classification Slide 17/25

Page 20: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Leibniz: Characteristica universalis (17th century)

animal

6 human

rational32

Copyright Edinburgh Napier University Lattices and classification Slide 18/25

Page 21: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Formal concept analysis

Formal concept analysis (FCA) is a mathematical method for dataanalysis and knowledge representation which uses lattice theory. Abinary relation (or formal context) is converted into a conceptlattice.

FCA is based on philosophical notions of the duality of concepts(extension and intension). It was invented in the 1980s and hassince grown into an international field of research with applicationsin many domains.

Copyright Edinburgh Napier University Lattices and classification Slide 19/25

Page 22: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Formal context and concept lattice

tortoise

GarfieldSnoopySocksGreyfriar’s BobbyHarriet

cartoon cat mammaldogreal

tortoise

cat

Garfield

cartoon dog

Harriet

Greyfriar’s BobbySnoopy

Socks

mammal real

Copyright Edinburgh Napier University Lattices and classification Slide 20/25

Page 23: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

Subconcept-superconcept relation

Concept B

realintension:

Harriet, Bobby, Socksextension:

real, mammalintension:

extension:Bobby, Socks

Concept A

Copyright Edinburgh Napier University Lattices and classification Slide 21/25

Page 24: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

An interval scale

(Japan)

at least 2000

at least 3000

at least 4000

at most 7000

at most 3000

at most 4000

at most 5000

at least 5000

Bristlecone pine "Methusala"

Fortingall Yew(Scotland)

Huon Pine(Tasmania)

Jomonsugi

Copyright Edinburgh Napier University Lattices and classification Slide 22/25

Page 25: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

A nominal scale

Taxodia/swamp cypress

Fortingall Yew(Scotland)

Huon Pine(Tasmania)

Jomonsugi(Japan)

Bristlecone pine"Methusala"

Podocarpa

broadleave

Pina/pineTaxa/yew

conifer

Copyright Edinburgh Napier University Lattices and classification Slide 23/25

Page 26: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

A nested line diagram

conifer

Podocarpa

Pina/pineTaxa/yew

Taxodia/swamp cypress

Fortingall Yew(Scotland)

Huon Pine(Tasmania)

Jomonsugi(Japan)

Bristlecone pine"Methusala"

Copyright Edinburgh Napier University Lattices and classification Slide 24/25

Page 27: Lattices and classification - upriss.org.uk · Title: Lattices and classification Author: SET07106 Mathematics for Software Engineering Created Date: 20110308201339Z

Ordered sets Trees Lattices Formal concept analysis

FCA applications in software engineering

I Visualise and analyse Java class hierarchies

I Detect variable or code dependencies

I Analyse dependencies and vulnerabilities in Linux

I Re-engineering, code analysis, module restructuring

Copyright Edinburgh Napier University Lattices and classification Slide 25/25