Mission.agda 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. open import Proc
  2. module Mission (param : Param) where
  3. import Interp
  4. import Hear
  5. open import Basics
  6. private
  7. open module P = Process param
  8. open module I = Interp param
  9. open module H = Hear param
  10. renaming ( sound to hear-sound
  11. ; uniq to hear-uniq
  12. ; complete to hear-complete
  13. )
  14. open Tran
  15. data IsRefuse {a : U}{p : Proc a} : Result p -> Set where
  16. isRefuse : {s : Silent p} -> IsRefuse (refuse s)
  17. completeS : {a : U}{p : Proc a}(g : Guard p) ->
  18. Silent p -> (oracle : Oracle) -> IsRefuse (step g oracle)
  19. completeS og silent-o oracle = isRefuse
  20. completeS (>g f) silent-> oracle = isRefuse
  21. completeS (_ !g _) () oracle
  22. completeS (_ ! _ +g _) () oracle
  23. completeS (g1 ||g g2) (silent-|| s1 s2) oracle
  24. with step g1 (nextOracle oracle)
  25. | completeS g1 s1 (nextOracle oracle)
  26. | step g2 (nextOracle oracle)
  27. | completeS g2 s2 (nextOracle oracle)
  28. | prophecy oracle
  29. ... | refuse _ | _ | refuse _ | _ | _ = isRefuse
  30. ... | speak _ | () | speak _ | _ | _
  31. ... | refuse _ | _ | speak _ | () | _
  32. ... | speak _ | () | speak _ | _ | left
  33. ... | speak _ | _ | speak _ | () | right
  34. ... | speak _ | _ | refuse _ | () | _
  35. completeS (φ /|g g) (silent-/| s) oracle with step g oracle
  36. | completeS g s oracle
  37. ... | speak _ | ()
  38. ... | refuse _ | _ = isRefuse
  39. completeS (defg x g) (silent-def s) oracle with step g oracle
  40. | completeS g s oracle
  41. ... | speak _ | ()
  42. ... | refuse _ | _ = isRefuse
  43. theOracle : {a : U}{p : Proc a}{w : LT a}{q : Proc a} ->
  44. p -! w !-> q -> Oracle
  45. theOracle tx-! = anyOracle
  46. theOracle tx-+ = anyOracle
  47. theOracle (tx-!| s r) = ocons left (theOracle s)
  48. theOracle (tx-|! r s) = ocons right (theOracle s)
  49. theOracle (tx-/| s) = theOracle s
  50. theOracle (tx-def s) = theOracle s
  51. data IsSpeak {a : U}{p : Proc a}(w : LT a)(q : Proc a) : Result p -> Set where
  52. isSpeak : {r : p -! w !-> q} -> IsSpeak w q (speak r)
  53. completeT : {a : U}{p : Proc a}(g : Guard p){w : LT a}{q : Proc a} ->
  54. (r : p -! w !-> q) -> IsSpeak w q (step g (\x -> theOracle r x))
  55. completeT og ()
  56. completeT (>g _) ()
  57. completeT (w !g p) tx-! = isSpeak
  58. completeT (w ! p +g f) tx-+ = isSpeak
  59. completeT (g1 ||g g2) (tx-!| s r) with step g1 (\x -> theOracle s x)
  60. | step g2 (\x -> theOracle s x)
  61. | completeT g1 s
  62. | hear-complete g2 r
  63. ... | .(speak _) | refuse _ | isSpeak | refl = isSpeak
  64. ... | .(speak _) | speak _ | isSpeak | refl = isSpeak
  65. completeT (g1 ||g g2) (tx-|! r s) with step g1 (\x -> theOracle s x)
  66. | step g2 (\x -> theOracle s x)
  67. | hear-complete g1 r
  68. | completeT g2 s
  69. ... | refuse _ | .(speak _) | refl | isSpeak = isSpeak
  70. ... | speak _ | .(speak _) | refl | isSpeak = isSpeak
  71. completeT (φ /|g g) (tx-/| s) with step g (\x -> theOracle s x)
  72. | completeT g s
  73. ... | ._ | isSpeak = isSpeak
  74. completeT (defg x g) (tx-def s) with step g (\x -> theOracle s x)
  75. | completeT g s
  76. ... | ._ | isSpeak = isSpeak