annotate ModelChecking.agda @ 636:1c8dca459d9a

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 14 Nov 2021 15:50:30 +0900
parents aee8de02dfe0
children e30dcd03c07f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
635
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module ModelChecking where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import Level renaming (zero to Z ; suc to succ)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Data.Nat hiding (compare)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import Data.Nat.Properties as NatProp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 open import Data.Maybe
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 -- open import Data.Maybe.Properties
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 open import Data.Empty
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 open import Data.List
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 open import Data.Product
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 open import Function as F hiding (const)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 open import Relation.Binary
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 open import Relation.Binary.PropositionalEquality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 open import Relation.Nullary
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 open import logic
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 open import Data.Unit hiding ( _≟_ ; _≤?_ ; _≤_)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 open import Relation.Binary.Definitions
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 record AtomicNat : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 value : ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 set : {n : Level } {t : Set n} → AtomicNat → (value : ℕ) → ( AtomicNat → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 set a v next = next record { value = v }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 record Phils : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 pid : ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 left right : AtomicNat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 putdown_rfork : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 putdown_rfork p next = set (Phils.right p) 0 ( λ f → next record p { right = f } )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 putdown_lfork : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 putdown_lfork p next = set (Phils.left p) 0 ( λ f → next record p { left = f } )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 thinking : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 thinking p next = next p
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 pickup_rfork : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
Shinji KONO <kono@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 } )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 pickup_lfork : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
Shinji KONO <kono@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 } )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 eating : {n : Level} {t : Set n} → Phils → ( Phils → t ) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 eating p next = next p
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49
636
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
50 data Code : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
51 C_set : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
52 C_putdown_rfork : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
53 C_putdown_lfork : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
54 C_thinking : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
55 C_pickup_rfork : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
56 C_pickup_lfork : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
57 C_eating : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
58
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
59 record Process : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
60 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
61 phil : Phils
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
62 next : Code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
63
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
64 putdown_rfork_stub : {n : Level} {t : Set n} → Process → ( Process → t) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
65 putdown_rfork_stub p next = putdown_rfork ( Process.phil p ) ( λ ph → next record p { phil = ph ; next = C_putdown_lfork } )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
66
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
67 code_table : {n : Level} {t : Set n} → Code → Process → ( Process → t) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
68 code_table C_set = ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
69 code_table C_putdown_rfork = putdown_rfork_stub
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
70 code_table C_putdown_lfork = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
71 code_table C_thinking = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
72 code_table C_pickup_rfork = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
73 code_table C_pickup_lfork = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
74 code_table C_eating = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
75
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
76 step : {n : Level} {t : Set n} → List Process → (List Process → t) → t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
77 step = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
78
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
79
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
80
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 635
diff changeset
81