- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对使用通用量词和不使用 forall 的 declare-const 感到有些困惑
(set-option :mbqi true)
(declare-fun f (Int Int) Int)
(declare-const a Int)
(declare-const b Int)
(assert (forall ((x Int)) (>= (f x x) (+ x a))))
我可以这样写:
(declare-const x Int)
(assert (>= (f x x) (+ x a))))
with Z3 将在这两种情况下探索 Int 类型的所有可能值。那么有什么区别呢?我真的可以使用 declare-const 来消除 forall 量词吗?
最佳答案
不,陈述不同。 Z3 中的常量是 nullary (0 arity) 函数,所以 (declare-const a Int)
只是 (declare-fun a () Int)
的语法糖,所以这些两个陈述是相同的。您的第二个语句 (assert (>= (f x x) (+ x a))))
隐式断言 x 的存在,而不是像第一个语句 (assert (forall (( x Int)) (>= (f x x) (+ x a))))
。为了清楚起见,请注意在您的第二个语句中,只有一个对 x 的赋值需要满足断言,而不是所有可能的赋值(还要注意函数 f 的区别,请参阅此 Z3@rise 脚本:http://rise4fun.com/Z3/4cif)。
这是该脚本的文本:
(set-option :mbqi true)
(declare-fun f (Int Int) Int)
(declare-const a Int)
(declare-fun af () Int)
(declare-const b Int)
(declare-fun bf () Int)
(push)
(declare-const x Int)
(assert (>= (f x x) (+ x a)))
(check-sat) ; note the explicit model value for x: this only checks a single value of x, not all of them
(get-model)
(pop)
(push)
(assert (forall ((x Int)) (>= (f x x) (+ x a))))
(check-sat)
(get-model) ; no model for x since any model must satisfy assertion
(pop)
此外,这是 Z3 SMT 指南中的一个示例(http://rise4fun.com/z3/tutorial/guide 来自“未解释的函数和常量”部分):
(declare-fun f (Int) Int)
(declare-fun a () Int) ; a is a constant
(declare-const b Int) ; syntax sugar for (declare-fun b () Int)
(assert (> a 20))
(assert (> b a))
(assert (= (f 10) 1))
(check-sat)
(get-model)
关于z3 - 我可以使用 declare-const 来消除 forall 通用量词吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13241938/
我是正则表达式的新手,我正在浏览 the regex quantifier section .我对 * 量词有疑问。下面是 * 量词的定义: X* - 没有找到或找到多个字母 X .* - 任何字符序
我想证明以下定理: Theorem Frobenius (A: Set) (q: Prop) (p: A -> Prop) : (q \/ forall x : A, p x) -> (foral
例子: /(?:Foo){0}bar/ 我在另一个答案中看到了类似的内容。起初我想“那应该是什么”,但后来,“好吧,有点消极的看法”,所以 Foo之前不允许 bar ,但这不起作用。 你可以看到这个
添加/删除“+”不会改变输出。但我也没有收到任何错误。 “+”在这里做什么? /.{3}+/g 最佳答案 “+”在这里无效,可能是你的意思 /(.{3})+/g 关于javascript - 正则表达
基本上我有以下字符串:http:/www.-woejfewiofjewow不允许匹配 我的正则表达式:http://(www\.[^-])?[^-].* (我用 regexr.com 来检查它..)
我的正则表达式以量词 * 结尾。但是我在字符串中几乎没有匹配项。我怎样才能让它仍然找到所有匹配项?我的正则表达式: ((CMD1|CMD2)+(?::|;)+.*) 测试字符串为"cmd1: test
关于Eloquent JavaScript这本书chapter 9: Regular Expressions在“解析 INI 文件”部分下有一个示例,其中包含一个我根本听不懂的正则表达式。作者正在尝试
假设我们有一个类型构造函数 f,它通过 DataKinds-promoted 对接受两种类型。 forall (f :: (ka, kb) -> *) 然后我可以实现一个函数 forward ,就像
有forAll量词返回一个检查所有测试用例是否通过的属性。有没有办法定义一个“存在”量词,它返回一个属性来检查它至少一个测试用例是否通过? 最佳答案 通过枚举测试存在会更可靠:SmallCheck ,
我可以知道以下代码的输出为:1,10,10 的原因吗?为什么不是这样:10, 10? var str="1, 100 or 1000?"; var patt1=/10?/g; document.wr
我要匹配模式的表达式 空格后跟(加法运算符或减法运算符) 例如:"+" 应该返回 True 我已经尝试在以下正则 exp 上使用 std::regex_match: "[+-]", "\\s[+-]"
我想不出我想使用 ?? 的情况在正则表达式中,但也许我想得还不够仔细。 最佳答案 也许是一个分隔符分隔的列表,并且您不想匹配任何终止分隔符。 ^((?:[^,]+,??)+),?$ 那将捕获 "a,b
当我尝试 Regex.Replace() 方法时失败。我该如何解决? Replace.Method (String, String, MatchEvaluator, RegexOptions) 我试试
正则表达式{n,m}量词: {n,m}量词可以重复前面匹配的字符n-m次,至少n次,最多m次。 语法结构: 构造函数方式: ?
当我声明这个新类型时: newtype ListScott a = ListScott { unconsScott :: (a -> ListScott a -> r) -> r -> r }
我是正则表达式的新手,我想找到“po”的所有实例及其变体(即“p.o. | p.o. | p o”)后跟“box”的变体,因为我很感兴趣在采购订单中,而不是在邮政信箱中。下面的代码不起作用,即使它后面
大家好。 我有以下结构和类, template struct Node { T DataMember; Node* Next; }; template class NCA {
在下面的代码中,如何让 Specs2 执行第一个测试? “print ones”测试在它应该失败的时候通过了。由于 new Scope,forAll() 部分中的代码未执行。 println 语句仅用
我是一名优秀的程序员,十分优秀!