Giter Club home page Giter Club logo

Comments (2)

NikolajBjorner avatar NikolajBjorner commented on July 25, 2024

this is expected behavior: When you translate from one context to another, the new context inherits data-type declarations from the first.

from z3.

shack avatar shack commented on July 25, 2024

First, thanks for looking at it. It doesn't seem to be the behavior for all data types:

from z3 import *

def decl_A(ctx):
    s = Datatype('A', ctx=ctx)
    s.declare('b')
    s.declare('c')
    return s.create()

c = Context()
m = main_ctx()
decl_A(ctx=c)
x = Int('x', ctx=c)
x.translate(m)
decl_A(ctx=m)

does not throw any exception. I did not check if the data type A is not translated back or just overwritten by the second declaration. Nevertheless, shouldn't the behavior be the same for all data types?

IMHO translating should only translate those data types the variable is dependent on, so I would expect the behavior of this example. But I might be wrong here.

To explain a bit further what I was doing: I was using context as namespaces. I have a function that solves a couple of SMT problems and declares data types to do that. It creates a context to keep these declarations local, translates in formulas from the main context, and translates the solutions (which don't use the data types) back to the main context. If that translation also translates back all the data types defined in that local context, I can basically not localize these declarations in a context because subsequent calls to that function will inherit the data type declarations from the main context to which they have been translated to by prior calls.

from z3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.