:- module(MappingClient). { The following import declarations give access to predicates needed for the * IPC connection, as well as access to the main predicate in apply.pro } :- import IpcChannel_call/3 from IpcChannelAccess. :- import connectCBserver/2 from IpcChannelAccess. :- import disconnectCBserver/0 from IpcChannelAccess. :- import thisToolClass/1 from IpcParameters. :- import thisToolId/1 from IpcParameters. :- import whatCBserverId/1 from IpcParameters. :- import server_id/1 from IpcParameters. :- import whatIpcServer/2 from IpcParameters. :- import init_timeout/1 from IpcParameters. :- import service_timeout/1 from IpcParameters. :- import service_retry/1 from IpcParameters. :- import user_name/1 from IpcParameters. :- import client_report/1 from IpcParameters. :- import genMethodInstanceNodeAttributeQuery/3 from apply. :- import genOffspringNodeType/3 from apply. :- import genNodeCategoryList/2 from apply. :- import genMainDefs/8 from apply. :- import appendToFile/1 from apply. { *************************************** } { Routine to Run Test data} {to invoke Prolog:} {../goBIM MappingClient} {module(MappingClient).} { Start with application APPLICATION (ApplNow); delete newnodes.* before invoking } {Execute the following. Result in newnodes.sml should be equivalent to runTestNewNodes.sml } {Note that the node numbers (**) may vary depending on the initial KB contents, and the order of applying methods. Nodes without (**) are already in the application (FR.sml). } { There may still be a problem with extra nodes being generated in the DerivedInfo methods (Problem when called from Prolog; no problem when called from Graphical interface.)} { *************************************** } { runRDS :- write('other proposition: '),readln(_pTemp), atomtolist(_pTemp,_l), atomconcat(_l,_p), reselect(_p,_r), write('reselected='),display(_r),nl, deselect(_r, _d, _a), write('deselected='),display(_d). } { runGAV :- getAttributeValues(ACCURACYReports1,label,_l), write('label = '),display(_l). runGAVN :- askAny(ACCURACYReports1,label,_l), write('label = '),display(_l). } { runTest :- { Preliminary --- For Cost --- to get to a potential conflict } call_refine(m,SubsortGDM, COSTSystem), call_refine(m,ComponentGDM, EquipCOSTSystem), { For now SubclassGDM } { For Security } call_refine(m,Subsort3SecGDM, SECAccount), call_refine(m,SubsortGDM, INTAccount), { For Accuracy } call_refine(m,ExhaustiveSubclassGDM, ACCAccount), call_refine(m,IndividualAttributeGDM, ACCCardholderAccount), call_refine(m,AttributeClassSupersetGDM, ACCtransaction), call_refine(m,SubsortGDM, ACCTransaction), call_refine(m,CriticalityGDM, TimeACCTransaction), call_refine(m,VitalFewGAM, select(TimeACCTransaction,!, offspring1)), {argument: MarketSurvey_strategic_importance} call_refine(m,RapidPostingGSM, CritTimeACCTransaction), call_refine(m,ReduceTransmissionTimeGSM, RapidPostingTransaction), call_refine(m, InstallInputDeviceGSM, RedTransTimeTransaction), { At this point, upward detection of a potential inter-conflict with EquipCOST --- The reason is more or less obvious } {call_refine(m,ResourceAssignmentGSM, INSTALLINPUTDEVICETransaction), {do this at the end,if needed}} { For confidentiality, use below } call_refine(m,SystemBoundaryGDM, CONFAccount), call_refine(m,ExhaustiveSubclassGDM, ExCONFAccount), call_refine(m,IndividualAttributeGDM, ExCONFCardholderAccount), call_refine(m,AttributeClassSupersetGDM, ExCONFtransaction), { At this point, downward-detection of a potential intra-harmony is detected, as might have been expected, with a CONDITION attached to the link between ExCONFTransaction and REDUCETRANSMISSIONTIMETransaction --- to help the designer understand the reason, which may not be obvious} { TODO: refine question --- re what goal, what route} { goal labelling vs. link labelling } { open-endedness --> interaction } } cTapply(ConfirmationAccGSM) :- nl, write(' proposition to refine: '),readln(_parentSelected), nl, write(' Confirmation application to '), write(_parentSelected),nl, call_refine(m,ConfirmationAccGSM,_parentSelected). cTapply(CasualModificationUserFriendlinessGSM) :- nl, write(' proposition to refine: '),readln(_parentSelected), nl, write(' CasualModification application to '), write(_parentSelected),nl, call_refine(m,CasualModificationUserFriendlinessGSM,_parentSelected). cTapply(RapidPostingGSM) :- nl, write(' proposition to refine: '),readln(_parentSelected), nl, write(' RapidPostingGSM application to '), write(_parentSelected),nl, call_refine(m,RapidPostingGSM,_parentSelected). cTapply(ReduceTransmissionTimeGSM) :- nl, write(' proposition to refine: '),readln(_parentSelected), nl, write(' ReduceTransmissionTimeGSM application to '), write(_parentSelected),nl, call_refine(m,ReduceTransmissionTimeGSM,_parentSelected). cTapply(InstallInputDeviceGSM) :- nl, write(' proposition to refine: '),readln(_parentSelected), nl, write(' InstallInputDeviceGSM application to '), write(_parentSelected),nl, call_refine(m,InstallInputDeviceGSM,_parentSelected). cTapply(ResourceAssignmentGSM) :- nl, write(' proposition to refine: '),readln(_parentSelected), nl, write(' ResourceAssignmentGSM application to '), write(_parentSelected),nl, call_refine(m,ResourceAssignmentGSM,_parentSelected). {**************************************************} {* apply_method called by MappingAssistant *} {**************************************************} {* methodSlected could be label or link type, depending on the context *} apply_method(_methodSelected,_parentSelected) :- {write(' method/label/link type Selected='),display(_methodSelected),} {write(' parentSelected='),display(_parentSelected),} getRefineType(_refineType), reselect(_parentSelected, _parentNodeOrLink), write(' parentSelected after reselect='),display(_parentNodeOrLink), call_refine(_refineType,_methodSelected,_parentNodeOrLink). getRefineType(_refineType) :- nl,nl,write(' type of design action (m for method application, '),nl, write(' l for label modification, '),nl, write(' t for link type modification,'),nl, write(' ll for link label modification): '), readln(_refineType1), ((member(_refineType1,[m,l,t,ll]) -> _refineType = _refineType1); (write(' >>>>>typo error<<<<<'),nl, getRefineType(_refineType))). call_refine(m, DerivedInfoAccGDM, _parentSelected) :- applyDerivedInfoOrMethod(_parentSelected, _methodInstanceCreated,_offspringListCreated), integrate(m, _parentSelected, _methodInstanceCreated, _DerivedInfoOrAccGDM, _offspringListCreated), nl,write(' Should the offspring be further decomposed (y/n)? '), {readln(_ans),} _ans = y, ((_ans == n -> true); recursiveDerivedInfoAndApply(_offspringListCreated)). recursiveDerivedInfoAndApply([]). recursiveDerivedInfoAndApply([_H | _offspringListCreatedT]) :- applyDerivedInfoAndMethod(_H, _methodInstanceCreated,_offspringListCreated), integrate(m, _parentSelected, _methodInstanceCreated, DerivedInfoAndAccGDM, _offspringListCreated), recursiveDerivedInfoAndApply(_offspringListCreatedT). call_refine(m,MultiplyApplicablePMCGAM, _parentSelected) :- nl,nl,write(' Other proposition: '), readln(_otherParent), reselect(_otherParent,_otherParentSelected), applyPolicyManualConsultationGAM (_parentSelected, _methodInstanceCreated,_offspringListCreated), _methodSelected = PolicyManualConsultationGAM, integrate(m, _parentSelected, _methodInstanceCreated, _methodSelected, _offspringListCreated), _offspringListCreated = [_leaf | _tail], correlateAndLabel (_leaf, _methodSelected,_parentSelected), integrate(m, _otherParentSelected, _methodInstanceCreated, _methodSelected, _offspringListCreated), correlateAndLabel (_leaf, _methodSelected,_otherParentSelected) . call_refine(m,VitalFewTrivialManyGAM,_parentSelected) :- {nl,write(' call_refine for method application:'),} apply1_method(VitalFewTrivialManyGAM, _parentSelected,_methodInstanceCreated,_offspringListCreated), _offspringListCreated = [_leaf | _tail], correlateAndLabel (_leaf, VitalFewTrivialManyGAM,_parentSelected). call_refine(m,RelativePriorityAssignmentGAM,_parentSelected) :- {nl,write(' call_refine for method application:'),} apply1_method(RelativePriorityAssignmentGAM, _parentSelected,_methodInstanceCreated,_offspringListCreated), _offspringListCreated = [_leaf | _tail], correlateAndLabel (_leaf, RelativePriorityAssignmentGAM, _parentSelected). call_refine(m,_methodSelected,_parentSelected) :- {nl,write(' call_refine for method application:'),} apply1_method(_methodSelected, _parentSelected,_methodInstanceCreated,_offspringListCreated), integrate(m, _parentSelected, _methodInstanceCreated, _methodSelected, _offspringListCreated), write('offspringListCreated = '),display(_offspringListCreated), write(' call_refine --- integrate done. '), {readln(_dummy),} _offspringListCreated = [_leaf | _tail], write('leaf='),display(_leaf),write(' tail='),display(_tail), correlateAndLabel (_leaf, _methodSelected,_parentSelected), write(' correlateAndLabel done from call_refine....'),nl,true,!. call_refine(m,_methodSelected,_parentSelected) :- {nl,write(' call_refine for method application:'),} apply2_method(_methodSelected, _parentSelected,_methodInstanceCreated,_offspringListCreated, _intentional), ((_intentional == no -> true); (integrate(m, _parentSelected, _methodInstanceCreated, _methodSelected, _offspringListCreated), _offspringListCreated = [_leaf | _tail], correlateAndLabel (_leaf, _methodSelected,_parentSelected))). call_refine(_refineType,_labelOrLinkType,_parentSelected) :- integrate(_refineType, _parentSelected, _labelOrLinkType). apply1_method(SubclassGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- {nl,write('calling applySubClassGDM: parent='), display(_parentSelected),nl,} applySubclassGDM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(IndividualAttributeGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyIndividualAttributeMethod(_parentSelected, _methodInstanceCreated,_offspringListCreated). {********** NEW *******************} apply1_method(Subsort3SecGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applySubsort3SecGDM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(SubsortGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applySubsortGDM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(AttributeClassSupersetGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyAttributeClassSupersetGDM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(CriticalityGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyCriticalityGDM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(SystemBoundaryGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applySystemBoundaryGDM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(ComponentGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyComponentMethod(_parentSelected, _methodInstanceCreated,_offspringListCreated). {******** END NEW *************} apply1_method(IndividualAttributeGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyIndividualAttributeMethod(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(DerivedInfoOrAccGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyDerivedInfoOrMethod(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(DerivedInfoAndAccGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyDerivedInfoAndMethod(_parentSelected, _methodInstanceCreated,_offspringListCreated). { Intermediary } { P H A S E - II: } { S E C U R I T Y M E T H O D S } { G D M } apply1_method(SubclassSecGDM,_parentSelected, _methodInstanceCreated,_offspringListCreated) :- _sort = Security, askAny(_parentSelected, infoItemParam, _infoItemParamSet), _infoItemParamSet = [_infoItemParam], findSpecialisations(_infoItemParam,_isAlist), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, SubclassSecGDM, _sort, _infoItemParam,_isAlist), ((atomic(_offspringListCreated) -> _offspringCreated = _offspringListCreated); _offspringListCreated = [_offspringCreated]), copyAllDown(_parentSelected, _offspringCreated). copyAllDown(_parentSelected, _offspringCreated) :- copy1Down(_parentSelected, _offspringCreated, authorizer), copy1Down(_parentSelected, _offspringCreated, permittedAgent), copy1Down(_parentSelected, _offspringCreated, condition) . copy1Down(_parent,_offspring, _attrName) :- askAny(_parent,_attrName,_attrValList), tellAny(_offspring, _attrName,_attrValList). apply1_method(SuperclassSecGDM,_parentSelected, _methodInstanceCreated,_offspringListCreated) :- _sort = Security, askAny(_parentSelected, infoItemParam, _infoItemParamSet), _infoItemParamSet = [_infoItemParam], askSuperclassList(_infoItemParam,_superclasses), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, SuperclassSecGDM, _sort, _infoItemParam,_superclasses). apply1_method(IndividualAttributeSecGDM,_parentSelected, _methodInstanceCreated,_offspringListCreated) :- _sort = Security, askAny(_parentSelected, infoItemParam, _infoItemParamSet), _infoItemParamSet = [_infoItemParam], findAllAttributes(_infoItemParam,_attributeList), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, IndividualAttributeSecGDM, _sort, _infoItemParam,_attributeList). { G S M } apply1_method(DisguiseSecGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- askAny(_parentSelected, infoItemParam, _infoSet), _infoSet = [_infoItemParam], applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, DisguiseSecGSM, DisguiseSec, _infoItemParam, [_infoItemParam]). apply1_method(MutualIdentificationSecGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- askAny(_parentSelected, infoItemParam, _infoSet), _infoSet = [_infoItemParam], applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, MutualIdentificationSecGSM, MutualIdentificationSec, _infoItemParam, [_infoItemParam]). apply1_method(CasualModificationUserFriendlinessGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- askAny(_parentSelected, infoItemParam, _infoSet), _infoSet = [_infoItemParam], applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, CasualModificationUserFriendlinessGSM, CasualModificationUF, _infoItemParam, [_infoItemParam]). { A C C U R A C Y ----> } {*********** NEW ***********} apply1_method(RapidPostingGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyRapidPostingGSM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(ReduceTransmissionTimeGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyReduceTransmissionTimeGSM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(InstallInputDeviceGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyInstallInputDeviceGSM(_parentSelected, _methodInstanceCreated,_offspringListCreated). {************ END NEW ***********} apply1_method(ResourceAssignmentGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyResourceAssignmentGSM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(SuperclassGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- {nl,write('calling applySuperclassGDM: parent='), display(_parentSelected),nl,} applySuperclassGDM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(ExhaustiveSubclassGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- {nl,write('calling applySubClassGDM: parent='), display(_parentSelected),nl,} applyExhaustiveSubclassGDM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(InexhaustiveSubclassGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- {nl,write('calling applySubClassGDM: parent='), display(_parentSelected),nl,} applyInexhaustiveSubclassGDM( _parentSelected,_methodInstanceCreated,_offspringListCreated), integrate(m, _parentSelected, _methodInstanceCreated, InexhaustiveSubclassGDM, _offspringListCreated), {nl,write('LABELLING ALL DONE'),} ((atomic(_offspringListCreated) -> true); (length(_offspringListCreated, _L),{write('length='),display(_L),} ((_L == 1 -> true); (_offspringListCreated = [_newParent], {nl,write('refine again, proceed?'),readln(_),} call_refine(m,SubClassAccGDM, _newParent))))). apply1_method(RelativePriorityAssignmentGAM, _parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyRelativePriorityAssignmentGAM (_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(HigherPriorityAssignmentGAM, _parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyHigherPriorityAssignmentGAM (_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(LowerPriorityAssignmentGAM, _parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyLowerPriorityAssignmentGAM (_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(PolicyManualConsultationGAM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyPolicyManualConsultationGAM (_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(PolicyManualConsultationDecompositionGAM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyPolicyManualConsultationDecompositionGAM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(StepwiseSpecializationGRM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyStepwiseSpecializationGRM (_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(IndependentSubclassGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyIndependentSubclassGDM(_parentSelected, _methodInstanceCreated, _offspringListCreated). apply1_method(MigratorySubclassGDM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyMigratorySubclassGDM(_parentSelected, _methodInstanceCreated, _offspringListCreated). apply1_method(VerificationGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyVerificationGSM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(VerificationViaDistinctChannelAccGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyVerificationViaDistinctChannelAccGSM(_parentSelected, _methodInstanceCreated, _offspringListCreated). apply1_method(VerificationViaIdenticalChannelAccGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyVerificationViaIdenticalChannelAccGSM(_parentSelected, _methodInstanceCreated, _offspringListCreated). apply1_method(ExternalReferencePMCGAM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyExternalReferencePMCGAM (_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(DesignGuidelinePMCGAM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyDesignGuidelinePMCGAM (_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(RelationshipBasedPolicyManualConsultationGAM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyRelationshipBasedPolicyManualConsultationGAM (_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(AuthorityConsultationGAM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyAuthorityConsultationGAM (_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(VitalFewTrivialManyGAM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyVitalFewTrivialManyGAM (_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(VitalFewGAM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyVitalFewGAM (_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(TrivialManyGAM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyTrivialManyGAM (_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(ConfirmationAccGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyConfirmationAccGSM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(CertificationAccGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyCertificationAccGSM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(ValidationAccGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyValidationAccGSM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply1_method(CheckSumConsistencyCheckingAccGSM,_parentSelected,_methodInstanceCreated,_offspringListCreated) :- applyCheckSumConsistencyCheckingAccGSM(_parentSelected, _methodInstanceCreated,_offspringListCreated). apply2_method(_methodSelected,_parentSelected,_methodInstanceCreated,_offspringListCreated,_intentional) :- applyDesignerDefinedGRM(_parentSelected, _methodSelected, _methodInstanceCreated,_offspringListCreated, _intentional). {**************************************************************************} {* G E N E R A L M E T H O D S (phase I) *} {**************************************************************************} { applySubclassGDM is a main predicate. It does the following: * 1) get the sort and parameters of the node selected, * 2) find the specialisations of the parameters class * 3) get the current value of the node counter and compute the new value * based on how many specialisations there are * 4) call genMainDefs to generate the new Telos definitions required to apply * the method * 5) load the new definitions into the KB * 6) update the node counter * 7) remove the temporary files generated by genMainDefs } { NOTE: In applySubclassGDM, the predicate genMainDefs is a external reference to the file apply.pro } applySubclassGDM(_parentSelected, _methodInstanceCreated, _offspringListCreated) :- findSortAndParameterAttributes(SubclassGDM,_parentSelected, _sort,_parameterStructure), paramGetSingleAttributeValueForGivenCategory(_parameterStructure, infoItemParam,_infoItemParam), findSpecialisations(_infoItemParam,_isAlist), {query KB for specialisations} getNode(_currentNodeNum), {get current value of node counter} length(_isAlist,_L), _newNodeNum is _L + _currentNodeNum, {compute new value of node counter} genMainDefs(SubclassGDM,_sort,_parameterStructure {_infoItemParam} , _parentSelected,_isAlist,_currentNodeNum, _methodInstanceCreated, _offspringListCreated), retellAny(NodeCount, counter,_newNodeNum) {write('applySubclassGDM... proceed?'),readln(_)}. {***********************} { applyIndividualAttributeMethod is a main predicate. It does the following: * 1) get the sort and parameters of the node selected, * 2) find the attributes of the parameter's class * 3) get the current value of the node counter and compute the new value * based on how many attributes there are * 4) call genMainDefs to generate the new Telos definitions required to apply * the method * 5) load the new definitions into the KB * 6) update the node counter * 7) remove the temporary files generated by genMainDefs } { NOTE: In applyIndividualAttributeMethod, the predicate genMainDefs is a external reference to the file apply.pro } applyIndividualAttributeMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated) :- askAny(_parentSelected, sort, _sortList), _sortList = [_sort], askAny(_parentSelected, infoItemParam, _infoItemParamList), _infoItemParamList = [_infoItemParam], findAllAttributes(_infoItemParam,_attributeList), {applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, IndividualAttributeGDM, _sort, _infoItemParam,_attributeList).} getNode(_currentNodeNum), atomconcat([IndividualAttributeGDM, _currentNodeNum], _methodInstanceCreated), checkDef(_methodInstanceCreated, IndividualAttributeGDM), _newNodeNum is 1 + _currentNodeNum, retellAny(NodeCount,counter,_newNodeNum), {given sort, infoItemParam, and attributeList, create offspring and return offspringListCreated} shortSort(_sort,_shortSort), fromSortToNfr(_sort,_nfrType), createOffspring(_shortSort,_nfrType, _sort,_infoItemParam,_attributeList,_offspringListCreated). createOffspring(_shortSort,_nfrType,_sort,_infoItemParam,[],[]). createOffspring(_shortSort,_nfrType,_sort,_infoItemParam,[_attrListH|_T],_offspringListCreated) :- atomconcat([_shortSort,_attrListH],_offspring), checkDef(_offspring,_nfrType), tellAny(_offspring,sort,[_sort]), tellAny(_offspring,infoItemParam,[select(_infoItemParam,!,_attrListH)]), createOffspring(_shortSort,_nfrType, _sort,_infoItemParam,_T, _offspringListCreatedT), append([_offspring],_offspringListCreatedT, _offspringListCreated). {***********************} { applyDerivedInfoMethod is a main predicate. It first invokes the DerivedInfoOrMethod on the selected node, then, for each resulting sub-node, invokes the DerivedInfoAndMethod. Note that this is a 2-stage method. _methodInstanceCreated becomes the method instance of the DerivedInfoOrMethod. _offspringListCreated becomes the union of the offspring of each of the sub-nodes created by the applications of the DerivedInfoAndMethod. Memo: might change above return values. Note that the offspringListCreated are NOT immediate offspring of the methodInstanceCreated. Note: To do: Labelling should be invoked a total of 3 times. 1. for Or method 2. for offspring of Or method (= And methods) 3. for offspring of And method. } applyDerivedInfoMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated) :- applyDerivedInfoOrMethod(_parentSelected, _OrMethodInstanceCreated, _OrOffspringListCreated), {possibly to do: invoke labelling on _OrOffspringListCreated} applyDerivedInfoAndMethodToSet(_OrOffspringListCreated, _AndMethodInstanceListCreated, _UnionOfAndOffspringSetsCreated), {possibly to do: invoke labelling on each of the _UnionOfAndOffspringSetsCreated} _methodInstanceCreated = _OrMethodInstanceCreated, _offspringListCreated = _UnionOfAndOffspringSetsCreated. {***********************} {Given a parentListSelected, repeatedly invoked applyDerivedInfoAndMethod to each member of the set. _methodInstanceListCreated becomes the set of method instances created by the invocations. _offspringSetUnionCreated becomes the union of the offspring sets created by the invocations. } applyDerivedInfoAndMethodToSet([],[],[]). applyDerivedInfoAndMethodToSet ([_headParentSelected|_TailParentListSelected], _methodInstanceListCreated, _offspringListCreated) :- applyDerivedInfoAndMethod(_headParentSelected, _headMethodInstanceCreated, _headOffspringListCreated), applyDerivedInfoAndMethodToSet(_TailParentListSelected, _tailMethodInstanceListCreated, _tailOffspringListCreated), _methodInstanceListCreated = [_headMethodInstanceCreated| _tailMethodInstanceCreated], append(_headOffspringListCreated,_tailOffspringListCreated, _offspringListCreated). {***********************} { applyDerivedInfoOrMethod is a main predicate. It does the following: * 1) get the sort and parameters of the node selected, * 2) find the derivation functions (and their derivation components) * of the parameter's class * 3) get the current value of the node counter and compute the new value * based on how many derivation functions there are * 4) call genMainDefs to generate the new Telos definitions required * to apply the method * 5) load the new definitions into the KB * 6) update the node counter * 7) remove the temporary files generated by genMainDefs } { NOTE: In applyDerivedInfoOrMethod, the predicate genMainDefs is a external reference to the file apply.pro } applyDerivedInfoOrMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated) :- findSortAndParameterAttributes(DerivedInfoOrAccGDM,_parentSelected, _sort,_parameterStructure), {query KB for sort,parameters of _parentSelected} { write(' sort '),write(_sort),nl, } { write(' parameterStructure '),display(_parameterStructure),nl, } { Select the (single-valued) infoItemParam from the parameterStructure.} paramGetSingleAttributeValueForGivenCategory(_parameterStructure, infoItemParam,_infoItemParam), findDerivationFunctions(_infoItemParam,_derivationFunctionList), {query KB for derivation functions} write(' derivationFunctionList '),display(_derivationFunctionList),nl, getNode(_currentNodeNum), {get current value of node counter} length(_derivationFunctionList,_L), _newNodeNum is _L + _currentNodeNum, {compute new value of node counter} { write(' NEED TO RECORD derivation source as well as derivation functions '),nl, } genMainDefs(DerivedInfoOrAccGDM,_sort, _parameterStructure {_infoItemParam},_parentSelected, _derivationFunctionList,_currentNodeNum, _methodInstanceCreated, _offspringListCreated), retellAny(NodeCount,counter,_newNodeNum). {***********************} { applyDerivedInfoAndMethod is a main predicate. It does the following: * 1) get the sort and parameters of the node selected, * 2) find the derivation components of the parameter's class * 3) get the current value of the node counter and compute the new value * based on how many derivation components there are * 4) call genMainDefs to generate the new Telos definitions required to apply * the method * 5) load the new definitions into the KB * 6) update the node counter * 7) remove the temporary files generated by genMainDefs } { NOTE: In applyDerivedInfoAndMethod, the predicate genMainDefs is a external reference to the file apply.pro } { ******* In following, may have to generate CorrectDeriv, * and add one to list length. ********************** } applyDerivedInfoAndMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated) :- findSortAndParameterAttributes(DerivedInfoAndAccGDM, _parentSelected,_sort,_parameterStructure), {query KB for sort,parameters of _parentSelected} { Select the (single-valued) derivationFnParam from the parameterStructure.} paramGetSingleAttributeValueForGivenCategory(_parameterStructure, derivationFnParam,_derivationFnParam), { write(' derivationFnParam '),display(_derivationFnParam),nl, } findDerivationComponents(_derivationFnParam,_DerivationComponentsList), {query KB for DerivationComponents} write(' DerivationComponentsList '),display(_DerivationComponentsList),nl, getNode(_currentNodeNum), {get current value of node counter} length(_DerivationComponentsList,_L), _newNodeNum is _L + _currentNodeNum, {compute new value of node counter} { write(' Any more parameters to add? '),nl, } genMainDefs(DerivedInfoAndAccGDM,_sort, _parameterStructure {_infoItemParam} , _parentSelected, _DerivationComponentsList,_currentNodeNum, _methodInstanceCreated, _offspringListCreated), retellAny(NodeCount,counter,_newNodeNum). { ************************************************************************** } { ************************************************************************** } {****************************************************************} {* Miscellaneous: *} {****************************************************************} { remove_tempfiles and getstats are helping predicates. remove_tempfiles * creates two strings, namely "rm $MAP_HOME/newnodes.sml" and * "rm $MAP_HOME/newnodes.sfg" and uses the Prolog call to execute * these commands as calls to UNIX. * getstats gets the internal identifiers for the server and Prolog client, * as these values are needed to communicate with the ConceptBase server * through the IpcChannel_call predicate. } { remove_tempfiles :- _L = [rm,' ','$MAP_HOME/newnodes.sml'], atomconcat(_L,_W), _L1 = [rm,' ','$MAP_HOME/newnodes.sfg'], atomconcat(_L1,_W1), system(_W), system(_W1). } getstats(_sid,_tid,_CBsid) :- server_id(_sid), thisToolId(_tid), whatCBserverId(_CBsid). { ************************************************************************** } { Code re internal representation of links} { Sample calls and results. translateEntityToExplanationMarkFormIfNecessary('#5866.31',_A), translateEntityToExplanationMarkFormIfNecessary('#5857.64',_B), translateEntityToExplanationMarkFormIfNecessary('#5866.50',_C), translateSelectClauseToExplanationMarkForm(Goal,_D1), translateSelectClauseToExplanationMarkForm( select(Goal,!,offspring),_D2), translateSelectClauseToExplanationMarkForm( select(select(Goal,!,offspring),!,linkType),_D3), translateEntityToClassParameterIfNecessary('#5866.50',_E), translateEntityToClassParameterIfNecessary('#5857.64',_F), translateEntityToClassParameterIfNecessary('#5866.31',_G), translateEntityToSelectClause('#5866.31',_H), translateEntityToSelectClause('#5857.64',_J), translateEntityToSelectClause('#5866.50',_K). _A = g1!offspring1 _B = Goal!offspring!linkType _C = g1!offspring1!linkType1 _D1 = Goal _D2 = Goal!offspring _D3 = Goal!offspring!linkType _E = g1offspring1linkType1 _F = GoaloffspringlinkType _G = g1offspring1 _H = select(g1,!,offspring1) _J = select(select(Goal,!,offspring),!,linkType) _K = select(select(g1,!,offspring1),!,linkType1) } { quoteIfNecessary(_parameter,_possiblyQuotedParameter) Given parameter, if it starts with '#', possiblyQuotedParameter will be parameter with single quotes around entire parmeter. Otherwise, possiblyQuotedParameter will be the same as parameter. This should be used before a Concept-Base query is invoked to check if argument starts with '#' (e.g., a proposition of the form #1234.5678). If so, put single quotes around it, via quoteIfNecessary. Future: It may be possible to replace calls to quoteIfNecessary with translateEntityToSelectClause. However, this involves the overhead of extra calls to ConceptBase. } quoteIfNecessary(_parameter,_possiblyQuotedParameter):- atompart(_parameter,_firstCharacterOfParameter,1,1), {firstCharacterOfParameter is the first character of parameter} ( {If} (_firstCharacterOfParameter = '#') -> {Then} (atomconcat(['''',_parameter,''''],_possiblyQuotedParameter)) ; {Else} (_possiblyQuotedParameter = _parameter)). { translateNumberSignAndPeriodIfNecessary(_parameter,_possiblyTranslatedParameter) ** THIS WORKS, HOWEVER translateEntityToClassParameterIfNecessary MAY BE MORE SUITABLE ***** Given parameter, if it starts with '#' and has a period, possiblyTranslatedParameter will be parameter with '#' replaced by 'proposition', '.' replaced by 'point', and terminated by 'number'. Otherwise, possiblyTranslatedParameter will be the same as parameter. This should be used before an SML name is generated, to check if the name starts with '#' and has a period (e.g., a proposition of the form #1234.5678). If so, translated it, via translateNumberSignAndPeriodIfNecessary. Note: For now, we assume that the '#' will only occur in the first position, and if so, that there will be at most one period. firstNumber is the string in between the leading '#' and the '.'. secondNumber is the string following the '.'. } { FUTURE IMPROVEMENT: Check for quotes surrounding items of the form #1234.5678 } translateNumberSignAndPeriodIfNecessary(_parameter,_possiblyTranslatedParameter):- atomverify(_parameter,'#',_startPositionOfNumberSign), atomverify(_parameter,'.',_startPositionOfPeriod), {If character not found in parameter, _startPosition... will be 0} ( {If} ((_startPositionOfNumberSign = 1) , {And} (_startPositionOfPeriod > 1)) -> {Then} {There is an initial number sign, followed somewhere by a period} (atomlength(_parameter,_parameterLength), {Produce firstNumber:} _lengthOfFirstNumber is (_startPositionOfPeriod - 2), { write(' a '), } { write(_lengthOfFirstNumber), } atompart(_parameter,_firstNumber,2,_lengthOfFirstNumber), {Produce secondNumber:} _startPositionOfSecondNumber is (_startPositionOfPeriod + 1), _lengthOfSecondNumber is (_parameterLength - _startPositionOfPeriod), { write(' b '), } { write(_startPositionOfPeriod), } { write(_lengthOfSecondNumber), } atompart(_parameter,_secondNumber, _startPositionOfSecondNumber,_lengthOfSecondNumber), {Produce the translated parameter:} atomconcat([proposition,_firstNumber,point,_secondNumber,number], _possiblyTranslatedParameter)) ; {Else} (_possiblyTranslatedParameter = _parameter)). { translateEntityToClassParameterIfNecessary(_parameter,_possiblyTranslatedParameter) Given parameter, if it starts with '#' and has a period, or if it is of the form IsA2('#123.456',Person) possiblyTranslatedParameter will be translated to the form Person (if it is a named object), or Personname (if it is a link, e.g., Person!age) Personnamesource (if it is a nested link, e.g., Person!name!source) Otherwise, possiblyTranslatedParameter will be the same as parameter. This should be used before an SML name is generated, to check if the name starts with '#' and has a period (e.g., a proposition of the form #1234.5678); or if it is of the form IsA2('#123.456',Person). If so, translate it, via translateEntityToClassParameterIfNecessary. Note: For now, we assume that the '#' will only occur in the first position, and if so, that there will be at most one period. firstNumber is the string in between the leading '#' and the '.'. secondNumber is the string following the '.'. } { FUTURE IMPROVEMENT: Check for quotes surrounding items of the form #1234.5678 } translateEntityToClassParameterIfNecessary(_parameter,_possiblyTranslatedParameter):- ( {If} (atom(_parameter)) -> {Then} {parameter is an atom} ( atomverify(_parameter,'#',_startPositionOfNumberSign), atomverify(_parameter,'.',_startPositionOfPeriod), {If character not found in parameter, _startPosition... will be 0} ( {If} ((_startPositionOfNumberSign = 1) , {And} (_startPositionOfPeriod > 1)) -> {Then} {(a)There is an initial number sign, followed somewhere by a period} ( translateEntityToSelectClause(_parameter,_selectClause), write(' selectClause '),display(_selectClause),nl, ( translateSelectClauseToClassAttributeForm(_selectClause, _possiblyTranslatedParameter) ) ) ; {Else} {(c)} ( _possiblyTranslatedParameter = _parameter ) ) ) ; {Else} ( {If} (_parameter = IsA2(_theProposition,_superclass) ) -> {Then} {(b) } ( write(' IsA2 case theProposition '),display(_theProposition),nl, write(' superclass '),display(_superclass),nl, {If} (atom(_theProposition)) -> {Then} {theProposition is an atom} ( atomverify(_theProposition,'#',_startPositionOfNumberSignInProp), atomverify(_theProposition,'.',_startPositionOfPeriodInProp), { write(' startPositionOfNumberSignInProp'), } { display(_startPositionOfNumberSignInProp),nl, } { write(' startPositionOfPeriodInProp '), } { display(_startPositionOfPeriodInProp),nl, } {If character not found in theProposition, _startPosition... will be 0} ( {If} ((_startPositionOfNumberSignInProp = 1) , {And} (_startPositionOfPeriodInProp > 1)) -> {Then} { There is an initial number sign, followed somewhere by a period} ( write(' IsA2 case, calling translateEntityToSelectClause '),nl, translateEntityToSelectClause(_theProposition, _PropositionSelectClause), write(' PropositionSelectClause '),display(_PropositionSelectClause),nl, ( {If} (_PropositionSelectClause = select(_theClassOfProposition,!, _theAttributeOfProposition)) -> {Then} { Return Classparameter format } ( write(' Future: may want to handle nested case here '),nl, {See translateSelectClauseToClassAttributeForm} atomconcat([_superclass,_theAttributeOfProposition], _possiblyTranslatedParameter) ) ; {Else} ( _possiblyTranslatedParameter = _selectClause {For future, could sub-divide this case. E.g., is it an IsA clause? } ) ) ) ; {Else} ( write(' error or recursive case '), _possiblyTranslatedParameter = _parameter ) ) ) ; {Else} {(c)} ( _possiblyTranslatedParameter = _parameter ) ) ; { Else } {(c)} ( _possiblyTranslatedParameter = _parameter ) ) ). {translateEntityToExplanationMarkFormIfNecessary: (formerly translateLinksIfNecessary) (a) If _parameter is of the form '#1234.5678' then _possiblyTranslatedParameter is of the form C!p (b) If _parameter is of the form IsA2('#1234.5678',SuperclassName) then _possiblyTranslatedParameter is of the form C!p (c) Otherwise _possiblyTranslatedParameter is set to the same value as _parameter RATIONALE: When attribute link expressions of the form ClassName!attribute are stored in ConceptBase, they may be subsequently retrieved as propositions of the form '#1234.5678' or IsA2('#1234.5678',SuperclassName) (when ClassName!attribute and SuperclassName!attribute have the same value) When we retrieve such expressions, we wish to immediately translate (via the ConceptBase expression select(C,!,p)) to the C!p form. Note that this process is not guaranteed to be unique, as a link may have more than one name. But given our limited use of links, we hope they will be unique in practice. SAMPLE PROPOSITIONS: From section 2.3 of the ConceptBase manual, recall propositions are of the form: proposition(oid,x,l,y,t,tt) where: From(oid,x),Label(oid,l),To(oid,y), etc. (for efficiency, restrict oid/attributes in queries) (a) '#5782.7' where: proposition('#5782.7',Reports,name,String, Always,tt(millisecond(1992,2,18,17,0,17,0))) . _possiblyTranslatedParameter should be Reports!name, i.e., _x!_l where From(_oid,_x), Label(_oid,_l) (b) IsA2('#5782.9',MeetingReports) [= IsA2(_proposition,_superclass) ] where: proposition('#5782.9',Reports,amount,Integer,Always, tt(millisecond(1992,2,18,17,0,17,0))) . _possiblyTranslatedParameter should be MeetingReports!amount , i.e., _superclass!_lproposition where Label(_proposition,_lproposition) Note: For now, we assume that the '#' will only occur before the period, and that there will be at most one period. firstNumber is the string in between the leading '#' and the '.'. secondNumber is the string following the '.'. } { Quoting convention: '#5782.9' IsA2('#1234.5678',SuperclassName) } { Future improvement: As a double check, take the return value, possiblyTranslatedParameter, and try to get its value from the KB. The internal value retrieved should be the same as the input, parameter.} { Sample calls: translateEntityToExplanationMarkFormIfNecessary(Reports,_V), translateEntityToExplanationMarkFormIfNecessary('#5782.7',_W), translateEntityToExplanationMarkFormIfNecessary('#5782.9',_X), translateEntityToExplanationMarkFormIfNecessary('#5782.90',_Y), translateEntityToExplanationMarkFormIfNecessary(IsA2('#5782.9',MeetingReports),_Z). Sample results: _V = Reports _W = Reports!name _X = Reports!amount _Y = DerivedAttributeProjectReportscosth!component1 _Z = MeetingReports!amount Yes } translateEntityToExplanationMarkFormIfNecessary(_parameter,_possiblyTranslatedParameter) :- ( {If} (atom(_parameter)) -> {Then} {parameter is an atom} ( atomverify(_parameter,'#',_startPositionOfNumberSign), atomverify(_parameter,'.',_startPositionOfPeriod), {If character not found in parameter, _startPosition... will be 0} ( {If} ((_startPositionOfNumberSign = 1) , {And} (_startPositionOfPeriod > 1)) -> {Then} {(a)There is an initial number sign, followed somewhere by a period} ( translateEntityToSelectClause(_parameter,_selectClause), write(' selectClause '),display(_selectClause),nl, translateSelectClauseToExplanationMarkForm(_selectClause, _possiblyTranslatedParameter) ) ; {Else} {(c)} ( _possiblyTranslatedParameter = _parameter ) ) ) ; {Else} ( {If} (_parameter = IsA2(_theProposition,_superclass) ) -> {Then} {(b) } ( write(' IsA2 case theProposition '),display(_theProposition),nl, write(' superclass '),display(_superclass),nl, {If} (atom(_theProposition)) -> {Then} {theProposition is an atom} ( atomverify(_theProposition,'#',_startPositionOfNumberSignInProp), atomverify(_theProposition,'.',_startPositionOfPeriodInProp), { write(' startPositionOfNumberSignInProp'), } { display(_startPositionOfNumberSignInProp),nl, } { write(' startPositionOfPeriodInProp '), } { display(_startPositionOfPeriodInProp),nl, } {If character not found in theProposition, _startPosition... will be 0} ( {If} ((_startPositionOfNumberSignInProp = 1) , {And} (_startPositionOfPeriodInProp > 1)) -> {Then} { There is an initial number sign, followed somewhere by a period} ( write(' IsA2 case, calling translateEntityToSelectClause '),nl, translateEntityToSelectClause(_theProposition, _PropositionSelectClause), { translateSelectClauseToExplanationMarkForm( _PropositionSelectClause, _possiblyTranslatedParameter)} write(' PropositionSelectClause '),display(_PropositionSelectClause),nl, ( {If} (_PropositionSelectClause = select(_theClassOfProposition,!, _theAttributeOfProposition)) -> {Then} { Return C!p format } ( { Future: to deal with IsA2 and nesting } atomconcat([_superclass,'!', _theAttributeOfProposition], _possiblyTranslatedParameter) {_possiblyTranslatedParameter is of form _x!_l } ) ; {Else} ( _possiblyTranslatedParameter = _selectClause {For future, could sub-divide this case. E.g., is it an IsA clause? } ) ) ) ; {Else} ( write(' error or recursive case '), _possiblyTranslatedParameter = _parameter ) ) ) ; {Else} {(c)} ( _possiblyTranslatedParameter = _parameter ) ) ; { Else } {(c)} ( _possiblyTranslatedParameter = _parameter ) ) ). { The predicate translateEntityToSelectClause (based on checkDef) takes an * entity, assumed to be a Proposition (e.g., '#1234.5678', * John,). * Where the entity is a link, it returns an expression (possibly recursive) * of the form select(Student,!,age); * otherwise it returns the entity name, e.g., Student.. * It uses the built-in * query get_object to get the Telos definition of _Entity, * and then uses getPropositionSelectClause to process the SMLFragment Input of form IsA2('#1234.566',Person) currently working formerly getSelectClauseOfProposition } translateEntityToSelectClause(_Entity,_selectClause):- ( {If} (_Entity = IsA2(_theProposition,_superclass) ) -> {Then} {(b) } ( {If} (atom(_theProposition)) -> {Then} {theProposition is an atom} ( atomverify(_theProposition,'#',_startPositionOfNumberSignInProp), atomverify(_theProposition,'.',_startPositionOfPeriodInProp), {If character not found in theProposition, _startPosition... will be 0} ( {If} ((_startPositionOfNumberSignInProp = 1) , {And} (_startPositionOfPeriodInProp > 1)) -> {Then} { There is an initial number sign, followed somewhere by a period} ( translateEntityToSelectClause(_theProposition, _PropositionSelectClause), { write(' theProposition '), display(_theProposition),nl, } { write(' PropositionSelectClause '),display(_PropositionSelectClause),nl, } ( {If} (_PropositionSelectClause = select(_theClassOfProposition,!, _theAttributeOfProposition)) -> {Then} { Return C!p format } ( { Future: to deal with IsA2 and nesting } _selectClause = select(_superclass,!,_theAttributeOfProposition) ) ; {Else} ( _selectClause = _Entity {error case?} {For future, could sub-divide this case. E.g., is it an IsA clause? } ) ) ) ; {Else} ( write(' error or recursive case '), _selectClause = _Entity {error case?} ) ) ) ; {Else} ( _selectClause = _Entity {error case?} ) ) ; { Else } ( {Normal case} getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[get_object([_Entity/objname])]), ipcanswer(_sender,_completion,_SMLFragment)), getSelectClauseFromSMLFragment(_SMLFragment,_selectClause) ) ). {* The predicate getSelectClauseFromSMLFragment processes the SMLfragment * to get the first argument of the "what" sub-fragment (which is the * first sub-fragment of the SMLFragment). * Where the SMLFragment is of a link, it returns an expression * of the form select(Student,!,age); * if it is of an entity, it returns the entity name, e.g., Student. * Note: there are other cases; e.g., if it is an IsA proposition, it returns: select(Mapping,=>,SimpleClass) } getSelectClauseFromSMLFragment([],[]) :- !. getSelectClauseFromSMLFragment(_SMLFragment,_selectClause) :- arg(1,_SMLFragment,_whatClause), { write(' whatClause '),display(_whatClause),nl, } arg(1,_whatClause,_selectClause) { , } { write(' selectClause '),display(_selectClause),nl } . { translateSelectClauseToExplanationMarkForm: (a) If _selectClause is of the form select(C,!,p) then _possiblyTranslatedParameter is of the form C!p (b) If _selectClause is of recursive form, e.g, select(select(C,!,p),q) then _possiblyTranslatedParameter is of the form C!p!q (c) Otherwise _possiblyTranslatedParameter is set to the same value as _selectClause } translateSelectClauseToExplanationMarkForm(_selectClause, _possiblyTranslatedParameter):- ( {If} (_selectClause = select(_theSubject,!,_theAttribute)) -> {Then} { Return theSubject!p format } ( translateSelectClauseToExplanationMarkForm(_theSubject, _possiblyTranslatedSubject), atomconcat([_possiblyTranslatedSubject,'!',_theAttribute], _possiblyTranslatedParameter) ) ; {Else} ( _possiblyTranslatedParameter = _selectClause {For future, could sub-divide this case. E.g., is it an IsA clause? } ) ). { translateSelectClauseToClassAttributeForm: (a) If _selectClause is of the form select(C,!,p) then _possiblyTranslatedParameter is of the form Cp (b) If _selectClause is of recursive form, e.g, select(select(C,!,p),q) then _possiblyTranslatedParameter is of the form Cpq (c) Otherwise _possiblyTranslatedParameter is set to the same value as _selectClause } translateSelectClauseToClassAttributeForm(_selectClause, _possiblyTranslatedParameter):- ( {If} (_selectClause = select(_theSubject,!,_theAttribute)) -> {Then} { Return theSubjectp format } ( translateSelectClauseToClassAttributeForm(_theSubject, _possiblyTranslatedSubject), atomconcat([_possiblyTranslatedSubject,_theAttribute], _possiblyTranslatedParameter) ) ; {Else} ( _possiblyTranslatedParameter = _selectClause {For future, could sub-divide this case. E.g., is it an IsA clause? } ) ). { ***************************************************************** } translateExplanationMarkFormToSelectClause (_explanationMarkForm,_selectClause):- {given a value, if it in explanation mark form (e.g., a!b!c), translate to selectClause form (e.g., select(select(a,!,b),!,c)} {If the value is not atomic, the new value will be the same as the old.} {First translate atomic value to a list (e.g., [a,b,c]), and then from the list to selectClause form.} {This should be used after accepting user input. Note that the user should quote expressions containing '!'.} {Possible future improvement: see if input has quotes.} {Notation: explanationMarkForm = source!remainder} ((atomic(_explanationMarkForm)) -> (translateExplanationMarkFormToList(_explanationMarkForm,_list), translateListToSelectClause(_list,_selectClause) ); ({else not atomic input} _selectClause = _explanationMarkForm ) ). translateExplanationMarkFormToList(_explanationMarkForm,_list):- {given an atomic value, possibly in explanation mark form (e.g., a!b!c), translate to a list (e.g., [a,b,c].} decomposeExplanationMarkFormToList([],_explanationMarkForm,_list). {decomposeExplanationMarkFormToList(_listIn,_explanationMarkForm,_listOut):} {This is a helping predicate for translateExplanationMarkFormToList. Given listIn and explanationMarkForm, find the first name in explanationMarkForm, append it to listIn, and then decompose the remainder of explanationMarkForm.} decomposeExplanationMarkFormToList(_listIn,[],_listIn). {nil explanationMarkForm} decomposeExplanationMarkFormToList(_listIn,_explanationMarkForm,_listOut):- {non-nil explanationMarkForm} (_explanationMarkForm \== nil), {Find first "!"} atomverify(_explanationMarkForm,'!',_startPositionOfFirstExplanationMark), {If character not found, _startPosition... will be 0} atomlength(_explanationMarkForm,_explanationMarkFormLength), ( ((_startPositionOfFirstExplanationMark > 1), (_startPositionOfFirstExplanationMark < _explanationMarkFormLength)) -> ({There is an explanationMark, not in the first or last character} {Produce source:} _lengthOfSource is (_startPositionOfFirstExplanationMark - 1), atompart(_explanationMarkForm,_source,1,_lengthOfSource), {write(' source '),display(_source),} {Produce remainder:} _startPositionOfRemainder is (_startPositionOfFirstExplanationMark + 1), _lengthOfRemainder is (_explanationMarkFormLength - _startPositionOfFirstExplanationMark), atompart(_explanationMarkForm,_remainder, _startPositionOfRemainder,_lengthOfRemainder), atomlength(_remainder,_remainderLength), {append, then decompose} append(_listIn,[_source],_listIntermediate), decomposeExplanationMarkFormToList(_listIntermediate,_remainder, _listOut) ); ({There is no explanation mark, or there is one in the first or last position} {Future: distinguish these cases} append(_listIn,[_explanationMarkForm],_listOut) ) ). translateListToSelectClause(_list,_selectClause):- {give a list, e.g., [a,b,c,d], produce a selectClause, e.g., select(select(select(a,!,b),!,c),!,d)} composeListToSelectClause([],_list,_selectClause). {composeListToSelectClause(_selectIn,_list,_selectOut):} {This is a helping predicate for translateListToSelectClause/2.} {Form select(_selectIn,!,list head), then compose this with list tail.} {Intial value of _selectIn is set to [] by caller.} composeListToSelectClause(_selectIn,[],_selectIn). {empty list} composeListToSelectClause([],[_singleListElement],_singleListElement). {one-element list} composeListToSelectClause([],[_listElement1|_listTail],_selectOut):- {list with >=2 elements} _listTail = [_listElement2|_listEnd], {see above case} composeListToSelectClause(select(_listElement1,!,_listElement2), _listEnd,_selectOut). composeListToSelectClause(_selectIn,[_listHead|_listTail],_selectOut):- {non-initial selectIn} (selectIn \== nil), {see case above} composeListToSelectClause(select(_selectIn,!,_listHead),_listTail, _selectOut). { testTranslate(_A,_B,_C,_D,_E):- translateExplanationMarkFormToSelectClause('a',_A), translateExplanationMarkFormToSelectClause('a!bb',_B), translateExplanationMarkFormToSelectClause('a!bb!ccc',_C), translateExplanationMarkFormToSelectClause('a!bb!ccc!ddd',_D), translateExplanationMarkFormToSelectClause(select(x,!,y),_E). } reselect(_explanationMarkForm,_selectClause):- translateExplanationMarkFormToSelectClause (_explanationMarkForm,_selectClause). { ***************************************************************** } { getNode queries the KB for the current value of the node counter, which is * placed in the variable _N. } getNode(_N) :- askAny(NodeCount, counter, _NList), _NList = [_N]. { updateNode takes two inputs, the old value and new value of the node counter, and updates the counter by * (1) UNTELLing the old attribute value of the class NodeCount * (2) TELLing the new value } { updateNode(_oldN,_newN) :- _L = ['Individual NodeCount with attribute,counter nodecnt:',' ', _oldN,' ','end NodeCount'], atomconcat(_L,_W), { construct atom representing definition for UNTELL } name(_W,_U), { convert the atom to Prolog string format } getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,UNTELL,[_U]), ipcanswer(_s,_c,_r)), { execute UNTELL } _L1 = ['Individual NodeCount with attribute,counter nodecnt:',' ',_newN, ' ','end NodeCount'], atomconcat(_L1,_W1), { construct new attribute definition } name(_W1,_U1), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,TELL,[_U1]), ipcanswer(_s1,_c1,_r1)). { execute TELL } } { ************************* } { Re queries on propositions } getSMLFragmentOfProposition(_proposition,_SMLFragment) :- { Given a proposition, SMLFragment is set to the SML fragment corresponding to the proposition. The generic query class mypropositionquery is invoked. It returns an SMLFragment.} getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[mypropositionquery([_proposition/WhatProposition])]), ipcanswer(_sender,_completion,_SMLFragment)) {,} { query KB } {write(' SMLFragment '),display(_SMLFragment),nl}. { **** testing routines follow: } { test1(_proposition,_SMLFragment) :- getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[mypropositionquery([_proposition/WhatProposition])]), ipcanswer(_sender,_completion,_SMLFragment)), { query KB } write(' SMLFragment '),display(_SMLFragment),nl. test2(_proposition,_SMLFragment) :- getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[mypropositionquery2([_proposition/WhatProposition])]), ipcanswer(_sender,_completion,_SMLFragment)), { query KB } write(' SMLFragment '),display(_SMLFragment),nl. test3(_proposition,_SMLFragment) :- getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[mypropositionquery3([_proposition/WhatClass])]), ipcanswer(_sender,_completion,_SMLFragment)), { query KB } write(' SMLFragment '),display(_SMLFragment),nl. test4(_proposition,_SMLFragment) :- getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[mypropositionquery4([_proposition/WhatProposition])]), ipcanswer(_sender,_completion,_SMLFragment)), { query KB } write(' SMLFragment '),display(_SMLFragment),nl. test5(_proposition,_SMLFragment) :- getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[mypropositionquery5([_proposition/WhatProposition])]), ipcanswer(_sender,_completion,_SMLFragment)), { query KB } write(' SMLFragment '),display(_SMLFragment),nl. test6(_proposition,_SMLFragment) :- getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[mypropositionquery6([_proposition/WhatClass])]), ipcanswer(_sender,_completion,_SMLFragment)), { query KB } write(' SMLFragment '),display(_SMLFragment),nl. } { **** testing routines above } { getTo, getFrom, getLabel all invoke getSMLFragmentOfProposition. Then each extracts the needed information from the proposition. } { An alternative is to have 3 separate queries. } { getTo queries the KB. Given a proposition, it sets attributeValue to the attribute value. I.e., To(_proposition, _attributeValue) (See ConceptBase manual). Predicate getSMLFragmentOfProposition returns an SMLFragment. Then predicate getToValue takes the SMLFragment and extracts and returns the attribute value. } { getTo(_proposition,_attributeValue) :- getSMLFragmentOfProposition(_proposition,_SMLFragment), getToValue(_SMLFragment,_attributeValue). } {process SMLfragment format to extract attribute value } { getToValue takes a SMLfragment format returned from the KB, and processes it * to extract the proper attribute value. } { getToValue(_SMLFragment,_attributeValue) :- { TO REVISE FOLLOWING } _SMLFragment = [_H], getAttrDeclListFromSMLFragment(_H,_attrdecllist), _attrdecllist = [_attrdec|_T], arg(2,_attrdec,_propertylist), _propertylist = [_property|_T1], arg(2,_property,_attributeValue). } { getFrom queries the KB. Given a proposition, it sets attributeValue to the attribute value. I.e., From(_proposition, _attributeValue) (See ConceptBase manual). Predicate getSMLFragmentOfProposition returns an SMLFragment. Then predicate getFromValue takes the SMLFragment and extracts and returns the attribute value. } { getFrom(_proposition,_attributeValue) :- getSMLFragmentOfProposition(_proposition,_SMLFragment), getFromValue(_SMLFragment,_attributeValue). } {process SMLfragment format to extract attribute value } { getFromValue takes a SMLfragment format returned from the KB, and processes * it to extract the proper attribute value. } { getFromValue(_SMLFragment,_attributeValue) :- { TO REVISE FOLLOWING } _SMLFragment = [_H], getAttrDeclListFromSMLFragment(_H,_attrdecllist), _attrdecllist = [_attrdec|_T], arg(2,_attrdec,_propertylist), _propertylist = [_property|_T1], arg(2,_property,_attributeValue). } { getLabel queries the KB. Given a proposition, it sets attributeValue to the attribute value. I.e., Label(_proposition, _attributeValue) (See ConceptBase manual). Predicate getSMLFragmentOfProposition returns an SMLFragment. Then predicate getLabelValue takes the SMLFragment and extracts and returns the attribute value. } { ************************* } { findSpecialisations is a predicate which, given the name of a Telos class * which is the parameter for the application of the subclass method, finds * the specialisations of that class. For example, in decomposing * Accuracy[Reports] using the subclass method, findSpecialisations would * find the specialisations of the class Reports. } { findSpecialisations has two variables: _parameter holds the name of the * class in question (e.g., Reports), and answer is a list which contains the * names of all the specialisations of _parameter (e.g., * [MeetingReports,MemberReports,ProjectReports]). * The call to IpcChannel_call queries the KB for the specialisations of * _parameter. This is done using a generic query class * (myspecialisationquery), contained * in the file isATest.sml. _parameter is substituted for the parameter * field of myspecialisationquery in order to implement the ASK operation. * The return * answer in SMLfragment format is placed in the variable _return. The * predicate process is then used to extract the names of the specialisations. } findSpecialisations(_parameter,_answer) :- { write(' fSp 0 '),write(_parameter),nl, } { quoteIfNecessary(_parameter,_quotedParameter),} getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[myspecialisationquery([_parameter/whatClass])]), { execute query } ipcanswer(_sender,_completion,_return)), { write(' fSp '),display(_return),nl, } getSubclassValues(_return,_answer). { process SMLfragment, get specialisations } { findSortAndParameterAttributes is similar to findSpecialisations, * except that it queries the KB for the sort and parameters * (returned in parameterStructure format) of the * attribute values for the node given in _Node. } { N.B. Use myallattributequery for all attributes (with category attribute of ExpenseManagementFunctionalRequirementClass; use mysortandparameterofnodequery for sort and parameters of Nodes. } findSortAndParameterAttributes(_methodClass,_Node,_sort,_parameterStructure) :- nl,write(' fsp 1 node '), write(_Node),nl, write(' fsp 1 methodClass '), write(_methodClass),nl, quoteIfNecessary(_Node,_QuotedNode), write(' QuotedNode '),display(_QuotedNode),nl, genMethodInstanceNodeAttributeQuery(_methodClass,_QuotedNode, [_methodInstanceNodeAttributeQuery]), {_methodInstanceNodeAttributeQuery is the node attribute query applicable to the _methodClass} {write(' methodInstanceNodeAttributeQuery '), } display(_methodInstanceNodeAttributeQuery),nl, getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[_methodInstanceNodeAttributeQuery]), ipcanswer(_sender,_completion,_return)), write('fsp 2 completion='),write(_completion), {write('fsp 2 return '),write(_return), } _return = [_SMLFragment|_T], {genMethodInstanceNodeType(_methodClass,_NodeType),} _parentNodeInFact = _Node, genOffspringNodeType(_methodClass,_parentNodeInFact, _offspringNodeType), _NodeType = _offspringNodeType, nl,write(' offspringNodeType='),display(_NodeType), {*** May need to pass NodeType to routine which generates new nodes } genNodeCategoryList(_NodeType,_NodeCategoryList), {_NodeCategoryList is the list of parameter categories which is then taken from the query answer and put into _parameterStructure.} { write(' SMLFragment '),nl,display(_SMLFragment),nl, } { write(' T should be nil: '),nl,display(_T),nl, } { write(' Change name of T, and revise getSortAndParameterAttributeValues'), } nl, { write(' to deal with parameterStructure'),nl, } getSortAndParameterAttributeValues(_SMLFragment,_NodeCategoryList, _sort,_parameterStructure). {************* To adjust the following **************************} { findAllAttributes is similar to findSpecialisations, * except that it queries the KB for all the (named) attributes * (of category attribute) the class (an instance of * ExpenseManagementFunctionalRequirementClass) given in _Class. } findAllAttributes(_Class,_ans) :- { write(' faa 1 class '), write(_Class), } quoteIfNecessary(_Class,_QuotedClass), getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[myallattributequery([_QuotedClass/whatClass])]), ipcanswer(_sender,_completion,_return)), { write('faa 2 return '),write(_return), } _return = [_SMLFragment|_T], { write('faa 3 SMLFragment '), write(_SMLFragment), } getAllAttributes(_SMLFragment,_ans). { findDerivationFunctions is similar to findSpecialisations, * except that it queries the KB for the * derivation functions for _Item. } findDerivationFunctions(_Item,_ans) :- quoteIfNecessary(_Item,_QuotedItem), { write(' QuotedItem '),display(_QuotedItem),nl, } getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid, _CBsid,ASK,[myderivationfunctionquery([_QuotedItem/whatTarget])]), ipcanswer(_sender,_completion,_return)), { OK UP TO HERE FOR ONE TEST } { write(' fDF return '),nl, } { display(_return),nl, } getAttributeValuesFromSMLFragmentList(_return,_ans). { _return = [_H|_T], getDerivationFunctionsValues(_H,_ans).} {********************* To compare above and below **********************} { ******* In following, may have to generate CorrectDeriv, * and add one to list length. ********************** } { findDerivationComponents is similar to findSpecialisations, * except that it queries the KB for the * derivation components for the function given in _Function. } findDerivationComponents(_Function,_ans) :- quoteIfNecessary(_Function,_QuotedFunction), getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid, ASK,[myderivationcomponentquery([_QuotedFunction/whatFunction])]), ipcanswer(_sender,_completion,_return)), { write(' fDC return '),nl, } { display(_return),nl, } getAttributeValuesFromSMLFragmentList(_return,_ans). { _return = [_H|_T], getDerivationComponentsValues(_H,_ans).} { The getSubclassValues predicate takes an answer from the CBserver in * SMLfragment * format and extracts the names of the specialisations, placing them in the * list _answer. The SMLfragment format is itself a Prolog list, with elements * Prolog terms. For the purposes of finding the names of the classes, it is * necessary to know that each term with functor SMLfragment will have a term * as first argument which itself has functor what. The first element of this * term in turn will have the name of the class (e.g., * [SMLfragment(what(MeetingReports,...)...),SMLfragment(what(MemberReports,...] * There is one SMLfragment(...) term for each specialisation. } { Note: getSubclassValues was formerly called process.} getSubclassValues([],[]). {When out of specialisations, return []} getSubclassValues([_H|_T],_answer) :- { write(' gSCV '),display(_H),nl, } functor(_H,SMLfragment,_Arity), arg(1,_H,_W), functor(_W,what,_Arity2), arg(1,_W,_NewName), {_NewName holds name of specialisations} { write(' newName '),display(_NewName), } getSubclassValues(_T,_answer2), {process rest of list recursively} append([_NewName],_answer2,_answer). append([],_L,_L). append([_X|_L1],_L2,[_X|_L3]) :- append(_L1,_L2,_L3). {consIfNonNil(_A,_L,_NewL): _NewL is cons(_A,_L) if _A is non-nil; _L otherwise.} consIfNonNil([],_L,_L). consIfNonNil(_A,_L,[_A|_L]) :- \+(_A == nil). { _A not= nil } { getSortAndParameterAttributeValues is the corresponding predicate to * getSubclassValues, * for the predicate findSortAndParameterAttributes. It gets the sort value * (set to nil if not found), * and (in parameterStructure format) * parameter values (corresponding to the categories indicated by * _methodInstanceNodeCategoryList) from the SMLfragment format. } getSortAndParameterAttributeValues(_SMLfragment, _methodInstanceNodeCategoryList,_sort,_parameterStructure) :- {write('Note: SML Fragment, not list '),nl, } { To revise,nl, } getAttrDeclListFromSMLFragment(_SMLfragment,_attrdecllist), {write(' attrdecllist '),display(_attrdecllist),nl,} getAttributeValuesOfGivenCategoryFromAttrDeclList(_attrdecllist, sort,_sortList), {write(' sortList '),display(_sortList),nl, } ((_sortList = []) -> (_sort = []); (_sortList = [_sort])), write(' sort '),display(_sort),nl, getParameterStructureOfGivenCategoryListFromAttrDeclList(_attrdecllist, _methodInstanceNodeCategoryList,_parameterStructure) ,write(' parameterStructure '),display(_parameterStructure),nl . { getAllAttributes is the corresponding predicate to * getSubclassValues, for the predicate findAllAttributes. * It gets all the (non-empty) attributes (not the attribute values) * of category attribute from the SMLfragment format. } { Get 5th argument, i.e., , from SMLFragment. Pick out from with(). Apply getAllAttributesFromAttrDeclList. } getAllAttributes(_SMLfragment,_ans) :- getAttrDeclListFromSMLFragment(_SMLfragment,_attrdecllist), getAllAttributesFromAttrDeclList(_attrdecllist,_ans). { getAllAttributesFromAttrDeclList(_attrdecllist,_ans) : _ans contains all the attributes from each attrdecl in _attrdecllist For each in do Get from , which is attrdecl(,). For each in , Get the non-null , where is property(,,,) } getAllAttributesFromAttrDeclList([],[]). getAllAttributesFromAttrDeclList([_attrdecl|_attrdecllist],_ans) :- arg(2,_attrdecl,_propertylist), selectAttributeLabels(_propertylist,_ansAttrDecl), getAllAttributesFromAttrDeclList(_attrdecllist,_ansAttrDeclList), append(_ansAttrDecl,_ansAttrDeclList,_ans). {selectAttributeLabels(_propertyList,_attributeLabelList) : _attributeLabelList contains the first argument (if non-nil) of each item in _propertyList} selectAttributeLabels([],[]). { Problem: ConceptBase can return ill-formed with a missing label, e.g.: property(,Integer,default,nil). This kind of structure cannot be used as input to the Prolog user interface. However, if untouched by human hands, ConceptBase and Prolog appear to be able to handle it. Ad hoc solution: When there is no first argument, _label is nil (i.e., []). Detect this case, and do not add it to the answer, _ans} selectAttributeLabels([_property|_propertyList],_ans) :- {write(' property '),display(_property),nl, } arg(1,_property,_label), atomtolist(_label,_labelList), { display(_labelList),nl, } selectAttributeLabels(_propertyList,_ansPL), constructAttributeLabelList(_labelList,_label,_ansPL,_ans). { constructAttributeLabelList(_labelList_label,_ansPL,_ans): if _labelList non-nil, set _ans to [_label|_ansPL], otherwise to _ansPL.} constructAttributeLabelList([],_label,_ansPL,_ansPL). constructAttributeLabelList(_labelList,_label,_ansPL,_ans) :- \+(_labelList == nil), { _labelList non-nil } _ans = [_label|_ansPL]. { ******************* } { getEntityNamesFromSMLFragmentList(_SMLFragmentList,_ansOverall) : * _ansOverall is a list containing the entity name of each SMLfragment in * _SMLFragmentList, which is a list of SMLfragments.} { ******************** } getEntityNamesFromSMLFragmentList([],[]). getEntityNamesFromSMLFragmentList([_SMLFragment|_SMLFragmentListTail], _ansOverall) :- { write(' getEntityNamesFromSMLFragmentList SMLFragment '),nl, } { display(_SMLFragment),nl, } {get EntityName From SMLFragment:} arg(1,_SMLFragment,_whatClause), arg(1,_whatClause,_entityName), {memo: arg(5,_whatClause,_attributeInformation)} {write(' entityName '),display(_entityName),nl, } getEntityNamesFromSMLFragmentList(_SMLFragmentListTail,_ansList), { write(' ansList '),display(_ansList),nl, } _ansOverall = [_entityName|_ansList]. { ******************** } {selectAttributeValues(_propertyList,_attributeValueList) : _attributeValueList contains the second argument (where the corresponding first argument is non-nil) of each item in _propertyList} selectAttributeValues([],[]). { Problem: ConceptBase can return ill-formed with a missing value, e.g.: property(,Integer,default,nil). This kind of structure cannot be used as input to the Prolog user interface. However, if untouched by human hands, ConceptBase and Prolog appear to be able to handle it. Ad hoc solution: When there is no first argument, _value is nil (i.e., []). Detect this case, and do not add it to the answer, _ans} selectAttributeValues([_property|_propertyList],_ans) :- { write(' property '),display(_property),nl, } arg(1,_property,_label), arg(2,_property,_value), atomtolist(_label,_labelList), { display(_labelList),nl, } selectAttributeValues(_propertyList,_ansPL), constructAttributeLabelList(_labelList,_value,_ansPL,_ans). { ******************** } { The following applies to at least findDerivationComponents and findDerivationFunctions. However, assuming that the ConceptBase query has already selected the necessary attributes, it can be used elsewhere.} { It generates one list of all attributes, not a list of lists.} { getAttributeValuesFromSMLFragmentList(_SMLFragmentList,_ansOverall) : * _ansOverall is a list of all the attribute values with non-empty attributes * for each category of each SMLfragment in * _SMLFragmentList, which is a list of SMLfragments.} {setdebug.} getAttributeValuesFromSMLFragmentList([],[]). getAttributeValuesFromSMLFragmentList([_SMLFragment|_SMLFragmentList], _ansOverall) :- { write(' getAttributeValuesFromSMLFragmentList SMLFragment '),nl, } { display(_SMLFragment),nl, } getAttributeValuesFromSMLFragment(_SMLFragment,_ans), { write(' ans '),display(_ans),nl, } getAttributeValuesFromSMLFragmentList(_SMLFragmentList,_ansList), { write(' ansList '),display(_ansList),nl, } append(_ans,_ansList,_ansOverall). { getAttributeValuesFromSMLFragment(_SMLFragment,_ans) : * _ans is a list of all the attribute values with non-empty attributes * for each category of the given _SMLfragment.} { Get 5th argument, i.e., , from SMLFragment. Pick out from with(). Apply getAttributeValuesFromAttrDeclList. } getAttributeValuesFromSMLFragment([],[]). getAttributeValuesFromSMLFragment(_SMLFragment, _ans) :- { write(' getAttributeValuesFromSMLFragment SMLFragment '),nl, } { display(_SMLFragment),nl, } getAttrDeclListFromSMLFragment(_SMLFragment,_attrdecllist), { write(' getAttributeValuesFromSMLFragment attrdecllist '),nl, } { display(_attrdecllist),nl, } getAttributeValuesFromAttrDeclList(_attrdecllist,_ans). { getAttributeValuesFromAttrDeclList(_attrdecllist,_ans) : _ans contains all the attribute values from each attrdecl in _attrdecllist For each in do Get from , which is attrdecl(,). For each in , If is non-null, append to _ans where is property(,,,) } getAttributeValuesFromAttrDeclList([],[]). getAttributeValuesFromAttrDeclList([_attrdecl|_attrdecllist],_ans) :- { write(' getAttributeValuesFromAttrDeclList attrdecl '),nl, } { display(_attrdecl),nl, } { write(' attrdecllist '), display(_attrdecllist),nl, } arg(2,_attrdecl,_propertylist), selectAttributeValues(_propertylist,_ansAttrDecl), getAttributeValuesFromAttrDeclList(_attrdecllist,_ansAttrDeclList), append(_ansAttrDecl,_ansAttrDeclList,_ans). { getAttrDeclListFromSMLFragment(_SMLFragment,_attrDeclList) : Given _SMLFragment, get the _attrDeclList } getAttrDeclListFromSMLFragment(_SMLFragment,_attrDeclList):- arg(5,_SMLFragment,_with), arg(1,_with,_attrDeclList). { selectAttributeValues(_propertyList,_attributeValueList) : _attributeValueList contains the first argument (if non-nil) of each item in _propertyList } selectAttributeValues([],[]). { Problem: ConceptBase can return ill-formed with a missing label, e.g.: property(,Integer,default,nil). This kind of structure cannot be used as input to the Prolog user interface. However, if untouched by human hands, ConceptBase and Prolog appear to be able to handle it. Ad hoc solution: When there is no first argument, _label is nil (i.e., []), and so is _labelList, where atomtolist(_label,_labelList). Detect this case, and do not add it to the answer, _ans} selectAttributeValues([_property|_propertyList],_ans) :- { write(' property '),display(_property),nl, } arg(1,_property,_label), arg(2,_property,_value), atomtolist(_label,_labelList), {display(_labelList),nl,} selectAttributeValues(_propertyList,_ansPL), constructAttributeValueList(_labelList,_value,_ansPL,_ans). { constructAttributeValueList(_labelList,_value,_ansPL,_ans): if _labelList non-nil, set _ans to [_value|_ansPL], otherwise to _ansPL.} constructAttributeValueList([],_value,_ansPL,_ansPL). constructAttributeValueList(_labelList,_value,_ansPL,[_value|_ansPL]) :- \+(_labelList == nil). { _labelList non-nil } { ******************** } { getParameterStructureOfGivenCategoryListFromAttrDeclList(_attrdecllist, _categoryList,_parameterStructure) : Given an _attrdecclist and a list of categories (_categoryList), the corresponding _parameterStructure is produced. } getParameterStructureOfGivenCategoryListFromAttrDeclList(_attrdecllist, [],[]). getParameterStructureOfGivenCategoryListFromAttrDeclList(_attrdecllist, [_category|_categoryListTail],_parameterStructure) :- getCategoryComponentOfGivenCategoryFromAttrDeclList(_attrdecllist, _category,_categoryComponent), getParameterStructureOfGivenCategoryListFromAttrDeclList(_attrdecllist, _categoryListTail,_TailParameterStructure), consIfNonNil(_categoryComponent,_TailParameterStructure, _parameterStructure). { ************ } { getCategoryComponentOfGivenCategoryFromAttrDeclList(_attrdecllist, _category,_categoryComponent) : _categoryComponent is the categoryComponent for the given _category. (If there are no attributes for the category, categoryComponent is nil.) Information is extracted from the given _attrdecllist.} getCategoryComponentOfGivenCategoryFromAttrDeclList(_attrdecllist, _category,_categoryComponent):- getAttributesAndValuesOfGivenCategoryFromAttrDeclList(_attrdecllist, _category,_ans), ({If} (_ans = [] ) -> {Then} (_categoryComponent = []) ; {Else} (_categoryComponent = [_category,_ans])). { getAttributesAndValuesOfGivenCategoryFromAttrDeclList(_attrdecllist, _category,_ans) : _ans contains a list of the form [[attribute1,value1], ... ,[attributeN,valueN]] which contains all the attributes and their values values from each attrdecl, of the given category, in _attrdecllist For each in do From which is attrdecl(,) Get . If _category is a member of then Get from , For each in , If is non-null, append [, ] to _ans where is property(,,,) (It is possible that _category will appear in more than one attrcategorylist, so all are examined.) } getAttributesAndValuesOfGivenCategoryFromAttrDeclList([],_category,[]). getAttributesAndValuesOfGivenCategoryFromAttrDeclList([_attrdecl|_attrdecllist], _category,_ans) :- { write(' getAttributesAndValuesOfGivenCategoryFromAttrDeclList attrdecl '),nl,} { display(_attrdecl),nl, } { write(' attrdecllist '), display(_attrdecllist),nl, } arg(1,_attrdecl,_attrcategorylist), { write(' attrcategorylist '), display(_attrcategorylist),nl, } ( {If} (member(_category,_attrcategorylist)) -> {Then} ( arg(2,_attrdecl,_propertylist), { write(' propertylist '), display(_propertylist),nl, } selectAttributesAndValues(_propertylist,_ansAttrDecl) { , } { write(' ansAttrDecl '),display(_ansAttrDecl),nl } ) ; {Else} ( _ansAttrDecl = [] {, write(' else '),nl } )), getAttributesAndValuesOfGivenCategoryFromAttrDeclList(_attrdecllist,_category, _ansAttrDeclList), { write(' ansAttrDecl '),display(_ansAttrDecl),nl, } { write(' ansAttrDeclList '),display(_ansAttrDeclList),nl, } { write(' need to also get attribute names? '),nl, } append(_ansAttrDecl,_ansAttrDeclList,_ans) { , write(' ans '),display(_ans),nl } . {selectAttributesAndValues(_propertyList,_attributeValueList) : _attributeValueList contains the first argument (if non-nil) of each item in _propertyList} selectAttributesAndValues([],[]). { Problem: ConceptBase can return ill-formed with a missing label, e.g.: property(,Integer,default,nil). This kind of structure cannot be used as input to the Prolog user interface. However, if untouched by human hands, ConceptBase and Prolog appear to be able to handle it. Ad hoc solution: When there is no first argument, _label is nil (i.e., []), and so is _labelList, where atomtolist(_label,_labelList). Detect this case, and do not add it to the answer, _ans} selectAttributesAndValues([_property|_propertyList],_ans) :- { write(' property '),display(_property),nl, } arg(1,_property,_label), arg(2,_property,_value), atomtolist(_label,_labelList), { display(_labelList),nl, } selectAttributesAndValues(_propertyList,_ansPL), constructAttributeValueList(_labelList,[_label,_value],_ansPL,_ans). { ******************** } { Code for obtaining sort and parameter from an SMLfragment, then producing a parameterStructure, then producing a tell-clause.} { ************************** } { Given an objectname, getInstanceOfIsASortAndAllParameterAttributeValues first gets its SMLFragment, then returns the entity's name, its isA list, its instanceOf list, its sort and, in parameterStructure format, all the "parameter" attribute values (for categories such as infoItemParam, agentParam, derivationFnParam).} getInstanceOfIsASortAndAllParameterAttributeValues(_entity, _instanceOfList,_isAList,_sort,_parameterStructure) :- getSMLFragmentOfObject(_entity,_SMLFragment), write(' SMLFragment '),display(_SMLFragment),nl, getInstanceOfListFromSMLFragment(_SMLFragment,_instanceOfList), write(' instanceOfList '),display(_instanceOfList),nl, getIsAListFromSMLFragment(_SMLFragment,_isAList), write(' isAList '),display(_isAList),nl, {parameterCategoryList is the list of all applicable parameter categories} genNodeCategoryList(AllParameterCategories,_parameterCategoryList), getSortAndParameterAttributeValues(_SMLFragment, _parameterCategoryList,_sort,_parameterStructure). { *********** } getInstanceOfListFromSMLFragment(_SMLFragment,_instanceOfList):- {Given SMLfragment, isAList is a list of superclass names in the fragment} arg(3,_SMLFragment,_instanceOfClause), write(' instanceOfClause '),display(_instanceOfClause),nl, getNameListFromSMLClause(_instanceOfClause,_instanceOfList). getIsAListFromSMLFragment(_SMLFragment,_isAList):- {Given SMLfragment, isAList is a list of superclass names in the fragment} arg(4,_SMLFragment,_isAClause), write(' isAClause '),display(_isAClause),nl, getNameListFromSMLClause(_isAClause,_isAList). getNameListFromSMLClause(_SMLClause,_NameList):- {Given an SMLClause (which is an isA or instanceOf portion of an SMLFragment, produce a list of names in the list (eliminating extra material from SMLClause} arg(1,_SMLClause,_SMLList), write(' SMLList '),display(_SMLList),nl, getNamesFromSMLList(_SMLList,_NameList). {getNamesFromSMLList(_SMLList,_NameList): Helping predicate. For each item in SMLList, append first argument of item to NameList.} getNamesFromSMLList([],[]). getNamesFromSMLList([_SMLListHead|_SMLListTail],_NameList):- arg(1,_SMLListHead,_NameListHead), write(' NameListHead '),display(_NameListHead),nl, getNamesFromSMLList(_SMLListTail,_NameListTail), write(' NameListTail '),display(_NameListTail),nl, _NameList = [_NameListHead|_NameListTail]. { *********** } translateHeaderAndSortAndParameterStructureToTelosCode (_entityName,_instanceOfList,_isAList, _sortValue,_parameterStructure,_TelosCode):- {Given entity name, instanceOfList, isAList, sort and parameter structure, TelosCode becomes an atom which is the corresponding entity declaration.} {Note: Until the end, use lists for intermediate forms of declarations.} {See also applyStepwiseSpecializationGRM for a similar approach, and testing re Individual vs. Attribute} translateSortAndParameterStructureToTelosCodeList (_sortValue,_parameterStructure,_SortAndParameterCodeList), write(' SortAndParameterCodeList '),display(_SortAndParameterCodeList),nl, {Decide whether declaration starts with Individual or Attribute. Use Individual if entityName is atomic, without an explanation mark} ( {If} (atomic(_entityName)) -> {Then} (atomverify(_entityName,'!',_startPositionOfFirstExplanationMark), {If character not found, _startPosition... will be 0} ((_startPositionOfFirstExplanationMark == 0) -> (_declarationPrefix = Individual) ; (_declarationPrefix = Attribute) )); {Else} {_entityName could be of form g1!offspring1 or select(g1,!,offspring)} (_declarationPrefix = Attribute) ), write(' declarationPrefix '),display(_declarationPrefix),nl, {Produce instanceOf code (possibly [])} translateListToTelosCodeList(in,_instanceOfList,_instanceOfCodeList), write(' instanceOfCodeList '),display(_instanceOfCodeList),nl, {Produce isA code (possibly [])} translateListToTelosCodeList(isA,_isAList,_isACodeList), write(' isACodeList '),display(_isACodeList),nl, {Produce one code list} append([_declarationPrefix,' ',_entityName,' '], _instanceOfCodeList,_List1), append(_isAList,[' ',with,' '],_List2), append(_SortAndParameterCodeList, [' ',end,' ',_entityName,' '], _List3), append(_List1,_List2,_ListHeadAndMiddle), append(_ListHeadAndMiddle,_List3,_TelosCodeList), {Change list to string} atomconcat(_TelosCodeList,_TelosCode). { *********** } {translateListToTelosCodeList(_listName,_list,_TelosCodeList):} {This is use to produce code lists for isA and instanceOf clauses. Given listName (isA or in) and list (e.g., [Student,Tutor]), TelosCodeList become a list with a correspoding Telos fragment (e.g., [' ',isA,' ',Student,',',Tutor,' ']). {spacing approximate} If list is nil, TelosCodeList will be nil.} translateListToTelosCodeList(_listName,[],[]). translateListToTelosCodeList(_listName,[_listHead|_listTail],_TelosCodeList):- _TelosCodeStart = [' ',_listName,' ',_listHead,' '], translateListRemainderToTelosCodeList(_listTail,_tailTelosCodeList), append(_TelosCodeStart,_tailTelosCodeList,_TelosCodeList). {translateListRemainderToTelosCodeList(_inputList,_TelosCodeList):- Helping predicate: If inputList is nil, TelosCodeList becomes nil; otherwise it becomes a list of the form [' ',',',' ',a,' ',' ',',',' ',b,' ']} {spacing approximate} translateListRemainderToTelosCodeList([],[]). translateListRemainderToTelosCodeList([_head|_tail],_TelosCodeList):- _TelosCodeStart = [' ',',',' ',_head,' '], translateListRemainderToTelosCodeList(_tail,_tailTelosCodeList), append(_TelosCodeStart,_tailTelosCodeList,_TelosCodeList). {********} translateSortAndParameterStructureToTelosCodeList (_sortValue,_parameterStructure,_TelosCodeList):- {Given a sort value and a parameter strucutre, generate a string with the body of the Telos declaration.} paramGetAllCategories(_parameterStructure,_categoryList), generateTelosFragmentForGivenCategories(_parameterStructure,_categoryList, _TelosParameterFragment), _sortDeclaration =[' ',sort,' ',sort1,' ',':',' ',_sortValue,' '], append(_sortDeclaration,_TelosParameterFragment,_TelosCodeList). generateTelosFragmentForGivenCategories(_parameterStructure,_categoryList, _TelosFragmentList):- generateTelosFragmentHelper(_parameterStructure,_categoryList, [],_TelosFragmentList). {generateTelosFragmentHelper(_parameterStructure,_categoryList, _TelosFragmentListIn,_TelosFragmentListOut):} {Given parameterStructure, categoryList and partially constructed TelosFragmentListIn, append TelosFragmentListIn to the Telos fragment for the category corresponding to the head of the category list. Then apply to the rest of the list.} generateTelosFragmentHelper(_parameterStructure,[], _TelosFragmentListIn,_TelosFragmentListIn). generateTelosFragmentHelper(_parameterStructure, [_categoryListHead|_categoryListTail], _TelosFragmentListIn,_TelosFragmentListOut):- write(' generateTelosFragmentHelper parameterStructure '), display(_parameterStructure),nl, write(' categoryListHead '),display(_categoryListHead),nl, write(' categoryListTail '),display(_categoryListTail),nl, write(' TelosFragmentListIn '),display(_TelosFragmentListIn),nl, generateTelosFragmentForGivenCategory(_parameterStructure, _categoryListHead,_TelosFragmentListHead), append(_TelosFragmentListIn,_TelosFragmentListHead, _TelosFragmentListIntermediate), generateTelosFragmentHelper(_parameterStructure,_categoryListTail, _TelosFragmentListIntermediate,_TelosFragmentListOut). generateTelosFragmentForGivenCategory(_parameterStructure,_category, _TelosFragmentList):- {Given parameterStructure and category name, produce a Telos code fragment list.} write(' generateTelosFragmentForGivenCategory parameterStructure '), display(_parameterStructure),nl, write(' category '),display(_category),nl, {Get AttributeAndValueList} paramGetAllAttributeNamesAndValuesForGivenCategory (_parameterStructure,_category,_attributeAndValueList), {Translate} write(' attributeAndValueList '),display(_attributeAndValueList),nl, translateAttributeAndValueListToTelosList(_attributeAndValueList, _attributeDeclarationList), write(' attributeDeclarationList '),display(_attributeDeclarationList),nl, {Combine if non-empty attribute list, else return nil} ((_attributeDeclarationList = nil) -> (_TelosFragmentList = nil) ; (append([' ',_category,' '], _attributeDeclarationList, _TelosFragmentList)) ) , write(' TelosFragmentList '),display(_TelosFragmentList),nl . translateAttributeAndValueListToTelosList(_attributeAndValueList, _attributeDeclarationList):- {Given attributeAndValueList, produce a list containing Telos attribute declarations} {From the parameterStructure documentation: nonEmptyAttributeAndValueList ::= [attributeAndValue] OR [attributeAndValue|nonEmptyAttributeAndValue] attributeAndValue ::= [attributeName,attributeValue] } write(' translateAttributeAndValueListToTelosList attributeAndValueList '), display(_attributeAndValueList),nl, write(' attributeDeclarationList '),display(_attributeDeclarationList),nl, translateAttributeAndValueListToTelosListHelper([],_attributeAndValueList, _attributeDeclarationList). {translateAttributeAndValueListToTelosListHelper(_attributeDeclarationListIn, _attributeAndValueList,_attributeDeclarationListOut):} {This is a helping predicate for translateAttributeAndValueListToTelosList. Append attributeDeclarationListIn with the declaration corresponding to the head of the attributeAndValueList; then apply to the remainder of the attributeAndValueList.} {Note: Do not put semicolon after final declaration} translateAttributeAndValueListToTelosListHelper( _attributeDeclarationListIn,[],_attributeDeclarationListIn). {Empty attributeAndValueList} translateAttributeAndValueListToTelosListHelper(_attributeDeclarationListIn, [[_attributeName,_attributeValue]], _attributeDeclarationListOut):- write(' translateAttributeAndValueListToTelosListHelper attributeDeclarationListIn '), display(_attributeDeclarationListIn),nl, write(' attributeName '),display(_attributeName),nl, write(' attributeValue '),display(_attributeValue),nl, {Do not put a semicolon between (possibly nil) _attributeDeclarationListIn and the single item in attributeAndValueList} append(_attributeDeclarationListIn, [' ',_attributeName,' ',':',' ',_attributeValue,' '], _attributeDeclarationListOut). translateAttributeAndValueListToTelosListHelper(_attributeDeclarationListIn, [_attributeAndValueListHead|_attributeAndValueListTail], _attributeDeclarationListOut):- (_attributeAndValueListTail \== nil), _attributeAndValueListHead =[_attributeName,_attributeValue], write(' translateAttributeAndValueListToTelosListHelper attributeDeclarationListIn '), display(_attributeDeclarationListIn),nl, write(' attributeAndValueListHead '),display(_attributeAndValueListHead),nl, write(' attributeAndValueListTail '),display(_attributeAndValueListTail),nl, write(' attributeName '),display(_attributeName),nl, write(' attributeValue '),display(_attributeValue),nl, {Do put semicolon after appending (possibly nil) attributeDeclarationListIn with the first item in attributeAndValueList which has at least 2 items} append(_attributeDeclarationListIn, [' ',_attributeName,' ',':',' ',_attributeValue,' ',';',' '], _attributeDeclarationListIntermediate), write(' attributeDeclarationListIntermediate '), display(_attributeDeclarationListIntermediate), {Process the remainder} translateAttributeAndValueListToTelosListHelper (_attributeDeclarationListIntermediate, _attributeAndValueListTail,_attributeDeclarationListOut). { ******************** } { testSortAndParameter(_TelosCode):- _parameterStructure = [[infoItemParam, [[infoItem1, value1]]], [derivationFnParam, [[df1, f], [df2, g]]]], _sort = Accuracy, translateSortAndParameterStructureToTelosCodeList(_sort, _parameterStructure,_TelosCode). } { ******************** } { getAttributeValuesOfGivenCategoryFromAttrDeclList(_attrdecllist,_category,_ans) : _ans contains all the attribute values from each attrdecl, of the given category, in _attrdecllist For each in do From which is attrdecl(,) Get . If _category is a member of then Get from , For each in , If is non-null, append to _ans where is property(,,,) (It is possible that _category will appear in more than one attrcategorylist, so all are examined.) } getAttributeValuesOfGivenCategoryFromAttrDeclList([],_category,[]). getAttributeValuesOfGivenCategoryFromAttrDeclList([_attrdecl|_attrdecllist], _category,_ans) :- {write(' getAttributeValuesOfGivenCategoryFromAttrDeclList attrdecl '),nl, } {display(_attrdecl),nl, } {write(' attrdecllist '), display(_attrdecllist),nl, } {nl,write(_category),nl,} arg(1,_attrdecl,_attrcategorylist), {write(' attrcategorylist '), display(_attrcategorylist),nl, } ( {If} (member(_category,_attrcategorylist)) -> {Then} ( arg(2,_attrdecl,_propertylist), {write(' propertylist '), display(_propertylist),nl, } selectAttributeValues(_propertylist,_ansAttrDecl) { , } { write(' ansAttrDecl '),display(_ansAttrDecl),nl } ) ; {Else} ( _ansAttrDecl = [] { , write(' else '),nl } )), getAttributeValuesOfGivenCategoryFromAttrDeclList(_attrdecllist,_category, _ansAttrDeclList), { write(' need to also get attribute names? '),nl, } append(_ansAttrDecl,_ansAttrDeclList,_ans). { ******************** } {find_dec currently not used.} find_dec([_H|_T],_match,_attrdec) :- arg(1,_H,_categorylist), member(_match,_categorylist), _attrdec = _H. find_dec([_|_T],_match,_attrdec) :- find_dec(_T,_match,_attrdec). { ***************************** } { ***************************************** } {* Code specific to ResourceAssignmentGAM *} {* The predicate getInstancesForResource queries the user to supply a * class name which is supposed to be an instance of the classes Agent, * Medium, and VerificationTime, respectively. For each class name the * user enters, a check is made to checkDef to see if such a class, being * an instance of the proper superclass (e.g., John is IN Agent) exists in the * KB. If such a class does not exist, a definition for the class is * generated using procInstance } getInstancesForResource(_Agent,_Medium,_VTime) :- write('Enter instance of Agent: '), readln(_Agent), checkDef(_Agent,Agent), write('Enter instance of Medium: '), readln(_Medium), checkDef(_Medium,Medium), write('Enter instance of VerificationTime: '), readln(_VTime), checkDef(_VTime,VerificationTime). { The predicate checkDef takes an entity name (e.g., John) and a * containingClass name (e.g., Agent) and checks to see if * an entity IN containingClass exists. If there * is, nothing else is done. If not, a Telos definition for the entity is * generated, and added to the file newnodes.sml. checkDef uses the built * in query get_object to get the Telos definition of _Entity, and then * uses getInstances to compute the list of containingClasses of _Entity. The * predicate procInstance is then called to take the appropriate action. } checkDef(_Entity,_ContainingClass) :- nl,write('checkDef('),display(_Entity),write(', '), display(_ContainingClass), write(')'), getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[get_object([_Entity/objname])]), ipcanswer(_sender,_completion,_return)), {write(' ipcanswer: _return = '),display(_return),} getInstances(_return,_ans), {write(' getInstances: _ans = '),display(_ans),} procInstance(_Entity,_ContainingClass,_ans). { Case: _Entity does exist as IN _ContainingClass --> do nothing } procInstance(_Entity,_ContainingClass,_ans) :- member(_ContainingClass,_ans),!. { Case: generate definition of _Entity and append to newnodes.sml } procInstance(_Entity,_ContainingClass,_ans) :- _L = [Individual,' ',_Entity,' ',in,' ',_ContainingClass,' ',with,' ',end,' ', _Entity], {nl,write(' procInstance: _L ='), display(_L),} atomconcat(_L,_W), appendToFile(_W), name(_W,_U1), {write(' now telling...'),nl,} getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,TELL,[_U1]), ipcanswer(_X,_Y,_Z)). {* The predicate getInstances processes the SMLfragment to get the * list of containingClasses of the given entity. It works as follows: } getInstances([],[]) :- write(' getInstances([],[])'), !. getInstances(no,[]) :- write(' getInstances(no,[])'), !. getInstances(_fragment,_List) :- {write(' getInstances('),display(_fragment),write(', '),display(_List),write(')'),} arg(3,_fragment,_in), arg(1,_in,_L), getNames(_L,_List). {* getNames extracts the names of the containingClasses from the _in construct } getNames([],[]) :- !. getNames([_H|_T],_List) :- arg(1,_H,_next), getNames(_T,_List1), append([_next],_List1,_List). { ***************************** } { IsA routines} {these 2 do not work} getsubclasses(_class,_subclassList) :- getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[oursubclassquery([_class/whatclass])]), ipcanswer(_sender,_completion,_return)), {write(' completion '),display(_completion),nl, write(' return '),display(_return),nl,} getInstances(_return,_ans), procInstance(_Entity,_ContainingClass,_ans). getsuperclasses(_class,_superclassList) :- getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[oursuperclassquery([_class/whatclass])]), ipcanswer(_sender,_completion,_return)), {write(' completion '),display(_completion),nl, write(' return '),display(_return),nl,} getInstances(_return,_ans), procInstance(_Entity,_ContainingClass,_ans). { ***************************** } {* The predicate findParameter takes the name of a node as input * (e.g., VERIFICATIONSGMeetingReportsAgentMediumVerificationTime4) and returns * the parameter value for that class (e.g., MeetingReports). It uses the * generic query class mysortandparameterofnodequery to extract the * proper SMLfragment, and then uses the predicate getResParam to extract * the actual value } findParameter(_node,_ans) :- getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK, [mysortandparameterofnodequery([_node/whatNode])]), ipcanswer(_sender,_completion,_return)), getResParam(_return,_ans). {* The predicate getResParam takes an SMLfragment and extracts the parameter * value from it. In the case of the ResourceAssignmentGAM, the class in * question will have three additional attributes (Agent, Medium, and * VerificationTime) under the attribute category params. Thus, getResParam * extracts these four and looks for the one which is not any of Agent, * Medium, or VerificationTime. } getResParam(_X,_ans) :- _X = [_SMLfragment], arg(5,_SMLfragment,_with), arg(1,_with,_attrdecList), findparams(_attrdecList,_attrdec), { extract the params attributes } arg(2,_attrdec,_propertyList), getParam(_propertyList,_ans). {get the proper one } findparams([],_X) :- !,fail. findparams([_H|_T],_attrdec) :- ( arg(1,_H,[params]), _attrdec = _H ) ; findparams(_T,_attrdec). {* getParam searches the list of parameter values one by one, looking * for the one which is NOT Agent,Medium, or VerificationTime. It then * treats the first such one it finds as the proper parameter value * e.g., MeetingReports } getParam([],_X) :- !,fail. getParam([_H|_T],_ans) :- ( not(arg(2,_H,Agent)), not(arg(2,_H,Medium)), not(arg(2,_H,VerificationTime)), arg(2,_H,_ans) ) ; getParam(_T,_ans). { ***************************** } member(_X,[_X|_]) :- !. member(_X,[_|_Y]) :- member(_X,_Y). length([],0). length([_H|_T],_N) :- length(_T,_W), _N is _W + 1 . { cancel/0 disconnects from ConceptBase. Use before exiting Prolog.} cancel :- disconnectCBserver$IpcChannelAccess. { ******************************************************************* } { ******************************************************************* } { Table routines: We use the parameterStructure code in a very simple way. Each named table is represented as a parameter structure. Each row of a table is treated as a category. Each column entry of a row is treated as an attribute of a category. Table structure values need to be set only once (per programme invocation). To be globally accessibly, they can be asserted as shown below. (mytables is a predicate: first argument is table name; second argument is table (a parameterStructure)). We use getTable/4 to retrieve values. } { ******************************************************************* } {Sample setting of value:} { assert( mytables(table1, [[row1, [[col1, valueT1R1C1],[col2, valueT1R1C2] ]], [row2, [[col1, valueT1R2C1],[col2, valueT1R2C2] ]] ] ) ). assert( mytables(table2, [[row1, [[col1, valueT2R1C1],[col2, valueT2R1C2] ]], [row2, [[col1, valueT2R2C1],[col2, valueT2R2C2] ]] ] ) ). } {Sample call:} { getTable(table1,row2,col1,_theValue). } {Memo: For future, might have extra entries for titles of rows and columns?} getTable(_tableName,_row,_column,_value) :- nl,write('getTable (tableName: '),display(_tableName), write(', row: '),display(_row), write(', column: '), display(_column), write(') '), {Given a particular row and column of a particular named table, value is the corresponding entry.} mytables(_tableName,_tableStructure), {Given tableName, get tableStructure} paramGetSingleAttributeValueForGivenCategoryAndAttribute(_tableStructure, _row,_column,_value), display(_value), write(' getTable...') . { ******************************************************************* } { **************************************************************************** PARAMETER STRUCTURE ROUTINES Instead of having the parameter of a node as a simple atom, it is represented as a parameterStructure. This allows us to handle 1 or more categories per parameter, 1 or more attributes per category; and also allows us to associate an attribute with each attribute value. **************************************************************************** } { Documentation: ************** Definitions: By category, we mean a category of an individual (which is an attribute of the corresponding class). By attribute, we mean an attribute of an individual. By attribute value, we mean an attribute value of an individual. Notation: | is the Prolog list constructor (where [a| [] ] is [a] and [a| [b] ] is [a,b] Meta-notation: OR separates syntactic alternatives. Structures: A parameterStructure is of the form [[categoryName, [[attributeName, attributeValue], [attributeName, attributeValue], ... ], [categoryName, [[attributeName, attributeValue], [attributeName, attributeValue], ... ], ... ] E.g.: [[infoItemParam, [[infoItem1, value1]]], [derivationFnParam, [[df1, f], [df2, g]]]] Grammar: parameterStructure ::= [] OR [categoryComponent|parameterStructure] categoryComponent ::= [categoryName, nonEmptyAttributeAndValueList] nonEmptyAttributeAndValueList ::= [attributeAndValue] OR [attributeAndValue|nonEmptyAttributeAndValue] attributeAndValue ::= [attributeName,attributeValue] Assumptions: Our code assumes that a parameterStructure obeys the following: 1. A categoryName is unique within a parameterStructure. 2. An attributeName is unique within a categoryComponent. 3. An attributeValue cannot have an anonymous attributeName. (It would not necessarily be hard to revise the above. For example, a search that stops as soon as a category name is matched could be replaced by a search which finds all matching category names.) } { Notes: When editing current Prolog code, selectively change _param (etc.) to more descriptive names, e.g., _parameterStructure, or _derivationFnParam. Some of the predicates which set a return variable to [] could instead fail. May also need to unpack from and pack to ConceptBase-Telos. See also AttrValueList routine(s): some simplifications may be possible. We currently do not allow un-named attribute values. } { Predicates: *********** paramGet...(...) are predicates for retrieving attribute values (and possibly attribute and category names) from a parameterStructure. } { paramGetSingleAttributeValueForGivenCategoryAndAttribute (_parameterStructure,_category,_attribute,_attributeValue) : } { Given a _parameterStructure, a _category, and an _attribute within that _category, _attributeValue will be the value corresponding to the _attribute, [] otherwise. } paramGetSingleAttributeValueForGivenCategoryAndAttribute([],_category, _attribute,[]). paramGetSingleAttributeValueForGivenCategoryAndAttribute([_categoryComponent|_parameterStructureTail], _category,_attribute,_attributeValue) :- _categoryComponent = [_categoryName, _nonEmptyAttributeAndValueList], ( {If} (_category = _categoryName) -> {Then} (paramGetSingleAttributeValueForGivenAttributeFromAttributeAndValueList (_nonEmptyAttributeAndValueList,_attribute,_attributeValue)) ; {Else} (paramGetSingleAttributeValueForGivenCategoryAndAttribute (_parameterStructureTail,_category,_attribute,_attributeValue))). { paramGetAllAttributeValuesForGivenCategory (_parameterStructure,_category,_attributeValueList) : } { Given a _parameterStructure, and a _category, _attributeValueList will be a list of all attribute values in that category, [] if there is no such _category in the _parameterStructure. } paramGetAllAttributeValuesForGivenCategory ([],_category,[]). paramGetAllAttributeValuesForGivenCategory ([_categoryComponent|_parameterStructureTail],_category, _attributeValueList) :- { write(' categoryComponent '),display(_categoryComponent),nl, } { write(' category '),display(_category),nl, } _categoryComponent = [_categoryName, _nonEmptyAttributeAndValueList], ( {If} (_category = _categoryName) -> {Then} ({write(' then '),nl,} paramGetAllAttributeValuesFromAttributeAndValueList (_nonEmptyAttributeAndValueList,_attributeValueList)) ; {Else} (paramGetAllAttributeValuesForGivenCategory (_parameterStructureTail,_category,_attributeValueList))). { paramGetAllAttributeNamesAndValuesForGivenCategory (_parameterStructure,_category,_AttributeAndValueList) :} { Given a _parameterStructure, and a _category, _attributeNameAndValueList will be a list of all [attribute name, attribute value] lists in that category, [] if there is no such _category in the _parameterStructure. } paramGetAllAttributeNamesAndValuesForGivenCategory ([],_category,[]). paramGetAllAttributeNamesAndValuesForGivenCategory ([_categoryComponent|_parameterStructureTail],_category, _AttributeAndValueList) :- { write(' categoryComponent '),display(_categoryComponent),nl, } { write(' category '),display(_category),nl, } _categoryComponent = [_categoryName, _nonEmptyAttributeAndValueList], ( {If} (_category = _categoryName) -> {Then} (_AttributeAndValueList = _nonEmptyAttributeAndValueList) ; {Else} (paramGetAllAttributeNamesAndValuesForGivenCategory (_parameterStructureTail,_category,_AttributeAndValueList))). { paramGetSingleAttributeValueForGivenCategory(_parameterStructure, _category,_attributeValue) : Given a _parameterStructure and a _category, if the _category has exactly one attribute and one attribute value, _attributeValue will be that value, else nil.} paramGetSingleAttributeValueForGivenCategory(_parameterStructure, _category,_attributeValue) :- paramGetAllAttributeValuesForGivenCategory (_parameterStructure,_category,_attributeValueList), ( {If} (_attributeValueList = [_attributeValue]) -> {Then} (true {Succeed if _attributeValueList has only one component}) ; {Else} (_attributeValue = [])). { paramGetSingleAttributeValueForSingleCategory (_parameterStructure,_attributeValue) :} { Given a _parameterStructure, if it has exactly one category, with one attribute and one attribute value, _attributeValue will be that value; else [].} { May be called very frequently.} paramGetSingleAttributeValueForSingleCategory (_parameterStructure,_attributeValue) :- ( {If} (_parameterStructure = [[_aCategoryName, [[_anAttributeName,_attributeValue]]]]) -> {Then} (true {Succeed if _parameterStructure has exactly one category, with one attribute and one attribute value}); {Else} (_attributeValue = [])). {paramGetAllAttributeValuesForSingleCategory (_parameterStructure,_attributeValueList) :} { Given a _parameterStructure, if it has exactly one category, _attributeValueList will be a list of all the attribute values in that category else [].} { May be called frequently.} paramGetAllAttributeValuesForSingleCategory (_parameterStructure,_attributeValueList) :- ({If} (_parameterStructure = [[_aCategoryName,_nonEmptyAttributeAndValueList]]) -> {Then} { _parameterStructure has exactly one category.} ( paramGetAllAttributeValuesFromAttributeAndValueList (_nonEmptyAttributeAndValueList,_attributeValueList)); {Else} (_attributeValueList = [])). {paramGetAllCategories(_parameterStructure,_categoryList):} {Given a parameterStructure, set categoryList to a list of all categories in the structure.} paramGetAllCategories([],[]). paramGetAllCategories([_categoryComponent|_parameterStructureTail], _categoryList):- _categoryComponent = [_categoryName, _nonEmptyAttributeAndValueList], paramGetAllCategories(_parameterStructureTail,_categoryListTail), _categoryList = [_categoryName|_categoryListTail]. { Helping predicates: ******************* } { paramGetSingleAttributeValueForGivenAttributeFromAttributeAndValueList (_attributeAndValueList,_attribute,_attributeValue) : } { Given a _attributeAndValueList, and an _attribute, _attributeValue will be the value corresponding to the _attribute, [] otherwise. } paramGetSingleAttributeValueForGivenAttributeFromAttributeAndValueList ([],_attribute,[]). paramGetSingleAttributeValueForGivenAttributeFromAttributeAndValueList ([_attributeAndValue|_attributeAndValueListTail],_attribute, _attributeValue) :- ( {If} (_attributeAndValue = [_attribute,_attributeValue]) -> {Then} ( true {Match. Result is _attributeValue} ) ; {Else} (paramGetSingleAttributeValueForGivenAttributeFromAttributeAndValueList (_attributeAndValueListTail,_attribute,_attributeValue))). { paramGetAllAttributeValuesFromAttributeAndValueList (_attributeAndValueList,_attributeValueList) : } { Given an _attributeAndValueList, _attributeValueList will be a list of all attribute values. If an attribute value is of the form #1234.5678 , translate it to proposition1234point5678number . } paramGetAllAttributeValuesFromAttributeAndValueList ([],[]). paramGetAllAttributeValuesFromAttributeAndValueList ([_attributeAndValue|_attributeAndValueListTail], _attributeValueList) :- { write(' aav '),nl, } { display(_attributeAndValue),nl, } _attributeAndValue = [_attribute,_attributeValue], { write(' a '),nl, } { display(_attribute),nl, } { write(' av '),nl, } { display(_attributeValue),nl, } { translateNumberSignAndPeriod***ToClassParameter?***IfNecessary(_attributeValue, _possiblyTranslatedAttributeValue), write(' ptav '),nl, { display(_possiblyTranslatedAttributeValue),nl, } } paramGetAllAttributeValuesFromAttributeAndValueList (_attributeAndValueListTail, _attributeValueListOfAttributeAndValueListTail), { write(' avlofaavlt '),nl, } { display(_attributeValueListOfAttributeAndValueListTail),nl, } _attributeValueList = [_attributeValue| { possiblyTranslatedAttributeValue bar } _attributeValueListOfAttributeAndValueListTail] { , } { write(' avl '),nl, } { display(_attributeValueList),nl } . { ******************************************************************* } { Attribute retrieval utility } getSMLFragmentOfObject(_entity,_SMLFragment):- getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[get_object([_entity/objname])]), ipcanswer(_sender,_completion,_SMLFragment)). {getAttributeValues(_entity,_category,_valueList): Given an entity, and a category of the entity, return in valueList a list of all the attribute values of the given category.} {entity can be of (at least) the following forms: Person select(Person,!,name) } getAttributeValues(_entity,_category,_valueList):- {nl,write(' getAttributeValues ('), display(_entity), write(', '), display(_category),write(')'),} {write(' vlaueList='),display(_valueList), write(_valueList),} getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[get_object([_entity/objname])]), ipcanswer(_sender,_completion,_SMLFragment)), {nl,display(_SMLFragment),nl,} getAttrDeclListFromSMLFragment(_SMLFragment,_attrdecllist), {write(' attrdecllist '),display(_attrdecllist), } getAttributeValuesOfGivenCategoryFromAttrDeclList(_attrdecllist, _category,_valueList) {write(' ---> '),display(_valueList),} {((_valueList==nil -> (nl,write('NIL proceed?'), readln(_)));true),}{write(' getAttributeValues...'),nl}. {**********************************************************************} {* L A B E L L I N G P R O C E D U R E *} {**********************************************************************} {**********************************************************************} {* testing routine *} {**********************************************************************} {test :- write('object to refine --- leafAddition (a), leafLabelChange (l), linkTypeChange (t), linkLabelChange (li), noMore (n):'), readln(_refineType), ( (_refineType == n -> write('All Done! Good Day!'),nl,nl, halt);} {**********************************************************************} {* TODO: parameters for query-class; *} {* Menu for Cases below *} {* Invocation of Label: (whenever there is a potential change *} {* in goal label value) *} {* *} {* % Cases: *} {* % 1) add leaf (either explicit or implicit (-) *} {* % 2) revise leaf label value *} {* % 3) link type; *} {* % 4) link label value: *} {* % *} {* % 1. Allow addition or revision according to each case above *} {* % 2. For cases 1) and 2) and 3) *} {* % Propagate (p, currentGoal) *} {* % For case 4), do additionally *} {* % Propagate (currentGoal.src, currentGoal.dst) *} {* Treat link as a goal to refine *} {* *} {* AttrId (phil, friends, jane, now) *} {* returns "favoriteGirlFriend" attribute link *} {**********************************************************************} integrate(implicitCorrelate, _parent, _linkType, _leaf) :- nl,nl,write('integrate(implicitCorrelate, parent: '),display(_parent), write(', linkType: '), display(_linkType), write(', leaf: '), display(_leaf), write(')'), bookkeepingLeaf(_leaf, _parent, _linkType), nl, write('bookkeepingLeaf...'), askAny(_leaf, parent, _parentSet), label(_parentSet,_leaf),write(' labelling all done'). integrate(m, _parent, _method, _methodClass,_leafSet):- nl,nl,nl,write(' I N T E G R A T E '),nl, nl,write('integrate(m, parent: '), display(_parent), write(', method: '), display(_method), write(', methodClass: '), display(_methodClass), write(', leafSet: '), display(_leafSet), write(') '), {write('proceed?'),}{readln(_),} nl, write('bookkeepingLeaves:'), bookkeepingLeaves(_leafSet, _parent, _method,_methodClass), nl, write('bookkeepingLeaves...'), pickOne(_leafSet, _g), write('addLeaf...'), askParentSet(_g, _parentSet), label(_parentSet,_g),write(' labelling all done'). integrate(l, _g, _label):- (_label \== nil -> (retellLabel(_g, _label), askParentSet(_g, _parentSet), label(_parentSet,_g) ) );true. integrate(t, _link, _linkType) :- (_linkType \== nil -> ( retellLinkType(_link, _linkType), askSource(_link, _p1), _p1 = [_p|_], askDestination(_link, _destination1), _destination1 = [_destination|_], propagate(_p, _destination) ) );true. integrate(ll, _link, _label) :- (_label \== nil -> ( retellLabel(_l, _label), {* link as offspring *} askParentSet(_l, _parentSet), label(_parentSet,_l), {* link as connnecting a parent and an offspring*} askSource(_l, _source), askDestination(_l, _destination), Propagate(_source, _destination) ));true. {*****************************************************************************} {* addition of a leaf *} {* 1) 1 offspring for the first time with a method, m *} {* 2) multiple offspring for a decomp. for the first time with m *} {* 3) a conjunct(s) to existing decomposition *} {* 4) a disjunct: 1 m with 1 offspring --- current assumption *} {* *} {* application of a method (m) to a goal (g) with offspring (sg): *} {*****************************************************************************} {addLeaf(_goal):- write('Enter parent:'), readln(_parent), write('Enter method: '), readln(_method), write('Enter method class: '), readln(_methodClass), readLeafSet(_leafSet), write('*Entering bookkeepingLeaves*'), bookkeepingLeaves(_leafSet, _parent, _method,_methodClass), write('*All done with bookkeepingLeaves*'), pickOne(_leafSet, _goal), write('addLeaf...').} {readLeafSet(_leafSet):- write('Enter next leaf (leaf object or noMore(n)):'), readln(_leaf), ( ( _leaf == n -> _leafSet = []); ( readLeafSet(_leafSetTail), append([_leaf], _leafSetTail, _leafSet) ) ), write('exiting readLeafSet'). } bookkeepingLeaves([], _, _,_). bookkeepingLeaves([_leafSetHead|_leafSetTail], _parent, _method,_methodClass):- nl,write('bookkeepingLeaves(['),display(_leafSetHead), write('|'), display(_leafSetTail), write('], '), display(_parent), write(', '), display(_method), write(', '), display(_methodClass), write(') '),nl, nl,write(' take care of the offspring :'), askLabel(_leafSetHead, _leafSetHeadLabel), ((_leafSetHeadLabel \== nil -> true); (defaultLeafLabel(_methodClass,_defaultLabel), ((_defaultLabel == nil -> true); tellAny(_leafSetHead, label, [_defaultLabel])))), {else} {****************************************} {* NOT NEEDED (other than poss warning) *} {* TODO: cycle checking *} {* worst --- n*2 (when linear) *} {* currentOffLeaf-g-..-currentLeaf*} {* if cycle, error message, stop *} {****************************************} {* maintain backward pointer from current leaf to parent *} askParentSet(_leafSetHead, _headP), union(_headP, [_parent], _leafParentSet1), removeRedundancy(_leafParentSet1, _leafParentSet), ((_leafParentSet == nil -> true); (member(_parent, _headP) -> true); tellParent(_leafSetHead, _leafParentSet)), nl,write(' take care of the parent proposition :'), askOffspringSet(_parent, _offspringSet), {write(' offspringSet returned='),display(_offspringSet),} union(_offspringSet, [_leafSetHead], _parentOffspringSet1), removeRedundancy(_parentOffspringSet1, _parentOffspringSet), {write(' offspring to tell='),display(_parentOffspringSet), } ((_parentOffspringSet == nil -> true); (member(_leafSetHead, _offspringSet) -> true); tellOffspring(_parent, _parentOffspringSet)), askJustifyingMethodSet(_parent, _justifyingMethodSet), union(_justifyingMethodSet, [_method], _parentJustifyingMethodSet1), removeRedundancy(_parentJustifyingMethodSet1, _parentJustifyingMethodSet2), ((_parentJustifyingMethodSet2 == nil -> true); (member(_method, _justifyingMethodSet) -> true); tellJustifyingMethod(_parent, _parentJustifyingMethodSet2)), nl,write(' take care of the method :'), askMethodParentSet(_method, _mParentSet), union(_mParentSet, [_parent], _mParentSet1), removeRedundancy(_mParentSet1, _mParentSet2), ((_mParentSet2 == nil -> true); (member(_parent, _mParentSet) -> true); tellMethodParent(_method, _methodClass, _mParentSet2)), askMethodOffspringSet(_method, _methodOffspringSet1), {write('calling union with: '), display(_methodOffspringSet1),display([_leafSetHead]),} union(_methodOffspringSet1, [_leafSetHead], _methodOffspringSet), removeRedundancy(_methodOffspringSet, _methodOffspringSet2), ((_methodOffspringSet2 == nil -> true); (member(_leafSetHead, _methodOffspringSet1) -> true); tellMethodOffspring(_method, _methodClass,_methodOffspringSet2)), nl,write(' take care of the link :'), askLink(_parent, _leafSetHead, _link), ((_parent == nil -> true); tellSource(_link, _parent)), ((_leafSetHead == nil -> true); tellDestination(_link, _leafSetHead)), ((_method == nil -> true); tellMSrcDst(_link, _method)), defaultIndividualEffect(_link,_methodClass,_dIE), retellIndividualEffect(_link, _dIE), defaultLinkLabel(_linkLabel), retellLabel(_link, _linkLabel), {nl,write('NOW ......determineLinkType:methodClass='),display(_methodClass),nl,} determineLinkType(_parent,_leafSetHead,_methodClass,_linkType1), nl,write('LINK TYPE = '), display(_linkType1),nl, ((_linkType1 == nil -> (nl,nl, write(' >>>NOT appropriate method application: neutral method<<< '), nl,nl,nl,write (' link type temporarily assigned u n d'),nl, nl, _linkType = und)); ((_linkType = _linkType1), ((_linkType \== negSub -> true); (nl,nl,nl, write(' >>> Current method induces negative effect <<< '),nl,nl)))), retellLinkType(_link, _linkType), bookkeepingLeaves(_leafSetTail, _parent, _method, _methodClass). {************************************} determineLinkType(_p, _l, DerivedInfoOrAccGDM, OR) :-write('DIOR'). determineLinkType(_p, _l, AttributeClassSupersetGDM, sup) :-write('sup'). determineLinkType(_p, _l, SuperclassGDM, sup) :-write('Sup'). determineLinkType(_p, _l, InexhaustiveSubclassGDM, sub) :-write('Inx'). determineLinkType(_p, _l, VerificationGSM, sub) :- write('Ver'). determineLinkType(_p, _l, ResourceAssignmentGSM, sup) :- write('RA'). determineLinkType(_p, _l, StepwiseSpecializationGRM, eql) :- write('Step'). determineLinkType(_parent,_offspring,_methodClass,_linkType) :- {(\+ member(_methodClass, [DerivedInfoOrAccGDM, SuperclassGDM, InexhaustiveSubclassGDM, VerificationGSM, StepwiseSpecializationGRM])),} nl,write(' determineLinkType (parent: '),display(_parent), write(', offspring: '), display(_offspring), write(', methodClass: '), display(_methodClass), write(', linkType: '), display(_linkType), write(')'),nl, askIsA(_methodClass, 'GDM',_answer1), ((_answer1 == yes -> defaultGDMLinkType(_methodClass,_linkType)); (askIsA(_methodClass, 'GAM', _ans), ((_ans == yes -> defaultGAMLinkType(_linkType); ( nl,write(' EXPLICIT CORRELATION RULE '),nl, ExplicitCorrelationRule(_parent,_offspring,_methodClass,_linkType)), display(_linkType),nl, write(' determineLinkType...proceed?'){,readln(_)} )))). {************************************} bookkeepingLeaf(_leaf, _parent, _linkType) :- nl,write(' take care of the offspring :'), {* maintain backward pointer from current leaf to parent *} askAny(_leaf, parent, _headP), union(_headP, [_parent], _leafParentSet1), removeRedundancy(_leafParentSet1, _leafParentSet), ((_leafParentSet == nil -> true); ((member(_parent, _headP) -> true); tellAny(_leaf, parent, _leafParentSet))), {* take care of the parent goal *} write(' take care of the parent goal :'), askAny(_parent, offspring, _offspringSet), union(_offspringSet, [_leaf], _parentOffspringSet1), removeRedundancy(_parentOffspringSet1, _parentOffspringSet), ((_parentOffspringSet == nil -> true); ((member(_leaf, _offspringSet) -> true); tellAny(_parent, offspring, _parentOffspringSet))), {* take care of the link *} write(' take care of the link :'), askLink(_parent, _leaf, _link), (_parent \== nil -> tellSource(_link, _parent));true, (_leaf \== nil -> tellDestination(_link, _leaf));true, {defaultIndividualEffect(_link,_methodClass,_dIE),} retellIndividualEffect(_link, U), defaultLinkLabel(_linkLabel), retellLabel(_link, _linkLabel), retellLinkType(_link, _linkType). {*************************************} {* Preferably in TELOS: *} {* global default (initial) set-up: ***********************************} {* *} {* TODO: offer menu to change the default: *} {***********************************************************************} {defaultGDMLinkType(AttributeClassSupersetGDM,sup).} defaultGDMLinkType(_methodClass,_type):- _type = AND. defaultGSMLinkType(_type):- (_type = sub). defaultGAMLinkType(_type):- (_type = eql). defaultLinkLabel(_label):- (_label = S). {defaultLeafLabel(VitalFewGAM,S).} defaultLeafLabel(_methodClass,_label) :- askIsA(_methodClass, GAM, _answer), ( ((_answer == yes) -> (_label = S)); (_label = U) ), display(_label),write(' defaultLeafLabel... '). defaultIndividualEffect(_link,_methodClass,_dIE) :- askIsA(_methodClass, GAM, _answer), ( ((_answer == yes) -> (_dIE = S)); (askIsA(_methodClass,GSM,_ans), (((_ans == yes) -> (_dIE = U));(_dIE = U))) ), {(((_ans == yes) -> (_dIE = Upos));(_dIE = U))) ),} display(_dIE),write(' defaultLeafLabel... '). { CorrelationRules(_offspring,_parent,_linkType):- nl,nl,write('Correlation Rules: parent='),display(_parent),write(' offspring='),display(_offspring),nl, write(' Checking explicit link type first........'),nl, write(' Checking implicit negative links........'),nl, _linkType = nil, write(' link type='),display(_linkType),nl,nl. } {*****************************************************************************} {* p: the current goal whose label may need to be changed *} {* triggeringOffspring: one of the offspring of p *} {* which caused the invocation of Prop. *} {* *} {* % % If not-cycle-node (has already been checked) then *} {* % % determine new label of current goal (i.e., p.label) *} {* % % by invoking CompositeEffect *} {* % % if new label is identical with the old label *} {* % % then return -- DONE, no more upward propagation is needed *} {* % % else *} {* % % for each upperP in p.parent *} {* % % Propagate (upperP, p) *} {* % % if p instanceOf Goal!offspring *} {* % % then Propagate(p.src, p.dst) *} {* *} {* the presence of >1 method implies non-conjunction *} {* otherwise, conjunction *} {* TODO: add a flag, round = odd/even *} {* starting point sets the flag *} {*****************************************************************************} propagate (_p, _triggeringOffspring) :- nl,write(' propagate (parent: '),display(_p),write(', offspring: '), display(_triggeringOffspring), write(') '),nl, ((notInCycle (_p) -> ( askAny(_p, label, _pLabel1), {Apr6} {nl,nl,write('pLabel1='),display(_pLabel1),nl,nl,nl,} ((atomic(_pLabel1) -> _pLabel = _pLabel1);(_pLabel1 = [_pLabel|_])), compositeEffect (_p, _triggeringOffspring, _pLabelNew), nl,write(' pLabel1='),display(_pLabel1), write(' pLabel='),display(_pLabel), write(' pLabelNew='),display(_pLabelNew),nl, ( (_pLabelNew == _pLabel -> nl, write('Optimization: no further propagation is needed'), nl); ( ((_pLabelNew == nil -> true); retellLabel (_p, _pLabelNew)), askParentSet(_p, _parentSet), {nl,write(' moving up with parentSet='),display(_parentSet), write(' p='),display(_p),nl,} label(_parentSet,_p), write(' askingInstanceOfLink: p='), display(_p), write(' _answer='),display(_answer), askInstanceOfLink(_p,_answer), ((_answer == no -> true); (nl,write('Link label change necessitates propagation along thecurrent link'),nl, askSource(_p, _pSource1), _pSource1 = [_pSource|_], askDestination(_p, _pDestination1), _pDestination1 = [_pDestination|_], propagate (_pSource, _pDestination) ))) ) ));true), {* if-not-cycle-node *} nl,nl,write(' propagate...'),nl,nl. notInCycle(_goal). {* needs to be extended for future *} label([],_). label([_parentSetH | _parentSetT],_offspring) :- nl,nl, write('label(['), display(_parentSetH), write('|'), display(_parentSetT), write('], '), display(_offspring), write(') '), nl, {pickOne (_parentSet, _upperP),} propagate (_parentSetH, _offspring), {setDiff(_parentSet, _upperP, _parentSet2),} label(_parentSetT,_offspring), write(' label...'). setDiff([],_,[]). setDiff([_H|_T], _H, _T). setDiff([_H|_T], _second, _diff) :- setDiff(_T, _second, _diff1), append([_H], _diff1, _diff). {************************************************************************} {* combine individual effects of propagated labels from two links *} {* to obtain the composite effect on the destination label, using *} {* % determine IndividualEffect of p!triggeringOffspring and *} {* triggeringOffspring *} {* % if new effect = old effect --- local optimization *} {* % then return -- DONE, no change in goal label *} {* % else determine composite effect on currentGoal *} {************************************************************************} compositeEffect (_p, _triggeringOffspring, _effect):- nl,nl,write(' compositeEffect (parent: '), display(_p), write(', offspring: '),display(_triggeringOffspring), write(') '),nl, askLink(_p, _triggeringOffspring, _l), askIndividualEffect(_l, _lIndividualEffect1), ((atomic(_lIndividualEffect1) -> _lIndividualEffect = _lIndividualEffect1); (_lIndividualEffect1 = [_lIndividualEffect|_])), individualEffect (_l, _p, _triggeringOffspring, _effect1), (( _effect1 == _lIndividualEffect -> (_effect = _effect1, nl, write('Optimization: no change in individual effect'), nl, write(' --> no composition is needed'),nl)); (retellIndividualEffect (_l, _effect1), askOffspringSet(_p, _offspringSet1), nl,nl,write(' calling setDiff with set1 ='),display(_offspringSet1),write(' and triggeringOffspring= '),display(_triggeringOffspring),nl,nl, setDiff(_offspringSet1, _triggeringOffspring, _offspringSet), write(' Calling cumulativeCompositeEffectTable: '), {_effect1 = _effect, Apr15} cumulativeCompositeEffectTable(_effect1, _p, _offspringSet, _effect))), write(_effect),write(' compositeEffect....'). cumulativeCompositeEffectTable(_cumulative, _p, _offspringSet, _effect):- nl,write(' cumulativeCompositeEffectTable (cumulative: '), display(_cumulative), write(', parent: '),display(_p), write(', offspringSet: '),display(_offspringSet), write(', effect: '),display(_effect),write(')'),nl, ((_offspringSet == [] -> _effect = _cumulative); (pickOne (_offspringSet, _nextOffspring), askLink(_p, _nextOffspring, _l), individualEffect (_l, _p, _nextOffspring, _nextIndividualEffect), compositeEffectTable (_cumulative, _nextIndividualEffect, _effect1), setDiff(_offspringSet, _nextOffspring, _offspringSet1), ((_effect1 == C -> (_effect = _effect1, nl,write('Optimization: with C, no further composition'),nl)); cumulativeCompositeEffectTable(_effect1, _p, _offspringSet1, _effect)))), display(_effect),write(' cumulativeCompositeEffectTable....'). compositeEffectTable (_cumulative, _next, _effect):- nl,write(' compositeEffectTable (cumulative: '), display(_cumulative), write(', next: '),display(_next), write(', effect: '),display(_effect),write(')'),nl, getTable(tableCompositeEffect, _cumulative, _next, _effect1), ( (member(_effect1, [Upos, Uneg]) -> (nl,nl,write('Uncertain propagation label: '), display(_effect1), nl, write('Enter your own value:'), readln(_effect) ) ); (_effect = _effect1)), display(_effect),write(' compositeEffectTable...'). {*************************************************************************} {* compute individual effect of offspring status value according to the *} {* link type: *} {*************************************************************************} individualEffect (_l, _p, _currentOffspring, _effect):- nl,nl,write('individualEffect (link: '), display(_l), write(', parent: '),display(_p), write(', currentOffspring: '),display(_currentOffspring), write(', effect: '),display(_effect), write(') '),nl, askLabel(_l, _linkLabel1), ((atomic(_linkLabel1) -> _linkLabel = _linkLabel1); (_linkLabel1 = [_linkLabel|_])), ((_linkLabel == S -> ( askLinkType(_l, _lT1), ((atomic(_lT1) -> _lT = _lT1);(_lT1 = [_lT|_])), askLabel(_currentOffspring, _sourceLabel1), ((atomic(_sourceLabel1) -> _sourceLabel = _sourceLabel1); (_sourceLabel1 = [_sourceLabel|_])), ( (_lT == AND -> individualEffectAND (_l, _p, _currentOffspring, _effect1)); (_lT == OR -> individualEffectOR (_l, _p, _currentOffspring, _effect1)); (write(' calling singleIndividualEffect: _sourceLabel='), display(_sourceLabel),write(' link type='),display(_lT), singleIndividualEffect (_sourceLabel, _lT, _effect1)) ) ) ); (_effect1 = U)), ( (member(_effect1, [Squestion, Dquestion, Uquestion]) -> (nl,nl,write('Uncertain propagation label: '), display(_effect1), nl, write('Enter your own value:'), readln(_effect) ) ); ((_effect1 == question -> (nl,nl,write('Uncertain propagation label: '), display(_effect1), nl, write('Enter your own value:'),readln (_effect))); (_effect = _effect1))), display(_effect),write(' individualEffect...'). individualEffectAND (_l, _p, _currentOffspring, _effect2):- {* Each sublink of AND has AND as its link type *} nl,write('individualEffectAND (link: '),display(_l), write(', parent: '),display(_p), write(', currentOffspring: '),display(_currentOffspring), write(')'),nl,nl, askLabel(_currentOffspring, _effect1), ((atomic(_effect1) -> _effect = _effect1);(_effect1 = [_effect|_])), askOffspringSet(_p, _offspringSet1), setDiff(_offspringSet1, _currentOffspring, _offspringSet), cumulativeANDTable(_effect, _offspringSet, _effect2). cumulativeANDTable(_cumulative, _offspringSet, _effect):- write('cumulativeANDTable (cumulative: '),display(_cumulative), write(', offspringSet: '),display(_offspringSet), write(') '), ((_offspringSet == [] -> _effect = _cumulative); (pickOne (_offspringSet, _nextOffspring), setDiff(_offspringSet, _nextOffspring, _offspringSet2), askLabel(_nextOffspring, _nextOffspringLabel1), ((atomic(_nextOffspringLabel1) -> _nextOffspringLabel = _nextOffspringLabel1); (_nextOffspringLabel1 = [_nextOffspringLabel|_])), ANDTable (_cumulative, _nextOffspringLabel, _effect1), ((_effect1 == D -> (_effect = _effect1, nl,write('Optimization: with D, no further composition'), nl)); cumulativeANDTable(_effect1, _offspringSet2, _effect) ))). pickOne([_H|_T], _H). ANDTable (_cumulative, _nextOffspringLabel, _effect):- write('ANDTable (cumulative: '),display(_cumulative), write(', _nextOffspringLabel: '),display(_nextOffspringLabel), write(') '), getTable(tableAND, _cumulative, _nextOffspringLabel, _effect1), ((member(_effect1, [Squestion, Dquestion, Cquestion, Uquestion]) -> ( display(_effect1), write('Enter your own value:'), readln(_effect) ) ); (((_effect1 == question) -> (write('Enter your own value:'),readln(_effect))); (_effect = _effect1))), display(_effect),write(' ANDTable... '). individualEffectOR (_l, _p, _currentOffspring, _effect2):- write('individualEffectOR (link: '),display(_l), write(', parent: '),display(_p), write(', currentOffspring: '),display(_currentOffspring), write(', effect2; '),display(_effect2), write(') '), askLabel(_currentOffspring, _effect1), ((atomic(_effect1) -> _effect = _effect1); (_effect1 = [_effect|_])), askOffspringSet(_p, _offspringSet1), setDiff(_offspringSet1, _currentOffspring, _offspringSet), cumulativeORTable(_effect, _offspringSet, _effect2), display(_effect2),write(' individualEffectOR...'). cumulativeORTable(_cumulative, _offspringSet1, _effect):- nl,write('cumulativeORTable (cumulative: '),display(_cumulative), write(', offspringSet1: '),display(_offspringSet1), write(', effect: '),display(_effect), write(')'),nl, ((_offspringSet1 == [] -> _effect = _cumulative); (pickOne (_offspringSet1, _nextOffspring), setDiff(_offspringSet1, _nextOffspring, _offspringSet), askLabel(_nextOffspring, _nextOffspringLabel1), ((atomic(_nextOffspringLabel1) -> _nextOffspringLabel = _nextOffspringLabel1); (_nextOffspringLabel1 = [_nextOffspringLabel|_])), ORTable (_cumulative, _nextOffspringLabel, _effect1), ((_effect1 == S -> (_effect = _effect1, nl, write('Optimization: with S, no further composition'), nl)); cumulativeORTable(_effect1, _offspringSet, _effect)))), display(_effect),write(' cumulativeORTable...'). ORTable (_cumulative, _next, _effect):- nl,write('ORTable (cumulative: '),display(_cumulative), write(', next: '),display(_next), write(', effect: '),display(_effect), write(') '), getTable(tableOR, _cumulative, _next, _effect1), ((member(_effect1, [Squestion, Dquestion, Uquestion]) -> ( display(_effect), write('Enter your own value:'), readln(_effect) )); _effect = _effect1), display(_effect),write(' ORTable...'). singleIndividualEffect (_sourceLabel, _lT, _effect):- {* l cannot be AND or OR *} nl,write('singleIndividualEffect (sourceLabel: '),display(_sourceLabel), write(', linktype: '),display(_lT), write(', effect: '),display(_effect), write(') '), getTable(tableSingleIndividualEffect, _sourceLabel, _lT, _effect), display(_effect),write(' singelIndividualEffect...'),nl. {*****************************************************************************} {* The predicates combine and composite implement the combination of *} {* values between sibling nodes during composite propagation. The input *} {* is *} {* (1) a Prolog list representing the bias/applicability values *} {* for the set of sibling nodes *} {* (2) a table name specification for the table for which the *} {* propagation can be applied. For composite propagation, this *} {* can be one of *} {* (i) tableCPBProperOR *} {* (ii) tableCPBProperAND *} {* (iii) tableCPBMutateOR *} {* (iv) tableCPAOR *} {* (v) tableCPAAND *} {* See the file tableDef.pro for definitions of these tables *} {* *} {* *} {* combine([],_tableName,_cumulative,_result) :- _result = _cumulative. *} {* combine([_H|_T],_tableName,_cumulative,_result) :- *} {* getTable(_tableName,_cumulative,_H,_val), *} {* combine(_T,_tableName,_val,_result). *} {* *} {* composite(_L,_table,_result) :- *} {* _L = [_H|_T], *} {* combine(_T,_table,_H,_result). *} {* *} {* ?- consult('tableDef'). *} {*****************************************************************************} {*****************************************************************************} {* tableDef.pro: *} { moved below } {*****************************************************************************} {*****************************************************************************} {* *} {* askParentSet(_offspring, _parentSet):- *} {* ... *} {* getParentSet(_return, _parent) *} {* *} {* askOffspringSet(_parent, _offspringSet):- *} {* ... *} {* getOffspringSet(_return, _offspringSet) *} {* *} {* askJustifyingMethodSet(_parent, _justifyingMethodSet):- *} {* ... *} {* getJustifyingMethodSet(_parent, _justifyingMethodSet) *} {* *} {* askMethodParentSet(_method, _methodParentSet):- *} {* ... *} {* getMethodParentSet(_return, _methodParent) *} {* *} {* askMethodOffspringSet(_method, _methodOffspringSet):- *} {* ... *} {* getMethodOffspringSet(_return, _methodOffspringSet) *} {* *} {* *} {* askLabel(_goal, _goalLabel):- *} {* ... *} {* getTheLabel(_return, _goalLabel) *} {* *} {* askSource(_link, _linkSource):- *} {* ... *} {* getSource(_return, _linkSource) *} {* *} {* askDestination(_link, _linkDestination):- *} {* ... *} {* getDestination(_return, _linkDestination) *} {* *} {* askLinkType(_link, _linkType):- *} {* ... *} {* getLinkType(_return, _linkType) *} {* *} {* askIndividualEffect(_link, _linkIndividualEffect):- *} {* ... *} {* getIndividualEffect(_return, _linkIndividualEffect) *} {* *} {* _link = ASK(ATTRID(_parent, offspring, _triggeringOffspring, now)) *} {* *} {* For now, from designer: *} {* askLink(_p, _o, _link):- *} {* ... *} {* getLink(_return, _link) *} {* *} {* askInstanceOf(_instance, _class):- *} {* *} {* askInstanceOfLink(_link):- (_link, Goal!offspring) *} {* *} {* askIsA(_subclass, _superclass) :- *} {* *} {*****************************************************************************} {* use: askAny(_object, parent, _parentSet) *} {* _attrValSet is a set *} {askAny(_object, _attrName, _attrValSet):-} {askAny(_object,_attrName,_attrValList) :- nl,write(' askAny (object: '), display(_object), write(' attrName='),write(_attrName),display(_attrName), write(' attrValSet='),display(_attrValList), {askAny(_object,_attrName,_attrValSet),} askAny(_object,_attrName,_attrValList), display(_attrValList), ((_attrValList==nil -> (write('NIL proceed?'){, readln(_)}));true),write(' askAny...'),nl.} askParentSet(_offspring, _parentSet):- askAny(_offspring, parent,_parentSet). {* _offspringSet = ASK(_parent.offspring) *} askOffspringSet(_parent, _offspringSet):- askAny(_parent, offspring,_offspringSet). askJustifyingMethodSet(_parent, _justifyingMethodSet):- askAny(_parent,justifyingMethod,_justifyingMethodSet). askMethodParentSet(_method, _methodParentSet):- askAny(_method,parent,_methodParentSet). askMethodOffspringSet(_method, _methodOffspringSet):- askAny(_method,offspring,_methodOffspringSet). {* _goalLabel = ASK(_goal.label)) *} askLabel(_goal, _goalLabel):- askAny(_goal,label,_goalLabel1), selectCurrentOne(_goalLabel1,_goalLabel). selectCurrentOne([],[]). selectCurrentOne([_historyH|_historyT],_current):- ( (_historyT == [] -> _current = [_historyH]); selectCurrentOne(_historyT,_current)). {* _linkSource = ASK(_link.src) *} askSource(_link, _linkSource):- askAny(_link,src,_linkSource). {* _linkDestination = ASK(_link.dst) *} askDestination(_link, _linkDestination):- askAny(_link,dst,_linkDestination). {* _lT = ASK(_l.linkType) *} askLinkType(_link, _linkType):- askAny(_link,linkType,_linkType). {* _linkIndividualEffect = ASK (_link.individualEffect) *} askIndividualEffect(_link, _linkIndividualEffect):- askAny(_link,individualEffect,_linkIndividualEffect). {* _l = ASK(ATTRID(_parent, offspring, _triggeringOffspring, now)) *} askLink(_p, _o, _link):- nl,write('askLink (parent: '),display(_p), write(', offspring: '),display(_o), write(') '), {deselect(_pNodeOrLink, _p, _dummyAnswer), deselect(_oNodeOrLink, _o, _dummyA),} {atomconcat([' ', _pNodeOrLink, ' '],_p),} getstats(_sid,_tid,_CBsid), { replace: too slow } { select(x,!,y) not working IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[queryOffspring([_p/currentGoal])]), ipcanswer(_sender,_completion,_return)), } {no inherited attribute shows up: modified MA.sml -- dupl.} IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[get_object([_p/objname])]), { works but all number returned ipcmessage(_tid,_CBsid,ASK,[get_object([_p/objname]), ROLLBACK : Now,FORMAT : FRAME]),} ipcanswer(_sender,_completion,_return)), getLinkName(_return, _o, _linkName), {atomconcat([select(,_p,', !, ',_linkName, ')'],_link),} _link = select(_p,!,_linkName), {write(' linkName='),display(_linkName),} write(' ---> '),display(_link),write(' askLink...'). askAttrClass(_infoItemParam,_attributeClass) :- nl,write('askAttrClass('),display(_infoItemParam), write(', '),display(_attributeClass),write(') '), _infoItemParam = select(_theSubject,!,_theAttribute), askLinkDst(_theSubject,_theAttribute,_attributeClass). askLinkDst(_theSubject,_theAttribute,_attributeClass):- nl,write('askLinkDst('),display(_theSubject), write(', '),display(_theAttribute), write(', '),display(_attributeClass),write(') '), write('proceed?'),readln(_dummy), getstats(_sid,_tid,_CBsid), {no inherited attribute shows up: modified MA.sml -- dupl.} IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[get_object([_theSubject/objname])]), ipcanswer(_sender,_completion,_return)), getLinkDst(_return, _theAttribute,_attributeClass), write(' ---> '),display(_attributeClass),write(' askLinkDst...'). getLinkDst([],_,[]). getLinkDst(_SMLfragment, _category,_attributeClass) :- nl,write('getLinkDst('),display(_SMLfragment), write(', '),display(_category), write(', '),display(_attributeClass), write(')'), arg(5,_SMLfragment,_with), arg(1,_with,_attrdecList), write(' attrdecList = '),display(_attrdecList), arg(1,_attrdecList,_attrdecl), write(' ist-arg = '),display(_attrdecl), arg(2,_attrdecl,_propertyList), write(' propertyList = '),display(_propertyList), {TODO} getAttrClass(_propertyList,_category, _attributeClass). getAttrClass([], _, []). getAttrClass([_property|_T], _category, _attributeClass) :- nl,write(' getAttrClass(['),display(_property), write('|'),display(_T), write('], '),display(_category), write(', '),display(_attributeClass),write(')'), arg(1,_property,_categoryName), write(' categoryName = '),display(_categoryName), ((_category == _categoryName -> write(' identical '));write(' different ')), name(_categoryName,_N1), display(_N1), name(_category,_N2), display(_N2), ((_N1 == _N2 -> ( arg(2,_property, _attributeClass))); getAttrClass(_T, _category, _attributeClass)). { Case: _instance does exist as IN _class --> do nothing } { testIsA(_superclass,_classList,_answer) :- write(' testIsA: _superclass='),display(_superclass),write(' classList='),display(_classList), member(_superclass,_classList),write('YES'),!,write('YES'),_answer=yes,write('testIsA...'). testIsA(_superclass,_classList,_answer) :- _answer=no. } {askSuperclasses sets superClassList to the (immediate) generalisations of the given class} askSuperclasses(_class, _superClassList):- getstats(_sid,_tid,_CBsid), {write(' getstats done '),} IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[get_object([_class/objname])]), ipcanswer(_sender,_completion,_return)), {write(' return '),display(_return),nl,} getSuperclasses(_return,_superClassList) {,} {write(' superClassList='),display(_superClassList),nl} . {askIsA returns yes if class isA (immediately or transitively) superClass, no, otherwise} askIsA(_class,_superClass,_answer):- nl,write('askIsA ('),display(_class), write(', '),display(_superClass), write(')'), recursiveIsA(_class,[_class],_superClass,_answer), write(' ---> '),display(_answer). {recursiveIsA(_class,_superClassList,_superClass,_answer):} {recursiveIsA returns yes if any member of transitive-IsA-closure of superClassList is equal to superClass no, otherwise} {_superClassList is the current list of superclasses of _class} {Do not go "above" SimpleClass} recursiveIsA(_class,[],_superClass,no). recursiveIsA(_class,[SimpleClass|_TailSuperClassList],_superClass,_answer):- recursiveIsA(_class,_TailSuperClassList,_superClass,_answer). {Ignore the SimpleClass case} recursiveIsA(_class,[_superClass|_TailSuperClassList],_superClass,yes). {trivially, the superClass is at the head of the list} recursiveIsA(_class,[_headSuperClassList|_tailSuperClassList],_superClass,_answer):- (_headSuperClassList \== SimpleClass), {not =} {See above case} (_headSuperClassList \== _superClass), {not =} {See above case} ((member(_class,_tailSuperClassList)) -> (_answer = yes) ; ( {write(' at non-trivial case '),nl,} write('.'), askSuperclasses(_headSuperClassList,_superClassListOfHead), append(_superClassListOfHead,_tailSuperClassList,_newSuperClassList), recursiveIsA(_class,_newSuperClassList,_superClass,_answer) ) ). { testDetermineIsA:- askIsA(Reports,Reports,_A), askIsA(MeetingReports,Reports,_B), askIsA(FormalStatement,Goal,_C), askIsA(VerificationNode,Goal,_D), askIsA(FormalStatement,InformalStatement,_E), askIsA(VerificationNode,MeetingReports,_F), askIsA(SubclassGDM,GoalRefinementMethod,_G), write(' answers '),display(_A),display(_B),display(_C),display(_D), display(_E),display(_F),display(_G),nl. } {A,B,C,D,G should be yes. E,F should be no} {* The predicate getSuperclasses processes the SMLfragment to get the * list of superclasses of the class given in _SMLfragment. It works as follows: } getSuperclasses([],[]) :- !. getSuperclasses(_SMLfragment,_classList) :- arg(4,_SMLfragment,_isa), arg(1,_isa,_L), getNames(_L,_classList). getClasses([],[]) :- !. getClasses(_SMLfragment,_classList) :- arg(3,_SMLfragment,_in), arg(1,_in,_L), getNames(_L,_classList). {* getNames extracts the names of the superclasses from the _in construct } getNames([],[]) :- !. getNames([_H|_T],_List) :- arg(1,_H,_next), getNames(_T,_List1), append([_next],_List1,_List). askInstanceOf(_instance, _class, _answer):- write('askInstanceOf: '), display(_instance), write(_class), myCheckDef(_instance, _class, _answer), {atomconcat(['exists',' ','([',_instance, '/objname ','])'], _W),}{!,} {name(_W,_U),} { convert the atom to Prolog string format } {getstats(_sid,_tid,_CBsid),} {IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[_U]), ipcanswer(_sender,_completion,_return)), write('_return= '),display(_return),} write(_answer),write(' askInstanceOf....') . askInstanceOfLink(_link,_answer):- {(select(g1,!,o1), Goal!offspring)} write('askInstanceOfLink (link: '),display(_link), write(', answer: '),display(_answer), write(') '), ( (atomic(_link) -> _answer = no); _answer = yes), {myCheckDef(_link,'Goal!offspring',_answer),} {_L = ['exists ([',_link, '/Goal!offspring])'],} {atomconcat(_L,_W),} { construct atom representing definition for ASK } {name(_W,_U),} { convert the atom to Prolog string format } {getstats(_sid,_tid,_CBsid),} {IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[_U]), ipcanswer(_sender,_completion,_return)),} write(_answer),write(' askInstanceOfLink...'). askInstances(_class,_instanceList) :- nl,write('askInstances('),display(_class), write(', '),display(_instanceList),write(') '), getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[find_instances([_class/class])]), ipcanswer(_sender,_completion,_return)), _instanceList = _return, write(' ---> '),display(_instanceList) . askSort(_g,_sort) :- askAny(_g,sort,_sortList), _sortList = [_sort]. {askAny(NodeCount,counter, [6]). for IndividualAttributeM } {askAny(NodeCount,counter, [7]).} {for AttributeClassSuperset } {askAny(NodeCount,counter, [8]).} {for Subsort } {askAny(NodeCount,counter, [9]).} {for Criticality } {askAny(NodeCount,counter, [10]).} {for VitalFew } {askAny(NodeCount,counter, [11]).} {for RapidPosting } {askAny(NodeCount,counter,[12]).} {for ReduceTransmissionTimeGSM} {askAny(NodeCount,counter,[13]).} {for InstallInputDeviceGSM} {askAny(NodeCount,counter,[14]).} {for SystemBoundaryGDM } {askAny(NodeCount,counter,[15]).} {for ExhaustiveSubclassGDM } {askAny(NodeCount,counter,[16]).} {for IndividualAttributeGDM } {askAny(NodeCount,counter,[17]).} {for AttributeClassSupersetGDM } askAny(_g,_category, _valList) :- nl,write('askAny('),display(_g), write(', '),display(_category), write(', '),display(_valList),write(') '), getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[get_object([_g/objname])]), ipcanswer(_sender,_completion,_return)), arg(5,_return,_with), arg(1,_with,_attrdecList), getAttrNameAndValList(_attrdecList, _category, _nameAndValList), getValListOnly(_nameAndValList, _valList), write(' ---> '),display(_valList) . getValListOnly([],[]). getValListOnly([_H|_T],_valList) :- _H = [_name,_val], getValListOnly(_T, _valListT), append([_val],_valListT, _valList). {Given a goal, g, and one of its offspring, o, determine the name of the link } {[get_object([g/objname])] withClause <- 5th arg of SMLframent, get-first-ele, see-if-offspring, if-yes,} getLinkName([],[],[]). getLinkName(_SMLfragment,_offspring,_answer) :- write('getLinkName: '),{display(_SMLfragment),} arg(5,_SMLfragment,_with), arg(1,_with,_attrdecList), getAttrNameAndValList(_attrdecList, offspring, _nameAndValList), nl,write('nameAndValList='),display(_nameAndValList), getLinkNameVal(_offspring,_nameAndValList, _answer). getAttrNameAndValList([], _category, []). getAttrNameAndValList([_attrdecl|_T], _category, _nameAndValList) :- arg(1,_attrdecl,_categoryNameComponent), atomconcat([_category,',attribute'],_categoryNameAndAttribute), {nl,write('categoryNameComponent='),display(_categoryNameComponent),} ((_categoryNameComponent == [_categoryNameAndAttribute] -> write('0')); (_categoryNameComponent = [_categoryName],write('3')); (_categoryNameComponent = [_categoryName,_attribute],write('1'))), {nl,write('categoryName='),display(_categoryName),} name(_categoryName, _N1), {display(_N1),} name(_category,_N2), {display(_N2),} {nl,write('atribute='),display(_attribute),} ((_N1 == _N2 -> ({write('OK'),} arg(2,_attrdecl,_propertyList), {nl,write('propertyList='),display(_propertyList),} extractNameAndValList(_propertyList, _nameAndValList))); getAttrNameAndValList(_T, _category, _nameAndValList)). extractNameAndValList([], []). extractNameAndValList([_H|_propertyList], _nameAndValList) :- arg(1, _H, _nameH), {nl,write('name='),write(_nameH),} arg(2, _H, _valH), {nl,write('val='),write(_valH),} _nameAndValH = [_nameH, _valH], extractNameAndValList(_propertyList, _nameAndValListT), {nl,write('eNAVL: nameAndValList='),display(_nameAndValListT),} append([_nameAndValH], _nameAndValListT, _nameAndValList). {[o1,v1],[o2,v2]} getLinkNameVal(_,[],[]). getLinkNameVal(_offspring, [_nameAndValList|_T],_answer) :- {nl,write('getLinkNameVal: _nameAndValList='),display(_nameAndValList), write('offspring='),display(_offspring),} _nameAndValList = [_name, _val], ( (_offspring == _val -> _answer = _name); getLinkNameVal(_offspring,_T,_answer)). { Earlier version based on query->SMLfrag: getLinkName([],[],[]). getLinkName(_SMLfragment,_offspring,_answer) :- write('getLinkName: '),display(_SMLfragment), _SMLfragment = [_SMLfrag], arg(5,_SMLfrag,_with), arg(1,_with,_attrdecList), _attrdecList = [_attrdecl|_T], arg(2,_attrdecl,_propertyList),write('propertyList='),display(_propertyList), getLinkVal(_propertyList,_offspring,_answer). getLinkVal([],[],[]). getLinkVal([_property|_T],_offspring,_answer) :- arg(2,_property,_val), write(' property='),display(_property), ( (_offspring == _val -> arg(1,_property,_preAns), atomtolist(_preAns, _ans),write('arg1='),display(_ans), ( (_ans \== [] -> _answer = _preAns); getLinkVal(_T,_offspring,_answer) ) ); getLinkVal(_T,_offspring,_answer)). } {given a goal, g, one of its offspring link name, l, and an attribute name, attrName, retrieve the value of g!l.attrName } {*****************************************************************************} {* processQuery.pro: *} {* This file contains Prolog code to process output from queries *} {* for the evaluation scheme algorithm *} {* *} {* getValue and getParents process SMLfragments received from the *} {* queryparent, which gets the parents of a given goal. For each *} {* SMLfragment present, getValue extracts the parent value, and each *} {* result is put into a list by getParents *} {* *} {* OLD WITH BACKWARDINFOS: *} {* getValue(_SMLfragment,_goalVal) :- *} {* arg(5,_SMLfragment,_with), *} {* arg(1,_with,_attrdecList), *} {* _attrdecList = [_attrdecl|_T], *} {* arg(2,_attrdecl,_propertyList), *} {* _propertyList = [_property|_T1], *} {* arg(2,_property,_goalVal). *} {* *} {* getParents([],[]). *} {* getParents(_SMLfragmentList,_answer) :- *} {* _SMLfragmentList = [_H|_T], *} {* getParents(_T,_answer1), *} {* getValue(_H,_goal), *} {* append(_answer1,[_goal],_answer). *} {* *} {* *} {* getOffspring and getsgVals are used to process SMLfragments from the *} {* queryOffspring query, which gets the children of a certain Goal. *} {* getOffspring and getsgVals work analagously to getValue and getParents *} {* *} {* NOTE: There may be duplications here in the list generated by these *} {* predicates. i.e some values may show up twice. *} {* *} {* These have been tested with the file sgframe *} {*****************************************************************************} { getMultiValuedAttributeValue([],[]). getMultiValuedAttributeValue(_SMLfragment,_answer) :- _SMLfragment = [_SMLfrag], arg(5,_SMLfrag,_with), arg(1,_with,_attrdecList), _attrdecList = [_attrdecl|_T], arg(2,_attrdecl,_propertyList), getsgVals(_propertyList,_ans), removeRedundancy(_ans,_answer). getsgVals([],[]). getsgVals([_property|_T],_answer) :- arg(2,_property,_val), getsgVals(_T,_answer2), append(_answer2,[_val],_answer). } removeRedundancy([],[]). removeRedundancy(_set1,_set2):- _set1 =[_H|_T], ( (member(_H,_T) -> removeRedundancy(_T,_set2) ); (removeRedundancy(_T,_setT), union([_H],_setT,_set2) ) ). {*****************************************************************************} {* OLD before TSE Final: *} {* getLinkType is used to process output from the getMethods query. Basically*} {* all that is done here is the number of SMLfragments in the input list are *} {* counted. The number N of these indicates the number of methods that have *} {* been applied to a node. If N=1 , then the link type is conjunctive, else *} {* it is disjunctive *} {* *} {* getLinkType(_SMLfragment,_type) :- *} {* length(_SMLfragment,_N), *} {* *} {*****************************************************************************} { use: tellAny(_g, parent, _parentSet)} tellAnyCategory(_g, _attrName, _attrType):- nl,write(' tellAnyCategory: goal='),write(_g), write(' attrName='),write(_attrName), write(' attrType='),write(_attrType), {((_g == InformalRequirement -> _nodeType = ' Class,MetaClass ');} _nodeType = ' Class,MetaClass ', {askNodeType(_g,_nodeType) ),} deselect(_g,_goal,_answer),display(_goal), ((_answer==no -> _L1 = ['Individual ',_goal, ' in ',_nodeType, ' with attribute ',_attrName,': ',_attrType, ' ','end ', ' ', _goal, ' ']); (_L1 = ['Individual ',_goal, ' in Goal!offspring with attribute ', _attrName, ': ',_attrType, ' ','end ', ' ', _goal, ' '])), atomconcat(_L1,_W1), { construct new attribute definition } appendToFile(_W1), name(_W1,_U1), getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,TELL,[_U1]), ipcanswer(_s1,_c1,_r1)), write(_c1),display(_r1),((_c1==ok -> true);(write('tellAnyCategory'), display(_c1),write(_W1),write('FAILURE,proceed?'),readln(_))), write('tellAnyCategory...'),nl . recursiveDeselect([],[],yes). recursiveDeselect([_H|_T],_objectInTelos,_answer):- nl, write('recursiveDeselect (['),display(_H), write('|'),display(_T), write('], '),display(_objectInTelos), write(', '), display(_answer), write(') '), deselect(_H,_objectInTelosH, _answer), recursiveDeselect(_T, _objectInTelosT, _ans2), append([_objectInTelosH],_objectInTelosT, _objectInTelos). { use: tellAny(_g, parent, _parentSet)} tellAny(_g, _attrName, _attrValSet):- nl,write('tellAny('),display(_g), write(', '),write(_attrName), write(', '),display(_attrValSet), write(') '), askNodeType(_g,_nodeType), deselect(_g,_goal,_answer),display(_goal), recursiveDeselect(_attrValSet, _attrValSet1, _a),display(_attrValSet1), genTellableAttrList(_attrName,1,_attrValSet1,_attrListGenerated), ((_answer==no -> _L1 = ['Individual ',_goal, ' in ',_nodeType, ' with attribute,',_attrName,' ',_attrListGenerated, ' ','end ', ' ', _goal, ' ']); {(_L1 = ['Individual ',_goal, ' in Goal!offspring with ', _attrName,} (_L1 = ['Attribute ',_goal, ' in ',_nodeType,' with attribute,', _attrName, ' ',_attrListGenerated, ' ','end ', ' ', _goal, ' '])), atomconcat(_L1,_W1), { construct new attribute definition } appendToFile(_W1), name(_W1,_U1), getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,TELL,[_U1]), ipcanswer(_s1,_c1,_r1)), write(_c1),display(_r1),((_c1==ok -> true);(write('tellAny'),write(_W1),write('FAILURE, proceed?'),readln(_))), write('tellAny...'),nl . tellParent(_g, _parentSet):- tellAny(_g, parent, _parentSet). tellOffspring(_g, _offspringSet):- tellAny(_g, offspring, _offspringSet). tellJustifyingMethod(_g, _justifyingMethodSet):- tellAny(_g, justifyingMethod, _justifyingMethodSet). tellMethodParent(_method, _methodClass, _parentSet):- tellAny(_method, parent, _parentSet). tellMethodOffspring(_method, _methodClass, _methodOffspringSet):- tellAny(_method, offspring, _methodOffspringSet). { use: retellAny(_g,label,_label); _g is either a goal or link; _attrVal is a singleton } {retellAny(NodeCount, counter, _) :- write(' doing nothing currently ').} retellAny(_g, _attrName, _attrVal):- nl,write('retellAny('), display(_g), write(', '),display(_attrName), write(', '),display(_attrVal), write(') '), { ask } askNodeType(_g,_nodeType), askAny(_g,_attrName,_attrValPrevious), _attrValListified = [_attrVal], {nl,write('attrValiListified='),display(_attrValListified),} {if _attrVal \== _attrValPrevious then retell:} ( (_attrValListified == _attrValPrevious -> (true, nl,write('no need to RETELL'))); {do nothing} ( { _attrVal ~= _attrValPrevious} deselect(_g,_goal, _answer),display(_goal), ( (_attrValPrevious == nil -> (true, nl,write('no need to UNTELL'))); {do nothing} (genTellableAttrList(_attrName,1,_attrValPrevious,_attrValSetPrevious), write(' attrValSetPrevious='),display(_attrValSetPrevious), {Please Leave As Is: attribute!!!!!!! Apr9,10} { The following does not work after change to CB3.1: ((_answer == no -> _L2 = ['Individual ',_goal, ' in ',_nodeType, ' with attribute,',_attrName,' ', {,attribute ',} _attrValSetPrevious, ' ','end ', ' ', _goal, ' ']); ( _L2 = ['Attribute ',_goal, ' with attribute,',_attrName,' ', {,attribute ',} _attrValSetPrevious, ' ','end ', ' ', _goal, ' '])), } {Please Leave As Is: Nov5,`92} _L2 = [_goal, ' with ',_attrName, ',attribute ', _attrValSetPrevious, ' ','end ', ' ', _goal, ' '], atomconcat(_L2,_W2), appendToFile(_W2), name(_W2,_U2), getstats(_sid2,_tid2,_CBsid2), IpcChannel_call(_sid2, ipcmessage(_tid2,_CBsid2,UNTELL,[_U2]), ipcanswer(_s2,_c2,_r2)), {nl,write(_c2),((_c2==ok -> true);(write('retellAny'),write(_W2),write('FAILURE, proceed?'),readln(_))),} nl,display(_r2),write('UNTELL done ...') )), { now tell} nl,write('NOW T E L L I N G'),nl, genTellableAttrList(_attrName,1,_attrValListified,_attrValSet), ((_answer == no -> _L1 = ['Individual ',_goal, ' in ',_nodeType, ' with attribute,',_attrName,' ',_attrValSet, ' ','end ', ' ', _goal, ' ']); (_L1 = ['Attribute ',_goal, {' in Goal!offspring with ',_attrName,' ',_attrValSet,} ' in ',_nodeType,' with attribute,',_attrName,' ',_attrValSet, ' ','end ', ' ', _goal, ' '])), atomconcat(_L1,_W1), { construct new attribute definition } appendToFile(_W1), name(_W1,_U1), getstats(_sid1,_tid1,_CBsid1), IpcChannel_call(_sid1, ipcmessage(_tid1,_CBsid1,TELL,[_U1]), ipcanswer(_s1,_c1,_r1)) )), nl,write(' c1 = '),display(_c1), {((_c1==ok -> true);(write('retellAny in retelling'),display(_W1),write('FAILURE, proceed?'),readln(_))), display(_r1),} write('Exiting retellAny...'),nl . retellLabel(_g, _label):- retellAny(_g,label,_label). tellSource(_l, _source):- tellAny(_l, src, [_source]). tellDestination(_l, _destination):- tellAny(_l, dst, [_destination]). tellMSrcDst(_l, _method):- tellAny(_l, mSrcDst, [_method]). retellIndividualEffect(_l, _sigma):- retellAny(_l, individualEffect, _sigma). retellLinkType(_l, _type):- retellAny(_l, linkType, _type). {**************************************************} {* From MappingClient.pro or apply.pro or variant *} {**************************************************} genTellableAttrList(_attrCatName,_index,[],' '). genTellableAttrList(_attrCatName,_index,[_H1|_T],_attrValSet):- nl,write(' genTellableAttrList ('),display(_attrCatName), write(', '),display(_index), write(', ['),display(_H1), write('|'),display(_T), write(']) '), ((atomic(_H1) -> _H = _H1);(_H1 = [_H])), {write(' new _H='),display(_H),} ( (_T \== [] -> atomconcat([_attrCatName,_index, ':',_H,'; '], _attrNameH) ); atomconcat([_attrCatName,_index, ':',_H,' '], _attrNameH) ), {write(' attrNameH='),display(_attrNameH),} _indexPlus is _index+1, genTellableAttrList(_attrCatName,_indexPlus, _T,_attrValSetTail), {write(' attrValSetTail='),display(_attrValSetTail),} atomconcat([_attrNameH, _attrValSetTail],_attrValSet), write(' ---> '),display(_attrValSet){,write(' genTellableAttrList...')}. union([],_X,_X). union([_H|_T],_set2,_set3):- member(_H,_set2),!,union(_T,_set2,_set3). union([_H|_T],_set2,[_H|_set3Tail]):-union(_T,_set2,_set3Tail). { The predicate myCheckDef takes a instance name (e.g., John) and a class name * (e.g., Agent) and checks to see if an instance IN class exists. If there * is, nothing else is done. If not, a Telos definition for the instance is * generated, and added to the file newnodes.sml. checkDef uses the built * in query get_object to get the Telos definition of _instance, and then * uses getClasses to compute the list of containin classes of _instance. The * predicate procInstance is then called to take the appropriate action. } myCheckDef(_instance,_class,_answer) :- write(' myCheckDef: '), getstats(_sid,_tid,_CBsid), {write(' getstats done '),} IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[get_object([_instance/objname])]), ipcanswer(_sender,_completion,_return)), display(_completion),display(_return), (_completion \== error -> ( getClasses(_return,_classList), testInstance(_class,_classList, _answer) ) ); createInstance(_instance,_class,_classList,_answer). { Case: _instance does exist as IN _class --> do nothing } testInstance(_class,_classList,_answer) :- member(_class,_classList),!,_answer=yes. testInstance(_class,_classList,_answer) :- _answer=no. { Case: generate definition of _instance and append to newnodes.sml } createInstance(_instance,_class,_classList,_answer) :- ((atomic(_instance) -> _L = [Individual,' ',_instance,' ',in,' ',_class,' ',with,' ',end,' ', _instance]); _L = [Attribute,' ',_instance,' ',in,' Goal!offspring ',with,' ',end,' ', _instance]), atomconcat(_L,_W1), appendToFile(_W1), name(_W1, _U1), getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,TELL,[_U1]), ipcanswer(_s1,_c1,_r1)), _answer=newCreation. {* The predicate getClasses processes the SMLfragment to get the * list of containing classes of the given _instance. It works as follows: } { ******************************************************************* } { for descrambling select(g1,excla,o1) to g1!o1} {deselect(_selectClause,_objectInTelos,_answer):- nl, write(' deselect (selectClause: '),display(_selectClause), write(', objectInTelos: '), display(_objectInTelos), write(', answer: '), display(_answer), write(')'),nl,nl, ( (atomic(_selectClause) -> _objectInTelos = _selectClause, _answer = no,write('ATOMIC!!')); (arg(1,_selectClause,_g), arg(3,_selectClause,_o), atomconcat([_g,'!',_o],_objectInTelos), _answer=yes ) ), display(_objectInTelos), write(' deselect...').} { for descrambling (_selectClause:) select(g1,excla,o1) to (_objectInTelos:) g1!o1} { _answer is no if _selectClause is atomic, otherwise yes} deselect(_selectClause,_objectInTelos,_answer):- nl, write(' deselect('),display(_selectClause),write(','), display(_objectInTelos),write(','), display(_answer),write(')'), ( (atomic(_selectClause) -> _objectInTelos = _selectClause, _answer = no, write('ATOMIC!!') ); (_answer = yes) ), translateSelectClauseToExplanationMarkForm (_selectClause,_objectInTelos). {**********************************************} {* E N D O F L A B E L *} {**********************************************} {**************************************************************************} {* G E N E R A L M E T H O D S: 2nd phase *} {**************************************************************************} {************************************} {* SOME Generalized routines *} {************************************} applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, _methodClass, _sort, _infoItemParam,_offspringFRList) :- nl,nl,write('applyAnyMethod ('),display(_parentSelected),write(', ?, ?, '), display(_methodClass),write(', '), display(_sort), write(', '), display(_infoItemParam), write(', '), display(_offspringFRList), write(')'), getNode(_currentNodeNum), {get current value of node counter} {length(_offspringFRList,_L),} _newNodeNum is 1 + _currentNodeNum, {compute new value of node counter} genMainDefs(_methodClass,_sort, [[infoItemParam, [infoItemParam1, _infoItemParam]]], _parentSelected,_offspringFRList,_currentNodeNum, _methodInstanceCreated, _offspringListCreated), retellAny(NodeCount,counter,_newNodeNum). {********** NEW *******************} {* A routine is needed for concat and shortening --- cosmetic*} shortSort(Accuracy, ACC). shortSort(Security, SEC). shortSort(Cost, COST). shortSort(OperatingCost, OpCOST). shortSort(EquipmentCost, EquipCOST). shortSort(ValueAccuracy, ValACC). shortSort(TimelyAccuracy, TimeACC). shortSort(PropertyAccuracy, PropACC). shortSort(ValueCriticalAccuracy, CritValACC). shortSort(TimelyCriticalAccuracy, CritTimeACC). shortSort(CriticalTimelyAccuracy, CritTimeACC). shortSort(PropertyCriticalAccuracy, CritPropACC). shortSort(ExternalConfidentiality, ExCONF). shortSort(InternalConfidentiality, InCONF). shortSort(ReduceTransmissionTime, RedTransTime). shortSort(_originalSort, _originalSort). fromSortToNfr(Accuracy, AccuracyRequirement). fromSortToNfr(Security, SecurityRequirement). fromSortToNfr(Cost, CostRequirement). fromSortToNfr(OperatingCost, OperatingCostRequirement). fromSortToNfr(EquipmentCost, EquipmentCostRequirement). fromSortToNfr(ValueAccuracy, ValueAccuracyRequirement). fromSortToNfr(PropertyAccuracy, PropertyAccuracyRequirement). fromSortToNfr(TimelyAccuracy, TimelyAccuracyRequirement). fromSortToNfr(ValueCriticalAccuracy, CriticalValueAccuracyRequirement). fromSortToNfr(PropertyCriticalAccuracy, CriticalPropertyAccuracyRequirement). fromSortToNfr(TimelyCriticalAccuracy, CriticalTimelyAccuracyRequirement). fromSortToNfr(CriticalTimelyAccuracy, CriticalTimelyAccuracyRequirement). fromSortToNfr(ExternalConfidentiality, ExternalConfidentialityRequirement). fromSortToNfr(InternalConfidentiality, InternalConfidentialityRequirement). instantiateMethodFindSortParam(_method, _methodInstanceCreated, _parentSelected, _sort, _infoItemParam) :- nl,nl,write('instantiateMethodFindSortParam ('),display(_method), write(', '), display(_methodInstanceCreated), write(', '), display(_parentSelected), write(', '), display(_sort), write(', '), display( _infoItemParam), write(')'),nl, getNode(_currentNodeNum), {get current value of node counter} write('_currentNodeNum:'), display(_currentNodeNum), atomconcat([_method, _currentNodeNum], _methodInstanceCreated), write('_methodInstanceCreated:'), display(_methodInstanceCreated),nl, checkDef(_methodInstanceCreated, _method), write(' checkDef done'), _newNodeNum is 1 + _currentNodeNum, {compute new val of node counter} write(' currentNodeNum = '),display(_currentNodeNum),write(', newNodeNum = '),display(_newNodeNum), retellAny(NodeCount,counter,_newNodeNum), askAny(_parentSelected, sort, _sortSet), _sortSet = [_sort], askAny(_parentSelected, infoItemParam, _infoItemParamSet), _infoItemParamSet = [_infoItemParam] , write(' instantiateMethodFindSortParam(sort:'), display(_sort), write(', infoItemParam: '), display(_infoItemParam), write(')') . instantiateAndAssignParam(_offspring, _infoItemParam, _nfrType) :- checkDef(_offspring, _nfrType), tellAny(_offspring, infoItemParam, [_infoItemParam]). applySubsort3SecGDM(_parentSelected,_methodInstanceCreated,_offspringListCreated) :- instantiateMethodFindSortParam(Subsort3SecGDM, _methodInstanceCreated, _parentSelected, _sort, _infoItemParam), write(' after iMFSP: _infoItemParam = '), display(_infoItemParam), atomconcat([CONF, _infoItemParam], _offspring1), instantiateAndAssignParam(_offspring1, _infoItemParam, ConfidentialityRequirement), tellAny(_offspring1,sort, [Confidentiality]), atomconcat([INT, _infoItemParam], _offspring2), instantiateAndAssignParam(_offspring2, _infoItemParam, IntegrityRequirement), tellAny(_offspring2,sort,[Integrity]), atomconcat([AVAIL, _infoItemParam], _offspring3), instantiateAndAssignParam(_offspring3, _infoItemParam, AvailabilityRequirement), tellAny(_offspring3,sort,[Availability]), _offspringListCreatedTemp = [_offspring1, _offspring2], append(_offspringListCreatedTemp, [_offspring3], _offspringListCreated). applySubsortGDM(_parentSelected,_methodInstanceCreated,_offspringListCreated) :- instantiateMethodFindSortParam(SubsortGDM, _methodInstanceCreated, _parentSelected, _sort, _infoItemParam), write(' after iMFSP: _infoItemParam = '), display(_infoItemParam), (((_sort == Integrity) -> (write(' sort = Integrity: '), atomconcat([ACC, _infoItemParam], _offspring1), instantiateAndAssignParam(_offspring1, _infoItemParam, AccuracyRequirement), tellAny(_offspring1,sort,[Accuracy]), atomconcat([COM, _infoItemParam], _offspring2), instantiateAndAssignParam(_offspring2, _infoItemParam, CompletenessRequirement), tellAny(_offspring2,sort,[Completeness]), _offspringListCreated = [_offspring1, _offspring2])); {**** sort = Accuracy or Cost ******} (((_sort == Accuracy) -> (write(' sort = Accuracy:'), atomconcat([Value, _sort], _newSort1), shortSort(_newSort1, _newShortSort1), atomconcat([_newShortSort1, _infoItemParam], _offspring1), fromSortToNfr(_newSort1, _nfrType1), instantiateAndAssignParam(_offspring1, _infoItemParam, _nfrType1), tellAny(_offspring1,sort,[ValueAccuracy]), atomconcat([Timely, _sort], _newSort2), shortSort(_newSort2, _newShortSort2), atomconcat([_newShortSort2, _infoItemParam], _offspring2), fromSortToNfr(_newSort2, _nfrType2), instantiateAndAssignParam(_offspring2, _infoItemParam, _nfrType2), tellAny(_offspring2,sort,[TimelyAccuracy]), atomconcat([Property, _sort], _newSort3), shortSort(_newSort3, _newShortSort3), atomconcat([_newShortSort3, _infoItemParam], _offspring3), fromSortToNfr(_newSort3, _nfrType3), instantiateAndAssignParam(_offspring3, _infoItemParam, _nfrType3), tellAny(_offspring3,sort,[PropertyAccuracy]), _offspringListCreatedTemp = [_offspring1, _offspring2], append( _offspringListCreatedTemp, [_offspring3], _offspringListCreated))); (write(' sort = Cost: infoItemParam = '), display(_infoItemParam), write(' proceed?'), readln(_dummy), atomconcat([OpCOST, _infoItemParam], _offspring1), write(' offspring1 = '), display(_offspring1), write(' proceed?'), readln(_dummy), instantiateAndAssignParam(_offspring1, _infoItemParam, OperatingCostRequirement), tellAny(_offspring1,sort,[OperatingCost]), atomconcat([EquipCOST, _infoItemParam], _offspring2), instantiateAndAssignParam(_offspring2, _infoItemParam, EquipmentCostRequirement), tellAny(_offspring2,sort,[EquipmentCost]), _offspringListCreated = [_offspring1, _offspring2]);true)). applyAttributeClassSupersetGDM(_parentSelected,_methodInstanceCreated,_offspringListCreated) :- instantiateMethodFindSortParam(AttributeClassSupersetGDM, _methodInstanceCreated, _parentSelected, _sort, _infoItemParam), {write(' attribute class: '), readln(_attributeClass),} askAttrClass(_infoItemParam,_attributeClass), shortSort(_sort, _shortSort), atomconcat([_shortSort, _attributeClass], _offspring), fromSortToNfr(_sort, _nfrType), instantiateAndAssignParam(_offspring, _attributeClass, _nfrType), tellAny(_offspring,sort,[_sort]), _offspringListCreated = [_offspring]. applyCriticalityGDM(_parentSelected,_methodInstanceCreated,_offspringListCreated) :- instantiateMethodFindSortParam(CriticalityGDM, _methodInstanceCreated, _parentSelected, _sort, _infoItemParam), {atomconcat([Critical, _sort], _newSort), shortSort(_newSort, _newShortSort), atomconcat([_newShortSort, _infoItemParam], _offspring),} atomconcat([_sort, _infoItemParam], _offspring2), atomconcat([_offspring2, Critical], _offspring), {fromSortToNfr(_newSort, _nfrType),} fromSortToNfr(_sort, _nfrType), instantiateAndAssignParam(_offspring, _infoItemParam, _nfrType), {tellAny(_offspring,sort,[_newSort]),} tellAny(_offspring,sort,[_sort]), { For the following,we need a more elaborate routine which increments the criticality of the parent:} tellAny(_offspring,criticality,[critical]), _offspringListCreated = [_offspring]. applySystemBoundaryGDM(_parentSelected,_methodInstanceCreated,_offspringListCreated) :- instantiateMethodFindSortParam(SystemBoundaryGDM, _methodInstanceCreated, _parentSelected, _sort, _infoItemParam), atomconcat([External, _sort], _newSort1), shortSort(_newSort1, _newShortSort1), atomconcat([_newShortSort1, _infoItemParam], _offspring1), fromSortToNfr(_newSort1, _nfrType1), instantiateAndAssignParam(_offspring1, _infoItemParam, _nfrType1), tellAny(_offspring1,sort,[_newSort1]), atomconcat([Internal, _sort], _newSort2), shortSort(_newSort2, _newShortSort2), atomconcat([_newShortSort2, _infoItemParam], _offspring2), fromSortToNfr(_newSort2, _nfrType2), instantiateAndAssignParam(_offspring2, _infoItemParam, _nfrType2), tellAny(_offspring2,sort,[_newSort2]), _offspringListCreated = [_offspring1, _offspring2]. findAllAttributeClasses(_infoItemParam,[],[]). findAllAttributeClasses(_infoItemParam,[_attributeListH|_T],_attributeClassList) :- askAny(_infoItemParam, _attributeListH, _attributeClassHList), findAllAttributeClasses(_infoItemParam,_T,_attributeClassListT), append(_attributeClassHList,_attributeClassListT,_attributeClassList). applyComponentMethod(_parentSelected, _methodInstanceCreated,_offspringListCreated) :- askAny(_parentSelected, sort, _sortSet), _sortSet = [_sort], write(' sort = '), display(_sort), askAny(_parentSelected, infoItemParam, _infoItemParamSet), _infoItemParamSet = [_infoItemParam], write(' infoItemparam = '), display(_infoItemParam), {param is the class in question} { query KB for for all attributes with category attribute} askAny(_infoItemParam,attribute,_attributeClassList), write(' attributeClassList = '),display(_attributeClassList), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, ComponentGDM, _sort, _infoItemParam,_attributeClassList). {******** END NEW *************} applySuperclassGDM(_parentSelected, _methodInstanceCreated,_offspringListCreated) :- _sort = Accuracy, askAny(_parentSelected, infoItemParam, _infoItemParamSet), _infoItemParamSet = [_infoItemParam], askSuperclassList(_infoItemParam,_superclasses), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, SuperclassGDM, _sort, _infoItemParam,_superclasses). applyExhaustiveSubclassGDM(_parentSelected,_methodInstanceCreated,_offspringListCreated) :- askAny(_parentSelected, sort, _sortList), _sortList = [_sort], askAny(_parentSelected, infoItemParam, _infoItemParamSet), _infoItemParamSet = [_infoItemParam], findSpecialisations(_infoItemParam,_isAlist1), ((member(_infoItemParam,_isAlist1) -> setDiff(_isAlist1,_infoItemParam,_isAlist));(_isAlist = _isAlist1)), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, ExhaustiveSubclassGDM, _sort, _infoItemParam,_isAlist). applyInexhaustiveSubclassGDM(_parentSelected,_methodInstanceCreated,_offspringListCreated) :- _sort = Accuracy, askAny(_parentSelected, infoItemParam, _infoItemParamSet), _infoItemParamSet = [_infoItemParam], findSpecialisations(_infoItemParam,_isAlist), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, InexhaustiveSubclassGDM, _sort, _infoItemParam,_isAlist). applyResourceAssignmentGSM(_parentSelected, _methodInstanceCreated, _offspringListCreated) :- _sort = ResourceAssignment, askAny(_parentSelected, infoItemParam, _infoItemParamSet), _infoItemParamSet = [_infoItemParam], applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, ResourceAssignmentGSM, _sort, _infoItemParam,[_infoItemParam]), ((atomic(_offspringListCreated) -> _offspring = _offspringListCreated); (_offspringListCreated = [_offspring])), acceptResourceParameters(_parentSelected, _paramNameAndValList), tellResourceParameters(_offspring,_paramNameAndValList). acceptResourceParameters(_parentSelected, _paramNameAndValList) :- askSort(_parentSelected, _sort), determineNameList(_sort, _nameList), acceptParamValList(_nameList, _paramNameAndValList), display(_paramNameAndValList). determineNameList(InstallInputDevice, [Agent, Medium, InputLoc]). determineNameList(VerificationAcc, [Agent, Medium, VerificationTime]). determineNameList(CertificationAcc, [Agent, SupportingDocument, CertificationTime]). determineNameList(ValidationAcc, [Agent, ValidationProcedure, ValidationTime]). determineNameList(VerificationViaDistinctChannelAcc, [Agent, Medium, Channel, VerificationTime]). determineNameList(VerificationViaIdenticalChannelAcc, [Agent,Medium, VerificationTime]). acceptParamValList([], []). acceptParamValList([_nameH|_nameT], _paramNameAndValList) :- nl, nl, write(_nameH), write(': '), readln(_valH), _nameAndValH = [_nameH, _valH], acceptParamValList(_nameT, _nameAndValListT), append([_nameAndValH], _nameAndValListT, _paramNameAndValList), display(_paramNameAndValList). tellResourceParameters(_offspring, []). tellResourceParameters(_offspring, [_H|_T]) :- _H = [_name, _val], checkDef(_name, Class), {checkDef(_val, _name),} checkDef(_val, Class), tellAnyCategory(SatisficingGoal, _name, Class), tellAny(_offspring, _name, [_val]), tellResourceParameters(_offspring, _T). {************************************} {* SOME GAM *} {************************************} applyRelativePriorityAssignmentGAM (_parentSelected,_methodInstanceCreated,_offspringListCreated) :- nl, write(' Is the current goal with higher priority (y/n)? '), readln(_isHigher), ((_isHigher == y -> _higherParentSelected = _parentSelected, nl, write(' proposition with lower priority: '), readln(_lowerParent), reselect(_lowerParent,_lowerParentSelected)); (_lowerParentSelected = _parentSelected, nl, write(' proposition with lower priority: '), readln(_higherParent), readln(_higherParent, _higherParentSelected))), getNode(_currentNodeNum), _newNodeNum is _currentNodeNum + 1, retellAny(NodeCount,counter,_newNodeNum), {updateNode(_currentNodeNum, _newNodeNum),} atomconcat([Priority, _currentNodeNum], _priorityInstance), checkDef(_priorityInstance,Priority), tellPriorityRequirement(_priorityInstance, _higherParentSelected, _lowerParentSelected), _sort = FormalClaim, askAny(_parentSelected, infoItemParam, _infoItemParamList), ((_infoItemParamList == []); (_infoItemParamList = [_infoItemParam |_])), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, RelativePriorityAssignmentGAM, _sort, _infoItemParam,[_priorityInstance]), ((atomic(_offspringListCreated) -> _offspring = _offspringListCreated); (_offspringListCreated = [_offspring|_])), tellArgument(_offspring,_priorityInstance), integrate(m, _higherParentSelected, _methodInstanceCreated, HigherPriorityAssignmentGAM, _offspringListCreated), integrate(m, _lowerParentSelected, _methodInstanceCreated, LowerPriorityAssignmentGAM, _offspringListCreated). {************************************} applyHigherPriorityAssignmentGAM (_parentSelected,_methodInstanceCreated,_offspringListCreated) :- nl,write(' statement: '),readln(_statement), checkDef(_statement, String), getNode(_currentNodeNum), {get current value of node counter} _newNodeNum is 1 + _currentNodeNum, retellAny(NodeCount,counter,_newNodeNum), {updateNode(_currentNodeNum,_newNodeNum), } atomconcat([InformalRequirement, _currentNodeNum], _statementName), checkDef(_statementName, InformalRequirement), tellAny(_statementName, informalStatement, [_statement]), _sort = InformalClaim, askAny(_parentSelected, infoItemParam, _infoItemParamList), ((_infoItemParamList == [] -> true); (_infoItemParamList = [_infoItemParam |_])), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, HigherPriorityAssignmentGAM, _sort, _infoItemParam,[_statementName]). {************************************} applyLowerPriorityAssignmentGAM (_parentSelected,_methodInstanceCreated,_offspringListCreated) :- nl,write(' statement: '),readln(_statement), checkDef(_statement, String), getNode(_currentNodeNum), {get current value of node counter} _newNodeNum is 1 + _currentNodeNum, retellAny(NodeCount,counter,_newNodeNum), {updateNode(_currentNodeNum,_newNodeNum), } atomconcat([InformalRequirement, _currentNodeNum], _statementName), checkDef(_statementName, InformalRequirement), tellAny(_statementName, informalStatement, [_statement]), _sort = InformalClaim, askAny(_parentSelected, infoItemParam, _infoItemParamList), ((_infoItemParamList == [] -> true); (_infoItemParamList = [_infoItemParam |_])), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, LowerPriorityAssignmentGAM, _sort, _infoItemParam,[_statementName]). applyPolicyManualConsultationGAM (_parentSelected,_methodInstanceCreated,_offspringListCreated) :- { Handle informal requirement:} nl,write(' statement: '),readln(_statement),{HERE} { The following fails: _statement = "A simple procedure for accurate MER.",} {_statement = A_simple_procedure_for_accurate_MER,} checkDef(_statement,String), getNode(_currentNodeNum), {get current value of node counter} _newNodeNum is 1 + _currentNodeNum, retellAny(NodeCount,counter,_newNodeNum), atomconcat([InformalRequirement, _currentNodeNum], _statementName), checkDef(_statementName, InformalRequirement), {KLC: remove after BN creates String-valued statement} tellAnyCategory(InformalRequirement,informalStatement, String), tellAny(_statementName, informalStatement, [_statement]), {KLC: remove after BN creates sort for Goal} tellAnyCategory(Goal, sort, Sort), { Handle informal argument:} _sort = InformalClaim, askAny(_parentSelected, infoItemParam, _infoItemParamList), ((_infoItemParamList == [] -> true); (_infoItemParamList = [_infoItemParam |_])), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, PolicyManualConsultationGAM, _sort, _infoItemParam,[_statementName]), write('offspringListCreated='),display(_offspringListCreated), ((atomic(_offspringListCreated) -> _offspring = _offspringListCreated); (_offspringListCreated = [_offspring|_])), {KLC: again after Goal isA --- BN, backto original} tellAnyCategory(Goal, informalArgument, InformalRequirement), nl,write('category told'), tellAny(_offspring, informalArgument, [_statementName]). {tellArgument(_offspring,_statementName).} {************************************} applyPolicyManualConsultationDecompositionGAM (_parentSelected,_methodInstanceCreated,_offspringListCreated) :- { Handle informal requirement:} getConjuncts(_statementNameList), { Handle informal argument:} _sort = InformalClaim, askAny(_parentSelected, infoItemParam, _infoItemParamList), ((_infoItemParamList == [] -> true); (_infoItemParamList = [_infoItemParam |_])), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, PolicyManualConsultationDecompositionGAM, _sort, _infoItemParam,_statementNameList). {tellConjunctiveArguments(_offspringListCreated,_statementNameList)} getConjuncts(_statementNameList) :- nl,write(' statement (n for no more): '),readln(_statement), ((_statement == n -> _statementNameList = []); (checkDef(_statement, String), getNode(_currentNodeNum), atomconcat([PolicyManual, _currentNodeNum], _statementName), checkDef(_statementName, InformalRequirement), tellAny(_statementName, informalStatement, [_statement]), getConjuncts(_moreStatementNameList), append([_statementName],_moreStatementNameList,_statementNameList)) ). {************************************} applyExternalReferencePMCGAM (_parentSelected,_methodInstanceCreated,_offspringListCreated) :- nl,write(' external reference: '),readln(_reference), CheckDef(_reference,Reference), nl,write(' statement: '),readln(_statement), checkDef(_statement, String), getNode(_currentNodeNum), {get current value of node counter} _newNodeNum is _currentNodeNum + 1, retellAny(NodeCount,counter,_newNodeNum), atomconcat([_reference, _currentNodeNum], _statementName), checkDef(_statementName, InformalRequirement), tellAny(_statementName, informalStatement, [_statement]), atomconcat([_sort,_reference],_infoItemParam), _sort = InformalClaim, askAny(_parentSelected, infoItemParam, _infoItemParamList), ((_infoItemParamList == [] -> true); (_infoItemParamList = [_infoItemParam |_])), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, ExternalReferencePMCGAM,_sort, _infoItemParam,[_statementName]), ((atomic(_offspringListCreated) -> _offspring = _offspringListCreated); (_offspringListCreated = [_offspring|_])), tellReference(_offspring, reference, _reference), tellArgument(_offspring,_statementName). {************************************} applyDesignGuidelinePMCGAM (_parentSelected,_methodInstanceCreated,_offspringListCreated) :- nl,write(' design guideline: '),readln(_guideline), CheckDef(_guideline,Guideline), nl,write(' statement: '),readln(_statement), checkDef(_statement, String), getNode(_currentNodeNum), _newNodeNum is 1 + _currentNodeNum, retellAny(NodeCount,counter,_newNodeNum), atomconcat([_guideline, _currentNodeNum], _statementName), checkDef(_statementName, InformalRequirement), tellAny(_statementName, informalStatement, [_statement]), _sort = InformalClaim, askAny(_parentSelected, infoItemParam, _infoItemParamList), ((_infoItemParamList == [] -> true); (_infoItemParamList = [_infoItemParam |_])), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, DesignGuidelinePMCGAM, _sort, _infoItemParam,[_statementName]), ((atomic(_offspringListCreated) -> _offspring = _offspringListCreated); (_offspringListCreated = [_offspring|_])), tellGuideline(_offspring, _guideline), tellArgument(_offspring,_statementName). {************************************} applyRelationshipBasedPolicyManualConsultationGAM (_parentSelected,_methodInstanceCreated,_offspringListCreated) :- getNode(_currentNodeNum), atomconcat([RelationshipBasedPolicyManualConsultationGAM, _currentNodeNum], _methodInstanceCreated), checkDef(_methodInstanceCreated, RelationshipBasedPolicyManualConsultationGAM), nl,write(' offspring: '),readln(_o), reselect(_o, _offspring), _offspringListCreated = [_offspring], _newNodeNum is _currentNodeNum + 1, retellAny(NodeCount,counter,_newNodeNum). {************************************} applyAuthorityConsultationGAM (_parentSelected,_methodInstanceCreated,_offspringListCreated) :- _sort = InformalClaim, nl,write(' authority: '),readln(_authority), CheckDef(_authority,Authority), nl,write(' statement: '),readln(_statement), checkDef(_statement, String), atomconcat([_authority, _statement], _statementName), checkDef(_statementName, InformalRequirement), tellAny(_statementName, informalStatement, [_statement]), atomconcat([_sort,_authority],_infoItemParam), askAny(_parentSelected, infoItemParam, _infoItemParamList), ((_infoItemParamList == [] -> true); (_infoItemParamList = [_infoItemParam |_])), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, AuthorityConsultationGAM, _sort, _infoItemParam,[_infoItemParam]), ((atomic(_offspringListCreated) -> _offspring = _offspringListCreated); (_offspringListCreated = [_offspring|_])), tellAuthority(_offspring, _authority), tellArgument(_offspring,_statementName). {************************************} applyVitalFewTrivialManyGAM (_parentSelected,_methodInstanceCreated,_offspringListCreated) :- nl, write(' Is the current goal one of the vital few (y/n)? '), readln(_isHigher), ((_isHigher == y -> _vitalFewSelected = _parentSelected, nl, write(' proposition in the trivial many: '), readln(_trivialMany), reselect(_trivialMany, _trivialManySelected)); (_trivialManySelected = _parentSelected, nl, write(' proposition in the vital few: '), readln(_vitalFew), reselect(_vitalFew,_vitalFewSelected))), getNode(_currentNodeNum), _newNodeNum is _currentNodeNum + 1, retellAny(NodeCount,counter,_newNodeNum), atomconcat([Priority, _currentNodeNum], _priorityInstance), checkDef(_priorityInstance,Priority), checkDef(_priorityInstance,Mapping), {Apr14} tellPriorityRequirement(_priorityInstance, _vitalFewSelected, _trivialManySelected), _sort = FormalClaim, askAny(_parentSelected, infoItemParam, _infoItemParamList), ((_infoItemParamList == [] -> true); (_infoItemParamList = [_infoItemParam |_])), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, VitalFewTrivialManyGAM, _sort, _infoItemParam,[_priorityInstance]), ((atomic(_offspringListCreated) -> _offspring = _offspringListCreated); (_offspringListCreated = [_offspring|_])), tellArgument(_offspring,_priorityInstance), write(' after tellArgument'), integrate(m, _vitalFewSelected, _methodInstanceCreated, HigherPriorityAssignmentGAM, _offspringListCreated), integrate(m, _trivialManySelected, _methodInstanceCreated, LowerPriorityAssignmentGAM, _offspringListCreated). {************************************} applyVitalFewGAM (_parentSelected,_methodInstanceCreated,_offspringListCreated) :- _sort = InformalClaim, nl,write(' argument: '), readln(_argument), checkDef(_argument,Mapping), getNode(_currentNodeNum), atomconcat([VitalFewGAM, _currentNodeNum], _methodInstanceCreated), checkDef(_methodInstanceCreated, VitalFewGAM), _newNodeNum is 1 + _currentNodeNum, {compute new val of node counter} retellAny(NodeCount,counter,_newNodeNum), atomconcat([_sort, _argument], _offspring), checkDef(_offspring,Goal), tellAny(_offspring,sort,[_sort]), tellAny(_offspring,argument,[_argument]), _offspringListCreated = [_offspring]. {************************************} applyTrivialManyGAM (_parentSelected,_methodInstanceCreated,_offspringListCreated) :- _sort = InformalClaim, askAny(_parentSelected, infoItemParam, _infoItemParamList), ((_infoItemParamList == [] -> true); (_infoItemParamList = [_infoItemParam |_])), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, TrivialManyGAM, _sort, _infoItemParam,[_infoItemParam]). {**************************************************} {* Decomp/Satisficing Method Specializations *} {**************************************************} {* get method to be specialized; create offspring; change id and justifyingMethod and parent; copy the parent parameters to offspring parameters *} applyStepwiseSpecializationGRM (_parentSelected,_methodInstanceCreated,_offspringListCreated) :- nl,write(' method to specialize: '), readln(_methodToSpecialize), tellAnyCategory(GoalRefinementMethod, intermediateMethod, GoalRefinementMethod), getInstanceOfIsASortAndAllParameterAttributeValues( _parentSelected, _instanceOfList,_isAList,_sort,_parameterStructure), {_sort = InformalClaim,} {MAR30}{See if should be same sort below} { write(' v1 sort '), display(_sort),nl, } { write(' parameterStructure '), display(_parameterStructure),nl, } { Select the (single-valued) infoItemParam from the parameterStructure.} paramGetSingleAttributeValueForGivenCategory(_parameterStructure, infoItemParam, _infoItemParam), { write(' infoItemParam '),display(_infoItemParam),nl, } applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, StepwiseSpecializationGRM, _sort, _infoItemParam,[_infoItemParam]), tellAny(_methodInstance,intermediateMethod,_methodToSpecialize), ((atomic(_offspringListCreated) -> _offspring = _offspringListCreated); (_offspringListCreated = [_offspring|_])), {genTellableSortAndParameters(_parameterStructure, _tellableSortAndParameters),} translateSortAndParameterStructureToTelosCodeList (_sort,_parameterStructure,_SortAndParameterCodeList), {See translateHeaderAndSortAndParameterStructureToTelosCode, which is more general} atomconcat(_SortAndParameterCodeList, _tellableSortAndParameters), tellSortAndParameters(_offspring,_tellableSortAndParameters). {genSortAndParameterStructure(_parentSelected,[]).} { See getInstanceOfIsASortAndAllParameterAttributeValues/5} {genTellableSortAndParameters(_parameterStructure, []).} { See translateSortAndParameterStructureToTelosCodeList/3} {************************************} applyIndependentSubclassGDM(_parentSelected, _methodInstanceCreated, _offspringListCreated) :- _sort = Accuracy, askAny(_parentSelected, infoItemParam, _infoItemParamList), ((_infoItemParamList == [] -> true); (_infoItemParamList = [_infoItemParam |_])), findSpecialisations(_infoItemParam,_isAlist), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, IndependentSubclassGDM, _sort, _infoItemParam,_isAlist), tellConstraint(IndependentSubclassGDM, _infoItemParam). {************************************} applyMigratorySubclassGDM(_parentSelected, _methodInstanceCreated, _offspringListCreated) :- _sort = Accuracy, askAny(_parentSelected, infoItemParam, _infoItemParamList), ((_infoItemParamList == [] -> true); (_infoItemParamList = [_infoItemParam |_])), findSpecialisations(_infoItemParam,_isAlist), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, MigratorySubclassGDM, _sort, _infoItemParam,_isAlist), tellConstraint(MigratorySubclassGDM, _infoItemParam). {************************************} applyVerificationGSM(_parentSelected, _methodInstanceCreated,_offspringListCreated) :- askAny(_parentSelected, infoItemParam, _infoSet), _infoSet = [_infoItemParam], checkDef(VerificationAcc, SGSort), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, VerificationGSM, VerificationAcc, _infoItemParam, [_infoItemParam]). {************************************} applyVerificationViaDistinctChannelAccGSM(_parentSelected, _methodInstanceCreated, _offspringListCreated) :- askAny(_parentSelected, infoItemParam, _infoSet), _infoSet = [_infoItemParam], checkDef(VerificationViaDistinctChannelAcc, SGSort), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, {VerificationViaDistinctChannelAccGSM, } VerificationGSM, VerificationViaDistinctChannelAcc, _infoItemParam, [_infoItemParam]). {************************************} applyVerificationViaIdenticalChannelAccGSM(_parentSelected, _methodInstanceCreated, _offspringListCreated) :- askAny(_parentSelected, infoItemParam, _infoSet), _infoSet = [_infoItemParam], checkDef(VerificationViaIdenticalChannelAccGSM, SGSort), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, VerificationViaIdenticalChannelAccGSM, VerificationViaIdenticalChannelAcc, _infoItemParam, [_infoItemParam]). {************************************} {* SOME Designer-defined Methods *} {************************************} { case stmt in apply_method has to be such that any unknown method is treated as designer-defined method:} applyDesignerDefinedGRM (_parentSelected,_methodClass,_methodInstanceCreated,_offspringListCreated, _intentional) :- nl,write('Unknown method.'),nl, write(' Are you applying your own method (y/n): '), readln(_answer), ((_answer == n -> _intentional = no); (_intentional = yes, tellDesignerDefinedGRM(_methodClass), nl,write(' sort: '),readln(_sort), getNode(_currentNodeNum), atomconcat([_methodClass, _currentNodeNum], _methodInstanceCreated), checkDef(_methodInstanceCreated, _methodClass), _nodeNum2 is _currentNodeNum + 1, atomconcat([DesignerDefined, _sort, _nodeNum2], _offspring), checkDef(_offspring, Goal), tellAny(_offspring, sort, [_sort]), getParametersFromDesigner(_offspring), _newNodeNum is 2 + _currentNodeNum, _offspringListCreated = [_offspring], retellAny(NodeCount,counter,_newNodeNum))). getParametersFromDesigner(_offspring) :- nl,write(' parameter name (n for no more): '),readln(_paramName), ((_param == n -> true); (write(' type of '),write(_paramName), write(' (String/Mapping/...: '), readln(_paramType), write(_paramName), write(' value: '), readln(_param), tellAnyCategory(Goal, _paramName,_paramType), checkDef(_param, Mapping), tellAny(_offspring, _paramName, [_param]), getParametersFromDesigner(_offspring))). {************************************} {* SOME AccGSM *} {************************************} {*********** NEW ***********} applyRapidPostingGSM(_parentSelected, _methodInstanceCreated,_offspringListCreated) :- askAny(_parentSelected,infoItemParam,_infoSet), _infoSet = [_infoItemParam], applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, RapidPostingGSM, RapidPosting, _infoItemParam, [_infoItemParam]). applyReduceTransmissionTimeGSM(_parentSelected, _methodInstanceCreated,_offspringListCreated) :- askAny(_parentSelected,infoItemParam,_infoSet), _infoSet = [_infoItemParam], applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, ReduceTransmissionTimeGSM, ReduceTransmissionTime, _infoItemParam, [_infoItemParam]). applyInstallInputDeviceGSM(_parentSelected, _methodInstanceCreated,_offspringListCreated) :- askAny(_parentSelected,infoItemParam,_infoSet), _infoSet = [_infoItemParam], applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, InstallInputDeviceGSM, InstallInputDevice, _infoItemParam, [_infoItemParam]). {************ END NEW ***********} applyConfirmationAccGSM(_parentSelected,_methodInstanceCreated,_offspringListCreated) :- askAny(_parentSelected,infoItemParam,_infoSet), _infoSet = [_infoItemParam], checkDef(ConfirmationAcc, SGSort), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, ConfirmationAccGSM, ConfirmationAcc, _infoItemParam, [_infoItemParam]). {************************************} { TODO: specialize ResourceAssignmentMethod to deal with Ver,Cer } applyCertificationAccGSM(_parentSelected,_methodInstanceCreated,_offspringListCreated) :- askAny(_parentSelected, infoItemParam, _infoSet), _infoSet = [_infoItemParam], checkDef(CertificationAcc, SGSort), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, CertificationAccGSM, CertificationAcc, _infoItemParam, [_infoItemParam]). {************************************} { TODO: specialize ResourceAssignmentMethod to deal with Ver,Cer } applyValidationAccGSM(_parentSelected,_methodInstanceCreated,_offspringListCreated) :- askAny(_parentSelected, infoItemParam, _infoSet), _infoSet = [_infoItemParam], checkDef(ValidationAcc, SGSort), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, ValidationAccGSM, ValidationAcc, _infoItemParam, [_infoItemParam]). {************************************} { TODO: specialize ResourceAssignmentMethod to deal with Ver,Cer } applyCheckSumConsistencyCheckingAccGSM(_parentSelected,_methodInstanceCreated,_offspringListCreated) :- askAny(_parentSelected, infoItemParam, _infoSet), _infoSet = [_infoItemParam], checkDef(CheckSumConsistencyCheckingAcc, SGSort), applyAnyMethod(_parentSelected, _methodInstanceCreated, _offspringListCreated, CheckSumConsistencyCheckingAccGSM, CheckSumConsistencyCheckingAcc, _infoItemParam, [_infoItemParam]). {**************************************************************************} {* T E L L F O R A B O V E M E T H O D S *} {**************************************************************************} { Assign higher and lower priority attr values to priorityInstance in Priority} tellPriorityRequirement(_instance,_higherParent, _lowerParent) :- tellAny(_instance, higherPriority, [_higherParent]), tellAny(_instance, lowerPriority, [_lowerParent]). {************************************} {************************************} { Assign val to the argument attribute of _argumentGoal in Argument} tellArgument(_argumentGoal,_val) :- tellAny(_argumentGoal, argument, [_val]). {************************************} { Assign one statementName from statementNameList to the argument attribute of one offspring in offspringListCreated} tellConjunctiveArguments([],[]). tellConjunctiveArguments([_offspringListH|_offspringListT], [_statementNameListH|_statementNameListT]) :- tellArgument(_offspringListH, _statementNameListH), tellConjunctiveArguments(_offspringListT, _statementNameListT). {************************************} tellSortAndParameters(_offspring,_tellableSortAndParameters) :- write(' tellSortAndParameters: offspring='),write(_offspring),write(' _tellableSortAndParameters='),write(__tellableSortAndParameters), askNodeType(_offspring, _nodeType), deselect(_offspring,_goal,_answer),display(_goal), ((_answer==no -> _L1 = ['Individual ',_goal, ' in ',_nodeType,' with ', _tellableSortAndParameters, ' ','end ', ' ',_goal, ' ']); (_L1 = ['Individual ',_goal, ' in Goal!offspring with ', _tellableSortAndParameters, ' end ', ' ', _goal, ' '])), atomconcat(_L1,_W1), { construct new attribute definition } appendToFile(_W1), name(_W1,_U1), getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,TELL,[_U1]), ipcanswer(_s1,_c1,_r1)), write(_c1),display(_r1),write('tellSortAndParameters...'). {************************************} tellAuthority(_offspring, _authority) :- tellAny(_offspring, authority, _authority). {************************************} {************************************} tellGuideline(_offspring, _guideline) :- tellAny(_offspring, guideline, _guideline). {************************************} { Add constraint to the class of infoItemParam:} tellConstraint(IndependentSubclassGDM, _infoItemParam) :- write(' tellConstraint: infoItemParam='),write(_infoItemParam), atomconcat(['$forall c1/MetaClass forall c2/MetaClass ', 'forall i1/',_infoItemParam, 'forall t/TimeInterval', '(IsA(c1 ',_infoItemParam, ' Always) and ', '(IsA(c2 ',_infoItemParam, ' Always) and ', '(InstanceOf(i1,c1,t) and', '(InstanceOf(i1,c2,t) ->', 'IDENTICAL(c1,c2,t)'], _constraint), askAny(_infoItemParam,constraint, _constraintSetReturned), union([_constraint],_constraintSetReturned, _constraintSet), genTellableAttrList('constraint',1,_constraintSet,_attrValSet), askContainingClassList(_infoItemParam, _inList), convertListToString(_inList, _inVal), _L1 = ['Individual ',_infoItemParam, ' in ', _inVal, ' with constraint ', _attrValSet,' ','end ', ' ', _infoItemParam, ' '], atomconcat(_L1,_W1), { construct new attribute definition } appendToFile(_W1), name(_W1,_U1), getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,TELL,[_U1]), ipcanswer(_s1,_c1,_r1)), write(_c1),display(_r1),write('tellConstraint...'). tellConstraint(MigratorySubclassGDM, _infoItemParam) :- write(' tellConstraint: infoItemParam='),write(_infoItemParam), atomconcat(['$forall c1/MetaClass exists c2/MetaClass ', 'forall i1/',_infoItemParam, 'forall t1/TimeInterval', 'exists t2/TimeInterval', '(IsA(c1 ',_infoItemParam, ' Always) and ', '(IsA(c2 ',_infoItemParam, ' Always) and ', '(InstanceOf(i1,c1,t1) ->', '(InstanceOf(i1,c2,t2)'], _constraint), askAny(_infoItemParam,constraint, _constraintSetReturned), union([_constraint],_constraintSetReturned, _constraintSet), genTellableAttrList('constraint',1,_constraintSet,_attrValSet), askContainingClassList(_infoItemParam, _inList), convertListToString(_inList, _inVal), _L1 = ['Individual ',_infoItemParam, ' in ', _inVal, ' with constraint ', _attrValSet,' ','end ', ' ', _infoItemParam, ' '], atomconcat(_L1,_W1), { construct new attribute definition } appendToFile(_W1), name(_W1,_U1), getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,TELL,[_U1]), ipcanswer(_s1,_c1,_r1)), write(_c1),display(_r1),write('tellConstraint...'). {************************************} {************************************} { methodClass in MetaClass isA GoalRefinementMethod:} tellDesignerDefinedGRM(_methodClass) :- write(' tellDesignerDefinedGRM: methodClass='),write(_methodClass), _L1 = ['Individual ',_methodClass, ' in MetaClass isA DesignerDefinedGRM with ', 'end ', ' ', _methodClass, ' '], atomconcat(_L1,_W1), { construct new attribute definition } appendToFile(_W1), name(_W1,_U1), getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,TELL,[_U1]), ipcanswer(_s1,_c1,_r1)), write(_c1),display(_r1),write('tellConstraint...'). {************************************} {**************************************************************************} {* G E N E R A L A S K F O R A B O V E M E T H O D S *} {**************************************************************************} {************************************} {************************************} {************************************} askNodeType(_offspring, _nodeType) :- nl,write(' askNodeType('),display(_offspring), write(', '),display(_nodeType),write(')'), askContainingClassList(_offspring,_containingClassList), {write(' proceed?'),readln(_),} _containingClassList = [_nodeType1|_], {APR8:KLC, HERE} deselect(_nodeType1,_nodeType,_dummy), write(' ---> '),display(_nodeType),nl . {************************************} askContainingClassList(_Entity, _inList) :- getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[get_object([_Entity/objname])]), ipcanswer(_sender,_completion,_return)), getClasses(_return,_inList). {In fact, the name should be getContainingClasses} {************************************} askSuperclassList(_class, _isAList) :- {not subclasses} write(' askSuperclassList: class='),display(_class),write(' isAList='),display(_isAList), getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[get_object([_class/objname])]), ipcanswer(_sender,_completion,_return)), display(_return), getSuperclasses(_return,_isAList), write(' isAList='),display(_isAList), display(_answer),write(' askIsA...'). {************************************} { Given a list, convert it to a string:} convertListToString([], ''). convertListToString([_H|_T], _string) :- write(' convertListToString: H='),display(_H),write(' T='),display(_T), convertListToString(_T, _stringT), atomconcat([_H, ' ', _stringT], _string), display(_string),write(' convertListToString...'). {**************************************} {* END OF GENERAL METHODS (phase II) *} {**************************************} {**************************************************************************} {* C O R R E L A T I O N R U L E *} {**************************************************************************} getEcrTList([],[]). getEcrTList([_ecrListH|_T],_ecrTList) :- write('getEcrTList(['),display(_ecrListH), write('|'),display(_T), display(_ecrTList),write(')'), {write('proceed?'),readln(_dummy),} askAny(_ecrListH,infoItemParam,_infoItemParamList), (((_infoItemParamList == [Transmission]) -> (_gAndlt = [[_ecrListH,negSub]])); (_gAndlt = [])), getEcrTList(_T,_ecrTList1), append(_gAndlt,_ecrTList1,_ecrTList), write(' ---> '),display(_ecrTList). {* Depending on the size of both correlation rules and NFRs as well as search would become important: CR first or NFR first. given a current offspring, _leaf in SG, _goalList becomes: all _goal in NFR such that (exists m in _goal.justifyingMethod such that m in GSM) and NO: (_leaf.infoItemParam isA _goal.infoItemParam or) (omit NO test for now) YES:(_goal.infoItemParam isA _leaf.infoItemParam); for each _g in _goalList: get its _sort; call implicitUpwardSimpleCorrelationTable (_methodClass, _sort, _linkType); _goalAndLinkType = [_g, _linkType]; append(_goalAndLinkType, _goalAndLinkTypeList1, _goalAndLinkTypeList) *} correlateAndLabel (_leaf, InstallInputDeviceGSM,_parentSelected) :- nl,nl,nl, write(' I M P L I C I T C O R R E L A T I O N R U L E'),nl, write('correlateAndLabel (offspring: '),display(_leaf), write(', methodClass: '),write(InstallInputDeviceGSM), write(', parent: '),display(_parentSelected), write(')'),nl, nl,write(' UPWARD CORRELATION:'),nl,nl, {find all instances of EquipmentCostRequirement,_ecrList; find those whose parameter is Transmission, _ecrTList; for each _goal in _ecrTList: construct _goalAndLinkTypeListT <- [_goal,negSub]; append(_goalAndLinkTypeListH, _goalAndLinkTypeListT, _goalAndLinkType)} askInstances(EquipmentCostRequirement, _ecrList), write(' after askInstances... ecrList = '),display(_ecrList), getEcrTList(_ecrList,_goalAndLinkTypeList), write(' after getEcrTList... goalAndLinkTypeList = '),display(_goalAndLinkTypeList), recursiveUpwardLabel (_goalAndLinkTypeList, _leaf), write('correlateAndLabel done .........'). correlateAndLabel (_leaf, _methodClass,_parentSelected) :- nl,nl,nl, write(' I M P L I C I T C O R R E L A T I O N R U L E'),nl, write('correlateAndLabel (offspring: '),display(_leaf), write(', methodClass: '),display(_methodClass), write(', parent: '),display(_parentSelected), write(')'),nl, askIsA(_methodClass, GAM, _answer), ( ((_answer == yes) -> true); (askIsA(_methodClass, GSM, _ans), ( ((_ans == yes) -> ( nl,write(' UPWARD CORRELATION:'),nl,nl, implicitUpwardSimpleCorrelationRule (_leaf, _methodClass, _gAndLTList1,_parentSelected), implicitComplexCorrelationRule(_leaf, _parentSelected, _gAndLTList2), append (_gAndLTList1, _gAndLTList2, _goalAndLinkTypeList), recursiveUpwardLabel (_goalAndLinkTypeList, _leaf) )); ( nl,nl,write(' DOWNWARD CORRELATION:'),nl, implicitDownwardSimpleCorrelationRule (_leaf, _methodClass, _leafAndLTList3,_parentSelected), write(' after implicitDownwardSimpleCorrelationRule ... leafAndLTList3 = '), display(_leafAndLTList3), implicitComplexCorrelationRule(_leaf, _parentSelected, _leafAndLTList4), append (_leafAndLTList3, _leafAndLTList4, _leafAndLinkTypeList5), write(' after append ... leafAndLinkTypeList5 = '), display(_leafAndLinkTypeList5), recursiveDownwardLabel (_leafAndLinkTypeList5, _leaf) )))), write('correlateAndLabel done .........'). {************************************} recursiveUpwardLabel ([], _). recursiveUpwardLabel ([_goalAndLinkTypeListH | _goalAndLinkTypeListT], _leaf) :- nl,write('recursiveUpwardLabel (goalAndLinkTypeListH: '), display(_goalAndLinkTypeListH), write(', goalAndLinkTypeListT: '),display(_goalAndLinkTypeListT), write(', leaf: '),display(_leaf), write(')'),nl, _goalAndLinkTypeListH = [_goal, _linkType], integrate(implicitCorrelate, _goal, _linkType, _leaf), recursiveUpwardLabel(_goalAndLinkTypeListT, _leaf). {************************************} implicitUpwardSimpleCorrelationRule (_leaf, ResourceAssignmentGSM, [],_parentSelected). implicitUpwardSimpleCorrelationRule (_leaf, _methodClass, _gAndLTList1,_parentSelected) :- askRelatedNFRs(_leaf, _goalList1), length(_goalList1, _L),{write('length='),display(_L),} ((_L == 1); {leaf NFR for current SG ((_goalList1 == [_parentSelected]);} (setDiff(_goalList1, _parentSelected, _goalList), askSort(_leaf, _leafSort), recursiveUpwardTableLookUp (_goalList, _leafSort, _gAndLTList1))). {************************************} recursiveUpwardTableLookUp ([], _, []). recursiveUpwardTableLookUp ([], ResourceAssignmentGSM, []). recursiveUpwardTableLookUp ([_gListH | _gListT], _leafSort, _gAndLinkTypeList) :- askSort(_gListH, _pSort), getTable(tableImplicitSimpleCorrelation,_leafSort,_pSort,_linkType), ((_linkType == [] -> _goalAndLinkType = []); (_goalAndLinkType = [_gListH, _linkType])), recursiveUpwardTableLookUp (_gListT, _leaf, _gAndLinkTypeList1), append([_goalAndLinkType], _gAndLinkTypeList1, _gAndLinkTypeList). {************************************} {************************************} recursiveDownwardLabel ([], _). recursiveDownwardLabel ([_leafAndLinkTypeListH | _leafAndLinkTypeListT], _parent) :- nl,write('recursiveDownwardLabel (leafAndLinkTypeListH: '),display(_leafAndLinkTypeListH), write(', leafAndLinkTypeListT: '),display(_leafAndLinkTypeListT), write(', parent: '),display(_parent), write(')'),nl, _leafAndLinkTypeListH = [_leaf, _linkType], integrate(implicitCorrelate, _parent, _linkType, _leaf), recursiveDownwardLabel(_leafAndLinkTypeListT, _parent). {************************************} implicitDownwardSimpleCorrelationRule (_leaf, _methodClass, _leafAndLTList1,_parent) :- askRelatedSGs(_leaf, _leafList1), ((_leafList1 == [_leaf]); (setDiff(_leafList1, _leaf, _leafList), askSort(_leaf, _pSort), recursiveDownwardTableLookUp (_leafList, _pSort, _leafAndLTList1))). {************************************} recursiveDownwardTableLookUp ([], _, []). recursiveDownwardTableLookUp ([], ResourceAssignmentGSM, []). recursiveDownwardTableLookUp ([_leafListH | _leafListT], _pSort, _leafAndLinkTypeList) :- askSort(_leafListH, _leafSort), getTable(tableImplicitSimpleCorrelation,_leafSort,_pSort,_lT), ((_lT == [] -> _leafAndLinkType = []); (_lT = [_linkType], _leafAndLinkType = [[_leafListH, _linkType]])), recursiveDownwardTableLookUp (_leafListT, _pSort, _leafAndLinkTypeList1), append(_leafAndLinkType, _leafAndLinkTypeList1, _leafAndLinkTypeList). {************************************} askRelatedNFRs(_leaf,_goalList):- nl,write('askRelatedNFRs: leaf='),display(_leaf), {given a current offspring, _leaf in SG, _goalList becomes: all _goal in NFR such that (exists m in _goal.justifyingMethod such that m in GSM) and (_goal.infoItemParam transitive_isA _leaf.infoItemParam)} {To test askRelatedNFRs: load testAskRelated.sml, then invoke via askRelatedNFRs(LeafSG,_goalList) See testAskRelated.sml for expected results.} {find _leaf.infoItemParam} getAttributeValues(_leaf,infoItemParam,_leafInfoItemParamValueList), write(' leafInfoItemParamValueList '),display(_leafInfoItemParamValueList),nl, ((_leafInfoItemParamValueList = [_leafInfoItemParamValue]) -> (true); (write(' Caution, leafInfoItemParamValueList not single-valued '), write(' leafInfoItemParamValueList '),display(_leafInfoItemParamValueList),nl )), {find prelimGoalList == set of _goalp in NFR (exists m in _goalp.justifyingMethod such that m in GSM) } askRelatedNFRsFindPrelimGoalList(_prelimGoalList), write(' prelimGoalList '),display(_prelimGoalList),nl, {for each goal in prelimGoalList: find _goal.infoItemParam; if (_goal.infoItemParam transitive_isA _leaf.infoItemParam) then add _goal to goalList} askRelatedNFRsTrimPrelimGoalList(_prelimGoalList,_leafInfoItemParamValue, _goalList), nl,display(_goalList),write(' askRelatedNFRs...'). askRelatedNFRsFindPrelimGoalList(_prelimGoalList):- {find prelimGoalList == set of _goalp in NFR (exists m in _goalp.justifyingMethod such that m in GSM) } {Future optimisation: if call frequently, could call following once, them reflect updates} {First apply query.} getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[myjustifyingmethodinaccgsmquery([])]), ipcanswer(_sender,_completion,_SMLFragmentList)), {write(' SMLFragmentList '),write(_SMLFragmentList), } {Filter SMLFragmentList} getEntityNamesFromSMLFragmentList(_SMLFragmentList,_prelimGoalList). {askRelatedNFRsTrimPrelimGoalList(_prelimGoalList,_leafInfoItemParamValue, _goalList):} {for each goal in prelimGoalList: find _goal.infoItemParam; if (_goal.infoItemParam transitive_isA _leafInfoItemParamValue) then add _goal to goalList} askRelatedNFRsTrimPrelimGoalList([],_leafInfoItemParamValue,[]). askRelatedNFRsTrimPrelimGoalList([_prelimGoalListHead|_prelimGoalListTail], _leafInfoItemParamValue,_goalList):- {find _prelimGoalListHead.infoItemParam} getAttributeValues(_prelimGoalListHead,infoItemParam, _prelimGoalListHeadInfoItemParamValueList), {write(' prelimGoalListHeadInfoItemParamValueList '),} {display(_prelimGoalListHeadInfoItemParamValueList),nl,} ((_prelimGoalListHeadInfoItemParamValueList = [_prelimGoalListHeadInfoItemParamValue]) -> (true); (write(' Caution, prelimGoalListHeadInfoItemParamValueList not single-valued '), display(_prelimGoalListHeadInfoItemParamValueList),nl)), {if (_prelimGoalListHeadInfoItemParamValue transitive_isA _leafInfoItemParamValue) then add _prelimGoalListHead to goalList (after processing tail of preliminary list)} askIsA(_prelimGoalListHeadInfoItemParamValue,_leafInfoItemParamValue, _isAAnswer), {write(' prelimGoalListHeadInfoItemParamValue '),} {display(_prelimGoalListHeadInfoItemParamValue),nl,} {write(' isAAnswer '),display(_isAAnswer),nl,} askRelatedNFRsTrimPrelimGoalList(_prelimGoalListTail, _leafInfoItemParamValue,_tailGoalList), ((_isAAnswer == yes) -> (_goalList = [_prelimGoalListHead|_tailGoalList]); (_goalList = _tailGoalList) ). {************************************} askRelatedSGs(_givenNFR,_SGList):- nl,write('askRelatedSGs (givenNFR: '), display(_givenNFR), write(', SGList: '), display(_SGList), write(') '), {given an NFR, _givenNFR, _SGList becomes: all instances sg of SatisificingGoal such that: givenNFR.infoItemParam transitive_isA sg.infoItemParam} {We assume that infoItemParam is single-valued} {To test askRelatedSGs: load testAskRelated.sml, then invoke via askRelatedSGs(NFR1,_SGList) See testAskRelated.sml for expected results.} {find _givenNFR.infoItemParam} getAttributeValues(_givenNFR,infoItemParam,_givenNFRInfoItemParamValueList), write(' givenNFRInfoItemParamValueList '), display(_givenNFRInfoItemParamValueList),nl, ((_givenNFRInfoItemParamValueList = [_givenNFRInfoItemParamValue]) -> (true); (write(' Caution, givenNFRInfoItemParamValueList not single-valued '), write(' givenNFRInfoItemParamValueList '), display(_givenNFRInfoItemParamValueList),nl )), {find prelimSGList == a list the SMLFragments (including the infoItemParam attribute value(s)) of all instancs of SatisificingGoal) } askRelatedSGsFindPrelimSGList(_prelimSGList), write(' prelimSGList '),display(_prelimSGList),nl, {for each SMLFragment (corresponding to satisficing goal sg) in prelimSGList: find _sg.infoItemParam; if (_givenNFR.infoItemParam transitive_isA _goal.infoItemParam) then add _sg to SGList} askRelatedSGsTrimPrelimSGList(_prelimSGList,_givenNFRInfoItemParamValue, _SGList), display(_SGList), write('askRelatedSGs...'). askRelatedSGsFindPrelimSGList(_prelimSGList):- {find prelimSGList == a list the SMLFragments (including the infoItemParam attribute value(s)) of all instancs of SatisificingGoal) } {First apply query.} getstats(_sid,_tid,_CBsid), IpcChannel_call(_sid, ipcmessage(_tid,_CBsid,ASK,[myinfoitemparamofsatisficinggoalquery([])]), {ipcmessage(_tid,_CBsid,ASK,[querySGinfoItemParam([])]), } ipcanswer(_sender,_completion,_SMLFragmentList)), _prelimSGList = _SMLFragmentList, write(' prelimSGList '),display(_prelimSGList). {askRelatedSGsTrimPrelimSGList(_prelimSGList,_givenNFRInfoItemParamValue, _SGList):} {for each SMLFragment (corresponding to satisficing goal sg) in prelimSGList: find _sg.infoItemParam; if (_givenNFR.infoItemParam transitive_isA _goal.infoItemParam) then add _sg to SGList} askRelatedSGsTrimPrelimSGList([],_givenNFRInfoItemParamValue,[]). askRelatedSGsTrimPrelimSGList([_prelimSGListHead|_prelimSGListTail], _givenNFRInfoItemParamValue,_SGList):- {find _prelimSGListHead.infoItemParam} getGivenAttributeValuesFromSMLFragment(infoItemParam,_prelimSGListHead, _prelimSGListHeadInfoItemParamValueList), write(' prelimSGListHeadInfoItemParamValueList '), display(_prelimSGListHeadInfoItemParamValueList),nl, ((_prelimSGListHeadInfoItemParamValueList = [_prelimSGListHeadInfoItemParamValue]) -> (true); (write(' Caution, prelimSGListHeadInfoItemParamValueList not single-valued '), display(_prelimSGListHeadInfoItemParamValueList),nl)), {if (_givenNFRInfoItemParamValue transitive_isA _prelimSGListHeadInfoItemParamValue) then add entity name of _prelimSGListHead to SGList (after processing tail of preliminary list)} write(' prelimSGListHeadInfoItemParamValue '), display(_prelimSGListHeadInfoItemParamValue),nl, askIsA(_givenNFRInfoItemParamValue, _prelimSGListHeadInfoItemParamValue, _isAAnswer), write(' isAAnswer '),display(_isAAnswer),nl, askRelatedSGsTrimPrelimSGList(_prelimSGListTail, _givenNFRInfoItemParamValue,_tailSGList), write(' tailSGList '),display(_tailSGList),nl, ((_isAAnswer == yes) -> ({get EntityName From SMLFragment prelimSGListHead:} arg(1,_prelimSGListHead,_whatClause), arg(1,_whatClause,_prelimSGListHeadEntityName), write(' Adding to list '),display(_prelimSGListHeadEntityName),nl, _SGList = [_prelimSGListHeadEntityName|_tailSGList]); (_SGList = _tailSGList) ). getGivenAttributeValuesFromSMLFragment(_category,_SMLFragment,_valueList):- {Given a category, and an SMLFragment of an entity, valueList becomes a list of the attribute values of the given category.} getAttrDeclListFromSMLFragment(_SMLFragment,_attrdecllist), write(' attrdecllist '),display(_attrdecllist), getAttributeValuesOfGivenCategoryFromAttrDeclList(_attrdecllist, _category,_valueList), display(_valueList). getAttrDeclListFromSMLFragment(_SMLFragment,_attrDeclList):- arg(5,_SMLFragment,_with), arg(1,_with,_attrDeclList). { getAttributeValuesOfGivenCategoryFromAttrDeclList(_attrdecllist,_category,_ans) : _ans contains all the attribute values from each attrdecl, of the given category, in _attrdecllist For each in do From which is attrdecl(,) Get . If _category is a member of then Get from , For each in , If is non-null, append to _ans where is property(,,,) (It is possible that _category will appear in more than one attrcategorylist, so all are examined.) } getAttributeValuesOfGivenCategoryFromAttrDeclList([],_category,[]). getAttributeValuesOfGivenCategoryFromAttrDeclList([_attrdecl|_attrdecllist], _category,_ans) :- write(' getAttributeValuesOfGivenCategoryFromAttrDeclList attrdecl '),nl, display(_attrdecl),nl, write(' attrdecllist '), display(_attrdecllist),nl, nl,write(_category),nl, arg(1,_attrdecl,_attrcategorylist), write(' attrcategorylist '), display(_attrcategorylist),nl, ( {If} (member(_category,_attrcategorylist)) -> {Then} ( arg(2,_attrdecl,_propertylist), write(' propertylist '), display(_propertylist),nl, selectAttributeValues(_propertylist,_ansAttrDecl) { , } { write(' ansAttrDecl '),display(_ansAttrDecl),nl } ) ; {Else} ( _ansAttrDecl = [] { , write(' else '),nl } )), getAttributeValuesOfGivenCategoryFromAttrDeclList(_attrdecllist,_category, _ansAttrDeclList), { write(' need to also get attribute names? '),nl, } append(_ansAttrDecl,_ansAttrDeclList,_ans). {selectAttributeValues(_propertyList,_attributeValueList) : _attributeValueList contains the second argument (where the corresponding first argument is non-nil) of each item in _propertyList} selectAttributeValues([],[]). { Problem: ConceptBase can return ill-formed with a missing value, e.g.: property(,Integer,default,nil). This kind of structure cannot be used as input to the Prolog user interface. However, if untouched by human hands, ConceptBase and Prolog appear to be able to handle it. Ad hoc solution: When there is no first argument, _value is nil (i.e., []). Detect this case, and do not add it to the answer, _ans} selectAttributeValues([_property|_propertyList],_ans) :- { write(' property '),display(_property),nl, } arg(1,_property,_label), arg(2,_property,_value), atomtolist(_label,_labelList), { display(_labelList),nl, } selectAttributeValues(_propertyList,_ansPL), constructAttributeLabelList(_labelList,_value,_ansPL,_ans). { constructAttributeLabelList(_labelList_label,_ansPL,_ans): if _labelList non-nil, set _ans to [_label|_ansPL], otherwise to _ansPL.} constructAttributeLabelList([],_label,_ansPL,_ansPL). constructAttributeLabelList(_labelList,_label,_ansPL,_ans) :- \+(_labelList == nil), { _labelList non-nil } _ans = [_label|_ansPL]. { ******************* } {************************************} implicitComplexCorrelationRule(_, _, []). {************************************} {*** ExplicitCorrelationRule(_parent,_offspring,_methodClass,_linkType)) ***} ExplicitCorrelationRule(_,_,ResourceAssignmentGSM,sup). ExplicitCorrelationRule(_parent,_offspring,RelativePriorityAssignmentGAM, _lt) :- askAny(_offspring, higherPriority, _higherParentList), _higherParentList = [_higherParent], ((_parent == _higherParent -> _lt = sub);_lt = negSub). ExplicitCorrelationRule(_parent,_offspring,RapidPostingGSM,_linkType) :- askAny(_parent, sort, _sortList), _sortList = [_sort], askIsA(_sort, TimelyAccuracy, _ans), ((_ans == yes) -> _linkType = sub);(_linkType = und). ExplicitCorrelationRule(_parent,_offspring, ReduceTransmissionTimeGSM,_linkType) :- askAny(_parent, sort, _sortList), _sortList = [_sort], ((_sort == RapidPosting) -> _linkType = sub); (((_sort == ExternalConfidentiality) -> _linkType = sub); (_linkType = und)). ExplicitCorrelationRule(_parent,_offspring, InstallInputDeviceGSM,_linkType) :- askAny(_parent, sort, _sortList), _sortList = [_sort], ((_sort == ReduceTransmissionTime) -> _linkType = sub); (((_sort == EquipmentCost) -> _linkType = negSub); (_linkType = und)). ExplicitCorrelationRule(_parent,_offspring, SafeguardTransmissionMediumGSM,_linkType) :- askAny(_parent, sort, _sortList), _sortList = [_sort], askIsA(_sort, ExternalConfidentiality, _ans), ((_ans == yes) -> _linkType = sub);(_linkType = und). ExplicitCorrelationRule(_,_,StepwiseSpecializationGRM,eql). ExplicitCorrelationRule(_,_,PolicyManualConsultationGAM,und). ExplicitCorrelationRule(_,_,TrivialManyGAM, sub). ExplicitCorrelationRule(_,_,HigherPriorityAssignmentGAM, sub). ExplicitCorrelationRule(_,_,LowerPriorityAssignmentGAM, negSub). ExplicitCorrelationRule(_,_,ExternalReferencePMCGAM,sub). ExplicitCorrelationRule(_,_,DesignGuidelinePMCGAM,sub). ExplicitCorrelationRule(_,_,AuthorityConsultationGAM,sub). ExplicitCorrelationRule(_,_,VitalFewGAM,sub). ExplicitCorrelationRule(_parent,_offspring,VitalFewTrivialManyGAM,_lt) :- askAny(_offspring, higherPriority, _higherParentList), _higherParentList = [_higherParent], ((_parent == _higherParent -> _lt = sub);_lt =sub). ExplicitCorrelationRule(_parent,_offspring,_methodClass,_linkType) :- askSort(_parent, _pSort), askSort(_offspring, _oSort), getTable(tableImplicitSimpleCorrelation,_oSort,_pSort,_linkType), ExplicitCorrelationRule(_, _, _, und). {************************************} {*******************************************} {* END OF CORRELATION RULE *} {*******************************************} { ******************************************************************* } { This query is executed when MappingClient.pro is compiled. * It has the following tasks: * (1) consult the files needed to interface with the IPC routines and * additional Prolog code * (i.e., IpcParameters.pro, IpcChannelAccess.pro, BimIpc.pro, apply.pro) * (2) connect MappingClient.pro to the ConceptBase server as a Prolog client * (3) load ConceptBase .sml files corresponding to the * (i) main schema (minimalTestSchema.sml) * (ii) example demo definitions (isATest.sml) * (iii) query classes needed to query the KB (SCQuery.sml) * This allows the startup of the mapping assistant to be automatic, * without intervention by the user. } {*****************************************************************************} {* tableDef.pro: *} {*****************************************************************************} ?- assert( mytables(tableCompositeEffect, [[S, [[S, S], [D, C], [U, U], [C, C], [Upos, S], [Uneg, Squestion] ]], [D, [[S, C], [D, D], [U, U], [C, C], [Upos, Dquestion], [Uneg, D] ]], [U, [[S, U], [D, U], [U, U], [C, C], [Upos, Uquestion], [Uneg, Uquestion] ]], [C, [[S, C], [D, C], [U, C], [C, C], [Upos, C], [Uneg, C] ]], [Upos, [[S, S], [D, Dquestion], [U, U], [C, C], [Upos, Uquestion], [Uneg, question] ]], [Uneg, [[S, Squestion], [D, D], [U, Uquestion], [C, C], [Upos, question], [Uneg, Uquestion] ]] ] ) ), assert( mytables(tableAND, [[S, [[S, S], [D, D], [U, U], [C, C], [Upos, Uquestion], [Uneg, Uquestion] ]], [D, [[S, D], [D, D], [U, D], [C, D], [Upos, D], [Uneg, D] ]], [U, [[S, U], [D, D], [U, U], [C, Uquestion], [Upos, Uquestion], [Uneg, Uquestion] ]], [C, [[S, C], [D, D], [U, Uquestion], [C, C], [Upos, Cquestion], [Uneg, Cquestion] ]], [Upos, [[S, S], [D, D], [U, U], [C, Cquestion], [Upos, Uquestion], [Uneg, Uquestion] ]], [Uneg, [[S, Uquestion], [D, D], [U, Uquestion], [C, Cquestion], [Upos, Uquestion], [Uneg, Uquestion] ]] ] ) ), assert( mytables(tableOR, [[S, [[S, S], [D, S], [U, S], [C, S], [Upos, S], [Uneg, S] ]], [D, [[S, S], [D, D], [U, U], [C, C], [Upos, Uquestion], [Uneg, Uquestion] ]], [U, [[S, S], [D, U], [U, U], [C, Uquestion], [Upos, Uquestion], [Uneg, Uquestion] ]], [C, [[S, S], [D, C], [U, Uquestion], [C, C], [Upos, Uquestion], [Uneg, Uquestion] ]], [Upos, [[S, S], [D, Uquestion], [U, U], [C, Uquestion], [Upos, Uquestion], [Uneg, Uquestion] ]], [Uneg, [[S, S], [D, Uquestion], [U, Uquestion], [C, Uquestion], [Upos, Uquestion], [Uneg, Uquestion] ]] ] ) ), assert( mytables(tableSingleIndividualEffect, [[S, [[sub, Upos], [sup, S], [negSub, Uneg], [negSup, D], [und, U], [posUnd, U], [negUnd, U], [eql, S] ]], [D, [[sub, D], [sup, Uneg], [negSub, S], [negSup, Upos], [und, U], [posUnd, U], [negUnd, U], [eql, D] ]], [C, [[sub, question], [sup, question], [negSub, question], [negSup, question], [und, U], [posUnd, U], [negUnd, U], [eql, question] ]], [U, [[sub, U], [sup, U], [negSub, U], [negSup, U], [und, U], [posUnd, U], [negUnd, U], [eql, U] ]] ] ) ), assert( mytables(tableImplicitSimpleCorrelation, [[RapidPosting, [[TimelyAccuracy, sub], [Security, []], [Cost, []], [UserFriendliness, []] ]], [ReduceTransmissionTime, [[RapidPosting, sub], [ExternalConfidentiality, [sub]], [Security, []], [Cost, []], [UserFriendliness, []] ]], [InstallInputDevice, [[ReduceTransmissionTime, sub], [EquipmentCost, [negSub]], [Security, []], [Cost, []], [UserFriendliness, []] ]], [SafeguardTransmissionMedium, [[ExternalConfidentiality, sub], [Security, []], [Cost, []], [UserFriendliness, []] ]], [ConfirmationAcc, [[Accuracy, sub], [Security, []], [Cost, []], [UserFriendliness, negSub] ]], [VerificationAcc, [[Accuracy, sub], [Security, []], [Cost, []], [UserFriendliness, negSub] ]], [VerificationViaDistinctChannelAcc, [[Accuracy, sub], [Security, []], [Cost, []], [UserFriendliness, negSub] ]], [CertificationAcc, [[Accuracy, sub], [Security, []], [Cost, []], [UserFriendliness, negSub] ]], [ValidationAcc, [[Accuracy, sub], [Security, []], [Cost, []], [UserFriendliness, negSub] ]], [MutualIdentificationAcc, [[Accuracy, []], [Security, sub], [Cost, negSub], [UserFriendliness, []] ]], [DisguiseSec, [[Accuracy, []], [Security, sub], [Cost, negSub], [UserFriendliness, []] ]], [CasualModificationUF, [[Accuracy, negSub], [Security, []], [Cost, []], [UserFriendliness, sub] ]], [DisplayDeviceUpgradeUF, [[Accuracy, []], [Security, []], [Cost, negSub], [UserFriendliness, sub] ]] ] ) ), { applying negative or neutral AccGSM is treated as error: } {assert( mytables(tableExplicitSimpleCorrelation, [[RapidPosting, [[TimelyAccuracy, sub], [Security, []], [Cost, []], [UserFriendliness, []] ]], [ReduceTransmissionTime, [[RapidPosting, sub], [ExternalConfidentiality, [sub]], [Security, []], [Cost, []], [UserFriendliness, []] ]], [InstallInputDevice, [[ReduceTransmissionTime, sub], [EquipmentCost, [negSub]], [Security, []], [Cost, []], [UserFriendliness, []] ]], [SafeguardTransmissionMedium, [[ExternalConfidentiality, sub], [Security, []], [Cost, []], [UserFriendliness, []] ]], [ConfirmationAccGSM, [[Accuracy, sub], [Security, []], [Cost, []], [UserFriendliness, []] ]], [VerificationAccGSM, [[Accuracy, sub], [Security, []], [Cost, []], [UserFriendliness, []] ]], [CertificationAccGSM, [[Accuracy, sub], [Security, []], [Cost, []], [UserFriendliness, []] ]], [MutualIdentificationSecGSM, [[Accuracy, []], [Security, sub], [Cost, []], [UserFriendliness, []] ]], [DisguiseSecGSM, [[Accuracy, []], [Security, sub], [Cost, []], [UserFriendliness, []] ]], [CasualModificationUFGSM, [[Accuracy, []], [Security, []], [Cost, []], [UserFriendliness, sub] ]], [DisplayDeviceUpgradeUFGSM, [[Accuracy, []], [Security, []], [Cost, []], [UserFriendliness, sub] ]] ] ) ), } {* OTHER INITIALISATION *} consult('$CB_HOME/CB_Exe/KSV_Exe/IpcParameters'), consult('$CB_HOME/CB_Exe/KSV_Exe/IpcChannelAccess'), consult('$CB_HOME/CB_Exe/KSV_Exe/BimIpc'), consult('$MAP_HOME/apply') , {THIS_IS_TEST(x),} {error message gets printed for this} {connectCBserver('telos.ai.toronto.edu',4001)} {KLC} {connectCBserver('telos.ai.toronto.edu',4444)} {KLC} {connectCBserver('telos.ai.toronto.edu',4004)} {KLC} {connectCBserver('telos.ai.toronto.edu',4400)} {KLC} {connectCBserver('telos.ai.toronto.edu',4440)} {KLC} {connectCBserver('telos.ai.toronto.edu',4040)} {KLC} {connectCBserver('telos.ai.toronto.edu',4441)} {KLC} {connectCBserver('telos.ai.toronto.edu',4111)} {KLC} {connectCBserver('telos.ai.toronto.edu',4112)} {KLC} {connectCBserver('telos.ai.toronto.edu',4113)} {KLC} {connectCBserver('telos.ai.toronto.edu',4114)} {KLC} {connectCBserver('telos.ai.toronto.edu',4115)} {KLC} {connectCBserver('telos.ai.toronto.edu',4116)} {KLC} {connectCBserver('telos.ai.toronto.edu',4117)} {KLC} {connectCBserver(telos,4002) } {BN} connectCBserver(telos,4001) {BN} .