I just started using Coq.
How can I define the proposition myProp
such that, given a set H
, myProp H
is true iff ?
In particular, how can I express the fact that H
is a subset of nat
in a proposition? Or how can I simply state let H be a subset of nat?
答案 0 :(得分:6)
You are in type theory, so the notion of subset does not exists exactly in the same manner as in set theory.
Describing something as a subset of nat is just done by by describing it as a proposition over natural numbers. Something of type nat -> Prop
.
The sentence let H
be a subset of nat is written:
Variable H : nat -> Prop.
Now that predicate on natural number can only be applied to natural numbers.
If you want to have uniformity and talk about the full subset of natural numbers, it is represented by (choosing a name at random)
Definition all_nat n := True.
Turning attention to your myProp
predicate, it will only be applied on predicates on natural numbers, so you can remove the part about being a subset of nat, which will always be satisfied.
Definition myProp (H : nat -> Prop) := forall x, H (2 * x) -> H x.
If I really want to have a description following your initial proposal, I would write
Definition myProp' (H : nat -> Prop) :=
(forall x, H x -> all_nat x) /\
(forall x, H (2 * x) -> H x).
But the first part of the conjunct is really useless in the case of all_nat
. It might come handy in other cases where you would want to consider all subsets of another meaningful subset of nat.