def test_ideal_framework(self): sceptically_preferred_sets = Semantics.sceptically_preferred( ExampleFrameworks.ideal_framework()) self.assertIn(Semantics.SemanticSet([a]), sceptically_preferred_sets) self.assertEqual(1, len(sceptically_preferred_sets)) ideal_sets = Semantics.ideal(ExampleFrameworks.ideal_framework()) self.assertIn(Semantics.SemanticSet([]), ideal_sets) self.assertEqual(1, len(ideal_sets))
def test_SemanticSet_equality(self): s1 = Semantics.SemanticSet([a, b, c]) s2 = Semantics.SemanticSet([c, a, b]) s3 = Semantics.SemanticSet([a, b]) self.assertEqual(s1, s2) self.assertNotEqual(s1, s3) self.assertNotEqual(s2, s3) self.assertTrue(s1 in set([s1]))
def test_group_intersection(self): set_a = Semantics.SemanticSet([a, b, c]) set_b = Semantics.SemanticSet([a, b]) set_c = Semantics.SemanticSet([c]) intersection_a_b = Utils.group_intersection([set_a, set_b]) self.assertIn(a, intersection_a_b.elements) self.assertIn(b, intersection_a_b.elements) self.assertEqual(2, len(intersection_a_b.elements)) intersection_a_c = Utils.group_intersection([set_a, set_c]) self.assertIn(c, intersection_a_c.elements) self.assertEqual(1, len(intersection_a_c.elements)) intersection_b_c = Utils.group_intersection([set_b, set_c]) self.assertEqual(0, len(intersection_b_c.elements))
def group_intersection(semantic_sets): intersection = semantic_sets.pop( ).elements if len(semantic_sets) > 0 else [] for element in semantic_sets: intersection = [ elem for elem in element.elements if elem in intersection ] return Semantics.SemanticSet(intersection)
def test_generate_admissible_venice_framework(self): admissible_sets = Semantics.admissible(venice_baba) self.assertIn(Semantics.SemanticSet([]), admissible_sets) self.assertIn(Semantics.SemanticSet([a, c, e]), admissible_sets) self.assertIn(Semantics.SemanticSet([c, e]), admissible_sets) self.assertIn(Semantics.SemanticSet([e]), admissible_sets) self.assertIn(Semantics.SemanticSet([b, d]), admissible_sets) self.assertIn(Semantics.SemanticSet([d]), admissible_sets) self.assertEqual(6, len(admissible_sets))
def test_complete_s_framework(self): complete_sets = Semantics.complete(s_baba) self.assertIn(Semantics.SemanticSet([a, c, e, f]), complete_sets) self.assertIn(Semantics.SemanticSet([b, d, f]), complete_sets) self.assertIn(Semantics.SemanticSet([e, f]), complete_sets) self.assertIn(Semantics.SemanticSet([b, e, f]), complete_sets) self.assertIn(Semantics.SemanticSet([f]), complete_sets) self.assertIn(Semantics.SemanticSet([b, f]), complete_sets) self.assertEqual(6, len(complete_sets))
def test_minimal_set(self): set_a = Semantics.SemanticSet([a, b]) set_b = Semantics.SemanticSet([c, d]) set_c = Semantics.SemanticSet([b, d]) set_d = Semantics.SemanticSet([a, b, d]) set_e = Semantics.SemanticSet([a, c, d]) set_f = Semantics.SemanticSet([a, b, c, d]) minimal_sets = Utils.minimal_set( set([set_a, set_b, set_c, set_d, set_e, set_f])) self.assertIn(set_a, minimal_sets) self.assertIn(set_b, minimal_sets) self.assertIn(set_c, minimal_sets) self.assertNotIn(set_d, minimal_sets) self.assertNotIn(set_e, minimal_sets) self.assertNotIn(set_f, minimal_sets)
def test_ideal_venice_framework(self): ideal_sets = Semantics.ideal(venice_baba) self.assertIn(Semantics.SemanticSet([]), ideal_sets) self.assertEqual(1, len(ideal_sets))
def test_extensions_and_derivations_to_str_list(self): ext_deriv = [(Semantics.SemanticSet([a, b, c]), [d, e, f]), (Semantics.SemanticSet([d, e, f]), [a, b, c])] string_representation = Utils.extensions_and_derivations_to_str_list( ext_deriv)
def test_sceptically_preferred_s_framework(self): sceptically_preferred_sets = Semantics.sceptically_preferred(s_baba) self.assertIn(Semantics.SemanticSet([f]), sceptically_preferred_sets) self.assertEqual(1, len(sceptically_preferred_sets))
def test_stable_s_framework(self): stable_sets = Semantics.stable(s_baba) self.assertIn(Semantics.SemanticSet([a, c, e, f]), stable_sets) self.assertIn(Semantics.SemanticSet([b, d, f]), stable_sets) self.assertIn(Semantics.SemanticSet([b, e, f]), stable_sets) self.assertEqual(3, len(stable_sets))
def test_stable_venice_framework(self): stable_sets = Semantics.stable(venice_baba) self.assertIn(Semantics.SemanticSet([a, c, e]), stable_sets) self.assertIn(Semantics.SemanticSet([b, d]), stable_sets) self.assertEqual(2, len(stable_sets))
def test_ideal_s_framework(self): ideal_sets = Semantics.ideal(s_baba) self.assertIn(Semantics.SemanticSet([f]), ideal_sets) self.assertEqual(2, len(ideal_sets))
def test_generate_admissible_larger_framework(self): baba = ExampleFrameworks.larger_framework() admissible_sets = Semantics.admissible(baba) self.assertIn(Semantics.SemanticSet([b, e, i]), admissible_sets) self.assertIn(Semantics.SemanticSet([b, e, g, h]), admissible_sets) self.assertIn(Semantics.SemanticSet([b, f, g, h, i]), admissible_sets)
def test_grounded_s_framework(self): grounded_sets = Semantics.grounded(s_baba) self.assertIn(Semantics.SemanticSet([f]), grounded_sets) self.assertEqual(1, len(grounded_sets))
def test_complete_venice_framework(self): complete_sets = Semantics.complete(venice_baba) self.assertIn(Semantics.SemanticSet([]), complete_sets) self.assertIn(Semantics.SemanticSet([a, c, e]), complete_sets) self.assertIn(Semantics.SemanticSet([b, d]), complete_sets) self.assertEqual(3, len(complete_sets))
def test_preferred_s_framework(self): preferred_sets = Semantics.preferred(s_baba) self.assertIn(Semantics.SemanticSet([b, e, f]), preferred_sets) self.assertIn(Semantics.SemanticSet([b, d, f]), preferred_sets) self.assertIn(Semantics.SemanticSet([a, c, e, f]), preferred_sets) self.assertEqual(3, len(preferred_sets))
def test_preferred_venice_framework(self): preferred_sets = Semantics.preferred(venice_baba) self.assertIn(Semantics.SemanticSet([a, c, e]), preferred_sets) self.assertIn(Semantics.SemanticSet([b, d]), preferred_sets) self.assertEqual(2, len(preferred_sets))
def test_preferred_larger_framework(self): baba = ExampleFrameworks.larger_framework() preferred_sets = Semantics.preferred(baba) self.assertIn(Semantics.SemanticSet([b, f, g, h, i]), preferred_sets)