Skip to content

Commit 02d457f

Browse files
committed
Lahenda modelcheck praktikumis
1 parent 58c3900 commit 02d457f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/modelcheck/checker.ml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,27 @@ struct
77
module StateSet = Set.Make (Model)
88
module StateSetFP = Fixpoint.MakeSet (StateSet)
99

10-
10+
let f states =
11+
StateSet.elements states
12+
|> List.concat_map Model.step
13+
|> StateSet.of_list
1114

1215
(** Tagastab kõik saavutatavad olekud. *)
1316
let all_states (): StateSet.t =
14-
failwith "TODO"
17+
StateSetFP.closure f (StateSet.singleton Model.initial)
1518

16-
(** Tagastab kõik saavutatavad veaolekud. *)
19+
(** Tagastab kõik saavutatavad veaolekud.
20+
Vihje: StateSet.filter. *)
1721
let error_states (): StateSet.t =
18-
failwith "TODO"
22+
StateSet.filter Model.is_error (all_states ())
1923

2024
(** Kas mõni veaolek on saavutatav? *)
2125
let has_error (): bool =
22-
failwith "TODO"
26+
not (StateSet.is_empty (error_states ()))
2327

2428
(** Kas veaolekud on mittesaavutatavad? *)
2529
let is_correct (): bool =
26-
failwith "TODO"
30+
not (has_error ())
2731
end
2832

2933

0 commit comments

Comments
 (0)