Skip to content

Commit

Permalink
added beginning of facility for functional programs
Browse files Browse the repository at this point in the history
  • Loading branch information
PtrMan committed Dec 5, 2015
1 parent ef2dbe8 commit f788bde
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
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 java/ptrman/causalReasoningSystem/functional/Transformer.java
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 java/ptrman/causalReasoningSystem/functional/tree/Element.java
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 java/ptrman/causalReasoningSystem/functional/tree/Type.java
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();
}

0 comments on commit f788bde

Please sign in to comment.