Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Coq 使用ssreflect进行子类型化_Coq_Subtype_Ssreflect - Fatal编程技术网

Coq 使用ssreflect进行子类型化

Coq 使用ssreflect进行子类型化,coq,subtype,ssreflect,Coq,Subtype,Ssreflect,我一直试图学习如何使用ssreflect作为我的主要参考来进行子类型划分,但一直遇到问题。我要做的是从一个包含三个术语的类型T,创建一个包含两个术语a,b的子类型T'。 (1) {x:T | px}和亚型P之间有什么区别? (2) 从我下面的代码中,我有Sub a Pa作为T'的一个术语,是否可以有一个适用于a,b的通用证明?我在这里感到困惑,因为eqType.v感觉好像insub是用来从一个类型投射到它的子类型的 From mathcomp Require Import ssreflect s

我一直试图学习如何使用ssreflect作为我的主要参考来进行子类型划分,但一直遇到问题。我要做的是从一个包含三个术语的类型
T
,创建一个包含两个术语
a,b
的子类型
T'
。 (1)
{x:T | px}
亚型P
之间有什么区别? (2) 从我下面的代码中,我有
Sub a Pa
作为
T'
的一个术语,是否可以有一个适用于
a,b
的通用证明?我在这里感到困惑,因为
eqType.v
感觉好像
insub
是用来从一个类型投射到它的子类型的

From mathcomp Require Import ssreflect ssrfun ssrbool eqtype.

Inductive T : Set := a | b | c.

Definition P := fun (x:T) =>
 match x with
 | a => true
 | b => true
 | c => false
 end.

 Definition T' := {x:T | P x}.
 Definition T'' := subType P.

 Definition cast (x: T) : option T'.
 destruct (P x) eqn:prf.
 - exact (Some (exist _ x prf)).
 - exact None.
 Defined.


 Definition Pa : is_true (P a).
   destruct (P a) eqn:prf.
   exact. simpl in prf. unfold is_true. symmetry. apply prf. Defined.

 Check (Sub a Pa) : T'.

 Check val (Sub a Pa) : T.

 Check insub (val (Sub a Pa)) : option T'.

 Definition Px :forall x : T, is_true (P x).
  intros x. destruct (P x) eqn:prf.
  - unfold is_true. reflexivity.
  - unfold is_true.
  Abort. 
(1) {x:T | px}和p亚型之间有什么区别

subType p
是包含
p
建立某些类型的子类型的所有相关证明的记录
val:U->T

{x:T | px}
是一个常规的sigma类型,如果
p
是一个布尔谓词,那么math comp已经声明了一种为该类型构建
子类型p
记录的规范方法

(2) 根据我下面的代码,我将Pa分为T'一词,是否可以 有适用于a和b的一般证明吗?我在这里也很困惑 从eqType.v中,感觉insub就是用来 从类型投影到其子类型

From mathcomp Require Import ssreflect ssrfun ssrbool eqtype.

Inductive T : Set := a | b | c.

Definition P := fun (x:T) =>
 match x with
 | a => true
 | b => true
 | c => false
 end.

 Definition T' := {x:T | P x}.
 Definition T'' := subType P.

 Definition cast (x: T) : option T'.
 destruct (P x) eqn:prf.
 - exact (Some (exist _ x prf)).
 - exact None.
 Defined.


 Definition Pa : is_true (P a).
   destruct (P a) eqn:prf.
   exact. simpl in prf. unfold is_true. symmetry. apply prf. Defined.

 Check (Sub a Pa) : T'.

 Check val (Sub a Pa) : T.

 Check insub (val (Sub a Pa)) : option T'.

 Definition Px :forall x : T, is_true (P x).
  intros x. destruct (P x) eqn:prf.
  - unfold is_true. reflexivity.
  - unfold is_true.
  Abort. 
我不确定你的意思<代码>insub不“投影”,但尝试嵌入[这并非总是可能的]。在您的情况下,证明非常简单,您不必将事情复杂化:

From mathcomp Require Import all_ssreflect.

Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.

Inductive T : Set := a | b | c.

Definition is_ab (x:T) : bool := match x with
 | a | b => true
 | c => false
 end.

Definition abT := { x : T | is_ab x }.

Lemma abT_is_ab (x : abT) : is_ab (val x).
Proof. exact: valP. Qed.
(1) {x:T | px}和p亚型之间有什么区别

subType p
是包含
p
建立某些类型的子类型的所有相关证明的记录
val:U->T

{x:T | px}
是一个常规的sigma类型,如果
p
是一个布尔谓词,那么math comp已经声明了一种为该类型构建
子类型p
记录的规范方法

(2) 根据我下面的代码,我将Pa分为T'一词,是否可以 有适用于a和b的一般证明吗?我在这里也很困惑 从eqType.v中,感觉insub就是用来 从类型投影到其子类型

From mathcomp Require Import ssreflect ssrfun ssrbool eqtype.

Inductive T : Set := a | b | c.

Definition P := fun (x:T) =>
 match x with
 | a => true
 | b => true
 | c => false
 end.

 Definition T' := {x:T | P x}.
 Definition T'' := subType P.

 Definition cast (x: T) : option T'.
 destruct (P x) eqn:prf.
 - exact (Some (exist _ x prf)).
 - exact None.
 Defined.


 Definition Pa : is_true (P a).
   destruct (P a) eqn:prf.
   exact. simpl in prf. unfold is_true. symmetry. apply prf. Defined.

 Check (Sub a Pa) : T'.

 Check val (Sub a Pa) : T.

 Check insub (val (Sub a Pa)) : option T'.

 Definition Px :forall x : T, is_true (P x).
  intros x. destruct (P x) eqn:prf.
  - unfold is_true. reflexivity.
  - unfold is_true.
  Abort. 
我不确定你的意思<代码>insub不“投影”,但尝试嵌入[这并非总是可能的]。在您的情况下,证明非常简单,您不必将事情复杂化:

From mathcomp Require Import all_ssreflect.

Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.

Inductive T : Set := a | b | c.

Definition is_ab (x:T) : bool := match x with
 | a | b => true
 | c => false
 end.

Definition abT := { x : T | is_ab x }.

Lemma abT_is_ab (x : abT) : is_ab (val x).
Proof. exact: valP. Qed.

我对
insub
的理解是针对
x:T
insub x:abT
,因为它是
T
T
的子类型
S
的一般部分投影,同样对于
x:abT
,我们将有
val x:T
。您还可以进一步解释引理
abT_is_ab
及其用法吗?引理
abT_is_ab
只是
valP
的别名,也就是说,子类型的每个元素都满足
P
谓词。证明是琐碎的,相当于破坏记录,如果我们能更好地支持math comp
valP
中的原始投影,它将在定义上保持不变
insub x
只检查子类型中是否有元素
x
。它相当于检查
px
的结果。注意
insub x:option abT
,因为任何元素
x:T
都不满足
ab
谓词。我对
insub
的理解是针对
x:T
insub x:abT
,因为它是
T
的子类型
S
的一般部分投影,同样,对于
x:abT
,我们将有
valx:T
。您还可以进一步解释引理
abT_is_ab
及其用法吗?引理
abT_is_ab
只是
valP
的别名,也就是说,子类型的每个元素都满足
P
谓词。证明是琐碎的,相当于破坏记录,如果我们能更好地支持math comp
valP
中的原始投影,它将在定义上保持不变
insub x
只检查子类型中是否有元素
x
。它相当于检查
px
的结果。注意
insub x:option abT
,因为任何元素
x:T
都不满足
ab
谓词。