Пример #1
0
def displayUnifyListH(xs, ys):
    subst = unifyLists(xs, ys)

    row1 = ['xs'] + list(map(simplerep, xs))
    row2 = ['ys'] + list(map(simplerep, ys))
    row3 = ['xs+'] + list(map(simplerep, applySubst(subst, xs)))
    row4 = ['ys+'] + list(map(simplerep, applySubst(subst, ys)))

    tab1 = mkTable([row1, row2, row3, row4])

    rows = []
    for p, q in subst:
        row = [p, q]
        row = [simplerep(d) for d in row]
        rows.append(row)
    tab2 = mkTable(rows)

    return tab1 + '<br>' + tab2
Пример #2
0
def displayUnifyList(xs, ys):
    subst = unifyLists(xs, ys)

    rows = []
    for x, y in zip(xs, ys):
        row = [x, y, applySubst(subst, x), applySubst(subst, y)]
        row = [simplerep(d) for d in row]
        rows.append(row)

    tab1 = mkTable(rows)

    rows = []
    for p, q in subst:
        row = [p, q]
        row = [simplerep(d) for d in row]
        rows.append(row)
    tab2 = mkTable(rows)

    return tab1 + tab2
Пример #3
0
def test0():
    tensorA3 = mkTensorSort(PPInt(), ['A', 3])
    tensor2B = mkTensorSort(PPInt(), [2, 'B'])

    l1 = [tensorA3]
    l2 = [tensor2B]
    subst = unifyLists(l1, l2)
    print(subst)
    # [(PPDimVar(name='A'), PPDimConst(value=2)), (PPDimVar(name='B'), PPDimConst(value=3))]

    r1 = [applySubst(subst, x) for x in l1]
    r2 = [applySubst(subst, x) for x in l2]

    assert r1 == [
        PPTensorSort(param_sort=PPInt(),
                     shape=[PPDimConst(value=2),
                            PPDimConst(value=3)])
    ]

    assert r1 == r2
Пример #4
0
def test1():
    listOfInt = PPListSort(PPInt())
    listOfT1 = PPListSort(PPSortVar('T1'))
    listOfT2 = PPListSort(PPSortVar('T2'))

    l1 = [listOfInt, listOfT1]
    l2 = [listOfInt, listOfT2]
    subst = unifyLists(l1, l2)
    print(subst)
    # [(PPSortVar(name='T1'), PPSortVar(name='T2'))]

    r1 = [applySubst(subst, x) for x in l1]
    r2 = [applySubst(subst, x) for x in l2]

    assert r1 == [
        PPListSort(param_sort=PPInt()),
        PPListSort(param_sort=PPSortVar(name='T2'))
    ]

    assert r1 == r2
Пример #5
0
def test3():
    graphOfA = PPGraphSort(PPSortVar('A'))
    graphOfB = PPGraphSort(PPSortVar('B'))
    graphOfT1 = PPGraphSort(PPSortVar('T1'))
    graphOfT2 = PPGraphSort(PPSortVar('T2'))

    l1 = [graphOfA, graphOfB]
    l2 = [graphOfT1, graphOfT2]
    subst = unifyLists(l1, l2)
    print(subst)
    # [(PPSortVar(name='A'), PPSortVar(name='T1')), (PPSortVar(name='B'), PPSortVar(name='T2'))]

    r1 = [applySubst(subst, x) for x in l1]
    r2 = [applySubst(subst, x) for x in l2]

    assert r1 == [
        PPGraphSort(param_sort=PPSortVar(name='T1')),
        PPGraphSort(param_sort=PPSortVar(name='T2'))
    ]

    assert r1 == r2