Exemplo n.º 1
0
def get_problem():
    # Initialize problem structure.
    p_a = Point('A')
    p_b = Point('B')
    p_c = Point('C')

    line_ab = Line('AB', end1=p_a, end2=p_b)
    line_bc = Line('BC', end1=p_b, end2=p_c)
    line_ac = Line('AC', end1=p_a, end2=p_c)

    angle_a = Angle('BAC', side1=line_ab, side2=line_ac, vertex=p_a)
    angle_b = Angle('ABC', side1=line_ab, side2=line_bc, vertex=p_b)
    angle_c = Angle('ACB', side1=line_ac, side2=line_bc, vertex=p_c)

    triangle = Triangle(
            'ABC', 
            vertex1=p_c, vertex2=p_a, vertex3=p_b,
            side1=line_ab, side2=line_bc, side3=line_ac,
            angle1=angle_c, angle2=angle_a, angle3=angle_b)
    
    entity = Entity('Basic test2')
    entity.add_entity(triangle)

    # Set target.
    target = Target(angle_c, 'angle')

    # Initialize conditions.
    conditions = []
    conditions.append(AttributeValue(angle_a, angle=60))
    conditions.append(AttributeValue(angle_b, angle=30))
    
    return entity, target, conditions
Exemplo n.º 2
0
def get_problem():
    # Initialize problem structure.
    p_a = Point('A')
    p_b = Point('B')
    p_c = Point('C')
    p_d = Point('D')

    line_ab = Line('AB', end1=p_a, end2=p_b)
    line_ac = Line('AC', end1=p_a, end2=p_c)
    line_ad = Line('AD', end1=p_a, end2=p_d)

    angle_bac = Angle('BAC', side1=line_ab, side2=line_ac, vertex=p_a)
    angle_cad = Angle('CAD', side1=line_ac, side2=line_ad, vertex=p_a)
    angle_bad = Angle('BAD', side1=line_ab, side2=line_ad, vertex=p_a)

    entity = Entity('Basic test3')
    entity.add_entity(p_a, p_b, p_c, p_d)
    entity.add_entity(line_ab, line_ac, line_ad)
    entity.add_entity(angle_bac, angle_bad, angle_cad)

    # Initialize conditions.
    conditions = []
    conditions.append(AttributeValue(angle_bac, angle=60))
    conditions.append(AttributeValue(angle_cad, angle=30))
    cva = CommonVertexAngle('A_BCD', vertex=p_a, ends=[p_b, p_c, p_d])
    r = RelationshipBased(cva)
    conditions.append(r)

    # Set target.
    target = Target(angle_bad, 'angle')

    return entity, target, conditions
Exemplo n.º 3
0
def get_problem():
    """Test for line sum."""
    # Initialize problem structure.
    p_a = Point('A')
    p_b = Point('B')
    p_c = Point('C')

    line_ab = Line('AB', end1=p_a, end2=p_b)
    line_bc = Line('BC', end1=p_b, end2=p_c)
    line_ac = Line('AC', end1=p_a, end2=p_c)

    entity = Entity('Basic test1')
    entity.add_entity(p_a, p_b, p_c)
    entity.add_entity(line_ab, line_bc, line_ac)

    # Set target.
    target = Target(line_bc, 'length')

    # Initialize conditions.
    conditions = []
    conditions.append(AttributeValue(line_ab, length=2))
    conditions.append(AttributeValue(line_ac, length=5))
    col = Collineation('ABC', [p_a, p_b, p_c])
    r = RelationshipBased(col)
    conditions.append(r)

    return entity, target, conditions
Exemplo n.º 4
0
def get_problem():
    # Initialize problem structure.
    p_a = Point('A')
    p_b = Point('B')
    p_c = Point('C')
    p_d = Point('D')

    line_ac = Line('AC', end1=p_a, end2=p_c)
    line_bc = Line('BC', end1=p_b, end2=p_c)
    line_bd = Line('BD', end1=p_b, end2=p_d)
    line_cd = Line('CD', end1=p_c, end2=p_d)

    angle_acb = Angle('ACB', side1=line_ac, side2=line_bc, vertex=p_c)
    angle_acd = Angle('ACD', side1=line_ac, side2=line_cd, vertex=p_c)

    entity = Entity('Basic test4')
    entity.add_entity(p_a, p_b, p_c, p_d)
    entity.add_entity(line_ac, line_bc, line_bd, line_cd)
    entity.add_entity(angle_acb, angle_acd)

    # Initialize conditions.
    conditions = []
    conditions.append(AttributeValue(angle_acb, angle=60))
    sa = SupplementaryAngle('ACB_ACD', angle1=angle_acb, angle2=angle_acd)
    col = Collineation('BCD', points=[p_b, p_c, p_d])
    conditions.append(RelationshipBased(sa))
    conditions.append(RelationshipBased(col))

    # Set target.
    target = Target(angle_acd, 'angle')

    return entity, target, conditions
Exemplo n.º 5
0
def get_problem():
    # Initialize problem structure.
    p_a = Point('A')
    p_b = Point('B')
    p_c = Point('C')
    p_d = Point('D')

    line_ac = Line('AC', end1=p_a, end2=p_c)
    line_bc = Line('BC', end1=p_b, end2=p_c)
    line_bd = Line('BD', end1=p_b, end2=p_d)
    line_cd = Line('CD', end1=p_c, end2=p_d)

    angle_acb = Angle('ACB', side1=line_ac, side2=line_bc, vertex=p_c)
    angle_acd = Angle('ACD', side1=line_ac, side2=line_cd, vertex=p_c)

    entity = Entity('Basic test5')
    entity.add_entity(p_a, p_b, p_c, p_d)
    entity.add_entity(line_ac, line_bc, line_bd, line_cd)
    entity.add_entity(angle_acb, angle_acd)

    # Initialize conditions.
    conditions = []
    p = Perpendicular('AC_BD', line1=line_ac, line2=line_bd, foot_point=p_c)
    conditions.append(RelationshipBased(p))

    # Set target.
    target = Target(angle_acd, 'angle')

    return entity, target, conditions
Exemplo n.º 6
0
def get_problem():
    # Initialize problem structure.
    p_a = Point('A')
    p_b = Point('B')
    p_c = Point('C')
    p_d = Point('D')

    line_ab = Line('AB', end1=p_a, end2=p_b)
    line_ac = Line('AC', end1=p_a, end2=p_c)
    line_ad = Line('AD', end1=p_a, end2=p_d)

    angle_bac = Angle('BAC', side1=line_ab, side2=line_ac, vertex=p_a)
    angle_bad = Angle('BAD', side1=line_ab, side2=line_ad, vertex=p_a)
    angle_cad = Angle('CAD', side1=line_ac, side2=line_ad, vertex=p_a)

    entity = Entity('Basic test20')
    entity.add_entity(p_a, p_b, p_c, p_d)
    entity.add_entity(line_ab, line_ac, line_ad)
    entity.add_entity(angle_bac, angle_bad, angle_cad)

    # Set target.
    target = Target(angle_bad, 'angle')

    # Initialize conditions.
    conditions = []
    conditions.append(AttributeValue(angle_bac, angle=30))
    r = NAngleSector('BAD_AC',
                     angle=angle_bad,
                     split_line=line_ac,
                     near_line=line_ab)
    conditions.append(RelationshipBased(r))
    conditions.append(AttributeValue(r, ratio=0.25))
    return entity, target, conditions
def get_problem():
    """Test for line sum."""
    # Initialize problem structure.
    p_a = Point('A')
    p_b = Point('B')
    p_c = Point('C')
    p_d = Point('D')
    p_e = Point('E')
    p_f = Point('F')
    p_g = Point('G')
    p_h = Point('H')

    line_ab = Line('AB', end1=p_a, end2=p_b)
    line_af = Line('AF', end1=p_a, end2=p_f)
    line_bf = Line('BF', end1=p_b, end2=p_f)
    line_cd = Line('CD', end1=p_c, end2=p_d)
    line_cg = Line('CG', end1=p_c, end2=p_g)
    line_dg = Line('DG', end1=p_d, end2=p_g)
    line_ef = Line('EF', end1=p_e, end2=p_f)
    line_eg = Line('EG', end1=p_e, end2=p_g)
    line_eh = Line('EH', end1=p_e, end2=p_h)
    line_fg = Line('FG', end1=p_f, end2=p_g)
    line_fh = Line('FH', end1=p_f, end2=p_h)
    line_gh = Line('GH', end1=p_g, end2=p_h)

    angle_afe = Angle('AFE', side1=line_af, side2=line_ef, vertex=p_f)
    angle_bfe = Angle('BFE', side1=line_bf, side2=line_ef, vertex=p_f)
    angle_afh = Angle('AFH', side1=line_af, side2=line_fh, vertex=p_f)
    angle_bfh = Angle('BFH', side1=line_bf, side2=line_fh, vertex=p_f)
    angle_cgh = Angle('CGH', side1=line_cg, side2=line_gh, vertex=p_g)
    angle_dgh = Angle('DGH', side1=line_dg, side2=line_gh, vertex=p_g)
    angle_cge = Angle('CGE', side1=line_cg, side2=line_eg, vertex=p_g)
    angle_dge = Angle('DGE', side1=line_dg, side2=line_eg, vertex=p_g)

    entity = Entity('Basic test14')
    for name, obj in locals().items():
        if name.startswith(tuple(['p_', 'line_', 'angle_'])):
            entity.add_entity(obj)

    # Initialize conditions.
    conditions = []
    conditions.append(AttributeValue(angle_afh, angle=60))
    parallel = Parallel('AB_CD', line1=line_ab, line2=line_cd)
    r = RelationshipBased(parallel)
    conditions.append(r)
    conditions.append(
        RelationshipBased(Collineation('AFB', points=[p_a, p_f, p_b])))
    conditions.append(
        RelationshipBased(Collineation('CGD', points=[p_c, p_g, p_d])))
    conditions.append(
        RelationshipBased(Collineation('EFGH', points=[p_e, p_f, p_g, p_h])))

    # Set target.
    target = Target(angle_cge, 'angle')

    return entity, target, conditions
Exemplo n.º 8
0
    def parse(self):
        problem = self.get_problem()

        solver = Solver(problem)

        print('Create a triangle successfully!')
        print(problem)

        # Add targets.
        for id_, type_, attr in self._target_dict:
            target = Target(TargetType.EVALUATION,
                            entity=problem.entity.find_child(id_, type_),
                            attr=attr)
            solver.add_target(target)

        solver.solve()

        return problem
Exemplo n.º 9
0
def get_problem():
    """Test for equality of opposite vertical angle."""
    # Initialize problem structure.
    p_a = Point('A')
    p_b = Point('B')
    p_c = Point('C')
    p_d = Point('D')
    p_o = Point('O')

    line_ao = Line('AO', end1=p_a, end2=p_o)
    line_ad = Line('AD', end1=p_a, end2=p_d)
    line_do = Line('DO', end1=p_d, end2=p_o)
    line_bo = Line('BO', end1=p_b, end2=p_o)
    line_bc = Line('BC', end1=p_b, end2=p_c)
    line_co = Line('CO', end1=p_c, end2=p_o)

    angle_aob = Angle('AOB', side1=line_ao, side2=line_bo, vertex=p_o)
    angle_aoc = Angle('AOC', side1=line_ao, side2=line_co, vertex=p_o)
    angle_cod = Angle('COD', side1=line_co, side2=line_do, vertex=p_o)
    angle_bod = Angle('BOD', side1=line_bo, side2=line_do, vertex=p_o)

    entity = Entity('Basic test6')
    entity.add_entity(p_a, p_b, p_c, p_d, p_o)
    entity.add_entity(line_ao, line_ad, line_do, line_bo, line_bc, line_co)
    entity.add_entity(angle_aob, angle_aoc, angle_cod, angle_bod)

    # Initialize conditions.
    conditions = []
    ova1 = OppositeVerticalAngle('AOB_COD',
                                 angle1=angle_aob,
                                 angle2=angle_cod,
                                 vertex=p_o)
    ova2 = OppositeVerticalAngle('AOC_BOD',
                                 angle1=angle_aoc,
                                 angle2=angle_bod,
                                 vertex=p_o)
    conditions.append(RelationshipBased(ova1))
    conditions.append(RelationshipBased(ova2))
    conditions.append(AttributeValue(angle_aob, angle=60))

    # Set target.
    target = Target(angle_cod, 'angle')

    return entity, target, conditions
def get_problem():
    # Initialize problem structure.
    p_a = Point('A')
    p_b = Point('B')
    p_c = Point('C')

    line_ab = Line('AB', end1=p_a, end2=p_b)
    line_bc = Line('BC', end1=p_b, end2=p_c)
    line_ac = Line('AC', end1=p_a, end2=p_c)

    angle_a = Angle('BAC', side1=line_ab, side2=line_ac, vertex=p_a)
    angle_b = Angle('ABC', side1=line_ab, side2=line_bc, vertex=p_b)
    angle_c = Angle('ACB', side1=line_ac, side2=line_bc, vertex=p_c)

    triangle = Triangle('ABC',
                        vertex1=p_c,
                        vertex2=p_a,
                        vertex3=p_b,
                        side1=line_ab,
                        side2=line_bc,
                        side3=line_ac,
                        angle1=angle_c,
                        angle2=angle_a,
                        angle3=angle_b)

    entity = Entity('Basic test23')
    entity.add_entity(triangle)

    # Set target.
    target = Target(angle_c, 'angle')

    # Initialize conditions.
    conditions = []
    conditions.append(AttributeValue(angle_b, angle=30))
    r = ValueEquivalence('AB_AC',
                         obj_list=[line_ab, line_ac],
                         attr_list=['length', 'length'])
    conditions.append(RelationshipBased(r))

    return entity, target, conditions
def get_problem():
    # Initialize problem structure.
    p_a = Point('A')
    p_b = Point('B')
    p_c = Point('C')

    line_ab = Line('AB', end1=p_a, end2=p_b)
    line_ac = Line('AC', end1=p_a, end2=p_c)
    line_bc = Line('BC', end1=p_b, end2=p_c)

    entity = Entity('Basic test21')
    entity.add_entity(line_ab, line_ac, line_bc)

    # Set target.
    target = Target(line_ac, 'length')

    # Initialize conditions.
    conditions = []
    conditions.append(AttributeValue(line_ab, length=1))
    r = NLineSector('AC_B', line=line_ac, split_point=p_b, nearer_point=p_a)
    conditions.append(RelationshipBased(r))
    conditions.append(AttributeValue(r, ratio=0.5))

    return entity, target, conditions
def create_target(problem):
    target = Target(TargetType.EVALUATION,
                    entity=problem.entity.find_child('DE', type_=Line),
                    attr='length')
    return target
Exemplo n.º 13
0
def create_target2(problem):
    target = Target(TargetType.EVALUATION,
                    entity=problem.entity.find_child('BDC', type_=Angle),
                    attr='angle')
    return target
Exemplo n.º 14
0
def get_problem():
    # Initialize problem structure.
    p_a = Point('A')
    p_b = Point('B')
    p_c = Point('C')

    line_ab = Line('AB', end1=p_a, end2=p_b)
    line_bc = Line('BC', end1=p_b, end2=p_c)
    line_ac = Line('AC', end1=p_a, end2=p_c)

    angle_a = Angle('BAC', side1=line_ab, side2=line_ac, vertex=p_a)
    angle_b = Angle('ABC', side1=line_ab, side2=line_bc, vertex=p_b)
    angle_c = Angle('ACB', side1=line_ac, side2=line_bc, vertex=p_c)

    triangle_abc = Triangle('ABC',
                            vertex1=p_c,
                            vertex2=p_a,
                            vertex3=p_b,
                            side1=line_ab,
                            side2=line_bc,
                            side3=line_ac,
                            angle1=angle_c,
                            angle2=angle_a,
                            angle3=angle_b)

    p_d = Point('D')
    p_e = Point('E')
    p_f = Point('F')

    line_de = Line('DE', end1=p_d, end2=p_e)
    line_ef = Line('EF', end1=p_e, end2=p_f)
    line_df = Line('DF', end1=p_d, end2=p_f)

    angle_d = Angle('EDF', side1=line_de, side2=line_df, vertex=p_d)
    angle_e = Angle('DEF', side1=line_de, side2=line_ef, vertex=p_e)
    angle_f = Angle('DFE', side1=line_df, side2=line_ef, vertex=p_f)

    triangle_def = Triangle('DEF',
                            vertex1=p_f,
                            vertex2=p_d,
                            vertex3=p_e,
                            side1=line_de,
                            side2=line_ef,
                            side3=line_df,
                            angle1=angle_f,
                            angle2=angle_d,
                            angle3=angle_e)

    entity = Entity('Basic test19')
    entity.add_entity(triangle_abc)
    entity.add_entity(triangle_def)

    # Set target.
    target = Target(line_df, 'length')

    # Initialize conditions.
    conditions = []
    conditions.append(AttributeValue(angle_a, angle=60))
    conditions.append(AttributeValue(angle_b, angle=90))
    conditions.append(AttributeValue(angle_c, angle=30))
    conditions.append(AttributeValue(angle_d, angle=60))
    conditions.append(AttributeValue(angle_e, angle=90))
    conditions.append(AttributeValue(angle_f, angle=30))
    conditions.append(AttributeValue(line_ab, length=1))
    conditions.append(AttributeValue(line_ac, length=2))
    conditions.append(AttributeValue(line_de, length=1))

    return Problem(entity, conditions, target)
Exemplo n.º 15
0
def create_target(problem):
    target = Target(TargetType.PROOF,
        entity=problem.entity.find_child('ABC', type_=Triangle).state,
        attr='rt_state',
        value=TriangleState.RT.rt)
    return target
Exemplo n.º 16
0
def create_target(problem):
    target = Target(TargetType.EVALUATION,
                    entity=problem.entity.find_child('COD'),
                    attr='angle')
    return target
Exemplo n.º 17
0
def get_problem():
    # Initialize problem structure.
    p_a = Point('A')
    p_b = Point('B')
    p_c = Point('C')

    line_ab = Line('AB', end1=p_a, end2=p_b)
    line_bc = Line('BC', end1=p_b, end2=p_c)
    line_ac = Line('AC', end1=p_a, end2=p_c)

    angle_a = Angle('BAC', side1=line_ab, side2=line_ac, vertex=p_a)
    angle_b = Angle('ABC', side1=line_ab, side2=line_bc, vertex=p_b)
    angle_c = Angle('ACB', side1=line_ac, side2=line_bc, vertex=p_c)

    triangle_abc = Triangle('ABC',
                            vertex1=p_c,
                            vertex2=p_a,
                            vertex3=p_b,
                            side1=line_ab,
                            side2=line_bc,
                            side3=line_ac,
                            angle1=angle_c,
                            angle2=angle_a,
                            angle3=angle_b)

    p_d = Point('D')
    p_e = Point('E')
    p_f = Point('F')

    line_de = Line('DE', end1=p_d, end2=p_e)
    line_ef = Line('EF', end1=p_e, end2=p_f)
    line_df = Line('DF', end1=p_d, end2=p_f)

    angle_d = Angle('EDF', side1=line_de, side2=line_df, vertex=p_d)
    angle_e = Angle('DEF', side1=line_de, side2=line_ef, vertex=p_e)
    angle_f = Angle('DFE', side1=line_df, side2=line_ef, vertex=p_f)

    triangle_def = Triangle('DEF',
                            vertex1=p_f,
                            vertex2=p_d,
                            vertex3=p_e,
                            side1=line_de,
                            side2=line_ef,
                            side3=line_df,
                            angle1=angle_f,
                            angle2=angle_d,
                            angle3=angle_e)

    entity = Entity('Basic test17')
    entity.add_entity(triangle_abc)
    entity.add_entity(triangle_def)

    # Set target.
    target = Target(angle_f, 'angle')

    # Initialize conditions.
    conditions = []
    conditions.append(AttributeValue(angle_a, angle=60))
    conditions.append(AttributeValue(angle_b, angle=90))
    st = SimilarTriangle('ABC_DEF',
                         triangle_abc,
                         triangle_def,
                         cor_angle=[(angle_a, angle_d), (angle_b, angle_e),
                                    (angle_c, angle_f)])
    conditions.append(RelationshipBased(st))
    return entity, target, conditions