-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added beginning of facility for functional programs
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
java/ptrman/causalReasoningSystem/functional/CausalFunctionalMutator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package ptrman.causalReasoningSystem.functional; | ||
|
||
/** | ||
* Mutates the functional programs in the graph and tries to find better/more compressed versions | ||
*/ | ||
public class CausalFunctionalMutator { | ||
// TODO | ||
// * decompose sequences into other sequences and try to match against existing sequences | ||
// * compose sequences and try to match them to exiting ones | ||
// * same for logical operations | ||
} |
23 changes: 23 additions & 0 deletions
23
java/ptrman/causalReasoningSystem/functional/Transformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package ptrman.causalReasoningSystem.functional; | ||
|
||
import ptrman.causalReasoningSystem.InputGraph; | ||
import ptrman.causalReasoningSystem.functional.tree.Element; | ||
|
||
/** | ||
* translates a functional tree to a causal set | ||
*/ | ||
public class Transformer { | ||
public static class Context { | ||
int index; | ||
} | ||
|
||
public static void transform(InputGraph graph, Context context, int entryGraphElement, Element entry) { | ||
final int thisIndex = entryGraphElement; | ||
graph.connections.add(new InputGraph.Connection(entryGraphElement, context.index)); | ||
context.index++; | ||
|
||
for( Element iterationChildren : entry.children ) { | ||
transform(graph, context, thisIndex, iterationChildren); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
java/ptrman/causalReasoningSystem/functional/tree/Element.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package ptrman.causalReasoningSystem.functional.tree; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Element of a expression of a functional language tree | ||
*/ | ||
public abstract class Element { | ||
public Type type; | ||
public List<Element> children = new ArrayList<>(); | ||
|
||
public abstract boolean isEqual(final Element other); | ||
} |
15 changes: 15 additions & 0 deletions
15
java/ptrman/causalReasoningSystem/functional/tree/Type.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ptrman.causalReasoningSystem.functional.tree; | ||
|
||
/** | ||
* Created by r0b3 on 04.12.2015. | ||
*/ | ||
public abstract class Type { | ||
public enum EnumFundamentalType { | ||
SEQUENCE, | ||
} | ||
|
||
public abstract boolean isEqualWithType(final Type other); | ||
|
||
public abstract boolean isFundamentalType(); | ||
public abstract EnumFundamentalType getFundamentalType(); | ||
} |