User Tools

Site Tools


public:t-622-arti-11-1:lab_6_materials

Lab 6: PowerLoom

In this lab we will work with First Order Logic and PowerLoom, a knowledge representation system. You will have to go through the following steps and create some logical statements representing Family Relations.

PowerLoom

  • The main webpage of PowerLoom;
  • You can download here the stable version;
  • PowerLoom documentation in PDF or HTML version.
  • Some helpful commands:
    (all-facts-of X) ;; prints out all known facts about X
    (help assert)    ;; prints out help text about “assert”
    (demo)           ;; leads you through various PowerLoom demonstrations

Doing Knowledge Representation and Reasoning with PowerLoom

  1. Basic Commands:
    Create a new, empty, module to work in and specify representation language syntax:
    (defmodule "PL-USER/FAMILY")
    (in-module "FAMILY")
    (reset-features)
    (in-dialect KIF)

    Save your module to disk (show up in your powerloom folder or the “kbs” subfolder), and loading it back later:

    (save-module "FAMILY" "FAMILY.PLM")
    
    (load "FAMILY.PLM")
    (in-module "FAMILY")  ;; If not already in this module
  2. Defining a basic type/class predicate (a unary relation) called a “concept”:
    (defconcept Person(?p))          ;; Defining a Person
    (defconcept Male (?p Person))    ;; A Male is a Person
    (defconcept Female (?p Person))  ;; A Female is a Person
  3. Basic TELLing and ASKing:
    (assert (Male John))
    (assert (Female Mary))
    
    (ask (Male John))
    (ask (Female Mary))
  4. Adding First Order Logic (FOL) axioms:
    Being a Male implies you are a person:
    (assert (forall (?x) (=> (Male ?x) (Person ?x))))

    Do the same for Females.

  5. Asking for possible substitutions:
    Returns one possible substitutions for ?p if it exists:
    (retrieve (Person ?p))

    Returns all possible substitutions for ?p:

    (retrieve all (Person ?p))
  6. The Open-World semantics:
    The following should be unknown since it wouldn't conflict with the KB
    (ask (Male Mary))

    If we add this assertion, being a male implies you are not a female:

    (assert (forall (?p) (<=> (Male ?p) (not (Female ?p)))))

    Create the same assertion for Females.

  7. Defining a regular relation predicate:
    The following creates a new Predicate called BrotherOf:
    (defrelation BrotherOf ((?p1 Male) (?p2 Person)))
    (assert (BrotherOf John Mary))
    (assert (Person Olaf))
    (assert (BrotherOf Olaf Mary))
    
    (retrieve all (BrotherOf ?x Mary))    ;; Retrieve all Brothers of Mary

    Create a new predicate called ParentOf.

  8. Defining a regular function and using it:
    If a (binary) relation always maps its first argument to exactly one value (i.e., if it it “single-valued”) we can specify it as a function instead of a relation.
    (deffunction GetFather ((?p1 Person)) :-> (?p2 Male))   ;; The second value (after the symbol ":->") is the output variable of the function

    We can refer to a function in a sentence in this way:

    (assert (= (GetFather Mary) Zod))

    A new axiom that uses a function and equivalence

    (assert (<=> (= (GetFather ?c) ?f) (and (Male ?f) (ParentOf ?f ?c))))

    Ask the following:

    • Is Zod Male?
    • Is Zod Mary's parent?
  9. Defining more family Relations:
    Now you are on your own…add more family relations like:
    • SisterOf;
    • AreSiblings;
    • SonOf, DaughterOf, ChildOf;
    • GrandmotherOf and GrandfatherOf;
    • UncleOf, AuntOf;

    • and try answering questions like:
    • Is X a sibling of Y?
    • Who are X's grandmothers?
    • Who are X's uncles?
    • Does X's mother's mother have a male child?
/var/www/cadia.ru.is/wiki/data/pages/public/t-622-arti-11-1/lab_6_materials.txt · Last modified: 2024/04/29 13:33 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki