ContextAlgebra: Implementation of the context algebra.

[ bsd3, math, program ] [ Propose Tags ]

Implementation of the context algebra published in dissertation: Context Algebra applied to Spatial Concepts

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,,
Dependencies base (>=4.8 && <4.9), containers (>=0.5 && <0.6), criterion (>=1.1 && <1.2), multiset (>=0.3 && <0.4), QuickCheck (>=2.8 && <2.9), statistics (>=0.13 && <0.14), vector (>=0.11 && <0.12) [details]
License BSD-3-Clause
Author Jürgen Hahn
Category Math
Home page
Uploaded by jhahn at 2016-08-24T10:47:04Z
Executables ContextAlgebra
Downloads 2914 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2016-10-24 [all 10 reports]

Readme for ContextAlgebra-

[back to package description]


Implementation of the ContextAlgebra published in dissertation: Context Algebra applied to Spatial Concepts

This library is available on hackage ContextAlgebra


Words are used to refer to objects in reality. One word can imply many references to different objects that are categorized as similar. For example, the word “city” can refer to Vienna, Alexandria, or Las Vegas; the word “near” can refer to a range of distances, e. g. “moon is near the earth” or “near St. Stephens cathedral”. If a Geographic Information System (GIS) is queried with a sentence including “city” or “near”, the challenge for an algorithm executed by the GIS is to decide which exemplar of the word “city” or which distance “near” refers to.

To overcome this challenge, the hypothesis is that context selects references to objects in reality. A context algebra is presented, implemented, and used to represent the word “near” (in the thesis), in order to evaluate the hypothesis. Context algebra makes use of the theory established by a context-enriched semiotic triangle. The semiotic triangle connects objects in reality to words via concepts in an agent. With context enrichment, the concept is separated into contextualized concepts that include objects in reality valid for a specific context. If words are used in this specific context, then they correspond to a specific contextualized concept, which then selects specific references to objects from reality.

Context algebra proposes a formalization for context. In this algebra, contexts are ordered with a partial order relation and can be combined with a disjunction or conjunction function to create other contexts. This relation and these functions satisfy algebraic properties that result in a lattice structure for context. Each context included in the lattice is mapped to a contextualized concept. A contextualized concept is modeled with sets of objects observed from reality, where a typical object is determined. This typical object (prototype) is assumed to be the translation from a word to an object in reality. For example, the influencing context “capital of Austria” for the word “city” selects the prototypical instance Vienna.

Context algebra is implemented using Haskell, it is then proven, and the complexity class is determined.

  • The implementation shows that the context algebra is realizable with reasonable performance.
  • To prove that the implementation satisfies the proposed algebraic properties, tests are successfully executed.
  • The benchmarks determine the complexity class exponential for the implementation.


The implementation is structured into several modules according to the mathematical structure of the theory.

  • ContextAlgebra is built upon several abstract classes, each representing a mathematical structure.
  • Concept invents two containers, one to connect a concept to context (Observation data type) and one to build the concept (MultiSet of Observations).
  • Mapping establishes a ContextualizedConcept via the mapping function m
  • ContextualizedConcept calculates prototypes for a ContextualizedConcept.


  • ContextAlgebraSetInstance instances all abstract classes given in module ContextAlgebra using sets.


  • NominalExemplars calculates a prototype from exemplars on a nominal exemplar scales.
  • RatioExamplars calculates a prototype from exemplars on a rational measurement scale.


  • ContextAlgebraEvaluation execution of all property tests for the ContextAlgebra.
  • QuickCheckHelper wrapper functions for QuickCheck execution.

Benchmarks - Complexity

  • ConceptGenerator establishes concepts, with a freely selected number of exemplars and contexts.
  • ProtoCalculator calculates prototypes for each level of a ContextLattice.

Example for a General Context Operation

Module GeneralContextOperation shows an example of the context algebra refining concepts and calculating prototypes for contextualized concepts. For an extended explanation look on page 58 in the dissertation.

Further Reading

If you are interested, there are two publications online to read and do not hesitate to contact me.