【发布时间】:2021-09-15 09:13:25
【问题描述】:
通过Separation Logic Foundations,我被困在Repr.v 中的triple_mlength 练习上。我认为我目前的问题是我不知道如何在 Coq 中处理 int 和 nat。
Lemma triple_mlength: forall (L: list val) (p:loc),
triple (mlength p)
(MList L p)
(fun r => \[r = val_int (length L)] \* (MList L p))
Check (fun L => val_int (length L)) 不会抛出错误,这意味着 length 可以是 int。但是,长度是不透明的,我无法展开它。
我目前的背景和目标:
x : val
p : loc
C : p <> null
x0 : loc
H : p <> null
xs : list val
IH : forall y : list val,
list_sub y (x :: xs) ->
forall p, triple (mlength p)
(MList y p)
(fun r:val => \[r = length y] \* MList y p)
______________________________________________________________
length xs + 1 = length (x :: xs)
取消设置目标转换为的打印符号:
eq (Z.add (length xs) (Zpos xH)) (length (cons x xs))
我认为试图将 (1:Z) 添加到 (length xs: nat),然后将其与 (length (cons x xs) : nat) 进行比较
类型:
Inductive nat : Set := O : nat
| S : nat -> nat
Inductive Z : Set := Z0 : int
| Zpos : positive -> int
| Zneg : positive -> int
list: forall A, list A -> nat
length: forall A, list A -> nat
val_int: int -> val
Coq 版本是 8.12.2
【问题讨论】:
标签: coq proof theorem-proving