0

I want to translate the following PVS into Coq: enter image description here

where type trans has type env -> env -> bool, I write the Coq code as follows:

Definition trans := env -> env -> bool.

Definition dseq (P Q : trans) : trans :=
  fun s1 s2 => andb (P s1 s') (Q s' s2).

However, I have no idea to represent the Exists (s : env) in Coq. The goal of this definition is that there exists a value s that satisfies the (P s1 s) and (P s s2). I would not like to use logic since I want to prove the following theorem:

Theorem dseq_comm:
  forall (F G H : trans), dseq (desq F G) H = dseq F (dseq G H).
Dejan Jovanović
  • 2,085
  • 1
  • 16
  • 22
Frank Sheng
  • 195
  • 7

1 Answers1

3

Chances are you want to use Prop instead of bool. You can then write:

Parameter env : Type.

Definition trans := env -> env -> Prop.

Definition dseq (P Q : trans) : trans :=
  fun s1 s2 => exists s', P s1 s' /\ Q s' s2.

You will be able to prove

Theorem dseq_assoc:
  forall (F G H : trans), dseq (desq F G) H = dseq F (dseq G H).

if you're willing to assume Proposition extensionality.

gallais
  • 11,823
  • 2
  • 30
  • 63
  • What's the status of propositional extensionality in Coq? Some years ago, there was this discussion on the Coq mailing list: [[Coq-Club] Propositional extensionality is inconsistent in Coq](https://sympa.inria.fr/sympa/arc/coq-club/2013-12/msg00119.html). The example in the first post no longer is accepted by Coq, but is it completely resolved now? – larsr Mar 04 '18 at 10:15
  • For reference, also see https://stackoverflow.com/a/39295989/304284 and https://mathoverflow.net/questions/156238/function-extensionality-does-it-make-a-difference-why-would-one-keep-it-out-of/156295#156295 about propositional extensionality. – larsr Mar 04 '18 at 11:02
  • AFAIK Coq is supposed to be compatible with Univalence (which implies Propositional extensionality) so I'd guess it has been fixed? – gallais Mar 04 '18 at 11:05
  • Ok, yes, it seems to have been fixed in V8.5beta1 with a stricter guard condition for fixpoints, https://github.com/coq/coq/commit/f7dd427889f3ab966238f9566ec1b5edbd6c6ab6 – larsr Mar 04 '18 at 11:34
  • I wonder the [functional_extensionality] is useful in this situation. I got the subgoal as **(exists s' : env, (exists s'0 : env, F x s'0 /\ G s'0 s') /\ H s' x0) = (exists s' : env, F x s' /\ (exists s'0 : env, G s' s'0 /\ H s'0 x0))**. @gallais – Frank Sheng Mar 09 '18 at 15:04
  • More 'propositional extensionality'. Try proving `P <-> Q` (in your case it's basically `split` followed by `intros [apatternhere]; eauto` in each branch) and you can then turn that into `P = Q`. – gallais Mar 09 '18 at 15:13