如何在MicrosoftZ3中执行sincos操作

如何在MicrosoftZ3中执行sincos操作,z3,smt,Z3,Smt,在MicrosoftZ3DotNetAPI中,没有执行sincos操作的函数。当我在线查看时,我发现可以通过将函数转换为笛卡尔坐标来计算sin和cos函数值 例如: if x = cos(theta) and y = sin(theta) x^2 + y^2 = 1 使用这个逻辑,我们可以为sincos函数生成值 我可以生成以下代码: (set-info :status sat) (set-option :pp.decimal true) (set-option :model_validat

在MicrosoftZ3DotNetAPI中,没有执行sincos操作的函数。当我在线查看时,我发现可以通过将函数转换为笛卡尔坐标来计算sin和cos函数值

例如:

if x = cos(theta) and y = sin(theta)
x^2 + y^2 = 1
使用这个逻辑,我们可以为sincos函数生成值

我可以生成以下代码:

(set-info :status sat)

(set-option :pp.decimal true)
(set-option :model_validate false)

(declare-fun x () Real)
(declare-fun y () Real)
(declare-fun theta () Real)

(assert (= (cos theta) x))
(assert (= (sin theta) y))
(assert (= (+ (* x x) (* y y)) 1))
(check-sat-using qfnra-nlsat)
(get-model)
(reset)
我现在得到的输出如下:

sat
(model 
  (define-fun x () Real
    0.125)
  (define-fun y () Real
    (- 0.9921567416?))
  (define-fun theta () Real
    (+ (acos (- 0.125)) pi))
)
我不清楚的是,如何得到给定θ在Z3中的sin(θ)或cos(θ)值?有人能帮我做smt代码吗


我在结果中得到的“(+(acos(-0.125))pi”)值是多少?

我不确定这在所有可能的情况下都会起作用(nlsat有点特殊),但您可以使用
get value
获得在模型下计算的任意表达式,例如,在
之后(使用…
检查sat),您可以添加

(get-value (theta))
(get-value ((sin theta)))
得到

((theta (+ (acos (- 0.125)) pi)))
(((sin theta) (- 0.9921567416?)))
请注意,
表示该值已被截断;有一些选项可以调整精度。例如,如果没有
pp.decimal=true
,则精确结果报告为

(((sin theta) (root-obj (+ (* 64 (^ x 2)) (- 63)) 1)))
(代数数)