subtypes
을 Coq
에 연습하고 ssreflect
을 사용하여 사물을 단순화하려고합니다. 하지만 하위 유형을 다시 작성할 때는 항상 문제가 발생합니다. 예 :하위 유형 Coq
Require Import Omega.
From mathcomp Require Import ssreflect ssrfun ssrbool ssrnat eqtype.
(* a type A to build X *)
Inductive A: Set :=
| mkA: nat -> A.
Definition getNat_A (a: A) :=
match a with
| mkA n => n
end.
Inductive X: Set :=
| r1 : A -> X.
(* subtype of X that satisfying some property *)
Definition Instantiated_X (x : X) : bool :=
match x with
| r1 a => (getNat_A a) > 10
end.
Definition iX : Set := {x:X | (Instantiated_X x)}.
(* rewrite constructor of X, stating the fact of elements of A, under certain condition creates element of iX *)
Program Definition r1_rewrite : A -> option iX :=
fun a: A =>
match (Instantiated_X (r1 a)) with
| true => Some (exist _ (r1 a) _)
| false => None
end.
(* try to prove r1_rewrite is surjective *)
Example r1_rewrite_surj:
forall t : iX, exists (a : A),
match (r1_rewrite a) with
| None => True
| Some e => eq t e
end.
Proof.
intros.
destruct t eqn: caseiX.
destruct x eqn: caseX.
exists a.
destruct (r1_rewrite a) eqn: r_res.
- destruct (10 < getNat_A a) eqn: guard.
destruct i0.
destruct x0.
unfold r1_rewrite in r_res.
simpl in r_res.
rewrite <- guard in r_res. (* <- stuck *)
Abort.
왜 거기에 붙어 있는지 이해할 수 없었습니다. 오류 메시지의 말 :
Error: Abstracting over the term "true" leads to a term: ...
which is ill-typed.
나는 COQ이 같은 리드하는 r_res
에 true
와 (10 < getNat_A a)
의 모든 항목을 바꾸 것이라고 생각 :
Some (exist (fun x : X => Instantiated_X x) (r1 a)
(r1_rewrite_obligation_1 a Heq_anonymous) =
Some (exist (fun x : X => Instantiated_X x) (r1 a0) i0)
및 proof irrelevance
및 r1 injectivity
에 의해, 내 증거가 갈 수 있습니다 을 통하여. 그래서, 나는이 경우에 r_res
을 어떻게 마사지 할 수 있는지에 대한 포인터를 얻을 수 있을지 궁금해합니다. 그래서 재 작성을 용이하게합니다.
편집 : 증명서 시도와
여기서 무엇을하려고하는지 잘 모르겠지만 어쩌면'insub'과'insubK' 보조 정리가 도움이 될 수 있습니다. [주입 성은 역행렬을 가짐으로써 발생한다. – ejgallego
또한이 예제에서는 Eq 클래스와 인스턴스가 실제로 필요하지 않음을 알 수 있습니다. –