Пример #1
0
def concepts_from_sig(symbols,concepts):

    for c in sorted(symbols,key=str):

        dom,rng = c.sort.dom,c.sort.rng

        if il.is_enumerated_sort(rng):
            # TODO: we have no way to display enumerated constants
            if len(dom) in [1,2]:
                vs = [Variable(n,s) for n,s in zip(['X','Y'],dom)]
                ec = concept_from_formula(c(*vs))
                concepts['enum'].append(ec.name)
                concepts[ec.name] = enum_concepts(ec.name,vs,c(*vs))
                for cons in rng.constructors:
                    c1 = add_domain_concept_fmla(concepts,Equals(c(*vs),cons),kind='enum_case')
                    concepts[ec.name].append(c1.name)

        elif il.is_boolean_sort(rng):
            # TODO: we have no way to display boolean constants
            if len(dom) in [1,2,3]:
                vs = [Variable(n,s) for n,s in zip(['X','Y','Z'],dom)]
                add_domain_concept_fmla(concepts,c(*vs))

        elif il.is_first_order_sort(rng):
            if len(dom) == 0:
                add_domain_concept_fmla(concepts,Equals(Variable('X', rng),c))
            elif len(dom) in [1,2]:
                vs = [Variable(n,s) for n,s in zip(['X','Y','Z'],dom+(rng,))]
                fmla = Equals(c(*vs[0:-1]),vs[-1])
                add_domain_concept_fmla(concepts,fmla)
Пример #2
0
def initial_concept_domain(sorts):

    concepts = OrderedDict()

    concepts['nodes'] = []
    concepts['node_labels'] = []
    concepts['edges'] = []

    # add the requested nodes
    for sort in sorts:
        X = Variable('X', sort)
        add_domain_concept(concepts,Equals(X,X),name=sort.name,kind='nodes')

    # add equality concept
    if False:
        X = Variable('X', TopSort())
        Y = Variable('Y', TopSort())
        concepts['='] = co.Concept([X, Y], Equals(X, Y))

    # add concepts from the signature
    for c in sorted(all_symbols(),key=str):

        dom,rng = c.sort.dom,c.sort.rng

        if il.is_enumerated_sort(rng):
            # TODO: we have no way to display enumerated constants
            if len(dom) in [1,2]:
                for cons in rng.constructors:
                    vs = [Variable(n,s) for n,s in zip(['X','Y'],dom)]
                    add_domain_concept(concepts,Equals(c(*vs),cons))

        elif il.is_boolean_sort(rng):
            # TODO: we have no way to display boolean constants
            if len(dom) in [1,2]:
                vs = [Variable(n,s) for n,s in zip(['X','Y'],dom)]
                add_domain_concept(concepts,c(*vs))

        elif il.is_first_order_sort(rng):
            if len(dom) == 0:
                add_domain_concept(concepts,Equals(Variable('X', rng),c))
            elif len(dom == 1):
                fmla = Equals(c(Variable('X', dom[0])),Variable('Y', rng))
                add_domain_concept(concepts,fmla)
                
    return co.ConceptDomain(concepts, co.get_standard_combiners(), co.get_standard_combinations())
Пример #3
0
def concepts_from_sig(symbols,concepts):

    for c in sorted(symbols,key=str):

        dom,rng = c.sort.dom,c.sort.rng

        if il.is_enumerated_sort(rng):
            if len(dom) in [0,1,2]:
                if len(dom) == 0:
                    if c in il.sig.constructors:
                        continue
                    # Hack: we treat enumerated constants as labels on the bogus sort "unit"
                    vs,xvs = [],[Variable('X',create_unit_sort(concepts))]
                else:
                    vs,xvs = [Variable(n,s) for n,s in zip(['X','Y'],dom)],None
                ec = concept_from_formula(c(*vs),vs=xvs)
                concepts['enum'].append(ec.name)
                concepts[ec.name] = enum_concepts(ec.name,vs,c(*vs))
                for cons in rng.constructors:
                    c1 = add_domain_concept_fmla(concepts,Equals(c(*vs),cons),kind='enum_case',vs=xvs)
                    concepts[ec.name].append(c1.name)                

        elif il.is_boolean_sort(rng):
            # TODO: we have no way to display boolean constants
            if len(dom) in [0,1,2,3]:
                if len(dom) == 0:
                    if c in il.sig.constructors:
                        continue
                    # Hack: we treat boolean constants as labels on the bogus sort "unit"
                    vs,xvs = [],[Variable('X',create_unit_sort(concepts))]
                else:
                    vs,xvs = [Variable(n,s) for n,s in zip(['X','Y','Z'],dom)],None
                add_domain_concept_fmla(concepts,c(*vs),vs=xvs)

        elif il.is_first_order_sort(rng):
            if len(dom) == 0:
                add_domain_concept_fmla(concepts,Equals(Variable('X', rng),c))
            elif len(dom) in [1,2]:
                vs = [Variable(n,s) for n,s in zip(['X','Y','Z'],dom+(rng,))]
                fmla = Equals(c(*vs[0:-1]),vs[-1])
                add_domain_concept_fmla(concepts,fmla)
Пример #4
0
def standard_graph(parent_state=None):
    sorts = [s for s in il.sig.sorts.values() if il.is_first_order_sort(s)]
    g = Graph(sorts,parent_state)
    return GraphStack(g)
Пример #5
0
def is_bv_term(self):
    return (il.is_first_order_sort(self.sort)
            and self.sort.name in il.sig.interp
            and il.sig.interp[self.sort.name].startswith('bv['))