annotate DPP/ModelChecking.agda @ 2:0425278b683b

Add dpp
author soto <soto@cr.ie.u-ryukyu.ac.jp>
date Thu, 12 Jan 2023 20:31:09 +0900
parents
children 8c1e9a6d58e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module ModelChecking where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import Level renaming (zero to Z ; suc to succ)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Data.Nat hiding (compare)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import Data.Nat.Properties as NatProp
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 open import Data.Maybe
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 -- open import Data.Maybe.Properties
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 open import Data.Empty
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 open import Data.List
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 open import Data.Product
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 open import Function as F hiding (const)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 open import Relation.Binary
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 open import Relation.Binary.PropositionalEquality
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 open import Relation.Nullary
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 open import logic
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 open import Data.Unit hiding (_≟_ ; _≤?_ ; _≤_)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 open import Relation.Binary.Definitions
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 record AtomicNat : Set where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 field
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 value : ℕ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 set : {n : Level } {t : Set n} → AtomicNat → (value : ℕ) → ( AtomicNat → t ) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 set a v next = next record { value = v }
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 record Phils : Set where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 field
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 pid : ℕ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 left right : AtomicNat
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 putdown_rfork : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 putdown_rfork p next = set (Phils.right p) 0 ( λ f → next record p { right = f } )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 putdown_lfork : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 putdown_lfork p next = set (Phils.left p) 0 ( λ f → next record p { left = f } )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 thinking : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 thinking p next = next p
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 pickup_rfork : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 pickup_rfork p next = set (Phils.right p) (Phils.pid p) ( λ f → next record p { right = f } )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 pickup_lfork : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 pickup_lfork p next = set (Phils.left p) (Phils.pid p) ( λ f → next record p { left = f } )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 --eating : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 --eating p next = next p
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 data Code : Set where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 -- C_set : Code
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 C_putdown_rfork : Code
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 C_putdown_lfork : Code
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 C_thinking : Code
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 C_pickup_rfork : Code
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 C_pickup_lfork : Code
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 C_eating : Code
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 record Process : Set where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 field
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 phil : Phils
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 next_code : Code
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 putdown_rfork_stub : {n : Level} {t : Set n} → Process → ( Process → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 putdown_rfork_stub p next = putdown_rfork ( Process.phil p ) ( λ ph → next record p { phil = ph ; next_code = C_putdown_lfork } )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 putdown_lfork_stub : {n : Level} {t : Set n} → Process → ( Process → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 putdown_lfork_stub p next = putdown_lfork ( Process.phil p ) ( λ ph → next record p { phil = ph ; next_code = C_putdown_lfork } )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 {-
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 code_table : {n : Level} {t : Set n} → Code → Process → ( Process → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 -- code_table C_set = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 code_table C_putdown_rfork = putdown_rfork_stub
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 code_table C_putdown_lfork = putdown_lfork_stub
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 code_table C_thinking = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 code_table C_pickup_rfork = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 code_table C_pickup_lfork = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 code_table C_eating = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 -}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 open Process
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 --step : {n : Level} {t : Set n} → List Process → (List Process → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 --step {n} {t} [] next0 = next0 []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 --step {n} {t} (p ∷ ps) next0 = code_table (next_code p) p ( λ np → next0 (ps ++ ( np ∷ [] ) ))
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 --test : List Process
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 --test = step ( record { phil = record { pid = 1 ; left = record { value = 1 } ; right = record { value = 1 } } ; next_code = C_putdown_rfork } ∷ [] ) ( λ ps → ps )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 --test1 : List Process
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 --test1 = step ( record { phil = record { pid = 1 ; left = record { value = 1 } ; right = record { value = 1 } } ; next_code = C_putdown_rfork } ∷ [] )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 -- $ λ ps → step ps $ λ ps → ps
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 record Phi : Set where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 field
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 pid : ℕ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 right-hand : Bool
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 left-hand : Bool
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 next-code : Code
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 open Phi
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 record Env : Set where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 field
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 table : List ℕ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 ph : List Phi
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 open Env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 init-table : {n : Level} {t : Set n} → ℕ → (exit : Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 init-table n exit = init-table-loop n 0 (record {table = [] ; ph = []}) exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 init-table-loop : {n : Level} {t : Set n} → (redu inc : ℕ) → Env → (exit : Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 init-table-loop zero ind env exit = exit env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 init-table-loop (suc redu) ind env exit = init-table-loop redu (suc ind) record env{
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 table = 0 ∷ (table env)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 ; ph = record {pid = redu ; left-hand = false ; right-hand = false ; next-code = C_thinking } ∷ (ph env) } exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 -- eatingも探索範囲に含める
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 brute-force-search : {n : Level} {t : Set n} → Env → (exit : List Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 brute-force-search env exit = make-state-list 1 [] (ph env) env (env ∷ []) exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 make-state-list : {n : Level} {t : Set n} → ℕ → List Bool → List Phi → Env → (List Env) → (exit : List Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 make-state-list redu state (x ∷ pl) env envl exit with next-code x
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 ... | C_thinking = make-state-list (redu + redu) (state ++ (false ∷ [])) pl env envl exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 ... | C_eating = make-state-list (redu + redu) (state ++ (false ∷ [])) pl env envl exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 ... | _ = make-state-list redu state pl env envl exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 make-state-list redu state [] env envl exit = bit-force-search redu [] state env envl exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 bit-force-search : {n : Level} {t : Set n} → ℕ → (f b : List Bool )→ Env → (List Env) → (exit : List Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 bit-force-search zero f l env envl exit = exit envl
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 bit-force-search (suc redu) f [] env envl exit = exit envl
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 bit-force-search (suc redu) f (true ∷ bs) env envl exit = bit-force-search (suc redu) (f ++ (false ∷ [])) bs env envl exit -- 今回の対象をfalseにしてfに追加,bを次の対象にする
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 bit-force-search (suc redu) f (false ∷ bs) env envl exit = set-state redu (f ++ (true ∷ bs)) (f ++ (true ∷ bs)) [] (ph env) env envl exit where -- 今回の対象をtrueにし、fとbを結合してそのListを代入する。かつそれをbに入れfをinitしてloopさせる
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 set-state : {n : Level} {t : Set n} → ℕ → (origin state : List Bool ) → (f b : List Phi) → Env → (List Env) → (exit : List Env → t) → t -- 入れ替える必要のあるやつはphaseがThinkingのやつのみ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 set-state redu origin [] f b env envl exit = bit-force-search redu [] origin env (record env{ph = (f ++ b)} ∷ envl) exit -- Stateが先に尽きる
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 set-state redu origin state@(s ∷ ss) f b env envl exit with b
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 ... | [] = bit-force-search redu [] origin env (record env{ph = f} ∷ envl) exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 ... | p ∷ ps with next-code p
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 set-state redu origin (true ∷ ss) f b env envl exit | p ∷ ps | C_eating = set-state redu origin ss (f ++ (record p{next-code = C_putdown_lfork} ∷ [])) ps env envl exit -- 変更対象なので変更して奥に進む
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 set-state redu origin (false ∷ ss) f b env envl exit | p ∷ ps | C_eating = set-state redu origin ss (f ++ (p ∷ [])) ps env envl exit -- 変更対象なので変更して奥に進む
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 set-state redu origin (true ∷ ss) f b env envl exit | p ∷ ps | C_thinking = set-state redu origin ss (f ++ (record p{next-code = C_pickup_rfork} ∷ [])) ps env envl exit -- 変更対象なので変更して奥に進む
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 set-state redu origin (false ∷ ss) f b env envl exit | p ∷ ps | C_thinking = set-state redu origin ss (f ++ (p ∷ [])) ps env envl exit -- 変更対象なので変更して奥に進む
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 set-state redu origin (s ∷ ss) f b env envl exit | p ∷ ps | _ = set-state redu origin state (f ++ (p ∷ [])) ps env envl exit -- 変更対象ではないので奥を対象にする
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 test-search : List Env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 test-search = init-table 3 (λ e0 → brute-force-search e0 (λ e1 → e1))
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 -- テーブルをたどるために若干loopが必要
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 pickup-rfork-c : {n : Level} {t : Set n} → ℕ → Phi → Env → (Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 pickup-rfork-c ind p env exit = pickup-rfork-p ind [] (table env) p env exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 pickup-rfork-p : {n : Level} {t : Set n} → ℕ → (f b : List ℕ) → Phi → Env → (Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 pickup-rfork-p zero f [] p env exit = exit env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 pickup-rfork-p zero f (zero ∷ ts) p env exit = exit record env{ph = ((ph env) ++ (record p{right-hand = true ; next-code = C_pickup_lfork} ∷ [])); table = (f ++ ((pid p) ∷ ts))} -- 取得可能なので変更する envの後ろにappendする感じ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 pickup-rfork-p zero f ((suc x) ∷ ts) p env exit = exit record env{ph = ((ph env) ++ p ∷ [])} -- 取得不可能なので変更せず終了する
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 pickup-rfork-p (suc ind) f [] p env exit = exit env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 pickup-rfork-p (suc ind) f (x ∷ ts) p env exit = pickup-rfork-p ind (f ++ (x ∷ [])) ts p env exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 pickup-lfork-c : {n : Level} {t : Set n} → ℕ → Phi → Env → (Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 pickup-lfork-c ind p env exit = pickup-lfork-p (suc ind) [] (table env) p env exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 pickup-lfork-p : {n : Level} {t : Set n} → ℕ → (f b : List ℕ) → Phi → Env → (Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 pickup-lfork-p zero f [] p env exit with table env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 ... | [] = exit env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 ... | 0 ∷ ts = exit record env{ph = ((ph env) ++ (record p{left-hand = true ; next-code = C_eating} ∷ [])); table = ((pid p) ∷ ts)} -- 取得可能なので変更する envの後ろにappendする感じ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 ... | (suc x) ∷ ts = exit record env{ph = ((ph env) ++ p ∷ [])} -- 取得不可能なので変更せず終了する
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 pickup-lfork-p zero f (0 ∷ ts) p env exit = exit record env{ph = ((ph env) ++ (record p{left-hand = true ; next-code = C_eating} ∷ [])); table = (f ++ ((pid p) ∷ ts))} -- 取得可能なので変更する envの後ろにappendする感じ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 pickup-lfork-p zero f ((suc x) ∷ ts) p env exit = exit record env{ph = ((ph env) ++ p ∷ [])} -- 取得不可能なので変更せず終了する
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 pickup-lfork-p (suc ind) f [] p env exit = exit env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 pickup-lfork-p (suc ind) f (x ∷ ts) p env exit = pickup-lfork-p ind (f ++ (x ∷ [])) ts p env exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 putdown-lfork-c : {n : Level} {t : Set n} → ℕ → Phi → Env → (Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 putdown-lfork-c ind p env exit = putdown-lfork-p (suc ind) [] (table env) p env exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 putdown-lfork-p : {n : Level} {t : Set n} → ℕ → (f b : List ℕ) → Phi → Env → (Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 putdown-lfork-p zero f [] p env exit with table env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 ... | [] = exit env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 ... | x ∷ ts = exit record env{ph = ((ph env) ++ (record p{left-hand = false ; next-code = C_putdown_rfork} ∷ [])); table = (0 ∷ ts)} -- 取得可能なので変更する envの後ろにappendする感じ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 putdown-lfork-p zero f (x ∷ ts) p env exit = exit record env{ph = ((ph env) ++ (record p{left-hand = false ; next-code = C_putdown_rfork} ∷ [])); table = (f ++ (0 ∷ ts))} -- 取得可能なので変更する envの後ろにappendする感じ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 putdown-lfork-p (suc ind) f [] p env exit = exit env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 putdown-lfork-p (suc ind) f (x ∷ ts) p env exit = putdown-lfork-p ind (f ++ (x ∷ [])) ts p env exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 putdown-rfork-c : {n : Level} {t : Set n} → ℕ → Phi → Env → (Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 putdown-rfork-c ind p env exit = putdown-rfork-p ind [] (table env) p env exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 putdown-rfork-p : {n : Level} {t : Set n} → ℕ → (f b : List ℕ) → Phi → Env → (Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 putdown-rfork-p zero f [] p env exit = exit env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 putdown-rfork-p zero f (x ∷ ts) p env exit = exit record env{ph = ((ph env) ++ (record p{right-hand = false ; next-code = C_thinking} ∷ [])); table = (f ++ (0 ∷ ts))} -- 取得可能なので変更する envの後ろにappendする感じ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 putdown-rfork-p (suc ind) f [] p env exit = exit env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 putdown-rfork-p (suc ind) f (x ∷ ts) p env exit = putdown-rfork-p ind (f ++ (x ∷ [])) ts p env exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 thinking-c : {n : Level} {t : Set n} → ℕ → Phi → Env → (Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 thinking-c ind p env exit = exit record env{ph = ((ph env) ++ p ∷ [])} -- 取得不要なので変更せず終了する
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 code_table-test : {n : Level} {t : Set n} → Code → ℕ → Phi → Env → (Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 code_table-test C_putdown_rfork = putdown-rfork-c
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 code_table-test C_putdown_lfork = putdown-lfork-c
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 code_table-test C_thinking = thinking-c
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 code_table-test C_pickup_rfork = pickup-rfork-c
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 code_table-test C_pickup_lfork = pickup-lfork-c
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 code_table-test C_eating = thinking-c
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 -- code_table-test C_set = ?
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 step-c : {n : Level} {t : Set n} → Env → (exit : Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 step-c env exit = step-p (length (table env)) 0 record env{ph = []} (ph env) exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 step-p : {n : Level} {t : Set n} → (redu index : ℕ) → Env → (List Phi) → (exit : Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 step-p zero ind env pl exit = exit env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 step-p (suc redu) ind env [] exit = exit env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 step-p (suc redu) ind env (p ∷ ps) exit = code_table-test (next-code p) ind p env (λ e → step-p redu (suc ind) e ps exit )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 step-c-debug : {n : Level} {t : Set n} → Env → (exit : List Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 step-c-debug env exit = step-p (length (table env)) 0 (record env{ph = [] } ∷ env ∷ []) (ph env) exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 step-p : {n : Level} {t : Set n} → (redu index : ℕ) → List Env → (List Phi) → (exit : List Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 step-p zero ind envl pl exit = exit envl
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 step-p (suc redu) ind [] pl exit = exit []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 step-p (suc redu) ind (e ∷ envl) [] exit = exit []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 step-p (suc redu) ind (e ∷ envl) (p ∷ ps) exit = code_table-test (next-code p) ind p e (λ e0 → step-p redu (suc ind) (e0 ∷ envl) ps exit )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 exec-n : {n : Level} {t : Set n} → ℕ → Env → (exit : List Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 exec-n n env exit = exec-n-p n (env ∷ []) exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 exec-n-p : {n : Level} {t : Set n} → ℕ → List Env → (exit : List Env → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 exec-n-p zero envl exit = exit envl
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 exec-n-p (suc n) [] exit = exit []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 exec-n-p (suc n) envl@(x ∷ es) exit = step-c x (λ e → exec-n-p n (e ∷ envl) exit)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 init-brute-force : {n : Level} {t : Set n} → List Env → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 init-brute-force envl exit = init-brute-force-p envl [] exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 init-brute-force-p : {n : Level} {t : Set n} → List Env → List (List Env) → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 init-brute-force-p [] envll exit = exit envll
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 init-brute-force-p (x ∷ envl) envll exit = init-brute-force-p envl ((x ∷ []) ∷ envll) exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 search-brute-force-envll : {n : Level} {t : Set n} → List (List Env) → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 search-brute-force-envll envll exit = search-brute-force-envll-p [] envll exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 search-brute-force-envll-p : {n : Level} {t : Set n} → (f b : List (List Env)) → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 search-brute-force-envll-p f [] exit = exit f
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 search-brute-force-envll-p f ([] ∷ bs) exit = search-brute-force-envll-p f bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 search-brute-force-envll-p f (b@(x ∷ xs) ∷ bs) exit = brute-force-search x (λ e0 → make-brute-force-envl [] e0 b (λ e1 → search-brute-force-envll-p (f ++ e1) bs exit) ) where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 make-brute-force-envl : {n : Level} {t : Set n} → List (List Env) → (state p_step : List Env) → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 make-brute-force-envl res [] xs exit = exit res
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 make-brute-force-envl res (x ∷ state) xs exit = make-brute-force-envl (res ++ (x ∷ xs) ∷ []) state xs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 step-brute-force : {n : Level} {t : Set n} → List (List Env) → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 step-brute-force envll exit = step-brute-force-p [] envll exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 step-brute-force-p : {n : Level} {t : Set n} → (f b : List (List Env)) → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 step-brute-force-p f [] exit = exit f
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 step-brute-force-p f ([] ∷ bs) exit = step-brute-force-p f bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 step-brute-force-p f ((x ∷ xs) ∷ bs) exit = step-c x (λ e0 → step-brute-force-p (f ++ ((e0 ∷ x ∷ xs) ∷ [])) bs exit)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 exec-brute-force : {n : Level} {t : Set n} → ℕ → List (List Env) → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 exec-brute-force n envll exit = exec-brute-force-p n envll exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 exec-brute-force-p : {n : Level} {t : Set n} → ℕ → List (List Env) → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 exec-brute-force-p zero envll exit = exit envll
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 exec-brute-force-p (suc n) envll exit = search-brute-force-envll envll (λ e1 → step-brute-force e1 (λ e2 → exec-brute-force-p n e2 exit))
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 {-
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 model-check-deadlock : {n : Level} {t : Set n} → List (List Env) → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 model-check-deadlock envll exit = test11 [] envll exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 test11 : {n : Level} {t : Set n} → (f b : List (List Env)) → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 test11 f [] exit = exit f
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 test11 f ([] ∷ bs) exit = test11 f bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 test11 f (s@(x ∷ []) ∷ bs) exit = test11 (f ++ (s ∷ [])) bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 test11 f (s@(x ∷ x1 ∷ []) ∷ bs) exit = test11 (f ++ (s ∷ [])) bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 test11 f ((x ∷ x1 ∷ x2 ∷ xs) ∷ bs) exit = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 -}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 record metadata : Set where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 field
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 num-branch : ℕ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 wait-list : List ℕ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 open metadata
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 record MetaEnv : Set where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 field
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 DG : List Env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 meta : metadata
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 deadlock : Bool
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 is-done : Bool
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 is-step : Bool
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 open MetaEnv
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
277
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 record MetaEnv2 : Set where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 field
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 DG : List (List Env)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 metal : List MetaEnv -- 結局探索して1ステップ実行(インターリーディング)するからMetaEnvのList Envがちょうどよい
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 open MetaEnv2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 branch-deadlock-check : {n : Level} {t : Set n} → List MetaEnv → (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 branch-deadlock-check metaenv exit = search-brute-force-envll-p [] metaenv exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 search-brute-force-envll-p : {n : Level} {t : Set n} → (f b : List (MetaEnv)) → (exit : List (MetaEnv) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 search-brute-force-envll-p f [] exit = exit f
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 search-brute-force-envll-p f b@(metaenv ∷ bs) exit with DG metaenv
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 ... | [] = search-brute-force-envll-p f bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 ... | (env ∷ envs) = brute-force-search env (λ e0 → make-brute-force-envl (length e0) [] metaenv e0 (λ e1 → search-brute-force-envll-p (f ++ e1) bs exit)) where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 make-brute-force-envl : {n : Level} {t : Set n} → ℕ → List MetaEnv → MetaEnv → (state : List Env) → (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 make-brute-force-envl len res xs [] exit = exit res
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 make-brute-force-envl len res xs (x ∷ state) exit = make-brute-force-envl len (res ++ (record xs{DG = (x ∷ DG xs); meta = record (meta xs){num-branch = len}} ∷ [])) xs state exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 data _===_ {n} {A : Set n} : List A -> List A -> Set n where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 reflection : {x : List A} -> x === x
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 reflection1 : {x : List A} -> (x === x)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 {-
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 testhoge : Code → Code → ℕ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 testhoge C_putdown_rfork C_putdown_rfork = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 testhoge C_putdown_lfork C_putdown_lfork = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 testhoge C_pickup_rfork C_pickup_rfork = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 testhoge C_pickup_lfork C_pickup_lfork = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 testhoge _ _ = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 -}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 step-deadlock-check : {n : Level} {t : Set n} → List MetaEnv → (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 step-deadlock-check metaenvl exit = deadlock-check-p [] metaenvl exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 deadlock-check-p : {n : Level} {t : Set n} → (f b : List (MetaEnv)) → (exit : List (MetaEnv) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 deadlock-check-p f [] exit = exit f
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 deadlock-check-p f b@(metaenv ∷ bs) exit with DG metaenv
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 ... | [] = deadlock-check-p f bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 ... | p0 ∷ [] = deadlock-check-p f bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 ... | p0 ∷ bp ∷ envs = check-wait-process [] (ph p0) bp ( λ e → deadlock-check-p (f ++ (record metaenv{meta = record (meta metaenv){wait-list = e } } ∷ [])) bs exit) where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 check-wait-process : {n : Level} {t : Set n} → List ℕ → List Phi → (p1 : Env) → (exit : List ℕ → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 check-wait-process waitl [] p1 exit = exit waitl
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 check-wait-process waitl (p ∷ ps) p1 exit = hoge11 p (ph p1) (λ e → check-wait-process (waitl ++ e) ps p1 exit) where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 hoge11 : {n : Level} {t : Set n} → Phi → List Phi → (exit : List ℕ → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 hoge11 p [] exit = exit []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
321 hoge11 p (bp ∷ p1s) exit with <-cmp (pid p) (pid bp)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 hoge11 p (bp ∷ p1s) exit | tri< a ¬b ¬c = hoge11 p p1s exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 hoge11 p (bp ∷ p1s) exit | tri> ¬a ¬b c = hoge11 p p1s exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 hoge11 p (bp ∷ p1s) exit | tri≈ ¬a b ¬c with (next-code p)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 hoge11 p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | next-codea with (next-code bp)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 hoge11 p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_putdown_rfork | C_putdown_rfork = exit (pid p ∷ [])
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 hoge11 p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_putdown_lfork | C_putdown_lfork = exit (pid p ∷ [])
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 hoge11 p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_thinking | C_thinking = exit (pid p ∷ [])
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 hoge11 p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_pickup_rfork | C_pickup_rfork = exit (pid p ∷ [])
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 hoge11 p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_pickup_lfork | C_pickup_lfork = exit (pid p ∷ [])
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 hoge11 p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_eating | C_eating = exit (pid p ∷ [])
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 hoge11 p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | _ | _ = exit []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 step-brute-force-meta : {n : Level} {t : Set n} → List MetaEnv → (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 step-brute-force-meta metaenvl exit = step-brute-force-p [] metaenvl exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 step-brute-force-p : {n : Level} {t : Set n} → (f b : List MetaEnv) → (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 step-brute-force-p f [] exit = exit f
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 step-brute-force-p f (metaenv ∷ bs) exit with DG metaenv
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 ... | [] = step-brute-force-p f bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 ... | envl@(x ∷ xs) with is-done metaenv
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 ... | true = step-brute-force-p (f ++ (metaenv ∷ []) ) bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 ... | false = step-c x (λ e0 → step-brute-force-p (f ++ (record metaenv{DG = e0 ∷ envl} ∷ [])) bs exit)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 judge-deadlock : {n : Level} {t : Set n} → List MetaEnv → (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
346 judge-deadlock metaenvl exit = judge-deadlock-p [] metaenvl exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 judge-deadlock-p : {n : Level} {t : Set n} → (f b : List (MetaEnv)) → (exit : List (MetaEnv) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 judge-deadlock-p f [] exit = exit f
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 judge-deadlock-p f (metaenv ∷ bs) exit with num-branch (meta metaenv)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 ... | suc (suc branchnum) = judge-deadlock-p (f ++ (metaenv ∷ []) ) bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 ... | zero = judge-deadlock-p (f ++ (metaenv ∷ []) ) bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 ... | suc zero with (DG metaenv )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 ... | [] = judge-deadlock-p (f ++ (metaenv ∷ []) ) bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 ... | p ∷ ps with <-cmp (length (wait-list (meta metaenv))) (length (ph p))
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 ... | tri< a ¬b ¬c = judge-deadlock-p (f ++ (metaenv ∷ []) ) bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 ... | tri> ¬a ¬b c = judge-deadlock-p (f ++ (metaenv ∷ []) ) bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 ... | tri≈ ¬a b ¬c = judge-deadlock-p (f ++ (record metaenv{deadlock = true} ∷ []) ) bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
358
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
359
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 {-
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 test-env-deadlock : {n : Level} {t : Set n} → (a b : Env)→ (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 test-env-deadlock a b exit = test12 (ph a) (ph b) exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 test12 : {n : Level} {t : Set n} → (a b : List Phi)→ (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 test12 [] b = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 test12 (x ∷ a) b = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 -}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 {-
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
369 test12 : List ℕ → (a b0 b : List Phi) → List ℕ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 test12 stack [] b0 b = stack
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 test12 stack (a ∷ as) b0 [] = test12 stack as b0 b0
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 test12 stack (a ∷ as) b0 (b ∷ bs) with <-cmp (pid a) (pid b)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 test12 stack al@(a ∷ as) b0 (b ∷ bs) | tri< a₁ ¬b ¬c = test12 stack al b0 bs
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 test12 stack al@(a ∷ as) b0 (b ∷ bs) | tri> ¬a ¬b c = test12 stack al b0 bs
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 test12 stack al@(a ∷ as) b0 (b ∷ bs) | tri≈ ¬a b₁ ¬c with (next-code a)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 test12 stack al@(a ∷ as) b0 (b ∷ bs) | _ | aaaa with (next-code b)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 test12 stack (a ∷ as) b0 (b ∷ bs) | tri≈ _ _ _ | C_putdown_rfork | C_putdown_rfork = pid a ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 test12 stack (a ∷ as) b0 (b ∷ bs) | tri≈ _ _ _ | C_putdown_lfork | C_putdown_lfork = pid a ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 test12 stack (a ∷ as) b0 (b ∷ bs) | tri≈ _ _ _ | C_thinking | C_thinking = pid a ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 test12 stack (a ∷ as) b0 (b ∷ bs) | tri≈ _ _ _ | C_pickup_rfork | C_pickup_rfork = pid a ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 test12 stack (a ∷ as) b0 (b ∷ bs) | tri≈ _ _ _ | C_pickup_lfork | C_pickup_lfork = pid a ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 test12 stack (a ∷ as) b0 (b ∷ bs) | tri≈ _ _ _ | C_eating | C_eating = pid a ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 test12 stack al@(a ∷ as) b0 (b ∷ bs) | tri≈ _ _ _ | _ | _ = test12 stack al b0 bs
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 -}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 branch-search-meta2 : {n : Level} {t : Set n} → MetaEnv2 → (next exit : MetaEnv2 → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 branch-search-meta2 meta2 next1 exit = search-brute-force-envll-p [] (metal meta2) (λ e0 → next1 record meta2{metal = e0} ) (λ e → exit meta2) where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 make-brute-force-envl : {n : Level} {t : Set n} → (statel : List MetaEnv) → ( f : List Env) → (state : MetaEnv) → (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 search-brute-force-envll-p : {n : Level} {t : Set n} → (f b : List (MetaEnv)) → (next exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 search-brute-force-envll-p f [] next1 exit = exit f
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 search-brute-force-envll-p f b@(x ∷ bs) next1 exit with is-done x
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 ... | true = search-brute-force-envll-p (f ++ (x ∷ [])) bs next1 exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 ... | false with is-step x
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 ... | false = search-brute-force-envll-p (f ++ (x ∷ [])) bs next1 exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
395 ... | true with DG x
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 ... | [] = search-brute-force-envll-p f bs next1 exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 ... | env1 ∷ sss = brute-force-search env1 (λ e2 → make-brute-force-envl [] e2 x (λ e1 → next1 (f ++ bs ++ (record x{is-done = true} ∷ e1)) ) )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
398 make-brute-force-envl res [] meta exit = exit res
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
399 make-brute-force-envl res (addenv ∷ statel) meta exit = make-brute-force-envl (res ++ ( record meta{DG = addenv ∷ (DG meta); is-done = false; is-step = false} ∷ [])) statel meta exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
400
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
401
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 step-meta2 : {n : Level} {t : Set n} → MetaEnv2 → (next exit : MetaEnv2 → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 step-meta2 meta2 next1 exit = step-brute-force-p1 [] (metal meta2) (λ envll → next1 record meta2{metal = envll}) (λ e → exit meta2) where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 step-brute-force-p-p : {n : Level} {t : Set n} → (envl : (List Env)) → (exit : (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 step-brute-force-p1 : {n : Level} {t : Set n} → (f b : List (MetaEnv)) → (next exit : List (MetaEnv) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 step-brute-force-p1 f [] next1 exit = next1 f
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 step-brute-force-p1 f (metaenv ∷ metaenvl) next1 exit with is-step metaenv
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 ... | true = step-brute-force-p1 (f ++ (metaenv ∷ [])) metaenvl next1 exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 ... | false = step-brute-force-p-p (DG metaenv) (λ e0 → step-brute-force-p1 (f ++ (record metaenv{DG = e0; is-step = true} ∷ [])) metaenvl next1 exit)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 step-brute-force-p-p [] exit = exit []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 step-brute-force-p-p (x ∷ bs) exit = step-c x (λ e0 → exit (e0 ∷ bs))
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
412
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 {-# TERMINATING #-}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 check-same-env : {n : Level} {t : Set n} → MetaEnv2 → (exit : MetaEnv2 → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 check-same-env meta2 exit = check-same-env-p [] (metal meta2) meta2 exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 check-wait-process-p : {n : Level} {t : Set n} → ℕ → List Phi → (p1 : Env) → (exit : ℕ → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 check-wait-process-p waitl [] p1 exit = exit waitl
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 check-wait-process-p waitl (p ∷ ps) p1 exit = hoge11 waitl p (ph p1) (λ e → check-wait-process-p e ps p1 exit) where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
419 hoge11 : {n : Level} {t : Set n} → ℕ → Phi → List Phi → (exit : ℕ → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
420 hoge11 n p [] exit = exit n
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 hoge11 n p (bp ∷ p1s) exit with <-cmp (pid p) (pid bp)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 hoge11 n p (bp ∷ p1s) exit | tri< a ¬b ¬c = hoge11 n p p1s exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 hoge11 n p (bp ∷ p1s) exit | tri> ¬a ¬b c = hoge11 n p p1s exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c with (next-code p)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | next-codea with (next-code bp)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_putdown_rfork | C_putdown_rfork = exit (suc n)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
427 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_putdown_lfork | C_putdown_lfork = exit (suc n)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_thinking | C_thinking = exit (suc n)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_pickup_rfork | C_pickup_rfork = exit (suc n)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_pickup_lfork | C_pickup_lfork = exit (suc n)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_eating | C_eating = exit (suc n)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | _ | _ = exit n
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 check-wait-process : {n : Level} {t : Set n} → ℕ → List Phi → List MetaEnv → MetaEnv → (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 check-wait-process n pl metal me exit with metal
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 ... | sss with <-cmp (length pl) n
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 ... | tri≈ ¬a b ¬c = exit (me ∷ [])
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 check-wait-process n pl metal me exit | [] | tri< a ¬b ¬c = exit []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 check-wait-process n pl metal me exit | x ∷ sss | tri< a ¬b ¬c with DG x
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 check-wait-process n pl metal me exit | x ∷ sss | tri< a ¬b ¬c | [] = exit []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
440 check-wait-process n pl metal me exit | x ∷ sss | tri< a ¬b ¬c | env ∷ envs = check-wait-process-p 0 (ph env) env (λ nn → check-wait-process nn pl sss me exit)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 check-wait-process n pl metal me exit | [] | tri> ¬a ¬b c = exit []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
442 check-wait-process n pl metal me exit | x ∷ sss | tri> ¬a ¬b c with DG x
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 ... | [] = exit []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 ... | env ∷ envs = check-wait-process-p 0 (ph env) env (λ nn → check-wait-process nn pl sss me exit)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
445 check-same-env-p : {n : Level} {t : Set n} → (f b : List MetaEnv) → MetaEnv2 → (exit : MetaEnv2 → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
446 check-same-env-p [] [] metae2 exit = exit metae2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
447 check-same-env-p f@(x ∷ fs) [] metae2 exit = step-meta2 record metae2{metal = f} (λ me2 → branch-search-meta2 me2 (λ me3 → check-same-env me3 exit) exit ) exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
448 check-same-env-p [] bl@(b ∷ bs) metae2 exit with DG b
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
449 ... | [] = check-same-env-p [] bs metae2 exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
450 ... | env ∷ envs = check-wait-process 0 (ph env) bl b (λ lme → check-same-env-p ([] ++ lme) bl metae2 exit)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
451 check-same-env-p f@(x ∷ fs) bl@(b ∷ bs) metae2 exit with DG b
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 ... | [] = check-same-env-p f bs metae2 exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
453 ... | env ∷ envs = check-wait-process 0 (ph env) bl b (λ lme → check-same-env-p (f ++ lme) bl metae2 exit)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
454
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
455 check-same-env-test : {n : Level} {t : Set n} → MetaEnv2 → (exit : MetaEnv2 → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 check-same-env-test meta2 exit = check-same-env-p [] (metal meta2) meta2 exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
457 check-wait-process-p : {n : Level} {t : Set n} → ℕ → List Phi → (p1 : Env) → (exit : ℕ → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
458 check-wait-process-p waitl [] p1 exit = exit waitl
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 check-wait-process-p waitl (p ∷ ps) p1 exit = hoge11 waitl p (ph p1) (λ e → check-wait-process-p e ps p1 exit) where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
460 hoge11 : {n : Level} {t : Set n} → ℕ → Phi → List Phi → (exit : ℕ → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
461 hoge11 n p [] exit = exit n
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 hoge11 n p (bp ∷ p1s) exit with <-cmp (pid p) (pid bp)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
463 hoge11 n p (bp ∷ p1s) exit | tri< a ¬b ¬c = hoge11 n p p1s exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 hoge11 n p (bp ∷ p1s) exit | tri> ¬a ¬b c = hoge11 n p p1s exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
465 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c with (next-code p)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | next-codea with (next-code bp)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
467 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_putdown_rfork | C_putdown_rfork = exit (suc n)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_putdown_lfork | C_putdown_lfork = exit (suc n)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_thinking | C_thinking = exit (suc n)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_pickup_rfork | C_pickup_rfork = exit (suc n)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
471 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_pickup_lfork | C_pickup_lfork = exit (suc n)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | C_eating | C_eating = exit (suc n)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
473 hoge11 n p (bp ∷ p1s) exit | tri≈ ¬a b ¬c | _ | _ = exit n
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
474 check-wait-process : {n : Level} {t : Set n} → ℕ → List Phi → List MetaEnv → MetaEnv → (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 check-wait-process n pl metal me exit with metal
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
476 ... | sss with <-cmp (length pl) n
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
477 ... | tri≈ ¬a b ¬c = exit (me ∷ [])
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
478 check-wait-process n pl metal me exit | [] | tri< a ¬b ¬c = exit (me ∷ [])
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
479 check-wait-process n pl metal me exit | x ∷ sss | tri< a ¬b ¬c with DG x
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
480 check-wait-process n pl metal me exit | x ∷ sss | tri< a ¬b ¬c | [] = exit []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
481 check-wait-process n pl metal me exit | x ∷ sss | tri< a ¬b ¬c | env ∷ envs = check-wait-process-p 0 (ph env) env (λ nn → check-wait-process nn pl sss me exit)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 check-wait-process n pl metal me exit | [] | tri> ¬a ¬b c = exit (me ∷ [])
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 check-wait-process n pl metal me exit | x ∷ sss | tri> ¬a ¬b c with DG x
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 ... | [] = exit []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 ... | env ∷ envs = check-wait-process-p 0 (ph env) env (λ nn → check-wait-process nn pl sss me exit)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 make-metaenvl : {n : Level} {t : Set n} → (f : (List MetaEnv)) → List (List Env) → (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 make-metaenvl f [] exit = exit f
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 make-metaenvl f ([] ∷ bs) exit = make-metaenvl f bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 make-metaenvl f ((e ∷ es) ∷ bs) exit = make-metaenvl (f ++ (record{ DG = (e ∷ []); meta = record { num-branch = zero ; wait-list = [] }; deadlock = true; is-done = false; is-step = false} ∷ [])) bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
490 check-same-env-p : {n : Level} {t : Set n} → (f b : List MetaEnv) → MetaEnv2 → (exit : MetaEnv2 → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 check-same-env-p [] [] metae2 exit = make-metaenvl [] (DG metae2) (λ lme → exit record metae2{metal = lme})
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 check-same-env-p f@(x ∷ fs) [] metae2 exit = exit record metae2{metal = f}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
493 check-same-env-p [] bl@(b ∷ bs) metae2 exit with DG b
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
494 ... | [] = check-same-env-p [] bs metae2 exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
495 ... | env ∷ envs = check-wait-process 0 (ph env) bl b (λ lme → check-same-env-p ([] ++ lme) bs metae2 exit)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 check-same-env-p f@(x ∷ fs) bl@(b ∷ bs) metae2 exit with DG b
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
497 ... | [] = check-same-env-p f bs metae2 exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
498 ... | env ∷ envs = check-wait-process 0 (ph env) bl b (λ lme → check-same-env-p (f ++ lme) bs metae2 exit)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
499
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 {-
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 search-brute-force-envll : {n : Level} {t : Set n} → List (List Env) → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
504 search-brute-force-envll envll exit = search-brute-force-envll-p [] envll exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 search-brute-force-envll-p : {n : Level} {t : Set n} → (f b : List (List Env)) → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 search-brute-force-envll-p f [] exit = exit f
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 search-brute-force-envll-p f ([] ∷ bs) exit = search-brute-force-envll-p f bs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 search-brute-force-envll-p f (b@(x ∷ xs) ∷ bs) exit = brute-force-search x (λ e0 → make-brute-force-envl [] e0 b (λ e1 → search-brute-force-envll-p (f ++ e1) bs exit) ) where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 make-brute-force-envl : {n : Level} {t : Set n} → List (List Env) → (state p_step : List Env) → (exit : List (List Env) → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 make-brute-force-envl res [] xs exit = exit res
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511 make-brute-force-envl res (x ∷ state) xs exit = make-brute-force-envl (res ++ (x ∷ xs) ∷ []) state xs exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 -}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
513
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
514 test-env : Env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 test-env = (record {
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
516 table = 0 ∷ 0 ∷ 0 ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 ; ph = record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 { pid = 1
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
520 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 ; next-code = C_thinking
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
522 } ∷ record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 { pid = 2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
524 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
525 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
526 ; next-code = C_thinking
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
527 } ∷ record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
528 { pid = 3
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
529 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 ; next-code = C_thinking
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 } ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 })
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 test-env1 : Env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 test-env1 = (record {
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 table = 1 ∷ 2 ∷ 0 ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 ; ph = record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
538 { pid = 1
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
541 ; next-code = C_pickup_rfork
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
542 } ∷ record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
543 { pid = 2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 ; next-code = C_pickup_rfork
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 } ∷ record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 { pid = 3
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
550 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
551 ; next-code = C_thinking
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
552 } ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 })
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
554
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
555 test-metaenv : MetaEnv
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 test-metaenv = record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 { DG = test-env1 ∷ test-env ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 ; meta = record { num-branch = zero ; wait-list = [] }
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
559 ; deadlock = true ; is-done = false ; is-step = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 }
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
561
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
562 test-metaenv1 : MetaEnv
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 test-metaenv1 = record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
564 { DG = test-env ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
565 ; meta = record { num-branch = zero ; wait-list = [] }
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 ; deadlock = true; is-done = false ; is-step = true
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 }
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 test-metaenv2 : MetaEnv2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 test-metaenv2 = record { DG = [] ; metal = test-metaenv ∷ [] }
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
570
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 test-metaenv3 : MetaEnv2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
572 test-metaenv3 = record { DG = [] ; metal = test-metaenv1 ∷ [] }
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
573
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
574
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
575
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
576 test-envl : List Env
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
577 test-envl = test-env1 ∷ test-env1 ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
578
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
579 testhoge : {n : Level} {t : Set n} → (env1 env2 : MetaEnv2) → (exit : MetaEnv2 → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 testhoge env1 env2 exit = loop-target-metaenv (metal env1) env2 exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
581 eq-pid : {n : Level} {t : Set n} → MetaEnv2 → (phl1 phl2 : List Phi) → (p1 p2 : Phi) → (exit : MetaEnv2 → t) → (loop : Bool → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
582 eq-lhand : {n : Level} {t : Set n} → MetaEnv2 → (phl1 phl2 : List Phi) → (p1 p2 : Phi) → (exit : MetaEnv2 → t ) → ( loop : Bool → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
583 eq-rhand : {n : Level} {t : Set n} → MetaEnv2 → (phl1 phl2 : List Phi) → (p1 p2 : Phi) → (exit : MetaEnv2 → t ) → ( loop : Bool → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
584 eq-next-code : {n : Level} {t : Set n} → MetaEnv2 → (phl1 phl2 : List Phi) → (p1 p2 : Phi) → (exit : MetaEnv2 → t ) → ( loop : Bool → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
585 eq-env : {n : Level} {t : Set n} → MetaEnv2 → ( e1 e2 : List Phi) → (exit : MetaEnv2 → t) → (loop : Bool → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
586
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
587 loop-metaenv : {n : Level} {t : Set n} → MetaEnv → (origin : MetaEnv2) → (f b : List MetaEnv) → (exit : MetaEnv2 → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
588
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
589 loop-target-metaenv : {n : Level} {t : Set n} → (env1 : List MetaEnv) → ( env2 : MetaEnv2) → (exit : MetaEnv2 → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 loop-target-metaenv [] metaenv2 exit = exit metaenv2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
591 loop-target-metaenv (metaenv ∷ metaenvl) metaenv2 exit = loop-metaenv metaenv metaenv2 [] (metal metaenv2) (λ e → loop-target-metaenv metaenvl e exit)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
592
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
593 boolor : Bool → Bool → Bool
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 boolor true true = true
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
595 boolor true false = true
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 boolor false true = true
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 boolor false false = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
598
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
599 loop-metaenv me origin f [] exit = exit (record origin{metal = me ∷ (metal origin) }) -- not found & add state to origin
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 loop-metaenv me origin f (x ∷ metaenvl) exit with DG me
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 ... | [] = exit origin
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
602 ... | env1 ∷ envl with DG x
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
603 ... | [] = loop-metaenv me origin (f ++ (x ∷ [])) metaenvl exit
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 ... | env2 ∷ history = eq-env origin (ph env1) (ph env2) (λ exit-e → exit record origin{metal = f ++ (record x{is-done = boolor (is-done me) (is-done x); is-step = boolor (is-step me) (is-step x) } ∷ metaenvl)}) (λ e → loop-metaenv me origin (f ++ (x ∷ [])) metaenvl exit )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
605
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
606 eq-env origin [] [] exit loop = exit origin -- true
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
607 eq-env origin [] (x ∷ pl2) exit loop = loop false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
608 eq-env origin (p1 ∷ pl1) [] exit loop = loop false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
609 eq-env origin (p1 ∷ pl1) (p2 ∷ pl2) exit loop = eq-pid origin pl1 pl2 p1 p2 exit (λ e → loop e) -- prototype
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
610
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
611 eq-pid origin pl1 pl2 p1 p2 next1 exit1 with <-cmp (pid p1) (pid p2)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
612 ... | tri< a ¬b ¬c = exit1 false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
613 ... | tri> ¬a ¬b c = exit1 false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
614 ... | tri≈ ¬a b ¬c = eq-lhand origin pl1 pl2 p1 p2 next1 exit1
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
615
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
616 eq-lhand origin pl1 pl2 phi1 phi2 next1 exit1 with (left-hand phi1)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
617 ... | sss with (left-hand phi2)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
618 eq-lhand origin pl1 pl2 phi1 phi2 next1 exit1 | true | true = eq-rhand origin pl1 pl2 phi1 phi2 next1 exit1
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
619 eq-lhand origin pl1 pl2 phi1 phi2 next1 exit1 | true | false = exit1 false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
620 eq-lhand origin pl1 pl2 phi1 phi2 next1 exit1 | false | true = exit1 false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
621 eq-lhand origin pl1 pl2 phi1 phi2 next1 exit1 | false | false = eq-rhand origin pl1 pl2 phi1 phi2 next1 exit1
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
622
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
623 eq-rhand origin pl1 pl2 phi1 phi2 next1 exit1 with (right-hand phi1)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
624 ... | sss with (right-hand phi2)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
625 eq-rhand origin pl1 pl2 phi1 phi2 next1 exit1 | true | true = eq-next-code origin pl1 pl2 phi1 phi2 next1 exit1
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
626 eq-rhand origin pl1 pl2 phi1 phi2 next1 exit1 | true | false = exit1 false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
627 eq-rhand origin pl1 pl2 phi1 phi2 next1 exit1 | false | true = exit1 false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
628 eq-rhand origin pl1 pl2 phi1 phi2 next1 exit1 | false | false = eq-next-code origin pl1 pl2 phi1 phi2 next1 exit1
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
629
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
630 eq-next-code origin pl1 pl2 p1 p2 next1 loop with (next-code p1)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
631 ... | sss with (next-code p2)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
632 eq-next-code origin pl1 pl2 p1 p2 next1 loop | C_putdown_rfork | C_putdown_rfork = eq-env origin pl1 pl2 next1 loop
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
633 eq-next-code origin pl1 pl2 p1 p2 next1 loop | C_putdown_rfork | _ = loop false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
634 eq-next-code origin pl1 pl2 p1 p2 next1 loop | C_putdown_lfork | C_putdown_lfork = eq-env origin pl1 pl2 next1 loop
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
635 eq-next-code origin pl1 pl2 p1 p2 next1 loop | C_putdown_lfork | _ = loop false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
636 eq-next-code origin pl1 pl2 p1 p2 next1 loop | C_thinking | C_thinking = eq-env origin pl1 pl2 next1 loop
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
637 eq-next-code origin pl1 pl2 p1 p2 next1 loop | C_thinking | _ = loop false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 eq-next-code origin pl1 pl2 p1 p2 next1 loop | C_pickup_rfork | C_pickup_rfork = eq-env origin pl1 pl2 next1 loop
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
639 eq-next-code origin pl1 pl2 p1 p2 next1 loop | C_pickup_rfork | _ = loop false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
640 eq-next-code origin pl1 pl2 p1 p2 next1 loop | C_pickup_lfork | C_pickup_lfork = eq-env origin pl1 pl2 next1 loop
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
641 eq-next-code origin pl1 pl2 p1 p2 next1 loop | C_pickup_lfork | _ = loop false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
642 eq-next-code origin pl1 pl2 p1 p2 next1 loop | C_eating | C_eating = eq-env origin pl1 pl2 next1 loop
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
643 eq-next-code origin pl1 pl2 p1 p2 next1 loop | C_eating | _ = loop false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
644
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 -- testhoge test-env test-env1
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
646
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
647 {-
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 testhoge record { table = table₁ ; ph = [] } record { table = table ; ph = [] } = true -- same table? is that realy true ?
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
649 testhoge record { table = table₁ ; ph = [] } record { table = table ; ph = (x ∷ ph₁) } = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
650 testhoge record { table = table₁ ; ph = (x ∷ ph₁) } record { table = table ; ph = [] } = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
651 testhoge record { table = table₁ ; ph = pl1@(x ∷ ph₁) } record { table = table ; ph = pl2@(x₁ ∷ ph₂) } = {!!}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
652 -}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
653
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
654
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
655
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
656 exec-brute-force-meta : {n : Level} {t : Set n} → ℕ → List MetaEnv → (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
657 exec-brute-force-meta n metaenvl exit = exec-brute-force-p n metaenvl exit where
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
658 exec-brute-force-p : {n : Level} {t : Set n} → ℕ → List MetaEnv → (exit : List MetaEnv → t) → t
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
659 exec-brute-force-p zero envll exit = exit envll
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
660 exec-brute-force-p (suc n) envll exit = branch-deadlock-check envll (λ e1 → step-brute-force-meta e1 (λ e2 → step-deadlock-check e2 (λ e3 → judge-deadlock e3 (λ e4 → exec-brute-force-p n e4 exit))))
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
661
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
662
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
663 test-dead-lock : List MetaEnv
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 test-dead-lock = exec-brute-force-meta 3 (record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
665 { DG = (record {
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
666 table = 0 ∷ 0 ∷ 0 ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
667 ; ph = record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
668 { pid = 1
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
669 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
670 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
671 ; next-code = C_thinking
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
672 } ∷ record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
673 { pid = 2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
674 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
675 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
676 ; next-code = C_pickup_rfork
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
677 } ∷ record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
678 { pid = 3
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
679 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
680 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
681 ; next-code = C_pickup_rfork
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
682 } ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
683 }∷ [])
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
684 ; meta = record { num-branch = zero ; wait-list = [] }
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
685 ; deadlock = false; is-done = false ; is-step = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
686 } ∷ []) (λ e3 → e3)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
687
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
688 test-dead-lock-meta2 : MetaEnv2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
689 test-dead-lock-meta2 = branch-search-meta2 (record { DG = (record { table = 0 ∷ 0 ∷ 0 ∷ [] ; ph = record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
690 { pid = 1
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
691 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
692 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
693 ; next-code = C_thinking
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
694 } ∷ record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
695 { pid = 2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
696 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
697 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
698 ; next-code = C_pickup_rfork
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
699 } ∷ record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
700 { pid = 3
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
701 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
702 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 ; next-code = C_pickup_rfork
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704 } ∷ [] } ∷ []) ∷ [] ; metal = [] }) (λ me0 → check-same-env-test me0 (λ me1 → step-meta2 me1 (λ me2 → branch-search-meta2 me2 ( λ me3 → testhoge me3 me2 (λ me4 → check-same-env-test me4 (λ me5 → me5))) (λ e → e) ) (λ e → e) )) (λ e → e)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
705
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
706
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
707 test-dead-lock-meta21 : MetaEnv2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
708 test-dead-lock-meta21 = branch-search-meta2 (record { DG = (record { table = 0 ∷ 0 ∷ 0 ∷ [] ; ph = record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
709 { pid = 1
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
710 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
711 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
712 ; next-code = C_thinking
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
713 } ∷ record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
714 { pid = 2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
715 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
716 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
717 ; next-code = C_pickup_rfork
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
718 } ∷ record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
719 { pid = 3
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
721 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
722 ; next-code = C_pickup_rfork
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
723 } ∷ [] } ∷ []) ∷ [] ; metal = [] }) (λ me0 → check-same-env-test me0 (λ me1 → step-meta2 me1 (λ me2 → branch-search-meta2 me2 ( λ me3 → testhoge me3 me2 (λ me4 → check-same-env-test me4 (λ me5 → me5))) (λ e → e) ) (λ e → e) )) (λ e → e)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
724
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
725
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
726 test-dead-lock-meta22 : ℕ → MetaEnv2 → MetaEnv2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
727 test-dead-lock-meta22 zero metaenv2 = metaenv2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
728 test-dead-lock-meta22 (suc n) metaenv2 = branch-search-meta2 metaenv2 (λ me1 → testhoge me1 metaenv2 (λ me2 → step-meta2 me2 (λ me3 → testhoge me3 me2 (λ me4 → test-dead-lock-meta22 n me4) ) (λ e → e)) ) (λ e → e)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
729
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
730 {-# TERMINATING #-}
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
731 test-dead-lock-loop : MetaEnv2 → MetaEnv2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
732 test-dead-lock-loop metaenv2 = branch-search-meta2 metaenv2 (λ me1 → testhoge me1 metaenv2 (λ me2 → step-meta2 me2 (λ me3 → testhoge me3 me2 (λ me4 → test-dead-lock-loop me4) ) (λ e → e)) ) (λ e → e)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
733
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
734 -- test-dead-lock-loop test-metaenv2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
735
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
736 test-step-c2 : List (List Env)
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
737 test-step-c2 = init-brute-force (record {
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
738 table = 0 ∷ 0 ∷ 0 ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
739 ; ph = record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
740 { pid = 1
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
741 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
742 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
743 ; next-code = C_thinking
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
744 } ∷ record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
745 { pid = 2
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
746 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
747 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
748 ; next-code = C_pickup_rfork
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
749 } ∷ record
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
750 { pid = 3
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
751 ; left-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
752 ; right-hand = false
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
753 ; next-code = C_pickup_rfork
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 } ∷ []
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
755 } ∷ []) (λ e0 → exec-brute-force 2 e0 (λ e2 → e2))
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
756
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
757 -- 以下メモ
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
758
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 -- eathingの状態はいらない Done
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
760 -- tableはℕのList Done
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 -- いきなりsearchしないで実行結果を持つ感じに
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
762 -- stubを使うとCodeの引数がスマートになるのでやる
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
763
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
764 -- 実行結果をListでもっているので、stepをじっこうしても変化がなかった場合をdeadlockとして検出したい
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
765 -- 東恩納先輩とおなじように、waitに入れて評価する
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
766
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
767 -- 余裕があったらassertにLTLの話をいれる
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
768
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
769 -- loop execution
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
770
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
771 -- concurrnt execution
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
772
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
773 -- state db ( binary tree of processes )
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
774
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
775 -- depth first ececution
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
776
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
777 -- verify temporal logic poroerries
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
778
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
779
0425278b683b Add dpp
soto <soto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
780