-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from StrykerKKD/split_up
Spliting up and refactoring examples
- Loading branch information
Showing
9 changed files
with
269 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(executables | ||
(names example knowledge_base) | ||
(public_names example knowledge_base) | ||
(names example friends parents lovers map_coloring murder_mystery) | ||
(public_names example friends parents lovers map_coloring murder_mystery) | ||
(libraries logical base)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,26 @@ | ||
open Logical | ||
|
||
let print_state_stream title state_stream = | ||
print_endline title; | ||
let state_list = Base.Sequence.to_list state_stream in | ||
Base.List.iter state_list ~f:(fun element -> | ||
match element with | ||
| Some value -> State.to_string value |> print_endline | ||
| None -> () | ||
); | ||
print_newline () | ||
|
||
let equal_result = Goal.equal (Value.var "a") (Value.int 1) State.empty | ||
let () = print_state_stream "equal_result" equal_result | ||
let () = Util.print_state_stream "equal_result" equal_result | ||
|
||
let either_result = Goal.either | ||
(Goal.equal (Value.var "a") (Value.int 1)) | ||
(Goal.equal (Value.var "b") (Value.int 2)) | ||
State.empty | ||
let () = print_state_stream "either_result" either_result | ||
let () = Util.print_state_stream "either_result" either_result | ||
|
||
let either_result_multi = Goal.either_multi | ||
[Goal.equal (Value.var "a") (Value.int 1); Goal.equal (Value.var "b") (Value.int 2); | ||
Goal.equal (Value.var "b") (Value.int 3);] | ||
State.empty | ||
let () = print_state_stream "either_result_multi" either_result_multi | ||
let () = Util.print_state_stream "either_result_multi" either_result_multi | ||
|
||
let both_result = Goal.both | ||
(Goal.equal (Value.var "a") (Value.int 1)) | ||
(Goal.equal (Value.var "b") (Value.int 2)) | ||
State.empty | ||
let () = print_state_stream "both_result" both_result | ||
let () = Util.print_state_stream "both_result" both_result | ||
|
||
let my_set = Base.Set.of_list (module Type) [Value.int 1; Value.int 2; Value.int 3] | ||
let in_set_result = Goal.in_set (Value.var "a") my_set State.empty | ||
let () = print_state_stream "in_set_result" in_set_result | ||
let () = Util.print_state_stream "in_set_result" in_set_result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
open Logical | ||
|
||
let first_friend_var = "first_friend_var" | ||
let second_friend_var = "second_friend_var" | ||
|
||
let friend first_friend second_friend = | ||
Goal.both | ||
(Goal.equal (Value.var first_friend_var) (Value.str first_friend)) | ||
(Goal.equal (Value.var second_friend_var) (Value.str second_friend)) | ||
|
||
let friend_refl first_friend second_friend = | ||
Goal.either | ||
(friend first_friend second_friend) | ||
(friend second_friend first_friend) | ||
|
||
let friend_db = | ||
Goal.either_multi [ | ||
friend "john" "julia"; | ||
friend "john" "jack"; | ||
friend "julia" "sam"; | ||
friend "julia" "molly"; | ||
] | ||
|
||
let friend_refl_db = | ||
Goal.either_multi [ | ||
friend_refl "john" "julia"; | ||
friend_refl "john" "jack"; | ||
friend_refl "julia" "sam"; | ||
friend_refl "julia" "molly"; | ||
] | ||
|
||
let friend_refl_querying first_friend second_friend = | ||
Goal.either | ||
(fun state -> friend_db (State.create_exn [first_friend_var,first_friend; second_friend_var,second_friend])) | ||
(fun state -> friend_db (State.create_exn [first_friend_var,second_friend; second_friend_var,first_friend])) | ||
State.empty | ||
|
||
let friend_querying first_friend second_friend = | ||
friend_refl_db (State.create_exn [first_friend_var, first_friend; second_friend_var, second_friend]) | ||
|
||
let friend_normal_query_state_stream = friend_querying (Value.str "julia") (Value.str "john") | ||
let _ = Util.print_state_stream "Friends: using normal query on refl DB" friend_normal_query_state_stream | ||
|
||
|
||
let friend_refl_query_state_stream = friend_refl_querying (Value.str "julia") (Value.str "john") | ||
let _ = Util.print_state_stream "Friends: using refl query on simple DB" friend_refl_query_state_stream |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.