Exemple #1
0
def test_intros():
    ctxt = context.Context('test_ctxt')
    g = Goals('test', ctxt, goals = \
              [Goal(empty_tel, Bound(Forall('x'), Real, impl(p, impl(p, q))))])

    g.solve_with(intros)
    assert(g.goals[0].prop.equals(q))
Exemple #2
0
def test_unpack():
    ctxt = context.Context('test_ctxt')
    s = Const('s', sig)
    goal = Goal(Tele(['s'], [sig]), Sub(s, s))
    g = Goals('test', ctxt, goals = [goal])
    g.solve_with(unpack('s'))
    assert(g.goals[0]['h'].equals(bin_op_x_y))
    assert(g.goals[0].prop.lhs.is_pair())
Exemple #3
0
def test_simpl():
    ctxt = context.Context('test_ctxt')
    g = Goals('test', ctxt, goals = \
              sub_goal(empty_tel, beta_redex, App(triv, op, y)))

    g.solve_with(simpl(conv.par_beta))
    g.solve_with(trivial)
    assert(g.is_solved())
Exemple #4
0
def test_trivial():
    """
    """
    ctxt = context.Context('test_ctxt')
    g = Goals('test', ctxt, goals = sub_goal(empty_tel, atm, atm))
    g.solve_with(trivial)
    assert(g.is_solved())

    g = Goals('test', ctxt, goals = [Goal(Tele(['_'], [p]), p)])
    g.solve_with(trivial)
    assert(g.is_solved())
Exemple #5
0
def mvar_infer(expr, ctxt=None):
    """Infer the type of an expression and return the pair
    (type, proof obligations) or raise an exception of type
    ExprTypeError.
    
    Arguments:
    - `expr`: an expression
    """
    if ctxt == None:
        ty_ctxt_name = meta_var_gen.get_name('_unif_ctxt')
        ty_ctxt = context.Context(ty_ctxt_name)
    else:
        ty_ctxt = ctxt
    prf_obl_name = meta_var_gen.get_name('_unif_goals')
    prf_obl = goals.empty_goals(prf_obl_name, ty_ctxt)
    ty = t.ExprInfer().visit(expr, prf_obl)
    return (ty, prf_obl)
Exemple #6
0
def test_destruct():
    ctxt = context.Context('test_ctxt')
    Real2 = Const('Real2', Type())
    rfun = Bound(Pi('x'), Real, Real)
    r2fun = Bound(Pi('y'), Real2, Real2)
    
    g = Goals('test', ctxt, goals = sub_goal(empty_tel, rfun, r2fun))
    g.solve_with(destruct)
    assert(g.goals[0].prop.is_sub())
    assert(g.goals[0].prop.lhs.equals(Real))
    assert(g.goals[0].prop.rhs.equals(Real2))

    assert(g.goals[1].prop.is_sub())
    assert(g.goals[1].prop.lhs.equals(Real2))
    assert(g.goals[1].prop.rhs.equals(Real))

    assert(g.goals[2].prop.is_sub())
    assert(g.goals[2].prop.lhs.equals(Real))
    assert(g.goals[2].prop.rhs.equals(Real2))