Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Using Graph Matching: Program Recognition of the Selection Sort Algorithm Ronald Finkbine, Ph.D. Department of Computer Science Indiana University Southeast [email protected] INTRODUCTION • • • • Program Understanding Existing Software Reuse and Recover Documentation [1] (define-routine sort [2] (parameters (inout numbers) (in count)) [9] (assign i 0) [10] (loop [11] (eval (gt i (minus count 1))) [12] (assign big i) [13] (assign j (plus i 1)) [14] (loop [15] (eval (gt j count)) [16] (if [17] (eval (gt (select numbers (key j) (field)) [18] (select numbers (key big) (field))) [19] (assign big j)) [20] (assign j (plus j 1))) [21] (assign temp (select numbers (key big) (field))) [22] (assign (select numbers (key big) (field)) [23] (select numbers (key i) (field)) [24] (assign (select numbers (key i) (field)) temp) [25] (assign i (plus i 1)))) INTERMEDIATE REPRESENTATION (generalNode 1) (assignNode 1) (operandNode 1) (identifierNode 1 “x”) (expressionNode 1) (operandNode 2) (integerLiteralNode 1 “1”) DERIVATION TREE -> x = 1 (deftemplate argument_node (field number (type INTEGER) (default 0)) (field next_argument (type INTEGER) (default 0)) (field operand (type INTEGER) (default 0))) (defrule exp_01 "detect_exp_1“ (declare (salience ?*salience_2*) (expression_node (number ?exp_nr) (operator no_op) (operand_1 ?exp_op)) (integer_literal_node (number ?il_nr) (value 1) (operand ?exp_op)) => (if (eq ?*test_rule* "exp_01") then (assert (successful_test exp_01))) (assert (spec_exp (exp_nr ?exp_nr) (type_exp exp_1)))) CLIPS-template and rule (generalNode (number 1) (sibling 0) (address "2.10.5") (node_type assignNode)) (assignNode (number 1) (lhsNode 1) (rhsNode 1) (generalNodeParent 1)) (identifierNode (number 1) (operand 2) (name "x")) (expressionNode (number 1) (operand_1 2)) (integerLiteralNode) (number 1) (operand 2) (value 1)) FACT LIST FIRING SET RULE PREFIX RULE NUMBERS First def 00 gen 00 exp 00, 02, 07, 09, 10, 11, 17 struc 00 eval 01, 02 var 00, 02, 04, 05, 06, 07, 08 swap 00, 01 loop 00, 01, 02, 03 min 00, 01 ssort 00, 01 Second Third Complete SELECTION SORT RULES FIRED RULE RULE NAME STATEMENTS var_00 detect_assign_sca_inc_1_self 21, 25 var_02 detect_assign_sca_array_bas e_c 9 var_04 detect_assign_sca_inc_1_oth er 13 var_05 detect_assign_sca_sca 12, 19 var_06 detect_assign_sca_strucid 21 var_07 detect_assign_strucid_strucid 22, 23 var_08 detect_assign_strucid_sca 24 swap_00 detect_potential_id_id_swap 21-24 swap_01 detect_actual_id_id_swap 21-24 ASSIGNMENT RECOGNITION ALGORITHM FIRINGS Selection sort 50 Quicksort 89 Heapsort 151 TOTAL RULE FIRINGS Attached Database GUI PLAN Library Concentrate on numerical/scientific Auto generate rules for model FUTURE