标签: totality

Agda中有哪些大小的类型?

Agda中有哪些大小的类型?我试图阅读有关MiniAgda的文章,但由于以下几点未能继续:

  1. 为什么数据类型超出其大小?据我所知,大小是感应树的深度.
  2. 为什么数据类型在其大小上是协变的,即i <= j - > T_i <= T_j?
  3. 这些>#模式意味着什么?

types type-systems agda induction totality

11
推荐指数
1
解决办法
605
查看次数

在Coq中定义Ackermann时出错

我试图在Coq中定义Ackermann-Peters函数,我收到一条我不明白的错误消息.正如你所看到的,我把a, bAckermann 的论据打包成一对ab; 我提供了一个定义参数的排序函数的排序.然后我使用Function表单来定义Ackermann本身,为它提供ab参数的排序函数.

Require Import Recdef.    
Definition ack_ordering (ab1 ab2 : nat * nat) :=
    match (ab1, ab2) with
    |((a1, b1), (a2, b2)) => 
       (a1 > a2) \/ ((a1 = a2) /\ (b1 > b2))   
    end.
Function ack (ab : nat * nat) {wf ack_ordering} : nat :=
match ab with
| (0, b) => b + 1
| (a, 0) => ack (a-1, 1)
| (a, b) => ack (a-1, …
Run Code Online (Sandbox Code Playgroud)

coq ackermann totality

9
推荐指数
1
解决办法
1336
查看次数

程序修复点的Coq简化

有喜欢的战术什么simplProgram FixpointS'

特别是,如何证明以下琐碎的陈述?

Program Fixpoint bla (n:nat) {measure n} :=
match n with
| 0 => 0
| S n' => S (bla n')
end.

Lemma obvious: forall n, bla n = n. 
induction n. reflexivity.
(* I'm stuck here. For a normal fixpoint, I could for instance use 
simpl. rewrite IHn. reflexivity. But here, I couldn't find a tactic 
transforming bla (S n) to S (bla n).*)
Run Code Online (Sandbox Code Playgroud)

显然,Program Fixpoint这个玩具示例没有必要,但我在一个更复杂的设置中面临同样的问题,我需要证明Program Fixpoint手动终止.

theorem-proving coq totality

9
推荐指数
1
解决办法
698
查看次数

Coq中Fixpoint的局限性?

我和Coq鬼混.具体来说,我试图实现mergesort,然后证明它的工作原理.

我尝试实施的是:

Fixpoint sort ls :=
match ls with
| nil => nil
| cons x nil => cons x nil
| xs =>
  let (left, right) := split xs nil nil
  in merge (sort left) (sort right)
end.
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

Error:
Recursive definition of sort is ill-formed.
In environment
sort : list nat -> list nat
ls : list nat
x : nat
l : list nat
y : nat
l0 : list nat
left : list nat
right : …
Run Code Online (Sandbox Code Playgroud)

coq totality

7
推荐指数
1
解决办法
1562
查看次数

如果伊德里斯认为事情可能完全没有,那么伊德里斯可以用于证明吗?

http://docs.idris-lang.org/en/v0.99/tutorial/theorems.html#totality-checking-issues指出:

其次,到目前为止,目前的实施工作进展有限,因此可能仍然存在一种情况,即它认为功能是总的而不是.不要依赖它来证明你的证明!

这是否意味着不能依赖Idris作为证据,或者是否有办法创建不需要整体检查的证明?

proof idris totality

7
推荐指数
1
解决办法
202
查看次数

程序修复点和Coq中的函数有什么区别?

他们似乎服务于类似的目的.到目前为止我注意到的一个区别是,虽然Program Fixpoint会接受一个复合测量{measure (length l1 + length l2) },但Function似乎拒绝这个并且只会允许{measure length l1}.

是否Program FixpointFunction它们更强大,或者它们更适合不同的用例?

coq totality

7
推荐指数
1
解决办法
887
查看次数

Defining recursive function over product type

I'm trying to formalize each integer as an equivalence class of pairs of natural numbers, where the first component is the positive part, and the second component is the negative part.

Definition integer : Type := prod nat nat.

I want to define a normalization function where positives and negatives cancel as much as possible.

Fixpoint normalize (i : integer) : integer :=
let (a, b) := i in
match a with
| 0 => (0, b)
| S a' …
Run Code Online (Sandbox Code Playgroud)

termination coq totality

6
推荐指数
3
解决办法
108
查看次数

无法猜测Coq中嵌套匹配的fix递减参数

我对术语有以下定义:

Inductive term : Type :=
  | Var : variable -> term
  | Func : function_symbol -> list term -> term.
Run Code Online (Sandbox Code Playgroud)

一个函数,该函数pos_list获取术语列表并为每个子术语返回“位置”列表。例如,对于[Var "e"; Func "f" [Var "x"; Func "i" [Var "x"]]]我来说,应该知道[[1]; [2]; [2; 1]; [2; 2]; [2; 2; 1]]每个元素在子项的树层次结构中的位置。

Definition pos_list (args:list term) : list position :=
  let fix pos_list_aux ts is head :=
    let enumeration := enumerate ts in
      let fix post_enumeration ts is head :=
        match is with
        | [] => [] …
Run Code Online (Sandbox Code Playgroud)

functional-programming coq totality

5
推荐指数
1
解决办法
1186
查看次数

Coq无法计算通过Fix定义的充分依据,但如果使用Program Fixpoint定义则可以计算

为了通过一个良好的关系理解递归,我决定实现扩展的欧几里得算法。

扩展的欧几里得算法适用于整数,因此我需要一些关于整数的良好依据。我尝试使用中的关系Zwf,但没有任何效果(我需要查看更多示例)。我认为使用该函数映射Z起来会更容易,然后将其用作关系即可。我们的朋友来帮助我。所以这是我做的:natZ.abs_natNat.ltwf_inverse_image

Require Import ZArith Coq.ZArith.Znumtheory.
Require Import Wellfounded.

Definition fabs := (fun x => Z.abs_nat (Z.abs x)). (* (Z.abs x) is a involutive nice guy to help me in the future *) 
Definition myR (x y : Z) := (fabs x < fabs y)%nat.
Definition lt_wf_on_Z := (wf_inverse_image Z nat lt fabs) lt_wf.
Run Code Online (Sandbox Code Playgroud)

扩展的欧几里得算法如下所示:

Definition euclids_type (a : Z) := forall b : Z, Z * Z * Z.

Definition euclids_rec …
Run Code Online (Sandbox Code Playgroud)

recursion coq totality

5
推荐指数
1
解决办法
176
查看次数

Coq中的相互递归功能和终止检查器

编辑

Require Import Bool List ZArith.
  Variable A: Type.
    Inductive error :=
    | Todo.
    Inductive result (A : Type) : Type :=
        Ok : A -> result A | Ko : error -> result A.
    Variable bool_of_result : result A -> bool.
    Variable rules : Type.
    Variable boolean : Type.
    Variable positiveInteger : Type.
    Variable OK: result unit.
    Definition dps := rules.
    Inductive dpProof := 
      | DpProof_depGraphProc : list 
       (dps * boolean * option (list positiveInteger) * option dpProof) -> …
Run Code Online (Sandbox Code Playgroud)

coq totality

4
推荐指数
1
解决办法
862
查看次数