User Tools

Site Tools


magik-demo:developer:generalization-howitworks

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

====== Generalization algorithm ====== After the elaboration MAGIK, will answer if the query given by the user, is complete or not with respect to schema constraints and TC-statements. \\ If it is not complete, MAGIK will try to generate the generalized and specialized query. \\ In this page it is explained how works the generalization algorithm {{ :magik-demo:developer:generalization.png?nolink&700 |}} ===== Phase 1: generation of the DLV program ===== The first of the algorithm is to "translate" query and schema in a DLV program. This operation is done by the class [[magik-demo:developer:class:core:programgenerator|ProgramGenerator]] in **core** package Translation depends on which kind of constraints are selected in the schema: ==== 1. TC-QC plain ==== If we have only TC-Statements and query the translation is straightforward. \\ First it will be created the canonical database. After that, the tc-statement is translated following the <code> CANONICAL_DATABASE_OVER_THE_IDEAL_SCHEMA. pupil(frozen_P_name,"1",frozen_P_code). TC_STATEMENTS. pupil_a(Name,Level,Code) :- pupil(Name,Level,Code). TESTING_QUERY_OVER_THE_AVAILABLE_SCHEMA. Q_a :- pupil_a(frozen_P_name,"1",frozen_P_code). </code> ==== 2. TC-QC under FDCs ==== ==== 3. TC-QC under FKs ==== ==== 4. TC-QC under FKs + FDCs ==== <code> CANONICAL_DATABASE_OVER_THE_IDEAL_SCHEMA. val(frozen_P_name,frozen_P_name). val(frozen_P_code,frozen_P_code). val(frozen_constant_1,"1"). pupil(frozen_P_name,frozen_constant_1,frozen_P_code). TC_STATEMENTS. pupil_a(Name_0,Level_1,Code_2) :- pupil(Name_0,Level_1,Code_2),val(Name_0,Name),val(Level_1,Level),val(Code_2,Code). TESTING_QUERY_OVER_THE_AVAILABLE_SCHEMA. Q_a :- pupil_a(P_name_3,Constant_1_4,P_code_5),val(frozen_P_name,P_name_6),val(P_name_3,P_name_6),val(Constant_1_4,"1"),val(frozen_P_code,P_code_7),val(P_code_5,P_code_7). val(X1,"a") v val(X1,"b") :- pupil(X0,X1,X2). :- val(X,Y), val(X,Z), X != Y, X != Z, Y != Z. FINITE_DOMAIN_CONSTRAINTS_RULES. pupil(Y1,f_pupil_1(V_Y1),f_pupil_2(V_Y1)) :- learns(Y1,X2), not auxpupil(V_Y1),val(Y1,V_Y1). val(f_pupil_1(V_Y1),f_pupil_1(V_Y1)) :- learns(Y1,X2), not auxpupil(V_Y1),val(Y1,V_Y1). val(f_pupil_2(V_Y1),f_pupil_2(V_Y1)) :- learns(Y1,X2), not auxpupil(V_Y1),val(Y1,V_Y1). auxpupil(V_Y1):-pupil(Y1,Z1,Z2),original(Z1),original(Z2),val(Y1,V_Y1). GROUND_TERMS_OF_DEPTH_ZERO. original(frozen_P_name). original(1). original(frozen_P_code). </code> <note tip>For more information about DLV please visit the [[http://www.dlvsystem.com/html/DLV_User_Manual.html|User Manual]]</note>

magik-demo/developer/generalization-howitworks.1374573901.txt.gz ยท Last modified: 2017/07/06 15:24 (external edit)