From 86bfc55d2ddc19b79127f2c788609635b702dbfd Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Sat, 17 Oct 2015 20:04:54 +0200 Subject: Family relations section fully hint-ready (just a few minor things missing). --- .../family_relations/aunt_2/Prolog_aunt_01.svg | 425 ++++++++++++++ .../family_relations/aunt_2/Prolog_aunt_02.svg | 402 +++++++++++++ .../family_relations/aunt_2/Prolog_aunt_03.svg | 639 +++++++++++++++++++++ .../family_relations/aunt_2/Prolog_aunt_04.svg | 560 ++++++++++++++++++ .../family_relations/aunt_2/Prolog_aunt_05.svg | 576 +++++++++++++++++++ .../family_relations/aunt_2/Prolog_aunt_06.svg | 425 ++++++++++++++ .../family_relations/aunt_2/Prolog_aunt_07.svg | 463 +++++++++++++++ prolog/problems/family_relations/aunt_2/common.py | 28 +- prolog/problems/family_relations/aunt_2/sl.py | 21 +- 9 files changed, 3529 insertions(+), 10 deletions(-) create mode 100644 prolog/problems/family_relations/aunt_2/Prolog_aunt_01.svg create mode 100644 prolog/problems/family_relations/aunt_2/Prolog_aunt_02.svg create mode 100644 prolog/problems/family_relations/aunt_2/Prolog_aunt_03.svg create mode 100644 prolog/problems/family_relations/aunt_2/Prolog_aunt_04.svg create mode 100644 prolog/problems/family_relations/aunt_2/Prolog_aunt_05.svg create mode 100644 prolog/problems/family_relations/aunt_2/Prolog_aunt_06.svg create mode 100644 prolog/problems/family_relations/aunt_2/Prolog_aunt_07.svg (limited to 'prolog/problems/family_relations/aunt_2') diff --git a/prolog/problems/family_relations/aunt_2/Prolog_aunt_01.svg b/prolog/problems/family_relations/aunt_2/Prolog_aunt_01.svg new file mode 100644 index 0000000..7b55826 --- /dev/null +++ b/prolog/problems/family_relations/aunt_2/Prolog_aunt_01.svg @@ -0,0 +1,425 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/prolog/problems/family_relations/aunt_2/Prolog_aunt_02.svg b/prolog/problems/family_relations/aunt_2/Prolog_aunt_02.svg new file mode 100644 index 0000000..1c994f5 --- /dev/null +++ b/prolog/problems/family_relations/aunt_2/Prolog_aunt_02.svg @@ -0,0 +1,402 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/prolog/problems/family_relations/aunt_2/Prolog_aunt_03.svg b/prolog/problems/family_relations/aunt_2/Prolog_aunt_03.svg new file mode 100644 index 0000000..8442518 --- /dev/null +++ b/prolog/problems/family_relations/aunt_2/Prolog_aunt_03.svg @@ -0,0 +1,639 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/prolog/problems/family_relations/aunt_2/Prolog_aunt_04.svg b/prolog/problems/family_relations/aunt_2/Prolog_aunt_04.svg new file mode 100644 index 0000000..83b6685 --- /dev/null +++ b/prolog/problems/family_relations/aunt_2/Prolog_aunt_04.svg @@ -0,0 +1,560 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/prolog/problems/family_relations/aunt_2/Prolog_aunt_05.svg b/prolog/problems/family_relations/aunt_2/Prolog_aunt_05.svg new file mode 100644 index 0000000..4083a57 --- /dev/null +++ b/prolog/problems/family_relations/aunt_2/Prolog_aunt_05.svg @@ -0,0 +1,576 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/prolog/problems/family_relations/aunt_2/Prolog_aunt_06.svg b/prolog/problems/family_relations/aunt_2/Prolog_aunt_06.svg new file mode 100644 index 0000000..4042814 --- /dev/null +++ b/prolog/problems/family_relations/aunt_2/Prolog_aunt_06.svg @@ -0,0 +1,425 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/prolog/problems/family_relations/aunt_2/Prolog_aunt_07.svg b/prolog/problems/family_relations/aunt_2/Prolog_aunt_07.svg new file mode 100644 index 0000000..c9f3d5c --- /dev/null +++ b/prolog/problems/family_relations/aunt_2/Prolog_aunt_07.svg @@ -0,0 +1,463 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/prolog/problems/family_relations/aunt_2/common.py b/prolog/problems/family_relations/aunt_2/common.py index 51bc99a..df1a272 100644 --- a/prolog/problems/family_relations/aunt_2/common.py +++ b/prolog/problems/family_relations/aunt_2/common.py @@ -27,14 +27,21 @@ aunt(X, Y) :- hint_type = { 'x_and_y_mixed_up': Hint('x_and_y_mixed_up'), 'precedence_fail': Hint('precedence_fail'), + 'x_must_have_sibling': Hint('x_must_have_sibling'), 'x_must_be_female': Hint('x_must_be_female'), + 'y_must_have_parent': Hint('y_must_have_parent'), 'aunt_vs_mother': Hint('aunt_vs_mother'), 'x_need_not_be_parent': Hint('x_need_not_be_parent'), 'y_need_not_be_parent': Hint('y_need_not_be_parent'), } test_cases = [ - # TODO + ('aunt(X, _)', + [{'X': 'sally'}, {'X': 'melanie'}, {'X': 'vanessa'}, {'X': 'patricia'}]), + ('aunt(_, X)', + [{'X': 'vanessa'}, {'X': 'patricia'}, {'X': 'joanne'}, {'X': 'john'}, {'X': 'susan'}]), + ('aunt(sally, X)', + [{'X': 'vanessa'}, {'X': 'patricia'}]), ] def test(program, solved_problems): @@ -82,25 +89,36 @@ def hint(program, solved_problems): if prolog.engine.ask_truth(engine_id, 'findall(X/Y, aunt(X, Y), \ [vanessa/sally, patricia/sally, joanne/melanie, john/vanessa, susan/patricia])'): - return [{'id', 'x_and_y_mixed_up'}] + return [{'id': 'x_and_y_mixed_up'}] # precedence fail (AND block vs OR block) # case in point: female(X), parent(P, Y), brother(P, X) ; sister(P, X) # warning: knowledge base dependent if prolog.util.Token('SEMI', ';') in tokens and prolog.engine.ask_truth(engine_id, 'findall(_, aunt(X, Y), L), length(L, 15)'): - return [{'id', 'precedence_fail'}] + return [{'id': 'precedence_fail'}] # X must be female if prolog.engine.ask_truth(engine_id, 'aunt(X, _), male(X)'): - return [{'id', 'x_must_be_female'}] + return [{'id': 'x_must_be_female'}] + + # Y must have a parent + # perhaps risky as only one such nephew exists in DB (susan) + if prolog.engine.ask_truth(engine_id, + 'aunt(_, Y), \+ parent(_, Y)'): + return [{'id': 'y_must_have_parent'}] # X and P can be the same person # this can occur if the problem is not solved using sister/2 if prolog.engine.ask_truth(engine_id, 'aunt(X, Y), mother(X, Y)'): - return [{'id', 'aunt_vs_mother'}] + return [{'id': 'aunt_vs_mother'}] + + # X must have sibling + if prolog.engine.ask_truth(engine_id, + 'aunt(X, _), \+ (sister(X, _) ; brother(X, _))'): # TODO: Tim, can I use sister/brother predicates here? Or sister98? + return [{'id': 'x_must_have_sibling'}] # X does not necessarily need to be a parent # perhaps risky as only one aunt that is not a parent exists in DB (melanie) diff --git a/prolog/problems/family_relations/aunt_2/sl.py b/prolog/problems/family_relations/aunt_2/sl.py index 2bf0ef6..e5c3bb9 100644 --- a/prolog/problems/family_relations/aunt_2/sl.py +++ b/prolog/problems/family_relations/aunt_2/sl.py @@ -13,13 +13,12 @@ description = '''\ plan = ['''\

Morda lahko uporabiš rešitev kakšne prejšnje naloge?

-

-

Loni naj zbriše imena relacij (parent, sister) s te slike!

-''', '''\ -

+

Moj brat ali sestra ima otroka...

''', '''\

Če je X sestra od starša od Y, potem je X teta od Y.

+''', '''\ +

Sestra od starša od Y, je teta od Y.

'''] hint = { @@ -31,16 +30,27 @@ hint = {

Si morda narobe upošteval prioriteto operatorjev IN ter ALI?

Operator IN veže močneje od ALI, če želiš spremeniti prioriteto, lahko uporabiš oklepaje.

+''', + + 'x_must_have_sibling': '''\ +

Teta ima navadno brata ali sestro...

+

''', 'x_must_be_female': '''\

Teta je navadno ženskega spola.

+

''', # TODO: Loni should mark female gender on some aunt hints! + 'y_must_have_parent': '''\ +

Verjetno bi bilo smiselno, da ima nečak kakšnega starša?

+

+''', + 'aunt_vs_mother': '''\

Kako je teta lahko hkrati še mama od Y? Si morda pozabil, da teta in starš od Y ne smeta biti ista oseba?

-

+

''', 'x_need_not_be_parent': '''\ @@ -54,6 +64,7 @@ Si morda pozabil, da teta in starš od Y ne smeta biti ista oseba?< 'interesting_tidbit': '''\

Zanimivost: nalogo bi lahko rešil tudi z uporabo rešitve za relacijo "sister". Teta je namreč sestra od starša od Y.

+

''', # TODO: only trigger if sister is not part of correct solution } -- cgit v1.2.1