annotate ModelChecking.agda @ 710:c588b77bc197

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 05 May 2022 14:23:49 +0900
parents 6a805c8c1e53
children 9be22bce3abd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
635
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module ModelChecking where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import Level renaming (zero to Z ; suc to succ)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Data.Nat hiding (compare)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import Data.Nat.Properties as NatProp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 open import Data.Maybe
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 -- open import Data.Maybe.Properties
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 open import Data.Empty
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 open import Data.List
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
11 -- open import Data.Tree.Binary
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
12 -- open import Data.Product
635
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 open import Function as F hiding (const)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 open import Relation.Binary
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 open import Relation.Binary.PropositionalEquality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 open import Relation.Nullary
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 open import logic
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 open import Data.Unit hiding ( _≟_ ; _≤?_ ; _≤_)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 open import Relation.Binary.Definitions
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 record AtomicNat : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 field
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
23 anid : ℕ
635
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 value : ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
26 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
27 -- single process implemenation
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
28 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
29
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
30 f_set : {n : Level } {t : Set n} → AtomicNat → (value : ℕ) → ( AtomicNat → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
31 f_set a v next = next record a { value = v }
635
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 record Phils : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 pid : ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 left right : AtomicNat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
38 pickup_rfork : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
39 pickup_lfork : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
40 eating : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
635
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 putdown_rfork : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 putdown_lfork : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 thinking : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
45 -- pickup_rfork p next = f_set (Phils.right p) (Phils.pid p) ( λ f → goto C_pickup_lfork record p { right = f } next )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
46
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
47 pickup_rfork p next = f_set (Phils.right p) (Phils.pid p) ( λ f → pickup_lfork record p { right = f } next )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
48 pickup_lfork p next = f_set (Phils.left p) (Phils.pid p) ( λ f → eating record p { left = f } next )
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
49 eating p next = putdown_rfork p next
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
50 putdown_rfork p next = f_set (Phils.right p) 0 ( λ f → putdown_lfork record p { right = f } next )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
51 putdown_lfork p next = f_set (Phils.left p) 0 ( λ f → thinking record p { left = f } next )
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
52 thinking p next = next p
635
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
54 run : Phils
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
55 run = pickup_rfork record { pid = 1 ; left = record { anid = 1 ; value = 0 } ; right = record { anid = 2 ; value = 0 } } $ λ p → p
635
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
57 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
58 -- goto version
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
59 --
635
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60
636
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
61 data Code : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
62 C_set : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
63 C_putdown_rfork : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
64 C_putdown_lfork : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
65 C_thinking : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
66 C_pickup_rfork : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
67 C_pickup_lfork : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
68 C_eating : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
69
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
70 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
71 -- all possible arguments in APIs
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
72 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
73 record AtomicNatAPI : Set where
636
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
74 field
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
75 next : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
76 value : ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
77 old : ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
78 impl : AtomicNat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
79
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
80 record PhilsAPI : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
81 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
82 next : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
83 impl : Phils
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
84
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
85 data Data : Set where
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
86 D_AtomicNat : AtomicNat → Data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
87 D_Phils : Phils → Data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
88 A_AtomicNat : AtomicNatAPI → Data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
89 A_Phils : PhilsAPI → Data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
90
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
91 data Error : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
92 E_cas_fail : Error
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
93
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
94 open import hoareBinaryTree
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
95
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
96 record Context : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
97 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
98 next : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
99 fail : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
100 phil : PhilsAPI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
101 atomicNat : AtomicNatAPI
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
102 mbase : ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
103 memory : bt Data
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
104 error : Data
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
105 fail_next : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
106
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
107 alloc-data : {n : Level} {t : Set n} → ( c : Context ) → ( Context → ℕ → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
108 alloc-data {n} {t} c next = next record c { mbase = ( suc ( Context.mbase c ) ) } ( suc ( Context.mbase c ) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
109
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
110 update-data : {n : Level} {t : Set n} → ( c : Context ) → ℕ → Data → ( Context → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
111 update-data c n x next = insertTree (Context.memory c) n x ( λ bt → next record c { memory = bt } )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
112
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
113 f_cas : {n : Level} {t : Set n} → AtomicNat → (old now new : ℕ ) → ( Error → t) → ( AtomicNat → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
114 f_cas a old now new error next with <-cmp old now
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
115 ... | tri≈ ¬a b ¬c = next record a { value = new }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
116 ... | tri< a₁ ¬b ¬c = error E_cas_fail
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
117 ... | tri> ¬a ¬b _ = error E_cas_fail
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
118
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
119 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
120 -- second level stub
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
121 --
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
122 g_set : {n : Level} {t : Set n} → Context → AtomicNat → ( Code → Context → t ) → t
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
123 g_set {_} {t} c a next = f_set a ( AtomicNatAPI.value api )
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
124 $ λ a → next ( AtomicNatAPI.next api ) record c { atomicNat = record api { impl = a } } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
125 api : AtomicNatAPI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
126 api = Context.atomicNat c
636
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
127
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
128 g_cas : {n : Level} {t : Set n} → Context → AtomicNat → ( Code → Context → t ) → t
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
129 g_cas {n} {t} c a next = f_cas a ( AtomicNatAPI.old api )( AtomicNat.value a ) ( AtomicNatAPI.value api ) ( λ e → next (Context.fail_next c) c )
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
130 $ λ a → next ( AtomicNatAPI.next api ) record c { atomicNat = record api { impl = a } } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
131 api : AtomicNatAPI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
132 api = Context.atomicNat c
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
133
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
134 g_putdown_rfork : {n : Level} {t : Set n} → Context → Phils → ( Code → Context → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
135 g_putdown_rfork c p next = next C_set record c {
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
136 atomicNat = record (Context.atomicNat c) { impl = Phils.right p ; value = Phils.pid p ; old = AtomicNat.value (Phils.right p ) ; next = C_putdown_lfork } }
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
137
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
138 g_putdown_lfork : {n : Level} {t : Set n} → Context → Phils → ( Code → Context → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
139 g_putdown_lfork c p next = next C_set record c {
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
140 atomicNat = record (Context.atomicNat c) { impl = Phils.left p ; value = Phils.pid p ; old = AtomicNat.value (Phils.left p ) ; next = C_thinking } }
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
141
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
142 g_thinking : {n : Level} {t : Set n} → Context → Phils → ( Code → Context → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
143 g_thinking c p next = next C_pickup_rfork c
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
144
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
145 g_pickup_rfork : {n : Level} {t : Set n} → Context → Phils → ( Code → Context → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
146 g_pickup_rfork c p next = next C_set record c {
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
147 atomicNat = record (Context.atomicNat c) { impl = Phils.right p ; value = 0 ; old = AtomicNat.value (Phils.right p ) ; next = C_pickup_lfork } }
708
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
148
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
149 g_pickup_lfork : {n : Level} {t : Set n} → Context → Phils → ( Code → Context → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
150 g_pickup_lfork c p next = next C_set record c {
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
151 atomicNat = record (Context.atomicNat c) { impl = Phils.left p ; value = 0 ; old = AtomicNat.value (Phils.left p ) ; next = C_eating } }
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
152
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
153 g_eating : {n : Level} {t : Set n} → Context → Phils → ( Code → Context → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
154 g_eating c p next = next C_putdown_rfork c
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
155
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
156 set_stub : {n : Level} {t : Set n} → Context → ( Context → t) → t
710
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
157 set_stub c next = f_cas (AtomicNatAPI.impl api) (AtomicNatAPI.old api) {!!} (AtomicNatAPI.value api) {!!} ( λ ai → next {!!} ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
158 api : AtomicNatAPI
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
159 api = Context.atomicNat c
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
160 ai : {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 709
diff changeset
161 ai = updateTree {!!} {!!} {!!} {!!} {!!}
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
162
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
163 putdown_rfork_stub : {n : Level} {t : Set n} → Context → ( Context → t) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
164 putdown_rfork_stub p next = {!!} -- g_putdown_rfork ( Context.phil p ) ( λ ph → next record p { phil = ph ; next_code = C_putdown_lfork } )
636
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
165
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
166 putdown_lfork_stub : {n : Level} {t : Set n} → Context → ( Context → t) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
167 putdown_lfork_stub p next = {!!} -- g_putdown_lfork ( Context.phil p ) ( λ ph → next record p { phil = ph ; next_code = C_thinking } )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
168
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
169 thinking_stub : {n : Level} {t : Set n} → Context → ( Context → t) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
170 thinking_stub p next = {!!} -- g_thinking ( Context.phil p ) ( λ ph → next record p { phil = ph ; next_code = C_pickup_rfork } )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
171
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
172 pickup_rfork_stub : {n : Level} {t : Set n} → Context → ( Context → t) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
173 pickup_rfork_stub p next = {!!} -- g_pickup_rfork ( Context.phil p ) ( λ ph → next record p { phil = ph ; next_code = C_pickup_lfork } )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
174
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
175 pickup_lfork_stub : {n : Level} {t : Set n} → Context → ( Context → t) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
176 pickup_lfork_stub p next = {!!} -- g_pickup_lfork ( Context.phil p ) ( λ ph → next record p { phil = ph ; next_code = C_eating } )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
177
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
178 eating_stub : {n : Level} {t : Set n} → Context → ( Context → t) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
179 eating_stub p next = {!!} -- g_pickup_lfork ( Context.phil p ) ( λ ph → next record p { phil = ph ; next_code = C_putdown_rfork } )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
180
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
181 code_table : {n : Level} {t : Set n} → Code → Context → ( Context → t) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
182 code_table C_set = set_stub
636
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
183 code_table C_putdown_rfork = putdown_rfork_stub
708
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
184 code_table C_putdown_lfork = putdown_lfork_stub
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
185 code_table C_thinking = thinking_stub
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
186 code_table C_pickup_rfork = pickup_rfork_stub
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
187 code_table C_pickup_lfork = pickup_lfork_stub
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
188 code_table C_eating = eating_stub
636
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
189
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
190 open Context
708
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
191
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
192 step : {n : Level} {t : Set n} → List Context → (List Context → t) → t
708
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
193 step {n} {t} [] next0 = next0 []
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
194 step {n} {t} (p ∷ ps) next0 = code_table {!!} p ( λ np → next0 (ps ++ ( np ∷ [] ) ))
708
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
195
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
196 test : List Context
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
197 test = step {!!} ( λ ps → ps )
708
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
198
709
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
199 test1 : List Context
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 708
diff changeset
200 test1 = step {!!}
708
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
201 $ λ ps → step ps $ λ ps → ps
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
202
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
203 -- loop exexution
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
204
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
205 -- concurrnt execution
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
206
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
207 -- state db ( binary tree of processes )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
208
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
209 -- depth first ececution
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
210
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 637
diff changeset
211 -- verify temporal logic poroerries
636
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
212
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
213
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
214