Skip to content

Commit cf18bef

Browse files
author
Ferhat Erata
committed
Initial code
1 parent 052500b commit cf18bef

File tree

1,350 files changed

+214972
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,350 files changed

+214972
-6
lines changed
308 KB
Loading

LICENSE

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
MIT License
1+
The MIT License
22

3-
Copyright (c) 2018 ITEA2-ModelWriter Project
3+
Copyright (c) 2016, Ferhat Erata <ferhat@computer.org>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,14 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99
copies of the Software, and to permit persons to whom the Software is
1010
furnished to do so, subject to the following conditions:
1111

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
1414

1515
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.
22+

README.md

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,248 @@
11
# AlloyInEcore
22
Deep Embedding of Alloy into Essential Meta-object Facility
3+
4+
### Full EMF Type System (`EPackage`, `EClass`, `EEnum`, `EReferences`, `EAttributes` ...)
5+
6+
### `composition` qualifier of an `EReference`
7+
8+
### `identifier` qualifier of an `EAttribute`in an `EClass` to mark as object identifier
9+
10+
### `derived` qualifier of an `EStructuralFeature` to suppress default values
11+
12+
Perform semantic analysis for 'derived' qualified 'EStructuralFeature' to suppress default values assigned by EMF or by the user or by the reasoning process. Normally, if a value is assigned to a slot, the reasoning process includes the current value in the lower bound, that gurantees this assigned is unchanged. However, if this value is unknown before the analysis and it should be derived from the structure of the state, then the user should mark the structural feature corresponding to this slot.
13+
14+
Delete any values on the slots of `derived` qualified `EAttributes` or `EReferences` of an user provided partial instance. The values on the state before analysis is `volatile`.
15+
16+
1. `EBoolean <- false`
17+
2. `EInteger <- 0
18+
19+
```
20+
import Ecore : 'http://www.eclipse.org/emf/2002/Ecore';
21+
22+
package ArchitectureMetamodel : arch = 'eu.modelwriter.demonstrations.metamodels.architecture'
23+
{
24+
public class one ArchitecturalModel
25+
{
26+
property one elements : ArchitecturalElement[*] { composes };
27+
model property leaves : Component[*];
28+
invariant leaves: Component - Component.^~subComponents in ArchitecturalModel.leaves;
29+
30+
}
31+
abstract class ArchitecturalElement [7]
32+
{
33+
attribute identifier : Integer[1] {id};
34+
-- invariant : all disj a, b: ArchitecturalElement | a.identifier != b.identifier;
35+
attribute name : String[?];
36+
-- invariant : all a: Component| #a.subComponents < 3;
37+
invariant : all c: Component | some c.subComponents implies #a.subComponents = 2;
38+
}
39+
class Component extends ArchitecturalElement
40+
{
41+
property subComponents : Component[*] { composes };
42+
ghost attribute description: String = 'Default Description';
43+
44+
model attribute isLeaf: Boolean { derived };
45+
invariant isLeaf: all c: Component | some (c - c.^r) implies c.isLeaf = True;
46+
47+
}
48+
}
49+
```
50+
51+
### Generic types (`EGeneric`) and type parameters, (`ETypeParameter`)
52+
53+
### String, Integer, and Boolean Values in constraints
54+
55+
#### Reasoning about `EBoolean` attributes
56+
57+
#### Reasoning about `EString` attributes
58+
59+
#### Reasoning about `EInteger` attributes
60+
61+
#### Reasoning about `EEnum` and `EEnumLiterals`
62+
63+
### `class`, `extends`, and `super` in constraints
64+
65+
This feature is inspired from `java.lang.Class` of the java language.
66+
1. `Class` is a unary relation and has exact bounds since the number of `EClass` specified on an EMF model is fixed (finite).
67+
`Class: [[[Object], [List], [List<Object>], [List<?>] ... ]]`
68+
`Class` also represents `Class<?>`
69+
2. Each `Class<T>` is a singleton as shown below:
70+
`Class<Object>: [[[Object]]]`
71+
`Class<List>: [[[List]]]`
72+
`Class<List<Object>>: [[[List<Object>]]]`
73+
`Class<List<?>>: [[[List<?>]]]`
74+
`...`
75+
3. All `Class<T>` singletons constitute the set of raw `Class`.
76+
`Class = Class<Object> + Class<List> + Class<List<Object>> + Class<List<?>> ... `
77+
4. `type` is a binary relation. Each atoms excluding the set of `Class` in the universe has **at least one type** based on the type hierarchy specified in the EMF file.
78+
`<EnginedVehicle281>.type = {<EnginedVehicle>, <Vehicle>, <Object>}`
79+
`<EnginedVehicle181>.type = {<EnginedVehicle>, <Vehicle>, <Object>}`
80+
`<EnginedVehicle281>.type = <EnginedVehicle181>.type`
81+
5. If the tuple comes from partial instance then the lower and upper bounds are fixed.
82+
`type: {<EnginedVehicle281, EngineVehicle>, <EnginedVehicle281, Vehicle>, <EnginedVehicle281, Object>, <EngineVehicle, EngineVehicle>, <EngineVehicle, Vehicle>, <EnginedVehicle, Object>, ...}`
83+
6. The set of `Class` is disjoint from all other sets.
84+
`no (Class & (Object + List + ... )`
85+
7. The set of `type` is the subset of the production from **`univ`** to **`Class`**.
86+
`type in (univ - Class) -> some Class`
87+
If we apply the bounds on the set of `type`, then the we should specify the following rule:
88+
`type in univ -> some Class`
89+
8. The Classes, Objects, StringLiterals, and Numbers form the universe.
90+
`univ = {<Object>, <List>, <List<Object>>, <List<?>>, ... , <EnginedVehicle281>, <Vehicle_1>, <EnginedVehicle181>, ... , <"Ferhat">, <EString_1>, <EString_2>, ... , <EInt_1>, <5>, <EInt_7>, <9.5>, ... }`
91+
9. Mapping from each set to the corresponding type.
92+
`all a: univ - Class | a in Object iff Class<Object> in a.type`
93+
`all a: univ - Class | a in List iff Class<List> in a.type`
94+
`all a: univ - Class | a in List<Object> iff Class<List<Object>> in a.type`
95+
`all a: univ - Class | a in List<?> iff Class<List<?>> in a.type`
96+
`...`
97+
10. From the the type system, the following axioms already exist:
98+
`no Object & List`
99+
`...`
100+
`Vehicle in Object`
101+
`EnginedVehicle in Vehicle`
102+
`...`
103+
`List = List<Object> + List<Vehicle> + List<EnginedVehicle>`
104+
`List<?> in List`
105+
These axioms enforce the consistency among types based on the type hierarchy. Consequently, the following assertions are always true:
106+
11. The assertions such as the following ones must always be true:
107+
`assert { all a: univ | a.type in Class<List<EnginedVehicle>> implies (a.type in Class<List<Vehicle>> and a.type in Class<List<Object>> }`
108+
`assert { all disj o, o': univ - Class | (o'.type in o.type) implies (o' in o) }`
109+
`assert { all v: Vehicle | Class<EnginedVehicle> in v.type}`
110+
`assert { all c: Class | some o : univ | c in o.type }`
111+
12. `type` is a partial order over the set `Class`.
112+
`reflexive[type, Class]`
113+
`antisymmetric[type]`
114+
`transitive[type]`
115+
13. The following equalities must hold adding respective type tuples to the set of `type`.
116+
`Class<EnginedVehicle>.type = {<EnginedVehicle>, <Vehicle>, <Object>}`
117+
`Class<Vehicle>.type = {<Vehicle>, <Object>}`
118+
`Class<Object>.type = {<Object>}`
119+
14. generation `extends` and `super` relations
120+
`all c, c' : Class | (c.type in c'.type and c'.type !in c.type) iff c in c'.extends`
121+
`super = ~extends`
122+
15. The following rule must hold because of the above first axiom:
123+
`extends in Class -> Class`
124+
16. `extends` and `super` are irreflexive, antisymmetric, and transitive.
125+
`irreflexive[extends]`
126+
`antisymmetric[extends]`
127+
`transitive[extends]`
128+
129+
- The intended usage in the Theory of List in the AlloyInEcore context:
130+
131+
```
132+
-- type(class) in univ -> set TYPE (java.lang.Class)
133+
-- a.type = b.type
134+
-- a.class = b.class
135+
-- type[a] = type[b]
136+
all a, b: List<E> | a in b.eq iff (a.car = b.car and a.cdr in b.cdr.eq and a.type != b.type);
137+
all a, b: List<E> | a in b.eq iff (a.car = b.car and a.cdr in b.cdr.eq and a.type in b.type.extends);
138+
```
139+
140+
### `model` and `ghost` attirubute and references.
141+
142+
### Predefined keywords for EReferences inspired by Alloy's `Relation` and `Graph` Libraries
143+
144+
### Instance Visualization
145+
146+
### Finite Implementation of Transitive Closure Operator of Alloy by Z3
147+
148+
* Unroll transitive closure operator and estimate the maximum number of join operation.
149+
150+
`^r = r + r.r + r.r.r + ...`
151+
152+
> For a finite universe, transitive closure needs only a finite unwinding,
153+
> limited by the length of the longest path in the graph.
154+
155+
> Viewing a relation as a graph, the transitive closure represents reachability.
156+
157+
```
158+
address =
159+
{(G0, A0), (G0, G1), (A0, D0), (G1, D0), (G1, A1), (A1, D1), (A2, D2)}
160+
```
161+
```
162+
'The length of the longest path in the graph' =
163+
#{(G0, G1), (G1, A1), (A1, D1)} = 3
164+
```
165+
```
166+
address =
167+
{(G0, A0), (G0, G1), (A0, D0), (G1, D0), (G1, A1), (A1, D1), (A2, D2)}
168+
address.address =
169+
{(G0, D0), (G0, A1), (G1, D1)}
170+
address.address.address =
171+
{(G0, D1)}
172+
```
173+
```
174+
^address = address + address.address + address.address.address
175+
{(G0, A0), (G0, G1), (A0, D0), (G1, D0), (G1, A1), (A1, D1), (A2, D2),
176+
(G0, D0), (G0, A1), (G1, D1),
177+
(G0, D1)}
178+
^address - address = {(G0, D0), (G0, A1), (G1, D1), (G0, D1)}
179+
```
180+
181+
* An example is shown in the following:
182+
183+
```
184+
(all d: Dir | !(d in (d.(^content))))
185+
186+
(all d: Dir | !(d in (d.(content))))
187+
(all d: Dir | !(d in (d.(content.content))))
188+
(all d: Dir | !(d in (d.(content.content.content))))
189+
...
190+
```
191+
```
192+
(all l: List | Nil in (l.(*cdr)))
193+
194+
(all l: List | Nil in (l.((cdr + iden))))
195+
(all l: List | Nil in (l.((cdr + iden).(cdr + iden))))
196+
(all l: List | Nil in (l.((cdr + iden).(cdr + iden).(cdr + iden))))
197+
...
198+
```
199+
200+
201+
```
202+
(all d: Dir | !(d in (d.(content)))) <=> (all d: Dir | (d -> d) !in content)
203+
```
204+
```
205+
all d, d': Dir | content(d,d') implies d != d'
206+
all d, d', d'': Dir | content(d,d') and content(d',d'') implies d != d''
207+
all d, d', d'',d''': Dir | content(d,d') and content(d',d'') and content(d'',d''') implies d != d'''
208+
...
209+
```
210+
211+
```
212+
(declare-sort FSObject)
213+
(declare-fun isDir (FSObject) Bool)
214+
(assert (forall ((f FSObject)) (=> (isDir f) (isFSObject f))))
215+
(declare-fun content (FSObject FSObject) Bool)
216+
(declare-fun trcontent1 (FSObject FSObject) Bool)
217+
(declare-fun trcontent2 (FSObject FSObject) Bool)
218+
(declare-fun trcontent3 (FSObject FSObject) Bool)
219+
220+
all d, d', d'': Dir | content(d,d') and content(d',d'') implies trcontent1(d , d'')
221+
all d, d', d'': Dir | trcontent1(d , d') and content(d',d'') implies trcontent2(d , d'')
222+
all d, d', d'': Dir | trcontent2(d , d') and content(d',d'') implies trcontent3(d , d'')
223+
224+
all d, d': Dir | content(d,d') implies d != d'
225+
all d, d': Dir | trcontent1(d,d') implies d != d'
226+
all d, d': Dir | trcontent2(d,d') implies d != d'
227+
all d, d': Dir | trcontent3(d,d') implies d != d'
228+
```
229+
![image](https://github.com/ModelWriter/AlloyInEcore/blob/aie-interpreter/Documents/FinitizationTransitiveClosureForSMTLIB.png)
230+
231+
```
232+
all d: FSObject | isDir(d) implies not content(d,d)
233+
all d: FSObject | isDir(d) implies not trcontent1(d,d)
234+
all d: FSObject | isDir(d) implies not trcontent2(d,d)
235+
```
236+
237+
```
238+
all d: Dir | not content(d,d)
239+
all d, d': Dir | not (content(d,d') and content(d',d))
240+
all d, d': FSObject | (isDir(d) and isDir(d')) implies not (content(d,d') and content(d',d))
241+
....
242+
```
243+
```
244+
forall d: FSObject, d': FSObject | isDir(d) implies not (content(d, d') and content(d',d) )
245+
```
246+
247+
248+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry exported="true" kind="lib" path="lib/antlr-4.7-complete.jar"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
5+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6+
<classpathentry kind="src" path="src"/>
7+
<classpathentry kind="lib" path="lib/eu.modelwriter.core.alloyinecore.jar" sourcepath="lib/eu.modelwriter.core.alloyinecore.jar"/>
8+
<classpathentry kind="lib" path="lib/ST-4.0.8.jar"/>
9+
<classpathentry kind="output" path="bin"/>
10+
<referencedentry kind="lib" path="lib/kodkod.jar" sourcepath="C:/Users/Harun/Documents/GitHub/kodkod"/>
11+
</classpath>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>eu.modelwriter.core.alloyinecore.mapping</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+
</buildSpec>
24+
<natures>
25+
<nature>org.eclipse.pde.PluginNature</nature>
26+
<nature>org.eclipse.jdt.core.javanature</nature>
27+
</natures>
28+
</projectDescription>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.compliance=1.8
5+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7+
org.eclipse.jdt.core.compiler.source=1.8

0 commit comments

Comments
 (0)