Parametric type variables and Datatype parameters #7562
philzook58
started this conversation in
General
Replies: 1 comment
-
I'm also unclear what happens when Arrays have polymorphic arguments or results. Here is an attempt to write down and apply a recursor for the Nats. from z3 import *
Nat = Datatype("Nat")
Nat.declare("Z")
Nat.declare("S", ("pred", Nat))
Nat = Nat.create()
a = DeclareTypeVar("a")
x = Const("x", Nat)
base = Const("base", a)
f = Const("f", ArraySort(a, a))
rec = Function("rec", Nat, a, ArraySort(a, a), a)
rec(x, base, f) == If(x == Nat.Z, base, f[rec(Nat.pred(x), base, f)]) # This is fine
p = Array("p", Nat, Nat)
rec(Nat.Z, Nat.Z, p) # This is a Sort mismatch error |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using the python API for building a proof assistant. I can deal with notions of genericity via using python functions
def List(T): ...
that build new sorts for particular instantiations of Lists or tuples say, but it would be nice to have the notion ofList<A>
available. AFAIK this is in the syntax of smtlib but not available through the bindings? Maybe I could useparse_smtlib2_string
to get more functionality here than what is available though the api? I'm not sure if the new smtlib2.7 has bearing on this or not.There is what I understand to be tentative support for
DeclareTypeVar
which would be preferable to using the meta python when I want to translate some Isabelle or HOL light axiomatization as they use at least parametric types liberally.The current behavior of type variables seems to be doing something like existential types when they go into the definition of a datatype.
I'm not exactly clear on what I may be missing or suggesting, so I thought maybe initiating a discussion could be helpful. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions