def sharp_graphs(self, family = 'test_data', graphs = []): if graphs == []: graphs = get_graph_data(family) return [G for G in graphs if self.hyp(graphs[G]) is True and self.conjecture_sharp(graphs[G]) is True] else: return [G for G in graphs if self.hyp(graphs[G]) is True and self.conjecture_sharp(graphs[G]) is True]
def Romy(conjs, data_set = 'test_data'): conjs = conjs[:1000] C = conjs.copy() graph_data = get_graph_data(data_set) for i in range(len(conjs)): first_sharp_graphs = set(conjs[i].sharp_graphs(graphs = graph_data)) for j in range(i+1, len(conjs)): if set(conjs[j].sharp_graphs(graphs = graph_data)) < first_sharp_graphs and \ conjs[j] in C: C.remove(conjs[j]) return C
def Dalmation(conjs, data_set = 'test_data'): C = [] C.append(conjs[0]) graph_data = get_graph_data(data_set) observed_graphs = set(conjs[0].sharp_graphs(graphs = graph_data)) for i in range(1, len(conjs)): current_sharp_graphs = set(conjs[i].sharp_graphs(graphs = graph_data)) if current_sharp_graphs - observed_graphs != set(): C.append(conjs[i]) observed_graphs.union(current_sharp_graphs) return C
def hyp_graphs(conj, family='test_data'): graphs = get_graph_data(family) return [G for G in graphs if conj.hyp(graphs[G]) is True]
def scaled_touch(self, family = 'test_data'): graphs = get_graph_data(family) graphs = [G for G in graphs if self.hyp(graphs[G]) is True] return Fraction(self.touch() / len(graphs)).limit_denominator(1000)
def hyp_graphs(self, family = 'test_data'): graphs = get_graph_data(family) return [G for G in graphs if self.hyp(graphs[G]) is True]
def make_conjs(target, two_hypothesis=False, two_invariants=False, data_set='test_data', use_Dalmation=False, use_Romy=False): conjs = [] hypothesis = get_hypothesis_data()[1] invariant_names = desired_invariant_names(target) graphs_hold = get_graph_data(data_set) for h in hypothesis: graphs = graphs_hold.copy() graphs = [graphs[G] for G in graphs if h(graphs[G]) is True] new_invariant_names = regular_exclusion_invariant_names( h, invariant_names) for invar in new_invariant_names: temp_conjs = list( filter(None, make_ratio(graphs, h, target, invar))) for c in temp_conjs: conjs.append(c) temp_conjs = list( filter(None, make_constant(graphs, h, target, invar))) for c in temp_conjs: conjs.append(c) if two_invariants == True: for invars in combinations(new_invariant_names, 2): invars = list(invars) temp_conjs = list( filter( None, make_constant_two(graphs, h, target, invars[0], invars[1]))) for c in temp_conjs: conjs.append(c) temp_conjs = list( filter( None, make_constant_two(graphs, h, target, invars[1], invars[0]))) for c in temp_conjs: conjs.append(c) temp_conjs = list( filter( None, make_ratio_two(graphs, h, target, invars[0], invars[1]))) for c in temp_conjs: conjs.append(c) temp_conjs = list( filter( None, make_ratio_three(graphs, h, target, invars[0], invars[1]))) for c in temp_conjs: conjs.append(c) temp_conjs = list( filter( None, make_ratio_three(graphs, h, target, invars[1], invars[0]))) for c in temp_conjs: conjs.append(c) if two_hypothesis == True: hypothesis = get_hypothesis_data()[2] for h in hypothesis: graphs = graphs_hold.copy() graphs = [graphs[G] for G in graphs if h(graphs[G]) is True] new_invariant_names = regular_exclusion_invariant_names( h, invariant_names) for invar in new_invariant_names: temp_conjs = list( filter(None, make_ratio(graphs, h, target, invar))) for c in temp_conjs: conjs.append(c) temp_conjs = list( filter(None, make_constant(graphs, h, target, invar))) for c in temp_conjs: conjs.append(c) if two_invariants == True: for invars in combinations(new_invariant_names, 2): invars = list(invars) temp_conjs = list( filter( None, make_constant_two(graphs, h, target, invars[0], invars[1]))) for c in temp_conjs: conjs.append(c) temp_conjs = list( filter( None, make_constant_two(graphs, h, target, invars[1], invars[0]))) for c in temp_conjs: conjs.append(c) temp_conjs = list( filter( None, make_ratio_two(graphs, h, target, invars[0], invars[1]))) for c in temp_conjs: conjs.append(c) temp_conjs = list( filter( None, make_ratio_three(graphs, h, target, invars[0], invars[1]))) for c in temp_conjs: conjs.append(c) temp_conjs = list( filter( None, make_ratio_three(graphs, h, target, invars[1], invars[0]))) for c in temp_conjs: conjs.append(c) if use_Dalmation == True: return Dalmation(Theo(conjs)) elif use_Romy == True: return Romy(Theo(conjs)) else: return Theo(conjs)