Open jaewooklee93 opened 9 years ago
This is a good point.
You are right that you cannot define 'find' directly because 'appears_in' is Prop. It is intuitively natural that there should not be any algorithm for find in case X is not a decidable set. The proposition "appears_in x l" only tells you the fact that x is in the list l somewhere, but does not tell you at which position the element x locates. If you want such information, you can define a proposition like
appears_in_at x n l (meaning that x appears at nth location in l)
Also, the theorem is provable because "exists n:nat, nth X l n = Some x" is Prop. As I said in the lecture, you can do a case analysis when you go from Prop to Prop.
It seems that the world of Prop
s and the world of computable functions are strictly separated.
I should be careful about their difference.
The rule is simple.
Note that technically Prop is a subset of Type. So, strictly speaking, anything in Type but not in Prop is a proper set.
On Mon, Apr 20, 2015 at 8:52 PM, jaewooklee93 notifications@github.com wrote:
It seems that the world of Props and the world of computable functions are strictly separated. I should be careful about their difference.
— Reply to this email directly or view it on GitHub https://github.com/snu-sf/pl2015/issues/74#issuecomment-94431903.
I think now I catch the point. I can perform the case analysis for Prop
only in the form of Prop -> Prop
but I can't do it in Prop -> Set
.
Require Import Omega.
Inductive even: nat -> Prop :=
| ev_0 : even 0
| ev_SS : forall n, even n -> even (2+n).
Theorem Prop2Prop:
forall n (H: even n),
0=n \/ 2<=n.
Proof.
intros.
inversion H; omega.
Qed.
Theorem Prop2Set:
forall n (H: even n),
{0=n} + {2<=n}.
Proof.
intros.
inversion H. (* Error *)
Abort.
I thought sumbool
has almost the same semantic to or
, but it seems that the meaning of sumbool
is much more restrictive.
Ah, of course, Set
like nat
and list
are always eliminable.
My idea is that if I have an evidence for
x
∈l
, wherex
is an element andl
is a list, I can construct a function to find the leftmost appearing position ofx
in the listl
. My first try was this.However, it only gave me an unfamiliar error.
I guess that this error is related to what professor explained in the last lecture. He said
Prop
is similar toSet
, butProp
only cares whether it is empty or nonempty. I think that is the reason of impossibility of doing case analysis forev
. Is that correct?In contrast, I can easily prove the following theorem
At this point, I'm little bit confused. While we can prove the existence of such function, even in a constructive way, why cannot we define that function with
Fixpoint
? Are such functions only living in the world ofTheorem
?