如何通过Java API在Z3中生成字符串常量。

huangapple go评论71阅读模式
英文:

how to generate string const in z3 through java-api

问题

In z3's Java API, you can generate a string constant using ctx.mkString("a"). However, there is no direct equivalent to ctx.mkStringConst("a") as in Python.

英文:

How can I generate string const in z3 through java-api? For integer, there are ctx.mkInt(int a) generate an IntExpr with value a and ctx.mkIntConst("a") generate an IntExpr with name "a". However, for string, I can only find ctx.mkString("a"), which is just a SeqExpr with value "a" similar as ctx.mkInt. So what I want is something like ctx.mkStringConst("a") but there is no such function.

I find in python api, what I want is is simply str = String("a")

答案1

得分: 1

尝试以下。

String variable_name = "foo";
Expr variable = context.mkConst(context.mkSymbol(variable_name), context.mkStringSort());


<details>
<summary>英文:</summary>

Try the following.

String variable_name="foo";
Expr variable = context.mkConst(context.mkSymbol(variable_name), context.mkStringSort());


</details>



huangapple
  • 本文由 发表于 2020年7月29日 15:17:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/63148263.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定