Source Code Cross Referenced for TranslateQuantifier.java in  » Testing » KeY » de » uka » ilkd » key » proof » decproc » translation » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » KeY » de.uka.ilkd.key.proof.decproc.translation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // This file is part of KeY - Integrated Deductive Software Design
002:        // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003:        //                         Universitaet Koblenz-Landau, Germany
004:        //                         Chalmers University of Technology, Sweden
005:        //
006:        // The KeY system is protected by the GNU General Public License. 
007:        // See LICENSE.TXT for details.
008:        //
009:        //
010:
011:        package de.uka.ilkd.key.proof.decproc.translation;
012:
013:        import org.apache.log4j.Logger;
014:
015:        import de.uka.ilkd.key.logic.op.*;
016:        import de.uka.ilkd.key.proof.decproc.DecisionProcedureSmtAufliaOp;
017:        import de.uka.ilkd.key.proof.decproc.smtlib.ConnectiveFormula;
018:        import de.uka.ilkd.key.proof.decproc.smtlib.Formula;
019:        import de.uka.ilkd.key.proof.decproc.smtlib.QuantifierFormula;
020:        import de.uka.ilkd.key.proof.decproc.smtlib.TermVariable;
021:
022:        /** This class represents the translation rule for <tt>Quantifier</tt>s.<br>
023:         * They are supported only in AUFLIA, not in QF_AUFLIA. 
024:         * <p> 
025:         * A <tt>Quantifier</tt> is translated into a <tt>QuantifierFormula</tt>, if it is an ALL or 
026:         * an EXISTS quantifier. Thereby, its bound variables will also be translated
027:         * 
028:         * @author akuwertz
029:         * @version 1.2,  11/09/2006  (Added type predicates for quantified variables)
030:         */
031:
032:        public class TranslateQuantifier implements  IOperatorTranslation {
033:
034:            /* Additional fields */
035:
036:            /** A <tt>Logger</tt> for logging and debugging operator translation */
037:            private static final Logger logger = Logger
038:                    .getLogger(TranslateQuantifier.class.getName());
039:            // Logger is created hierarchical to inherit configuration and behaviour from parent
040:
041:            /* String constants for error messages */
042:            private static final String translationFailure = "Translation of quantifier failed due to illegal arguments on visitor stack:\n";
043:            private static final String failureCauseNoFormula = " expected an argument of class Formula (SMT-LIB) and found the object:\n";
044:            private static final String unsupportedQuantifier = "Translation of quantifier failed!";
045:            private static final String unsupportedOperator = "\nCause: this quantifier operator is not supported!";
046:            private static final String unsupportedVar = "\nCause: the quantified variable cound not be translated: ";
047:            private static final String varTransFailed = "\nThe following exception was thrown during variable translation: \n";
048:
049:            /* Public methods */
050:
051:            /* (non-Javadoc)
052:             * @see de.uka.ilkd.key.proof.decproc.translation.IOperatorTranslation#isApplicable(de.uka.ilkd.key.logic.op.Operator)
053:             */
054:            public boolean isApplicable(Operator op) {
055:                return op instanceof  Quantifier;
056:            }
057:
058:            /* (non-Javadoc)
059:             * @see de.uka.ilkd.key.proof.decproc.translation.IOperatorTranslation#translate(de.uka.ilkd.key.logic.op.Operator, de.uka.ilkd.key.proof.decproc.translation.TermTranslationVisitor)
060:             */
061:            public Object translate(Operator op,
062:                    TermTranslationVisitor ttVisitor) {
063:
064:                if (op == Op.ALL || op == Op.EX) {
065:                    String opName = op == Op.ALL ? DecisionProcedureSmtAufliaOp.FORALL
066:                            : DecisionProcedureSmtAufliaOp.EXISTS;
067:                    logger.info("Found '" + opName
068:                            + "' quantifier, starting operator translation...");
069:                    logger.debug("Popping one argument term from stack");
070:
071:                    Object arg = ttVisitor.getTranslatedArguments(1)[0];
072:                    Formula form;
073:                    if (arg instanceof  Formula)
074:                        form = (Formula) arg;
075:                    else
076:                        throw new IllegalArgumentException(translationFailure
077:                                + opName + failureCauseNoFormula + arg);
078:
079:                    ArrayOfQuantifiableVariable boundVars = ttVisitor
080:                            .getCurrentTerm().varsBoundHere(0);
081:                    logger
082:                            .info("Found "
083:                                    + boundVars.size()
084:                                    + " quantifiable variables, trying to create new term variables...");
085:                    TermVariable[] quantVars = new TermVariable[boundVars
086:                            .size()];
087:                    Formula[] typePreds = new Formula[boundVars.size()];
088:                    for (int i = 0; i < quantVars.length; i++) {
089:                        QuantifiableVariable var = boundVars
090:                                .getQuantifiableVariable(i);
091:                        // Give the quantifiable variable to the ttVisitor!
092:                        try {
093:                            quantVars[i] = ttVisitor
094:                                    .translateLvManually((LogicVariable) var);
095:                            // ClassCastExceptions will also be catched!
096:                        } catch (RuntimeException e) {
097:                            // Pass on the exception after adding some quantifier specific information
098:                            throw new UnsupportedOperationException(
099:                                    unsupportedQuantifier + op.name()
100:                                            + unsupportedVar + var
101:                                            + varTransFailed + e);
102:                        }
103:                        // Create type predicate for quantifiable variable
104:                        typePreds[i] = ttVisitor.createTypePredLv(var.sort(),
105:                                quantVars[i]);
106:                    }
107:                    logger.info("Creating new quantifier formula!");
108:                    // Integrate type predicates and quantified formula
109:                    Formula preconditions = typePreds[0];
110:                    Formula[] helper;
111:                    for (int i = 1; i < typePreds.length; i++) { // typePreds.length > 0!
112:                        helper = new Formula[] { preconditions, typePreds[i] };
113:                        preconditions = new ConnectiveFormula(
114:                                DecisionProcedureSmtAufliaOp.AND, helper);
115:                    }
116:                    helper = new Formula[] { preconditions, form };
117:                    if (op == Op.ALL) {
118:                        form = new ConnectiveFormula(
119:                                DecisionProcedureSmtAufliaOp.IMP, helper);
120:                    } else { // op == Op.EX
121:                        form = new ConnectiveFormula(
122:                                DecisionProcedureSmtAufliaOp.AND, helper);
123:                    }
124:                    return new QuantifierFormula(opName, quantVars, form);
125:                }
126:
127:                // Other quantifier operators are not supported
128:                logger
129:                        .info("Found unsupported quantifier operator, exiting with exception!");
130:                throw new UnsupportedOperationException(unsupportedQuantifier
131:                        + ((Quantifier) op).name() + unsupportedOperator);
132:            }
133:
134:        }
w__w__w__.___j___a_v_a_2___s___.___co_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.