Skip to content

Instantly share code, notes, and snippets.

@fusiongyro
Created February 9, 2019 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fusiongyro/a596dd9affaf0a65f25d606bf5c913d7 to your computer and use it in GitHub Desktop.
Save fusiongyro/a596dd9affaf0a65f25d606bf5c913d7 to your computer and use it in GitHub Desktop.
:- op(100,xf ,holds).
:- op(150,xfy, .).
:- op(200,xfx, if).
:- op(220,xfy,and_).
:- op(300,xfx,can_verify).
:- op(300,xfx,sees).
:- op(300,xfx,is_deducible_from).
:- op(300, fx,it_is_deducible_that).
:- op(300,xf ,is_false).
:- op(320,xfy,and).
:- op(340, xfx, knows_that).
:- op(340,xf ,knows_what_hat_he_has_himself).
:- op(360,xfx,has).
:- op(380, fx,the).
:- op(380,xf ,hat).
X holds:- fact(X).
X holds:- fact(X if Y), Y holds.
X and_ Y holds:- X holds, Y holds.
fact(X):- ( the_problem_is_stated_as(Text) ;
inference_rules_are_stated_as(Text) ),
member(X, Text).
question(X):- it_is_deducible_that X holds, output(X).
the_problem_is_stated_as(
there_are_five_hats. three_of_them_are_white_two_are_black.
three_men_are_standing_one_behind_the_other_i.e. the second sees
the first. the third sees the second. the third sees the first.
each_has_one_hat_on_his_head. ie_the_statement. the third has
black hat and the second has black hat and the first has black
hat is_false.
the_third_said_that_he_does_not_know_what_hat _he_has_on_his_head.
then_the_second_said_the_same. it_means_that. the third
knows_what_hat_he_has_himself is_false. and_similarly. the second
knows_what_hat_he_has_himself is_false.
the_question_is_what_hat _the_first_man_has).
inference_rules_are_stated_as(
it_is_deducible_that A_man has white hat if Statement is_false
and_ Statement is_deducible_from A_man has black hat. similarly.
A_man has white hat is_deducible_from An_assumption if Statement
is_false and_Statement is_deducible_from A_man has black hat and
An_assumption.
A_man knows_what_hat_he_has_himself is_deducible_from An_assumption
if A_man can_verify An_assumption and_
A_man has
Certain hat is_deducible_from An_assumption.
Man1 can_verify Man2 has Some hat if Man1 sees Man2. A_man can_verify
Fact1 and Fact2 if A_man can_verify Fact1 and_ A_man
can_verify Fact.
Everything is_deducible_from An_assumption if An_assumption
is_false.
and_it_is_all_for_solving_the_problem).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment