W3C home > Mailing lists > Public > www-rdf-interest@w3.org > September 2003

mkr2cyc: #$ist #$defnIff ...

From: Richard H. McCullough <rhm@cdepot.net>
Date: Sat, 6 Sep 2003 14:23:35 -0700
Message-ID: <000e01c374bf$dcb1a0f0$bd7ba8c0@rhm8200>
To: "Guha, R. V." <guha@guha.com>, "Reed, Stephen L." <reed@cyc.com>, "McCool, Rob" <robm@stanford.edu>
Cc: "www-rdf-interest at W3C" <www-rdf-interest@w3.org>, "KR-language" <KR-language@YahooGroups.com>
I have added some more sophisticated features, including

    McCarthy context (#$ist)
    genus-differentia definitions (#$defnIff)
    identity (#$equals)
    causality (#$causedBy)

I haven't been able to test all the new features due to
lack of examples.  The one feature that I am most
concerned about is the default microtheory

    at view = mt;

I have guessed that it can be set using "WITH-MT", but
I haven't been able to find any documentation.  Can you 
tell me how OpenCyc does it?

Here is today's version of mkr2cyc.

# KEHOME/bin/mkr2cyc
# Sep/6/2003

#####exec 2>&1  # send errors to stdout

# translate MKR propositions to CycL expressions
# usage:
#	mkr2cyc
#	proposition
#	...
#	EOF
#
# proposition ::=
#   exit;
#   at view = mt;
#   do action od directobject with modifier from/to indirectobject done;
#   set variable op value;
#   subject predicate object mod1 mod2 mod3 mod4 mod5 mod6;
# predicate ::=
#   MKR verb
#   CycL predicate
#
# expression ::=
#   see below
#
# Notes:
# MKR commands for special CycL commands
#	do ke-create-now od "name" done;
#	do write-image to "world/name" done;
#	do generate-phrase from expression done;
# context for most questions and statements is
#	#$UniversalVocabularyMt
# MKR verb (is,has,do,rel,means,causes,...)
#	see below
# MKR characteristic (part,attribute,relation,action,interaction)
#	begins with letter
# MKR variable (attribute)
#	begins with letter
# MKR question variable
#	begins with "?"
#
# CycL predicate
#	begins with "#$"
# CycL constant
#	begins with "#$"
# CycL variable
#	begins with "?"

#echo "# mkr2cyc $@" >&2  # echo command line

if [ -n "$1" ]
then prompt=''		# mkr2cyc -q
else prompt='ke$ \c'	# mkr2cyc
fi

mt='#$UniversalVocabularyMt'  # default Microtheory

if [ -n "$prompt" ]
then echo -e "$prompt" >&2
fi
while read subject predicate object mod1 mod2 mod3 mod4 mod5 mod6; do
    	subject="${subject%;}"
    	case "$subject" in
    	\(*)	# ( CycL pass thru )
    		echo "$subject $predicate $object $mod1 $mod2 $mod3 $mod4 $mod5 $mod6";
    		continue;;
    	exit)	# exit;
    		echo "(exit)";
    		exit;;
    	at)	mt=${mod1%;};
    		if -n "$mod3"
    		then  # at view = mt { proposition } ;
    			proposition="${mod3%;}";
    			echo "( #$ist $mt $proposition )"
    		else  # at view = mt ;
    			echo "( WITH-MT $mt )"
    		fi;
    		continue;;
    	do|hdo|vdo)
    		# do action od direct with modifier from/to indirect done;
    		# do ke-create-now od "name" done;
    		# do write-image to "world/name" done;
    		# do generate-phrase from expression done;
    		verb="$subject";
    		subject="cyc";
    		action="${predicate%;}";
    		direct="${mod1%;}";
    		modifier="${mod3%;}";
    		fromto="${mod4%;}";
    		indirect="${mod5%;}";
    		echo "( $action $direct $modifier $indirect )";
    		continue;;
    	set|unset|vset)
    		# set variable op value;
    		verb="$subject";
    		subject="cyc";
    		variable="${predicate%;}";
    		op="${object%;}";
    		value="${mod1%;}";
    		echo "( $verb $variable $op $value )";
    		continue;;

    	*)	# subject predicate object;
    		predicate="${predicate%;}";
    		object="${object%;}";
    		value="${mod2%;}";;
    	esac

    	case "$subject" in
    	\?)	# MKR variable
    		subject="$object";
    		predicate="$(mkr_inverse $predicate)";
    		object="?";;
    	\?*) ;;	# CycL variable
    	esac

    	#####case "$object" in
    	#####\?)  object="";;	# MKR variable
    	#####\?*) ;;		# CycL variable
    	#####esac

    	#####echo "# INFO: mkr2cyc: ( $predicate $subject $object )" >&2
    	case "$predicate" in
    	##### hierarchy verbs #####
    	isa)
    		echo "$subject iss $object" | mkr2cyc -q;
    		echo "$subject isu $object" | mkr2cyc -q;;
    		#echo "(genls $subject $object )";
    		#echo "(isa   $subject $object )";;
    	iss)	echo "( genls $subject $object )";;
    	isu)	echo "( isa   $subject $object )";;
    	isc)
    		echo "$subject isg $object" | mkr2cyc -q;
    		echo "$subject isp $object" | mkr2cyc -q;;
    		#echo "( specs     $subject $object )";
    		#echo "( instances $subject $object )";;
    	isg)	echo "( specs     $subject $object )";;
    	isp)	echo "( instances $subject $object )";;

    	isa\*)	
    		echo "$subject iss* $object" | mkr2cyc -q;
    		echo "$subject isu* $object" | mkr2cyc -q;;
    		#echo "( all-genls $subject $object )";
    		#echo "( all-isa   $subject $object )";;
    	iss\*)	echo "( all-genls $subject $object )";;
    	isu\*)	echo "( all-isa   $subject $object )";;
    	isc\*)
    		echo "$subject isg* $object" | mkr2cyc -q;
    		echo "$subject isp* $object" | mkr2cyc -q;;
    		#echo "( all-specs     $subject $object )";
    		#echo "( all-instances $subject $object )";;
    	isg\*)	echo "( all-specs     $subject $object )";;
    	isp\*)	echo "( all-instances $subject $object )";;

    	##### other MKR verbs #####
    	haspart)echo "( physicalParts $subject $object $value )";;
    	isapart)echo "( physicalParts $object $subject )";;
    	ismem)	echo "( groupMembers  $object $subject )";;
    	isall)	echo "( groupMembers  $subject $object )";;
    	isalt)	echo "( groupMembers  $object $subject )";;
    	isany)	echo "( groupMembers  $subject $object )";;

    	is)	if [ -n "$mod1" ]  # "with"
    		then  # subject is genus with differentia ;
    			genus="$object";
    			differentia="${mod2%;}";
    			echo "( #$defnIff $subject (#$and";
    			echo "  ( #$genls $subject $object }";
    			echo "  ( $differentia )))"
    		else  # subject is object;
    			case "$object" in
    			\?) echo "( DEFINING-DEFNS '( $subject $mt ) )";;
    			*)  echo "( equals  $subject $object )";;
    			esac;
    		fi;;
    	has)	case "$object" in
    		\?) echo "( ALL-TERM-ASSERTIONS '( $subject T ))";;
    		*)  echo "( $object $subject $value )";;
    		esac;;
    	do)	echo "( $object $subject $value )";;
    	rel)	echo "( $object $subject $value )";;
    	isin)	echo "( $object $subject $value )";;

    	means)	 echo "( signifies $subject $object )";;
    	isref)	 echo "( signifies $object  $subject )";;
    	causes)	 echo "( causedBy  $object  $subject )";;
    	causedBy)echo "( causedBy  $subject $object )";;

    	##### other predicates #####
    	*)
    	    case "$object" in
    	    \?*) echo "(CYC-QUERY  '($predicate $subject $object) $mt)";;
    	    *)	 echo "(CYC-ASSERT '($predicate $subject $object) $mt)";;
    	    esac;;
    	esac

    	if [ -n "$prompt" ]
    	then echo -e "$prompt" >&2
    	fi
done



Dick McCullough
knowledge := man do identify od existent done;
knowledge haspart proposition list;
Received on Saturday, 6 September 2003 17:43:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:52:02 GMT