From 2fefd55550808f630190c89c6d9b3f6bfed3f164 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Thu, 1 Oct 2015 21:11:58 +0200 Subject: Figures and hints updated for mother/2, father/2, and grandparent/2 problems. --- prolog/problems/family_relations/father_2/common.py | 7 +++++++ prolog/problems/family_relations/father_2/sl.py | 18 +++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'prolog/problems/family_relations/father_2') diff --git a/prolog/problems/family_relations/father_2/common.py b/prolog/problems/family_relations/father_2/common.py index cbfbcab..1643066 100644 --- a/prolog/problems/family_relations/father_2/common.py +++ b/prolog/problems/family_relations/father_2/common.py @@ -21,6 +21,7 @@ father(X, Y) :- hint_type = { 'or_instead_of_and': Hint('or_instead_of_and'), + 'or_instead_of_and_two_rules': Hint('or_instead_of_and_two_rules'), 'x_must_be_male': Hint('x_must_be_male'), 'x_must_be_parent': Hint('x_must_be_parent'), 'y_can_be_of_any_gender': Hint('y_can_be_of_any_gender'), @@ -80,6 +81,12 @@ def hint(program, solved_problems): 'findall(_, father(X, Y), L), length(L, 48)'): return [{'id': 'or_instead_of_and'}] + # OR instead of AND written with two rules, namely: + # (r1) father(X, Y):- male(X). (r2) father(X, Y):- parent(X, Y). + if prolog.engine.ask_truth(engine_id, + 'findall(_, father(X, Y), L), length(L, 48)'): + return [{'id': 'or_instead_of_and_two_rules'}] + # X must be male if prolog.engine.ask_truth(engine_id, 'female(X), father(X, _)'): return [{'id': 'x_must_be_male'}] diff --git a/prolog/problems/family_relations/father_2/sl.py b/prolog/problems/family_relations/father_2/sl.py index ee6893b..67bf764 100644 --- a/prolog/problems/family_relations/father_2/sl.py +++ b/prolog/problems/family_relations/father_2/sl.py @@ -17,28 +17,32 @@ description = '''\ plan = [ '''\ -

-

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

''', +

Oče ima otroka in je moškega spola.

''', '''\ -

''', +

Oče X je starš od Y in je moškega spola.

''', '''\ -

Če je X ženska in je hkrati X starš od Y, -potem je X mama od Y.

''' +

Če je X moški in je hkrati X starš od Y, +potem je X oče od Y.

''' ] hint = { 'or_instead_of_and': '''\

Si morda uporabil podpičje (ki pomeni ALI) namesto vejice (ki pomeni IN)?

+''', + + 'or_instead_of_and_two_rules': '''\ +

Si morda zapisal dve pravili, eno za spol in eno za "starševstvo"? +Pozor: velja eno ALI drugo, ne nujno eno IN drugo!

''', 'x_must_be_male': '''\

Oče je navadno moškega spola.

-

+

''', 'x_must_be_parent': '''\

Oče naj bi imel vsaj enega otroka... torej je starš od nekoga.

-

+

''', 'y_can_be_of_any_gender': '''\ -- cgit v1.2.1