Skip to content

Commit c9fd5a1

Browse files
committed
Lahenda fixpoint praktikumis
1 parent 14e17c7 commit c9fd5a1

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/fixpoint/fixpoint.ml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,24 @@ struct
2323
(** Leiab funktsiooni vähima püsipunkti.
2424
Kasutada fp funktsiooni. *)
2525
let lfp (f: D.t -> D.t): D.t =
26-
failwith "TODO"
26+
fp f D.empty
2727

2828
(** Leiab funktsiooni sulundi, mis sisaldab antud väärtusi.
2929
Kasutada lfp funktsiooni. *)
3030
let closure (f: D.t -> D.t) (initial: D.t): D.t =
31-
failwith "TODO"
31+
lfp (fun x -> D.union initial (f x))
3232

3333
(** Leiab agara distributiivse funktsiooni sulundi, mis sisaldab antud väärtusi.
3434
Pole vaja kasutada fp/lfp funktsiooni. *)
3535
let closure_strict_distr (f: D.t -> D.t) (initial: D.t): D.t =
36-
failwith "TODO"
36+
let rec helper closure frontier =
37+
(* if D.is_empty frontier then *)
38+
if D.subset frontier closure then
39+
closure
40+
else
41+
(* helper (D.union closure frontier) (f frontier) *)
42+
let closure' = D.union closure frontier in
43+
helper closure' (D.diff (f frontier) closure')
44+
in
45+
helper D.empty initial
3746
end

test/fixpoint/nfa_eps_test.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ let nfa_eps = function
1919

2020
(** Epsilonsammude funktsioon hulgal. *)
2121
let nfa_eps_set states =
22+
(* IntSet.of_list (List.concat_map nfa_eps (IntSet.elements states)) *)
2223
IntSet.elements states
2324
|> List.concat_map nfa_eps
2425
|> IntSet.of_list

0 commit comments

Comments
 (0)