annotate ModelChecking.agda @ 635:aee8de02dfe0

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 14 Nov 2021 14:55:22 +0900
parents
children 1c8dca459d9a
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