Concept Version Space

'Copyright (c) 2007‑2012 Bo Morgan.
 All rights reserved.
 
 Author: Bo Morgan
 
 Permission to use, copy, modify and distribute this software and its
 documentation is hereby granted, provided that both the copyright
 notice and this permission notice appear in all copies of the
 software, derivative works or modified versions, and any portions
 thereof, and that both notices appear in supporting documentation.
 
 BO MORGAN ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
 BO MORGAN DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
 WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 
 Bo Morgan requests users of this software to return to bo@mit.edu any
 improvements or extensions that they make and grant Bo Morgan the
 rights to redistribute these changes.'

[defunk concept_version_space‑test_hypothesis_orderings []
  [let [[h1 [new concept_version_space_hypothesis t]]
        [h2 [new concept_version_space_hypothesis t]]]
    [have h1 exclude_variable_value `color `red]
    [have h2 exclude_variable_value `color `red]
    [have h2 exclude_variable_value `shape `cube]
    [terminal_format standard‑terminal '\nh1: ' h1]
    [terminal_format standard‑terminal '\nh2: ' h2]
    [if [not [get h1 is_consistent_with_or_more_general_than_hypothesis  h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑a number 1]]
    [if      [get h2 is_consistent_with_or_more_general_than_hypothesis  h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑a number 2]]
    [if      [get h1 is_consistent_with_or_more_specific_than_hypothesis h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑a number 3]]
    [if [not [get h2 is_consistent_with_or_more_specific_than_hypothesis h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑a number 4]]
    [if [not [get h1 is_more_general_than_hypothesis                     h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑a number 5]]
    [if      [get h2 is_more_general_than_hypothesis                     h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑a number 6]]
    [if      [get h1 is_more_specific_than_hypothesis                    h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑a number 7]]
    [if [not [get h2 is_more_specific_than_hypothesis                    h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑a number 8]]
    [if      [get h1 is_consistent_with_hypothesis                       h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑a number 9]]
    [if      [get h2 is_consistent_with_hypothesis                       h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑a number 10]]
    nil]
  [let [[h1 [new concept_version_space_hypothesis t]]
        [h2 [new concept_version_space_hypothesis t]]]
    [have h1 exclude_variable_value `color `red]
    [have h1 exclude_variable_value `shape `cube]
    [have h2 exclude_variable_value `color `‑]
    [have h2 exclude_variable_value `shape `cube]
    [terminal_format standard‑terminal '\nh1: ' h1]
    [terminal_format standard‑terminal '\nh2: ' h2]
    [if [not [get h1 is_consistent_with_or_more_general_than_hypothesis  h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑b number 1]]
    [if      [get h2 is_consistent_with_or_more_general_than_hypothesis  h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑b number 2]]
    [if      [get h1 is_consistent_with_or_more_specific_than_hypothesis h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑b number 3]]
    [if [not [get h2 is_consistent_with_or_more_specific_than_hypothesis h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑b number 4]]
    [if [not [get h1 is_more_general_than_hypothesis                     h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑b number 5]]
    [if      [get h2 is_more_general_than_hypothesis                     h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑b number 6]]
    [if      [get h1 is_more_specific_than_hypothesis                    h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑b number 7]]
    [if [not [get h2 is_more_specific_than_hypothesis                    h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑b number 8]]
    [if      [get h1 is_consistent_with_hypothesis                       h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑b number 9]]
    [if      [get h2 is_consistent_with_hypothesis                       h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑b number 10]]
    nil]
  [let [[h1 [new concept_version_space_hypothesis t]]
        [h2 [new concept_version_space_hypothesis t]]]
    [have h1 exclude_variable_value `color `red]
    [have h1 exclude_variable_value `shape `cube]
    [have h2 exclude_variable_value `color `red]
    [have h2 exclude_variable_value `color `green]
    [terminal_format standard‑terminal '\nh1: ' h1]
    [terminal_format standard‑terminal '\nh2: ' h2]
    [if      [get h1 is_consistent_with_or_more_general_than_hypothesis  h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑c number 1]]
    [if      [get h2 is_consistent_with_or_more_general_than_hypothesis  h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑c number 2]]
    [if      [get h1 is_consistent_with_or_more_specific_than_hypothesis h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑c number 3]]
    [if      [get h2 is_consistent_with_or_more_specific_than_hypothesis h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑c number 4]]
    [if      [get h1 is_more_general_than_hypothesis                     h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑c number 5]]
    [if      [get h2 is_more_general_than_hypothesis                     h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑c number 6]]
    [if      [get h1 is_more_specific_than_hypothesis                    h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑c number 7]]
    [if      [get h2 is_more_specific_than_hypothesis                    h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑c number 8]]
    [if      [get h1 is_consistent_with_hypothesis                       h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑c number 9]]
    [if      [get h2 is_consistent_with_hypothesis                       h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑c number 10]]
    nil]
  
  [let [[h1 [new concept_version_space_hypothesis nil]]
        [h2 [new concept_version_space_hypothesis nil]]]
    [have h1 include_variable_value `color `red]
    [have h2 include_variable_value `color `red]
    [have h2 include_variable_value `shape `cube]
    [terminal_format standard‑terminal '\nh1: ' h1]
    [terminal_format standard‑terminal '\nh2: ' h2]
    [if [not [get h2 is_consistent_with_or_more_general_than_hypothesis  h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑c2 number 1]]
    [if [not [get h1 is_consistent_with_or_more_specific_than_hypothesis h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑c2 number 2]]
    [if [not [get h2 is_more_general_than_hypothesis                     h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑c2 number 3]]
    [if [not [get h1 is_more_specific_than_hypothesis                    h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑c2 number 4]]
    [if      [get h1 is_consistent_with_hypothesis                       h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑c2 number 5]]
    [if      [get h2 is_consistent_with_hypothesis                       h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑c2 number 6]]
    nil]
  [let [[h1 [new concept_version_space_hypothesis nil]]
        [h2 [new concept_version_space_hypothesis nil]]]
    [have h1 include_variable_value `color `red]
    [have h1 include_variable_value `shape `cube]
    [have h2 include_variable_value `color `red]
    [have h2 include_variable_value `shape `cube]
    [terminal_format standard‑terminal '\nh1: ' h1]
    [terminal_format standard‑terminal '\nh2: ' h2]
    [if [not [get h2 is_consistent_with_or_more_general_than_hypothesis  h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑d number 1]]
    [if [not [get h1 is_consistent_with_or_more_specific_than_hypothesis h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑d number 2]]
    [if      [get h2 is_more_general_than_hypothesis                     h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑d number 3]]
    [if      [get h1 is_more_specific_than_hypothesis                    h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑d number 4]]
    [if [not [get h1 is_consistent_with_hypothesis                       h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑d number 5]]
    [if [not [get h2 is_consistent_with_hypothesis                       h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑d number 6]]
    nil]
  [let [[h1 [new concept_version_space_hypothesis t]]
        [h2 [new concept_version_space_hypothesis nil]]]
    [have h1 include_variable_value `color `red]
    [have h1 include_variable_value `shape `cube]
    [have h2 include_variable_value `color `red]
    [terminal_format standard‑terminal '\nh1: ' h1]
    [terminal_format standard‑terminal '\nh2: ' h2]
    [if      [get h2 is_consistent_with_or_more_general_than_hypothesis  h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑e number 1]]
    [if      [get h1 is_consistent_with_or_more_specific_than_hypothesis h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑e number 2]]
    [if      [get h2 is_more_general_than_hypothesis                     h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑e number 3]]
    [if      [get h1 is_more_specific_than_hypothesis                    h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑e number 4]]
    [if      [get h1 is_consistent_with_hypothesis                       h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑e number 5]]
    [if      [get h2 is_consistent_with_hypothesis                       h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑e number 6]]
    nil]
  [let [[h1 [new concept_version_space_hypothesis t]]
        [h2 [new concept_version_space_hypothesis nil]]]
    [have h1 include_variable_value `color `red]
    [have h1 include_variable_value `shape `cube]
    [have h2 include_variable_value `color `red]
    [have h2 include_variable_value `shape `cube]
    [terminal_format standard‑terminal '\nh1: ' h1]
    [terminal_format standard‑terminal '\nh2: ' h2]
    [if      [get h1 is_consistent_with_or_more_specific_than_hypothesis h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑e2 number 1]]
    [if [not [get h2 is_consistent_with_or_more_specific_than_hypothesis h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑e2 number 2]]
    [if [not [get h1 is_consistent_with_or_more_general_than_hypothesis  h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑e2 number 3]]
    [if      [get h2 is_consistent_with_or_more_general_than_hypothesis  h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑e2 number 4]]
    [if      [get h1 is_more_specific_than_hypothesis                    h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑e2 number 5]]
    [if [not [get h2 is_more_specific_than_hypothesis                    h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑e2 number 6]]
    [if [not [get h1 is_more_general_than_hypothesis                     h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑e2 number 7]]
    [if      [get h2 is_more_general_than_hypothesis                     h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑e2 number 8]]
    [if      [get h1 is_consistent_with_hypothesis                       h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑e2 number 9]]
    [if      [get h2 is_consistent_with_hypothesis                       h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑e2 number 10]]
    nil]
  [let [[h1 [new concept_version_space_hypothesis t]]
        [h2 [new concept_version_space_hypothesis nil]]]
    [have h1 include_variable_value `color `red]
    [have h1 include_variable_value `shape `‑]
    [have h2 include_variable_value `color `red]
    [have h2 include_variable_value `shape `‑]
    [terminal_format standard‑terminal '\nh1: ' h1]
    [terminal_format standard‑terminal '\nh2: ' h2]
    [if [not [get h1 is_consistent_with_or_more_general_than_hypothesis  h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑f number 1]]
    [if      [get h2 is_consistent_with_or_more_general_than_hypothesis  h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑f number 2]]
    [if [not [get h2 is_consistent_with_or_more_specific_than_hypothesis h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑f number 3]]
    [if      [get h1 is_consistent_with_or_more_specific_than_hypothesis h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑f number 4]]
    [if [not [get h1 is_more_general_than_hypothesis                     h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑f number 5]]
    [if      [get h2 is_more_general_than_hypothesis                     h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑f number 6]]
    [if      [get h1 is_more_specific_than_hypothesis                    h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑f number 7]]
    [if [not [get h2 is_more_specific_than_hypothesis                    h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑f number 8]]
    [if      [get h1 is_consistent_with_hypothesis                       h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑f number 9]]
    [if      [get h2 is_consistent_with_hypothesis                       h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑f number 10]]
    nil]
  [let [[h1 [new concept_version_space_hypothesis t]]
        [h2 [new concept_version_space_hypothesis nil]]]
    [have h1 include_variable_value `color `red]
    [have h1 exclude_variable_value `shape `red]
    [have h1 exclude_variable_value `shape `green]
    [have h2 include_variable_value `color `red]
    [have h2 include_variable_value `shape `cube]
    [terminal_format standard‑terminal '\nh1: ' h1]
    [terminal_format standard‑terminal '\nh2: ' h2]
    [if      [get h1 is_consistent_with_or_more_general_than_hypothesis  h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑g number 1]]
    [if      [get h2 is_consistent_with_or_more_general_than_hypothesis  h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑g number 2]]
    [if      [get h2 is_consistent_with_or_more_specific_than_hypothesis h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑g number 3]]
    [if      [get h1 is_consistent_with_or_more_specific_than_hypothesis h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑g number 4]]
    [if      [get h1 is_more_general_than_hypothesis                     h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑g number 5]]
    [if      [get h2 is_more_general_than_hypothesis                     h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑g number 6]]
    [if      [get h1 is_more_specific_than_hypothesis                    h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑g number 7]]
    [if      [get h2 is_more_specific_than_hypothesis                    h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑g number 8]]
    [if      [get h1 is_consistent_with_hypothesis                       h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑g number 9]]
    [if      [get h2 is_consistent_with_hypothesis                       h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑g number 10]]
    nil]
  [let [[h1 [new concept_version_space_hypothesis nil]]
        [h2 [new concept_version_space_hypothesis nil]]]
    [have h1 include_variable_value `color `red]
    [have h2 include_variable_value `color `red]
    [have h2 include_variable_value `shape `cube]
    [terminal_format standard‑terminal '\nh1: ' h1]
    [terminal_format standard‑terminal '\nh2: ' h2]
    [if      [get h1 is_consistent_with_or_more_general_than_hypothesis  h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑h number 1]]
    [if [not [get h2 is_consistent_with_or_more_general_than_hypothesis  h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑h number 2]]
    [if      [get h2 is_consistent_with_or_more_specific_than_hypothesis h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑h number 3]]
    [if [not [get h1 is_consistent_with_or_more_specific_than_hypothesis h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑h number 4]]
    [if      [get h1 is_more_general_than_hypothesis                     h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑h number 5]]
    [if [not [get h2 is_more_general_than_hypothesis                     h1]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑h number 6]]
    [if [not [get h1 is_more_specific_than_hypothesis                    h2]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑h number 7]]
    [if      [get h2 is_more_specific_than_hypothesis                    h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑h number 8]]
    [if      [get h1 is_consistent_with_hypothesis                       h2]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑h number 9]]
    [if      [get h2 is_consistent_with_hypothesis                       h1]  [error bug_type `concept_version_space‑test_hypothesis_orderings‑h number 10]]
    nil]
  
  [let [[h [new concept_version_space_hypothesis t]]
        [e [new concept_version_space_example    t]]]
    [have e add_variable_value `color `red]
    [have e add_variable_value `shape `cube]
    [terminal_format standard‑terminal '\nh: ' h]
    [terminal_format standard‑terminal '\ne: ' e]
    [if [not [get h is_consistent_with_example e]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑i number 1]]
    nil]
  [let [[h [new concept_version_space_hypothesis t]]
        [e [new concept_version_space_example    t]]]
    [have h exclude_variable_value `color `red]
    [have e add_variable_value `color `red]
    [have e add_variable_value `shape `cube]
    [terminal_format standard‑terminal '\nh: ' h]
    [terminal_format standard‑terminal '\ne: ' e]
    [if [get h is_consistent_with_example e] [error bug_type `concept_version_space‑test_hypothesis_orderings‑j number 1]]
    nil]
  [let [[h [new concept_version_space_hypothesis t]]
        [e [new concept_version_space_example    nil]]]
    [have e add_variable_value `color `red]
    [have e add_variable_value `shape `cube]
    [terminal_format standard‑terminal '\nh: ' h]
    [terminal_format standard‑terminal '\ne: ' e]
    [if [get h is_consistent_with_example e] [error bug_type `concept_version_space‑test_hypothesis_orderings‑m number 1]]
    nil]
  [let [[h [new concept_version_space_hypothesis t]]
        [e [new concept_version_space_example    nil]]]
    [have h exclude_variable_value `color `red]
    [have e add_variable_value `color `red]
    [have e add_variable_value `shape `cube]
    [terminal_format standard‑terminal '\nh: ' h]
    [terminal_format standard‑terminal '\ne: ' e]
    [if [not [get h is_consistent_with_example e]] [error bug_type `concept_version_space‑test_hypothesis_orderings‑n number 1]]
    nil]
  nil]

[defunk concept_version_space‑test []
  [let [[cvs [new concept_version_space]]
        [e1  [let [[this [new concept_version_space_example t]]]
               [have this add_variable_value `x 1]
               [have this add_variable_value `y 1]
               this]]
        [e2  [let [[this [new concept_version_space_example nil]]]
               [have this add_variable_value `x 1]
               [have this add_variable_value `y 2]
               this]]
        ]
    [have cvs train_on_example e2]
    [terminal_format standard‑terminal '\ncvs: ' cvs]
    [have cvs train_on_example e1]
    [terminal_format standard‑terminal '\ncvs: ' cvs]
    cvs]]