loop-invariant

    2热度

    1回答

    我开始学习Dafny并学习了不变式。我有这样的代码: function pot(m:int, n:nat): int { if n==0 then 1 else if n==1 then m else if m==0 then 0 else pot(m,n-1) * m } method Pot(m:int, n:nat) returns (x:int

    0热度

    1回答

    我正在研究如何使用dafny验证使用“交换”相邻元素的插入排序,但我无法找到while循环的合理不变量,谁能帮我修复它? 这里是链接:http://rise4fun.com/Dafny/wmYME

    0热度

    1回答

    k :=0 for i ←1 to n c←a[i] k←k+1 这并没有改变的事情是要知道元素

    3热度

    1回答

    我有一个函数sum采用两个阵列a和b作为输入并修改b使得b[i] = a[0] + a[1] + ... + a[i]。我写了这个函数,想用Dafny来验证它。但是,Dafny告诉我,我的循环不变可能不会被循环维护。这里是代码: function sumTo(a:array<int>, n:int) : int requires a != null; requires 0 <=

    2热度

    1回答

    我们知道循环变体被定义为在循环的每次迭代之前和之后都是真的语句。但是这个定义太松了吗?让我们看一个具体的例子:线性搜索。 输入:索引:n个A =(A 1 ,一个,一个,...,一个Ñ)和一个值v 输出的序列我使得v = A [1]或NIL如果v是没有在甲 这里发现是我的伪代码: linear_search(A, v) 1 for i ∈ {1, 2, ..., n} 2 if A[i] =

    0热度

    1回答

    前提条件:len(list)> = 2的整数列表 后置条件:返回第二小的值。如果列表中存在两个最小值,则返回最小值。 def SecondSmallest(list): 1 smallest = min(list[0], list[1]) 2 second_smallest = max(list[0], list[1]) 3 i = 2 4 while i < len(list): 5

    1热度

    2回答

    import tensorflow as tf cluster_size = tf.constant(6) # size of the cluster m = tf.constant(6) # number of contigs (column size) n = tf.constant(3) # number of points in a single contigs (column s

    2热度

    1回答

    有关终止函数定义的问题。 我们有一个相对简单的函数来计算输入的₂log2n⌋。 LOG2 Configuration: {[r, n] | Integers r ≥ 0 and n ≥ 1} [r, n] -> [r + 1, n/2] if n > 1 ∧ n even [r, n] -> [r, n − 1] if n > 1 ∧ n odd 而且我们问过一些终端功能μ(R,N)是否

    17热度

    1回答

    考虑解决100 prisoners and a lightbulb问题的标准策略。这是我尝试它Dafny型号: method strategy<T>(P: set<T>, Special: T) returns (count: int) requires |P| > 1 && Special in P ensures count == (|P| - 1) decrea

    2热度

    1回答

    我有一个数组“行”,其中包含一个字符串中包含长度“l”和一个数组“nl”,其中包含一个字符串中的长度“p”。 注意:“l”和“p”不一定是每个对应数组的长度。参数“at”将是在“line”内进行插入的位置。 恢复:长度为“p”的数组将被插入到“行”中,将位置(at,i,at + p),'p'位置之间的所有字符移动到右边以便插入。 我确保的逻辑是检查插入“行”的元素是否具有相同的顺序,并且与包含在“