Exemplo n.º 1
0
    def controlAxiomsAsap(self):
        from pytptp import axiom,annot,all,any
        s  = self.symbols
        less,succ,pred,X,Y,T,Z,U,V =  s.less,s.succ,s.pred,s.X,s.Y,s.T,s.Z,s.U,s.V
        path,edge,input,output,diverge,signal,branch,at,want,crit,block,flop = s.path,s.edge,s.input,s.output,s.diverge,s.signal,s.branch,s.at,s.want,s.crit,s.block,s.flop
        T,T1,T2,A,B = s.T,s.T1,s.T2,s.A,s.B

        inNodes = [v  for v in self.vertices.values() if v.isInput()]

        f =  annot('')
        f += annot('Axiomy rizeni')

        f += annot('Formalizace neni sporna i kdyz vyjede hned jak to je mozne')
        f += axiom('want2', all(T,X,U) * ((at(T,X,U) & ~input(X) ) >= want(T,X)) )

        f += annot('Blokace vstupu jinym vlakem')
        f += axiom('block', all(T,Z) * ((( input(Z) & (any(X) * ( any(U)*at(T,X,U) & ~input(X) & (Z != X) & ~(any(Y) * (path(X,Y) & path(Y,Z)))) )) >= block(T,Z))))

        f += annot('Casovac - je povolen pouze jeden vstup')
        f += axiom('clock',all(T) * reduce(lambda x,y:x|y, ( reduce(lambda x,y:x&y,(~flop(T,u) for u in inNodes if u is not v),flop(T,v)) for v in inNodes) ))

        f += annot('Casovac - posunuti signalu na dalsi vstup')
        if len(inNodes) > 1:
            a = inNodes[1:]+inNodes[:1]
            k = Inc(0,'clock_')
            #f +=  [ axiom(
            #    +k, all(T) * ( (reduce(lambda x,y:x&y,(~flop(succ(T),u) for u in inNodes if u is not j),flop(succ(T),j))) <= (flop(T,i)) )
            # for i,j in ( (inNodes[i],a[i]) for i in range(len(inNodes)) ) ]

            f +=  [ axiom( +k, all(T) * ( flop(succ(T),j) <= (flop(T,i)) ) ) for i,j in ( (inNodes[i],a[i]) for i in range(len(inNodes)) ) ]


        f += annot('Povoleni k vstupu ')
        f += axiom('signal', all(T,X) *  ( input(X) & flop(T,X) & ~block(T,X) ) >= signal(T,X) )

        f += annot('Vyhybka')
        f += axiom('branch',
            all(T,Z,Y) * (( diverge(Z) & edge(Z,Y) & any(X,U) * ( at(T,X,U) & (path(X,Z)|(X==Z)) & (path(Y,U)|(Y==U)) ) ) >= branch(T,Z,Y))
        )
        return 'control_asap', f
Exemplo n.º 2
0
    def test3Conjectures(self):
        from pytptp import conjecture,annot,all,any
        s  = self.symbols
        less,succ,pred,X,Y,T,Z,U,V =  s.less,s.succ,s.pred,s.X,s.Y,s.T,s.Z,s.U,s.V
        path,edge,input,output,diverge,signal,branch,at,want,crit,block,flop = s.path,s.edge,s.input,s.output,s.diverge,s.signal,s.branch,s.at,s.want,s.crit,s.block,s.flop
        T,T1,T2,A,B = s.T,s.T1,s.T2,s.A,s.B

        f =  annot('')
        f += annot('Test 3')
        f += annot('Tento test funguje len pre nadrazie s 1 vstupom - flop je potom stale v platnosti')
        f += conjecture('t3', all(T,X) * ( (input(X) & any(U,V) * (output(U) & output(V) & at(T,X,U) & at(T,V,V) & path(X,V))) >= (signal(succ(T),X)) ))
        #f += conjecture('t3', all(T,X) * ( (input(X) & any(U,V) * (output(U) & output(V) & at(T,X,U) & at(T,V,V) & path(X,V))) >= (any(T1) * (less(T,T1) & signal(T1,X))) ))
        #f += conjecture('t3', all(T,X) * ( (input(X) & any(U,V) * (output(U) & output(V) & at(T,X,U) & at(T,V,V) & path(X,V) & ~ (any(Y,Z) * (at(T,Y,Z) & (X!=Y)& (V!=Y))))) >=( signal(succ(T),X) )  ))

        #f += conjecture('t3', all(T) * ( any(X) * ( (any(U,V)*(at(T,X,U) & input(X) & output(U) & at(T,V,U) & output(V) & block(T,X) & ~ (any(Y,Z) * (~input(Y) & ~output(Y) & at(T,Y,Z) ) ) )) >= ( signal(succ(T),X) )   ) )  )

        return 't3',f
Exemplo n.º 3
0
    def test2Conjectures(self):
        from pytptp import conjecture,annot,all,any
        s  = self.symbols
        less,succ,pred,X,Y,T,Z,U,V =  s.less,s.succ,s.pred,s.X,s.Y,s.T,s.Z,s.U,s.V
        path,edge,input,output,diverge,signal,branch,at,want,crit,block,flop = s.path,s.edge,s.input,s.output,s.diverge,s.signal,s.branch,s.at,s.want,s.crit,s.block,s.flop
        T,T1,T2,A,B = s.T,s.T1,s.T2,s.A,s.B

        f =  annot('')
        f += annot('Test 2')
        f += annot('Nenastane kriticky stav')
        f += conjecture('t2', all(T) * ( all(X,U)*(at(T,X,U) & input(X) & output(U)) >= ~( any(T1)*(less(T,T1) & crit(T1)) )   ) )
        return 't2',f
Exemplo n.º 4
0
    def test1Conjectures(self):
        from pytptp import conjecture,annot,all,any
        s  = self.symbols
        less,succ,pred,X,Y,T,Z,U,V =  s.less,s.succ,s.pred,s.X,s.Y,s.T,s.Z,s.U,s.V
        path,edge,input,output,diverge,signal,branch,at,want,crit,block,flop = s.path,s.edge,s.input,s.output,s.diverge,s.signal,s.branch,s.at,s.want,s.crit,s.block,s.flop
        T,T1,T2,A,B = s.T,s.T1,s.T2,s.A,s.B

        f =  annot('')
        f += annot('Test 1')
        f += annot('Vlak sa vzdy dostane zo vstupu (X) na definovany vystup (U)')
        #f += conjecture('t1', all(T,X,U) * (( input(X) & output(U) & at(T,X,U) & (all(Y) * (input(Y) | ~ (any(V) * ( at(T,Y,V) )))) ) >=
        #                                    (any(T1) * ( less(T,T1) &  at(T1,U,U) ) ) ))
        f += conjecture('t1', all(T,X,U) * (( input(X) & output(U) & path(X,U) & at(T,X,U)  ) >= (any(T1) * ( less(T,T1) &  at(T1,U,U) ) ) ))
        return 't1',f
Exemplo n.º 5
0
    def graphAxioms(self):
        from pytptp import axiom,annot,all,any
        s  = self.symbols
        less,succ,pred,X,Y,T,Z,U,V =  s.less,s.succ,s.pred,s.X,s.Y,s.T,s.Z,s.U,s.V
        path,edge,input,output,diverge,signal,branch,at,want,crit,block,flop = s.path,s.edge,s.input,s.output,s.diverge,s.signal,s.branch,s.at,s.want,s.crit,s.block,s.flop
        T,T1,T2,A,B = s.T,s.T1,s.T2,s.A,s.B

        posEdges = set(self.edges.values())
        inputNodes = [X==v for v in self.vertices.values() if v.isInput()]
        outputNodes = [X==v for v in self.vertices.values() if v.isOutput()]
        divergentNodes = [X==v for v in self.vertices.values() if v.isDivergent()]

        f =  annot('')

        f +=  annot('*** Axiomy nadrazi ***')
        f +=  annot('Graf')
        f += axiom('graph', reduce(lambda x,y:x&y,(((e in posEdges) and e) or ~e for e in (edge(a,b) for a in self.vertices.values() for b in self.vertices.values()) )))
        f +=  annot('Cesty v grafu')
        f += axiom('path_trans', all(X,Y,Z) * ( ( path(X,Z) & path(Z,Y) ) >= path(X,Y) ))
        f += axiom('path', all(X,Y) * ( ( path(X,Y) ) <= edge(X,Y) ))
        f +=  annot('Enumerace vstupu, vystupu a divergentnich spoju')
        if len(inputNodes)>0:
            f += axiom('input', all(X) * (input(X) == reduce(lambda x,y:x|y, inputNodes ) ) )
        else:
            f +=  axiom('diverge', all(X) * (~input(X) ) )
        if len(outputNodes)>0:
            f += axiom('output', all(X) * (output(X) == reduce(lambda x,y:x|y, outputNodes ) ) )
        else:
            f +=  axiom('diverge', all(X) * (~output(X) ) )
        if len(divergentNodes)>0:
            f += axiom('diverge', all(X) * (diverge(X) == reduce(lambda x,y:x|y, divergentNodes ) ) )
        else:
            f +=  axiom('diverge', all(X) * (~diverge(X) ) )
        f += annot('*** Pohyb vlaku ***')
        f += axiom('at', all(T,Y,U)*(
            at(succ(T),Y,U) == (
                (at(T,Y,U) & (~want(T,Y) | (input(Y) & ~signal(T,Y) ))) |
                (any(X) * (
                    edge(X,Y) & at(T,X,U) & want(T,X) & (
                        (input(X) & signal(T,X))|
                        (diverge(X) & branch(T,X,Y))|
                        (~input(X)&~diverge(X))
                        )
                    ))
                ))
        )

        f += annot('"Vule" strojvudce')
        #f += axiom('want', all(T,X,U) * ( at(T,X,U) >= (input(X) & want(T,X)) | (any(T1) * (less(T,T1) & (all(T2) * (less(T1,T2) &  want(T2,X))) )) ) )
        f += axiom('want1', all(T,X,U) * ( (at(T,X,U)&input(X)&signal(T,X)) >= want(T,X) ) )
        f += axiom('want2', all(T,X,U) * ( (at(T,X,U)&~input(X)) >= (any(T1) * (less(T,T1) & want(T1,X) )) ) )

        f += annot('*** Kriticke stavy ***')
        f += annot('Srazka dvou nebo vice vlaku')
        f += axiom('crit1', all(T) *(
            ( any(X,Y) * (
                at(T,X,U) & (~want(T,X) | (input(Y) & ~signal(T,Y) )) &
                any(Y,V) * (
                    at(T,Y,V) & edge(Y,X) & want(T,Y) &
                    ((input(Y) & signal(T,Y))|(diverge(Y) & branch(T,Y,X))|(~input(Y)&~diverge(Y)))
                    )
                )) >= crit(succ(T))
            ) )

        f += annot('Zmena stavu vyhyby po prijezdu vlaku')
        f += axiom('crit2', all(T) * ( ( any(X,U) * ( diverge(X) & at(T,X,U) & (any(Y,Z) * ((Z!=Y) & branch(T,X,Y) & branch(succ(T),X,Z) ) ) ) ) >= crit(succ(T))) )

        f += annot('Uviznuti vlaku na vstupu')
        f += axiom('crit3', all(T)*( crit(T) <= any(X,U) * ( input(X) & at(T,X,U) & ~ (any(T1) * ( less(T,T1) & signal(T1,X) ) ) ) ) )


        return 'graph',f