Lift.v 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. (* SPDX-License-Identifier: GPL-2.0 or GPL-3.0
  2. Copyright © 2019 Ariadne Devos *)
  3. Require Import S.Lucid.Arrow.
  4. Require Import Coq.Program.Basics.
  5. (* Lift Gallina functions to arrows
  6. (or rather, lift the functions to
  7. corresponding arrow signatures)
  8. (actually lifting the arrows is
  9. in S.Lucid.Primitives). *)
  10. Section definitions.
  11. (* The behaviour of a pure Gallina function. *)
  12. Record PureSig A B := {
  13. (* precondition *)
  14. P : A -> Prop;
  15. (* postcondition *)
  16. Q : B -> Prop;
  17. (* function (sig: subset type) *)
  18. f : sig (A := A) P -> sig (A := B) Q;
  19. }.
  20. Variable World : Type.
  21. (* Lift a PureSig to an ArrowSig *)
  22. Definition PureArrowSig A B (p : PureSig A B) (rely_guarantee : Situation (World := World) A -> Frame World) : ArrowSig World A B
  23. := {| rely := rely_guarantee;
  24. guarantee := rely_guarantee;
  25. pre := compose (P _ _ p) snd;
  26. (* the output value is, in fact, in function
  27. of the input value. *)
  28. post := fun t u => exists pf, snd u = proj1_sig (f _ _ p (exist _ (snd t) pf)) |}.
  29. End definitions.
  30. Arguments P { _ _ }.
  31. Arguments Q { _ _ }.
  32. Arguments f { _ _ }.
  33. Arguments PureArrowSig { _ _ _ }.