示例#1
0
def boxDegree(varsNum, SMatrix):
    SMatrix = shortTableToLong(varsNum, SMatrix)
    alltruthTable = AllTruthTableSelect(varsNum)
    degMin = varsNum
    for ele in SMatrix:
        deg = getDegree(ele, alltruthTable)
        if deg < degMin:
            degMin = deg
    print(degMin)
示例#2
0
def NinenormalIndex(varsNum, truthTable):
    resList = []
    allThTable = AllTruthTableSelect(varsNum)
    for i in range(len(truthTable)):
        if truthTable[i] == 1:
            tableDic = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0}
            for j in range(len(allThTable[i])):
                tableDic[j] = allThTable[i][j]
            resList.append(copy.deepcopy(tableDic))
    return resList
def conclusion():
    varsNum = 8
    # lst = [6, 7, 8, 9, 10, 14, 16, 17, 18, 19, 20, 22, 24, 25, 26, 32, 34]
    allTruthTable = AllTruthTableSelect(varsNum)
    oribit = finalOribit(varsNum)
    for i in range(1, 33):
        res = fileToList("116_" + str(16) + ".txt")
        for ele in res:
            dicIndexList = initRSBF(varsNum, ele[0], oribit)
            truthTable = TruthTableSelect(varsNum, dicIndexList)
            x = xiao_messay(varsNum, truthTable, allTruthTable)
            with open("relisent.txt", mode="a+", encoding="utf-8") as f:
                f.write(str(ele) + str(x) + "\n")
        print("check")
def maxAbsolute(varsNum, Matrix):
    Matrix = shortTableToLong(varsNum, Matrix)
    allTruthtable = AllTruthTableSelect(varsNum)

    resList = []
    for ele in allTruthtable[1:]:
        resList.append(autoCorrelation(Matrix, ele, allTruthtable))

    maxValue = 0
    for ele in resList:
        value = max(ele)
        if value > maxValue:
            maxValue = value

    return maxValue
def uniform(varsNum, SMatix):
    SMatix = shortTableToLong(varsNum, SMatix)
    alltruthTable = AllTruthTableSelect(varsNum)
    midOpRes = boxMidOp(SMatix, alltruthTable)
    countList = []
    for element in alltruthTable:
        for ele in midOpRes:
            count = 0
            for i in range(len(ele[0])):
                tmpList = []
                for j in range(len(ele)):
                    tmpList.append(ele[j][i])
                if tmpList == element:
                        count += 1
            countList.append(count)
    return max(countList)
示例#6
0
def isRotationSymmetric(varsNum, truthTable):
    oribitList = finalOribit(varsNum)
    print(len(oribitList))
    nineTable = AllTruthTableSelect(varsNum)
    shortTableOribitList = []
    for ele in oribitList:
        tmpList = []
        for i in range(len(nineTable)):
            if nineTable[i] in ele:
                tmpList.append(i)
        shortTableOribitList.append(copy.deepcopy(tmpList))

    TableOribitList = []
    for ele in shortTableOribitList:
        tmpList = []
        for elem in ele:
            tmpList.append(truthTable[elem])
        TableOribitList.append(copy.deepcopy(tmpList))
    '''
        判断是否为旋转对称布尔函数
    '''
    FlagList = []
    for ele in TableOribitList:
        if ele.count(0) == len(ele) or ele.count(1) == len(ele):
            FlagList.append(True)
        else:
            FlagList.append(False)
    '''
        此处可获得短表
    '''
    shortList = []
    for i in range(len(TableOribitList)):
        if TableOribitList[i].count(1) == len(TableOribitList[i]):
            shortList.append(i + 1)
    print(shortList)

    if FlagList.count(True) == len(TableOribitList):
        print("Rotation Symmetric Prove")
    else:
        print("The function is not Rotation Symmetric")
示例#7
0
def revisedTO(varsNum, SMatrix):
    truthTableXOR = []
    allTruthtable = AllTruthTableSelect(varsNum)

    for ele in allTruthtable[1:]:
        tmpList = []
        for elem in allTruthtable:
            tmpList.append((vectorXOR(ele, elem)))
        truthTableXOR.append((tmpList))

    betaList = []
    for ele in allTruthtable:
        betaList.append(betaOp(ele))

    maxValue = 0
    for j in (range(len(allTruthtable))):
        sumTerm = 0
        for i in range(len(allTruthtable[1:])):
            sumTerm += (sumTermRTO(betaList[j], SMatrix, allTruthtable, truthTableXOR[i]))
        tmpValue = (varsNum - ((1 / ((pow(2, 2 * varsNum) - pow(2, varsNum)))) * sumTerm))
        if  tmpValue > maxValue:
            maxValue = tmpValue

    return maxValue
    for ele in zeroVec:
        truthTableVec.append(allTruthTable[ele].count(1))
    # print(oneNumStatic)
    # print(truthTableVec)
    oneNumStatic.pop(0)
    autoDeg = 0
    for k, v in oneNumStatic.items():
        if truthTableVec.count(k) == v:
            autoDeg = k
        else:
            break
    return autoDeg


if __name__ == '__main__':
    varsNum = 8
    # # lst = [6, 7, 8, 9, 10, 14, 16, 17, 18, 19, 20, 22, 24, 25, 26, 32, 34]
    allTruthTable = AllTruthTableSelect(varsNum)

    RSST = [
        3.0, 10.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 21.0, 24.0,
        25.0, 26.0, 27.0, 30.0, 34.0
    ]
    # tmp = (sorted(RSST))
    # print(tmp)
    oribit = finalOribit(varsNum)
    dicIndexList = initRSBF(varsNum, RSST, oribit)
    truthTable = TruthTableSelect(varsNum, dicIndexList)
    print(truthTable)
    print(xiao_messay(varsNum, truthTable, allTruthTable))