% parent(Parent, Son) relation parent(mario, maurizio). parent(mario, carla). parent(maurizio, andrea). parent(maurizio, gianluca). parent(andrea, teresa). parent(andrea, davide). parent(dina, nicoletta). parent(roberto, nicoletta). parent(nicoletta, teresa). parent(nicoletta, davide). parent(dina, cristina). % useful for widow dead( mario ). dead( maurizio ). dead( carla ). dead( dina ). dead( roberto ). married( anna, mario ). married( nicoletta, andrea ). married( dina, roberto). % should we add divorced? % gender(Person, Gender) relation gender(mario, m). gender(anna, f). gender(maurizio, m). gender(marlene, f). gender(carla, f). gender(gianluca, m). gender(andrea, m). gender(elena, f). gender(sabina, f). gender(roberto, m). gender(dina, f). gender(davide, m). gender(nicoletta, f). gender(teresa, f). gender(cristina, f). % who are the known ancestors of teresa? % QUESTION: is a parent an ancestor? (obviously yes, level 0) ancestor( Kid, Ancestor ) :- % a Kid has an Ancestor parent(Ancestor, Kid). % if this is her parent ancestor( Kid, Ancestor ) :- % or parent( P, Kid ), % if she has a parent ancestor( P, Ancestor). % that has some ancestor sibling( Kid1, Kid2 ) :- % two kids are siblings parent(P, Kid1), % if they have parent(P, Kid2), % a common parent Kid1 @< Kid2. % and they are different kids (ordered) uncle( Aunt, Kid ) :- % a Kid has an Aunt/Uncle parent( P, Kid ), % if she has a parent sibling( P, Aunt ). % who has a brother % QUESTION: how do we define a grandparent? or a great-grandparent or a great-great-grandparent? grandparent(Kid, Grandpa) :- parent(Dad_or_mam, Kid), parent(Grandpa, Dad_or_mam). great_grandparent(Kid, Grandpa) :- parent(Dad_or_mam, Kid), grandparent(Grandpa, Dad_or_mam). great_great_grandparent(Kid, Grandpa) :- parent(Dad_or_mam, Kid), great_grandparent(Grandpa, Dad_or_mam). % QUESTION: What if we want to find the *name* of the human relation? % IDEA: move the name of the relation inside the arguments, make it declarative, make it DATA! % Let start with parents and sons relative(parent, Kid, Dad_or_mum) :- parent(Dad_or_mum, Kid). relative(son, Dad_or_mum, Kid) :- parent(Dad_or_mum, Kid), gender(Kid, m). relative(daughter, Dad_or_mum, Kid) :- parent(Dad_or_mum, Kid), gender(Kid, f). % then rewrite all grandparents relative(grandparent, Kid, Grandpa) :- relative(parent,Kid, Dad_or_mum), relative(parent,Dad_or_mum, Grandpa). relative(great_grandparent, Kid, Grandpa) :- relative(parent, Kid, Dad_or_mum), relative(grandparent, Dad_or_mum, Grandpa). relative(great_great_grandparent, Kid, Grandpa) :- relative(parent, Kid,Dad_or_mam), relative(great_grandparent, Dad_or_mam, Grandpa). % BUT: what about other relations? % a mum is a female parent relative(mum, Kid, Mum) :- relative(parent, Kid, Mum), gender(Mum, f). % a dad is a male parent relative(dad, Kid, Dad) :- relative(parent, Kid, Dad), gender(Dad, m). % a sibling has same parent and it's not me relative(sibling, Kid, Sibling) :- relative(parent, Kid, Dad_or_mum), relative(parent, Sibling, Dad_or_mum), Kid \= Sibling. % a sister is a female sibling relative(sister, Kid, Sister) :- relative(sibling, Kid, Sister), gender(Sister, f). % a brother is a male sibling relative(brother, Kid, Brother) :- relative(sibling, Kid, Brother), gender(Brother, m). % an aunt is the sister of a parent relative(aunt, Kid, Aunt ) :- relative(parent, Kid, Dad_or_mum), relative(sister, Dad_or_mum, Aunt). % an uncle is the brother of a parent relative(uncle, Kid, Uncle) :- relative(parent, Kid, Dad_or_mum), relative(brother, Dad_or_mum, Uncle). % nephiew of an aunt/uncle relative(nephiew, Uncle, Kid) :- relative(uncle, Kid, Uncle). relative(nephiew, Aunt, Kid) :- relative(aunt, Kid, Aunt). % but there exists also grandparents' nephiews relative(nephiew, Grandparent, Kid) :- relative(grandparent, Kid, Grandparent). % % TASK: % define other known relations (e.g. widow/widower, girlfriend/boyfriend, granddad/grandmum) % (and add the necessary relevant information, e.g. marriages/divorces, live/dead, ...) relative( widower_of, Wife, Husband ) :- married( Wife, Husband ), dead( Husband ). relative( widow_of, Husband, Wife ) :- married( Wife, Husband ), dead( Wife ). % % TASK: % find a culture (e.g. matrilinear) with different family relations and represent them % % TASK: % find all inheriting people of a given person % (consider also live/dead persons) % % TASK: % compute what are the heirloom quotas depending on the relations and % number of people alive % % TASK: % compute how inheritance changes in different cultures % % TASK: % add a culture where "gender at birth" (sex) and "chosen gender" (gender) are represented separately % so that it's possible to describe same-sex relations % % TASK: % examine other social issues wrt the family structure and cultures % - responsibility w.r.t. sons or ancestors or widows % - .... %