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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621

:- dynamic term_expansion/2.
:- multifile term_expansion/2.


great_grandfather(X, Y) :-
    great_grandparent(X, Y),
    male(Y).

great_grandchild(X, Y) :-
    great_grandparent(Y, X).

great_grandparent(X, Y) :-
    grandparent(X, Z),
    parent(Z, Y).

:- dynamic library_directory/1.
:- multifile library_directory/1.


great_grandmother(X, Y) :-
    great_grandparent(X, Y),
    female(Y).

:- dynamic goal_expansion/4.
:- multifile goal_expansion/4.


:- dynamic hobby/2.

hobby("Ana Colin", "amateur astronomy").
hobby("Antionette Song", "crystals").
hobby("Danilo Colin", "stamp collecting").
hobby("Deirdre Bivins", "trainspotting").
hobby("Eddie Song", "animation").
hobby("Gene Song", "esports").
hobby("Genesis Colin", "magnet fishing").
hobby("Hannah Bivins", "billiards").
hobby("Jamal Song", "iceboat racing").
hobby("Jeana Song", "aerospace").
hobby("Jesse Kiel", "learning").
hobby("Jolene Song", "meteorology").
hobby("Lance Kiel", "learning").
hobby("Lester Bivins", "trapshooting").
hobby("Lynda Colin", "shoes").
hobby("Maynard Song", "meteorology").
hobby("Mckinley Colin", "birdwatching").
hobby("Meghann Kidd", "mahjong").
hobby("Melvin Kidd", "horseback riding").
hobby("Nikki Kidd", "birdwatching").
hobby("Nina Song", "air sports").
hobby("Ramona Colin", "publishing").
hobby("Sol Song", "fossicking").
hobby("Tory Song", "dolls").
hobby("Yvette Song", "web design").

granddaughter(X, Y) :-
    grandchild(X, Y),
    female(Y).

grandson(X, Y) :-
    grandchild(X, Y),
    male(Y).

:- dynamic job/2.

job("Ana Colin", "academic librarian").
job("Antionette Song", "clinical research associate").
job("Danilo Colin", "museum curator").
job("Deirdre Bivins", "technical sales engineer").
job("Eddie Song", "advertising account planner").
job("Gene Song", "toxicologist").
job("Genesis Colin", "education administrator").
job("Hannah Bivins", "colour technologist").
job("Jamal Song", "regulatory affairs officer").
job("Jeana Song", "gaffer").
job("Jesse Kiel", "producer").
job("Jolene Song", "newspaper journalist").
job("Lance Kiel", "social researcher").
job("Lester Bivins", "learning disability nurse").
job("Lynda Colin", "interior and spatial designer").
job("Maynard Song", "pharmacologist").
job("Mckinley Colin", "investment banker").
job("Meghann Kidd", "biomedical engineer").
job("Melvin Kidd", "marketing executive").
job("Nikki Kidd", "chartered legal executive").
job("Nina Song", "public relations officer").
job("Ramona Colin", "nutritional therapist").
job("Sol Song", "psychotherapist").
job("Tory Song", "production designer").
job("Yvette Song", "phytotherapist").

great_uncle(X, Y) :-
    grandparent(X, A),
    brother(A, Y).

:- dynamic save_all_clauses_to_file/1.

save_all_clauses_to_file(A) :-
    open(A, write, B),
    set_output(B),
    listing,
    close(B).

:- dynamic term_expansion/4.
:- multifile term_expansion/4.


grandchild(X, Y) :-
    grandparent(Y, X).

:- dynamic dob/2.

dob("Ana Colin", "0935-04-16").
dob("Antionette Song", "0991-05-04").
dob("Danilo Colin", "0909-08-09").
dob("Deirdre Bivins", "1021-12-21").
dob("Eddie Song", "0935-01-05").
dob("Gene Song", "1016-07-28").
dob("Genesis Colin", "0935-10-02").
dob("Hannah Bivins", "0991-10-05").
dob("Jamal Song", "0961-07-23").
dob("Jeana Song", "0965-11-11").
dob("Jesse Kiel", "0878-11-05").
dob("Jolene Song", "1015-01-07").
dob("Lance Kiel", "0879-03-08").
dob("Lester Bivins", "0991-03-23").
dob("Lynda Colin", "0941-08-16").
dob("Maynard Song", "1023-05-28").
dob("Mckinley Colin", "0936-10-18").
dob("Meghann Kidd", "0929-12-23").
dob("Melvin Kidd", "0905-06-22").
dob("Nikki Kidd", "0903-01-28").
dob("Nina Song", "0936-08-07").
dob("Ramona Colin", "0909-09-08").
dob("Sol Song", "0993-10-31").
dob("Tory Song", "1042-12-18").
dob("Yvette Song", "0962-11-01").

:- dynamic file_search_path/2.
:- multifile file_search_path/2.

file_search_path(library, Dir) :-
    library_directory(Dir).
file_search_path(swi, A) :-
    system:current_prolog_flag(home, A).
file_search_path(swi, A) :-
    system:current_prolog_flag(shared_home, A).
file_search_path(library, app_config(lib)).
file_search_path(library, swi(library)).
file_search_path(library, swi(library/clp)).
file_search_path(library, A) :-
    system:'$ext_library_directory'(A).
file_search_path(foreign, swi(A)) :-
    system:
    (   current_prolog_flag(apple_universal_binary, true),
        A='lib/fat-darwin'
    ).
file_search_path(path, A) :-
    system:
    (   getenv('PATH', B),
        current_prolog_flag(path_sep, C),
        atomic_list_concat(D, C, B),
        '$member'(A, D)
    ).
file_search_path(user_app_data, A) :-
    system:'$xdg_prolog_directory'(data, A).
file_search_path(common_app_data, A) :-
    system:'$xdg_prolog_directory'(common_data, A).
file_search_path(user_app_config, A) :-
    system:'$xdg_prolog_directory'(config, A).
file_search_path(common_app_config, A) :-
    system:'$xdg_prolog_directory'(common_config, A).
file_search_path(app_data, user_app_data('.')).
file_search_path(app_data, common_app_data('.')).
file_search_path(app_config, user_app_config('.')).
file_search_path(app_config, common_app_config('.')).
file_search_path(app_preferences, user_app_config('.')).
file_search_path(user_profile, app_preferences('.')).
file_search_path(app, swi(app)).
file_search_path(app, app_data(app)).
file_search_path(autoload, swi(library)).
file_search_path(autoload, pce(prolog/lib)).
file_search_path(autoload, app_config(lib)).
file_search_path(autoload, Dir) :-
    '$autoload':'$ext_library_directory'(Dir).
file_search_path(pack, app_data(pack)).
file_search_path(library, PackLib) :-
    '$pack':pack_dir(_Name, prolog, PackLib).
file_search_path(foreign, PackLib) :-
    '$pack':pack_dir(_Name, foreign, PackLib).
file_search_path(app, AppDir) :-
    '$pack':pack_dir(_Name, app, AppDir).

:- multifile prolog_list_goal/1.


:- dynamic type/2.

type("Ana Colin", person).
type("Antionette Song", person).
type("Danilo Colin", person).
type("Deirdre Bivins", person).
type("Eddie Song", person).
type("Gene Song", person).
type("Genesis Colin", person).
type("Hannah Bivins", person).
type("Jamal Song", person).
type("Jeana Song", person).
type("Jesse Kiel", person).
type("Jolene Song", person).
type("Lance Kiel", person).
type("Lester Bivins", person).
type("Lynda Colin", person).
type("Maynard Song", person).
type("Mckinley Colin", person).
type("Meghann Kidd", person).
type("Melvin Kidd", person).
type("Nikki Kidd", person).
type("Nina Song", person).
type("Ramona Colin", person).
type("Sol Song", person).
type("Tory Song", person).
type("Yvette Song", person).

grandfather(X, Y) :-
    grandparent(X, Y),
    male(Y).

:- dynamic expand_query/4.
:- multifile expand_query/4.


:- dynamic attribute/1.

attribute("academic librarian").
attribute("amateur astronomy").
attribute("clinical research associate").
attribute("crystals").
attribute("museum curator").
attribute("stamp collecting").
attribute("technical sales engineer").
attribute("trainspotting").
attribute("advertising account planner").
attribute("animation").
attribute("toxicologist").
attribute("esports").
attribute("education administrator").
attribute("magnet fishing").
attribute("colour technologist").
attribute("billiards").
attribute("regulatory affairs officer").
attribute("iceboat racing").
attribute("gaffer").
attribute("aerospace").
attribute("producer").
attribute("learning").
attribute("newspaper journalist").
attribute("meteorology").
attribute("social researcher").
attribute("learning").
attribute("learning disability nurse").
attribute("trapshooting").
attribute("interior and spatial designer").
attribute("shoes").
attribute("pharmacologist").
attribute("meteorology").
attribute("investment banker").
attribute("birdwatching").
attribute("biomedical engineer").
attribute("mahjong").
attribute("marketing executive").
attribute("horseback riding").
attribute("chartered legal executive").
attribute("birdwatching").
attribute("public relations officer").
attribute("air sports").
attribute("nutritional therapist").
attribute("publishing").
attribute("psychotherapist").
attribute("fossicking").
attribute("production designer").
attribute("dolls").
attribute("phytotherapist").
attribute("web design").

great_aunt(X, Y) :-
    grandparent(X, A),
    sister(A, Y).

grandparent(X, Y) :-
    parent(X, Z),
    parent(Z, Y).

grandmother(X, Y) :-
    grandparent(X, Y),
    female(Y).

:- dynamic friend_/2.

friend_("Ana Colin", "Danilo Colin").
friend_("Ana Colin", "Jamal Song").
friend_("Ana Colin", "Lance Kiel").
friend_("Ana Colin", "Ramona Colin").
friend_("Antionette Song", "Genesis Colin").
friend_("Antionette Song", "Jeana Song").
friend_("Antionette Song", "Nina Song").
friend_("Antionette Song", "Sol Song").
friend_("Danilo Colin", "Sol Song").
friend_("Danilo Colin", "Tory Song").
friend_("Deirdre Bivins", "Jamal Song").
friend_("Deirdre Bivins", "Lester Bivins").
friend_("Gene Song", "Meghann Kidd").
friend_("Gene Song", "Nina Song").
friend_("Genesis Colin", "Jeana Song").
friend_("Genesis Colin", "Jesse Kiel").
friend_("Genesis Colin", "Ramona Colin").
friend_("Hannah Bivins", "Lynda Colin").
friend_("Hannah Bivins", "Melvin Kidd").
friend_("Hannah Bivins", "Nina Song").
friend_("Jamal Song", "Lester Bivins").
friend_("Jamal Song", "Lynda Colin").
friend_("Jamal Song", "Melvin Kidd").
friend_("Jeana Song", "Jolene Song").
friend_("Jeana Song", "Melvin Kidd").
friend_("Jeana Song", "Ramona Colin").
friend_("Jesse Kiel", "Jolene Song").
friend_("Jesse Kiel", "Maynard Song").
friend_("Jolene Song", "Tory Song").
friend_("Lance Kiel", "Nina Song").
friend_("Lance Kiel", "Ramona Colin").
friend_("Lester Bivins", "Lynda Colin").
friend_("Lester Bivins", "Maynard Song").
friend_("Lester Bivins", "Nina Song").
friend_("Lester Bivins", "Tory Song").
friend_("Lynda Colin", "Ramona Colin").
friend_("Maynard Song", "Nina Song").
friend_("Mckinley Colin", "Melvin Kidd").
friend_("Meghann Kidd", "Sol Song").
friend_("Nikki Kidd", "Ramona Colin").

friend(X, Y) :-
    friend_(X, Y).
friend(X, Y) :-
    friend_(Y, X).

niece(X, Y) :-
    sibling(X, A),
    daughter(A, Y).

nephew(X, Y) :-
    sibling(X, A),
    son(A, Y).

brother_in_law(X, Y) :-
    married(X, A),
    brother(A, Y).

:- multifile message_property/2.


sister_in_law(X, Y) :-
    married(X, A),
    sister(A, Y).

wife(X, Y) :-
    married(X, Y),
    female(Y).

husband(X, Y) :-
    married(X, Y),
    male(Y).

daughter_in_law(X, Y) :-
    child(X, A),
    wife(A, Y).

son_in_law(X, Y) :-
    child(X, A),
    husband(A, Y).

son(X, Y) :-
    child(X, Y),
    male(Y).

female(X) :-
    gender(X, "female").

daughter(X, Y) :-
    child(X, Y),
    female(Y).

father_in_law(X, Y) :-
    married(X, A),
    father(A, Y).

mother_in_law(X, Y) :-
    married(X, A),
    mother(A, Y).

father(X, Y) :-
    parent(X, Y),
    male(Y).

:- multifile prolog_predicate_name/2.


child(X, Y) :-
    parent(Y, X).

male_first_cousin_once_removed(X, Y) :-
    cousin(X, A),
    son(A, Y),
    X\=Y.

:- multifile prolog_clause_name/2.


:- dynamic expand_answer/2.
:- multifile expand_answer/2.


:- dynamic exception/3.
:- multifile exception/3.


female_first_cousin_once_removed(X, Y) :-
    cousin(X, A),
    daughter(A, Y),
    X\=Y.

brother(X, Y) :-
    sibling(X, Y),
    male(Y).

mother(X, Y) :-
    parent(X, Y),
    female(Y).

male_second_cousin(X, Y) :-
    parent(X, A),
    parent(Y, B),
    cousin(A, B),
    male(Y),
    X\=Y.

:- dynamic message_hook/3.
:- multifile message_hook/3.


female_second_cousin(X, Y) :-
    parent(X, A),
    parent(Y, B),
    cousin(A, B),
    female(Y),
    X\=Y.

married(X, Y) :-
    parent(Child, X),
    parent(Child, Y),
    X\=Y.

male(X) :-
    gender(X, "male").

:- dynamic prolog_file_type/2.
:- multifile prolog_file_type/2.

prolog_file_type(pl, prolog).
prolog_file_type(prolog, prolog).
prolog_file_type(qlf, prolog).
prolog_file_type(qlf, qlf).
prolog_file_type(A, executable) :-
    system:current_prolog_flag(shared_object_extension, A).
prolog_file_type(dylib, executable) :-
    system:current_prolog_flag(apple, true).

sister(X, Y) :-
    sibling(X, Y),
    female(Y).

male_cousin(X, Y) :-
    cousin(X, Y),
    male(Y).

:- dynamic nonbinary/1.

nonbinary(X) :-
    gender(X, "nonbinary").

female_cousin(X, Y) :-
    cousin(X, Y),
    female(Y).

sibling(X, Y) :-
    parent(X, A),
    parent(Y, A),
    X\=Y.

:- dynamic portray/1.
:- multifile portray/1.


:- dynamic prolog_load_file/2.
:- multifile prolog_load_file/2.


:- dynamic goal_expansion/2.
:- multifile goal_expansion/2.


:- dynamic parent/2.

parent("Ana Colin", "Danilo Colin").
parent("Ana Colin", "Ramona Colin").
parent("Deirdre Bivins", "Hannah Bivins").
parent("Deirdre Bivins", "Lester Bivins").
parent("Gene Song", "Antionette Song").
parent("Gene Song", "Sol Song").
parent("Genesis Colin", "Melvin Kidd").
parent("Genesis Colin", "Nikki Kidd").
parent("Hannah Bivins", "Jamal Song").
parent("Hannah Bivins", "Yvette Song").
parent("Jamal Song", "Eddie Song").
parent("Jamal Song", "Nina Song").
parent("Jeana Song", "Eddie Song").
parent("Jeana Song", "Nina Song").
parent("Lynda Colin", "Danilo Colin").
parent("Lynda Colin", "Ramona Colin").
parent("Maynard Song", "Antionette Song").
parent("Maynard Song", "Sol Song").
parent("Mckinley Colin", "Danilo Colin").
parent("Mckinley Colin", "Ramona Colin").
parent("Meghann Kidd", "Melvin Kidd").
parent("Meghann Kidd", "Nikki Kidd").
parent("Ramona Colin", "Jesse Kiel").
parent("Ramona Colin", "Lance Kiel").
parent("Sol Song", "Jamal Song").
parent("Sol Song", "Yvette Song").
parent("Tory Song", "Gene Song").
parent("Tory Song", "Jolene Song").
parent("Yvette Song", "Genesis Colin").
parent("Yvette Song", "Mckinley Colin").

cousin(X, Y) :-
    parent(X, A),
    parent(Y, B),
    sibling(A, B),
    X\=Y.

uncle(X, Y) :-
    parent(X, A),
    brother(A, Y).

:- dynamic resource/3.
:- multifile resource/3.


:- thread_local thread_message_hook/3.
:- dynamic thread_message_hook/3.
:- volatile thread_message_hook/3.


aunt(X, Y) :-
    parent(X, A),
    sister(A, Y).

second_uncle(X, Y) :-
    great_grandparent(X, A),
    brother(A, Y).

:- dynamic gender/2.

gender("Ana Colin", "female").
gender("Antionette Song", "female").
gender("Danilo Colin", "male").
gender("Deirdre Bivins", "female").
gender("Eddie Song", "male").
gender("Gene Song", "male").
gender("Genesis Colin", "female").
gender("Hannah Bivins", "female").
gender("Jamal Song", "male").
gender("Jeana Song", "female").
gender("Jesse Kiel", "female").
gender("Jolene Song", "female").
gender("Lance Kiel", "male").
gender("Lester Bivins", "male").
gender("Lynda Colin", "female").
gender("Maynard Song", "male").
gender("Mckinley Colin", "male").
gender("Meghann Kidd", "female").
gender("Melvin Kidd", "male").
gender("Nikki Kidd", "female").
gender("Nina Song", "female").
gender("Ramona Colin", "female").
gender("Sol Song", "male").
gender("Tory Song", "female").
gender("Yvette Song", "female").

second_aunt(X, Y) :-
    great_grandparent(X, A),
    sister(A, Y).

great_grandson(X, Y) :-
    great_grandchild(X, Y),
    male(Y).

:- dynamic pyrun/2.

pyrun(A, B) :-
    read_term_from_atom(A, C, [variable_names(B)]),
    call(C).

great_granddaughter(X, Y) :-
    great_grandchild(X, Y),
    female(Y).

:- dynamic resource/2.
:- multifile resource/2.