An Algebraic Notion of Conditional Independence, and Its Application to Knowledge Representation (full version)