aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/Alloy-Solver
diff options
context:
space:
mode:
Diffstat (limited to 'Solvers/Alloy-Solver')
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.classpath11
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.gitignore4
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.project40
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.settings/org.eclipse.incquery.patternlanguage.emf.EMFPatternLanguage.prefs29
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.settings/org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguage.prefs29
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/META-INF/MANIFEST.MF26
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/build.properties10
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/plugin.properties4
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/plugin.xml21
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/queries/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/queries/signatureQueries.vql17
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/queries/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/queries/typeQueries.vql85
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/AlloyAnalyzerConfiguration.xtend32
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/AlloySolver.xtend72
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Alloy2LogicMapper.xtend48
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/AlloyHandler.xtend145
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/AlloyModelInterpretation.xtend331
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper.xtend467
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapperTrace.xtend49
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_ConstantMapper.xtend43
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_Containment.xtend260
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_FunctionMapper.xtend87
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_RelationMapper.xtend111
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_Support.xtend207
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper.xtend16
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper_FilteredTypes.xtend268
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper_Horizontal.xtend_old428
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper_InheritanceAndHorizontal.xtend50
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/AlloyModelInterpretation.xtend_212
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/FunctionWithTimeout.xtend_40
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/Logic2AlloyApiMapper.xtend_345
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/oldTypes74
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.classpath9
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.gitignore4
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.project34
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/META-INF/MANIFEST.MF27
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/build.properties6
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/plugin.xml398
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/plugin.xml_gen425
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/AlloyLanguageUiModule.java15
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/contentassist/AlloyLanguageProposalProvider.xtend12
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/labeling/AlloyLanguageDescriptionLabelProvider.xtend24
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/labeling/AlloyLanguageLabelProvider.xtend29
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/outline/AlloyLanguageOutlineTreeProvider.xtend13
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/quickfix/AlloyLanguageQuickfixProvider.xtend26
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.classpath9
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.gitignore4
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.launch/Generate Language Infrastructure (hu.bme.mit.inf.dslreasoner.alloy.language).launch18
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.project34
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/META-INF/MANIFEST.MF37
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/build.properties7
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/model/generated/AlloyLanguage.ecore267
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/model/generated/AlloyLanguage.genmodel206
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/plugin.xml16
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/plugin.xml_gen16
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/AlloyLanguage.xtext149
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/AlloyLanguageRuntimeModule.java11
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/AlloyLanguageStandaloneSetup.java16
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/GenerateAlloyLanguage.mwe2133
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/formatting/AlloyLanguageFormatter.xtend96
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/generator/AlloyLanguageGenerator.xtend24
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/scoping/AlloyLanguageScopeProvider.xtend81
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/validation/AlloyLanguageValidator.xtend24
67 files changed, 5761 insertions, 0 deletions
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.classpath b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.classpath
new file mode 100644
index 00000000..de68b5f7
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.classpath
@@ -0,0 +1,11 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<classpath>
3 <classpathentry kind="src" path="xtend-gen"/>
4 <classpathentry kind="src" path="queries"/>
5 <classpathentry kind="src" path="vql-gen"/>
6 <classpathentry exported="true" kind="lib" path="lib/alloy4.2_2015-02-22.jar"/>
7 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
8 <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
9 <classpathentry kind="src" path="src"/>
10 <classpathentry kind="output" path="bin"/>
11</classpath>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.gitignore b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.gitignore
new file mode 100644
index 00000000..e42fe9ea
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.gitignore
@@ -0,0 +1,4 @@
1/bin/
2/src-gen/
3/vql-gen/
4/xtend-gen/ \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.project b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.project
new file mode 100644
index 00000000..a1c16519
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.project
@@ -0,0 +1,40 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<projectDescription>
3 <name>hu.bme.mit.inf.dlsreasoner.alloy.reasoner</name>
4 <comment></comment>
5 <projects>
6 </projects>
7 <buildSpec>
8 <buildCommand>
9 <name>org.eclipse.viatra.query.tooling.core.projectbuilder</name>
10 <arguments>
11 </arguments>
12 </buildCommand>
13 <buildCommand>
14 <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
15 <arguments>
16 </arguments>
17 </buildCommand>
18 <buildCommand>
19 <name>org.eclipse.jdt.core.javabuilder</name>
20 <arguments>
21 </arguments>
22 </buildCommand>
23 <buildCommand>
24 <name>org.eclipse.pde.ManifestBuilder</name>
25 <arguments>
26 </arguments>
27 </buildCommand>
28 <buildCommand>
29 <name>org.eclipse.pde.SchemaBuilder</name>
30 <arguments>
31 </arguments>
32 </buildCommand>
33 </buildSpec>
34 <natures>
35 <nature>org.eclipse.pde.PluginNature</nature>
36 <nature>org.eclipse.jdt.core.javanature</nature>
37 <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
38 <nature>org.eclipse.viatra.query.projectnature</nature>
39 </natures>
40</projectDescription>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.settings/org.eclipse.incquery.patternlanguage.emf.EMFPatternLanguage.prefs b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.settings/org.eclipse.incquery.patternlanguage.emf.EMFPatternLanguage.prefs
new file mode 100644
index 00000000..7d03706a
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.settings/org.eclipse.incquery.patternlanguage.emf.EMFPatternLanguage.prefs
@@ -0,0 +1,29 @@
1BuilderConfiguration.is_project_specific=true
2autobuilding=true
3eclipse.preferences.version=1
4generateGeneratedAnnotation=false
5generateSuppressWarnings=true
6generatedAnnotationComment=
7includeDateInGenerated=false
8outlet.DEFAULT_OUTPUT.cleanDirectory=false
9outlet.DEFAULT_OUTPUT.cleanupDerived=true
10outlet.DEFAULT_OUTPUT.createDirectory=true
11outlet.DEFAULT_OUTPUT.derived=true
12outlet.DEFAULT_OUTPUT.directory=./viatra-gen
13outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true
14outlet.DEFAULT_OUTPUT.installDslAsPrimarySource=false
15outlet.DEFAULT_OUTPUT.keepLocalHistory=true
16outlet.DEFAULT_OUTPUT.override=true
17outlet.DEFAULT_OUTPUT.sourceFolder.ecore-gen.directory=
18outlet.DEFAULT_OUTPUT.sourceFolder.ecore-gen.ignore=
19outlet.DEFAULT_OUTPUT.sourceFolder.queries.directory=
20outlet.DEFAULT_OUTPUT.sourceFolder.queries.ignore=
21outlet.DEFAULT_OUTPUT.sourceFolder.src-gen.directory=
22outlet.DEFAULT_OUTPUT.sourceFolder.src-gen.ignore=
23outlet.DEFAULT_OUTPUT.sourceFolder.src.directory=
24outlet.DEFAULT_OUTPUT.sourceFolder.src.ignore=
25outlet.DEFAULT_OUTPUT.sourceFolder.xtend-gen.directory=
26outlet.DEFAULT_OUTPUT.sourceFolder.xtend-gen.ignore=
27outlet.DEFAULT_OUTPUT.userOutputPerSourceFolder=
28targetJavaVersion=JAVA5
29useJavaCompilerCompliance=true
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.settings/org.eclipse.jdt.core.prefs b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..295926d9
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
1eclipse.preferences.version=1
2org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4org.eclipse.jdt.core.compiler.compliance=1.8
5org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7org.eclipse.jdt.core.compiler.source=1.8
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.settings/org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguage.prefs b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.settings/org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguage.prefs
new file mode 100644
index 00000000..c6f56e64
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/.settings/org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguage.prefs
@@ -0,0 +1,29 @@
1BuilderConfiguration.is_project_specific=true
2autobuilding=true
3eclipse.preferences.version=1
4generateGeneratedAnnotation=false
5generateSuppressWarnings=true
6generatedAnnotationComment=
7includeDateInGenerated=false
8outlet.DEFAULT_OUTPUT.cleanDirectory=true
9outlet.DEFAULT_OUTPUT.cleanupDerived=true
10outlet.DEFAULT_OUTPUT.createDirectory=true
11outlet.DEFAULT_OUTPUT.derived=true
12outlet.DEFAULT_OUTPUT.directory=./vql-gen
13outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true
14outlet.DEFAULT_OUTPUT.installDslAsPrimarySource=false
15outlet.DEFAULT_OUTPUT.keepLocalHistory=true
16outlet.DEFAULT_OUTPUT.override=true
17outlet.DEFAULT_OUTPUT.sourceFolder.ecore-gen.directory=
18outlet.DEFAULT_OUTPUT.sourceFolder.ecore-gen.ignore=
19outlet.DEFAULT_OUTPUT.sourceFolder.queries.directory=
20outlet.DEFAULT_OUTPUT.sourceFolder.queries.ignore=
21outlet.DEFAULT_OUTPUT.sourceFolder.src.directory=
22outlet.DEFAULT_OUTPUT.sourceFolder.src.ignore=
23outlet.DEFAULT_OUTPUT.sourceFolder.viatra-gen.directory=
24outlet.DEFAULT_OUTPUT.sourceFolder.viatra-gen.ignore=
25outlet.DEFAULT_OUTPUT.sourceFolder.xtend-gen.directory=
26outlet.DEFAULT_OUTPUT.sourceFolder.xtend-gen.ignore=
27outlet.DEFAULT_OUTPUT.userOutputPerSourceFolder=
28targetJavaVersion=JAVA5
29useJavaCompilerCompliance=true
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/META-INF/MANIFEST.MF b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..13ad2d10
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
1Manifest-Version: 1.0
2Bundle-ManifestVersion: 2
3Bundle-Name: %pluginName
4Bundle-SymbolicName: hu.bme.mit.inf.dlsreasoner.alloy.reasoner;singleton:=true
5Bundle-Version: 1.0.0.qualifier
6Bundle-ClassPath: lib/alloy4.2_2015-02-22.jar,
7 .
8Bundle-Vendor: %providerName
9Bundle-Localization: plugin
10Export-Package: hu.bme.mit.inf.dlsreasoner.alloy.reasoner,
11 hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder,
12 hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries,
13 hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.util
14Require-Bundle: com.google.guava,
15 org.eclipse.xtend.lib,
16 org.eclipse.xtext.xbase.lib,
17 org.eclipse.core.runtime,
18 org.eclipse.emf.ecore;visibility:=reexport,
19 hu.bme.mit.inf.dslreasoner.logic.model;bundle-version="1.0.0";visibility:=reexport,
20 hu.bme.mit.inf.dslreasoner.alloy.language;bundle-version="1.0.0",
21 org.eclipse.viatra.query.runtime;bundle-version="[1.2.0,2.0.0)",
22 org.eclipse.viatra.query.runtime.base.itc;bundle-version="1.3.0",
23 hu.bme.mit.inf.dslreasoner.ecore2logic;bundle-version="1.0.0"
24Bundle-RequiredExecutionEnvironment: JavaSE-1.8
25Bundle-ActivationPolicy: lazy
26Import-Package: org.apache.log4j;version="1.2.15"
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/build.properties b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/build.properties
new file mode 100644
index 00000000..bb9e5d4d
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/build.properties
@@ -0,0 +1,10 @@
1bin.includes = .,\
2 model/,\
3 META-INF/,\
4 plugin.xml,\
5 plugin.properties
6jars.compile.order = .
7source.. = ecore-gen/,\
8 src/,\
9 src-gen/
10output.. = bin/
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/plugin.properties b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/plugin.properties
new file mode 100644
index 00000000..14541a0a
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/plugin.properties
@@ -0,0 +1,4 @@
1#
2
3pluginName = AlloyLanguage Model
4providerName = www.example.org
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/plugin.xml b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/plugin.xml
new file mode 100644
index 00000000..23c55a4d
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/plugin.xml
@@ -0,0 +1,21 @@
1<?xml version="1.0" encoding="UTF-8"?><?eclipse version="3.0"?><!--
2--><plugin>
3 <extension point="org.eclipse.emf.ecore.generated_package">
4 <!-- @generated AlloyLanguage -->
5 <package class="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.alloylanguage.AlloylanguagePackage" genModel="model/AlloyLanguage.genmodel" uri="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.language"/>
6 </extension>
7 <extension id="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.SignatureQueries" point="org.eclipse.viatra.query.runtime.queryspecification">
8 <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.SignatureQueries" id="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.SignatureQueries">
9 <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.directSubset"/>
10 <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.subset"/>
11 </group>
12 </extension>
13 <extension id="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.TypeQueries" point="org.eclipse.viatra.query.runtime.queryspecification">
14 <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.TypeQueries" id="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.TypeQueries">
15 <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.supertype"/>
16 <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.topmostCommonSubtypes"/>
17 <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.lowermostCommonSupertype"/>
18 <query-specification fqn="hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.lowestCommonSupertypeOfAllOccuranceOfElement"/>
19 </group>
20 </extension>
21</plugin>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/queries/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/queries/signatureQueries.vql b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/queries/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/queries/signatureQueries.vql
new file mode 100644
index 00000000..a020953c
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/queries/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/queries/signatureQueries.vql
@@ -0,0 +1,17 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries
2
3import epackage "http://www.bme.hu/mit/inf/dslreasoner/AlloyLanguage"
4
5pattern directSubset(x: ALSSignatureDeclaration, y: ALSSignatureDeclaration) {
6 ALSSignatureBody.declarations(b,y);
7 ALSSignatureBody.supertype(b,x);
8} or {
9 ALSSignatureBody.declarations(b,y);
10 ALSSignatureBody.superset(b,x);
11}
12
13pattern subset(x: ALSSignatureDeclaration, y: ALSSignatureDeclaration) {
14 x == y;
15} or {
16 find directSubset+(x,y);
17}
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/queries/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/queries/typeQueries.vql b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/queries/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/queries/typeQueries.vql
new file mode 100644
index 00000000..8d93cafb
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/queries/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/queries/typeQueries.vql
@@ -0,0 +1,85 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries
2
3import epackage "http://www.bme.hu/mit/inf/dslreasoner/logic/model/language"
4
5private pattern supertypeEdge(type1: Type, type2: Type) {
6 Type.supertypes(type1,type2);
7}
8
9pattern supertype(type1: Type, type2: Type) {
10 type1 == type2;
11} or {
12 find supertypeEdge+(type1,type2);
13}
14
15private pattern commonSubtype(type1: Type, type2: Type, common: Type) {
16 find supertype(common,type1);
17 find supertype(common,type2);
18}
19
20private pattern commonSupertype(type1: Type, type2: Type, common: Type) {
21 find supertype(common,type1);
22 find supertype(common,type2);
23}
24
25private pattern hasHigherCommonSubtype(type1: Type, type2: Type, common: Type, higher: Type) {
26 find supertype(higher,type1);
27 find supertype(higher,type2);
28 Type.supertypes(common,higher);
29 higher != common;
30}
31
32private pattern hasLowerCommonSupertype(type1: Type, type2: Type, common: Type, lower: Type) {
33 find supertype(type1,lower);
34 find supertype(type2,lower);
35 Type.supertypes(lower,common);
36 lower != common;
37}
38
39pattern topmostCommonSubtypes(type1: Type, type2: Type, common: Type) {
40 find commonSubtype(type1, type2, common);
41 neg find hasHigherCommonSubtype(type1, type2, common, _);
42}
43
44pattern lowermostCommonSupertype(type1: Type, type2: Type, common: Type) {
45 find commonSupertype(type1, type2, common);
46 neg find hasLowerCommonSupertype(type1, type2, common, _);
47}
48/*pattern topmostCommonSubtypesInObject(type1: Type, type2: Type, common: Type) {
49 find commonSubtype(type1, type2, common);
50 neg find supertypeEdge(type1,_);
51 neg find supertypeEdge(type2,_);
52 neg find hasHigherCommonSubtype(type1, type2, common, _);
53}
54pattern topmostCommonSubtypesInType(in: Type, type1: Type, type2: Type, common: Type) {
55 find commonSubtype(type1, type2, common);
56 find supertypeEdge(type1,in);
57 find supertypeEdge(type2,in);
58 neg find hasHigherCommonSubtype(type1, type2, common, _);
59}
60 */
61
62pattern lowestCommonSupertypeOfAllOccuranceOfElement(element: DefinedElement, type: Type) {
63 find typeContainsAllOccuranceOfElement(element,type);
64 neg find hasLowerCommonSupertypeOfAllOccuranceOfElement(element, type, _);
65}
66
67private pattern hasLowerCommonSupertypeOfAllOccuranceOfElement(element: DefinedElement, type: Type, lower: Type) {
68 find typeContainsAllOccuranceOfElement(element, type);
69 find typeContainsAllOccuranceOfElement(element, lower);
70 find supertype(lower, type);
71 type != lower;
72}
73
74private pattern typeContainsAllOccuranceOfElement(element: DefinedElement, type: Type) {
75 find supertype(containerType,type);
76 TypeDefinition.elements(containerType,element);
77 neg find typeDoesNotCoverElementOccurance(element,type,_);
78}
79
80private pattern typeDoesNotCoverElementOccurance(element: DefinedElement, type: Type, uncoveredOccurance: TypeDefinition) {
81 find supertype(containerType,type);
82 TypeDefinition.elements(containerType,element);
83 TypeDefinition.elements(uncoveredOccurance,element);
84 neg find supertype(uncoveredOccurance,type);
85} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/AlloyAnalyzerConfiguration.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/AlloyAnalyzerConfiguration.xtend
new file mode 100644
index 00000000..cdf21174
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/AlloyAnalyzerConfiguration.xtend
@@ -0,0 +1,32 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner
2
3import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicSolverConfiguration
4
5class AlloySolverConfiguration extends LogicSolverConfiguration {
6 /*public var boolean createCommonSupertype
7 public var int intScope = 1 // 5 by default
8 public def setIntScopeFor(int max) {
9 intScope = 31 - Integer.numberOfLeadingZeros(max) + 1
10 }*/
11 public var int symmetry = 0 // by default
12 public var AlloyBackendSolver solver = AlloyBackendSolver.SAT4J
13 public var boolean writeToFile = false
14}
15
16enum AlloyBackendSolver {
17 BerkMinPIPE,
18 SpearPIPE,
19 MiniSatJNI,
20 MiniSatProverJNI,
21 LingelingJNI,
22 PLingelingJNI,
23 GlucoseJNI,
24 CryptoMiniSatJNI,
25 SAT4J,
26 CNF,
27 KodKod
28}
29
30enum TypeMappingTechnique {
31 FilteredTypes
32} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/AlloySolver.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/AlloySolver.xtend
new file mode 100644
index 00000000..7dfc3161
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/AlloySolver.xtend
@@ -0,0 +1,72 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner
2
3import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder.Alloy2LogicMapper
4import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder.AlloyHandler
5import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder.AlloyModelInterpretation
6import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder.Logic2AlloyLanguageMapper
7import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder.Logic2AlloyLanguageMapperTrace
8import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder.MonitoredAlloySolution
9import hu.bme.mit.inf.dslreasoner.AlloyLanguageStandaloneSetupGenerated
10import hu.bme.mit.inf.dslreasoner.alloyLanguage.AlloyLanguagePackage
11import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner
12import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasonerException
13import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicSolverConfiguration
14import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
15import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult
16import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace
17import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder.Logic2AlloyLanguageMapper_TypeMapper_FilteredTypes
18import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder.AlloyModelInterpretation_TypeInterpretation_FilteredTypes
19import org.eclipse.emf.common.util.URI
20
21class AlloySolver extends LogicReasoner{
22
23 new() {
24 AlloyLanguagePackage.eINSTANCE.eClass
25 val x = new AlloyLanguageStandaloneSetupGenerated
26 x.createInjectorAndDoEMFRegistration
27 }
28
29 val Logic2AlloyLanguageMapper forwardMapper = new Logic2AlloyLanguageMapper(new Logic2AlloyLanguageMapper_TypeMapper_FilteredTypes)
30 val AlloyHandler handler = new AlloyHandler
31 val Alloy2LogicMapper backwardMapper = new Alloy2LogicMapper
32
33 val fileName = "problem.als"
34
35 override solve(LogicProblem problem, LogicSolverConfiguration configuration, ReasonerWorkspace workspace) throws LogicReasonerException {
36 if(configuration instanceof AlloySolverConfiguration) {
37 val transformationStart = System.currentTimeMillis
38 val result = forwardMapper.transformProblem(problem,configuration)
39 val alloyProblem = result.output
40
41 /*val x = alloyProblem.eAllContents.filter(ALSFunctionCall).filter[it.referredDefinition == null].toList
42 println(x)*/
43 val forwardTrace = result.trace
44
45 var String fileURI = null;
46 var String alloyCode = null;
47 if(configuration.writeToFile) {
48 fileURI = workspace.writeModel(alloyProblem,fileName).toFileString
49 } else {
50 alloyCode = workspace.writeModelToString(alloyProblem,fileName)
51 }
52
53 //val alloyCode = workspace.readText(fileName)
54 //val FunctionWithTimeout<MonitoredAlloySolution> call = new FunctionWithTimeout[]
55
56 val transformationTime = System.currentTimeMillis - transformationStart
57 val result2 = handler.callSolver(alloyProblem,workspace,configuration,fileURI,alloyCode)
58 workspace.deactivateModel(fileName)
59 val logicResult = backwardMapper.transformOutput(problem,result2,forwardTrace,transformationTime)
60 return logicResult
61 } else throw new IllegalArgumentException('''The configuration have to be an «AlloySolverConfiguration.simpleName»!''')
62 }
63
64 override getInterpretation(ModelResult modelResult) {
65 return new AlloyModelInterpretation(
66 new AlloyModelInterpretation_TypeInterpretation_FilteredTypes,
67 (modelResult.representation as MonitoredAlloySolution).solution,
68 forwardMapper,
69 modelResult.trace as Logic2AlloyLanguageMapperTrace
70 );
71 }
72} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Alloy2LogicMapper.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Alloy2LogicMapper.xtend
new file mode 100644
index 00000000..637752b0
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Alloy2LogicMapper.xtend
@@ -0,0 +1,48 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
4import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicresultFactory
5
6class Alloy2LogicMapper {
7 val extension LogicresultFactory resultFactory = LogicresultFactory.eINSTANCE
8
9 public def transformOutput(LogicProblem problem, MonitoredAlloySolution solution, Logic2AlloyLanguageMapperTrace trace, long transformationTime) {
10 if(solution == null) {
11 return createInsuficientResourcesResult => [
12 it.problem = problem
13 it.statistics = transformStatistics(solution,transformationTime)
14 ]
15 } else {
16 val logicResult = solution.solution
17 if(logicResult.satisfiable) {
18 return createModelResult => [
19 it.problem = problem
20 it.representation += solution
21 it.maxInteger = logicResult.max
22 it.minInteger = logicResult.min
23 it.trace = trace
24 it.statistics = transformStatistics(solution,transformationTime)
25 ]
26 } else {
27 return createInconsistencyResult => [
28 it.problem = problem
29 //trace?
30 it.statistics = transformStatistics(solution,transformationTime)
31 ]
32 }
33 }
34 }
35
36 def transformStatistics(MonitoredAlloySolution solution, long transformationTime) {
37 createStatistics => [
38 it.transformationTime = transformationTime as int
39 if(solution != null) {
40 it.solverTime = solution.runtimeTime as int
41 it.entries += LogicresultFactory.eINSTANCE.createIntStatisticEntry => [
42 it.name = "KoodkodToCNFTransformationTime"
43 it.value = solution.getKodkodTime as int
44 ]
45 }
46 ]
47 }
48} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/AlloyHandler.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/AlloyHandler.xtend
new file mode 100644
index 00000000..6bac4130
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/AlloyHandler.xtend
@@ -0,0 +1,145 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import edu.mit.csail.sdg.alloy4.A4Reporter
4import edu.mit.csail.sdg.alloy4.Err
5import edu.mit.csail.sdg.alloy4.ErrorWarning
6import edu.mit.csail.sdg.alloy4compiler.ast.Command
7import edu.mit.csail.sdg.alloy4compiler.parser.CompModule
8import edu.mit.csail.sdg.alloy4compiler.parser.CompUtil
9import edu.mit.csail.sdg.alloy4compiler.translator.A4Options
10import edu.mit.csail.sdg.alloy4compiler.translator.A4Solution
11import edu.mit.csail.sdg.alloy4compiler.translator.TranslateAlloyToKodkod
12import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace
13import java.util.LinkedList
14import java.util.List
15import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloyBackendSolver
16import org.eclipse.xtend.lib.annotations.Data
17import java.util.Map
18import java.util.HashMap
19import edu.mit.csail.sdg.alloy4compiler.translator.A4Options.SatSolver
20import org.eclipse.emf.common.CommonPlugin
21import java.util.ArrayList
22import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSDocument
23import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloySolverConfiguration
24
25class AlloySolverException extends Exception{
26 new(String s) { super(s) }
27 new(String s, Exception e) { super(s,e) }
28 new(String s, List<String> errors, Exception e) {
29 super(s + '\n' + errors.join('\n'), e)
30 }
31}
32
33@Data class MonitoredAlloySolution{
34 List<String> warnings
35 List<String> debugs
36 long kodkodTime
37 long runtimeTime
38
39 A4Solution solution
40}
41
42class AlloyHandler {
43
44 //val fileName = "problem.als"
45
46 public def callSolver(ALSDocument problem, ReasonerWorkspace workspace, AlloySolverConfiguration configuration, String path, String alloyCode) {
47 //Prepare
48
49 val warnings = new LinkedList<String>
50 val debugs = new LinkedList<String>
51 val runtime = new ArrayList<Long>
52 val reporter = new A4Reporter() {
53 override debug(String message) { debugs += message }
54 override resultSAT (Object command, long solvingTime, Object solution) { runtime += solvingTime }
55 override resultUNSAT (Object command, long solvingTime, Object solution) { runtime += solvingTime }
56 override warning(ErrorWarning msg) { warnings += msg.message }
57 }
58
59 val options = new A4Options() => [
60 it.symmetry = configuration.symmetry
61 it.noOverflow = true
62 it.solver = getSolver(configuration.solver, configuration)
63 if(configuration.solver.externalSolver) {
64 it.solverDirectory = configuration.solverPath
65 }
66 it.tempDirectory = CommonPlugin.resolve(workspace.workspaceURI).toFileString
67 ]
68
69 // Transform
70 var Command command = null;
71 var CompModule compModule = null
72
73 val kodkodTransformStart = System.currentTimeMillis();
74
75 try {
76 if(configuration.writeToFile) {
77 compModule = CompUtil.parseEverything_fromFile(reporter,null,path)
78 } else {
79 compModule = CompUtil.parseEverything_fromString(reporter,alloyCode)
80 }
81 if(compModule.allCommands.size != 1)
82 throw new UnsupportedOperationException('''Alloy files with multiple commands are not supported!''')
83 command = compModule.allCommands.head
84 } catch (Err e){
85 throw new AlloySolverException(e.message,warnings,e)
86 }
87 val kodkodTransformFinish = System.currentTimeMillis - kodkodTransformStart
88
89 //Execute
90 var A4Solution answer = null;
91 try {
92 answer = TranslateAlloyToKodkod.execute_command(reporter,compModule.allSigs,command,options)
93 }catch(Exception e) {
94 warnings +=e.message
95 }
96
97 var long runtimeFromAnswer;
98 if(runtime.empty) {
99 runtimeFromAnswer = System.currentTimeMillis - (kodkodTransformStart + kodkodTransformFinish)
100 } else {
101 runtimeFromAnswer = runtime.head
102 }
103
104 return new MonitoredAlloySolution(warnings,debugs,kodkodTransformFinish,runtimeFromAnswer,answer)
105 }
106
107 val static Map<SolverConfiguration, SatSolver> previousSolverConfigurations = new HashMap
108 def getSolverConfiguration(AlloyBackendSolver backedSolver, String path, String[] options) {
109 val config = new SolverConfiguration(backedSolver,path,options)
110 if(previousSolverConfigurations.containsKey(config)) {
111 return previousSolverConfigurations.get(config)
112 } else {
113 val id ='''DSLReasoner_Alloy_«previousSolverConfigurations.size»_«backedSolver»'''
114 val newSolver = A4Options.SatSolver.make(id,id,path,options)
115 previousSolverConfigurations.put(config,newSolver)
116 return newSolver
117 }
118 }
119
120 def getSolver(AlloyBackendSolver backedSolver, AlloySolverConfiguration configuration) {
121 switch(backedSolver){
122 case BerkMinPIPE: return A4Options.SatSolver.BerkMinPIPE
123 case SpearPIPE: return A4Options.SatSolver.SpearPIPE
124 case MiniSatJNI: return A4Options.SatSolver.MiniSatJNI
125 case MiniSatProverJNI: return A4Options.SatSolver.MiniSatProverJNI
126 case LingelingJNI: return A4Options.SatSolver.LingelingJNI
127 case PLingelingJNI: return getSolverConfiguration(backedSolver,configuration.solverPath,null)
128 case GlucoseJNI: return A4Options.SatSolver.GlucoseJNI
129 case CryptoMiniSatJNI: return A4Options.SatSolver.CryptoMiniSatJNI
130 case SAT4J: return A4Options.SatSolver.SAT4J
131 case CNF: return A4Options.SatSolver.CNF
132 case KodKod: return A4Options.SatSolver.KK
133 }
134 }
135
136 def isExternalSolver(AlloyBackendSolver backedSolver) {
137 return !(backedSolver == AlloyBackendSolver.SAT4J)
138 }
139}
140
141@Data class SolverConfiguration {
142 AlloyBackendSolver backedSolver
143 String path
144 String[] options
145}
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/AlloyModelInterpretation.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/AlloyModelInterpretation.xtend
new file mode 100644
index 00000000..d00291e0
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/AlloyModelInterpretation.xtend
@@ -0,0 +1,331 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import edu.mit.csail.sdg.alloy4compiler.ast.ExprVar
4import edu.mit.csail.sdg.alloy4compiler.ast.Sig.Field
5import edu.mit.csail.sdg.alloy4compiler.translator.A4Solution
6import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicModelInterpretation
7import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ConstantDeclaration
8import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
9import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.FunctionDeclaration
10import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguageFactory
11import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration
12import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
13import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration
14import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition
15import java.util.Arrays
16import java.util.HashMap
17import java.util.LinkedList
18import java.util.List
19import java.util.Map
20import java.util.Set
21
22import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
23import edu.mit.csail.sdg.alloy4compiler.ast.Sig
24import java.util.ArrayList
25
26interface AlloyModelInterpretation_TypeInterpretation {
27 def void resolveUnknownAtoms(
28 Iterable<ExprVar> objectAtoms,
29 A4Solution solution,
30 Logic2AlloyLanguageMapperTrace forwardTrace,
31 Map<String, Sig> name2AlloySig,
32 Map<String, Field> name2AlloyField,
33 Map<String,DefinedElement> expression2DefinedElement,
34 Map<TypeDeclaration, List<DefinedElement>> interpretationOfUndefinedType)
35}
36
37class AlloyModelInterpretation_TypeInterpretation_FilteredTypes implements AlloyModelInterpretation_TypeInterpretation{
38 protected val extension LogiclanguageFactory factory = LogiclanguageFactory.eINSTANCE
39
40 override resolveUnknownAtoms(
41 Iterable<ExprVar> objectAtoms,
42 A4Solution solution,
43 Logic2AlloyLanguageMapperTrace forwardTrace,
44 Map<String, Sig> name2AlloySig,
45 Map<String, Field> name2AlloyField,
46 Map<String,DefinedElement> expression2DefinedElement,
47 Map<TypeDeclaration, List<DefinedElement>> interpretationOfUndefinedType)
48 {
49 /*val Map<String,DefinedElement> expression2DefinedElement = new HashMap()
50 val Map<TypeDeclaration, List<DefinedElement>> interpretationOfUndefinedType = new HashMap;*/
51
52 val typeTrace = forwardTrace.typeMapperTrace as Logic2AlloyLanguageMapper_TypeMapperTrace_FilteredTypes
53
54 // 1. Evaluate the defined elements
55 for(definedElementMappingEntry : typeTrace.definedElement2Declaration.entrySet) {
56 val name = definedElementMappingEntry.value.name
57 val matchingSig = '''this/«name»'''.toString.lookup(name2AlloySig)
58 val elementsOfSingletonSignature = solution.eval(matchingSig)
59 if(elementsOfSingletonSignature.size != 1) {
60 throw new IllegalArgumentException('''Defined element is unambigous: "«name»", possible values: «elementsOfSingletonSignature»!''')
61 } else {
62 val expressionOfDefinedElement = elementsOfSingletonSignature.head.atom(0)// as ExprVar
63 expression2DefinedElement.put(expressionOfDefinedElement, definedElementMappingEntry.key)
64 }
65 }
66
67 // 2. evaluate the signatures and create new elements if necessary
68 for(type2SingatureEntry : typeTrace.type2ALSType.entrySet) {
69 val type = type2SingatureEntry.key
70 if(type instanceof TypeDeclaration) {
71 val name = type2SingatureEntry.value.name
72 val matchingSig = '''this/«name»'''.toString.lookup(name2AlloySig)
73 val elementsOfSignature = solution.eval(matchingSig)
74 val elementList = new ArrayList(elementsOfSignature.size)
75 var newVariableIndex = 1;
76 for(elementOfSignature : elementsOfSignature) {
77 val expressionOfDefinedElement = elementOfSignature.atom(0)
78 if(expression2DefinedElement.containsKey(expressionOfDefinedElement)) {
79 elementList += expressionOfDefinedElement.lookup(expression2DefinedElement)
80 } else {
81 val newElementName = '''newObject «newVariableIndex.toString»'''
82 val newRepresentation = createDefinedElement => [
83 it.name = newElementName
84 ]
85 elementList += newRepresentation
86 expression2DefinedElement.put(expressionOfDefinedElement,newRepresentation)
87 }
88 }
89 interpretationOfUndefinedType.put(type,elementList)
90 }
91 }
92 }
93}
94/*
95class AlloyModelInterpretation_TypeInterpretation_Horizontal implements AlloyModelInterpretation_TypeInterpretation{
96 protected val extension LogiclanguageFactory factory = LogiclanguageFactory.eINSTANCE
97
98 override resolveUnknownAtoms(Iterable<ExprVar> objectAtoms, Logic2AlloyLanguageMapperTrace forwardTrace, Map<String,DefinedElement> alloyAtom2LogicElement) {
99 val Map<TypeDeclaration, List<DefinedElement>> interpretationOfUndefinedType = new HashMap;
100
101 //TMP sig maps to identify alloy signatures by their names
102 val Map<String,Type> sigName2LogicType =
103 forwardTrace.type2ALSType.keySet.toMap[x|forwardTrace.type2ALSType.get(x).name]
104 //val Map<String,DefinedElement> elementNameNamel2DefinedElement =
105 // forwardTrace.definedElement2Declaration.keySet.toMap[x|forwardTrace.definedElement2Declaration.get(x).name]
106
107 // Fill the interpretation map with empty lists
108 forwardTrace.type2ALSType.keySet.filter(TypeDeclaration).forEach[x|interpretationOfUndefinedType.put(x,new LinkedList)]
109
110 // exporing individuals
111 for(atom: objectAtoms) {
112 val typeName = getName(atom.type)
113 //val atomName = atom.name
114
115 if(sigName2LogicType.containsKey(typeName)) {
116 val type = sigName2LogicType.get(typeName)
117 val elementsOfType = interpretationOfUndefinedType.get(type)
118 val element = createDefinedElement => [
119 it.name += type.name
120 it.name += (elementsOfType.size+1).toString
121 ]
122 alloyAtom2LogicElement.put(atom.label,element)
123 elementsOfType+=element
124 }
125 else throw new UnsupportedOperationException('''Unknown atom: «atom»''')
126 }
127
128 return interpretationOfUndefinedType
129 }
130
131 def private getName(edu.mit.csail.sdg.alloy4compiler.ast.Type type) {
132 val name = type.toString
133 if(name.startsWith("{this/") && name.endsWith("}")) {
134 return type.toString.replaceFirst("\\{this\\/","").replace("}","")
135 }
136 else throw new IllegalArgumentException('''Unknown type format: "«name»"!''')
137 }
138 //def private getName(ExprVar atom) { atom.toString.split("\\$") }
139}*/
140
141class AlloyModelInterpretation implements LogicModelInterpretation{
142
143 protected val extension LogiclanguageFactory factory = LogiclanguageFactory.eINSTANCE
144 protected val AlloyModelInterpretation_TypeInterpretation typeInterpretator
145
146 protected val Logic2AlloyLanguageMapper forwardMapper
147 protected val Logic2AlloyLanguageMapperTrace forwardTrace;
148
149 private var ExprVar logicLanguage;
150
151 private var String logicBooleanTrue;
152 private var String logicBooleanFalse;
153
154 private val Map<String, DefinedElement> alloyAtom2LogicElement = new HashMap
155 private val Map<TypeDeclaration, List<DefinedElement>> interpretationOfUndefinedType = new HashMap
156
157 private val Map<ConstantDeclaration, Object> constant2Value
158 private val Map<FunctionDeclaration, ? extends Map<ParameterSubstitution, Object>> function2Value
159 private val Map<RelationDeclaration, ? extends Set<ParameterSubstitution>> relation2Value
160
161 private val int minInt
162 private val int maxInt
163
164 public new (AlloyModelInterpretation_TypeInterpretation typeInterpretator, A4Solution solution, Logic2AlloyLanguageMapper forwardMapper, Logic2AlloyLanguageMapperTrace trace) {
165 this.typeInterpretator = typeInterpretator
166 this.forwardMapper = forwardMapper
167 this.forwardTrace = trace
168
169 // Maps to trace language elements to the parsed problem.
170 val Map<String, Sig> name2AlloySig = new HashMap
171 val Map<String, Field> name2AlloyField = new HashMap
172 // exploring signatures
173 for(sig:solution.allReachableSigs) {
174 name2AlloySig.put(sig.label,sig)
175 for(field : sig.fields) {
176 name2AlloyField.put(field.label,field)
177 }
178 }
179
180 val unknownAtoms = collectUnknownAndResolveKnownAtoms(solution.allAtoms)
181 this.typeInterpretator.resolveUnknownAtoms(
182 unknownAtoms,
183 solution,
184 forwardTrace,
185 name2AlloySig,
186 name2AlloyField,
187 alloyAtom2LogicElement,
188 interpretationOfUndefinedType)
189
190 // eval consants
191 constant2Value = forwardTrace.constantDeclaration2LanguageField.mapValues[
192 solution.eval(it.name.lookup(name2AlloyField)).head.atom(1).atomLabel2Term
193 ]
194 // eval functions
195 val hostedfunction2Value = forwardTrace.functionDeclaration2HostedField.mapValues[ function |
196 newHashMap(
197 solution.eval(function.name.lookup(name2AlloyField))
198 .map[t | new ParameterSubstitution(#[t.atom(0).atomLabel2Term]) -> t.atom(1).atomLabel2Term])]
199
200 val globalfunction2Value = forwardTrace.functionDeclaration2LanguageField.keySet.toInvertedMap[ function |
201 val alsFunction = function.lookup(forwardTrace.functionDeclaration2LanguageField)
202 val paramIndexes = 1..(function.parameters.size)
203 return newHashMap(
204 solution.eval(alsFunction.name.lookup(name2AlloyField)).map[t |
205 new ParameterSubstitution(paramIndexes.map[t.atom(it).atomLabel2Term])
206 ->
207 t.atom(function.parameters.size + 1).atomLabel2Term
208 ])]
209 this.function2Value = Union(hostedfunction2Value,globalfunction2Value)
210 // eval relations
211 val hostedRelation2Value = forwardTrace.relationDeclaration2Field.mapValues[ relation |
212 solution.eval(relation.name.lookup(name2AlloyField)).map[ t |
213 new ParameterSubstitution(#[t.atom(0).atomLabel2Term,t.atom(1).atomLabel2Term])].toSet]
214 val globalRelation2Value = forwardTrace.relationDeclaration2Global.mapValues[ relation |
215 solution.eval(relation.name.lookup(name2AlloyField)).map[ t |
216 new ParameterSubstitution((1..<t.arity).map[int a|t.atom(a).atomLabel2Term])].toSet]
217 this.relation2Value = Union(hostedRelation2Value,globalRelation2Value)
218
219 //Int limits
220 this.minInt = solution.min
221 this.maxInt = solution.max
222
223 //print(trace)
224 }
225
226 def List<ExprVar> collectUnknownAndResolveKnownAtoms(Iterable<ExprVar> allAtoms) {
227 val List<ExprVar> unknownAtoms = new LinkedList
228
229 for(atom: allAtoms) {
230 val typeName = getName(atom.type)
231 val atomName = atom.name
232 //println(atom.toString + " < - " + typeName)
233 if(typeName == forwardTrace.logicLanguage.name) {
234 this.logicLanguage = atom
235 } else if(typeName == "Int" || typeName == "seq/Int") {
236 // do nothing, integers will be parsed from the string
237 } else if(forwardTrace.boolType != null && typeName == forwardTrace.boolType.name) {
238 if(atomName.head == forwardTrace.boolTrue.name) { this.logicBooleanTrue = atom.label }
239 else if(atomName.head == forwardTrace.boolFalse.name) { this.logicBooleanFalse = atom.label}
240 else throw new UnsupportedOperationException('''Unknown boolean value: «atom»''')
241 }
242 else unknownAtoms += atom
243 }
244
245 return unknownAtoms
246 }
247
248 def private getName(edu.mit.csail.sdg.alloy4compiler.ast.Type type) {
249 val name = type.toString
250 if(name.startsWith("{this/") && name.endsWith("}")) {
251 return type.toString.replaceFirst("\\{this\\/","").replace("}","")
252 }
253 else throw new IllegalArgumentException('''Unknown type format: "«name»"!''')
254 }
255 def private getName(ExprVar atom) { atom.toString.split("\\$") }
256
257 def print(Logic2AlloyLanguageMapperTrace trace) {
258 println('''Undefined-----''')
259 interpretationOfUndefinedType.forEach[k,v|println('''«k.name» -> «v.map[name]»''')]
260 //println('''Defined-----''')
261 //trace.type2ALSType.keySet.filter(TypeDefinition).forEach[println('''«it.name» -> «it.elements.map[name.join]»''')]
262
263 println('''Constants-----''')
264 constant2Value.forEach[k, v|println('''«k.name» : «v»''')]
265 println('''Functions-----''')
266 function2Value.forEach[f,m|m.forEach[k,v| println('''«f.name» : «k» |-> «v»''')]]
267 println('''Relations-----''')
268 relation2Value.forEach[r,s|s.forEach[t | println('''«r.name»: («t»)''')]]
269 }
270
271 override getElements(Type type) { getElementsDispatch(type) }
272 def private dispatch getElementsDispatch(TypeDeclaration declaration) { return declaration.lookup(this.interpretationOfUndefinedType) }
273 def private dispatch getElementsDispatch(TypeDefinition declaration) { return declaration.elements }
274
275 override getInterpretation(FunctionDeclaration function, Object[] parameterSubstitution) {
276 val transformedParams = new ParameterSubstitution(parameterSubstitution)
277 return transformedParams.lookup(
278 function.lookup(this.function2Value)
279 )
280 }
281
282 override getInterpretation(RelationDeclaration relation, Object[] parameterSubstitution) {
283 relation.lookup(this.relation2Value).contains(new ParameterSubstitution(parameterSubstitution))
284 }
285
286 override getInterpretation(ConstantDeclaration constant) {
287 constant.lookup(this.constant2Value)
288 }
289
290 override getMinimalInteger() { this.minInt }
291 override getMaximalInteger() { this.maxInt }
292
293 // Alloy term -> logic term
294 def private atomLabel2Term(String label) {
295 if(label.number) return Integer.parseInt(label)
296 else if(label == this.logicBooleanTrue) return true
297 else if(label == this.logicBooleanFalse) return false
298 else if(this.alloyAtom2LogicElement.containsKey(label)) return label.lookup(alloyAtom2LogicElement)
299 else throw new IllegalArgumentException('''Unknown atom label: "«label»"!''')
300 }
301 def private isNumber(String s) {
302 try{
303 Integer.parseInt(s)
304 return true
305 }catch(NumberFormatException e) {
306 return false
307 }
308 }
309}
310
311/**
312 * Helper class for efficiently matching parameter substitutions for functions and relations.
313 */
314class ParameterSubstitution{
315 val Object[] data;
316
317 new(Object[] data) { this.data = data }
318
319 override equals(Object obj) {
320 if(obj === this) return true
321 else if(obj == null) return false
322 if(obj instanceof ParameterSubstitution) {
323 return Arrays.equals(this.data,obj.data)
324 }
325 return false
326 }
327
328 override hashCode() {
329 Arrays.hashCode(data)
330 }
331} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper.xtend
new file mode 100644
index 00000000..23b9027f
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper.xtend
@@ -0,0 +1,467 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloySolverConfiguration
4import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSDocument
5import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSEnumLiteral
6import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSMultiplicity
7import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSNumericOperator
8import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSTerm
9import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSVariableDeclaration
10import hu.bme.mit.inf.dslreasoner.alloyLanguage.AlloyLanguageFactory
11import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicSolverConfiguration
12import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput
13import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.And
14import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Assertion
15import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolLiteral
16import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolTypeReference
17import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference
18import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ConstantDeclaration
19import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ConstantDefinition
20import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
21import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Distinct
22import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Divison
23import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Equals
24import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Exists
25import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Forall
26import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.FunctionDeclaration
27import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.FunctionDefinition
28import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Iff
29import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Impl
30import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.InstanceOf
31import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntLiteral
32import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntTypeReference
33import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LessOrEqualThan
34import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LessThan
35import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Minus
36import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Mod
37import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.MoreOrEqualThan
38import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.MoreThan
39import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Multiply
40import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Not
41import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Or
42import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Plus
43import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealLiteral
44import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealTypeReference
45import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration
46import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDefinition
47import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.SymbolicValue
48import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Term
49import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Variable
50import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
51import java.util.Collections
52import java.util.HashMap
53import java.util.List
54import java.util.Map
55import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
56import org.eclipse.viatra.query.runtime.emf.EMFScope
57import org.eclipse.xtend.lib.annotations.Accessors
58
59import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
60import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.Annotation
61import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion
62import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.AssertionAnnotation
63import java.util.Collection
64import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.LowerMultiplicityAssertion
65import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.UpperMultiplicityAssertion
66import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSDirectProduct
67
68class Logic2AlloyLanguageMapper {
69 private val extension AlloyLanguageFactory factory = AlloyLanguageFactory.eINSTANCE
70 private val Logic2AlloyLanguageMapper_Support support = new Logic2AlloyLanguageMapper_Support;
71 @Accessors(PUBLIC_GETTER) private val Logic2AlloyLanguageMapper_TypeMapper typeMapper;
72 @Accessors(PUBLIC_GETTER) private val Logic2AlloyLanguageMapper_ConstantMapper constantMapper = new Logic2AlloyLanguageMapper_ConstantMapper(this)
73 @Accessors(PUBLIC_GETTER) private val Logic2AlloyLanguageMapper_FunctionMapper functionMapper = new Logic2AlloyLanguageMapper_FunctionMapper(this)
74 @Accessors(PUBLIC_GETTER) private val Logic2AlloyLanguageMapper_RelationMapper relationMapper = new Logic2AlloyLanguageMapper_RelationMapper(this)
75 @Accessors(PUBLIC_GETTER) private val Logic2AlloyLanguageMapper_Containment containmentMapper = new Logic2AlloyLanguageMapper_Containment(this)
76
77 public new(Logic2AlloyLanguageMapper_TypeMapper typeMapper) {
78 this.typeMapper = typeMapper
79 }
80
81 public def TracedOutput<ALSDocument,Logic2AlloyLanguageMapperTrace> transformProblem(LogicProblem problem, AlloySolverConfiguration config) {
82 val logicLanguage = createALSSignatureBody => [
83 it.multiplicity = ALSMultiplicity.ONE
84 it.declarations +=
85 createALSSignatureDeclaration => [
86 it.name = support.toID(#["util", "language"]) ]
87 ]
88
89 val specification = createALSDocument=>[
90 it.signatureBodies+=logicLanguage
91 ]
92 val trace = new Logic2AlloyLanguageMapperTrace => [
93 it.specification = specification
94 it.logicLanguage = logicLanguage.declarations.head
95 it.logicLanguageBody = logicLanguage
96
97 it.incqueryEngine = ViatraQueryEngine.on(new EMFScope(problem))
98 ]
99
100 typeMapper.transformTypes(problem.types,problem.elements,this,trace)
101
102 trace.constantDefinitions = problem.collectConstantDefinitions
103 trace.functionDefinitions = problem.collectFunctionDefinitions
104 trace.relationDefinitions = problem.collectRelationDefinitions
105
106 problem.constants.forEach[this.constantMapper.transformConstant(it,trace)]
107 problem.functions.forEach[this.functionMapper.transformFunction(it, trace)]
108 problem.relations.forEach[this.relationMapper.transformRelation(it, trace)]
109
110 problem.constants.filter(ConstantDefinition).forEach[this.constantMapper.transformConstantDefinitionSpecification(it,trace)]
111 problem.functions.filter(FunctionDefinition).forEach[this.functionMapper.transformFunctionDefinitionSpecification(it,trace)]
112 problem.relations.filter(RelationDefinition).forEach[this.relationMapper.transformRelationDefinitionSpecification(it,trace)]
113
114 val containment = problem.getContainmentHierarchies.head
115 if(containment !== null) {
116 this.containmentMapper.transformContainmentHierarchy(containment,trace)
117 }
118
119 ////////////////////
120 // Collect EMF-specific assertions
121 ////////////////////
122 val assertion2InverseRelation = problem.annotations.collectAnnotations(InverseRelationAssertion)
123 val assertion2UpperMultiplicityAssertion = problem.annotations.collectAnnotations(UpperMultiplicityAssertion)
124 val assertion2LowerMultiplicityAssertion = problem.annotations.collectAnnotations(LowerMultiplicityAssertion)
125
126 ////////////////////
127 // Transform Assertions
128 ////////////////////
129 for(assertion : problem.assertions) {
130 if(assertion2InverseRelation.containsKey(assertion)) {
131 transformInverseAssertion(assertion.lookup(assertion2InverseRelation),trace)
132 } else if(assertion2UpperMultiplicityAssertion.containsKey(assertion)) {
133 transformUpperMultiplicityAssertion(assertion.lookup(assertion2UpperMultiplicityAssertion),trace)
134 } else if(assertion2LowerMultiplicityAssertion.containsKey(assertion)) {
135 transformLowerMultiplicityAssertion(assertion.lookup(assertion2LowerMultiplicityAssertion),trace)
136 } else {
137 transformAssertion(assertion,trace)
138 }
139 }
140
141 transformRunCommand(specification, trace, config)
142
143 return new TracedOutput(specification,trace)
144 }
145
146 def transformInverseAssertion(InverseRelationAssertion assertion, Logic2AlloyLanguageMapperTrace trace) {
147 val a = assertion.inverseA
148 val b = assertion.inverseB
149 if(a instanceof RelationDeclaration && b instanceof RelationDeclaration &&
150 !trace.relationDefinitions.containsKey(a) && !trace.relationDefinitions.containsKey(b))
151 {
152 val fact = createALSFactDeclaration => [
153 it.name = support.toID(assertion.target.name)
154 it.term = createALSEquals => [
155 it.leftOperand = relationMapper.transformRelationReference(a as RelationDeclaration, trace)
156 it.rightOperand = createALSInverseRelation => [it.operand = relationMapper.transformRelationReference(b as RelationDeclaration, trace) ]
157 ]
158 ]
159 trace.specification.factDeclarations += fact
160 } else {
161 return transformAssertion(assertion.target,trace)
162 }
163 }
164
165 def transformUpperMultiplicityAssertion(UpperMultiplicityAssertion assertion, Logic2AlloyLanguageMapperTrace trace) {
166 val x = assertion.relation
167 if(x instanceof RelationDeclaration && !trace.relationDefinitions.containsKey(x)) {
168 val relation = relationMapper.getRelationReference((x as RelationDeclaration),trace)
169 val type = relation.type
170
171 if(type instanceof ALSDirectProduct) {
172 type.rightMultiplicit = type.rightMultiplicit.addUpper
173 } else {
174 relation.multiplicity = relation.multiplicity.addUpper
175 }
176
177 if(assertion.upper === 1) {
178 return true
179 } else {
180 return transformAssertion(assertion.target,trace)
181 }
182
183 } else {
184 return transformAssertion(assertion.target,trace)
185 }
186 }
187
188 def transformLowerMultiplicityAssertion(LowerMultiplicityAssertion assertion, Logic2AlloyLanguageMapperTrace trace) {
189 val x = assertion.relation
190 if(x instanceof RelationDeclaration && !trace.relationDefinitions.containsKey(x)) {
191 val relation = relationMapper.getRelationReference((x as RelationDeclaration),trace)
192 val type = relation.type
193
194 if(type instanceof ALSDirectProduct) {
195 type.rightMultiplicit = type.rightMultiplicit.addLower
196 } else {
197 relation.multiplicity = relation.multiplicity.addLower
198 }
199
200 if(assertion.lower === 1) {
201 return true
202 } else {
203 return transformAssertion(assertion.target,trace)
204 }
205
206 } else {
207 return transformAssertion(assertion.target,trace)
208 }
209 }
210
211 private def addLower(ALSMultiplicity multiplicity) {
212 if(multiplicity === ALSMultiplicity::SET || multiplicity === null) {
213 return ALSMultiplicity::SOME
214 } else if(multiplicity === ALSMultiplicity::LONE) {
215 return ALSMultiplicity::ONE
216 } else {
217 throw new IllegalArgumentException('''Lower multiplicity is already set!''')
218 }
219 }
220 private def addUpper(ALSMultiplicity multiplicity) {
221 if(multiplicity === ALSMultiplicity::SET || multiplicity === null) {
222 return ALSMultiplicity::LONE
223 } else if(multiplicity === ALSMultiplicity::SOME) {
224 return ALSMultiplicity::ONE
225 } else {
226 throw new IllegalArgumentException('''Upper multiplicity is already set!''')
227 }
228 }
229
230 private def <T extends AssertionAnnotation> collectAnnotations(Collection<? extends Annotation> collection, Class<T> annotationKind) {
231 val res = new HashMap
232 collection.filter(annotationKind).forEach[res.put(it.target,it)]
233 return res
234 }
235
236 private def collectConstantDefinitions(LogicProblem problem) {
237 val res = new HashMap
238 problem.constants.filter(ConstantDefinition).filter[it.defines!==null].forEach[
239 res.put(it.defines,it)
240 ]
241 return res
242 }
243 private def collectFunctionDefinitions(LogicProblem problem) {
244 val res = new HashMap
245 problem.functions.filter(FunctionDefinition).filter[it.defines!==null].forEach[
246 res.put(it.defines,it)
247 ]
248 return res
249 }
250 private def collectRelationDefinitions(LogicProblem problem) {
251 val res = new HashMap
252 problem.relations.filter(RelationDefinition).filter[it.defines!==null].forEach[
253 res.put(it.defines,it)
254 ]
255 return res
256 }
257
258 ////////////////////
259 // Type References
260 ////////////////////
261 def dispatch protected ALSTerm transformTypeReference(BoolTypeReference boolTypeReference, Logic2AlloyLanguageMapperTrace trace) {
262 return createALSReference => [ it.referred = support.getBooleanType(trace) ]
263 }
264 def dispatch protected ALSTerm transformTypeReference(IntTypeReference intTypeReference, Logic2AlloyLanguageMapperTrace trace) { createALSInt }
265 def dispatch protected ALSTerm transformTypeReference(RealTypeReference realTypeReference, Logic2AlloyLanguageMapperTrace trace) {throw new UnsupportedOperationException('''Real types are not supported in Alloy.''')}
266 def dispatch protected ALSTerm transformTypeReference(ComplexTypeReference complexTypeReference, Logic2AlloyLanguageMapperTrace trace) {
267 val types = typeMapper.transformTypeReference(complexTypeReference.referred, this, trace)
268 return support.unfoldPlus(types.map[t|createALSReference=>[referred = t]])
269 }
270
271 //////////////
272 // Scopes
273 //////////////
274
275 def transformRunCommand(ALSDocument specification, Logic2AlloyLanguageMapperTrace trace, AlloySolverConfiguration config) {
276 specification.runCommand = createALSRunCommand => [
277 it.typeScopes+= createALSSigScope => [
278 it.type= typeMapper.getUndefinedSupertype(trace)
279 it.number = typeMapper.getUndefinedSupertypeScope(config.typeScopes.maxNewElements,trace)
280 //it.exactly = (config.typeScopes.maxElements == config.typeScopes.minElements)
281 ]
282 if(config.typeScopes.maxIntScope == LogicSolverConfiguration::Unlimited) throw new UnsupportedOperationException(
283 '''An integer scope have to be specified for Alloy!''')
284 it.typeScopes += createALSIntScope => [
285 number = Integer.SIZE-Integer.numberOfLeadingZeros(config.typeScopes.maxIntScope)
286 ]
287// for(definedScope : config.typeScopes.allDefinedScope) {
288// it.typeScopes += createALSSigScope => [
289// it.type = definedScope.type.lookup(trace.type2ALSType)
290// it.number = definedScope.upperLimit
291// it.exactly = (definedScope.upperLimit == definedScope.lowerLimit)
292// ]
293// }
294 ]
295 }
296
297
298 //////////////
299 // Assertions + Terms
300 //////////////
301
302 def protected transformAssertion(Assertion assertion, Logic2AlloyLanguageMapperTrace trace) {
303 val res = createALSFactDeclaration => [
304 it.name = support.toID(assertion.name)
305 it.term = assertion.value.transformTerm(trace,Collections.EMPTY_MAP)
306 ]
307 trace.specification.factDeclarations += res
308 }
309
310 def dispatch protected ALSTerm transformTerm(BoolLiteral literal, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
311 var ALSEnumLiteral ref;
312 if(literal.value==true) {ref = support.getBooleanTrue(trace)}
313 else {ref = support.getBooleanFalse(trace)}
314 val refFinal = ref
315
316 return support.booleanToLogicValue((createALSReference => [referred = refFinal]),trace)
317 }
318 def dispatch protected ALSTerm transformTerm(RealLiteral literal, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
319 throw new UnsupportedOperationException("RealLiteral is not supported")
320 }
321 def dispatch protected ALSTerm transformTerm(IntLiteral literal, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
322 if(literal.value>=0) { createALSNumberLiteral => [value = literal.value]}
323 else {createALSUnaryMinus => [it.operand = createALSNumberLiteral => [value = literal.value] ] }
324 }
325
326 def dispatch protected ALSTerm transformTerm(Not not, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
327 createALSNot=>[operand = not.operand.transformTerm(trace,variables)] }
328 def dispatch protected ALSTerm transformTerm(And and, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
329 support.unfoldAnd(and.operands.map[transformTerm(trace,variables)]) }
330 def dispatch protected ALSTerm transformTerm(Or or, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
331 support.unfoldOr(or.operands.map[transformTerm(trace,variables)],trace) }
332 def dispatch protected ALSTerm transformTerm(Impl impl, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
333 createALSImpl => [leftOperand = impl.leftOperand.transformTerm(trace,variables) rightOperand = impl.rightOperand.transformTerm(trace,variables)] }
334 def dispatch protected ALSTerm transformTerm(Iff iff, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
335 createALSIff => [leftOperand = iff.leftOperand.transformTerm(trace,variables) rightOperand = iff.rightOperand.transformTerm(trace,variables)] }
336 def dispatch protected ALSTerm transformTerm(MoreThan moreThan, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
337 createALSMore => [leftOperand = moreThan.leftOperand.transformTerm(trace,variables) rightOperand = moreThan.rightOperand.transformTerm(trace,variables)] }
338 def dispatch protected ALSTerm transformTerm(LessThan lessThan, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
339 createALSLess => [leftOperand = lessThan.leftOperand.transformTerm(trace,variables) rightOperand = lessThan.rightOperand.transformTerm(trace,variables)] }
340 def dispatch protected ALSTerm transformTerm(MoreOrEqualThan moreThan, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
341 createALSMeq => [leftOperand = moreThan.leftOperand.transformTerm(trace,variables) rightOperand = moreThan.rightOperand.transformTerm(trace,variables)] }
342 def dispatch protected ALSTerm transformTerm(LessOrEqualThan lessThan, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
343 createALSLeq => [leftOperand = lessThan.leftOperand.transformTerm(trace,variables) rightOperand = lessThan.rightOperand.transformTerm(trace,variables)] }
344 def dispatch protected ALSTerm transformTerm(Equals equals, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
345 createALSEquals => [leftOperand = equals.leftOperand.transformTerm(trace,variables) rightOperand = equals.rightOperand.transformTerm(trace,variables)] }
346 def dispatch protected ALSTerm transformTerm(Distinct distinct, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
347 support.unfoldDistinctTerms(this,distinct.operands,trace,variables) }
348
349 def dispatch protected ALSTerm transformTerm(Plus plus, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
350 createALSFunctionCall => [it.params += plus.leftOperand.transformTerm(trace,variables) it.params += plus.rightOperand.transformTerm(trace,variables) it.referredNumericOperator = ALSNumericOperator.PLUS] }
351 def dispatch protected ALSTerm transformTerm(Minus minus, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
352 createALSFunctionCall => [it.params += minus.leftOperand.transformTerm(trace,variables) it.params += minus.rightOperand.transformTerm(trace,variables) it.referredNumericOperator = ALSNumericOperator.SUB] }
353 def dispatch protected ALSTerm transformTerm(Multiply multiply, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
354 createALSFunctionCall => [it.params += multiply.leftOperand.transformTerm(trace,variables) it.params += multiply.rightOperand.transformTerm(trace,variables) it.referredNumericOperator = ALSNumericOperator.MUL] }
355 def dispatch protected ALSTerm transformTerm(Divison div, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
356 createALSFunctionCall => [it.params += div.leftOperand.transformTerm(trace,variables) it.params += div.rightOperand.transformTerm(trace,variables) it.referredNumericOperator = ALSNumericOperator.DIV] }
357 def dispatch protected ALSTerm transformTerm(Mod mod, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
358 createALSFunctionCall => [it.params += mod.leftOperand.transformTerm(trace,variables) it.params += mod.rightOperand.transformTerm(trace,variables) it.referredNumericOperator = ALSNumericOperator.REM] }
359
360 def dispatch protected ALSTerm transformTerm(Forall forall, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
361 support.createQuantifiedExpression(this,forall,ALSMultiplicity.ALL,trace,variables) }
362 def dispatch protected ALSTerm transformTerm(Exists exists, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
363 support.createQuantifiedExpression(this,exists,ALSMultiplicity.SOME,trace,variables) }
364
365 def dispatch protected ALSTerm transformTerm(InstanceOf instanceOf, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
366 return createALSSubset => [
367 it.leftOperand = instanceOf.value.transformTerm(trace,variables)
368 it.rightOperand = instanceOf.range.transformTypeReference(trace)
369 ]
370 }
371
372 def dispatch protected ALSTerm transformTerm(SymbolicValue symbolicValue, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
373 symbolicValue.symbolicReference.transformSymbolicReference(symbolicValue.parameterSubstitutions,trace,variables) }
374
375 def dispatch protected ALSTerm transformSymbolicReference(DefinedElement referred, List<Term> parameterSubstitutions, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
376 typeMapper.transformReference(referred,trace)}
377 def dispatch protected ALSTerm transformSymbolicReference(ConstantDeclaration constant, List<Term> parameterSubstitutions, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
378 if(trace.constantDefinitions.containsKey(constant)) {
379 return this.transformSymbolicReference(constant.lookup(trace.constantDefinitions),parameterSubstitutions,trace,variables)
380 } else {
381 val res = createALSJoin=> [
382 leftOperand = createALSReference => [ referred = trace.logicLanguage ]
383 rightOperand = createALSReference => [ referred = constant.lookup(trace.constantDeclaration2LanguageField) ]
384 ]
385 return support.postprocessResultOfSymbolicReference(constant.type,res,trace)
386 }
387 }
388 def dispatch protected ALSTerm transformSymbolicReference(ConstantDefinition constant, List<Term> parameterSubstitutions, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
389 val res = createALSFunctionCall => [
390 it.referredDefinition = constant.lookup(trace.constantDefinition2Function)
391 ]
392 return support.postprocessResultOfSymbolicReference(constant.type,res,trace)
393 }
394 def dispatch protected ALSTerm transformSymbolicReference(Variable variable, List<Term> parameterSubstitutions, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
395 val res = createALSReference => [referred = variable.lookup(variables)]
396 return support.postprocessResultOfSymbolicReference(variable.range,res,trace)
397 }
398 def dispatch protected ALSTerm transformSymbolicReference(FunctionDeclaration function, List<Term> parameterSubstitutions, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
399 if(trace.functionDefinitions.containsKey(function)) {
400 return this.transformSymbolicReference(function.lookup(trace.functionDefinitions),parameterSubstitutions,trace,variables)
401 } else {
402 if(functionMapper.transformedToHostedField(function,trace)) {
403 val param = parameterSubstitutions.get(0).transformTerm(trace,variables)
404 val res = createALSJoin => [
405 leftOperand = support.prepareParameterOfSymbolicReference(function.parameters.get(0),param,trace)
406 rightOperand = createALSReference => [referred = function.lookup(trace.functionDeclaration2HostedField)]
407 ]
408 return support.postprocessResultOfSymbolicReference(function.range,res,trace)
409 } else {
410 val functionExpression = createALSJoin=>[
411 leftOperand = createALSReference => [referred = trace.logicLanguage]
412 rightOperand = createALSReference => [referred = function.lookup(trace.functionDeclaration2LanguageField)]
413 ]
414 val res = support.unfoldDotJoin(this,parameterSubstitutions,functionExpression,trace,variables)
415 return support.postprocessResultOfSymbolicReference(function.range,res,trace)
416 }
417 }
418 }
419 def dispatch protected ALSTerm transformSymbolicReference(FunctionDefinition function, List<Term> parameterSubstitutions, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
420 val result = createALSFunctionCall => [
421 it.referredDefinition = function.lookup(trace.functionDefinition2Function)
422 it.params += parameterSubstitutions.map[it.transformTerm(trace,variables)]
423 ]
424 return support.postprocessResultOfSymbolicReference(function.range,result,trace)
425 }
426
427 def dispatch protected ALSTerm transformSymbolicReference(RelationDeclaration relation, List<Term> parameterSubstitutions,
428 Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
429 if(trace.relationDefinitions.containsKey(relation)) {
430 this.transformSymbolicReference(relation.lookup(trace.relationDefinitions),parameterSubstitutions,trace,variables)
431 } else {
432 if(relationMapper.transformToHostedField(relation,trace)) {
433 val alsRelation = relation.lookup(trace.relationDeclaration2Field)
434 // R(a,b) =>
435 // b in a.R
436 return createALSSubset => [
437 it.leftOperand = parameterSubstitutions.get(1).transformTerm(trace,variables)
438 it.rightOperand = createALSJoin => [
439 it.leftOperand = parameterSubstitutions.get(0).transformTerm(trace,variables)
440 it.rightOperand = createALSReference => [ it.referred = alsRelation ]
441 ]
442 ]
443 } else {
444 val target = createALSJoin => [
445 leftOperand = createALSReference => [referred = trace.logicLanguage]
446 rightOperand = createALSReference => [ referred = relation.lookup(trace.relationDeclaration2Global) ]]
447 val source = support.unfoldTermDirectProduct(this,parameterSubstitutions,trace,variables)
448
449 return createALSSubset => [
450 leftOperand = source
451 rightOperand = target
452 ]
453 }
454 }
455 }
456
457
458
459 def dispatch protected ALSTerm transformSymbolicReference(RelationDefinition relation, List<Term> parameterSubstitutions,
460 Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables)
461 {
462 return createALSFunctionCall => [
463 it.referredDefinition = relation.lookup(trace.relationDefinition2Predicate)
464 it.params += parameterSubstitutions.map[p | p.transformTerm(trace,variables)]
465 ]
466 }
467} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapperTrace.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapperTrace.xtend
new file mode 100644
index 00000000..22f49c98
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapperTrace.xtend
@@ -0,0 +1,49 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSDocument
4import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSEnumDeclaration
5import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSEnumLiteral
6import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSFieldDeclaration
7import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSFunctionDefinition
8import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSRelationDefinition
9import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSSignatureBody
10import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSSignatureDeclaration
11import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ConstantDeclaration
12import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ConstantDefinition
13import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.FunctionDeclaration
14import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.FunctionDefinition
15import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration
16import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDefinition
17import java.util.HashMap
18import java.util.Map
19import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
20
21interface Logic2AlloyLanguageMapper_TypeMapperTrace {}
22
23class Logic2AlloyLanguageMapperTrace {
24 public var ViatraQueryEngine incqueryEngine;
25
26 public var ALSDocument specification;
27 public var ALSSignatureDeclaration logicLanguage;
28 public var ALSSignatureBody logicLanguageBody;
29 public var ALSEnumDeclaration boolType;
30 public var ALSEnumLiteral boolTrue;
31 public var ALSEnumLiteral boolFalse;
32
33 public var Logic2AlloyLanguageMapper_TypeMapperTrace typeMapperTrace
34
35 public val Map<ConstantDeclaration, ALSFieldDeclaration> constantDeclaration2LanguageField = new HashMap
36 public val Map<ConstantDefinition, ALSFunctionDefinition> constantDefinition2Function = new HashMap
37
38 public val Map<FunctionDeclaration,ALSFieldDeclaration> functionDeclaration2HostedField = new HashMap
39 public val Map<FunctionDeclaration,ALSFieldDeclaration> functionDeclaration2LanguageField = new HashMap
40 public val Map<FunctionDefinition,ALSFunctionDefinition> functionDefinition2Function = new HashMap
41
42 public val Map<RelationDeclaration,ALSFieldDeclaration> relationDeclaration2Global = new HashMap
43 public val Map<RelationDeclaration, ALSFieldDeclaration> relationDeclaration2Field = new HashMap
44 public val Map<RelationDefinition,ALSRelationDefinition> relationDefinition2Predicate = new HashMap
45
46 public var Map<ConstantDeclaration, ConstantDefinition> constantDefinitions
47 public var Map<FunctionDeclaration, FunctionDefinition> functionDefinitions
48 public var Map<RelationDeclaration, RelationDefinition> relationDefinitions
49} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_ConstantMapper.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_ConstantMapper.xtend
new file mode 100644
index 00000000..401c2ec2
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_ConstantMapper.xtend
@@ -0,0 +1,43 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import hu.bme.mit.inf.dslreasoner.alloyLanguage.AlloyLanguageFactory
4import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ConstantDeclaration
5import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSMultiplicity
6import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ConstantDefinition
7import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
8
9class Logic2AlloyLanguageMapper_ConstantMapper {
10 private val extension AlloyLanguageFactory factory = AlloyLanguageFactory.eINSTANCE
11 private val Logic2AlloyLanguageMapper_Support support = new Logic2AlloyLanguageMapper_Support;
12 val Logic2AlloyLanguageMapper base;
13 public new(Logic2AlloyLanguageMapper base) {
14 this.base = base
15 }
16
17 def protected dispatch transformConstant(ConstantDeclaration constant, Logic2AlloyLanguageMapperTrace trace) {
18 if(!trace.constantDefinitions.containsKey(constant)) {
19 val c = createALSFieldDeclaration=> [
20 name = support.toID(constant.name)
21 it.type = base.transformTypeReference(constant.type,trace)
22 it.multiplicity = ALSMultiplicity.ONE
23 ]
24 trace.logicLanguageBody.fields+= c
25 trace.constantDeclaration2LanguageField.put(constant,c)
26 }
27 }
28
29 def protected dispatch transformConstant(ConstantDefinition constant, Logic2AlloyLanguageMapperTrace trace) {
30 val c = createALSFunctionDefinition=> [
31 name = support.toID(constant.name)
32 it.type = base.transformTypeReference(constant.type,trace)
33 // the value is set later
34 ]
35 trace.specification.functionDefinitions += c
36 trace.constantDefinition2Function.put(constant,c)
37 }
38
39 def protected transformConstantDefinitionSpecification(ConstantDefinition constant, Logic2AlloyLanguageMapperTrace trace) {
40 val definition = constant.lookup(trace.constantDefinition2Function)
41 definition.value = base.transformTerm(constant.value, trace,emptyMap)
42 }
43} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_Containment.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_Containment.xtend
new file mode 100644
index 00000000..fd519c1e
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_Containment.xtend
@@ -0,0 +1,260 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSMultiplicity
4import hu.bme.mit.inf.dslreasoner.alloyLanguage.AlloyLanguageFactory
5import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguageFactory
6import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration
7import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.ContainmentHierarchy
8import java.util.HashMap
9
10class Logic2AlloyLanguageMapper_Containment {
11 val extension AlloyLanguageFactory factory = AlloyLanguageFactory.eINSTANCE
12 private val Logic2AlloyLanguageMapper_Support support = new Logic2AlloyLanguageMapper_Support;
13 val Logic2AlloyLanguageMapper base;
14 public new(Logic2AlloyLanguageMapper base) {
15 this.base = base
16 }
17
18 def protected transformContainmentHierarchy(ContainmentHierarchy containment, Logic2AlloyLanguageMapperTrace trace) {
19 // Single root
20 val rootField = createALSFieldDeclaration => [
21 it.name= support.toID(#["util", "root"])
22 it.multiplicity = ALSMultiplicity.ONE
23 it.type = typesOrderedInContainment(containment,trace)
24 ]
25 trace.logicLanguageBody.fields += rootField
26
27 val contains = createALSFieldDeclaration => [
28 it.name = support.toID(#["util", "contains"])
29 //it.multiplicity = ALSMultiplicity::SET
30 it.type = createALSDirectProduct => [
31 it.leftMultiplicit = ALSMultiplicity::LONE
32 it.rightMultiplicit = ALSMultiplicity::SET
33 it.leftOperand = typesOrderedInContainment(containment,trace)
34 it.rightOperand = typesOrderedInContainment(containment,trace)
35 ]
36 ]
37 trace.logicLanguageBody.fields += contains
38
39 val containmentRelationDefinition = createALSFactDeclaration => [
40 it.name = support.toID(#["util", "containmentDefinition"])
41 ]
42
43 if(containment.containmentRelations.forall[it instanceof RelationDeclaration]) {
44 val containmentRelations = containment.containmentRelations.filter(RelationDeclaration).map[relation|
45 base.relationMapper.transformRelationReference(relation,trace)
46 ].toList
47
48 containmentRelationDefinition.term = createALSEquals => [
49 leftOperand = createALSJoin => [
50 leftOperand = createALSReference => [referred = trace.logicLanguage]
51 rightOperand = createALSReference => [ referred = contains ]]
52 rightOperand = support.unfoldPlus(containmentRelations)
53 ]
54 } else {
55 val parent = createALSVariableDeclaration => [
56 it.name = "parent"
57 it.range = typesOrderedInContainment(containment, trace)
58 ]
59 val child = createALSVariableDeclaration => [
60 it.name = "child"
61 it.range = typesOrderedInContainment(containment, trace)
62 ]
63
64 val logicFactory = LogiclanguageFactory.eINSTANCE
65 val logicParentVariable = logicFactory.createVariable
66 val logicChildVariable = logicFactory.createVariable
67 val logicParent = logicFactory.createSymbolicValue => [it.symbolicReference = logicParentVariable]
68 val logicChild = logicFactory.createSymbolicValue => [it.symbolicReference = logicChildVariable]
69 val variableMap = new HashMap => [put(logicParentVariable,parent) put(logicChildVariable,child)]
70 val possibleRelations = containment.containmentRelations.map[relation |
71 base.transformSymbolicReference(relation,#[logicParent,logicChild],trace,variableMap)
72 ]
73
74 containmentRelationDefinition.term = createALSQuantifiedEx => [
75 it.type = ALSMultiplicity.ALL
76 it.variables += parent
77 it.variables += child
78 it.expression = createALSIff => [
79 it.leftOperand = createALSSubset => [
80 it.leftOperand = createALSDirectProduct => [
81 it.leftOperand = createALSReference => [it.referred = child]
82 it.rightOperand = createALSReference => [it.referred = parent]
83 ]
84 it.rightOperand = createALSJoin => [
85 leftOperand = createALSReference => [referred = trace.logicLanguage]
86 rightOperand = createALSReference => [ referred = contains ]
87 ]
88 ]
89 it.rightOperand = support.unfoldOr(possibleRelations,trace)
90 ]
91 ]
92 }
93
94 trace.specification.factDeclarations += containmentRelationDefinition
95
96 // With the exception of the root, every object has at least one parent
97 // No parent for root
98 trace.specification.factDeclarations += createALSFactDeclaration => [
99 it.name = support.toID(#["util", "noParentForRoot"])
100 it.term = createALSQuantifiedEx => [
101 it.type = ALSMultiplicity::NO
102 val parent = createALSVariableDeclaration => [
103 it.name = "parent"
104 it.range = typesOrderedInContainment(containment,trace)
105 ]
106 it.variables += parent
107 it.expression = createALSSubset => [
108 it.leftOperand = createALSDirectProduct => [
109 it.leftOperand = createALSReference => [it.referred = parent]
110 it.rightOperand = createALSJoin => [
111 it.leftOperand = createALSReference => [it.referred = trace.logicLanguage]
112 it.rightOperand = createALSReference => [it.referred = rootField]
113 ]
114 ]
115 it.rightOperand = createALSJoin => [
116 leftOperand = createALSReference => [referred = trace.logicLanguage]
117 rightOperand = createALSReference => [ referred = contains ]
118 ]
119 ]
120 ]
121 ]
122 // Parent for nonroot
123 trace.specification.factDeclarations += createALSFactDeclaration => [
124 it.name = support.toID(#["util", "atLeastOneParent"])
125 it.term = createALSQuantifiedEx => [
126 it.type = ALSMultiplicity::ALL
127 val child = createALSVariableDeclaration => [
128 it.name = "child"
129 it.range = typesOrderedInContainment(containment,trace)
130 ]
131 it.variables += child
132 it.expression = createALSOr => [
133 it.leftOperand = createALSEquals => [
134 it.leftOperand = createALSReference => [it.referred = child]
135 it.rightOperand = createALSJoin => [
136 it.leftOperand = createALSReference => [it.referred = trace.logicLanguage]
137 it.rightOperand = createALSReference => [it.referred = rootField]
138 ]
139 ]
140 it.rightOperand = createALSQuantifiedEx => [
141 it.type = ALSMultiplicity::SOME
142 val parent = createALSVariableDeclaration => [
143 it.name = "parent"
144 it.range = typesOrderedInContainment(containment, trace)
145 ]
146 it.variables += parent
147 it.expression = createALSSubset => [
148 it.leftOperand = createALSDirectProduct => [
149 it.leftOperand = createALSReference => [it.referred = parent]
150 it.rightOperand = createALSReference => [it.referred = child]
151 ]
152 it.rightOperand = createALSJoin => [
153 leftOperand = createALSReference => [referred = trace.logicLanguage]
154 rightOperand = createALSReference => [ referred = contains ]
155 ]
156 ]
157 ]
158 ]
159 ]
160 ]
161
162 // Every object has at most one parent
163// trace.specification.factDeclarations += createALSFactDeclaration => [
164// it.name = support.toID(#["util", "atMostOneParent"])
165// it.term = createALSQuantifiedEx => [
166// it.type = ALSMultiplicity::ALL
167// val child = createALSVariableDeclaration => [
168// it.name = "child"
169// it.range = typesOrderedInContainment(containment,trace)
170// ]
171// it.variables += child
172// it.expression = createALSQuantifiedEx => [
173// it.type = ALSMultiplicity::LONE
174// val parent = createALSVariableDeclaration => [
175// it.name = "parent"
176// it.range = typesOrderedInContainment(containment, trace)
177// ]
178// it.variables += parent
179// it.expression = createALSFunctionCall => [
180// it.referredDefinition = containmentRelation
181// it.params += createALSReference => [
182// it.referred = parent
183// it.referred = child
184// ]
185// ]
186// ]
187// ]
188// ]
189
190 // No circle in containment
191 trace.specification.factDeclarations += createALSFactDeclaration => [
192 it.name = support.toID(#["util", "noCircularContainment"])
193 it.term = createALSQuantifiedEx => [
194 it.type = ALSMultiplicity::NO
195 val variable = createALSVariableDeclaration => [
196 it.name = "circle"
197 it.range = typesOrderedInContainment(containment,trace)
198 ]
199 it.variables += variable
200 it.expression = createALSSubset => [
201 it.leftOperand = createALSDirectProduct => [
202 it.leftOperand = createALSReference => [it.referred = variable]
203 it.rightOperand = createALSReference => [it.referred = variable]
204 ]
205 it.rightOperand = createAlSTransitiveClosure => [
206 it.operand = createALSJoin => [
207 leftOperand = createALSReference => [referred = trace.logicLanguage]
208 rightOperand = createALSReference => [ referred = contains ]
209 ]
210 ]
211 ]
212 ]
213 ]
214
215 }
216
217 /*def protected calculateContainmentTypeCoveringSignatures(ContainmentHierarchy containment, Logic2AlloyLanguageMapperTrace trace) {
218 val types = containment.typesOrderedInHierarchy
219 val signaturesInContainment = types.map[base.typeMapper.transformTypeReference(it, base, trace)].flatten.toList
220// val uncoveredSignatures = new ArrayList(signaturesInContainment)
221// val coveringSignatures = new LinkedList
222//
223 val engine = ViatraQueryEngine.on(new EMFScope(trace.specification))
224 //val directSubsetMatcher = DirectSubsetMatcher.on(engine)
225 // x <= y
226 val subsetMatcher = SubsetMatcher.on(engine)
227
228 if()
229 }*/
230
231 /*def boolean coveringAllSignaturesInContainment(ALSSignatureDeclaration target, List<ALSSignatureDeclaration> signaturesInContainment, SubsetMatcher matcher) {
232 for(signatureInContainment : signaturesInContainment) {
233 if(!matcher.hasMatch(signatureInContainment,target)) {
234 return false
235 }
236 }
237 return true
238 }*/
239
240 /*def boolean coveringSignatureNotInContainment(ALSSignatureDeclaration target, List<ALSSignatureDeclaration> signaturesInContainment, SubsetMatcher matcher) {
241 val subtypes = matcher.getAllValuesOfx(target);
242 for(subType : subtypes) {
243 val isSubtypeOfASignatureInContainment = signaturesInContainment.exists[contained |
244 matcher.hasMatch(subType,contained)
245 ]
246 if(!isSubtypeOfASignatureInContainment) {
247 return false
248 }
249 }
250 return true
251 }*/
252
253 def protected typesOrderedInContainment(ContainmentHierarchy containment, Logic2AlloyLanguageMapperTrace trace) {
254 val types = containment.typesOrderedInHierarchy
255 val signaturesInContainment = types.map[base.typeMapper.transformTypeReference(it, base, trace)].flatten
256 // val allSignatures = trace.specification.signatureBodies.map[declarations].flatten
257 val typeReferences = signaturesInContainment.map[sig | createALSReference => [it.referred = sig]].toList
258 return support.unfoldPlus(typeReferences)
259 }
260} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_FunctionMapper.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_FunctionMapper.xtend
new file mode 100644
index 00000000..ff18ef80
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_FunctionMapper.xtend
@@ -0,0 +1,87 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import hu.bme.mit.inf.dslreasoner.alloyLanguage.AlloyLanguageFactory
4import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.FunctionDeclaration
5import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference
6import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSMultiplicity
7import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSSignatureBody
8import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.FunctionDefinition
9import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
10import java.util.HashMap
11
12class Logic2AlloyLanguageMapper_FunctionMapper {
13 private val extension AlloyLanguageFactory factory = AlloyLanguageFactory.eINSTANCE
14 private val Logic2AlloyLanguageMapper_Support support = new Logic2AlloyLanguageMapper_Support;
15 val Logic2AlloyLanguageMapper base;
16 public new(Logic2AlloyLanguageMapper base) {
17 this.base = base
18 }
19
20 def protected dispatch transformFunction(FunctionDeclaration f, Logic2AlloyLanguageMapperTrace trace) {
21 if(!trace.constantDefinitions.containsKey(f)) {
22 if(transformedToHostedField(f,trace)) transformFunctionToFieldOfSignature(f,trace)
23 else transformFunctionToGlobalRelation(f,trace)
24 }
25 }
26
27 def protected transformedToHostedField(FunctionDeclaration f, Logic2AlloyLanguageMapperTrace trace) {
28 if(f.parameters.size == 1 && f.parameters.head instanceof ComplexTypeReference) {
29 val head = f.parameters.head
30 if(head instanceof ComplexTypeReference) {
31 val types = base.typeMapper.transformTypeReference(head.referred,base,trace)
32 return types.size == 1
33 }
34 }
35 return (f.parameters.size == 1 && f.parameters.head instanceof ComplexTypeReference)
36 }
37 def protected transformFunctionToFieldOfSignature(FunctionDeclaration f,Logic2AlloyLanguageMapperTrace trace) {
38 val param = (f.parameters.head as ComplexTypeReference)
39 val referred = param.referred
40 val field = createALSFieldDeclaration => [
41 it.name = support.toID(f.getName)
42 it.multiplicity = ALSMultiplicity.ONE
43 it.type = base.transformTypeReference(f.range,trace)
44 ]
45 val host = base.typeMapper.transformTypeReference(referred,base,trace).get(0)
46 (host.eContainer as ALSSignatureBody).fields += field
47 trace.functionDeclaration2HostedField.put(f, field)
48 }
49 def protected transformFunctionToGlobalRelation(FunctionDeclaration f, Logic2AlloyLanguageMapperTrace trace) {
50 val field = createALSFieldDeclaration => [
51 it.name = support.toID(f.name)
52 it.multiplicity = ALSMultiplicity.SET
53 it.type = createALSDirectProduct => [
54 it.leftOperand = support.unfoldReferenceDirectProduct(base,f.parameters,trace)
55 it.rightMultiplicit = ALSMultiplicity.ONE
56 it.rightOperand = base.transformTypeReference(f.range,trace)
57 ]
58 ]
59 trace.logicLanguageBody.fields += field
60 trace.functionDeclaration2LanguageField.put(f, field)
61 }
62
63 def protected dispatch transformFunction(FunctionDefinition f, Logic2AlloyLanguageMapperTrace trace) {
64 val res = createALSFunctionDefinition => [
65 name = support.toID(f.name)
66 // variables + specification later
67 ]
68 trace.specification.functionDefinitions+=res;
69 trace.functionDefinition2Function.put(f,res)
70 }
71
72 def protected transformFunctionDefinitionSpecification(FunctionDefinition f, Logic2AlloyLanguageMapperTrace trace) {
73 val target = f.lookup(trace.functionDefinition2Function)
74 val variableMap = new HashMap
75 for(variable : f.variable) {
76 val v = createALSVariableDeclaration => [
77 it.name = support.toID(variable.name)
78 it.range = base.transformTypeReference(variable.range,trace)
79 // specification later
80 ]
81 target.variables+=v
82 variableMap.put(variable,v)
83 }
84 target.value = base.transformTerm(f.value,trace,variableMap)
85 }
86
87} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_RelationMapper.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_RelationMapper.xtend
new file mode 100644
index 00000000..9dd4da2f
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_RelationMapper.xtend
@@ -0,0 +1,111 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSMultiplicity
4import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSSignatureBody
5import hu.bme.mit.inf.dslreasoner.alloyLanguage.AlloyLanguageFactory
6import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference
7import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration
8import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDefinition
9import java.util.HashMap
10
11import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
12
13class Logic2AlloyLanguageMapper_RelationMapper {
14 private val extension AlloyLanguageFactory factory = AlloyLanguageFactory.eINSTANCE
15 private val Logic2AlloyLanguageMapper_Support support = new Logic2AlloyLanguageMapper_Support;
16 val Logic2AlloyLanguageMapper base;
17 public new(Logic2AlloyLanguageMapper base) {
18 this.base = base
19 }
20
21 def dispatch protected void transformRelation(RelationDeclaration r, Logic2AlloyLanguageMapperTrace trace) {
22 if(!trace.relationDefinitions.containsKey(r)) {
23 if(r.transformToHostedField(trace)) {
24 transformRelationDeclarationToHostedField(r,trace)
25 } else {
26 transformRelationDeclarationToGlobalField(r,trace)
27 }
28 }
29 }
30
31 def protected transformToHostedField(RelationDeclaration r, Logic2AlloyLanguageMapperTrace trace) {
32 val first = r.parameters.get(0)
33 if(r.parameters.size == 2) {
34 if(first instanceof ComplexTypeReference) {
35 val types = base.typeMapper.transformTypeReference(first.referred,base,trace)
36 if(types.size == 1) {
37 return true
38 }
39 }
40 }
41 return false
42 }
43
44 def protected transformRelationDeclarationToHostedField(RelationDeclaration r, Logic2AlloyLanguageMapperTrace trace) {
45 val hostType = (r.parameters.head as ComplexTypeReference).referred
46
47 val targetBody = base.typeMapper.transformTypeReference(hostType,base,trace).get(0).eContainer as ALSSignatureBody
48 val field = createALSFieldDeclaration => [
49 it.name = support.toID(r.getName)
50 it.multiplicity = ALSMultiplicity.SET
51 it.type = base.transformTypeReference(r.parameters.get(1),trace)
52 ]
53 targetBody.fields += field
54 trace.relationDeclaration2Field.put(r,field)
55
56 }
57
58 def protected transformRelationDeclarationToGlobalField(RelationDeclaration r, Logic2AlloyLanguageMapperTrace trace) {
59 val field = createALSFieldDeclaration => [
60 it.name = support.toID(r.name)
61 it.type = support.unfoldReferenceDirectProduct(base,r.parameters,trace)
62 ]
63 trace.logicLanguageBody.fields += field
64 trace.relationDeclaration2Global.put(r, field)
65 }
66
67 def dispatch protected void transformRelation(RelationDefinition r, Logic2AlloyLanguageMapperTrace trace) {
68 val res = createALSRelationDefinition => [
69 name = support.toID(r.name)
70 // fill the variables later
71 // fill the expression later
72 ]
73
74 trace.relationDefinition2Predicate.put(r,res)
75 trace.specification.relationDefinitions+=res;
76 }
77
78 def protected void transformRelationDefinitionSpecification(RelationDefinition r, Logic2AlloyLanguageMapperTrace trace) {
79 val predicate = r.lookup(trace.relationDefinition2Predicate)
80 if(predicate !== null) {
81 val variableMap = new HashMap
82 for(variable : r.variables) {
83 val v = createALSVariableDeclaration => [
84 it.name = support.toID(variable.name)
85 it.range = base.transformTypeReference(variable.range,trace)
86 ]
87 predicate.variables+=v
88 variableMap.put(variable,v)
89 }
90 predicate.value = base.transformTerm(r.value,trace,variableMap)
91 }
92 }
93
94 def public transformRelationReference(RelationDeclaration relation, Logic2AlloyLanguageMapperTrace trace) {
95 if(relation.transformToHostedField(trace)) {
96 return createALSReference => [it.referred = relation.lookup(trace.relationDeclaration2Field) ]
97 } else {
98 return createALSJoin => [
99 leftOperand = createALSReference => [referred = trace.logicLanguage]
100 rightOperand = createALSReference => [ referred = relation.lookup(trace.relationDeclaration2Global) ]]
101 }
102 }
103
104 def public getRelationReference(RelationDeclaration relation, Logic2AlloyLanguageMapperTrace trace) {
105 if(relation.transformToHostedField(trace)) {
106 return relation.lookup(trace.relationDeclaration2Field)
107 } else {
108 return relation.lookup(trace.relationDeclaration2Global)
109 }
110 }
111} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_Support.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_Support.xtend
new file mode 100644
index 00000000..39896c27
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_Support.xtend
@@ -0,0 +1,207 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSEquals
4import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSMultiplicity
5import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSReference
6import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSTerm
7import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSVariableDeclaration
8import hu.bme.mit.inf.dslreasoner.alloyLanguage.AlloyLanguageFactory
9import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolTypeReference
10import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.QuantifiedExpression
11import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Term
12import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeReference
13import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Variable
14import java.util.ArrayList
15import java.util.HashMap
16import java.util.List
17import java.util.Map
18import org.eclipse.emf.ecore.util.EcoreUtil
19
20class Logic2AlloyLanguageMapper_Support {
21 private val extension AlloyLanguageFactory factory = AlloyLanguageFactory.eINSTANCE
22
23 /// ID handling
24 def protected String toIDMultiple(String... ids) {
25 ids.map[it.split("\\s+").join("'")].join("'")
26 }
27
28 def protected String toID(String ids) {
29 ids.split("\\s+").join("'")
30 }
31 def protected String toID(List<String> ids) {
32 ids.map[it.split("\\s+").join("'")].join("'")
33 }
34
35 /// Support functions
36
37 def protected getBooleanType(Logic2AlloyLanguageMapperTrace trace) {
38 if(trace.boolType!=null) {
39 return trace.boolType
40 } else {
41 trace.boolType = createALSEnumDeclaration => [
42 it.name = toID(#["util","boolean"])
43 trace.boolTrue = createALSEnumLiteral =>[it.name=toID(#["util","boolean","true"])]
44 it.literal += trace.boolTrue
45 trace.boolFalse = createALSEnumLiteral =>[it.name=toID(#["util","boolean","false"])]
46 it.literal += trace.boolFalse
47 ]
48 trace.specification.enumDeclarations+=trace.boolType
49 return trace.boolType
50 }
51 }
52 def protected getBooleanTrue(Logic2AlloyLanguageMapperTrace trace) {
53 getBooleanType(trace)
54 return trace.boolTrue
55 }
56 def protected getBooleanFalse(Logic2AlloyLanguageMapperTrace trace) {
57 getBooleanType(trace)
58 return trace.boolFalse
59 }
60
61 def protected booleanToLogicValue(ALSTerm boolReference, Logic2AlloyLanguageMapperTrace trace) {
62 //println((boolReference as ALSReference).referred)
63 createALSEquals => [
64 leftOperand = EcoreUtil.copy(boolReference)
65 rightOperand = createALSReference => [referred = getBooleanTrue(trace)]
66 ]
67 }
68 def protected booleanToEnumValue(ALSTerm value, Logic2AlloyLanguageMapperTrace trace) {
69 if(value instanceof ALSEquals) {
70 val rightOperand = value.rightOperand
71 if(rightOperand instanceof ALSReference) {
72 if(rightOperand.referred == getBooleanTrue(trace)) {
73 return value.leftOperand
74 }
75 }
76 }
77 return value;
78 }
79 def protected prepareParameterOfSymbolicReference(TypeReference type, ALSTerm term, Logic2AlloyLanguageMapperTrace trace) {
80 if(type instanceof BoolTypeReference) {
81 return booleanToEnumValue(term,trace)
82 }
83 else return term
84 }
85 def protected postprocessResultOfSymbolicReference(TypeReference type, ALSTerm term, Logic2AlloyLanguageMapperTrace trace) {
86 if(type instanceof BoolTypeReference) {
87 return booleanToLogicValue(term,trace)
88 }
89 else return term
90 }
91
92 def protected ALSTerm unfoldAnd(List<? extends ALSTerm> operands) {
93 if(operands.size == 1) { return operands.head }
94 else if(operands.size > 1) { return createALSAnd=>[
95 leftOperand=operands.head
96 rightOperand=operands.subList(1,operands.size).unfoldAnd
97 ]}
98 else throw new UnsupportedOperationException('''Logic operator with 0 operands!''')
99 }
100
101 def protected ALSTerm unfoldOr(List<? extends ALSTerm> operands, Logic2AlloyLanguageMapperTrace trace) {
102 if(operands.size == 0) { return unfoldTrueStatement(trace)}
103 else if(operands.size == 1) { return operands.head }
104 else if(operands.size > 1) { return createALSOr=>[
105 leftOperand=operands.head
106 rightOperand=unfoldOr(operands.subList(1,operands.size),trace)
107 ]}
108 //else throw new UnsupportedOperationException('''Logic operator with 0 operands!''')
109 }
110
111 protected def unfoldTrueStatement(Logic2AlloyLanguageMapperTrace trace) {
112 createALSEquals => [
113 it.leftOperand = createALSReference => [it.referred = getBooleanTrue(trace)]
114 it.rightOperand = createALSReference => [it.referred = getBooleanTrue(trace)]
115 ]
116 }
117
118 protected def unfoldTFalseStatement(Logic2AlloyLanguageMapper m, Logic2AlloyLanguageMapperTrace trace) {
119 createALSEquals => [
120 it.leftOperand = createALSReference => [it.referred = getBooleanTrue(trace)]
121 it.rightOperand = createALSReference => [it.referred = getBooleanTrue(trace)]
122 ]
123 }
124
125 def protected ALSTerm unfoldPlus(List<? extends ALSTerm> operands) {
126 if(operands.size == 1) { return operands.head }
127 else if(operands.size > 1) { return createALSPlus=>[
128 leftOperand=operands.head
129 rightOperand=operands.subList(1,operands.size).unfoldPlus
130 ]}
131 else return createALSNone
132 }
133
134 def protected ALSTerm unfoldIntersection(List<? extends ALSTerm> operands) {
135 if(operands.size == 1) { return operands.head }
136 else if(operands.size > 1) { return createALSIntersection=>[
137 leftOperand=operands.head
138 rightOperand=operands.subList(1,operands.size).unfoldIntersection
139 ]}
140 else throw new UnsupportedOperationException('''Logic operator with 0 operands!''')
141 }
142
143 def protected ALSTerm unfoldDistinctTerms(Logic2AlloyLanguageMapper m, List<Term> operands, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
144 if(operands.size == 1) { return m.transformTerm(operands.head,trace,variables) }
145 else if(operands.size > 1) {
146 val notEquals = new ArrayList<ALSTerm>(operands.size*operands.size/2)
147 for(i:0..<operands.size) {
148 for(j: i+1..<operands.size) {
149 notEquals+=createALSNotEquals=>[
150 leftOperand = m.transformTerm(operands.get(i),trace,variables)
151 rightOperand = m.transformTerm(operands.get(j),trace,variables)
152 ]
153 }
154 }
155 return notEquals.unfoldAnd
156 }
157 else throw new UnsupportedOperationException('''Logic operator with 0 operands!''')
158 }
159
160 def protected ALSTerm unfoldReferenceDirectProduct(Logic2AlloyLanguageMapper m, List<TypeReference> references,Logic2AlloyLanguageMapperTrace trace) {
161 if(references.size == 1) return m.transformTypeReference(references.head,trace)
162 else if(references.size > 1) return createALSDirectProduct => [
163 it.leftOperand = m.transformTypeReference(references.head,trace)
164 it.rightOperand = unfoldReferenceDirectProduct(m,references.subList(1,references.size),trace)
165 ]
166 else throw new UnsupportedOperationException
167 }
168
169 def protected ALSTerm unfoldDotJoin(Logic2AlloyLanguageMapper m, List<Term> elements, ALSTerm target, Logic2AlloyLanguageMapperTrace trace,
170 Map<Variable, ALSVariableDeclaration> variables) {
171 if (elements.size == 1) {
172 return createALSJoin => [
173 it.leftOperand = m.transformTerm(elements.head,trace, variables)
174 it.rightOperand = target
175 ]
176 } else if (elements.size > 1) {
177 return createALSJoin => [
178 it.leftOperand = m.transformTerm(elements.last,trace, variables)
179 it.rightOperand = m.unfoldDotJoin(elements.subList(0, elements.size - 1), target, trace, variables)
180 ]
181 } else
182 throw new UnsupportedOperationException
183 }
184
185 def protected ALSTerm unfoldTermDirectProduct(Logic2AlloyLanguageMapper m, List<Term> references,Logic2AlloyLanguageMapperTrace trace,Map<Variable, ALSVariableDeclaration> variables) {
186 if(references.size == 1) return m.transformTerm(references.head,trace,variables)
187 else if(references.size > 1) return createALSDirectProduct => [
188 it.leftOperand = m.transformTerm(references.head,trace,variables)
189 it.rightOperand = unfoldTermDirectProduct(m,references.subList(1,references.size),trace, variables)
190 ]
191 else throw new UnsupportedOperationException
192 }
193
194 def protected createQuantifiedExpression(Logic2AlloyLanguageMapper m, QuantifiedExpression q, ALSMultiplicity multiplicity, Logic2AlloyLanguageMapperTrace trace, Map<Variable, ALSVariableDeclaration> variables) {
195 val variableMap = q.quantifiedVariables.toInvertedMap[v | createALSVariableDeclaration=> [
196 it.name = toID(v.name)
197 it.range = m.transformTypeReference(v.range,trace) ]]
198
199 createALSQuantifiedEx=>[
200 it.type = multiplicity
201 it.variables += variableMap.values
202 it.expression = m.transformTerm(q.expression,trace,variables.withAddition(variableMap))
203 ]
204 }
205
206 def protected withAddition(Map<Variable, ALSVariableDeclaration> v1, Map<Variable, ALSVariableDeclaration> v2) { new HashMap(v1) => [putAll(v2)] }
207} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper.xtend
new file mode 100644
index 00000000..9927f1cc
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper.xtend
@@ -0,0 +1,16 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSSignatureDeclaration
4import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSTerm
5import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
6import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
7import java.util.Collection
8import java.util.List
9
10interface Logic2AlloyLanguageMapper_TypeMapper {
11 def void transformTypes(Collection<Type> types, Collection<DefinedElement> elements, Logic2AlloyLanguageMapper mapper, Logic2AlloyLanguageMapperTrace trace);
12 def List<ALSSignatureDeclaration> transformTypeReference(Type referred, Logic2AlloyLanguageMapper mapper, Logic2AlloyLanguageMapperTrace trace)
13 def ALSSignatureDeclaration getUndefinedSupertype(Logic2AlloyLanguageMapperTrace trace)
14 def int getUndefinedSupertypeScope(int undefinedScope,Logic2AlloyLanguageMapperTrace trace)
15 def ALSTerm transformReference(DefinedElement referred,Logic2AlloyLanguageMapperTrace trace)
16}
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper_FilteredTypes.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper_FilteredTypes.xtend
new file mode 100644
index 00000000..ade9860b
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper_FilteredTypes.xtend
@@ -0,0 +1,268 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.queries.TypeQueries
4import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSMultiplicity
5import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSSignatureBody
6import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSSignatureDeclaration
7import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSTerm
8import hu.bme.mit.inf.dslreasoner.alloyLanguage.AlloyLanguageFactory
9import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
10import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
11import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition
12import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage
13import java.util.ArrayList
14import java.util.Collection
15import java.util.HashMap
16import java.util.List
17import java.util.Map
18
19import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
20
21class Logic2AlloyLanguageMapper_TypeMapperTrace_FilteredTypes
22 implements Logic2AlloyLanguageMapper_TypeMapperTrace
23{
24 public var ALSSignatureDeclaration objectSupperClass;
25 public val Map<Type, ALSSignatureDeclaration> type2ALSType = new HashMap;
26 public val Map<DefinedElement, ALSSignatureDeclaration> definedElement2Declaration = new HashMap
27}
28/**
29 * Each object is an element of an Object set, and types are subsets of the objects.
30 */
31class Logic2AlloyLanguageMapper_TypeMapper_FilteredTypes implements Logic2AlloyLanguageMapper_TypeMapper{
32 private val Logic2AlloyLanguageMapper_Support support = new Logic2AlloyLanguageMapper_Support;
33 private val extension AlloyLanguageFactory factory = AlloyLanguageFactory.eINSTANCE
34
35 new() {
36 // Initialize package
37 LogicproblemPackage.eINSTANCE.class
38 }
39
40 override transformTypes(Collection<Type> types, Collection<DefinedElement> elements, Logic2AlloyLanguageMapper mapper, Logic2AlloyLanguageMapperTrace trace) {
41 val typeTrace = new Logic2AlloyLanguageMapper_TypeMapperTrace_FilteredTypes
42 trace.typeMapperTrace = typeTrace
43
44 // 1. A global type for Objects is created
45 val objectSig = createALSSignatureDeclaration => [it.name = support.toID(#["util","Object"])]
46 val objectBody = createALSSignatureBody => [
47 it.declarations += objectSig
48 it.abstract = true
49 ]
50 typeTrace.objectSupperClass = objectSig
51 trace.specification.signatureBodies += objectBody
52
53 // 2. Each type is mapped to a unique sig
54 for(type : types) {
55 val sig = createALSSignatureDeclaration => [it.name = support.toIDMultiple("type",type.name)]
56 val body = createALSSignatureBody => [it.declarations += sig]
57 trace.specification.signatureBodies += body
58 typeTrace.type2ALSType.put(type,sig)
59 }
60
61 // 3. The elements of a defined type is mapped to singleton signatures
62 // 3.1 Collect the elements
63 val elementMatcher = TypeQueries.instance.getLowestCommonSupertypeOfAllOccuranceOfElement(trace.incqueryEngine)
64 val topmostType2Elements = new HashMap<ALSSignatureDeclaration,List<DefinedElement>>
65 for(element : elements) {
66 val topmostTypes = elementMatcher.getAllValuesOftype(element)
67 var ALSSignatureDeclaration selectedTopmostType;
68 if(topmostTypes.empty) {
69 selectedTopmostType = objectSig
70 } else{
71 selectedTopmostType = topmostTypes.head.lookup(typeTrace.type2ALSType)
72 }
73 topmostType2Elements.putOrAddToList(selectedTopmostType,element)
74 }
75
76 // 4. For each topmost types several singleton classes are generated, which represents the elements.
77 // For the sake of clarity, common bodies are used.
78 for(topmostEntry : topmostType2Elements.entrySet) {
79
80 for(element : topmostEntry.value) {
81 val signature = createALSSignatureDeclaration => [it.name = support.toIDMultiple("element",element.name)]
82 typeTrace.definedElement2Declaration.put(element,signature)
83 }
84
85 val body = createALSSignatureBody => [
86 it.multiplicity = ALSMultiplicity.ONE
87 it.declarations += topmostEntry.value.map[it.lookup(typeTrace.definedElement2Declaration)]
88 ]
89
90 val containerLogicType = topmostEntry.key
91 body.superset += containerLogicType
92
93 trace.specification.signatureBodies+=body
94 }
95
96 // 5.1 Each Defined Type is specified as the union of its elements
97 for(definedType : types.filter(TypeDefinition)) {
98 trace.specification.factDeclarations += createALSFactDeclaration => [
99 it.name = support.toIDMultiple("typedefinition",definedType.name)
100 it.term = createALSEquals => [
101 it.leftOperand = createALSReference => [ it.referred = definedType.lookup(typeTrace.type2ALSType) ]
102 it.rightOperand = support.unfoldPlus(definedType.elements.map[e|
103 createALSReference => [it.referred = e.lookup(typeTrace.definedElement2Declaration)]])
104 ]
105 ]
106 }
107 // 5.2 Each Defined Element is unique
108 for(definedType : types.filter(TypeDefinition)) {
109 val allElementsIncludingSubtypes =
110 definedType.<Type>transitiveClosureStar[it.subtypes].filter(TypeDefinition)
111 .map[elements].flatten.toSet.toList
112 if(allElementsIncludingSubtypes.size>=2) {
113 trace.specification.factDeclarations += createALSFactDeclaration => [
114 it.name = support.toIDMultiple("typeElementsUnique",definedType.name)
115 it.term = unfoldDistinctElements(allElementsIncludingSubtypes,trace)
116 ]
117 }
118 }
119
120 // 6. Each inheritance is modeled by subset operator 'in'
121 for(type : types) {
122 val sigBody = type.lookup(typeTrace.type2ALSType).eContainer as ALSSignatureBody
123 if(type.supertypes.empty) {
124 sigBody.superset += typeTrace.objectSupperClass
125 } else {
126 sigBody.superset += type.supertypes.map[lookup(typeTrace.type2ALSType)]
127 }
128 }
129
130
131 // 7. Each type is in the intersection of the supertypes
132 for(type : types.filter[it.supertypes.size>=2]) {
133 trace.specification.factDeclarations += createALSFactDeclaration => [
134 it.name = support.toIDMultiple("abstract",type.name)
135 it.term = createALSEquals => [
136 it.leftOperand = createALSReference => [ it.referred = type.lookup(typeTrace.type2ALSType) ]
137 it.rightOperand = support.unfoldIntersection(type.supertypes.map[e|
138 createALSReference => [it.referred = e.lookup(typeTrace.type2ALSType)]])
139 ]
140 ]
141 }
142
143 // 8. Each abstract type is equal to the union of the subtypes
144 for(type : types.filter[isIsAbstract]) {
145 trace.specification.factDeclarations += createALSFactDeclaration => [
146 it.name = support.toIDMultiple("abstract",type.name)
147 it.term = createALSEquals => [
148 it.leftOperand = createALSReference => [ it.referred = type.lookup(typeTrace.type2ALSType) ]
149 it.rightOperand = support.unfoldPlus(type.subtypes.map[e|
150 createALSReference => [it.referred = e.lookup(typeTrace.type2ALSType)]])
151 ]
152 ]
153 }
154 // 8.1 The object type is the union of the root types.
155 val rootTypes = types.filter[it.supertypes.empty].toList
156 trace.specification.factDeclarations += createALSFactDeclaration => [
157 it.name = support.toIDMultiple(#["ObjectTypeDefinition"])
158 it.term = createALSEquals => [
159 it.leftOperand = createALSReference => [ it.referred = typeTrace.objectSupperClass ]
160 it.rightOperand = support.unfoldPlus(rootTypes.map[e|
161 createALSReference => [it.referred = e.lookup(typeTrace.type2ALSType)]])
162 ]
163 ]
164
165 // 9. For each type X (including Object)
166 // only the common subtypes are in the intersection
167 // of the two subtype.
168 // 9.1. for the object
169 {
170 val rootTypeList = types.filter[it.supertypes.empty].toList
171 for(type1Index: 0..<rootTypeList.size) {
172 for(type2Index: 0..<type1Index) {
173 trace.specification.factDeclarations +=
174 commonSubtypeOnlyInDiamonds(rootTypeList.get(type1Index),rootTypeList.get(type2Index),trace)
175 }
176 }
177 }
178
179 //9.3 for the subtypes of each objects
180 {
181 for(inScope : types) {
182 val subtypeList = inScope.subtypes//.toList
183 if(subtypeList.size>=2) {
184 for(type1Index: 0..<subtypeList.size) {
185 for(type2Index: 0..<type1Index) {
186 trace.specification.factDeclarations +=
187 commonSubtypeOnlyInDiamonds(subtypeList.get(type1Index),subtypeList.get(type2Index),trace)
188 }
189 }
190 }
191 }
192 }
193 }
194
195 private def isEnumlikeType(Type type) {
196 if(type instanceof TypeDefinition) {
197 val elements = type.elements
198 return elements.forall[it.definedInType.size === 1 && it.definedInType.head === type]
199 }
200 return false
201 }
202
203 private def isEnumlikeElement(DefinedElement d) {
204 d.definedInType.size === 1 && d.definedInType.head.isEnumlikeType
205 }
206
207 def getTypeTrace(Logic2AlloyLanguageMapperTrace trace) {
208 val res = trace.typeMapperTrace
209 if(res instanceof Logic2AlloyLanguageMapper_TypeMapperTrace_FilteredTypes) {
210 return res
211 } else {
212 throw new IllegalArgumentException('''
213 Expected type mapping trace: «Logic2AlloyLanguageMapper_TypeMapperTrace_FilteredTypes.name»,
214 but found «res.class.name»''')
215 }
216 }
217
218 def private commonSubtypeOnlyInDiamonds(Type t1, Type t2, Logic2AlloyLanguageMapperTrace trace) {
219 val topmostCommonSubtypes = TypeQueries.instance.getTopmostCommonSubtypes(trace.incqueryEngine)
220 val allTopmostCommon = topmostCommonSubtypes.getAllValuesOfcommon(t1,t2).toList
221 return createALSFactDeclaration => [
222 it.name = support.toIDMultiple("common","types",t1.name,t2.name)
223 it.term = createALSEquals => [
224 it.leftOperand = createALSIntersection => [
225 it.leftOperand = createALSReference => [it.referred = t1.lookup(trace.typeTrace.type2ALSType)]
226 it.rightOperand = createALSReference => [it.referred = t2.lookup(trace.typeTrace.type2ALSType)]
227 ]
228 it.rightOperand = support.unfoldPlus(allTopmostCommon.map[t|createALSReference => [it.referred = t.lookup(trace.typeTrace.type2ALSType)]])
229 ]
230 ]
231 }
232
233 def private unfoldDistinctElements(
234 List<DefinedElement> operands,
235 Logic2AlloyLanguageMapperTrace trace
236 ) {
237 if(operands.size == 1 || operands.size == 0) {support.unfoldTrueStatement(trace);}
238 else {
239 val notEquals = new ArrayList<ALSTerm>(operands.size*operands.size/2)
240 for(i:0..<operands.size) {
241 for(j: i+1..<operands.size) {
242 notEquals+=createALSNotEquals=>[
243 leftOperand = createALSReference => [it.referred = trace.typeTrace.definedElement2Declaration.get(operands.get(i)) ]
244 rightOperand = createALSReference => [it.referred = trace.typeTrace.definedElement2Declaration.get(operands.get(j)) ]
245 ]
246 }
247 }
248 return support.unfoldAnd(notEquals)
249 }
250 }
251
252 override transformTypeReference(Type referred, Logic2AlloyLanguageMapper mapper, Logic2AlloyLanguageMapperTrace trace) {
253 return #[trace.typeTrace.type2ALSType.get(referred)]
254 }
255
256 override getUndefinedSupertype(Logic2AlloyLanguageMapperTrace trace) {
257 trace.typeTrace.objectSupperClass
258 }
259
260 override transformReference(DefinedElement referred, Logic2AlloyLanguageMapperTrace trace) {
261 createALSReference => [it.referred = referred.lookup(trace.typeTrace.definedElement2Declaration)]
262 }
263
264 override getUndefinedSupertypeScope(int undefinedScope, Logic2AlloyLanguageMapperTrace trace) {
265 return undefinedScope + trace.typeTrace.definedElement2Declaration.size
266 }
267
268} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper_Horizontal.xtend_old b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper_Horizontal.xtend_old
new file mode 100644
index 00000000..7383904d
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper_Horizontal.xtend_old
@@ -0,0 +1,428 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSIntersection
4import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSMultiplicity
5import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSSignatureDeclaration
6import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSTerm
7import hu.bme.mit.inf.dslreasoner.alloyLanguage.AlloyLanguageFactory
8import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference
9import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
10import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
11import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration
12import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition
13import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
14import hu.bme.mit.inf.dslreasoner.logic.model.patterns.SupertypeStarMatcher
15import java.util.HashMap
16import java.util.LinkedHashSet
17import java.util.LinkedList
18import java.util.List
19import java.util.Map
20import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
21import org.eclipse.viatra.query.runtime.emf.EMFScope
22import org.eclipse.xtend.lib.annotations.Data
23
24import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
25
26class Logic2AlloyLanguageMapper_TypeMapperTrace_Horizontal
27 implements Logic2AlloyLanguageMapper_TypeMapperTrace {
28 public var ALSSignatureDeclaration declaredSupertype
29 public var ALSSignatureDeclaration definedSupertype
30 public val Map<DefinedElement, ALSSignatureDeclaration> definedElement2Declaration = new HashMap
31
32 public val Map<TypeDefinition, ALSSignatureDeclaration> definition2definition = new HashMap
33 public val Map<TypeDeclaration, ALSSignatureDeclaration> declaration2definition = new HashMap
34 public val Map<TypeDeclaration, ALSSignatureDeclaration> undefined2definition = new HashMap
35 public val Map<TypeDeclaration, ALSSignatureDeclaration> new2declaration = new HashMap
36
37 def getAllDefinedTypes() {
38 return (definition2definition.values) +
39 (declaration2definition.values) +
40 (undefined2definition.values)
41 }
42 def getAllDeclaredTypes() {
43 return new2declaration.values
44 }
45
46 public val Map<Type,List<ALSSignatureDeclaration>> type2AllSignatures = new HashMap;
47}
48
49@Data
50class DynamicTypeConstraints {
51 List<List<Type>> positiveCNF
52 LinkedHashSet<Type> negative
53 public new() {
54 this.positiveCNF = new LinkedList
55 this.negative = new LinkedHashSet
56 }
57 def public void addPositiveTypeOptions(List<Type> typeDisjunction) {
58 this.positiveCNF.add(typeDisjunction)
59 }
60 def public void addNegativeTypes(Iterable<Type> negativeTypes) {
61 this.negative.addAll(negativeTypes)
62 }
63}
64
65/**
66 * Dynamic types are represented by disjoint sets, and
67 * static types are represented by the union of the dynamic type sets.
68 *
69 * Definition Declaration
70 * | / \
71 * | W/DefinedSuper Wo/DefinedSuper
72 * | | / \
73 * | | undefined2declaration new2declaration
74 * definition2definition definition2declaration
75 * +----------------------------------------------------+ +-------------+
76 * Defined Declared
77 */
78class Logic2AlloyLanguageMapper_TypeMapper_Horizontal implements Logic2AlloyLanguageMapper_TypeMapper{
79 private val Logic2AlloyLanguageMapper_Support support = new Logic2AlloyLanguageMapper_Support;
80 private val extension AlloyLanguageFactory factory = AlloyLanguageFactory.eINSTANCE
81
82 override transformTypes(LogicProblem problem, Logic2AlloyLanguageMapper mapper, Logic2AlloyLanguageMapperTrace trace) {
83 // 0. Creating the traces
84 val typeTrace = new Logic2AlloyLanguageMapper_TypeMapperTrace_Horizontal
85 trace.typeMapperTrace = typeTrace
86 /**
87 * Static type -> list of possible dynamic type map
88 */
89 val typeToConcreteSubtypes = problem.typeToConcreteSubtypes(trace)
90
91
92
93 // 1. Transforming the types
94
95 // There are two kind of types:
96 // A: one with defined supertypes (including itself), that only has defined elements
97 // Those types can have instances only from the defined elements, ie they are subset of problem.elements
98 // B: one without defined supertypes
99 // Those types can have instances from two sources
100 // B.1 from elements that dont have definitions
101 // B.2 from newly created elements
102 val allConcreteTypes = problem.types.filter[!it.isAbstract]
103 val definitions = allConcreteTypes.filter(TypeDefinition).toList
104 val declarationsWithDefinedSupertype = allConcreteTypes.filter(TypeDeclaration).filter[it.hasDefinedSupertype].toList
105 val declarationsWithoutDefinedSupertype = allConcreteTypes.filter(TypeDeclaration).filter[!it.hasDefinedSupertype].toList
106
107 // 2. If there are defined elements
108 if(trace.typeTrace.definedSupertype != null) {
109 // 3 mapping the elements
110 problem.elements.transformDefinedSupertype(trace)
111 // 4. if there are elements that are added to types, then it have to be mapped to defined parts
112 if(problem.elements.exists[!it.definedInType.empty]) {
113 definitions.forEach[it.transformDefinition2Definition(trace)]
114 declarationsWithDefinedSupertype.forEach[it.transformDeclaration2Definition(trace)]
115 }
116 // 5. if there are elements that are not added to types, then it have to be mapped to declarations without definitions
117 if(problem.elements.exists[it.definedInType.empty]) {
118 declarationsWithoutDefinedSupertype.forEach[it.transformUndefined2Definition(trace)]
119 }
120
121 definedConcreteTypesAreFull(trace)
122 definedConcreteTypesAreDisjoint(trace)
123 problem.definedConcreteTypesAreSatisfyingDefinitions(typeToConcreteSubtypes,trace)
124 }
125
126 // Transforming the declared and defined concrete types
127 problem.elements.transformDefinedSupertype(trace)
128 if(trace.typeTrace.definedSupertype != null) {
129 problem.elements.transformDefinedElements(trace)
130 declarationsWithoutDefinedSupertype.forEach[it.transformNew2Declaration(trace)]
131 }
132
133 // 2: Caching the types by filling type2AllSignatures
134 for(typeToConcreteSubtypesEntry : typeToConcreteSubtypes.entrySet) {
135 val type = typeToConcreteSubtypesEntry.key
136 val List<ALSSignatureDeclaration> signatures = new LinkedList
137
138 }
139 }
140
141 def getTypeTrace(Logic2AlloyLanguageMapperTrace trace) {
142 val res = trace.typeMapperTrace
143 if(res instanceof Logic2AlloyLanguageMapper_TypeMapperTrace_Horizontal) {
144 return res
145 } else {
146 throw new IllegalArgumentException('''
147 Expected type mapping trace: «Logic2AlloyLanguageMapper_TypeMapperTrace_Horizontal.name»,
148 but found «res.class.name»''')
149 }
150 }
151
152 private def boolean hasDefinedSupertype(Type type) {
153 if(type instanceof TypeDefinition) {
154 return true
155 } else {
156 if(type.supertypes.empty) return false
157 else return type.supertypes.exists[it.hasDefinedSupertype]
158 }
159 }
160
161 private def transformDefinedSupertype(List<DefinedElement> elements, Logic2AlloyLanguageMapperTrace trace) {
162 trace.typeTrace.definedSupertype = createALSSignatureDeclaration => [
163 it.name = support.toID(#["util","defined","Object"])
164 ]
165 trace.specification.signatureBodies += createALSSignatureBody => [
166 it.abstract = true
167 it.declarations += trace.typeTrace.definedSupertype
168 ]
169 }
170
171 private def transformDefinedElements(List<DefinedElement> elements,
172 Logic2AlloyLanguageMapperTrace trace){
173 if(trace.typeTrace.definedSupertype != null) {
174 // 2. Create elements as singleton signatures subtype of definedSupertype
175 val elementBodies = createALSSignatureBody => [
176 it.multiplicity = ALSMultiplicity::ONE
177 it.supertype = trace.typeTrace.definedSupertype
178 ]
179 trace.specification.signatureBodies += elementBodies
180 for(element : elements) {
181 val elementDeclaration = createALSSignatureDeclaration => [
182 it.name = support.toIDMultiple(#["element"],element.name)
183 ]
184 elementBodies.declarations += elementDeclaration
185 trace.typeTrace.definedElement2Declaration.put(element,elementDeclaration)
186 }
187 // 3. Specify that definedSupertype is equal to the union of specified
188 /*trace.specification.factDeclarations += createALSFactDeclaration => [
189 it.name = support.toID(#["util","typehierarchy","definitionOfElements"])
190 it.term = createALSEquals => [
191 it.leftOperand = createALSReference => [it.referred = trace.typeTrace.definedSupertype]
192 it.rightOperand = support.unfoldPlus(elements.map[element|createALSReference=>[
193 it.referred = element.lookup(trace.typeTrace.definedElement2Declaration)
194 ]])
195 ]
196 ]*/
197 }
198 }
199
200 ///// Type definitions
201
202 protected def void transformDefinition2Definition(TypeDefinition type, Logic2AlloyLanguageMapperTrace trace) {
203 val sig = createALSSignatureDeclaration => [it.name = support.toIDMultiple(#["definition2definition"],type.name)]
204 val body = createALSSignatureBody => [
205 it.declarations += sig
206 it.superset += trace.typeTrace.definedSupertype
207 ]
208 trace.specification.signatureBodies += body
209 trace.typeTrace.definition2definition.put(type,sig)
210 }
211 protected def void transformDeclaration2Definition(TypeDeclaration type, Logic2AlloyLanguageMapperTrace trace) {
212 val sig = createALSSignatureDeclaration => [it.name = support.toIDMultiple(#["declaration2definition"],type.name)]
213 val body = createALSSignatureBody => [
214 it.declarations += sig
215 it.superset += trace.typeTrace.definedSupertype
216 ]
217 trace.specification.signatureBodies += body
218 trace.typeTrace.declaration2definition.put(type,sig)
219 }
220 protected def void transformUndefined2Definition(TypeDeclaration type, Logic2AlloyLanguageMapperTrace trace) {
221 val sig = createALSSignatureDeclaration => [it.name = support.toIDMultiple(#["undefined2definition"],type.name)]
222 val body = createALSSignatureBody => [
223 it.declarations += sig
224 it.supertype = trace.typeTrace.definedSupertype
225 ]
226 trace.specification.signatureBodies += body
227 trace.typeTrace.undefined2definition.put(type,sig)
228 }
229 protected def void transformNew2Declaration(TypeDeclaration type, Logic2AlloyLanguageMapperTrace trace) {
230 val sig = createALSSignatureDeclaration => [it.name = support.toIDMultiple(#["declaredPartOfDeclaration"],type.name)]
231 val body = createALSSignatureBody => [
232 it.declarations += sig
233 it.supertype = trace.typeTrace.declaredSupertype
234 ]
235 trace.specification.signatureBodies += body
236 trace.typeTrace.new2declaration.put(type,sig)
237 }
238
239 /**
240 * The dynamic types cover each concrete types
241 */
242 protected def definedConcreteTypesAreFull(Logic2AlloyLanguageMapperTrace trace) {
243 trace.specification.factDeclarations += createALSFactDeclaration => [
244 it.name = support.toID(#["util","typehierarchy","elementFull"])
245 it.term = createALSEquals => [
246 it.leftOperand = createALSReference => [it.referred = trace.typeTrace.definedSupertype]
247 it.rightOperand = support.unfoldPlus(
248 trace.typeTrace.allDefinedTypes.map[type|
249 createALSReference=>[referred = type]
250 ].toList
251 )
252 ]
253 ]
254
255 }
256 /**
257 * The dynamic types are disjoint
258 */
259 protected def definedConcreteTypesAreDisjoint(Logic2AlloyLanguageMapperTrace trace) {
260 val types = trace.getTypeTrace.allDefinedTypes.toList
261 if (types.size >= 2) {
262 trace.specification.factDeclarations += createALSFactDeclaration => [
263 it.name = support.toID(#["util", "typehierarchy", "elementFull"])
264 it.term = types.disjointSets
265 ]
266 }
267 }
268 /**
269 * The dynamic types are subtypes of the types where it is defined, but not subtypes where it is not
270 */
271 protected def definedConcreteTypesAreSatisfyingDefinitions(LogicProblem problem, Map<Type,List<Type>> typeToConcreteSubtypes, Logic2AlloyLanguageMapperTrace trace) {
272 val constraintOnElements = problem.elements.typeConstraints(typeToConcreteSubtypes)
273 for(constraintOnElement : constraintOnElements.entrySet) {
274 val element = constraintOnElement.key
275 val elementSignature = element.lookup(trace.typeTrace.definedElement2Declaration)
276 val constraint = constraintOnElement.value
277
278 var ALSTerm negativeConstraints;
279 if(constraint.negative.isEmpty) {
280 negativeConstraints = null
281 } else {
282 negativeConstraints = support.unfoldAnd(constraint.negative.map[type|
283 createALSNot=> [ elementInDefinedType(elementSignature, type, trace) ]
284 ].toList)
285 }
286
287 var ALSTerm positiveTypeConstraints
288 if(constraint.positiveCNF.isEmpty) {
289 positiveTypeConstraints = null
290 } else {
291 positiveTypeConstraints = support.unfoldAnd(constraint.positiveCNF.map[ typeConstraintFromDefinition |
292 support.unfoldOr(typeConstraintFromDefinition.map[type |
293 elementInDefinedType(elementSignature,type,trace)
294 ].toList,trace)
295 ])
296 }
297
298 var ALSTerm typeConstraint
299 if(negativeConstraints != null && positiveTypeConstraints == null) {
300 typeConstraint = negativeConstraints
301 } else if (negativeConstraints == null && positiveTypeConstraints != null) {
302 typeConstraint = positiveTypeConstraints
303 } else if (negativeConstraints != null && positiveTypeConstraints != null) {
304 val and = createALSAnd
305 and.leftOperand = positiveTypeConstraints
306 and.rightOperand = negativeConstraints
307 typeConstraint = and
308 } else {
309 typeConstraint = null
310 }
311
312 if(typeConstraint != null) {
313 val fact = createALSFactDeclaration => [
314 name = support.toIDMultiple(#["util","typehierarchy","definition"],element.name)
315 ]
316 fact.term = typeConstraint
317 trace.specification.factDeclarations +=fact
318 }
319 // otherwise there is no type constraint on element
320 }
321 }
322
323 private def elementInDefinedType(
324 ALSSignatureDeclaration elementSignature,
325 Type type,
326 Logic2AlloyLanguageMapperTrace trace)
327 {
328 var ALSSignatureDeclaration signature
329 if(type instanceof TypeDeclaration) {
330 if(trace.typeTrace.declaration2definition.containsKey(type)) {
331 signature = type.lookup(trace.typeTrace.declaration2definition)
332 } else if(trace.typeTrace.undefined2definition.containsKey(type)) {
333 signature = type.lookup(trace.typeTrace.undefined2definition)
334 } else {
335 return null
336 }
337 } else if(type instanceof TypeDefinition) {
338 if(trace.typeTrace.definition2definition.containsKey(type)) {
339 signature = type.lookup(trace.typeTrace.definition2definition)
340 } else {
341 return null
342 }
343 } else throw new IllegalArgumentException('''Unknownt type «type.class.name»''')
344
345 val finalSignature = signature
346 return createALSSubset => [
347 leftOperand = createALSReference => [
348 referred = elementSignature
349 ]
350 rightOperand = createALSReference => [
351 referred = finalSignature
352 ]
353 ]
354 }
355
356 def private typeToConcreteSubtypes(LogicProblem problem, Logic2AlloyLanguageMapperTrace trace) {
357 if(trace.incqueryEngine == null) {
358 trace.incqueryEngine = ViatraQueryEngine.on(new EMFScope(problem))
359 }
360 val matcher = SupertypeStarMatcher.on(trace.incqueryEngine)
361 val Map<Type,List<Type>> typeToConcreteSubtypes = new HashMap
362 for(supertype : problem.types) {
363 typeToConcreteSubtypes.put(
364 supertype,
365 matcher.getAllValuesOfsubtype(supertype)
366 .filter[!it.isIsAbstract].toList)
367 }
368 return typeToConcreteSubtypes
369 }
370
371 /**
372 * Gives type constraints in a form of CNF
373 */
374 def private Map<DefinedElement,DynamicTypeConstraints> typeConstraints(List<DefinedElement> elements, Map<Type,List<Type>> typeToConcreteSubtypes) {
375 val Map<DefinedElement,DynamicTypeConstraints> constraints = new HashMap
376 elements.forEach[constraints.put(it,new DynamicTypeConstraints)]
377
378 for(type : typeToConcreteSubtypes.keySet.filter(TypeDefinition)) {
379 val subtypes = type.lookup(typeToConcreteSubtypes)
380 for(elementInType:type.elements) {
381 elementInType.lookup(constraints).addPositiveTypeOptions(subtypes)
382 }
383 for(elementNotInType:elements.filter[!type.elements.contains(it)]) {
384 elementNotInType.lookup(constraints).addNegativeTypes(subtypes)
385 }
386 }
387
388 return constraints
389 }
390
391 private def ALSTerm disjointSets(List<ALSSignatureDeclaration> signatures) {
392 if(signatures.size >= 2){
393 val top = createALSEquals => [
394 it.leftOperand = signatures.intersectionOfTypes
395 it.rightOperand = createALSNone
396 ]
397 if(signatures.size > 2) {
398 return createALSAnd => [
399 it.leftOperand = top
400 it.rightOperand = signatures.subList(1,signatures.size).disjointSets
401 ]
402 } else{
403 return top
404 }
405 } else {
406 throw new UnsupportedOperationException()
407 }
408 }
409
410 private def ALSIntersection intersectionOfTypes(List<ALSSignatureDeclaration> signatures) {
411 if(signatures.size == 2) {
412 return createALSIntersection => [
413 leftOperand = createALSReference => [it.referred = signatures.get(0)]
414 rightOperand = createALSReference => [it.referred = signatures.get(1)]
415 ]
416 } else if(signatures.size > 2) {
417 return createALSIntersection => [
418 leftOperand = createALSReference => [it.referred = signatures.get(0)]
419 rightOperand = signatures.subList(1,signatures.size).intersectionOfTypes
420 ]
421 } else throw new UnsupportedOperationException()
422 }
423
424
425 override transformTypeReference(ComplexTypeReference complexTypeReference, Logic2AlloyLanguageMapper mapper, Logic2AlloyLanguageMapperTrace trace) {
426 //trace.typeTrace.
427 }
428} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper_InheritanceAndHorizontal.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper_InheritanceAndHorizontal.xtend
new file mode 100644
index 00000000..6533ad36
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/src/hu/bme/mit/inf/dlsreasoner/alloy/reasoner/builder/Logic2AlloyLanguageMapper_TypeMapper_InheritanceAndHorizontal.xtend
@@ -0,0 +1,50 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSSignatureDeclaration
4import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
5import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
6import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration
7import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition
8import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
9import java.util.HashMap
10import java.util.Map
11import java.util.Collection
12
13class Logic2AlloyLanguageMapper_TypeMapperTrace_InheritanceAndHorizontal implements Logic2AlloyLanguageMapper_TypeMapperTrace {
14 val Map<TypeDeclaration,ALSSignatureDeclaration> newElementTypes = new HashMap
15 val Map<Type,ALSSignatureDeclaration> definedElementTypes = new HashMap
16 var ALSSignatureDeclaration undefinedSupertype
17 var ALSSignatureDeclaration definedSupertype
18}
19
20class Logic2AlloyLanguageMapper_TypeMapper_InheritanceAndHorizontal implements Logic2AlloyLanguageMapper_TypeMapper{
21
22 override transformTypes(Collection<Type> types, Collection<DefinedElement> elements, Logic2AlloyLanguageMapper mapper, Logic2AlloyLanguageMapperTrace trace) {
23 throw new UnsupportedOperationException("TODO: auto-generated method stub")
24 }
25
26 private def boolean hasDefinedSupertype(Type type) {
27 if(type instanceof TypeDefinition) {
28 return true
29 } else {
30 if(type.supertypes.empty) return false
31 else return type.supertypes.exists[it.hasDefinedSupertype]
32 }
33 }
34
35 override transformTypeReference(Type referred, Logic2AlloyLanguageMapper mapper, Logic2AlloyLanguageMapperTrace trace) {
36 throw new UnsupportedOperationException("TODO: auto-generated method stub")
37 }
38
39 override getUndefinedSupertype(Logic2AlloyLanguageMapperTrace trace) {
40 throw new UnsupportedOperationException("TODO: auto-generated method stub")
41 }
42
43 override transformReference(DefinedElement referred, Logic2AlloyLanguageMapperTrace trace) {
44 throw new UnsupportedOperationException("TODO: auto-generated method stub")
45 }
46
47 override getUndefinedSupertypeScope(int undefinedScope, Logic2AlloyLanguageMapperTrace trace) {
48 throw new UnsupportedOperationException("TODO: auto-generated method stub")
49 }
50} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/AlloyModelInterpretation.xtend_ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/AlloyModelInterpretation.xtend_
new file mode 100644
index 00000000..05b97b0c
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/AlloyModelInterpretation.xtend_
@@ -0,0 +1,212 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import edu.mit.csail.sdg.alloy4compiler.ast.ExprVar
4import edu.mit.csail.sdg.alloy4compiler.ast.Sig.Field
5import edu.mit.csail.sdg.alloy4compiler.translator.A4Solution
6import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicModelInterpretation
7import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ConstantDeclaration
8import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
9import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.FunctionDeclaration
10import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguageFactory
11import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration
12import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
13import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration
14import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition
15import java.util.Arrays
16import java.util.HashMap
17import java.util.LinkedList
18import java.util.List
19import java.util.Map
20import java.util.Set
21
22import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
23
24class AlloyModelInterpretation implements LogicModelInterpretation{
25
26 protected val extension LogiclanguageFactory factory = LogiclanguageFactory.eINSTANCE
27 //protected val extension LogicProblemBuilder builder = new LogicProblemBuilder
28
29 protected val Logic2AlloyLanguageMapper forwardMapper
30 protected val Logic2AlloyLanguageMapperTrace forwardTrace;
31
32 private var ExprVar logicLanguage;
33 private var String logicBooleanTrue;
34 private var String logicBooleanFalse;
35
36 val Map<String,DefinedElement> alloyAtom2LogicElement = new HashMap
37 private val Map<TypeDeclaration, List<DefinedElement>> interpretationOfUndefinedType = new HashMap
38
39 private val Map<ConstantDeclaration, Object> constant2Value
40 private val Map<FunctionDeclaration, ? extends Map<ParameterSubstitution, Object>> function2Value
41 private val Map<RelationDeclaration, ? extends Set<ParameterSubstitution>> relation2Value
42
43 private val int minInt
44 private val int maxInt
45
46 public new (A4Solution solution, Logic2AlloyLanguageMapper forwardMapper, Logic2AlloyLanguageMapperTrace trace) {
47
48 this.forwardMapper = forwardMapper
49 this.forwardTrace = trace
50
51 //TMP sig maps to identify alloy signatures by their names
52 val Map<String,Type> sigName2LogicType =
53 forwardTrace.type2ALSType.keySet.toMap[x|forwardTrace.type2ALSType.get(x).name]
54 val Map<String,DefinedElement> elementNameNamel2DefinedElement =
55 forwardTrace.definedElement2Declaration.keySet.toMap[x|forwardTrace.definedElement2Declaration.get(x).name]
56
57 // Fill the interpretation map with empty lists
58 forwardTrace.type2ALSType.keySet.filter(TypeDeclaration).forEach[x|interpretationOfUndefinedType.put(x,new LinkedList)]
59
60 // exporing individuals
61 for(atom: solution.allAtoms) {
62 val typeName = getName(atom.type)
63 val atomName = atom.name
64 //println(atom.toString + " < - " + typeName)
65 if(typeName == forwardTrace.logicLanguage.name) {
66 this.logicLanguage = atom
67 } else if(typeName == "Int" || typeName == "seq/Int") {
68 // do nothing
69 } else if(sigName2LogicType.containsKey(typeName) && typeName.lookup(sigName2LogicType) instanceof TypeDefinition) {
70 val element = elementNameNamel2DefinedElement.get(atomName.head)
71 alloyAtom2LogicElement.put(atom.label,element)
72 } else if(sigName2LogicType.containsKey(typeName)) {
73 val type = sigName2LogicType.get(typeName)
74 val elementsOfType = interpretationOfUndefinedType.get(type)
75 val element = createDefinedElement => [
76 it.name += type.name
77 it.name += (elementsOfType.size+1).toString
78 ]
79 alloyAtom2LogicElement.put(atom.label,element)
80 elementsOfType+=element
81 } else if(forwardTrace.boolType != null && typeName == forwardTrace.boolType.name) {
82 if(atomName.head == forwardTrace.boolTrue.name) { this.logicBooleanTrue = atom.label }
83 else if(atomName.head == forwardTrace.boolFalse.name) { this.logicBooleanFalse = atom.label}
84 else throw new UnsupportedOperationException('''Unknown boolean value: «atom»''')
85 }
86 else throw new UnsupportedOperationException('''Unknown atom: «atom»''')
87 }
88
89 //TMP field maps
90 val Map<String, Field> name2AlloyField = new HashMap
91 // exploring signatures
92 for(sig:solution.allReachableSigs) {
93 for(field : sig.fields) {
94 name2AlloyField.put(field.label,field)
95 }
96 }
97
98 // eval consants
99 constant2Value = forwardTrace.constantDeclaration2LanguageField.mapValues[
100 solution.eval(it.name.lookup(name2AlloyField)).head.atom(1).atomLabel2Term
101 ]
102 // eval functions
103 val hostedfunction2Value = forwardTrace.functionDeclaration2HostedField.mapValues[ function |
104 newHashMap(
105 solution.eval(function.name.lookup(name2AlloyField))
106 .map[t | new ParameterSubstitution(#[t.atom(0).atomLabel2Term]) -> t.atom(1).atomLabel2Term])]
107
108 val globalfunction2Value = forwardTrace.functionDeclaration2LanguageField.keySet.toInvertedMap[ function |
109 val alsFunction = function.lookup(forwardTrace.functionDeclaration2LanguageField)
110 val paramIndexes = 1..(function.parameters.size)
111 return newHashMap(
112 solution.eval(alsFunction.name.lookup(name2AlloyField)).map[t |
113 new ParameterSubstitution(paramIndexes.map[t.atom(it).atomLabel2Term])
114 ->
115 t.atom(function.parameters.size + 1).atomLabel2Term
116 ])]
117 this.function2Value = Union(hostedfunction2Value,globalfunction2Value)
118 // eval relations
119 val hostedRelation2Value = forwardTrace.relationDeclaration2Field.mapValues[ relation |
120 solution.eval(relation.name.lookup(name2AlloyField)).map[ t |
121 new ParameterSubstitution(#[t.atom(0).atomLabel2Term,t.atom(1).atomLabel2Term])].toSet]
122 val globalRelation2Value = forwardTrace.relationDeclaration2Global.mapValues[ relation |
123 solution.eval(relation.name.lookup(name2AlloyField)).map[ t |
124 new ParameterSubstitution((1..<t.arity).map[int a|t.atom(a).atomLabel2Term])].toSet]
125 this.relation2Value = Union(hostedRelation2Value,globalRelation2Value)
126
127 //Int limits
128 this.minInt = solution.min
129 this.maxInt = solution.max
130
131 //print
132 }
133
134 def print() {
135 println('''Elements-----''')
136 interpretationOfUndefinedType.forEach[k,v|println('''«k.name» -> «v»''')]
137
138 println('''Constants-----''')
139 constant2Value.forEach[k, v|println('''«k.name» : «v»''')]
140 println('''Functions-----''')
141 function2Value.forEach[f,m|m.forEach[k,v| println('''«f.name» : «k» |-> «v»''')]]
142 println('''Relations-----''')
143 relation2Value.forEach[r,s|s.forEach[t | println('''«r.name»: («t»)''')]]
144 }
145
146 def private getName(edu.mit.csail.sdg.alloy4compiler.ast.Type type) {
147 val name = type.toString
148 if(name.startsWith("{this/") && name.endsWith("}")) {
149 return type.toString.replaceFirst("\\{this\\/","").replace("}","")
150 }
151 else throw new IllegalArgumentException('''Unknown type format: "«name»"!''')
152 }
153 def private getName(ExprVar atom) { atom.toString.split("\\$") }
154
155 override getElements(Type type) { getElementsDispatch(type) }
156 def private dispatch getElementsDispatch(TypeDeclaration declaration) { return declaration.lookup(this.interpretationOfUndefinedType) }
157 def private dispatch getElementsDispatch(TypeDefinition declaration) { return declaration.elements }
158
159 override getInterpretation(FunctionDeclaration function, Object[] parameterSubstitution) {
160 val transformedParams = new ParameterSubstitution(parameterSubstitution)
161 return transformedParams.lookup(
162 function.lookup(this.function2Value)
163 )
164 }
165
166 override getInterpretation(RelationDeclaration relation, Object[] parameterSubstitution) {
167 relation.lookup(this.relation2Value).contains(new ParameterSubstitution(parameterSubstitution))
168 }
169
170 override getInterpretation(ConstantDeclaration constant) {
171 constant.lookup(this.constant2Value)
172 }
173
174 override getMinimalInteger() { this.minInt }
175 override getMaximalInteger() { this.maxInt }
176
177 // Alloy term -> logic term
178 def private atomLabel2Term(String label) {
179 if(label.number) return Integer.parseInt(label)
180 else if(label == this.logicBooleanTrue) return true
181 else if(label == this.logicBooleanFalse) return false
182 else if(this.alloyAtom2LogicElement.containsKey(label)) return label.lookup(alloyAtom2LogicElement)
183 else throw new IllegalArgumentException('''Unknown atom label: "«label»"!''')
184 }
185 def isNumber(String s) {
186 try{
187 Integer.parseInt(s)
188 return true
189 }catch(NumberFormatException e) {
190 return false
191 }
192 }
193}
194
195class ParameterSubstitution{
196 val Object[] data;
197
198 new(Object[] data) { this.data = data }
199
200 override equals(Object obj) {
201 if(obj === this) return true
202 else if(obj == null) return false
203 if(obj instanceof ParameterSubstitution) {
204 return Arrays.equals(this.data,obj.data)
205 }
206 return false
207 }
208
209 override hashCode() {
210 Arrays.hashCode(data)
211 }
212} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/FunctionWithTimeout.xtend_ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/FunctionWithTimeout.xtend_
new file mode 100644
index 00000000..8c03af6e
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/FunctionWithTimeout.xtend_
@@ -0,0 +1,40 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import org.eclipse.xtext.xbase.lib.Functions.Function0
4import java.util.concurrent.Executors
5import java.util.concurrent.Callable
6import java.util.concurrent.TimeUnit
7import java.util.concurrent.TimeoutException
8import java.util.concurrent.ExecutionException
9
10class FunctionWithTimeout<Type> {
11 val Function0<Type> function;
12
13 new(Function0<Type> function) {
14 this.function = function
15 }
16
17 def execute(long millisecs) {
18 if(millisecs>0) {
19 val executor = Executors.newCachedThreadPool();
20 val task = new Callable<Type>() {
21 override Type call() { function.apply }
22 };
23 val future = executor.submit(task);
24 try {
25 val result = future.get(millisecs, TimeUnit.MILLISECONDS);
26 return result
27 } catch (TimeoutException ex) {
28 // handle the timeout
29 } catch (InterruptedException e) {
30 // handle the interrupts
31 } catch (ExecutionException e) {
32 // handle other exceptions
33 } finally {
34 future.cancel(true); // may or may not desire this
35 }
36 return null
37 }
38 else return function.apply
39 }
40} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/Logic2AlloyApiMapper.xtend_ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/Logic2AlloyApiMapper.xtend_
new file mode 100644
index 00000000..29acd681
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/Logic2AlloyApiMapper.xtend_
@@ -0,0 +1,345 @@
1package hu.bme.mit.inf.dlsreasoner.alloy.reasoner.builder
2
3import java.util.Map
4import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput
5import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
6import java.util.List
7import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolTypeReference
8import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntTypeReference
9import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealTypeReference
10import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference
11import edu.mit.csail.sdg.alloy4compiler.ast.ExprConstant
12import edu.mit.csail.sdg.alloy4compiler.ast.Expr
13import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Assertion
14import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolLiteral
15import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntLiteral
16import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Variable
17import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Not
18import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.And
19import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Or
20import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Impl
21import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Iff
22import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.MoreThan
23import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LessThan
24import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.MoreOrEqualThan
25import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LessOrEqualThan
26import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Equals
27import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Plus
28import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Minus
29import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Multiply
30import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Divison
31import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Mod
32import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Forall
33import java.util.HashMap
34import edu.mit.csail.sdg.alloy4compiler.ast.Decl
35import java.util.ArrayList
36import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Exists
37import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealLiteral
38import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration
39import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
40import edu.mit.csail.sdg.alloy4compiler.ast.Attr
41import edu.mit.csail.sdg.alloy4compiler.ast.Sig.PrimSig
42import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation
43import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Term
44import javax.naming.OperationNotSupportedException
45import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.SymbolicValue
46import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Constant
47import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.alloylanguage.AlloySpecification
48import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.alloylanguage.Multiplicity
49import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.alloylanguage.InverseReference
50import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition
51import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
52
53class AlloyInput{
54 public val List<PrimSig> typeDeclarations=new ArrayList
55 public val List<Expr> functionDeclarations=new ArrayList
56 public val List<Expr> assertions=new ArrayList
57 public val List<Expr> multiplicityConstraints=new ArrayList
58 public val List<Expr> inverseConstraints=new ArrayList
59}
60
61class Logic2AlloyApiMapperTrace {
62 val Map<Type, PrimSig> typeMap
63 val Map<DefinedElement, PrimSig> elementMap
64 //val Map<Function, SMTFunctionDeclaration> functionMap
65 val Map<Relation,Expr> relationMap
66 //val Map<Constant,SMTFunctionDeclaration> constantMap
67
68 new () {
69 this.typeMap = new HashMap
70 this.elementMap = new HashMap
71 //this.functionMap = new HashMap
72 this.relationMap = new HashMap
73 //this.constantMap = new HashMap
74 }
75 new (Map<Type, PrimSig> typeMap,
76 Map<DefinedElement, PrimSig> elementMap,
77 //Map<Function, SMTFunctionDeclaration> functionMap,
78 Map<Relation,Expr> relationMap/*,
79 Map<Constant,SMTFunctionDeclaration> constantMap*/)
80 {
81 this.typeMap = typeMap
82 this.elementMap = elementMap
83 //this.functionMap = functionMap
84 this.relationMap = relationMap
85 //this.constantMap = constantMap
86 }
87
88 def types() { typeMap }
89 def elements() { elementMap }
90 //def functions() { functionMap }
91 def relations() { relationMap }
92 //def constants() { constantMap }
93}
94
95class Logic2AlloyApiMapper{
96 //TODO output
97 public def TracedOutput<List<PrimSig>, Logic2AlloyApiMapperTrace> transformProblem(LogicProblem problem) {
98 val documentInput = new AlloyInput()
99 //createSMTInput => [satCommand = createSMTSimpleSatCommand getModelCommand = createSMTGetModelCommand]
100 //val document = createSMTDocument => [input = documentInput]
101 val List<PrimSig> document=new ArrayList
102 val trace = new Logic2AlloyApiMapperTrace
103
104 // Trafo
105 documentInput.typeDeclarations += problem.types.map[transformType(trace)]
106 //documentInput.functionDeclarations += problem.functions.map[transformFunction(trace)]
107 documentInput.functionDeclarations += problem.relations.map[transformRelation(trace)]
108 //documentInput.functionDeclarations += problem.constants.map[transformConstant(trace)]
109 documentInput.assertions += problem.assertions.map[transformAssertion(trace)]
110
111
112 val alloySpecification = problem.specifications.filter(AlloySpecification).head
113
114 for(mult: alloySpecification.multiplicities){
115 if(mult.min>0){
116 documentInput.multiplicityConstraints+=mult.transformMultiplicityLowerBound(trace)
117 }
118 if(mult.max!=-1){
119 documentInput.multiplicityConstraints+=mult.transformMultiplicityUpperBound(trace)
120 }
121 }
122
123 for(inv: alloySpecification.inverses){
124 documentInput.inverseConstraints += inv.transformInverse(trace)
125 }
126 // End trafo
127
128 return new TracedOutput(document,trace)
129 }
130
131 def Expr transformMultiplicityLowerBound(Multiplicity multiplicity, Logic2AlloyApiMapperTrace trace){
132
133 val Decl forallVariable=(trace.relations.get(multiplicity.multiplicityOf)).oneOf("o") as Decl
134 return (forallVariable.get.cardinality.gte(ExprConstant.makeNUMBER(multiplicity.min))).forAll(forallVariable)
135
136 }
137
138 def Expr transformMultiplicityUpperBound(Multiplicity multiplicity, Logic2AlloyApiMapperTrace trace){
139
140 val Decl forallVariable=(trace.relations.get(multiplicity.multiplicityOf)).oneOf("o") as Decl
141 return (forallVariable.get.cardinality.lte(ExprConstant.makeNUMBER(multiplicity.max))).forAll(forallVariable)
142
143 }
144
145 def Expr transformInverse(InverseReference inverse, Logic2AlloyApiMapperTrace trace){
146 return trace.relations.get(inverse.inverseOf.get(0)).equal(trace.relations.get(inverse.inverseOf.get(1)).transpose)
147 }
148
149 private def toID(List<String> names) {names.join("!") }
150
151 def dispatch protected transformType(TypeDefinition declaration, Logic2AlloyApiMapperTrace trace) {
152 val result = new PrimSig(declaration.name.toID, Attr.ABSTRACT)
153 trace.types.put(declaration,result)
154 return result
155 }
156
157 def protected transformDefinedElement(TypeDefinition enumType, DefinedElement element, Logic2AlloyApiMapperTrace trace) {
158 val result=new PrimSig(element.name.toID, trace.types.get(enumType), Attr.ONE)
159 trace.elements.put(element,result)
160 return result
161 }
162
163 def dispatch protected transformType(TypeDeclaration declaration, Logic2AlloyApiMapperTrace trace) {
164 //TODO �r�kles, absztrakt
165 val result = new PrimSig(declaration.name.toID)
166 trace.types.put(declaration,result)
167 return result
168 }
169
170 def dispatch protected transformTypeReference(BoolTypeReference boolTypeReference, Logic2AlloyApiMapperTrace trace) {
171 throw new UnsupportedOperationException("BoolTypeReference is not supported.")
172 }
173 def dispatch protected transformTypeReference(IntTypeReference intTypeReference, Logic2AlloyApiMapperTrace trace) {
174 return PrimSig.SIGINT
175 }
176 def dispatch protected transformTypeReference(RealTypeReference realTypeReference, Logic2AlloyApiMapperTrace trace) {
177 throw new UnsupportedOperationException("RealTypeReference is not supported.")
178 }
179 def dispatch protected PrimSig transformTypeReference(ComplexTypeReference complexTypeReference, Logic2AlloyApiMapperTrace trace) {
180 return trace.types.get(complexTypeReference.referred)
181 }
182
183 /*def protected transformFunction(Function declaration, Logic2AlloyApiMapperTrace trace) {
184 val functionDeclaration = createSMTFunctionDeclaration => [
185 name = declaration.name.toID
186 range = declaration.range.transformTypeReference(trace)
187 parameters+= declaration.parameters.map[transformTypeReference(trace)]
188 ]
189 trace.functions.put(declaration,functionDeclaration)
190 return functionDeclaration
191 }*/
192
193 def transformRelation(Relation relation, Logic2AlloyApiMapperTrace trace) {
194 if(relation.parameters.size==2){
195 trace.relations.put(relation,(relation.parameters.get(0).transformTypeReference(trace) as PrimSig).addField(relation.name.toID, (relation.parameters.get(1).transformTypeReference(trace) as PrimSig).setOf))
196 } else{
197 throw new OperationNotSupportedException("More parameters are not supported.")
198 }
199 }
200
201 /*def transformConstant(Constant constant, Logic2AlloyApiMapperTrace trace) {
202 val smtConstant = createSMTFunctionDeclaration => [
203 name = constant.name.toID
204 range = transformTypeReference(constant.type, trace)
205 ]
206 trace.constants.put(constant,smtConstant)
207 return smtConstant
208 }*/
209
210 def protected Expr transformAssertion(Assertion assertion, Logic2AlloyApiMapperTrace trace) {
211
212 return assertion.value.transformTerm(trace,emptyMap)
213 }
214
215 def dispatch protected Expr transformTerm(BoolLiteral literal, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
216 throw new UnsupportedOperationException("Bool is not supported")
217 //open util/boolean, autoPay: Bool
218 //https://code.google.com/p/valloy2009/source/browse/trunk/src/models/util/boolean.als?r=142
219 }
220 def dispatch protected Expr transformTerm(IntLiteral literal, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
221 return ExprConstant.makeNUMBER(literal.value)
222 }
223 def dispatch protected Expr transformTerm(RealLiteral literal, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
224 throw new UnsupportedOperationException("Real number is not supported")
225 }
226 def dispatch protected Expr transformTerm(Not not, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
227 return not.operand.transformTerm(trace,variables).not}
228 def dispatch protected Expr transformTerm(And and, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
229 val List<Expr> operands= and.operands.map[transformTerm(trace,variables)]
230 var andTerm=operands.get(0)
231 for(Integer i: 1..(operands.size-1)){
232 andTerm=andTerm.and(operands.get(i))
233 }
234 return andTerm
235 }
236 def dispatch protected Expr transformTerm(Or or, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
237 val List<Expr> operands= or.operands.map[transformTerm(trace,variables)]
238 var orTerm=operands.get(0)
239 for(Integer i: 1..(operands.size-1)){
240 orTerm=orTerm.or(operands.get(i))
241 }
242 return orTerm
243 }
244 def dispatch protected Expr transformTerm(Impl impl, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
245 return impl.leftOperand.transformTerm(trace,variables).implies(impl.rightOperand.transformTerm(trace,variables))
246 }
247 def dispatch protected Expr transformTerm(Iff ifExpression, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
248 return ifExpression.leftOperand.transformTerm(trace,variables).iff(ifExpression.rightOperand.transformTerm(trace,variables))
249 }
250 def dispatch protected Expr transformTerm(MoreThan moreThan, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
251 return moreThan.leftOperand.transformTerm(trace,variables).gt(moreThan.rightOperand.transformTerm(trace,variables))
252 }
253 def dispatch protected Expr transformTerm(LessThan lessThan, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
254 return lessThan.leftOperand.transformTerm(trace,variables).lt(lessThan.rightOperand.transformTerm(trace,variables))
255 }
256 def dispatch protected Expr transformTerm(MoreOrEqualThan moreThan, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
257 return moreThan.leftOperand.transformTerm(trace,variables).gte(moreThan.rightOperand.transformTerm(trace,variables))
258 }
259 def dispatch protected Expr transformTerm(LessOrEqualThan lessThan, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
260 return lessThan.leftOperand.transformTerm(trace,variables).lte(lessThan.rightOperand.transformTerm(trace,variables))
261 }
262 def dispatch protected Expr transformTerm(Equals equals, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
263 return equals.leftOperand.transformTerm(trace,variables).equal(equals.rightOperand.transformTerm(trace,variables))
264 }
265 /*def dispatch protected Expr transformTerm(Distinct distinct, Logic2AlloyApiMapperTrace trace, Map<Variable, SMTSortedVariable> variables) {
266 createSMTDistinct => [ operands += distinct.operands.map[transformTerm(trace,variables)]]}*/
267 def dispatch protected Expr transformTerm(Plus plus, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
268 return plus.leftOperand.transformTerm(trace,variables).plus(plus.rightOperand.transformTerm(trace,variables))
269 }
270 def dispatch protected Expr transformTerm(Minus minus, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
271 return minus.leftOperand.transformTerm(trace,variables).minus(minus.rightOperand.transformTerm(trace,variables))
272 }
273 def dispatch protected Expr transformTerm(Multiply multiply, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
274 return multiply.leftOperand.transformTerm(trace,variables).mul(multiply.rightOperand.transformTerm(trace,variables))
275 }
276 def dispatch protected Expr transformTerm(Divison div, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
277 return div.leftOperand.transformTerm(trace,variables).div(div.rightOperand.transformTerm(trace,variables))
278 }
279 def dispatch protected Expr transformTerm(Mod mod, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
280 throw new UnsupportedOperationException("Modulo is not supported.")
281 }
282 def dispatch protected Expr transformTerm(Forall forall, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
283 return configureForall(forall,trace,variables)
284 }
285 def dispatch protected Expr transformTerm(Exists exists, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
286 return configureExists(exists,trace,variables)
287 }
288 def dispatch protected Expr transformTerm(SymbolicValue symbolicValue, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
289 symbolicValue.symbolicReference.transformSymbolicReference(symbolicValue.parameterSubstitutions,trace,variables) }
290
291 def private configureForall(
292 Forall quantifiedExpression,
293 Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables)
294 {
295 val allVariables = new HashMap(variables)
296 val newAlloyVariables = new ArrayList<Decl>(quantifiedExpression.quantifiedVariables.size)
297
298 for(logicVariable: quantifiedExpression.quantifiedVariables) {
299 val newAlloyVariable = (logicVariable.range.transformTypeReference(trace)).oneOf(logicVariable.name.toID) as Decl
300 allVariables.put(logicVariable, newAlloyVariable)
301 newAlloyVariables += newAlloyVariable
302 }
303 val variable0=newAlloyVariables.get(0)
304 newAlloyVariables.remove(0)
305 return (quantifiedExpression.expression.transformTerm(trace,allVariables)).forAll(variable0, newAlloyVariables)
306 }
307
308 def private configureExists(
309 Exists quantifiedExpression,
310 Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables)
311 {
312 val allVariables = new HashMap(variables)
313 val newAlloyVariables = new ArrayList<Decl>(quantifiedExpression.quantifiedVariables.size)
314
315 for(logicVariable: quantifiedExpression.quantifiedVariables) {
316 val newAlloyVariable = (logicVariable.range.transformTypeReference(trace)).oneOf(logicVariable.name.toID) as Decl
317 allVariables.put(logicVariable, newAlloyVariable)
318 newAlloyVariables += newAlloyVariable
319 }
320 val variable0=newAlloyVariables.get(0)
321 newAlloyVariables.remove(0)
322 return (quantifiedExpression.expression.transformTerm(trace,allVariables)).forSome(variable0, newAlloyVariables)
323 }
324
325 def dispatch protected Expr transformSymbolicReference(DefinedElement referred, List<Term> parameterSubstitutions, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
326 return trace.elements.get(referred)
327 }
328 def dispatch protected Expr transformSymbolicReference(Variable variable, List<Term> parameterSubstitutions, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
329 return variables.get(variable).get
330 }
331 /*def dispatch protected Expr transformSymbolicReference(Function function, List<Term> parameterSubstitutions, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
332 val result = createSMTSymbolicValue => [sv | sv.symbolicReference = trace.functions.get(function)]
333 for(paramSubstitution : parameterSubstitutions) {
334 result.parameterSubstitutions.add(paramSubstitution.transformTerm(trace,variables))
335 }
336 return result
337 }*/
338 def dispatch protected Expr transformSymbolicReference(Relation relation, List<Term> parameterSubstitutions, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
339 return trace.relations.get(relation)
340 }
341 def dispatch protected Expr transformSymbolicReference(Constant constant, List<Term> parameterSubstitutions, Logic2AlloyApiMapperTrace trace, Map<Variable, Decl> variables) {
342 //createSMTSymbolicValue => [symbolicReference = trace.constants.get(constant)]
343 throw new UnsupportedOperationException("Constant is not supported")
344 }
345} \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/oldTypes b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/oldTypes
new file mode 100644
index 00000000..5e349ac8
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dlsreasoner.alloy.reasoner/unused/oldTypes
@@ -0,0 +1,74 @@
1/*def dispatch boolean hasDeclaredElement(TypeDefinition type) { return false; }
2 def dispatch boolean hasDeclaredElement(TypeDeclaration type) {
3 if(type.isAbstract) {
4 type.subtypes.exists[it.hasDeclaredElement]
5 } else return true;
6 }
7
8 def dispatch List<TypeDefinition> allEnumSubtypes(TypeDefinition type) { return #[type] }
9 def dispatch List<TypeDefinition> allEnumSubtypes(TypeDeclaration type) {
10 return type.subtypes.map[it.allEnumSubtypes].flatten.toList
11 }
12
13 def protected transformTypes(List<Type> types, Logic2AlloyLanguageMapperTrace trace) {
14 val Map<TypeDeclaration,ALSSignatureDeclaration> signatureTrace = new HashMap;
15
16 // Creating the root type
17 val objectType = createALSSignatureDeclaration => [ name=#["util","object"].toID it.abstract = true ]
18 trace.objectSupperClass = objectType
19 trace.specification.typeDeclarations += objectType
20
21 // Creating the images of the types
22 for(type : types) {
23 if(type instanceof TypeDefinition) {
24 if(type.elements.empty) {
25 trace.type2ALSType.put(type,#[]);
26 } else {
27 val e = createALSEnumDeclaration => [
28 it.name = type.name.toID
29 it.literal += type.elements.map[transformDefinedElement(trace)]
30 ]
31 trace.type2ALSType.put(type,#[e])
32 trace.specification.typeDeclarations += e
33 }
34 }
35 else if(type instanceof TypeDeclaration) {
36 if(hasDeclaredElement(type)) {
37 val s = createALSSignatureDeclaration => [
38 name=type.name.toID
39 it.abstract = type.isIsAbstract
40 ]
41 trace.type2ALSType.put(type,new LinkedList=>[add(s)])
42 signatureTrace.put(type, s)
43 trace.specification.typeDeclarations += s
44 }
45 else {
46 signatureTrace.put(type, null)
47 trace.type2ALSType.put(type,new LinkedList);// empty
48 }
49 }
50 else throw new IllegalArgumentException('''Unknown type «type.class.name»''')
51 }
52
53
54 for(type: types.filter(TypeDeclaration)) {
55 // Adding inheritance
56 val s = type.lookup(signatureTrace)
57 if(s!=null) {
58 for(supertype : type.supertypes) {
59 s.supertype += (supertype as TypeDeclaration).lookup(signatureTrace)
60 }
61 if(type.supertypes.empty) {
62 s.supertype += objectType
63 }
64 }
65 // Adding enum subtypes
66 type.lookup(trace.type2ALSType)+=type.allEnumSubtypes.map[it.lookup(trace.type2ALSType)].flatten
67 }
68 }
69
70 def protected transformDefinedElement(DefinedElement element, Logic2AlloyLanguageMapperTrace trace) {
71 val result = createALSEnumLiteral => [name = element.name.toID]
72 trace.definedElement2EnumProperty.put(element,result)
73 return result
74 }*/ \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.classpath b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.classpath
new file mode 100644
index 00000000..f5ffadb8
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.classpath
@@ -0,0 +1,9 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<classpath>
3 <classpathentry kind="src" path="src"/>
4 <classpathentry kind="src" path="src-gen"/>
5 <classpathentry kind="src" path="xtend-gen"/>
6 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
7 <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
8 <classpathentry kind="output" path="bin"/>
9</classpath>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.gitignore b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.gitignore
new file mode 100644
index 00000000..8ae4e44d
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.gitignore
@@ -0,0 +1,4 @@
1/bin/
2/src-gen/
3/vql-gen/
4/xtend-gen/
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.project b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.project
new file mode 100644
index 00000000..25768d12
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.project
@@ -0,0 +1,34 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<projectDescription>
3 <name>hu.bme.mit.inf.dslreasoner.alloy.language.ui</name>
4 <comment></comment>
5 <projects>
6 </projects>
7 <buildSpec>
8 <buildCommand>
9 <name>org.eclipse.jdt.core.javabuilder</name>
10 <arguments>
11 </arguments>
12 </buildCommand>
13 <buildCommand>
14 <name>org.eclipse.pde.ManifestBuilder</name>
15 <arguments>
16 </arguments>
17 </buildCommand>
18 <buildCommand>
19 <name>org.eclipse.pde.SchemaBuilder</name>
20 <arguments>
21 </arguments>
22 </buildCommand>
23 <buildCommand>
24 <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
25 <arguments>
26 </arguments>
27 </buildCommand>
28 </buildSpec>
29 <natures>
30 <nature>org.eclipse.jdt.core.javanature</nature>
31 <nature>org.eclipse.pde.PluginNature</nature>
32 <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
33 </natures>
34</projectDescription>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.settings/org.eclipse.core.resources.prefs b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..4824b802
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
1eclipse.preferences.version=1
2encoding/<project>=UTF-8
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.settings/org.eclipse.jdt.core.prefs b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..11f6e462
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
1eclipse.preferences.version=1
2org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4org.eclipse.jdt.core.compiler.compliance=1.7
5org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7org.eclipse.jdt.core.compiler.source=1.7
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/META-INF/MANIFEST.MF b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..a6ff6ade
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
1Manifest-Version: 1.0
2Bundle-ManifestVersion: 2
3Bundle-Name: hu.bme.mit.inf.dslreasoner.alloy.language.ui
4Bundle-Vendor: My Company
5Bundle-Version: 1.0.0.qualifier
6Bundle-SymbolicName: hu.bme.mit.inf.dslreasoner.alloy.language.ui; singleton:=true
7Bundle-ActivationPolicy: lazy
8Require-Bundle: hu.bme.mit.inf.dslreasoner.alloy.language;visibility:=reexport,
9 org.eclipse.xtext.ui,
10 org.eclipse.ui.editors;bundle-version="3.5.0",
11 org.eclipse.ui.ide;bundle-version="3.5.0",
12 org.eclipse.xtext.ui.shared,
13 org.eclipse.ui,
14 org.eclipse.xtext.builder,
15 org.eclipse.xtext.xbase.lib,
16 org.antlr.runtime,
17 org.eclipse.xtext.common.types.ui,
18 org.eclipse.xtext.ui.codetemplates.ui,
19 org.eclipse.compare
20Import-Package: org.apache.log4j
21Bundle-RequiredExecutionEnvironment: JavaSE-1.7
22Export-Package: hu.bme.mit.inf.dslreasoner.ui.quickfix,
23 hu.bme.mit.inf.dslreasoner.ui.contentassist,
24 hu.bme.mit.inf.dslreasoner.ui.contentassist.antlr,
25 hu.bme.mit.inf.dslreasoner.ui.internal,
26 hu.bme.mit.inf.dslreasoner.ui.contentassist.antlr.internal
27Bundle-Activator: hu.bme.mit.inf.dslreasoner.ui.internal.AlloyLanguageActivator
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/build.properties b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/build.properties
new file mode 100644
index 00000000..31255ed0
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/build.properties
@@ -0,0 +1,6 @@
1source.. = src/,\
2 src-gen/,\
3 xtend-gen/
4bin.includes = META-INF/,\
5 .,\
6 plugin.xml \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/plugin.xml b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/plugin.xml
new file mode 100644
index 00000000..962a70ce
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/plugin.xml
@@ -0,0 +1,398 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<?eclipse version="3.0"?>
3
4<plugin>
5
6 <extension
7 point="org.eclipse.ui.editors">
8 <editor
9 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor"
10 contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
11 default="true"
12 extensions="als"
13 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
14 name="AlloyLanguage Editor">
15 </editor>
16 </extension>
17 <extension
18 point="org.eclipse.ui.handlers">
19 <handler
20 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclarationHandler"
21 commandId="org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclaration">
22 <activeWhen>
23 <reference
24 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
25 </reference>
26 </activeWhen>
27 </handler>
28 <handler
29 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.handler.ValidateActionHandler"
30 commandId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.validate">
31 <activeWhen>
32 <reference
33 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
34 </reference>
35 </activeWhen>
36 </handler>
37 <!-- copy qualified name -->
38 <handler
39 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedNameHandler"
40 commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName">
41 <activeWhen>
42 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened" />
43 </activeWhen>
44 </handler>
45 <handler
46 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedNameHandler"
47 commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName">
48 <activeWhen>
49 <and>
50 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.XtextEditor.opened" />
51 <iterate>
52 <adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
53 </iterate>
54 </and>
55 </activeWhen>
56 </handler>
57 </extension>
58 <extension point="org.eclipse.core.expressions.definitions">
59 <definition id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
60 <and>
61 <reference definitionId="isActiveEditorAnInstanceOfXtextEditor"/>
62 <with variable="activeEditor">
63 <test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName"
64 value="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
65 forcePluginActivation="true"/>
66 </with>
67 </and>
68 </definition>
69 <definition id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.XtextEditor.opened">
70 <and>
71 <reference definitionId="isXtextEditorActive"/>
72 <with variable="activeEditor">
73 <test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName"
74 value="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
75 forcePluginActivation="true"/>
76 </with>
77 </and>
78 </definition>
79 </extension>
80 <extension
81 point="org.eclipse.ui.preferencePages">
82 <page
83 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
84 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
85 name="AlloyLanguage">
86 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
87 </page>
88 <page
89 category="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
90 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.syntaxcoloring.SyntaxColoringPreferencePage"
91 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.coloring"
92 name="Syntax Coloring">
93 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
94 </page>
95 <page
96 category="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
97 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.templates.XtextTemplatePreferencePage"
98 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.templates"
99 name="Templates">
100 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
101 </page>
102 </extension>
103 <extension
104 point="org.eclipse.ui.propertyPages">
105 <page
106 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
107 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
108 name="AlloyLanguage">
109 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
110 <enabledWhen>
111 <adapt type="org.eclipse.core.resources.IProject"/>
112 </enabledWhen>
113 <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
114 </page>
115 </extension>
116 <extension
117 point="org.eclipse.ui.keywords">
118 <keyword
119 id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"
120 label="AlloyLanguage"/>
121 </extension>
122 <extension
123 point="org.eclipse.ui.commands">
124 <command
125 description="Trigger expensive validation"
126 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.validate"
127 name="Validate">
128 </command>
129 <!-- copy qualified name -->
130 <command
131 id="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
132 categoryId="org.eclipse.ui.category.edit"
133 description="Copy the qualified name for the selected element"
134 name="Copy Qualified Name">
135 </command>
136 <command
137 id="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
138 categoryId="org.eclipse.ui.category.edit"
139 description="Copy the qualified name for the selected element"
140 name="Copy Qualified Name">
141 </command>
142 </extension>
143 <extension point="org.eclipse.ui.menus">
144 <menuContribution
145 locationURI="popup:#TextEditorContext?after=group.edit">
146 <command
147 commandId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.validate"
148 style="push"
149 tooltip="Trigger expensive validation">
150 <visibleWhen checkEnabled="false">
151 <reference
152 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
153 </reference>
154 </visibleWhen>
155 </command>
156 </menuContribution>
157 <!-- copy qualified name -->
158 <menuContribution locationURI="popup:#TextEditorContext?after=copy">
159 <command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
160 style="push" tooltip="Copy Qualified Name">
161 <visibleWhen checkEnabled="false">
162 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened" />
163 </visibleWhen>
164 </command>
165 </menuContribution>
166 <menuContribution locationURI="menu:edit?after=copy">
167 <command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
168 style="push" tooltip="Copy Qualified Name">
169 <visibleWhen checkEnabled="false">
170 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened" />
171 </visibleWhen>
172 </command>
173 </menuContribution>
174 <menuContribution locationURI="popup:org.eclipse.xtext.ui.outline?after=additions">
175 <command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
176 style="push" tooltip="Copy Qualified Name">
177 <visibleWhen checkEnabled="false">
178 <and>
179 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.XtextEditor.opened" />
180 <iterate>
181 <adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
182 </iterate>
183 </and>
184 </visibleWhen>
185 </command>
186 </menuContribution>
187 </extension>
188 <extension point="org.eclipse.ui.menus">
189 <menuContribution locationURI="popup:#TextEditorContext?endof=group.find">
190 <command commandId="org.eclipse.xtext.ui.editor.FindReferences">
191 <visibleWhen checkEnabled="false">
192 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
193 </reference>
194 </visibleWhen>
195 </command>
196 </menuContribution>
197 </extension>
198 <extension point="org.eclipse.ui.handlers">
199 <handler
200 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler"
201 commandId="org.eclipse.xtext.ui.editor.FindReferences">
202 <activeWhen>
203 <reference
204 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
205 </reference>
206 </activeWhen>
207 </handler>
208 </extension>
209
210<!-- adding resource factories -->
211
212 <extension
213 point="org.eclipse.emf.ecore.extension_parser">
214 <parser
215 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
216 type="als">
217 </parser>
218 </extension>
219 <extension point="org.eclipse.xtext.extension_resourceServiceProvider">
220 <resourceServiceProvider
221 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
222 uriExtension="als">
223 </resourceServiceProvider>
224 </extension>
225
226
227 <!-- marker definitions for hu.bme.mit.inf.dslreasoner.AlloyLanguage -->
228 <extension
229 id="alloylanguage.check.fast"
230 name="AlloyLanguage Problem"
231 point="org.eclipse.core.resources.markers">
232 <super type="org.eclipse.xtext.ui.check.fast"/>
233 <persistent value="true"/>
234 </extension>
235 <extension
236 id="alloylanguage.check.normal"
237 name="AlloyLanguage Problem"
238 point="org.eclipse.core.resources.markers">
239 <super type="org.eclipse.xtext.ui.check.normal"/>
240 <persistent value="true"/>
241 </extension>
242 <extension
243 id="alloylanguage.check.expensive"
244 name="AlloyLanguage Problem"
245 point="org.eclipse.core.resources.markers">
246 <super type="org.eclipse.xtext.ui.check.expensive"/>
247 <persistent value="true"/>
248 </extension>
249
250 <extension
251 point="org.eclipse.xtext.builder.participant">
252 <participant
253 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.builder.IXtextBuilderParticipant"
254 fileExtensions="als"
255 >
256 </participant>
257 </extension>
258 <extension
259 point="org.eclipse.ui.preferencePages">
260 <page
261 category="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
262 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage"
263 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.compiler.preferencePage"
264 name="Compiler">
265 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
266 </page>
267 </extension>
268 <extension
269 point="org.eclipse.ui.propertyPages">
270 <page
271 category="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
272 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage"
273 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.compiler.propertyPage"
274 name="Compiler">
275 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
276 <enabledWhen>
277 <adapt type="org.eclipse.core.resources.IProject"/>
278 </enabledWhen>
279 <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
280 </page>
281 </extension>
282
283 <!-- Quick Outline -->
284 <extension
285 point="org.eclipse.ui.handlers">
286 <handler
287 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.outline.quickoutline.ShowQuickOutlineActionHandler"
288 commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline">
289 <activeWhen>
290 <reference
291 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
292 </reference>
293 </activeWhen>
294 </handler>
295 </extension>
296 <extension
297 point="org.eclipse.ui.commands">
298 <command
299 description="Open the quick outline."
300 id="org.eclipse.xtext.ui.editor.outline.QuickOutline"
301 name="Quick Outline">
302 </command>
303 </extension>
304 <extension point="org.eclipse.ui.menus">
305 <menuContribution
306 locationURI="popup:#TextEditorContext?after=group.open">
307 <command commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline"
308 style="push"
309 tooltip="Open Quick Outline">
310 <visibleWhen checkEnabled="false">
311 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened"/>
312 </visibleWhen>
313 </command>
314 </menuContribution>
315 </extension>
316 <!-- quickfix marker resolution generator for hu.bme.mit.inf.dslreasoner.AlloyLanguage -->
317 <extension
318 point="org.eclipse.ui.ide.markerResolution">
319 <markerResolutionGenerator
320 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
321 markerType="hu.bme.mit.inf.dslreasoner.ui.alloylanguage.check.fast">
322 <attribute
323 name="FIXABLE_KEY"
324 value="true">
325 </attribute>
326 </markerResolutionGenerator>
327 <markerResolutionGenerator
328 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
329 markerType="hu.bme.mit.inf.dslreasoner.ui.alloylanguage.check.normal">
330 <attribute
331 name="FIXABLE_KEY"
332 value="true">
333 </attribute>
334 </markerResolutionGenerator>
335 <markerResolutionGenerator
336 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
337 markerType="hu.bme.mit.inf.dslreasoner.ui.alloylanguage.check.expensive">
338 <attribute
339 name="FIXABLE_KEY"
340 value="true">
341 </attribute>
342 </markerResolutionGenerator>
343 </extension>
344 <!-- Rename Refactoring -->
345 <extension point="org.eclipse.ui.handlers">
346 <handler
347 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler"
348 commandId="org.eclipse.xtext.ui.refactoring.RenameElement">
349 <activeWhen>
350 <reference
351 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
352 </reference>
353 </activeWhen>
354 </handler>
355 </extension>
356 <extension point="org.eclipse.ui.menus">
357 <menuContribution
358 locationURI="popup:#TextEditorContext?after=group.edit">
359 <command commandId="org.eclipse.xtext.ui.refactoring.RenameElement"
360 style="push">
361 <visibleWhen checkEnabled="false">
362 <reference
363 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
364 </reference>
365 </visibleWhen>
366 </command>
367 </menuContribution>
368 </extension>
369 <extension point="org.eclipse.ui.preferencePages">
370 <page
371 category="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
372 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage"
373 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.refactoring"
374 name="Refactoring">
375 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
376 </page>
377 </extension>
378
379 <extension point="org.eclipse.compare.contentViewers">
380 <viewer id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.compare.contentViewers"
381 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
382 extensions="als">
383 </viewer>
384 </extension>
385 <extension point="org.eclipse.compare.contentMergeViewers">
386 <viewer id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.compare.contentMergeViewers"
387 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
388 extensions="als" label="AlloyLanguage Compare">
389 </viewer>
390 </extension>
391 <extension point="org.eclipse.ui.editors.documentProviders">
392 <provider id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.editors.documentProviders"
393 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.model.XtextDocumentProvider"
394 extensions="als">
395 </provider>
396 </extension>
397
398</plugin>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/plugin.xml_gen b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/plugin.xml_gen
new file mode 100644
index 00000000..634f234b
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/plugin.xml_gen
@@ -0,0 +1,425 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<?eclipse version="3.0"?>
3
4<plugin>
5
6 <extension
7 point="org.eclipse.ui.editors">
8 <editor
9 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor"
10 contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
11 default="true"
12 extensions="als"
13 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
14 name="AlloyLanguage Editor">
15 </editor>
16 </extension>
17 <extension
18 point="org.eclipse.ui.handlers">
19 <handler
20 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclarationHandler"
21 commandId="org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclaration">
22 <activeWhen>
23 <reference
24 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
25 </reference>
26 </activeWhen>
27 </handler>
28 <handler
29 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.handler.ValidateActionHandler"
30 commandId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.validate">
31 <activeWhen>
32 <reference
33 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
34 </reference>
35 </activeWhen>
36 </handler>
37 <!-- copy qualified name -->
38 <handler
39 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedNameHandler"
40 commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName">
41 <activeWhen>
42 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened" />
43 </activeWhen>
44 </handler>
45 <handler
46 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedNameHandler"
47 commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName">
48 <activeWhen>
49 <and>
50 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.XtextEditor.opened" />
51 <iterate>
52 <adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
53 </iterate>
54 </and>
55 </activeWhen>
56 </handler>
57 </extension>
58 <extension point="org.eclipse.core.expressions.definitions">
59 <definition id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
60 <and>
61 <reference definitionId="isActiveEditorAnInstanceOfXtextEditor"/>
62 <with variable="activeEditor">
63 <test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName"
64 value="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
65 forcePluginActivation="true"/>
66 </with>
67 </and>
68 </definition>
69 <definition id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.XtextEditor.opened">
70 <and>
71 <reference definitionId="isXtextEditorActive"/>
72 <with variable="activeEditor">
73 <test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName"
74 value="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
75 forcePluginActivation="true"/>
76 </with>
77 </and>
78 </definition>
79 </extension>
80 <extension
81 point="org.eclipse.ui.preferencePages">
82 <page
83 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
84 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
85 name="AlloyLanguage">
86 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
87 </page>
88 <page
89 category="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
90 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.syntaxcoloring.SyntaxColoringPreferencePage"
91 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.coloring"
92 name="Syntax Coloring">
93 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
94 </page>
95 <page
96 category="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
97 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.templates.XtextTemplatePreferencePage"
98 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.templates"
99 name="Templates">
100 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
101 </page>
102 </extension>
103 <extension
104 point="org.eclipse.ui.propertyPages">
105 <page
106 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
107 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
108 name="AlloyLanguage">
109 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
110 <enabledWhen>
111 <adapt type="org.eclipse.core.resources.IProject"/>
112 </enabledWhen>
113 <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
114 </page>
115 </extension>
116 <extension
117 point="org.eclipse.ui.keywords">
118 <keyword
119 id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"
120 label="AlloyLanguage"/>
121 </extension>
122 <extension
123 point="org.eclipse.ui.commands">
124 <command
125 description="Trigger expensive validation"
126 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.validate"
127 name="Validate">
128 </command>
129 <!-- copy qualified name -->
130 <command
131 id="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
132 categoryId="org.eclipse.ui.category.edit"
133 description="Copy the qualified name for the selected element"
134 name="Copy Qualified Name">
135 </command>
136 <command
137 id="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
138 categoryId="org.eclipse.ui.category.edit"
139 description="Copy the qualified name for the selected element"
140 name="Copy Qualified Name">
141 </command>
142 </extension>
143 <extension point="org.eclipse.ui.menus">
144 <menuContribution
145 locationURI="popup:#TextEditorContext?after=group.edit">
146 <command
147 commandId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.validate"
148 style="push"
149 tooltip="Trigger expensive validation">
150 <visibleWhen checkEnabled="false">
151 <reference
152 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
153 </reference>
154 </visibleWhen>
155 </command>
156 </menuContribution>
157 <!-- copy qualified name -->
158 <menuContribution locationURI="popup:#TextEditorContext?after=copy">
159 <command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
160 style="push" tooltip="Copy Qualified Name">
161 <visibleWhen checkEnabled="false">
162 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened" />
163 </visibleWhen>
164 </command>
165 </menuContribution>
166 <menuContribution locationURI="menu:edit?after=copy">
167 <command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
168 style="push" tooltip="Copy Qualified Name">
169 <visibleWhen checkEnabled="false">
170 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened" />
171 </visibleWhen>
172 </command>
173 </menuContribution>
174 <menuContribution locationURI="popup:org.eclipse.xtext.ui.outline?after=additions">
175 <command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
176 style="push" tooltip="Copy Qualified Name">
177 <visibleWhen checkEnabled="false">
178 <and>
179 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.XtextEditor.opened" />
180 <iterate>
181 <adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
182 </iterate>
183 </and>
184 </visibleWhen>
185 </command>
186 </menuContribution>
187 </extension>
188 <extension point="org.eclipse.ui.menus">
189 <menuContribution locationURI="popup:#TextEditorContext?endof=group.find">
190 <command commandId="org.eclipse.xtext.ui.editor.FindReferences">
191 <visibleWhen checkEnabled="false">
192 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
193 </reference>
194 </visibleWhen>
195 </command>
196 </menuContribution>
197 </extension>
198 <extension point="org.eclipse.ui.handlers">
199 <handler
200 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler"
201 commandId="org.eclipse.xtext.ui.editor.FindReferences">
202 <activeWhen>
203 <reference
204 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
205 </reference>
206 </activeWhen>
207 </handler>
208 </extension>
209
210<!-- adding resource factories -->
211
212 <extension
213 point="org.eclipse.emf.ecore.extension_parser">
214 <parser
215 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
216 type="als">
217 </parser>
218 </extension>
219 <extension point="org.eclipse.xtext.extension_resourceServiceProvider">
220 <resourceServiceProvider
221 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
222 uriExtension="als">
223 </resourceServiceProvider>
224 </extension>
225
226
227 <!-- marker definitions for hu.bme.mit.inf.dslreasoner.AlloyLanguage -->
228 <extension
229 id="alloylanguage.check.fast"
230 name="AlloyLanguage Problem"
231 point="org.eclipse.core.resources.markers">
232 <super type="org.eclipse.xtext.ui.check.fast"/>
233 <persistent value="true"/>
234 </extension>
235 <extension
236 id="alloylanguage.check.normal"
237 name="AlloyLanguage Problem"
238 point="org.eclipse.core.resources.markers">
239 <super type="org.eclipse.xtext.ui.check.normal"/>
240 <persistent value="true"/>
241 </extension>
242 <extension
243 id="alloylanguage.check.expensive"
244 name="AlloyLanguage Problem"
245 point="org.eclipse.core.resources.markers">
246 <super type="org.eclipse.xtext.ui.check.expensive"/>
247 <persistent value="true"/>
248 </extension>
249
250 <extension
251 point="org.eclipse.xtext.builder.participant">
252 <participant
253 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.builder.IXtextBuilderParticipant"
254 fileExtensions="als"
255 >
256 </participant>
257 </extension>
258 <extension
259 point="org.eclipse.ui.preferencePages">
260 <page
261 category="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
262 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage"
263 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.compiler.preferencePage"
264 name="Compiler">
265 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
266 </page>
267 </extension>
268 <extension
269 point="org.eclipse.ui.propertyPages">
270 <page
271 category="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
272 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage"
273 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.compiler.propertyPage"
274 name="Compiler">
275 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
276 <enabledWhen>
277 <adapt type="org.eclipse.core.resources.IProject"/>
278 </enabledWhen>
279 <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
280 </page>
281 </extension>
282 <extension point="org.eclipse.ui.menus">
283 <menuContribution locationURI="popup:#TextEditorContext?after=xtext.ui.openDeclaration">
284 <command
285 commandId="org.eclipse.xtext.ui.OpenGeneratedFileCommand"
286 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.OpenGeneratedCode"
287 style="push">
288 <visibleWhen checkEnabled="false">
289 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened" />
290 </visibleWhen>
291 </command>
292 </menuContribution>
293 </extension>
294 <extension point="org.eclipse.ui.handlers">
295 <handler
296 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.generator.trace.OpenGeneratedFileHandler"
297 commandId="org.eclipse.xtext.ui.OpenGeneratedFileCommand">
298 <activeWhen>
299 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened" />
300 </activeWhen>
301 </handler>
302 </extension>
303
304 <!-- Quick Outline -->
305 <extension
306 point="org.eclipse.ui.handlers">
307 <handler
308 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.outline.quickoutline.ShowQuickOutlineActionHandler"
309 commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline">
310 <activeWhen>
311 <reference
312 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
313 </reference>
314 </activeWhen>
315 </handler>
316 </extension>
317 <extension
318 point="org.eclipse.ui.commands">
319 <command
320 description="Open the quick outline."
321 id="org.eclipse.xtext.ui.editor.outline.QuickOutline"
322 name="Quick Outline">
323 </command>
324 </extension>
325 <extension point="org.eclipse.ui.menus">
326 <menuContribution
327 locationURI="popup:#TextEditorContext?after=group.open">
328 <command commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline"
329 style="push"
330 tooltip="Open Quick Outline">
331 <visibleWhen checkEnabled="false">
332 <reference definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened"/>
333 </visibleWhen>
334 </command>
335 </menuContribution>
336 </extension>
337 <!-- quickfix marker resolution generator for hu.bme.mit.inf.dslreasoner.AlloyLanguage -->
338 <extension
339 point="org.eclipse.ui.ide.markerResolution">
340 <markerResolutionGenerator
341 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
342 markerType="hu.bme.mit.inf.dslreasoner.ui.alloylanguage.check.fast">
343 <attribute
344 name="FIXABLE_KEY"
345 value="true">
346 </attribute>
347 </markerResolutionGenerator>
348 <markerResolutionGenerator
349 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
350 markerType="hu.bme.mit.inf.dslreasoner.ui.alloylanguage.check.normal">
351 <attribute
352 name="FIXABLE_KEY"
353 value="true">
354 </attribute>
355 </markerResolutionGenerator>
356 <markerResolutionGenerator
357 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
358 markerType="hu.bme.mit.inf.dslreasoner.ui.alloylanguage.check.expensive">
359 <attribute
360 name="FIXABLE_KEY"
361 value="true">
362 </attribute>
363 </markerResolutionGenerator>
364 </extension>
365 <!-- Rename Refactoring -->
366 <extension point="org.eclipse.ui.handlers">
367 <handler
368 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler"
369 commandId="org.eclipse.xtext.ui.refactoring.RenameElement">
370 <activeWhen>
371 <reference
372 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
373 </reference>
374 </activeWhen>
375 </handler>
376 </extension>
377 <extension point="org.eclipse.ui.menus">
378 <menuContribution
379 locationURI="popup:#TextEditorContext?after=group.edit">
380 <command commandId="org.eclipse.xtext.ui.refactoring.RenameElement"
381 style="push">
382 <visibleWhen checkEnabled="false">
383 <reference
384 definitionId="hu.bme.mit.inf.dslreasoner.AlloyLanguage.Editor.opened">
385 </reference>
386 </visibleWhen>
387 </command>
388 </menuContribution>
389 </extension>
390 <extension point="org.eclipse.ui.preferencePages">
391 <page
392 category="hu.bme.mit.inf.dslreasoner.AlloyLanguage"
393 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage"
394 id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.refactoring"
395 name="Refactoring">
396 <keywordReference id="hu.bme.mit.inf.dslreasoner.ui.keyword_AlloyLanguage"/>
397 </page>
398 </extension>
399
400 <extension point="org.eclipse.compare.contentViewers">
401 <viewer id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.compare.contentViewers"
402 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
403 extensions="als">
404 </viewer>
405 </extension>
406 <extension point="org.eclipse.compare.contentMergeViewers">
407 <viewer id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.compare.contentMergeViewers"
408 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
409 extensions="als" label="AlloyLanguage Compare">
410 </viewer>
411 </extension>
412 <extension point="org.eclipse.ui.editors.documentProviders">
413 <provider id="hu.bme.mit.inf.dslreasoner.AlloyLanguage.editors.documentProviders"
414 class="hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageExecutableExtensionFactory:org.eclipse.xtext.ui.editor.model.XtextDocumentProvider"
415 extensions="als">
416 </provider>
417 </extension>
418 <extension point="org.eclipse.team.core.fileTypes">
419 <fileTypes
420 extension="als"
421 type="text">
422 </fileTypes>
423 </extension>
424
425</plugin>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/AlloyLanguageUiModule.java b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/AlloyLanguageUiModule.java
new file mode 100644
index 00000000..20d083e6
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/AlloyLanguageUiModule.java
@@ -0,0 +1,15 @@
1/*
2 * generated by Xtext
3 */
4package hu.bme.mit.inf.dslreasoner.ui;
5
6import org.eclipse.ui.plugin.AbstractUIPlugin;
7
8/**
9 * Use this class to register components to be used within the IDE.
10 */
11public class AlloyLanguageUiModule extends hu.bme.mit.inf.dslreasoner.ui.AbstractAlloyLanguageUiModule {
12 public AlloyLanguageUiModule(AbstractUIPlugin plugin) {
13 super(plugin);
14 }
15}
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/contentassist/AlloyLanguageProposalProvider.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/contentassist/AlloyLanguageProposalProvider.xtend
new file mode 100644
index 00000000..cf8d33f8
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/contentassist/AlloyLanguageProposalProvider.xtend
@@ -0,0 +1,12 @@
1/*
2 * generated by Xtext
3 */
4package hu.bme.mit.inf.dslreasoner.ui.contentassist
5
6import hu.bme.mit.inf.dslreasoner.ui.contentassist.AbstractAlloyLanguageProposalProvider
7
8/**
9 * see http://www.eclipse.org/Xtext/documentation.html#contentAssist on how to customize content assistant
10 */
11class AlloyLanguageProposalProvider extends AbstractAlloyLanguageProposalProvider {
12}
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/labeling/AlloyLanguageDescriptionLabelProvider.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/labeling/AlloyLanguageDescriptionLabelProvider.xtend
new file mode 100644
index 00000000..89bb0f87
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/labeling/AlloyLanguageDescriptionLabelProvider.xtend
@@ -0,0 +1,24 @@
1/*
2* generated by Xtext
3*/
4package hu.bme.mit.inf.dslreasoner.ui.labeling
5
6//import org.eclipse.xtext.resource.IEObjectDescription
7
8/**
9 * Provides labels for a IEObjectDescriptions and IResourceDescriptions.
10 *
11 * see http://www.eclipse.org/Xtext/documentation.html#labelProvider
12 */
13class AlloyLanguageDescriptionLabelProvider extends org.eclipse.xtext.ui.label.DefaultDescriptionLabelProvider {
14
15 // Labels and icons can be computed like this:
16
17// override text(IEObjectDescription ele) {
18// ele.name.toString
19// }
20//
21// override image(IEObjectDescription ele) {
22// ele.EClass.name + '.gif'
23// }
24}
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/labeling/AlloyLanguageLabelProvider.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/labeling/AlloyLanguageLabelProvider.xtend
new file mode 100644
index 00000000..6f002921
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/labeling/AlloyLanguageLabelProvider.xtend
@@ -0,0 +1,29 @@
1/*
2* generated by Xtext
3*/
4package hu.bme.mit.inf.dslreasoner.ui.labeling
5
6import com.google.inject.Inject
7
8/**
9 * Provides labels for a EObjects.
10 *
11 * see http://www.eclipse.org/Xtext/documentation.html#labelProvider
12 */
13class AlloyLanguageLabelProvider extends org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider {
14
15 @Inject
16 new(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider delegate) {
17 super(delegate);
18 }
19
20 // Labels and icons can be computed like this:
21
22// def text(Greeting ele) {
23// 'A greeting to ' + ele.name
24// }
25//
26// def image(Greeting ele) {
27// 'Greeting.gif'
28// }
29}
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/outline/AlloyLanguageOutlineTreeProvider.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/outline/AlloyLanguageOutlineTreeProvider.xtend
new file mode 100644
index 00000000..fe3fef9d
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/outline/AlloyLanguageOutlineTreeProvider.xtend
@@ -0,0 +1,13 @@
1/*
2* generated by Xtext
3*/
4package hu.bme.mit.inf.dslreasoner.ui.outline
5
6/**
7 * Customization of the default outline structure.
8 *
9 * see http://www.eclipse.org/Xtext/documentation.html#outline
10 */
11class AlloyLanguageOutlineTreeProvider extends org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider {
12
13}
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/quickfix/AlloyLanguageQuickfixProvider.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/quickfix/AlloyLanguageQuickfixProvider.xtend
new file mode 100644
index 00000000..3e329e62
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src/hu/bme/mit/inf/dslreasoner/ui/quickfix/AlloyLanguageQuickfixProvider.xtend
@@ -0,0 +1,26 @@
1/*
2* generated by Xtext
3*/
4package hu.bme.mit.inf.dslreasoner.ui.quickfix
5
6//import org.eclipse.xtext.ui.editor.quickfix.Fix
7//import org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor
8//import org.eclipse.xtext.validation.Issue
9
10/**
11 * Custom quickfixes.
12 *
13 * see http://www.eclipse.org/Xtext/documentation.html#quickfixes
14 */
15class AlloyLanguageQuickfixProvider extends org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider {
16
17// @Fix(MyDslValidator::INVALID_NAME)
18// def capitalizeName(Issue issue, IssueResolutionAcceptor acceptor) {
19// acceptor.accept(issue, 'Capitalize name', 'Capitalize the name.', 'upcase.png') [
20// context |
21// val xtextDocument = context.xtextDocument
22// val firstLetter = xtextDocument.get(issue.offset, 1)
23// xtextDocument.replace(issue.offset, 1, firstLetter.toUpperCase)
24// ]
25// }
26}
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.classpath b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.classpath
new file mode 100644
index 00000000..5c568755
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.classpath
@@ -0,0 +1,9 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<classpath>
3 <classpathentry kind="src" path="src"/>
4 <classpathentry kind="src" path="src-gen"/>
5 <classpathentry kind="src" path="xtend-gen"/>
6 <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
7 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
8 <classpathentry kind="output" path="bin"/>
9</classpath>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.gitignore b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.gitignore
new file mode 100644
index 00000000..8ae4e44d
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.gitignore
@@ -0,0 +1,4 @@
1/bin/
2/src-gen/
3/vql-gen/
4/xtend-gen/
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.launch/Generate Language Infrastructure (hu.bme.mit.inf.dslreasoner.alloy.language).launch b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.launch/Generate Language Infrastructure (hu.bme.mit.inf.dslreasoner.alloy.language).launch
new file mode 100644
index 00000000..77031bf1
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.launch/Generate Language Infrastructure (hu.bme.mit.inf.dslreasoner.alloy.language).launch
@@ -0,0 +1,18 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<launchConfiguration type="org.eclipse.emf.mwe2.launch.Mwe2LaunchConfigurationType">
3<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; id=&quot;1299248699643_13&quot; label=&quot;working set&quot; name=&quot;working set&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/hu.bme.mit.inf.dslreasoner.alloy.language&quot; type=&quot;4&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/hu.bme.mit.inf.dslreasoner.alloy.language.generator&quot; type=&quot;4&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/hu.bme.mit.inf.dslreasoner.alloy.language.tests&quot; type=&quot;4&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/hu.bme.mit.inf.dslreasoner.alloy.language.ui&quot; type=&quot;4&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
4<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
5<listEntry value="/hu.bme.mit.inf.dslreasoner.alloy.language"/>
6</listAttribute>
7<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
8<listEntry value="4"/>
9</listAttribute>
10<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
11<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
12<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
13</listAttribute>
14<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher"/>
15<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="src/hu/bme/mit/inf/dslreasoner/GenerateAlloyLanguage.mwe2"/>
16<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="hu.bme.mit.inf.dslreasoner.alloy.language"/>
17<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m"/>
18</launchConfiguration>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.project b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.project
new file mode 100644
index 00000000..d33a2394
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.project
@@ -0,0 +1,34 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<projectDescription>
3 <name>hu.bme.mit.inf.dslreasoner.alloy.language</name>
4 <comment></comment>
5 <projects>
6 </projects>
7 <buildSpec>
8 <buildCommand>
9 <name>org.eclipse.jdt.core.javabuilder</name>
10 <arguments>
11 </arguments>
12 </buildCommand>
13 <buildCommand>
14 <name>org.eclipse.pde.ManifestBuilder</name>
15 <arguments>
16 </arguments>
17 </buildCommand>
18 <buildCommand>
19 <name>org.eclipse.pde.SchemaBuilder</name>
20 <arguments>
21 </arguments>
22 </buildCommand>
23 <buildCommand>
24 <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
25 <arguments>
26 </arguments>
27 </buildCommand>
28 </buildSpec>
29 <natures>
30 <nature>org.eclipse.jdt.core.javanature</nature>
31 <nature>org.eclipse.pde.PluginNature</nature>
32 <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
33 </natures>
34</projectDescription>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.settings/org.eclipse.core.resources.prefs b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..4824b802
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
1eclipse.preferences.version=1
2encoding/<project>=UTF-8
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.settings/org.eclipse.jdt.core.prefs b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..ace45cee
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
1eclipse.preferences.version=1
2org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
4org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
5org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6org.eclipse.jdt.core.compiler.compliance=1.8
7org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8org.eclipse.jdt.core.compiler.debug.localVariable=generate
9org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12org.eclipse.jdt.core.compiler.source=1.8
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/META-INF/MANIFEST.MF b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..1de8b744
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/META-INF/MANIFEST.MF
@@ -0,0 +1,37 @@
1Manifest-Version: 1.0
2Bundle-ManifestVersion: 2
3Bundle-Name: hu.bme.mit.inf.dslreasoner.alloy.language
4Bundle-Vendor: My Company
5Bundle-Version: 1.0.0.qualifier
6Bundle-SymbolicName: hu.bme.mit.inf.dslreasoner.alloy.language; singleton:=true
7Bundle-ActivationPolicy: lazy
8Require-Bundle: org.eclipse.xtext;visibility:=reexport,
9 org.eclipse.xtext.xbase;resolution:=optional;visibility:=reexport,
10 org.eclipse.xtext.generator;resolution:=optional,
11 org.apache.commons.logging;bundle-version="1.0.4";resolution:=optional,
12 org.eclipse.emf.codegen.ecore;resolution:=optional,
13 org.eclipse.emf.mwe.utils;resolution:=optional,
14 org.eclipse.emf.mwe2.launch;resolution:=optional,
15 org.eclipse.xtext.util,
16 org.eclipse.emf.ecore,
17 org.eclipse.emf.common,
18 org.eclipse.xtext.xbase.lib,
19 org.antlr.runtime,
20 org.eclipse.xtext.common.types,
21 org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional,
22 org.eclipse.equinox.common;bundle-version="3.7.0"
23Import-Package: org.apache.log4j
24Bundle-RequiredExecutionEnvironment: JavaSE-1.7
25Export-Package: hu.bme.mit.inf.dslreasoner,
26 hu.bme.mit.inf.dslreasoner.services,
27 hu.bme.mit.inf.dslreasoner.alloyLanguage,
28 hu.bme.mit.inf.dslreasoner.alloyLanguage.impl,
29 hu.bme.mit.inf.dslreasoner.alloyLanguage.util,
30 hu.bme.mit.inf.dslreasoner.serializer,
31 hu.bme.mit.inf.dslreasoner.parser.antlr,
32 hu.bme.mit.inf.dslreasoner.parser.antlr.internal,
33 hu.bme.mit.inf.dslreasoner.validation,
34 hu.bme.mit.inf.dslreasoner.scoping,
35 hu.bme.mit.inf.dslreasoner.generator,
36 hu.bme.mit.inf.dslreasoner.formatting
37
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/build.properties b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/build.properties
new file mode 100644
index 00000000..07a42688
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/build.properties
@@ -0,0 +1,7 @@
1source.. = src/,\
2 src-gen/,\
3 xtend-gen/
4bin.includes = model/,\
5 META-INF/,\
6 .,\
7 plugin.xml \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/model/generated/AlloyLanguage.ecore b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/model/generated/AlloyLanguage.ecore
new file mode 100644
index 00000000..a825966e
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/model/generated/AlloyLanguage.ecore
@@ -0,0 +1,267 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="alloyLanguage" nsURI="http://www.bme.hu/mit/inf/dslreasoner/AlloyLanguage"
4 nsPrefix="alloyLanguage">
5 <eClassifiers xsi:type="ecore:EClass" name="ALSDocument">
6 <eStructuralFeatures xsi:type="ecore:EReference" name="enumDeclarations" upperBound="-1"
7 eType="#//ALSEnumDeclaration" containment="true"/>
8 <eStructuralFeatures xsi:type="ecore:EReference" name="signatureBodies" upperBound="-1"
9 eType="#//ALSSignatureBody" containment="true"/>
10 <eStructuralFeatures xsi:type="ecore:EReference" name="functionDefinitions" upperBound="-1"
11 eType="#//ALSFunctionDefinition" containment="true"/>
12 <eStructuralFeatures xsi:type="ecore:EReference" name="relationDefinitions" upperBound="-1"
13 eType="#//ALSRelationDefinition" containment="true"/>
14 <eStructuralFeatures xsi:type="ecore:EReference" name="factDeclarations" upperBound="-1"
15 eType="#//ALSFactDeclaration" containment="true"/>
16 <eStructuralFeatures xsi:type="ecore:EReference" name="runCommand" eType="#//ALSRunCommand"
17 containment="true"/>
18 </eClassifiers>
19 <eClassifiers xsi:type="ecore:EEnum" name="ALSMultiplicity">
20 <eLiterals name="all" literal="all"/>
21 <eLiterals name="no" value="1" literal="no"/>
22 <eLiterals name="some" value="2" literal="some"/>
23 <eLiterals name="lone" value="3" literal="lone"/>
24 <eLiterals name="one" value="4" literal="one"/>
25 <eLiterals name="set" value="5" literal="set"/>
26 </eClassifiers>
27 <eClassifiers xsi:type="ecore:EClass" name="ALSRelationDeclaration">
28 <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
29 </eClassifiers>
30 <eClassifiers xsi:type="ecore:EClass" name="ALSTypeDeclaration" eSuperTypes="#//ALSRelationDeclaration"/>
31 <eClassifiers xsi:type="ecore:EClass" name="ALSEnumDeclaration" eSuperTypes="#//ALSTypeDeclaration">
32 <eStructuralFeatures xsi:type="ecore:EReference" name="literal" upperBound="-1"
33 eType="#//ALSEnumLiteral" containment="true"/>
34 </eClassifiers>
35 <eClassifiers xsi:type="ecore:EClass" name="ALSEnumLiteral" eSuperTypes="#//ALSRelationDeclaration"/>
36 <eClassifiers xsi:type="ecore:EClass" name="ALSSignatureDeclaration" eSuperTypes="#//ALSTypeDeclaration"/>
37 <eClassifiers xsi:type="ecore:EClass" name="ALSSignatureBody">
38 <eStructuralFeatures xsi:type="ecore:EAttribute" name="multiplicity" eType="#//ALSMultiplicity"/>
39 <eStructuralFeatures xsi:type="ecore:EAttribute" name="abstract" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
40 <eStructuralFeatures xsi:type="ecore:EReference" name="declarations" upperBound="-1"
41 eType="#//ALSSignatureDeclaration" containment="true"/>
42 <eStructuralFeatures xsi:type="ecore:EReference" name="supertype" eType="#//ALSSignatureDeclaration"/>
43 <eStructuralFeatures xsi:type="ecore:EReference" name="superset" unique="false"
44 upperBound="-1" eType="#//ALSSignatureDeclaration"/>
45 <eStructuralFeatures xsi:type="ecore:EReference" name="fields" upperBound="-1"
46 eType="#//ALSFieldDeclaration" containment="true"/>
47 </eClassifiers>
48 <eClassifiers xsi:type="ecore:EClass" name="ALSFieldDeclaration" eSuperTypes="#//ALSRelationDeclaration">
49 <eStructuralFeatures xsi:type="ecore:EAttribute" name="multiplicity" eType="#//ALSMultiplicity"/>
50 <eStructuralFeatures xsi:type="ecore:EReference" name="type" eType="#//ALSTerm"
51 containment="true"/>
52 </eClassifiers>
53 <eClassifiers xsi:type="ecore:EClass" name="ALSDefinition">
54 <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
55 <eStructuralFeatures xsi:type="ecore:EReference" name="variables" upperBound="-1"
56 eType="#//ALSVariableDeclaration" containment="true"/>
57 <eStructuralFeatures xsi:type="ecore:EReference" name="value" eType="#//ALSTerm"
58 containment="true"/>
59 </eClassifiers>
60 <eClassifiers xsi:type="ecore:EClass" name="ALSFunctionDefinition" eSuperTypes="#//ALSDefinition">
61 <eStructuralFeatures xsi:type="ecore:EReference" name="type" eType="#//ALSTerm"
62 containment="true"/>
63 </eClassifiers>
64 <eClassifiers xsi:type="ecore:EClass" name="ALSRelationDefinition" eSuperTypes="#//ALSDefinition"/>
65 <eClassifiers xsi:type="ecore:EClass" name="ALSFactDeclaration">
66 <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
67 <eStructuralFeatures xsi:type="ecore:EReference" name="term" eType="#//ALSTerm"
68 containment="true"/>
69 </eClassifiers>
70 <eClassifiers xsi:type="ecore:EClass" name="ALSTerm"/>
71 <eClassifiers xsi:type="ecore:EEnum" name="ALSNumericOperator">
72 <eLiterals name="plus" literal="plus"/>
73 <eLiterals name="sub" value="1" literal="sub"/>
74 <eLiterals name="mul" value="2" literal="mul"/>
75 <eLiterals name="rem" value="3" literal="rem"/>
76 <eLiterals name="div" value="4" literal="div"/>
77 </eClassifiers>
78 <eClassifiers xsi:type="ecore:EClass" name="ALSVariableDeclaration" eSuperTypes="#//ALSRelationDeclaration">
79 <eStructuralFeatures xsi:type="ecore:EReference" name="range" eType="#//ALSTerm"
80 containment="true"/>
81 </eClassifiers>
82 <eClassifiers xsi:type="ecore:EClass" name="ALSRunCommand">
83 <eStructuralFeatures xsi:type="ecore:EReference" name="typeScopes" upperBound="-1"
84 eType="#//ALSTypeScope" containment="true"/>
85 </eClassifiers>
86 <eClassifiers xsi:type="ecore:EClass" name="ALSTypeScope">
87 <eStructuralFeatures xsi:type="ecore:EAttribute" name="number" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
88 </eClassifiers>
89 <eClassifiers xsi:type="ecore:EClass" name="ALSSigScope" eSuperTypes="#//ALSTypeScope">
90 <eStructuralFeatures xsi:type="ecore:EAttribute" name="exactly" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
91 <eStructuralFeatures xsi:type="ecore:EReference" name="type" eType="#//ALSSignatureDeclaration"/>
92 </eClassifiers>
93 <eClassifiers xsi:type="ecore:EClass" name="ALSIntScope" eSuperTypes="#//ALSTypeScope"/>
94 <eClassifiers xsi:type="ecore:EClass" name="ALSQuantifiedEx" eSuperTypes="#//ALSTerm">
95 <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="#//ALSMultiplicity"/>
96 <eStructuralFeatures xsi:type="ecore:EAttribute" name="disj" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
97 <eStructuralFeatures xsi:type="ecore:EReference" name="variables" upperBound="-1"
98 eType="#//ALSVariableDeclaration" containment="true"/>
99 <eStructuralFeatures xsi:type="ecore:EReference" name="expression" eType="#//ALSTerm"
100 containment="true"/>
101 </eClassifiers>
102 <eClassifiers xsi:type="ecore:EClass" name="ALSOr" eSuperTypes="#//ALSTerm">
103 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
104 containment="true"/>
105 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
106 containment="true"/>
107 </eClassifiers>
108 <eClassifiers xsi:type="ecore:EClass" name="ALSIff" eSuperTypes="#//ALSTerm">
109 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
110 containment="true"/>
111 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
112 containment="true"/>
113 </eClassifiers>
114 <eClassifiers xsi:type="ecore:EClass" name="ALSImpl" eSuperTypes="#//ALSTerm">
115 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
116 containment="true"/>
117 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
118 containment="true"/>
119 <eStructuralFeatures xsi:type="ecore:EReference" name="elseOperand" eType="#//ALSTerm"
120 containment="true"/>
121 </eClassifiers>
122 <eClassifiers xsi:type="ecore:EClass" name="ALSAnd" eSuperTypes="#//ALSTerm">
123 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
124 containment="true"/>
125 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
126 containment="true"/>
127 </eClassifiers>
128 <eClassifiers xsi:type="ecore:EClass" name="ALSEquals" eSuperTypes="#//ALSTerm">
129 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
130 containment="true"/>
131 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
132 containment="true"/>
133 </eClassifiers>
134 <eClassifiers xsi:type="ecore:EClass" name="ALSNotEquals" eSuperTypes="#//ALSTerm">
135 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
136 containment="true"/>
137 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
138 containment="true"/>
139 </eClassifiers>
140 <eClassifiers xsi:type="ecore:EClass" name="ALSSubset" eSuperTypes="#//ALSTerm">
141 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
142 containment="true"/>
143 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
144 containment="true"/>
145 </eClassifiers>
146 <eClassifiers xsi:type="ecore:EClass" name="ALSLess" eSuperTypes="#//ALSTerm">
147 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
148 containment="true"/>
149 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
150 containment="true"/>
151 </eClassifiers>
152 <eClassifiers xsi:type="ecore:EClass" name="ALSLeq" eSuperTypes="#//ALSTerm">
153 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
154 containment="true"/>
155 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
156 containment="true"/>
157 </eClassifiers>
158 <eClassifiers xsi:type="ecore:EClass" name="ALSMore" eSuperTypes="#//ALSTerm">
159 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
160 containment="true"/>
161 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
162 containment="true"/>
163 </eClassifiers>
164 <eClassifiers xsi:type="ecore:EClass" name="ALSMeq" eSuperTypes="#//ALSTerm">
165 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
166 containment="true"/>
167 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
168 containment="true"/>
169 </eClassifiers>
170 <eClassifiers xsi:type="ecore:EClass" name="ALSOverride" eSuperTypes="#//ALSTerm">
171 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
172 containment="true"/>
173 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
174 containment="true"/>
175 </eClassifiers>
176 <eClassifiers xsi:type="ecore:EClass" name="ALSRangeRestrictionRight" eSuperTypes="#//ALSTerm">
177 <eStructuralFeatures xsi:type="ecore:EReference" name="relation" eType="#//ALSTerm"
178 containment="true"/>
179 <eStructuralFeatures xsi:type="ecore:EReference" name="filter" eType="#//ALSTerm"
180 containment="true"/>
181 </eClassifiers>
182 <eClassifiers xsi:type="ecore:EClass" name="ALSRangeRestrictionLeft" eSuperTypes="#//ALSTerm">
183 <eStructuralFeatures xsi:type="ecore:EReference" name="filter" eType="#//ALSTerm"
184 containment="true"/>
185 <eStructuralFeatures xsi:type="ecore:EReference" name="relation" eType="#//ALSTerm"
186 containment="true"/>
187 </eClassifiers>
188 <eClassifiers xsi:type="ecore:EClass" name="ALSJoin" eSuperTypes="#//ALSTerm">
189 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
190 containment="true"/>
191 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
192 containment="true"/>
193 </eClassifiers>
194 <eClassifiers xsi:type="ecore:EClass" name="ALSMinus" eSuperTypes="#//ALSTerm">
195 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
196 containment="true"/>
197 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
198 containment="true"/>
199 </eClassifiers>
200 <eClassifiers xsi:type="ecore:EClass" name="ALSPlus" eSuperTypes="#//ALSTerm">
201 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
202 containment="true"/>
203 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
204 containment="true"/>
205 </eClassifiers>
206 <eClassifiers xsi:type="ecore:EClass" name="ALSIntersection" eSuperTypes="#//ALSTerm">
207 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
208 containment="true"/>
209 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
210 containment="true"/>
211 </eClassifiers>
212 <eClassifiers xsi:type="ecore:EClass" name="ALSDirectProduct" eSuperTypes="#//ALSTerm">
213 <eStructuralFeatures xsi:type="ecore:EReference" name="leftOperand" eType="#//ALSTerm"
214 containment="true"/>
215 <eStructuralFeatures xsi:type="ecore:EAttribute" name="leftMultiplicit" eType="#//ALSMultiplicity"/>
216 <eStructuralFeatures xsi:type="ecore:EAttribute" name="rightMultiplicit" eType="#//ALSMultiplicity"/>
217 <eStructuralFeatures xsi:type="ecore:EReference" name="rightOperand" eType="#//ALSTerm"
218 containment="true"/>
219 </eClassifiers>
220 <eClassifiers xsi:type="ecore:EClass" name="ALSNot" eSuperTypes="#//ALSTerm">
221 <eStructuralFeatures xsi:type="ecore:EReference" name="operand" eType="#//ALSTerm"
222 containment="true"/>
223 </eClassifiers>
224 <eClassifiers xsi:type="ecore:EClass" name="ALSInverseRelation" eSuperTypes="#//ALSTerm">
225 <eStructuralFeatures xsi:type="ecore:EReference" name="operand" eType="#//ALSTerm"
226 containment="true"/>
227 </eClassifiers>
228 <eClassifiers xsi:type="ecore:EClass" name="AlSTransitiveClosure" eSuperTypes="#//ALSTerm">
229 <eStructuralFeatures xsi:type="ecore:EReference" name="operand" eType="#//ALSTerm"
230 containment="true"/>
231 </eClassifiers>
232 <eClassifiers xsi:type="ecore:EClass" name="ALSReflectiveTransitiveClosure" eSuperTypes="#//ALSTerm">
233 <eStructuralFeatures xsi:type="ecore:EReference" name="operand" eType="#//ALSTerm"
234 containment="true"/>
235 </eClassifiers>
236 <eClassifiers xsi:type="ecore:EClass" name="ALSCardinality" eSuperTypes="#//ALSTerm">
237 <eStructuralFeatures xsi:type="ecore:EReference" name="operand" eType="#//ALSTerm"
238 containment="true"/>
239 </eClassifiers>
240 <eClassifiers xsi:type="ecore:EClass" name="ALSUnaryMinus" eSuperTypes="#//ALSTerm">
241 <eStructuralFeatures xsi:type="ecore:EReference" name="operand" eType="#//ALSTerm"
242 containment="true"/>
243 </eClassifiers>
244 <eClassifiers xsi:type="ecore:EClass" name="ALSSum" eSuperTypes="#//ALSTerm">
245 <eStructuralFeatures xsi:type="ecore:EReference" name="variables" upperBound="-1"
246 eType="#//ALSVariableDeclaration" containment="true"/>
247 <eStructuralFeatures xsi:type="ecore:EReference" name="expression" eType="#//ALSTerm"
248 containment="true"/>
249 </eClassifiers>
250 <eClassifiers xsi:type="ecore:EClass" name="ALSFunctionCall" eSuperTypes="#//ALSTerm">
251 <eStructuralFeatures xsi:type="ecore:EReference" name="referredDefinition" eType="#//ALSDefinition"/>
252 <eStructuralFeatures xsi:type="ecore:EAttribute" name="referredNumericOperator"
253 eType="#//ALSNumericOperator"/>
254 <eStructuralFeatures xsi:type="ecore:EReference" name="params" upperBound="-1"
255 eType="#//ALSTerm" containment="true"/>
256 </eClassifiers>
257 <eClassifiers xsi:type="ecore:EClass" name="ALSNone" eSuperTypes="#//ALSTerm"/>
258 <eClassifiers xsi:type="ecore:EClass" name="ALSIden" eSuperTypes="#//ALSTerm"/>
259 <eClassifiers xsi:type="ecore:EClass" name="ALSUniv" eSuperTypes="#//ALSTerm"/>
260 <eClassifiers xsi:type="ecore:EClass" name="ALSInt" eSuperTypes="#//ALSTerm"/>
261 <eClassifiers xsi:type="ecore:EClass" name="ALSReference" eSuperTypes="#//ALSTerm">
262 <eStructuralFeatures xsi:type="ecore:EReference" name="referred" eType="#//ALSRelationDeclaration"/>
263 </eClassifiers>
264 <eClassifiers xsi:type="ecore:EClass" name="ALSNumberLiteral" eSuperTypes="#//ALSTerm">
265 <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
266 </eClassifiers>
267</ecore:EPackage>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/model/generated/AlloyLanguage.genmodel b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/model/generated/AlloyLanguage.genmodel
new file mode 100644
index 00000000..dd1d46d2
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/model/generated/AlloyLanguage.genmodel
@@ -0,0 +1,206 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
3 xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/hu.bme.mit.inf.dslreasoner.alloy.language/src-gen"
4 editDirectory="/hu.bme.mit.inf.dslreasoner.alloy.language.edit/src" editorDirectory="/hu.bme.mit.inf.dslreasoner.alloy.language.editor/src"
5 modelPluginID="hu.bme.mit.inf.dslreasoner.alloy.language" forceOverwrite="true"
6 modelName="AlloyLanguage" updateClasspath="false" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container"
7 complianceLevel="6.0" copyrightFields="false" editPluginID="hu.bme.mit.inf.dslreasoner.alloy.language.edit"
8 editorPluginID="hu.bme.mit.inf.dslreasoner.alloy.language.editor" runtimeVersion="2.11">
9 <genPackages prefix="AlloyLanguage" basePackage="hu.bme.mit.inf.dslreasoner" disposableProviderFactory="true"
10 fileExtensions="als" ecorePackage="AlloyLanguage.ecore#/">
11 <genEnums typeSafeEnumCompatible="false" ecoreEnum="AlloyLanguage.ecore#//ALSMultiplicity">
12 <genEnumLiterals ecoreEnumLiteral="AlloyLanguage.ecore#//ALSMultiplicity/all"/>
13 <genEnumLiterals ecoreEnumLiteral="AlloyLanguage.ecore#//ALSMultiplicity/no"/>
14 <genEnumLiterals ecoreEnumLiteral="AlloyLanguage.ecore#//ALSMultiplicity/some"/>
15 <genEnumLiterals ecoreEnumLiteral="AlloyLanguage.ecore#//ALSMultiplicity/lone"/>
16 <genEnumLiterals ecoreEnumLiteral="AlloyLanguage.ecore#//ALSMultiplicity/one"/>
17 <genEnumLiterals ecoreEnumLiteral="AlloyLanguage.ecore#//ALSMultiplicity/set"/>
18 </genEnums>
19 <genEnums typeSafeEnumCompatible="false" ecoreEnum="AlloyLanguage.ecore#//ALSNumericOperator">
20 <genEnumLiterals ecoreEnumLiteral="AlloyLanguage.ecore#//ALSNumericOperator/plus"/>
21 <genEnumLiterals ecoreEnumLiteral="AlloyLanguage.ecore#//ALSNumericOperator/sub"/>
22 <genEnumLiterals ecoreEnumLiteral="AlloyLanguage.ecore#//ALSNumericOperator/mul"/>
23 <genEnumLiterals ecoreEnumLiteral="AlloyLanguage.ecore#//ALSNumericOperator/rem"/>
24 <genEnumLiterals ecoreEnumLiteral="AlloyLanguage.ecore#//ALSNumericOperator/div"/>
25 </genEnums>
26 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSDocument">
27 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSDocument/enumDeclarations"/>
28 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSDocument/signatureBodies"/>
29 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSDocument/functionDefinitions"/>
30 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSDocument/relationDefinitions"/>
31 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSDocument/factDeclarations"/>
32 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSDocument/runCommand"/>
33 </genClasses>
34 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSRelationDeclaration">
35 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSRelationDeclaration/name"/>
36 </genClasses>
37 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSTypeDeclaration"/>
38 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSEnumDeclaration">
39 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSEnumDeclaration/literal"/>
40 </genClasses>
41 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSEnumLiteral"/>
42 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSSignatureDeclaration"/>
43 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSSignatureBody">
44 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSSignatureBody/multiplicity"/>
45 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSSignatureBody/abstract"/>
46 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSSignatureBody/declarations"/>
47 <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSSignatureBody/supertype"/>
48 <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSSignatureBody/superset"/>
49 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSSignatureBody/fields"/>
50 </genClasses>
51 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSFieldDeclaration">
52 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSFieldDeclaration/multiplicity"/>
53 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSFieldDeclaration/type"/>
54 </genClasses>
55 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSDefinition">
56 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSDefinition/name"/>
57 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSDefinition/variables"/>
58 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSDefinition/value"/>
59 </genClasses>
60 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSFunctionDefinition">
61 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSFunctionDefinition/type"/>
62 </genClasses>
63 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSRelationDefinition"/>
64 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSFactDeclaration">
65 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSFactDeclaration/name"/>
66 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSFactDeclaration/term"/>
67 </genClasses>
68 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSTerm"/>
69 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSVariableDeclaration">
70 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSVariableDeclaration/range"/>
71 </genClasses>
72 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSRunCommand">
73 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSRunCommand/typeScopes"/>
74 </genClasses>
75 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSTypeScope">
76 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSTypeScope/number"/>
77 </genClasses>
78 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSSigScope">
79 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSSigScope/exactly"/>
80 <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSSigScope/type"/>
81 </genClasses>
82 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSIntScope"/>
83 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSQuantifiedEx">
84 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSQuantifiedEx/type"/>
85 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSQuantifiedEx/disj"/>
86 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSQuantifiedEx/variables"/>
87 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSQuantifiedEx/expression"/>
88 </genClasses>
89 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSOr">
90 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSOr/leftOperand"/>
91 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSOr/rightOperand"/>
92 </genClasses>
93 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSIff">
94 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSIff/leftOperand"/>
95 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSIff/rightOperand"/>
96 </genClasses>
97 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSImpl">
98 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSImpl/leftOperand"/>
99 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSImpl/rightOperand"/>
100 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSImpl/elseOperand"/>
101 </genClasses>
102 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSAnd">
103 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSAnd/leftOperand"/>
104 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSAnd/rightOperand"/>
105 </genClasses>
106 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSEquals">
107 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSEquals/leftOperand"/>
108 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSEquals/rightOperand"/>
109 </genClasses>
110 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSNotEquals">
111 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSNotEquals/leftOperand"/>
112 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSNotEquals/rightOperand"/>
113 </genClasses>
114 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSSubset">
115 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSSubset/leftOperand"/>
116 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSSubset/rightOperand"/>
117 </genClasses>
118 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSLess">
119 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSLess/leftOperand"/>
120 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSLess/rightOperand"/>
121 </genClasses>
122 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSLeq">
123 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSLeq/leftOperand"/>
124 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSLeq/rightOperand"/>
125 </genClasses>
126 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSMore">
127 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSMore/leftOperand"/>
128 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSMore/rightOperand"/>
129 </genClasses>
130 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSMeq">
131 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSMeq/leftOperand"/>
132 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSMeq/rightOperand"/>
133 </genClasses>
134 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSOverride">
135 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSOverride/leftOperand"/>
136 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSOverride/rightOperand"/>
137 </genClasses>
138 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSRangeRestrictionRight">
139 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSRangeRestrictionRight/relation"/>
140 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSRangeRestrictionRight/filter"/>
141 </genClasses>
142 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSRangeRestrictionLeft">
143 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSRangeRestrictionLeft/filter"/>
144 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSRangeRestrictionLeft/relation"/>
145 </genClasses>
146 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSJoin">
147 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSJoin/leftOperand"/>
148 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSJoin/rightOperand"/>
149 </genClasses>
150 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSMinus">
151 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSMinus/leftOperand"/>
152 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSMinus/rightOperand"/>
153 </genClasses>
154 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSPlus">
155 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSPlus/leftOperand"/>
156 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSPlus/rightOperand"/>
157 </genClasses>
158 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSIntersection">
159 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSIntersection/leftOperand"/>
160 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSIntersection/rightOperand"/>
161 </genClasses>
162 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSDirectProduct">
163 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSDirectProduct/leftOperand"/>
164 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSDirectProduct/leftMultiplicit"/>
165 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSDirectProduct/rightMultiplicit"/>
166 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSDirectProduct/rightOperand"/>
167 </genClasses>
168 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSNot">
169 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSNot/operand"/>
170 </genClasses>
171 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSInverseRelation">
172 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSInverseRelation/operand"/>
173 </genClasses>
174 <genClasses ecoreClass="AlloyLanguage.ecore#//AlSTransitiveClosure">
175 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//AlSTransitiveClosure/operand"/>
176 </genClasses>
177 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSReflectiveTransitiveClosure">
178 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSReflectiveTransitiveClosure/operand"/>
179 </genClasses>
180 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSCardinality">
181 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSCardinality/operand"/>
182 </genClasses>
183 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSUnaryMinus">
184 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSUnaryMinus/operand"/>
185 </genClasses>
186 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSSum">
187 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSSum/variables"/>
188 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSSum/expression"/>
189 </genClasses>
190 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSFunctionCall">
191 <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSFunctionCall/referredDefinition"/>
192 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSFunctionCall/referredNumericOperator"/>
193 <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSFunctionCall/params"/>
194 </genClasses>
195 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSNone"/>
196 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSIden"/>
197 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSUniv"/>
198 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSInt"/>
199 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSReference">
200 <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference AlloyLanguage.ecore#//ALSReference/referred"/>
201 </genClasses>
202 <genClasses ecoreClass="AlloyLanguage.ecore#//ALSNumberLiteral">
203 <genFeatures createChild="false" ecoreFeature="ecore:EAttribute AlloyLanguage.ecore#//ALSNumberLiteral/value"/>
204 </genClasses>
205 </genPackages>
206</genmodel:GenModel>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/plugin.xml b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/plugin.xml
new file mode 100644
index 00000000..7567279d
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/plugin.xml
@@ -0,0 +1,16 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<?eclipse version="3.0"?>
3
4<plugin>
5
6 <extension point="org.eclipse.emf.ecore.generated_package">
7 <package
8 uri = "http://www.bme.hu/mit/inf/dslreasoner/AlloyLanguage"
9 class = "hu.bme.mit.inf.dslreasoner.alloyLanguage.AlloyLanguagePackage"
10 genModel = "model/generated/AlloyLanguage.genmodel" />
11
12 </extension>
13
14
15
16</plugin>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/plugin.xml_gen b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/plugin.xml_gen
new file mode 100644
index 00000000..7567279d
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/plugin.xml_gen
@@ -0,0 +1,16 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<?eclipse version="3.0"?>
3
4<plugin>
5
6 <extension point="org.eclipse.emf.ecore.generated_package">
7 <package
8 uri = "http://www.bme.hu/mit/inf/dslreasoner/AlloyLanguage"
9 class = "hu.bme.mit.inf.dslreasoner.alloyLanguage.AlloyLanguagePackage"
10 genModel = "model/generated/AlloyLanguage.genmodel" />
11
12 </extension>
13
14
15
16</plugin>
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/AlloyLanguage.xtext b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/AlloyLanguage.xtext
new file mode 100644
index 00000000..6d5fcf58
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/AlloyLanguage.xtext
@@ -0,0 +1,149 @@
1grammar hu.bme.mit.inf.dslreasoner.AlloyLanguage with org.eclipse.xtext.common.Terminals
2
3generate alloyLanguage "http://www.bme.hu/mit/inf/dslreasoner/AlloyLanguage"
4
5ALSDocument:
6 ( enumDeclarations += ALSEnumDeclaration |
7 signatureBodies += ALSSignatureBody |
8 functionDefinitions += ALSFunctionDefinition |
9 relationDefinitions += ALSRelationDefinition |
10 factDeclarations += ALSFactDeclaration)+
11 runCommand = ALSRunCommand
12;
13
14//////////////////////////////////
15// ALS terminals
16//////////////////////////////////
17
18terminal ID: ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|"'"|'"'|'0'..'9')*;
19ALSID: ID;
20
21enum ALSMultiplicity: all | no | some | lone | one | set;
22
23
24//////////////////////////////////
25// ALS types
26//////////////////////////////////
27
28ALSRelationDeclaration: ALSTypeDeclaration | ALSEnumLiteral | ALSFieldDeclaration | ALSVariableDeclaration;
29
30ALSTypeDeclaration:
31 ALSEnumDeclaration | ALSSignatureDeclaration
32;
33
34ALSEnumDeclaration:
35 'enum' name=ALSID '{'
36 literal+=ALSEnumLiteral ("," literal+=ALSEnumLiteral)*
37 '}';
38ALSEnumLiteral: name = ALSID;
39
40ALSSignatureDeclaration: name = ALSID;
41
42ALSSignatureBody:
43 ((multiplicity = ALSMultiplicity?) & (abstract ?= 'abstract')?)
44 'sig'
45 declarations += ALSSignatureDeclaration (',' declarations += ALSSignatureDeclaration)*
46 (('extends' supertype = [ALSSignatureDeclaration])
47 |
48 ('in' superset += [ALSSignatureDeclaration] ('+' superset += [ALSSignatureDeclaration])*) )?
49 '{' (fields+=ALSFieldDeclaration ("," fields+=ALSFieldDeclaration)*)? '}'
50;
51
52ALSFieldDeclaration:
53 name = ALSID ':' (multiplicity = ALSMultiplicity)? type = ALSTerm
54;
55
56ALSDefinition : ALSFunctionDefinition | ALSRelationDefinition;
57
58ALSFunctionDefinition:
59 "fun" name = ALSID "[" variables+=ALSVariableDeclaration (',' variables+=ALSVariableDeclaration)* "]" ":" type = ALSTerm
60 "{" value = ALSTerm "}"
61;
62ALSRelationDefinition:
63 "pred" name = ALSID "[" variables+=ALSVariableDeclaration (',' variables+=ALSVariableDeclaration)* "]"
64 "{" value = ALSTerm "}"
65;
66
67ALSFactDeclaration: {ALSFactDeclaration} 'fact' (name=ALSID)? '{' (term = ALSTerm) '}' ;
68
69//////////////////////////////////
70// ALS terms
71//////////////////////////////////
72ALSTerm: ALSQuantified;
73
74ALSQuantified returns ALSTerm: ({ALSQuantifiedEx} type = ALSMultiplicity
75 (disj?='disj')? variables+=ALSVariableDeclaration (',' variables+=ALSVariableDeclaration)* '{' expression = ALSTerm '}') | ALSOr;
76
77ALSOr returns ALSTerm: ALSIff ({ALSOr.leftOperand = current} ( "||" | "or" ) rightOperand = ALSIff)?;
78ALSIff returns ALSTerm: ALSImpl ({ALSIff.leftOperand = current} ("<=>" | "iff") rightOperand = ALSImpl)?;
79ALSImpl returns ALSTerm: ALSAnd ({ALSImpl.leftOperand = current} ("=>" | "implies") rightOperand = ALSAnd ('else' elseOperand = ALSAnd)?)?;
80ALSAnd returns ALSTerm: ALSComparison ({ALSAnd.leftOperand = current} ( "&&" | "and" ) rightOperand = ALSComparison)?;
81
82ALSComparison returns ALSTerm:
83 ALSOverride
84 (({ALSEquals.leftOperand = current} "=" |
85 {ALSNotEquals.leftOperand = current} "!=" |
86 {ALSSubset.leftOperand = current} "in" |
87 {ALSLess.leftOperand = current} ">" |
88 {ALSLeq.leftOperand = current} ">=" |
89 {ALSMore.leftOperand = current} "<" |
90 {ALSMeq.leftOperand = current} "<=")
91 rightOperand = ALSOverride)?;
92
93ALSOverride returns ALSTerm: ALSRangeRestrictionRight ({ALSOverride.leftOperand = current} '++' rightOperand = ALSRangeRestrictionRight)?;
94
95ALSRangeRestrictionRight returns ALSTerm: ALSRangeRestrictionLeft ({ALSRangeRestrictionRight.relation = current} ':>' filter = ALSRangeRestrictionLeft)?;
96ALSRangeRestrictionLeft returns ALSTerm: ALSJoin ({ALSRangeRestrictionLeft.filter = current} '<:' relation = ALSJoin)?;
97ALSJoin returns ALSTerm: ALSMinus ({ALSJoin.leftOperand = current} '.' rightOperand = ALSMinus )*;
98
99ALSMinus returns ALSTerm: ALSPlus ({ALSMinus.leftOperand = current} '-' rightOperand = ALSPlus)*;
100ALSPlus returns ALSTerm: ALSIntersection ({ALSPlus.leftOperand = current} '+' rightOperand = ALSIntersection)*;
101ALSIntersection returns ALSTerm: ALSDirectProduct ({ALSIntersection.leftOperand = current} '&' rightOperand = ALSDirectProduct)*;
102//ALSMultiply returns ALSTerm: ALSDirectProduct ({ALSMultiply.leftOperand = current} '*' rightOperand = ALSDirectProduct)*;
103
104ALSDirectProduct returns ALSTerm:
105 ALSPreficed
106 ({ALSDirectProduct.leftOperand = current} (leftMultiplicit = ALSMultiplicity)?
107 '->'
108 (rightMultiplicit = ALSMultiplicity)?
109 rightOperand = ALSPreficed)?
110;
111
112ALSPreficed returns ALSTerm:
113 {ALSNot}=>("!"|'not') operand = ALSBasicRelationTerm |
114 {ALSInverseRelation}=>"~" operand = ALSBasicRelationTerm |
115 {AlSTransitiveClosure} "^" operand = ALSBasicRelationTerm |
116 {ALSReflectiveTransitiveClosure} "*" operand = ALSBasicRelationTerm |
117 {ALSCardinality} '#' operand = ALSBasicRelationTerm |
118 {ALSUnaryMinus} =>'-' operand = ALSBasicRelationTerm |
119 {ALSSum} 'sum' variables+=ALSVariableDeclaration (',' variables+=ALSVariableDeclaration)* '{' expression = ALSTerm '}' |
120// {ALSQuantifiedEx} type = ALSMultiplicity
121// (disj?='disj')? variables+=ALSVariableDeclaration (',' variables+=ALSVariableDeclaration)* '{' expression = ALSTerm '}' |
122 {ALSFunctionCall} (referredDefinition=[ALSDefinition]|referredNumericOperator=ALSNumericOperator) '['params+=ALSTerm (',' params+=ALSTerm)*']' |
123 ALSBasicRelationTerm;
124
125enum ALSNumericOperator: plus|sub|mul|rem|div;
126
127//ALSVariable: name = ALSID;
128ALSVariableDeclaration: name=ALSID ':' range = ALSTerm;
129
130ALSBasicRelationTerm returns ALSTerm:
131 {ALSNone} 'none'|
132 {ALSIden} 'iden'|
133 {ALSUniv} 'univ'|
134 {ALSInt} 'Int' |
135 {ALSReference} referred = [ALSRelationDeclaration] |
136 {ALSNumberLiteral} value = INT|
137 '(' ALSTerm ')'
138;
139
140//////////////////////////////////
141// ALS Commands and scopes
142//////////////////////////////////
143ALSRunCommand:
144 {ALSRunCommand} 'run' '{' '}' ('for' typeScopes+=ALSTypeScope (',' typeScopes+=ALSTypeScope)*)?;
145
146ALSTypeScope: ALSSigScope | ALSIntScope;
147
148ALSSigScope: (exactly?='exactly')? number = INT type = [ALSSignatureDeclaration];
149ALSIntScope: number = INT 'Int'; \ No newline at end of file
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/AlloyLanguageRuntimeModule.java b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/AlloyLanguageRuntimeModule.java
new file mode 100644
index 00000000..b78c88c2
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/AlloyLanguageRuntimeModule.java
@@ -0,0 +1,11 @@
1/*
2 * generated by Xtext
3 */
4package hu.bme.mit.inf.dslreasoner;
5
6/**
7 * Use this class to register components to be used at runtime / without the Equinox extension registry.
8 */
9public class AlloyLanguageRuntimeModule extends hu.bme.mit.inf.dslreasoner.AbstractAlloyLanguageRuntimeModule {
10
11}
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/AlloyLanguageStandaloneSetup.java b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/AlloyLanguageStandaloneSetup.java
new file mode 100644
index 00000000..bb1447eb
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/AlloyLanguageStandaloneSetup.java
@@ -0,0 +1,16 @@
1/*
2* generated by Xtext
3*/
4package hu.bme.mit.inf.dslreasoner;
5
6/**
7 * Initialization support for running Xtext languages
8 * without equinox extension registry
9 */
10public class AlloyLanguageStandaloneSetup extends AlloyLanguageStandaloneSetupGenerated{
11
12 public static void doSetup() {
13 new AlloyLanguageStandaloneSetup().createInjectorAndDoEMFRegistration();
14 }
15}
16
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/GenerateAlloyLanguage.mwe2 b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/GenerateAlloyLanguage.mwe2
new file mode 100644
index 00000000..fa57e2de
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/GenerateAlloyLanguage.mwe2
@@ -0,0 +1,133 @@
1module hu.bme.mit.inf.dslreasoner.GenerateAlloyLanguage
2
3import org.eclipse.emf.mwe.utils.*
4import org.eclipse.xtext.generator.*
5import org.eclipse.xtext.ui.generator.*
6
7var grammarURI = "classpath:/hu/bme/mit/inf/dslreasoner/AlloyLanguage.xtext"
8var fileExtensions = "als"
9var projectName = "hu.bme.mit.inf.dslreasoner.alloy.language"
10var runtimeProject = "../${projectName}"
11var generateXtendStub = true
12var encoding = "UTF-8"
13
14Workflow {
15 bean = StandaloneSetup {
16 scanClassPath = true
17 platformUri = "${runtimeProject}/.."
18 // The following two lines can be removed, if Xbase is not used.
19 registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
20 registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
21 }
22
23 component = DirectoryCleaner {
24 directory = "${runtimeProject}/src-gen"
25 }
26
27 component = DirectoryCleaner {
28 directory = "${runtimeProject}/model/generated"
29 }
30
31 component = DirectoryCleaner {
32 directory = "${runtimeProject}.ui/src-gen"
33 }
34
35// component = DirectoryCleaner {
36// directory = "${runtimeProject}.tests/src-gen"
37// }
38
39 component = Generator {
40 pathRtProject = runtimeProject
41 pathUiProject = "${runtimeProject}.ui"
42 //pathTestProject = "${runtimeProject}.tests"
43 projectNameRt = projectName
44 projectNameUi = "${projectName}.ui"
45 encoding = encoding
46 language = auto-inject {
47 uri = grammarURI
48
49 // Java API to access grammar elements (required by several other fragments)
50 fragment = grammarAccess.GrammarAccessFragment auto-inject {}
51
52 // generates Java API for the generated EPackages
53 fragment = ecore.EMFGeneratorFragment auto-inject {}
54
55 // the old serialization component
56 // fragment = parseTreeConstructor.ParseTreeConstructorFragment auto-inject {}
57
58 // serializer 2.0
59 fragment = serializer.SerializerFragment auto-inject {
60 generateStub = false
61 }
62
63 // a custom ResourceFactory for use with EMF
64 fragment = resourceFactory.ResourceFactoryFragment auto-inject {}
65
66 // The antlr parser generator fragment.
67 fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject {
68 // options = {
69 // backtrack = true
70 // }
71 }
72
73 // Xtend-based API for validation
74 fragment = validation.ValidatorFragment auto-inject {
75 // composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
76 // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
77 }
78
79 // old scoping and exporting API
80 // fragment = scoping.ImportURIScopingFragment auto-inject {}
81 // fragment = exporting.SimpleNamesFragment auto-inject {}
82
83 // scoping and exporting API
84 fragment = scoping.ImportNamespacesScopingFragment auto-inject {}
85 fragment = exporting.QualifiedNamesFragment auto-inject {}
86 fragment = builder.BuilderIntegrationFragment auto-inject {}
87
88 // generator API
89 fragment = generator.GeneratorFragment auto-inject {}
90
91 // formatter API
92 fragment = formatting.FormatterFragment auto-inject {}
93
94 // labeling API
95 fragment = labeling.LabelProviderFragment auto-inject {}
96
97 // outline API
98 fragment = outline.OutlineTreeProviderFragment auto-inject {}
99 fragment = outline.QuickOutlineFragment auto-inject {}
100
101 // quickfix API
102 fragment = quickfix.QuickfixProviderFragment auto-inject {}
103
104 // content assist API
105 fragment = contentAssist.ContentAssistFragment auto-inject {}
106
107 // generates a more lightweight Antlr parser and lexer tailored for content assist
108 fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {}
109
110 // generates junit test support classes into Generator#pathTestProject
111 fragment = junit.Junit4Fragment auto-inject {}
112
113 // rename refactoring
114 fragment = refactoring.RefactorElementNameFragment auto-inject {}
115
116 // provides the necessary bindings for java types integration
117 fragment = types.TypesGeneratorFragment auto-inject {}
118
119 // generates the required bindings only if the grammar inherits from Xbase
120 fragment = xbase.XbaseGeneratorFragment auto-inject {}
121
122 // generates the required bindings only if the grammar inherits from Xtype
123 fragment = xbase.XtypeGeneratorFragment auto-inject {}
124
125 // provides a preference page for template proposals
126 fragment = templates.CodetemplatesGeneratorFragment auto-inject {}
127
128 // provides a compare view
129 fragment = compare.CompareFragment auto-inject {}
130 }
131 }
132}
133
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/formatting/AlloyLanguageFormatter.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/formatting/AlloyLanguageFormatter.xtend
new file mode 100644
index 00000000..28797bc4
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/formatting/AlloyLanguageFormatter.xtend
@@ -0,0 +1,96 @@
1/*
2 * generated by Xtext
3 */
4package hu.bme.mit.inf.dslreasoner.formatting
5
6import com.google.inject.Inject
7import hu.bme.mit.inf.dslreasoner.services.AlloyLanguageGrammarAccess
8import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter
9import org.eclipse.xtext.formatting.impl.FormattingConfig
10
11/**
12 * This class contains custom formatting description.
13 *
14 * see : http://www.eclipse.org/Xtext/documentation.html#formatting
15 * on how and when to use it
16 *
17 * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
18 */
19class AlloyLanguageFormatter extends AbstractDeclarativeFormatter {
20
21 @Inject extension AlloyLanguageGrammarAccess
22
23 override protected void configureFormatting(FormattingConfig c) {
24 // It's usually a good idea to activate the following three statements.
25 // They will add and preserve newlines around comments
26 c.setLinewrap(0, 1, 2).before(SL_COMMENTRule)
27 c.setLinewrap(0, 1, 2).before(ML_COMMENTRule)
28 c.setLinewrap(0, 1, 1).after(ML_COMMENTRule)
29
30 c.setAutoLinewrap(100000);
31
32 //Signatures
33 c.setIndentationIncrement.after(ALSSignatureBodyAccess.leftCurlyBracketKeyword_5);
34 c.setLinewrap.after(ALSSignatureBodyAccess.leftCurlyBracketKeyword_5)
35 c.setIndentationDecrement.before(ALSSignatureBodyAccess.rightCurlyBracketKeyword_7);
36 c.setLinewrap.after(ALSSignatureBodyAccess.rightCurlyBracketKeyword_7)
37 c.setLinewrap.before(ALSSignatureBodyAccess.rightCurlyBracketKeyword_7)
38 c.setNoSpace.before(ALSSignatureBodyAccess.commaKeyword_3_0)
39 c.setLinewrap.after(ALSSignatureBodyAccess.commaKeyword_3_0)
40 c.setNoSpace.before(ALSSignatureBodyAccess.commaKeyword_3_0)
41 c.setNoSpace.before(ALSSignatureBodyAccess.commaKeyword_6_1_0)
42 c.setLinewrap.after(ALSSignatureBodyAccess.commaKeyword_6_1_0)
43 c.setNoSpace.before(ALSSignatureBodyAccess.commaKeyword_6_1_0)
44 //c.setLinewrap(0,1,2).between(ALSSignatureDeclarationRule,ALSSignatureDeclarationRule)
45
46 //Enums
47 c.setIndentationIncrement.after(ALSEnumDeclarationAccess.leftCurlyBracketKeyword_2)
48 c.setLinewrap.after(ALSEnumDeclarationAccess.leftCurlyBracketKeyword_2)
49 c.setIndentationDecrement.before(ALSEnumDeclarationAccess.rightCurlyBracketKeyword_5)
50 c.setLinewrap.before(ALSEnumDeclarationAccess.rightCurlyBracketKeyword_5)
51 c.setLinewrap.after(ALSEnumDeclarationAccess.rightCurlyBracketKeyword_5)
52 c.setNoSpace.before(ALSEnumDeclarationAccess.commaKeyword_4_0)
53
54
55 //facts
56 c.setIndentationIncrement.after(ALSFactDeclarationAccess.leftCurlyBracketKeyword_3)
57 c.setLinewrap.after(ALSFactDeclarationAccess.leftCurlyBracketKeyword_3)
58 c.setIndentationDecrement.before(ALSFactDeclarationAccess.rightCurlyBracketKeyword_5)
59 c.setLinewrap.before(ALSFactDeclarationAccess.rightCurlyBracketKeyword_5)
60 c.setLinewrap.after(ALSFactDeclarationAccess.rightCurlyBracketKeyword_5)
61
62 //predicates
63 c.setIndentationIncrement.after(ALSRelationDefinitionAccess.leftCurlyBracketKeyword_6)
64 c.setLinewrap.after(ALSRelationDefinitionAccess.leftCurlyBracketKeyword_6)
65 c.setIndentationDecrement.before(ALSRelationDefinitionAccess.rightCurlyBracketKeyword_8)
66 c.setLinewrap.before(ALSRelationDefinitionAccess.rightCurlyBracketKeyword_8)
67 c.setLinewrap.after(ALSRelationDefinitionAccess.rightCurlyBracketKeyword_8)
68 c.setNoSpace.after(ALSRelationDefinitionAccess.leftSquareBracketKeyword_2)
69 c.setNoSpace.before(ALSRelationDefinitionAccess.rightSquareBracketKeyword_5)
70 c.setNoSpace.before(ALSRelationDefinitionAccess.commaKeyword_4_0)
71
72 // terms
73 //c.setNoSpace.before(ALSJoinAccess.rightSquareBracketKeyword_1_2_1_3)
74 c.setNoSpace.before(ALSJoinAccess.fullStopKeyword_1_1)
75 c.setNoSpace.after(ALSJoinAccess.fullStopKeyword_1_1)
76
77 c.setNoSpace.before(ALSDirectProductAccess.hyphenMinusGreaterThanSignKeyword_1_2)
78 c.setNoSpace.after(ALSDirectProductAccess.hyphenMinusGreaterThanSignKeyword_1_2)
79
80 c.setNoSpace.before(ALSVariableDeclarationAccess.colonKeyword_1)
81// c.setNoSpace.before(ALSPreficedAccess.commaKeyword_5_3_0)
82// c.setNoSpace.before(ALSPreficedAccess.commaKeyword_6_4_0)
83//
84// c.setIndentationIncrement.after(ALSPreficedAccess.leftCurlyBracketKeyword_5_4)
85// c.setLinewrap.after(ALSPreficedAccess.leftCurlyBracketKeyword_5_4)
86// c.setLinewrap.before(ALSPreficedAccess.rightCurlyBracketKeyword_5_6)
87// c.setIndentationDecrement.before(ALSPreficedAccess.rightCurlyBracketKeyword_5_6)
88
89 c.setNoSpace.after(ALSBasicRelationTermAccess.leftParenthesisKeyword_6_0)
90 c.setNoSpace.before(ALSBasicRelationTermAccess.rightParenthesisKeyword_6_2)
91
92 // Quantified expression
93 c.setNoSpace.before(ALSQuantifiedAccess.commaKeyword_0_4_0)
94
95 }
96}
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/generator/AlloyLanguageGenerator.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/generator/AlloyLanguageGenerator.xtend
new file mode 100644
index 00000000..9afcc300
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/generator/AlloyLanguageGenerator.xtend
@@ -0,0 +1,24 @@
1/*
2 * generated by Xtext
3 */
4package hu.bme.mit.inf.dslreasoner.generator
5
6import org.eclipse.emf.ecore.resource.Resource
7import org.eclipse.xtext.generator.IGenerator
8import org.eclipse.xtext.generator.IFileSystemAccess
9
10/**
11 * Generates code from your model files on save.
12 *
13 * see http://www.eclipse.org/Xtext/documentation.html#TutorialCodeGeneration
14 */
15class AlloyLanguageGenerator implements IGenerator {
16
17 override void doGenerate(Resource resource, IFileSystemAccess fsa) {
18// fsa.generateFile('greetings.txt', 'People to greet: ' +
19// resource.allContents
20// .filter(typeof(Greeting))
21// .map[name]
22// .join(', '))
23 }
24}
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/scoping/AlloyLanguageScopeProvider.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/scoping/AlloyLanguageScopeProvider.xtend
new file mode 100644
index 00000000..6e095f3c
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/scoping/AlloyLanguageScopeProvider.xtend
@@ -0,0 +1,81 @@
1/*
2 * generated by Xtext
3 */
4package hu.bme.mit.inf.dslreasoner.scoping
5
6import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSDefinition
7import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSDocument
8import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSEnumDeclaration
9import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSFunctionCall
10import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSQuantifiedEx
11import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSReference
12import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSRelationDeclaration
13import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSRelationDefinition
14import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSSignatureBody
15import hu.bme.mit.inf.dslreasoner.alloyLanguage.ALSSum
16import java.util.ArrayList
17import java.util.Collections
18import java.util.HashSet
19import java.util.LinkedList
20import java.util.List
21import java.util.Set
22import org.eclipse.emf.ecore.EObject
23import org.eclipse.emf.ecore.EReference
24import org.eclipse.xtext.scoping.IScope
25import org.eclipse.xtext.scoping.Scopes
26import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider
27
28/**
29 * This class contains custom scoping description.
30 *
31 * see : http://www.eclipse.org/Xtext/documentation.html#scoping
32 * on how and when to use it
33 *
34 */
35class AlloyLanguageScopeProvider extends AbstractDeclarativeScopeProvider {
36
37 def public IScope scope_ALSReference_referred(ALSReference alsReferecnce, EReference ref) {
38 val Set<ALSRelationDeclaration> declarations = new HashSet
39
40 val parent = alsReferecnce.getAllParents(ALSDocument).head as ALSDocument
41 val signatures = parent.signatureBodies.map[ALSSignatureBody x|x.declarations].flatten
42 declarations+=parent.enumDeclarations
43 declarations+=signatures
44 declarations+=parent.enumDeclarations.map[ALSEnumDeclaration x | x.literal].flatten
45 declarations+=parent.signatureBodies.map[ALSSignatureBody x|x.fields].flatten
46
47 declarations+=alsReferecnce.getAllParents(ALSQuantifiedEx).map[ALSQuantifiedEx x | x.variables].flatten
48 declarations+=alsReferecnce.getAllParents(ALSSum).map[ALSSum x | x.variables].flatten
49 declarations+=alsReferecnce.getAllParents(ALSRelationDefinition).map[ALSRelationDefinition x | x.variables].flatten
50
51// println("---")
52// println(declarations.map[it.name].join(", "))
53
54 return Scopes.scopeFor(declarations)
55 }
56 //{ALSFunctionCall} (/*functionName=ALSID |*/ referredDefinition=[ALSDefinition])
57 def public IScope scope_ALSFunctionCall_referredDefinition(ALSFunctionCall call, EReference ref) {
58 val parent = call.<ALSDocument>getAllParents(ALSDocument).head as ALSDocument
59 val list = new LinkedList<ALSDefinition>
60 list += parent.relationDefinitions
61 list += parent.functionDefinitions
62 //list.forEach[println(it.name + " " + it.eContainer)]
63 return Scopes.scopeFor(list)
64 }
65
66 def <X extends EObject> List<X> getAllParents(EObject object, Class<X> type) {
67 if(object.eContainer == null) {
68 return Collections.EMPTY_LIST
69 } else {
70 val container = object.eContainer;
71 val previousParents = container.getAllParents(type)
72 if(type.isInstance(container)){
73 val res = new ArrayList(previousParents)
74 res+= container as X
75 return res
76 }
77 else return previousParents
78
79 }
80 }
81}
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/validation/AlloyLanguageValidator.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/validation/AlloyLanguageValidator.xtend
new file mode 100644
index 00000000..8e1efc99
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/validation/AlloyLanguageValidator.xtend
@@ -0,0 +1,24 @@
1/*
2 * generated by Xtext
3 */
4package hu.bme.mit.inf.dslreasoner.validation
5//import org.eclipse.xtext.validation.Check
6
7/**
8 * Custom validation rules.
9 *
10 * see http://www.eclipse.org/Xtext/documentation.html#validation
11 */
12class AlloyLanguageValidator extends AbstractAlloyLanguageValidator {
13
14// public static val INVALID_NAME = 'invalidName'
15//
16// @Check
17// def checkGreetingStartsWithCapital(Greeting greeting) {
18// if (!Character.isUpperCase(greeting.name.charAt(0))) {
19// warning('Name should start with a capital',
20// MyDslPackage.Literals.GREETING__NAME,
21// INVALID_NAME)
22// }
23// }
24}