Commit 4a36be37 authored by Ralf Jung's avatar Ralf Jung
Browse files

apply feedback; fix compilation with coq 8.5

parent af7b6da1
Pipeline #3593 canceled with stage
......@@ -956,22 +956,25 @@ Proof.
(** Sigma *)
Class LimitPreserving {A : ofeT} `{!Cofe A} (P : A Prop) : Prop :=
limit_preserving : c : chain A, ( n, P (c n)) P (compl c).
  • You can probably just write

     `{Cofe A}
    Edited by Robbert Krebbers
  • I guess I could... I can pretty much never predict what exactly ` does, so I tweak it until it works ;)

    Edited by Ralf Jung
  • `{C x0 ... xn}

    means generalize all arguments of C apart from those that are mentioned in the declaration (i.e. x0 ... xn).

    `{!C x0 ... xn}

    means generalize nothing. It is just an anonymous implicit argument.

  • Well, that's not entirely right. If x0 is not bound anywhere, then {C x0 ... xn} will also generalize it. And I pretty sure that adding a ! can also generalize things, but the documentation is really not clear.

Please register or sign in to reply
Section sigma.
Context {A : ofeT} {f : A Prop}.
Context {A : ofeT} {P : A Prop}.
(* TODO: Find a better place for this Equiv instance. It also
should not depend on A being an OFE. *)
Instance sig_equiv : Equiv (sig f) :=
Instance sig_equiv : Equiv (sig P) :=
λ x1 x2, (proj1_sig x1) (proj1_sig x2).
Instance sig_dist : Dist (sig f) :=
Instance sig_dist : Dist (sig P) :=
λ n x1 x2, (proj1_sig x1) {n} (proj1_sig x2).
Global Lemma exist_ne :
Lemma exist_ne :
n x1 x2, x1 {n} x2
(H1 : f x1) (H2 : f x2), (exist f x1 H1) {n} (exist f x2 H2).
(H1 : P x1) (H2 : P x2), (exist P x1 H1) {n} (exist P x2 H2).
Proof. intros n ?? Hx ??. exact Hx. Qed.
Global Instance proj1_sig_ne : Proper (dist n ==> dist n) (@proj1_sig _ f).
Global Instance proj1_sig_ne : Proper (dist n ==> dist n) (@proj1_sig _ P).
Proof. intros n [] [] ?. done. Qed.
Definition sig_ofe_mixin : OfeMixin (sig f).
Definition sig_ofe_mixin : OfeMixin (sig P).
- intros x y. unfold dist, sig_dist, equiv, sig_equiv.
......@@ -979,24 +982,24 @@ Section sigma.
- unfold dist, sig_dist. intros n.
split; [intros [] | intros [] [] | intros [] [] []]; simpl; try done.
intros. by etrans.
- intros n [] []. unfold dist, sig_dist. apply dist_S.
- intros n [??] [??]. unfold dist, sig_dist. simpl. apply dist_S.
Canonical Structure sigC : ofeT := OfeT (sig f) sig_ofe_mixin.
Canonical Structure sigC : ofeT := OfeT (sig P) sig_ofe_mixin.
Global Class LimitPreserving `{Cofe A} : Prop :=
limit_preserving : c : chain A, ( n, f (c n)) f (compl c).
Program Definition sig_compl `{LimitPreserving} : Compl sigC :=
λ c, exist f (compl (chain_map proj1_sig c)) _.
(* FIXME: WTF, it seems that within these braces {...} the ofe argument of LimitPreserving
suddenyl becomes explicit...? *)
  • Use

    `{!LimitPreserving P}
  • That still doesn't explain why an implicit argument becomes explicit. Also, I think I tried that... or no, I tried `{Cofe A, LimitPreserving P}, to no avail.

  • Also, doing so doesn't work either:

    Error: Cannot infer the implicit parameter Cofe0 of LimitPreserving whose type is "Cofe A" (no type class instance
    found) in environment:
  • Ah, there is also the Cofe. You need:

    `{Cofe A, !LimitPreserving P}
  • Then what I have is shorter ;)

  • Alright, then you can remove the WTF ;)

  • Not really, I still don't understand why implicit arguments become explicit.

  • I tried looking up the backtick syntax in the Coq refman, but could not find it. Is it documented at all? Maybe open a bug report, if it is not.

    I think, using the _ you mention the argument explicitly, so the backtick does not generalize it. Makes sense? No.


    `{Cofe A, !LimitPreserving P}

    is understandable given the two rules I described above.

  • The backtick is documented there :

    But really, this is far from clear...

  • Thanks! That page is kind of hard to find. At least, I could not find it starting from the documentation of the Context command.

Please register or sign in to reply
Program Definition sig_compl `{LimitPreserving _ P} : Compl sigC :=
λ c, exist P (compl (chain_map proj1_sig c)) _.
Next Obligation.
intros ? Hlim c. apply Hlim. move=>n /=. destruct (c n). done.
Program Definition sig_cofe `{LimitPreserving} : Cofe sigC :=
Program Definition sig_cofe `{LimitPreserving _ P} : Cofe sigC :=
{| compl := sig_compl |}.
Next Obligation.
intros ? Hlim n c. apply (conv_compl n (chain_map proj1_sig c)).
Global Instance sig_timeless (x : sig f) :
Global Instance sig_timeless (x : sig P) :
Timeless (proj1_sig x) Timeless x.
Proof. intros ? y. destruct x, y. unfold dist, sig_dist, equiv, sig_equiv. apply (timeless _). Qed.
Global Instance sig_discrete_cofe : Discrete A Discrete sigC.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment