                 (=> (proper-subset? Y X)
                     (proper-subset? (adprime ctx Y) X)))))))))
 
-(deftest test-stem-base-with-background-knowledge
+(deftest test-canonical-base-with-background-knowledge
   ;; make sure implications with empty premise are handled correctly
   (is (let [ctx (make-context-from-matrix 5 5
                                           [0 0 1 0 1

                    [3 5] [3 8] [4 1] [4 3] [4 5]
                    [4 8] [5 2] [5 3] [5 5] [5 7]})))

(deftest test-stem-base-from-base
  (with-testing-data [ctx (random-contexts 10 20)]
    (= (set (stem-base ctx))
       (stem-base-from-base (proper-premise-implications ctx))))
  (= (stem-base-from-base [(make-implication #{1} #{2 3})
                           (make-implication #{1} #{2 4})])
     #{(make-implication #{1} #{2 3 4})}))

(deftest test-canonical-base-from-clop
  (with-testing-data [ctx stem-base-test-contexts]
    (and (= (set (canonical-base ctx))
            (set (canonical-base-from-clop #(adprime ctx %) (attributes ctx)))))))

(deftest test-parallel-canonical-base-from-clop
  (with-testing-data [ctx stem-base-test-contexts]
    (and (= (set (canonical-base ctx))
            (set (parallel-canonical-base-from-clop #(adprime ctx %)
                                                    (attributes ctx)))))))

    (is (sound-implication-set? ctx irr-subset))
    (is (complete-implication-set? ctx irr-subset))))

(def canonical-base-test-contexts [contexts/test-ctx-01,
                                   contexts/test-ctx-04
                                   contexts/test-ctx-07,
                                   contexts/test-ctx-08])

(deftest test-canonical-base
  (is (= 1 (count (canonical-base (one-context #{1 2 3 4 5})))))
  (doseq [ctx canonical-base-test-contexts]
    (let [sb (canonical-base ctx)]
      (is (minimal-implication-set? sb))
      (is (sound-implication-set? ctx sb))
      (is (complete-implication-set? ctx sb))
