Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Access return values in theorem

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Access return values in theorem


Chronological Thread 
  • From: Castéran Pierre <pierre.casteran AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Access return values in theorem
  • Date: Wed, 5 Aug 2020 11:45:03 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=pierre.casteran AT gmail.com; spf=Pass smtp.mailfrom=pierre.casteran AT gmail.com; spf=None smtp.helo=postmaster AT mail-wm1-f48.google.com
  • Ironport-phdr: 9a23:j7kIWx9DTXPRwv9uRHKM819IXTAuvvDOBiVQ1KB20OIcTK2v8tzYMVDF4r011RmVBNudtKIP0rqempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9JDffgRFiCC/bL5xIxm6sAbcvdQKjIV/Lao81gHHqWZSdeRMwmNoK1OTnxLi6cq14ZVu7Sdete8/+sBZSan1cLg2QrJeDDQ9LmA6/9brugXZTQuO/XQTTGMbmQdVDgff7RH6WpDxsjbmtud4xSKXM9H6QawyVD+/6apgVR3mhzodNzMh8G/YlsN/gr9VrhKvuRJwwY3aboaOOfVkYq/deMkXRWpdUstTUSFKH4Oyb5EID+oEJetVsZPyp0ASrRykHwmjHuXvxSdSiH/3w6I6yf4hHh/b1wEnB9IOsWrbrM/vNKgMS+y60LPHzS7fb/xIwzfy8o7IfwsuofGJR71wcM7RxVMzGAPCi1WdsIroNC6a2eoRqWaU9fZgVf6xhG49rQF8ujehy9oxh4TIhI8bxU3I+Th2zYooK9O1R052b96nHZdOtyyXNJV7Tt8tTWxnpis3yqMKtJq0ciUKyZkpyR7SZv+BfoOV7BzjU+ORLi15hHJjYL+/hhCy8VKhyuLmTMW03kxKoyxYmdfPrnAAzwLf5tSDR/dn/Uqs2SyD2x3N5uxHO0w5mqnWJ4Y/zrEqipYfrEHOETPtl0nriKKbc0cp9fOo5unibLjpuIOQO5Nxhw3gMqkihs2yDOE3PwUMQmeX5OGx2bLt/UD2QLhHi/w7n6vbvZ/AI8kQu7S3DBVP0ok57hayFzem38ocnXkANF9FfQiIj4ntO13XLvH4COqzj02ikDpkxP3KJLLhApLKLnjMlLfuY6xx5FJbyAo21dxf5pRUBa8dIP/rREP9qNjVAgU6PgG02errFctx24AEVW+AAaKVKKbSvkWJ5uIrLemMfogVuDPlJvg95v7hk2U5mUUDcqWzwZQYcmu4Huh4LEWDe3XshMwMEWgPvgUkTezqjEeOXiJUZ3a3R648/C00CJq6DYffQYCgmKCO3CCiHpFPem9GDk2MHmzzeoWfW/YMbTqSLdV7njwFU7ihUY4h2gu0uA/00bo0ZtbTryYfrNfo0MV/z+zVjxA7szJuXOqH1GTYZGhvguISTjkB5KFyu1ZwggOb0KVimfEeHtVI+/5TWwESOpvVzug8ANf3DFGSNuyVQUqrF431SQo6Scg8lodXMhRNXu66hxWG5BKERroclriFHpsxq/uO0H34JsI7wHHDhvB40wsWB/BXPGjjvZZRshDJDteQwUqcnqeuM68b2XyVrTrR/S+1pEhdFTVIf+DFUHQYPBaEqN344gbdSubrB+h3dARGzsGGJ+1Bbdi71Vg=

Hello,

Well, if I guess the property you want to prove, it may be like as follows :

Inductive Green : state -> Prop :=
  green1 : forall c w, Green (State c w tramGreen)
 | green2 : forall c t,  Green (State c walkerGreen t)
 | green3 : forall t w, Green (State carGreen t w).

Hint Constructors Green : core.

Fixpoint iterate {A:Type}(f : A -> A) (n: nat)(x:A) :=
  match n with
  | 0 => x
  | S p =>  (iterate  f p (f x))
  end.

Definition green_acc s := exists n:nat, Green (iterate_t  fsm n s).


Lemma green_acc_trans : forall s , green_acc (fsm s) -> green_acc s.
Proof. intros s [n H]. now exists (S n). Qed.

Then you prove the proposition forall s, green_acc s, following the structure of fsm (avoiding to consider all the 16 possible values of s).

If you prefer to consider the transition as relations, you can reason with reflexive and transitive closures (cf  https://coq.inria.fr/distrib/current/stdlib/Coq.Relations.Operators_Properties.html )

Hope that helps,

Pierre

Le 4 août 2020 à 17:53, fritjof AT uni-bremen.de a écrit :

Inductive trafficLightCar:=
   | carRed
   | carYellow
   | carGreen
   | carRedYellow.

Inductive trafficLightWalker:=
   | walkerRed
   | walkerGreen.

Inductive trafficLightTram:=
   | tramRed
   | tramGreen.


Inductive state :=
   | State : trafficLightCar -> trafficLightWalker -> trafficLightTram -> state.


Definition fsm (s : state) : state :=
   match s with
    | State carRed walkerRed tramRed => State carRed walkerRed tramGreen 
    | State carRed walkerRed tramGreen => State carRedYellow walkerRed tramRed
    | State carRedYellow walkerRed tramRed => State carGreen walkerRed tramRed
    | State carGreen walkerRed tramRed => State carYellow walkerRed tramRed
    | State carYellow walkerRed tramRed => State carRed walkerGreen tramRed
    | State _ _ _ => State carRed walkerRed tramRed
   end.

Do you agree with the following ones ?

Variables a b: Type.
Variable green: a.
Inductive state :=
  | State : a -> b -> state.

Variable fsm : state -> state. 

Now, if s is any state, you can decompose it with a match.
Since fsm is a function, (fsm s) is a single value, the first component of which is (or not) green. 
So I don’t understand the need for an existential quantifier.

What do you think about the following statement ? Is it what you meant ?

Theorem foo:
 forall (s : state),
        match fsm s with (State a' b') => a' = green end.






Archive powered by MHonArc 2.6.19+.

Top of Page