From 3ccbfae137a4775cf7d8596eca33b13fa5bc02d9 Mon Sep 17 00:00:00 2001
From: jgeldart <jgeldart@91dfdad4-c543-0410-b26a-7d79dded8189>
Date: Wed, 9 Apr 2008 17:06:22 +0000
Subject: [PATCH] First commit of new classes and interfaces. Nothing
 executable as yet, unless you like objects which do nothing, but it is a
 start. Documentation needs completion and a clear up of what's already
 written.

---
 .../opennars/areas/AbstractArea.java          |  26 +++
 .../serialisation/AbstractFormatter.java      |  32 ++++
 .../areas/serialisation/AbstractParser.java   |  32 ++++
 .../AbstractSimpleFormatter.java              | 104 +++++++++++
 .../serialisation/AbstractSimpleParser.java   |  85 +++++++++
 .../opennars/core/AbstractReasoner.java       |  51 ++++++
 .../googlecode/opennars/language/Action.java  |  67 ++++++++
 .../googlecode/opennars/language/Namable.java |  24 +++
 .../language/control/ControlAction.java       |  23 +++
 .../language/control/LogicAction.java         |  65 +++++++
 .../opennars/language/control/Sentence.java   |  93 ++++++++++
 .../language/logic/AbstractLogicVisitor.java  | 162 ++++++++++++++++++
 .../opennars/language/logic/AtomicTerm.java   |  14 ++
 .../language/logic/BooleanLiteral.java        |  86 ++++++++++
 .../opennars/language/logic/CompoundTerm.java |  64 +++++++
 .../opennars/language/logic/Conjunction.java  |  79 +++++++++
 .../language/logic/DependentVariable.java     |  21 +++
 .../opennars/language/logic/Disjunction.java  |  47 +++++
 .../opennars/language/logic/Equivalence.java  |  47 +++++
 .../language/logic/ExtDifference.java         |  47 +++++
 .../opennars/language/logic/ExtImage.java     |  47 +++++
 .../language/logic/ExtIntersection.java       |  85 +++++++++
 .../opennars/language/logic/ExtSet.java       |  47 +++++
 .../opennars/language/logic/FutureTense.java  |  47 +++++
 .../language/logic/IdentityTruthDelegate.java |  32 ++++
 .../opennars/language/logic/Implication.java  |  47 +++++
 .../language/logic/IndependentVariable.java   |  22 +++
 .../opennars/language/logic/Inheritance.java  |  46 +++++
 .../language/logic/IntDifference.java         |  47 +++++
 .../opennars/language/logic/IntImage.java     |  47 +++++
 .../language/logic/IntIntersection.java       |  47 +++++
 .../opennars/language/logic/IntSet.java       |  47 +++++
 .../opennars/language/logic/LiteralTerm.java  |  52 ++++++
 .../language/logic/LiteralTruthDelegate.java  |  16 ++
 .../opennars/language/logic/LogicVisitor.java |  54 ++++++
 .../opennars/language/logic/Negation.java     |  47 +++++
 .../language/logic/NumericLiteral.java        |  22 +++
 .../language/logic/ParallelConjunction.java   |  47 +++++
 .../opennars/language/logic/PastTense.java    |  47 +++++
 .../opennars/language/logic/PresentTense.java |  47 +++++
 .../opennars/language/logic/Product.java      |  47 +++++
 .../language/logic/QueryVariable.java         |  22 +++
 .../language/logic/SequentialConjunction.java |  47 +++++
 .../opennars/language/logic/Similarity.java   |  46 +++++
 .../opennars/language/logic/Statement.java    |  39 +++++
 .../language/logic/StringLiteral.java         |  25 +++
 .../opennars/language/logic/Term.java         |  53 ++++++
 .../opennars/language/logic/TruthValue.java   |  65 +++++++
 .../opennars/language/logic/URIReference.java |  28 +++
 .../opennars/language/logic/Variable.java     |  24 +++
 50 files changed, 2458 insertions(+)
 create mode 100644 open-nars/src/com/googlecode/opennars/areas/AbstractArea.java
 create mode 100644 open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractFormatter.java
 create mode 100644 open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractParser.java
 create mode 100644 open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractSimpleFormatter.java
 create mode 100644 open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractSimpleParser.java
 create mode 100644 open-nars/src/com/googlecode/opennars/core/AbstractReasoner.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/Action.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/Namable.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/control/ControlAction.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/control/LogicAction.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/control/Sentence.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/AbstractLogicVisitor.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/AtomicTerm.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/BooleanLiteral.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/CompoundTerm.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/Conjunction.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/DependentVariable.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/Disjunction.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/Equivalence.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/ExtDifference.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/ExtImage.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/ExtIntersection.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/ExtSet.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/FutureTense.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/IdentityTruthDelegate.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/Implication.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/IndependentVariable.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/Inheritance.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/IntDifference.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/IntImage.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/IntIntersection.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/IntSet.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/LiteralTerm.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/LiteralTruthDelegate.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/LogicVisitor.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/Negation.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/NumericLiteral.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/ParallelConjunction.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/PastTense.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/PresentTense.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/Product.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/QueryVariable.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/SequentialConjunction.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/Similarity.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/Statement.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/StringLiteral.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/Term.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/TruthValue.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/URIReference.java
 create mode 100644 open-nars/src/com/googlecode/opennars/language/logic/Variable.java

diff --git a/open-nars/src/com/googlecode/opennars/areas/AbstractArea.java b/open-nars/src/com/googlecode/opennars/areas/AbstractArea.java
new file mode 100644
index 0000000..8ba6a7c
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/areas/AbstractArea.java
@@ -0,0 +1,26 @@
+/**
+ * <p>
+ * Top-level package containing classes implementing processing tasks,
+ * called <i>areas</i> after the standard way of dividing up the neo-cortex in
+ * humans. Areas are implemented as JavaFBP components.
+ * </p>
+ */
+package com.googlecode.opennars.areas;
+
+import com.jpmorrsn.javaFBP.Component;
+
+/**
+ * <p>
+ * Abstract class which all areas should inherit from. Provides the basic
+ * functionality of an OpenNARS processing component. Currently this doesn't
+ * actually amount to anything, but it is expected that certain features will
+ * be found to be common to most or even all areas, and so this class exists in
+ * anticipation.
+ * </p>
+ *  
+ * @author jgeldart
+ *
+ */
+public abstract class AbstractArea extends Component {
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractFormatter.java b/open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractFormatter.java
new file mode 100644
index 0000000..299a570
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractFormatter.java
@@ -0,0 +1,32 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.areas.serialisation;
+
+import com.googlecode.opennars.areas.AbstractArea;
+import com.jpmorrsn.javaFBP.InPorts;
+import com.jpmorrsn.javaFBP.InPort;
+import com.jpmorrsn.javaFBP.OutPort;
+
+/**
+ * <p>
+ * A formatter is an area which takes in a set of control and logic actions and
+ * converts them into a string which may be saved to a file, printed, etc.
+ * Specific serialisation formats implement a concrete sub-class of this.
+ * </p>
+ * <p>
+ * Note, while some serialisations may require it, there is no general
+ * requirement for a pair of an <code>AbstractParser</code> and an
+ * <code>AbstractFormatter</code> connected in series to be the identity
+ * on strings. Serialisations which do not have this isomorphism property
+ * should document their implementations appropriately.
+ * </p>
+ * 
+ * @author jgeldart
+ *
+ */
+@InPorts(value= {@InPort("CONTROL"), @InPort("LOGIC")})
+@OutPort("STRING")
+public abstract class AbstractFormatter extends AbstractArea {
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractParser.java b/open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractParser.java
new file mode 100644
index 0000000..d75335d
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractParser.java
@@ -0,0 +1,32 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.areas.serialisation;
+
+import com.googlecode.opennars.areas.AbstractArea;
+import com.jpmorrsn.javaFBP.InPort;
+import com.jpmorrsn.javaFBP.OutPort;
+import com.jpmorrsn.javaFBP.OutPorts;
+
+/**
+ * <p>
+ * An <code>AbstractParser</code> is a component which takes some string and
+ * converts it into a series of NARS language actions. These terms may be 
+ * either control or logic actions, and each is output on a separate port.
+ * </p>
+ * <p>
+ * Note, while some serialisations may require it, there is no general
+ * requirement for a pair of an <code>AbstractParser</code> and an
+ * <code>AbstractFormatter</code> connected in series to be the identity
+ * on strings. Serialisations which do not have this isomorphism property
+ * should document their implementations appropriately.
+ * </p>
+ * 
+ * @author jgeldart
+ *
+ */
+@InPort("STRING")
+@OutPorts(value = { @OutPort("LOGIC"), @OutPort("CONTROL") })
+public abstract class AbstractParser extends AbstractArea {
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractSimpleFormatter.java b/open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractSimpleFormatter.java
new file mode 100644
index 0000000..5e122cf
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractSimpleFormatter.java
@@ -0,0 +1,104 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.areas.serialisation;
+
+import com.googlecode.opennars.language.control.ControlAction;
+import com.googlecode.opennars.language.control.LogicAction;
+import com.jpmorrsn.javaFBP.InputPort;
+import com.jpmorrsn.javaFBP.OutputPort;
+import com.jpmorrsn.javaFBP.Packet;
+
+/**
+ * <p>
+ * Provides a simple abstraction on an <code>AbstractFormatter</code>.
+ * Rather than worry about the details of the execution loop, one can just
+ * write a <code>format</code> method. This method should take an 
+ * <code>Action</code> and return a <code>String</code>.
+ * </p>
+ * <p>
+ * This abstract class probably isn't as useful as the
+ * <code>AbstractParser</code> as formatting can be more involved. The use
+ * of other components here to collate and reorder the stream may help.
+ * </p>
+ * @author jgeldart
+ *
+ */
+public abstract class AbstractSimpleFormatter extends AbstractFormatter {
+  
+  OutputPort stringPort;
+  InputPort controlPort;
+  InputPort logicPort;
+
+  /* (non-Javadoc)
+   * @see com.jpmorrsn.javaFBP.Component#execute()
+   */
+  @Override
+  protected void execute() throws Throwable {
+    Packet c = null;
+    Packet l = null;
+    
+    while((c = controlPort.receive()) != null || (l = logicPort.receive()) != null) {
+      String out = null;
+      if(c != null) {
+        out = this.format((ControlAction) c.getContent());
+        if(out != null)
+          stringPort.send(this.create(out));
+        out = null;
+        drop(c);
+      }
+      if(l != null) {
+        out = this.format((LogicAction) l.getContent());
+        if(out != null)
+          stringPort.send(this.create(out));
+        drop(l);
+      }
+    }
+  }
+
+  /**
+   * <p>
+   * Formats a <code>LogicAction</code> to a string. A concrete sub-class of
+   * this class would override this in order to provide a renderer for single
+   * sentences of the logic.
+   * </p>
+   * @param content The <code>LogicAction</code> to format into a string
+   * @return The rendered string
+   */
+  protected abstract String format(LogicAction content); 
+
+  /**
+   * <p>
+   * Formats a <code>ControlAction</code> to a string. A concrete sub-class of
+   * this class would override this in order to provide a renderer for single
+   * commands to the control strategy.
+   * </p>
+   * @param content The <code>ControlAction</code> to format into a string
+   * @return The rendered string
+   */
+  protected abstract String format(ControlAction content); 
+
+  /* (non-Javadoc)
+   * @see com.jpmorrsn.javaFBP.Component#introspect()
+   */
+  @Override
+  protected Object[] introspect() {
+    return new Object[] {
+      "Takes two streams of actions and converts them into strings",
+      "STRING", "string", String.class, "A formatted string",
+      "LOGIC", "logic", LogicAction.class, "A sequence of logical actions",
+      "CONTROL", "control", ControlAction.class, "A sequence of control actions"
+    };
+  }
+
+  /* (non-Javadoc)
+   * @see com.jpmorrsn.javaFBP.Component#openPorts()
+   */
+  @Override
+  protected void openPorts() {
+    stringPort = openOutput("STRING");
+    controlPort = openInput("CONTROL");
+    logicPort = openInput("LOGIC");
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractSimpleParser.java b/open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractSimpleParser.java
new file mode 100644
index 0000000..85be5cd
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/areas/serialisation/AbstractSimpleParser.java
@@ -0,0 +1,85 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.areas.serialisation;
+
+import java.util.List;
+
+import com.googlecode.opennars.language.Action;
+import com.googlecode.opennars.language.control.ControlAction;
+import com.googlecode.opennars.language.control.LogicAction;
+import com.jpmorrsn.javaFBP.InputPort;
+import com.jpmorrsn.javaFBP.OutputPort;
+import com.jpmorrsn.javaFBP.Packet;
+
+/**
+ * <p>
+ * An <code>AbstractSimpleParser</code> abstracts away some of the complexities
+ * of writing a parser area for OpenNARS. Rather than implementing the 
+ * <code>execute</code> method, one simply writes a <code>parse</code> method
+ * which returns a sequence of <code>Action</code>s.
+ * </p>
+ * 
+ * @author jgeldart
+ *
+ */
+public abstract class AbstractSimpleParser extends AbstractParser {
+  
+  InputPort stringPort;
+  OutputPort controlPort;
+  OutputPort logicPort;
+
+  /* (non-Javadoc)
+   * @see com.jpmorrsn.javaFBP.Component#execute()
+   */
+  @Override
+  protected void execute() throws Throwable {
+    
+    Packet p;
+    while((p = this.stringPort.receive()) != null) {
+      String str = (String) p.getContent();
+      
+      // Get the results of parsing the string
+      List<Action> acts = this.parse(str);
+      
+      // For each action in the parse results, forward it to the appropriate channel 
+      for(Action a : acts) {
+        if(a instanceof LogicAction)
+          this.logicPort.send(create(a));
+        else if(a instanceof ControlAction)
+          this.controlPort.send(create(a));
+      }
+      drop(p);
+    }
+    
+    this.stringPort.close();
+
+  }
+
+  /* (non-Javadoc)
+   * @see com.jpmorrsn.javaFBP.Component#introspect()
+   */
+  @Override
+  protected Object[] introspect() {
+    // TODO Auto-generated method stub
+    return new Object[] {
+        "Takes a string and converts it into a series of NARS actions",
+        "STRING", "string", String.class, "A string to parse",
+        "LOGIC", "logic", LogicAction.class, "A sequence of logical actions",
+        "CONTROL", "control", ControlAction.class, "A sequence of control actions"
+    };
+  }
+
+  /* (non-Javadoc)
+   * @see com.jpmorrsn.javaFBP.Component#openPorts()
+   */
+  @Override
+  protected void openPorts() {
+    this.stringPort = openInput("STRING");
+    this.logicPort = openOutput("LOGIC");
+    this.controlPort = openOutput("CONTROL");
+  }
+  
+  protected abstract List<Action> parse(String str);
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/core/AbstractReasoner.java b/open-nars/src/com/googlecode/opennars/core/AbstractReasoner.java
new file mode 100644
index 0000000..9d2f05e
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/core/AbstractReasoner.java
@@ -0,0 +1,51 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.core;
+
+import com.jpmorrsn.javaFBP.InPort;
+import com.jpmorrsn.javaFBP.InPorts;
+import com.jpmorrsn.javaFBP.InputPort;
+import com.jpmorrsn.javaFBP.OutPort;
+import com.jpmorrsn.javaFBP.OutPorts;
+import com.jpmorrsn.javaFBP.OutputPort;
+import com.jpmorrsn.javaFBP.SubNet;
+
+/**
+ * <p>
+ * The (abstract) base class for all NARS reasoners. Defines the basic external
+ * interface of a reasoner.
+ * </p>
+ * @author jgeldart
+ *
+ */
+@InPorts(value = { @InPort("INLOGIC"), @InPort("INCONTROL"), @InPort("PARAMETERS") })
+@OutPorts(value = { @OutPort("OUTLOGIC"), @OutPort("OUTCONTROL") })
+public class AbstractReasoner extends SubNet {
+
+  @SuppressWarnings("unused")
+  private InputPort inLogic;
+  
+  @SuppressWarnings("unused")
+  private InputPort inControl;
+  
+  @SuppressWarnings("unused")
+  private InputPort params;
+  
+  @SuppressWarnings("unused")
+  private OutputPort outLogic;
+  
+  @SuppressWarnings("unused")
+  private OutputPort outControl;
+  
+  @Override
+  protected void openPorts() {
+    super.openPorts();
+    inLogic = this.openInput("INLOGIC");
+    inControl = this.openInput("INCONTROL");
+    params = this.openInput("PARAMETERS");
+    outLogic = this.openOutput("OUTLOGIC");
+    outControl = this.openOutput("OUTCONTROL");
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/Action.java b/open-nars/src/com/googlecode/opennars/language/Action.java
new file mode 100644
index 0000000..c4cc197
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/Action.java
@@ -0,0 +1,67 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * <code>Action</code> is the interface all NARS language terms must comply
+ * with. The interface supports the annotation of a term with metadata which
+ * may be used to support things such as source identification or various
+ * forms of control strategy. This interface is kept as light as possible to
+ * avoid enforcing a particular form of strategy on a system.
+ * </p>
+ * <p>
+ * The metadata on an action should be preserved through inferences
+ * <i>unless</i> otherwise specified by the control strategy. This means that
+ * answers to questions, for example, will still have the same 'origin'
+ * metadata to allow routing of the answer to the correct agent. Exceptions to
+ * the preservation property should be <i>explicitly</i> mentioned in the
+ * documentation of a reasoner.
+ * </p>
+ * 
+ * @author jgeldart
+ *
+ */
+public interface Action {
+  
+  /**
+   * <p>
+   * Returns a map of keys to objects representing the metadata on this action.
+   * </p>
+   * @return The metadata map for the action.
+   */
+  public Map<String, Object> getMetadata();
+  
+  /**
+   * <p>
+   * Replace all the metadata on an action at the same time using the provided
+   * map.
+   * </p>
+   * @param meta The map of metadata to use as a replacement.
+   */
+  public void replaceMetadata(Map<String, Object> meta);
+  
+  /**
+   * <p>
+   * Get a specific piece of metadata on the action by its <code>String</code>
+   * key.
+   * </p>
+   * @param key The key of the piece of metadata to return.
+   * @return The appropriate piece of metadata or <code>null</code> if no such data exists.
+   */
+  public Object getMetadataByKey(String key);
+  
+  /**
+   * <p>
+   * Sets a specific piece of metadata on the action according to its
+   * <code>String</code> key.
+   * </p>
+   * @param key The key of the metadata to set. 
+   * @param meta The metadata object to set with.
+   */
+  public void setMetadataByKey(String key, Object meta);
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/Namable.java b/open-nars/src/com/googlecode/opennars/language/Namable.java
new file mode 100644
index 0000000..f4bfc98
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/Namable.java
@@ -0,0 +1,24 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language;
+
+import com.googlecode.opennars.language.logic.Term;
+
+/**
+ * <p>
+ * A <code>Nameable</code> object is one which can be asked for a name which
+ * may be used in the reasoner. A name is some term.
+ * </p>
+ * @author jgeldart
+ *
+ */
+public interface Namable {
+  
+  /**
+   * Fetch the name of the object.
+   * @return The object's name.
+   */
+  public Term getName();
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/control/ControlAction.java b/open-nars/src/com/googlecode/opennars/language/control/ControlAction.java
new file mode 100644
index 0000000..c557339
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/control/ControlAction.java
@@ -0,0 +1,23 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.control;
+
+import com.googlecode.opennars.language.Action;
+
+/**
+ * <p>
+ * An <code>Action</code> representing some extra-logical event or data
+ * being passed between <code>Area</code>s in an OpenNARS system. Examples
+ * of such data include instructions to change the parameters of a reasoner,
+ * requests for an external operation to be performed, etc. This interface
+ * has no additional members currently, but this is expected to change as
+ * we learn more about the sorts of control actions developers need.
+ * </p>
+ * 
+ * @author jgeldart
+ *
+ */
+public interface ControlAction extends Action {
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/control/LogicAction.java b/open-nars/src/com/googlecode/opennars/language/control/LogicAction.java
new file mode 100644
index 0000000..061776d
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/control/LogicAction.java
@@ -0,0 +1,65 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.control;
+
+import com.googlecode.opennars.language.Action;
+
+/**
+ * <p>
+ * A <code>LogicAction</code> represents some logical information being sent
+ * between <code>Area</code>s in OpenNARS. Implementations of this interface
+ * are things such as goals, questions and judgements.
+ * </p>
+ * <p>
+ * In order to better support compositional inferencing and other catamorphic
+ * operations, this interface includes an inner interface for the visitor
+ * pattern.
+ * </p>
+ * @author jgeldart
+ *
+ */
+public interface LogicAction extends Action {
+  
+  /**
+   * <p>
+   * An interface used in the visitor pattern over <code>LogicAction</code>s.
+   * </p>
+   * @author jgeldart
+   *
+   * @param <R> The result type from the visit operation.
+   * @param <A> The type of the argument passed through the visiting.
+   */
+  public interface Visitor<R,A> {
+    
+    /**
+     * <p>
+     * Visit a <code>LogicAction</code> with the given argument object
+     * and return a result. The argument object is typically used to
+     * wire through some necessary state to all the visit operations performed.
+     * </p>
+     * @param <R> The type of the result.
+     * @param <A> The type of the argument object.
+     * @param act The <code>LogicAction</code> being visited.
+     * @param argument The argument object being used in the visiting.
+     * @return Some result of type R.
+     */
+    public R visit(LogicAction act, A argument);
+    
+  }
+  
+  /**
+   * <p>
+   * The other half of the visitor design pattern consists of
+   * <code>LogicAction</code>s accepting a visitor upon themselves.
+   * The visitor is executed and a result is returned.
+   * </p>
+   * @param <R> The result type.
+   * @param <A> The argument type.
+   * @param visitor The visitor to be used.
+   * @param argument The argument structure used for wiring state.
+   * @return Some result of type R.
+   */
+  public <R,A> R accept(Visitor<R,A> visitor, A argument); 
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/control/Sentence.java b/open-nars/src/com/googlecode/opennars/language/control/Sentence.java
new file mode 100644
index 0000000..077ea24
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/control/Sentence.java
@@ -0,0 +1,93 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.control;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.googlecode.opennars.language.logic.Term;
+import com.googlecode.opennars.language.logic.TruthValue;
+
+/**
+ * The base class of all speech act type actions. A speech act includes such
+ * things as telling, asking, commanding, etc.
+ * 
+ * @author jgeldart
+ *
+ */
+public abstract class Sentence implements LogicAction {
+  
+  private Map<String, Object> metadata;
+  private Term content;
+  private TruthValue truth;
+
+  public interface SentenceVisitor<R,A> extends Visitor<R, A> {
+    
+    public R visit(Sentence p, A arg);
+    
+  }
+  
+  public Sentence(Term term) {
+    this.metadata = new HashMap<String,Object>();
+    this.content = term;
+    this.truth = null;
+  }
+  
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.LogicAction#accept(com.googlecode.opennars.language.logic.LogicAction.Visitor, java.lang.Object)
+   */
+  public abstract <R, A> R accept(SentenceVisitor<R, A> visitor, A argument);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.Action#getMetadata()
+   */
+  public Map<String, Object> getMetadata() {
+    return new HashMap<String,Object>(this.metadata);
+  }
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.Action#getMetadataByKey(java.lang.String)
+   */
+  public Object getMetadataByKey(String key) {
+    return this.metadata.get(key);
+  }
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.Action#replaceMetadata(java.util.Map)
+   */
+  public void replaceMetadata(Map<String, Object> meta) {
+    this.metadata = new HashMap<String,Object>(meta);
+  }
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.Action#setMetadataByKey(java.lang.String, java.lang.Object)
+   */
+  public void setMetadataByKey(String key, Object meta) {
+    this.metadata.put(key, meta);
+  }
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.LogicAction#accept(com.googlecode.opennars.language.logic.LogicAction.Visitor, java.lang.Object)
+   */
+  public <R, A> R accept(Visitor<R, A> visitor, A argument) {
+    return visitor.visit(this, argument);
+  }
+
+  /**
+   * Set the truth value of this sentence.
+   * @param truth The truth value to set.
+   */
+  public void setTruth(TruthValue truth) {
+    this.truth = truth;
+  }
+
+  /**
+   * Get the truth value of this sentence.
+   * @return the truth value.
+   */
+  public TruthValue getTruth() {
+    return truth;
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/AbstractLogicVisitor.java b/open-nars/src/com/googlecode/opennars/language/logic/AbstractLogicVisitor.java
new file mode 100644
index 0000000..4ffa82c
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/AbstractLogicVisitor.java
@@ -0,0 +1,162 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+/**
+ * @author jgeldart
+ * 
+ * @param <R> 
+ * @param <A> 
+ *
+ */
+public abstract class AbstractLogicVisitor<R,A> implements LogicVisitor<R,A> {
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.StringLiteral.StringLiteralVisitor#visit(com.googlecode.opennars.language.logic.StringLiteral, java.lang.Object)
+   */
+  public abstract R visit(StringLiteral p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.SequentialConjunction.SequentialConjunctionVisitor#visit(com.googlecode.opennars.language.logic.SequentialConjunction, java.lang.Object)
+   */
+  public abstract R visit(SequentialConjunction p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.Negation.NegationVisitor#visit(com.googlecode.opennars.language.logic.Negation, java.lang.Object)
+   */
+  public abstract R visit(Negation p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.Similarity.SimilarityVisitor#visit(com.googlecode.opennars.language.logic.Similarity, java.lang.Object)
+   */
+  public abstract R visit(Similarity p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.Disjunction.DisjunctionVisitor#visit(com.googlecode.opennars.language.logic.Disjunction, java.lang.Object)
+   */
+  public abstract R visit(Disjunction p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.BooleanLiteral.BooleanLiteralVisitor#visit(com.googlecode.opennars.language.logic.BooleanLiteral, java.lang.Object)
+   */
+  public abstract R visit(BooleanLiteral p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.ParallelConjunction.ParallelConjunctionVisitor#visit(com.googlecode.opennars.language.logic.ParallelConjunction, java.lang.Object)
+   */
+  public abstract R visit(ParallelConjunction p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.ExtSet.ExtSetVisitor#visit(com.googlecode.opennars.language.logic.ExtSet, java.lang.Object)
+   */
+  public abstract R visit(ExtSet p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.ExtIntersection.ExtIntersectionVisitor#visit(com.googlecode.opennars.language.logic.ExtIntersection, java.lang.Object)
+   */
+  public abstract R visit(ExtIntersection p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.ExtDifference.ExtDifferenceVisitor#visit(com.googlecode.opennars.language.logic.ExtDifference, java.lang.Object)
+   */
+  public abstract R visit(ExtDifference p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.NumericLiteral.NumericLiteralVisitor#visit(com.googlecode.opennars.language.logic.NumericLiteral, java.lang.Object)
+   */
+  public abstract R visit(NumericLiteral p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.IndependentVariable.IndependentVariableVisitor#visit(com.googlecode.opennars.language.logic.IndependentVariable, java.lang.Object)
+   */
+  public abstract R visit(IndependentVariable p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.PastTense.PastTenseVisitor#visit(com.googlecode.opennars.language.logic.PastTense, java.lang.Object)
+   */
+  public abstract R visit(PastTense p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.FutureTense.FutureTenseVisitor#visit(com.googlecode.opennars.language.logic.FutureTense, java.lang.Object)
+   */
+  public abstract R visit(FutureTense p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.QueryVariable.QueryVariableVisitor#visit(com.googlecode.opennars.language.logic.QueryVariable, java.lang.Object)
+   */
+  public abstract R visit(QueryVariable p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.IntImage.IntImageVisitor#visit(com.googlecode.opennars.language.logic.IntImage, java.lang.Object)
+   */
+  public abstract R visit(IntImage p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.Inheritance.InheritanceVisitor#visit(com.googlecode.opennars.language.logic.Inheritance, java.lang.Object)
+   */
+  public abstract R visit(Inheritance p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.URIReference.URIReferenceVisitor#visit(com.googlecode.opennars.language.logic.URIReference, java.lang.Object)
+   */
+  public abstract R visit(URIReference p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.PresentTense.PresentTenseVisitor#visit(com.googlecode.opennars.language.logic.PresentTense, java.lang.Object)
+   */
+  public abstract R visit(PresentTense p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.IntDifference.IntDifferenceVisitor#visit(com.googlecode.opennars.language.logic.IntDifference, java.lang.Object)
+   */
+  public abstract R visit(IntDifference p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.Equivalence.EquivalenceVisitor#visit(com.googlecode.opennars.language.logic.Equivalence, java.lang.Object)
+   */
+  public abstract R visit(Equivalence p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.Conjunction.ConjunctionVisitor#visit(com.googlecode.opennars.language.logic.Conjunction, java.lang.Object)
+   */
+  public abstract R visit(Conjunction p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.ExtImage.ExtImageVisitor#visit(com.googlecode.opennars.language.logic.ExtImage, java.lang.Object)
+   */
+  public abstract R visit(ExtImage p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.Implication.ImplicationVisitor#visit(com.googlecode.opennars.language.logic.Implication, java.lang.Object)
+   */
+  public abstract R visit(Implication p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.IntIntersection.IntIntersectionVisitor#visit(com.googlecode.opennars.language.logic.IntIntersection, java.lang.Object)
+   */
+  public abstract R visit(IntIntersection p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.IntSet.IntSetVisitor#visit(com.googlecode.opennars.language.logic.IntSet, java.lang.Object)
+   */
+  public abstract R visit(IntSet p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.Product.ProductVisitor#visit(com.googlecode.opennars.language.logic.Product, java.lang.Object)
+   */
+  public abstract R visit(Product p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.DependentVariable.DependentVariableVisitor#visit(com.googlecode.opennars.language.logic.DependentVariable, java.lang.Object)
+   */
+  public abstract R visit(DependentVariable p, A arg);
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.Term.Visitor#visit(com.googlecode.opennars.language.logic.Term, java.lang.Object)
+   */
+  public R visit(Term act, A arg) {
+    return null;
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/AtomicTerm.java b/open-nars/src/com/googlecode/opennars/language/logic/AtomicTerm.java
new file mode 100644
index 0000000..90e9214
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/AtomicTerm.java
@@ -0,0 +1,14 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+/**
+ * The (abstract) base class of all atomic terms (terms with no components).
+ * @author jgeldart
+ *
+ */
+public abstract class AtomicTerm extends Term {
+
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/BooleanLiteral.java b/open-nars/src/com/googlecode/opennars/language/logic/BooleanLiteral.java
new file mode 100644
index 0000000..1c8cd4e
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/BooleanLiteral.java
@@ -0,0 +1,86 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+/**
+ * A boolean literal term, for those domains which require it.
+ * 
+ * @author jgeldart
+ *
+ */
+public class BooleanLiteral extends LiteralTerm {
+
+  private boolean booleanTerm;
+  
+  /**
+   * <p>
+   * A visitor for boolean literals.
+   * </p>
+   * @author jgeldart
+   *
+   * @param <R> The visitor return type.
+   * @param <A> The visitor argument structure type.
+   */
+  public interface BooleanLiteralVisitor<R,A> extends Visitor<R,A> {
+    
+    /**
+     * <p>
+     * Implement this method to provide the core of the visitor's algorithm.
+     * </p>
+     * @param p The literal being visited.
+     * @param arg The argument structure being threaded through.
+     * @return An object of type R.
+     */
+    public R visit(BooleanLiteral p, A arg);
+    
+  }
+  
+  /**
+   * <p>
+   * Accept a visitor and invoke it on this literal.
+   * </p>
+   * @param <R> The return type of the visitor.
+   * @param <A> The argument structure type of the visitor.
+   * @param visitor The visitor being called.
+   * @param arg The argument structure being threaded through.
+   * @return An object of type R.
+   */
+  public<R,A> R accept(BooleanLiteralVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+  
+  /**
+   * <p>
+   * Create a new boolean literal.
+   * </p>
+   * @param b The boolean to use.
+   */
+  public BooleanLiteral(boolean b) {
+    this.booleanTerm = b;
+    this.setLiteralTruthDelegate(new IdentityTruthDelegate());
+  }
+  
+  /**
+   * <p>
+   * Create a new boolean literal with the given literal truth delegate.
+   * </p>
+   * @param b The boolean to use.
+   * @param delegate The delegate.
+   */
+  public BooleanLiteral(boolean b, LiteralTruthDelegate delegate) {
+    this.booleanTerm = b;
+    this.setLiteralTruthDelegate(delegate);
+  }
+
+  /**
+   * <p>
+   * Get the value of this literal as a boolean.
+   * </p>
+   * @return The boolean term.
+   */
+  public boolean getBooleanTerm() {
+    return booleanTerm;
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/CompoundTerm.java b/open-nars/src/com/googlecode/opennars/language/logic/CompoundTerm.java
new file mode 100644
index 0000000..bc5b854
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/CompoundTerm.java
@@ -0,0 +1,64 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * The (abstract) base class of all compound terms.
+ * </p>
+ * @author jgeldart
+ *
+ */
+public abstract class CompoundTerm extends Term {
+  
+  private List<Term> components;
+  
+  /**
+   * <p>
+   * Create a new compound term from a list of components.
+   * </p>
+   * @param cs The list of components.
+   */
+  public CompoundTerm(List<Term> cs) {
+    this.components = cs;
+  }
+  
+  /**
+   * <p>
+   * Create a new compound term with a single component.
+   * </p>
+   * @param t The term to use.
+   */
+  public CompoundTerm(Term t) {
+    this.components = new ArrayList<Term>();
+    this.components.add(t);
+  }
+  
+  /**
+   * <p>
+   * Create a new compound term with two components.
+   * </p>
+   * @param t1 The first component.
+   * @param t2 The second component.
+   */
+  public CompoundTerm(Term t1, Term t2) {
+    this.components = new ArrayList<Term>();
+    this.components.add(t1);
+    this.components.add(t2);
+  }
+  
+  /**
+   * <p>
+   * Get the components of this compound term.
+   * </p>
+   * @return The components.
+   */
+  public List<Term> getComponents() {
+    return this.components;
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/Conjunction.java b/open-nars/src/com/googlecode/opennars/language/logic/Conjunction.java
new file mode 100644
index 0000000..bfb10d0
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/Conjunction.java
@@ -0,0 +1,79 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class Conjunction extends CompoundTerm {
+
+  /**
+   * <p>
+   * Construct a conjunction from a list of conjunctions.
+   * </p>
+   * @param cs The conjuncts to use.
+   */
+  public Conjunction(List<Term> cs) {
+    super(cs);
+  }
+  
+  /**
+   * <p>
+   * Construct a conjunction of a single term.
+   * </p>
+   * @param t The conjunct.
+   */
+  public Conjunction(Term t) {
+    super(t);
+  }
+  
+  /**
+   * <p>
+   * Construct a conjunction of two conjuncts.
+   * </p>
+   * @param t1 The first conjunct.
+   * @param t2 The second conjunct.
+   */
+  public Conjunction(Term t1, Term t2) {
+    super(t1, t2);
+  }
+
+  /**
+   * <p>
+   * A visitor on <code>Conjunction</code>s.
+   * </p>
+   * @author jgeldart
+   *
+   * @param <R> The return type of the visitor.
+   * @param <A> The argument structure type of the visitor.
+   */
+  public interface ConjunctionVisitor<R,A> extends Visitor<R,A> {
+    /**
+     * <p>
+     * Visit a <code>Conjunction</code>.
+     * @param p The conjunction.
+     * @param arg The argument structure being threaded through.
+     * @return An object of type R.
+     */
+    public R visit(Conjunction p, A arg);
+  }
+  
+  /**
+   * <p>
+   * Accept a visitor and invoke it.
+   * </p>
+   * @param <R> The return type of the visitor.
+   * @param <A> The argument structure type of the visitor.
+   * @param visitor The visitor.
+   * @param arg The argument structure being threaded through.
+   * @return An object of type R.
+   */
+  public<R,A> R accept(ConjunctionVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/DependentVariable.java b/open-nars/src/com/googlecode/opennars/language/logic/DependentVariable.java
new file mode 100644
index 0000000..5a26278
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/DependentVariable.java
@@ -0,0 +1,21 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+/**
+ * A dependent variable, used in NAL-5 and up for higher-order reasoning.
+ * @author jgeldart
+ *
+ */
+public class DependentVariable extends Variable {
+
+  public interface DependentVariableVisitor<R,A> extends Visitor<R,A> {
+    public R visit(DependentVariable p, A arg);
+  }
+  
+  public<R,A> R accept(DependentVariableVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/Disjunction.java b/open-nars/src/com/googlecode/opennars/language/logic/Disjunction.java
new file mode 100644
index 0000000..4ad9d37
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/Disjunction.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class Disjunction extends CompoundTerm {
+
+  public interface DisjunctionVisitor<R,A> extends Visitor<R,A> {
+    public R visit(Disjunction p, A arg);
+  }
+  
+  public<R,A> R accept(DisjunctionVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public Disjunction(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public Disjunction(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public Disjunction(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/Equivalence.java b/open-nars/src/com/googlecode/opennars/language/logic/Equivalence.java
new file mode 100644
index 0000000..7d07c78
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/Equivalence.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class Equivalence extends Statement {
+  
+  public interface EquivalenceVisitor<R,A> extends Visitor<R,A> {
+    public R visit(Equivalence p, A arg);
+  }
+  
+  public<R,A> R accept(EquivalenceVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public Equivalence(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public Equivalence(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public Equivalence(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/ExtDifference.java b/open-nars/src/com/googlecode/opennars/language/logic/ExtDifference.java
new file mode 100644
index 0000000..da5be23
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/ExtDifference.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class ExtDifference extends CompoundTerm {
+
+  public interface ExtDifferenceVisitor<R,A> extends Visitor<R,A> {
+    public R visit(ExtDifference p, A arg);
+  }
+  
+  public<R,A> R accept(ExtDifferenceVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public ExtDifference(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public ExtDifference(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public ExtDifference(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/ExtImage.java b/open-nars/src/com/googlecode/opennars/language/logic/ExtImage.java
new file mode 100644
index 0000000..f9795ed
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/ExtImage.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class ExtImage extends CompoundTerm {
+  
+  public interface ExtImageVisitor<R,A> extends Visitor<R,A> {
+    public R visit(ExtImage p, A arg);
+  }
+  
+  public<R,A> R accept(ExtImageVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public ExtImage(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public ExtImage(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public ExtImage(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/ExtIntersection.java b/open-nars/src/com/googlecode/opennars/language/logic/ExtIntersection.java
new file mode 100644
index 0000000..abe4c23
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/ExtIntersection.java
@@ -0,0 +1,85 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * <p>
+ * Represents an extensional intersection.
+ * </p>
+ * 
+ * @author jgeldart
+ * 
+ */
+public class ExtIntersection extends CompoundTerm {
+  
+  /**
+   * <p>
+   * A visitor on extensional intersections.
+   * </p>
+   * @author jgeldart
+   *
+   * @param <R> The return type of the visitor.
+   * @param <A> The argument structure type of the visitor.
+   */
+  public interface ExtIntersectionVisitor<R,A> extends Visitor<R,A> {
+    
+    /**
+     * <p>
+     * Visits an extensional intersection.
+     * </p>
+     * @param p The extensional intersection.
+     * @param arg The argument structure being threaded through the visitor.
+     * @return An object of type R.
+     */
+    public R visit(ExtIntersection p, A arg);
+  }
+  
+  /**
+   * <p>
+   * Accepts an <code>ExtIntersectionVisitor</code>
+   * </p>
+   * @param <R> The return type of the visitor.
+   * @param <A> The argument structure type of the visitor.
+   * @param visitor The visitor.
+   * @param arg The argument structure being threaded through the visitor
+   * @return An object of type R.
+   */
+  public<R,A> R accept(ExtIntersectionVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * <p>
+   * Create a new extensional intersection from a list of intersectands.
+   * </p>
+   * @param cs The intersectands.
+   */
+  public ExtIntersection(List<Term> cs) {
+    super(cs);
+  }
+
+  /**
+   * <p>
+   * Create a new extensional intersection from a pair of intersectand terms.
+   * </p>
+   * @param t1 The first intersectand.
+   * @param t2 The second intersectand.
+   */
+  public ExtIntersection(Term t1, Term t2) {
+    super(t1, t2);
+  }
+
+  /**
+   * <p>
+   * Create a new extensional intersection from a single intersectand term.
+   * </p>
+   * @param t The intersectand.
+   */
+  public ExtIntersection(Term t) {
+    super(t);
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/ExtSet.java b/open-nars/src/com/googlecode/opennars/language/logic/ExtSet.java
new file mode 100644
index 0000000..b0bb6aa
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/ExtSet.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class ExtSet extends CompoundTerm {
+  
+  public interface ExtSetVisitor<R,A> extends Visitor<R,A> {
+    public R visit(ExtSet p, A arg);
+  }
+  
+  public<R,A> R accept(ExtSetVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public ExtSet(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public ExtSet(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public ExtSet(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/FutureTense.java b/open-nars/src/com/googlecode/opennars/language/logic/FutureTense.java
new file mode 100644
index 0000000..468062b
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/FutureTense.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class FutureTense extends CompoundTerm {
+
+  public interface FutureTenseVisitor<R,A> extends Visitor<R,A> {
+    public R visit(FutureTense p, A arg);
+  }
+  
+  public<R,A> R accept(FutureTenseVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public FutureTense(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public FutureTense(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public FutureTense(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/IdentityTruthDelegate.java b/open-nars/src/com/googlecode/opennars/language/logic/IdentityTruthDelegate.java
new file mode 100644
index 0000000..32ca71f
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/IdentityTruthDelegate.java
@@ -0,0 +1,32 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+/**
+ * Treats object equality (in the Java sense) as the defining condition of
+ * similarity.
+ * 
+ * @author jgeldart
+ *
+ */
+public class IdentityTruthDelegate implements LiteralTruthDelegate {
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.LiteralTruthDelegate#getInheritance(com.googlecode.opennars.language.logic.LiteralTerm, com.googlecode.opennars.language.logic.LiteralTerm)
+   */
+  public TruthValue getInheritance(LiteralTerm t1, LiteralTerm t2) {
+    if(t1.equals(t2))
+      return new TruthValue(1,1);
+    else
+      return new TruthValue(0,1);
+  }
+
+  /* (non-Javadoc)
+   * @see com.googlecode.opennars.language.logic.LiteralTruthDelegate#getSimilarity(com.googlecode.opennars.language.logic.LiteralTerm, com.googlecode.opennars.language.logic.LiteralTerm)
+   */
+  public TruthValue getSimilarity(LiteralTerm t1, LiteralTerm t2) {
+    return this.getInheritance(t1, t2);
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/Implication.java b/open-nars/src/com/googlecode/opennars/language/logic/Implication.java
new file mode 100644
index 0000000..1516cf7
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/Implication.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class Implication extends Statement {
+  
+  public interface ImplicationVisitor<R,A> extends Visitor<R,A> {
+    public R visit(Implication p, A arg);
+  }
+  
+  public<R,A> R accept(ImplicationVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public Implication(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public Implication(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public Implication(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/IndependentVariable.java b/open-nars/src/com/googlecode/opennars/language/logic/IndependentVariable.java
new file mode 100644
index 0000000..604f18d
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/IndependentVariable.java
@@ -0,0 +1,22 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+/**
+ * An independent variable, used in NAL-5 and up for higher-order reasoning.
+ * 
+ * @author jgeldart
+ *
+ */
+public class IndependentVariable extends Variable {
+
+  public interface IndependentVariableVisitor<R,A> extends Visitor<R,A> {
+    public R visit(IndependentVariable p, A arg);
+  }
+  
+  public<R,A> R accept(IndependentVariableVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/Inheritance.java b/open-nars/src/com/googlecode/opennars/language/logic/Inheritance.java
new file mode 100644
index 0000000..36edd62
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/Inheritance.java
@@ -0,0 +1,46 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class Inheritance extends Statement {
+
+  public interface InheritanceVisitor<R,A> extends Visitor<R,A> {
+    public R visit(Inheritance p, A arg);
+  }
+  
+  public<R,A> R accept(InheritanceVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public Inheritance(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public Inheritance(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public Inheritance(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/IntDifference.java b/open-nars/src/com/googlecode/opennars/language/logic/IntDifference.java
new file mode 100644
index 0000000..49a8b05
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/IntDifference.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class IntDifference extends CompoundTerm {
+
+  public interface IntDifferenceVisitor<R,A> extends Visitor<R,A> {
+    public R visit(IntDifference p, A arg);
+  }
+  
+  public<R,A> R accept(IntDifferenceVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public IntDifference(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public IntDifference(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public IntDifference(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/IntImage.java b/open-nars/src/com/googlecode/opennars/language/logic/IntImage.java
new file mode 100644
index 0000000..90e018d
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/IntImage.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class IntImage extends CompoundTerm {
+  
+  public interface IntImageVisitor<R,A> extends Visitor<R,A> {
+    public R visit(IntImage p, A arg);
+  }
+  
+  public<R,A> R accept(IntImageVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public IntImage(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public IntImage(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public IntImage(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/IntIntersection.java b/open-nars/src/com/googlecode/opennars/language/logic/IntIntersection.java
new file mode 100644
index 0000000..2045f36
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/IntIntersection.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class IntIntersection extends CompoundTerm {
+  
+  public interface IntIntersectionVisitor<R,A> extends Visitor<R,A> {
+    public R visit(IntIntersection p, A arg);
+  }
+  
+  public<R,A> R accept(IntIntersectionVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public IntIntersection(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public IntIntersection(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public IntIntersection(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/IntSet.java b/open-nars/src/com/googlecode/opennars/language/logic/IntSet.java
new file mode 100644
index 0000000..77cc14d
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/IntSet.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class IntSet extends CompoundTerm {
+  
+  public interface IntSetVisitor<R,A> extends Visitor<R,A> {
+    public R visit(IntSet p, A arg);
+  }
+  
+  public<R,A> R accept(IntSetVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public IntSet(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public IntSet(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public IntSet(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/LiteralTerm.java b/open-nars/src/com/googlecode/opennars/language/logic/LiteralTerm.java
new file mode 100644
index 0000000..5eab520
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/LiteralTerm.java
@@ -0,0 +1,52 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.net.URI;
+
+/**
+ * The (abstract) base class of all literal terms such as strings, numbers,
+ * boolean truth values (for those domains which need it) and less common terms
+ * such as XML documents, images, etc.
+ * 
+ * Literal terms include a reference to a delegate object which computes
+ * literal truth similarity and inheritance of two literals. This may be used
+ * to provide a bridge between an axiomatic world and NARS, or to provide a
+ * means of adding physical world measures of similarity. An example of this
+ * would be a similarity measure on images which computes a metric such as
+ * the vector space distance between their eigenvectors relative to a base
+ * (potentially useful in image recognition applications) or one which computes
+ * the Hamming distance between two strings. The default delegate for each
+ * literal in this library should return %1;1% if the terms are equal and %0;1%
+ * otherwise. The use of this delegate for inheritance allows the use of things
+ * like tree containment in XML as a measure of inheritance.
+ * @author jgeldart
+ *
+ */
+public abstract class LiteralTerm extends AtomicTerm {
+  
+  private LiteralTruthDelegate literalTruthDelegate;
+  private URI type;
+  
+  /**
+   * Return the literal truth delegate of the literal term.
+   * @return The literal truth delegate.
+   */
+  public LiteralTruthDelegate getLiteralTruthDelegate() {
+    return this.literalTruthDelegate;
+  }
+  
+  public void setLiteralTruthDelegate(LiteralTruthDelegate delegate) {
+    this.literalTruthDelegate = delegate;
+  }
+  
+  public TruthValue getSimilarity(LiteralTerm t) {
+    return this.literalTruthDelegate.getSimilarity(this, t);
+  }
+  
+  public TruthValue getInheritance(LiteralTerm t) {
+    return this.literalTruthDelegate.getInheritance(this, t);
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/LiteralTruthDelegate.java b/open-nars/src/com/googlecode/opennars/language/logic/LiteralTruthDelegate.java
new file mode 100644
index 0000000..9b59dae
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/LiteralTruthDelegate.java
@@ -0,0 +1,16 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+/**
+ * Computes the similarity and inheritance truth value of two literal terms.
+ * @author jgeldart
+ *
+ */
+public interface LiteralTruthDelegate {
+
+  public TruthValue getSimilarity(LiteralTerm t1, LiteralTerm t2);
+  public TruthValue getInheritance(LiteralTerm t1, LiteralTerm t2);
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/LogicVisitor.java b/open-nars/src/com/googlecode/opennars/language/logic/LogicVisitor.java
new file mode 100644
index 0000000..3eef075
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/LogicVisitor.java
@@ -0,0 +1,54 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import com.googlecode.opennars.language.logic.BooleanLiteral.BooleanLiteralVisitor;
+import com.googlecode.opennars.language.logic.Conjunction.ConjunctionVisitor;
+import com.googlecode.opennars.language.logic.DependentVariable.DependentVariableVisitor;
+import com.googlecode.opennars.language.logic.Disjunction.DisjunctionVisitor;
+import com.googlecode.opennars.language.logic.Equivalence.EquivalenceVisitor;
+import com.googlecode.opennars.language.logic.ExtDifference.ExtDifferenceVisitor;
+import com.googlecode.opennars.language.logic.ExtImage.ExtImageVisitor;
+import com.googlecode.opennars.language.logic.ExtIntersection.ExtIntersectionVisitor;
+import com.googlecode.opennars.language.logic.ExtSet.ExtSetVisitor;
+import com.googlecode.opennars.language.logic.FutureTense.FutureTenseVisitor;
+import com.googlecode.opennars.language.logic.Implication.ImplicationVisitor;
+import com.googlecode.opennars.language.logic.IndependentVariable.IndependentVariableVisitor;
+import com.googlecode.opennars.language.logic.Inheritance.InheritanceVisitor;
+import com.googlecode.opennars.language.logic.IntDifference.IntDifferenceVisitor;
+import com.googlecode.opennars.language.logic.IntImage.IntImageVisitor;
+import com.googlecode.opennars.language.logic.IntIntersection.IntIntersectionVisitor;
+import com.googlecode.opennars.language.logic.IntSet.IntSetVisitor;
+import com.googlecode.opennars.language.logic.Negation.NegationVisitor;
+import com.googlecode.opennars.language.logic.NumericLiteral.NumericLiteralVisitor;
+import com.googlecode.opennars.language.logic.ParallelConjunction.ParallelConjunctionVisitor;
+import com.googlecode.opennars.language.logic.PastTense.PastTenseVisitor;
+import com.googlecode.opennars.language.logic.PresentTense.PresentTenseVisitor;
+import com.googlecode.opennars.language.logic.Product.ProductVisitor;
+import com.googlecode.opennars.language.logic.QueryVariable.QueryVariableVisitor;
+import com.googlecode.opennars.language.logic.SequentialConjunction.SequentialConjunctionVisitor;
+import com.googlecode.opennars.language.logic.Similarity.SimilarityVisitor;
+import com.googlecode.opennars.language.logic.StringLiteral.StringLiteralVisitor;
+import com.googlecode.opennars.language.logic.URIReference.URIReferenceVisitor;
+
+/**
+ * @author jgeldart
+ *
+ */
+public interface LogicVisitor<R,A> extends BooleanLiteralVisitor<R, A>,
+    ConjunctionVisitor<R, A>, DependentVariableVisitor<R, A>,
+    DisjunctionVisitor<R, A>, EquivalenceVisitor<R, A>,
+    ExtDifferenceVisitor<R, A>, ExtImageVisitor<R, A>,
+    ExtIntersectionVisitor<R, A>, ExtSetVisitor<R, A>,
+    FutureTenseVisitor<R, A>, ImplicationVisitor<R, A>,
+    IndependentVariableVisitor<R, A>, InheritanceVisitor<R, A>,
+    IntDifferenceVisitor<R, A>, IntImageVisitor<R, A>,
+    IntIntersectionVisitor<R, A>, IntSetVisitor<R, A>, NegationVisitor<R, A>,
+    NumericLiteralVisitor<R, A>, ParallelConjunctionVisitor<R, A>,
+    PastTenseVisitor<R, A>, PresentTenseVisitor<R, A>, ProductVisitor<R, A>,
+    QueryVariableVisitor<R, A>, SequentialConjunctionVisitor<R, A>,
+    SimilarityVisitor<R, A>, StringLiteralVisitor<R, A>,
+    URIReferenceVisitor<R, A> {
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/Negation.java b/open-nars/src/com/googlecode/opennars/language/logic/Negation.java
new file mode 100644
index 0000000..91d36fa
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/Negation.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class Negation extends CompoundTerm {
+  
+  public interface NegationVisitor<R,A> extends Visitor<R,A> {
+    public R visit(Negation p, A arg);
+  }
+  
+  public<R,A> R accept(NegationVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public Negation(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public Negation(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public Negation(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/NumericLiteral.java b/open-nars/src/com/googlecode/opennars/language/logic/NumericLiteral.java
new file mode 100644
index 0000000..c43d95c
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/NumericLiteral.java
@@ -0,0 +1,22 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class NumericLiteral extends LiteralTerm {
+  
+  private Number num;
+  
+  public interface NumericLiteralVisitor<R,A> extends Visitor<R,A> {
+    public R visit(NumericLiteral p, A arg);
+  }
+  
+  public<R,A> R accept(NumericLiteralVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/ParallelConjunction.java b/open-nars/src/com/googlecode/opennars/language/logic/ParallelConjunction.java
new file mode 100644
index 0000000..ff7143d
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/ParallelConjunction.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class ParallelConjunction extends CompoundTerm {
+
+  public interface ParallelConjunctionVisitor<R,A> extends Visitor<R,A> {
+    public R visit(ParallelConjunction p, A arg);
+  }
+  
+  public<R,A> R accept(ParallelConjunctionVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public ParallelConjunction(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public ParallelConjunction(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public ParallelConjunction(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/PastTense.java b/open-nars/src/com/googlecode/opennars/language/logic/PastTense.java
new file mode 100644
index 0000000..fb4f9c6
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/PastTense.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class PastTense extends CompoundTerm {
+
+  public interface PastTenseVisitor<R,A> extends Visitor<R,A> {
+    public R visit(PastTense p, A arg);
+  }
+  
+  public<R,A> R accept(PastTenseVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public PastTense(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public PastTense(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public PastTense(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/PresentTense.java b/open-nars/src/com/googlecode/opennars/language/logic/PresentTense.java
new file mode 100644
index 0000000..83ec035
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/PresentTense.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class PresentTense extends CompoundTerm {
+
+  public interface PresentTenseVisitor<R,A> extends Visitor<R,A> {
+    public R visit(PresentTense p, A arg);
+  }
+  
+  public<R,A> R accept(PresentTenseVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public PresentTense(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public PresentTense(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public PresentTense(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/Product.java b/open-nars/src/com/googlecode/opennars/language/logic/Product.java
new file mode 100644
index 0000000..6202d68
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/Product.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class Product extends CompoundTerm {
+
+  public interface ProductVisitor<R,A> extends Visitor<R,A> {
+    public R visit(Product p, A arg);
+  }
+  
+  public<R,A> R accept(ProductVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public Product(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public Product(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public Product(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/QueryVariable.java b/open-nars/src/com/googlecode/opennars/language/logic/QueryVariable.java
new file mode 100644
index 0000000..f70c80e
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/QueryVariable.java
@@ -0,0 +1,22 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+/**
+ * A query variable, used in <code>Question</code> sentences to indicate a
+ * 'hole' to be filled by the reasoner. 
+ * @author jgeldart
+ *
+ */
+public class QueryVariable extends Variable {
+  
+  public interface QueryVariableVisitor<R,A> extends Visitor<R,A> {
+    public R visit(QueryVariable p, A arg);
+  }
+  
+  public<R,A> R accept(QueryVariableVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/SequentialConjunction.java b/open-nars/src/com/googlecode/opennars/language/logic/SequentialConjunction.java
new file mode 100644
index 0000000..9049d60
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/SequentialConjunction.java
@@ -0,0 +1,47 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class SequentialConjunction extends CompoundTerm {
+
+  public interface SequentialConjunctionVisitor<R,A> extends Visitor<R,A> {
+    public R visit(SequentialConjunction p, A arg);
+  }
+  
+  public<R,A> R accept(SequentialConjunctionVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public SequentialConjunction(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public SequentialConjunction(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public SequentialConjunction(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/Similarity.java b/open-nars/src/com/googlecode/opennars/language/logic/Similarity.java
new file mode 100644
index 0000000..d957069
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/Similarity.java
@@ -0,0 +1,46 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class Similarity extends Statement {
+
+  public interface SimilarityVisitor<R,A> extends Visitor<R,A> {
+    public R visit(Similarity p, A arg);
+  }
+  
+  public<R,A> R accept(SimilarityVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  /**
+   * @param cs
+   */
+  public Similarity(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public Similarity(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public Similarity(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/Statement.java b/open-nars/src/com/googlecode/opennars/language/logic/Statement.java
new file mode 100644
index 0000000..91e8b21
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/Statement.java
@@ -0,0 +1,39 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.util.List;
+
+/**
+ * @author jgeldart
+ *
+ */
+public abstract class Statement extends CompoundTerm {
+
+  /**
+   * @param cs
+   */
+  public Statement(List<Term> cs) {
+    super(cs);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t1
+   * @param t2
+   */
+  public Statement(Term t1, Term t2) {
+    super(t1, t2);
+    // TODO Auto-generated constructor stub
+  }
+
+  /**
+   * @param t
+   */
+  public Statement(Term t) {
+    super(t);
+    // TODO Auto-generated constructor stub
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/StringLiteral.java b/open-nars/src/com/googlecode/opennars/language/logic/StringLiteral.java
new file mode 100644
index 0000000..8a2aef0
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/StringLiteral.java
@@ -0,0 +1,25 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.net.URI;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class StringLiteral extends LiteralTerm {
+  
+  private String content;
+  private String lang;
+  
+  public interface StringLiteralVisitor<R,A> extends Visitor<R,A> {
+    public R visit(StringLiteral p, A arg);
+  }
+  
+  public<R,A> R accept(StringLiteralVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/Term.java b/open-nars/src/com/googlecode/opennars/language/logic/Term.java
new file mode 100644
index 0000000..668ab19
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/Term.java
@@ -0,0 +1,53 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+/**
+ * <p>
+ * This class is the (abstract) base class of all fully logical language items.
+ * </p>
+ * @author jgeldart
+ *
+ */
+public abstract class Term {
+
+  /**
+   * <p>
+   * A visitor on <code>Term</code>s.
+   * </p> 
+   * @author jgeldart
+   *
+   * @param <R> The return type of the visitor.
+   * @param <A> The type of the argument object for the visitor.
+   */
+  public interface Visitor<R,A> {
+    
+    /**
+     * <p>
+     * Visit a given term with the current visitor object.
+     * </p>
+     * @param act The term to visit.
+     * @param arg The argument object passed through the visitor.
+     * @return A result of type R.
+     */
+    public R visit(Term act, A arg);
+    
+  }
+  
+  /** 
+   * <p>
+   * Accept a visitor on this term and invoke it.
+   * </p>
+   * @param visitor The visitor to invoke. 
+   * @param argument The argument structure being threaded through.
+   * @param <R> The return type of the visitor.
+   * @param <A> The argument structure type of the visitor.
+   * @return A result of type R.
+   * @see com.googlecode.opennars.language.logic.LogicAction#accept(com.googlecode.opennars.language.logic.LogicAction.Visitor, java.lang.Object)
+   */
+  public <R, A> R accept(Visitor<R, A> visitor, A argument) {
+    return visitor.visit(this, argument);
+  }
+  
+}
\ No newline at end of file
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/TruthValue.java b/open-nars/src/com/googlecode/opennars/language/logic/TruthValue.java
new file mode 100644
index 0000000..ffaa33d
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/TruthValue.java
@@ -0,0 +1,65 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+/**
+ * A NARS two-component truth value. Includes convenience methods for making
+ * a truth value in the form of a frequency and confidence, an evidence pair
+ * and an interval form. For these conversions, a value for the horizon
+ * parameter is required.
+ * 
+ * @author jgeldart
+ *
+ */
+public class TruthValue {
+  
+  private float frequency;
+  private float confidence;
+  
+  public TruthValue(float f, float c) {
+    this.frequency = f;
+    this.confidence = c;
+  }
+  
+  public float getFrequency() {
+    return this.frequency;
+  }
+  
+  public float getConfidence() {
+    return this.confidence;
+  }
+  
+  public float getLowerBound() {
+    return this.frequency * this.confidence;
+  }
+  
+  public float getUpperBound() {
+    return 1 - this.confidence * (1 - this.frequency);
+  }
+  
+  public float getPositiveEvidence(int horizon) {
+    return horizon * this.frequency * this.confidence / (1 - this.confidence);
+  }
+  
+  public float getTotalEvidence(int horizon) {
+    return horizon * this.confidence/(1 - this.confidence);
+  }
+  
+  public float getExpectation() {
+    return (float) (this.confidence * (this.frequency - 0.5) + 0.5);
+  }
+  
+  public static TruthValue fromFrequencyConfidence(float f, float c) {
+    return new TruthValue(f,c);
+  }
+  
+  public static TruthValue fromBounds(float l, float u) {
+    return new TruthValue(l/(1-(u-l)), 1 - u - l);
+  }
+  
+  public static TruthValue fromEvidence(float wp, float w, int horizon) {
+    return new TruthValue(wp/w, w/(w + horizon));
+  }
+
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/URIReference.java b/open-nars/src/com/googlecode/opennars/language/logic/URIReference.java
new file mode 100644
index 0000000..39a77c4
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/URIReference.java
@@ -0,0 +1,28 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+import java.net.URI;
+
+/**
+ * @author jgeldart
+ *
+ */
+public class URIReference extends AtomicTerm {
+  
+  private URI uri;
+  
+  public interface URIReferenceVisitor<R,A> extends Visitor<R,A> {
+    public R visit(URIReference p, A arg);
+  }
+  
+  public<R,A> R accept(URIReferenceVisitor<R,A> visitor, A arg) {
+    return visitor.visit(this, arg);
+  }
+
+  public URI getURI() {
+    return this.uri;
+  }
+  
+}
diff --git a/open-nars/src/com/googlecode/opennars/language/logic/Variable.java b/open-nars/src/com/googlecode/opennars/language/logic/Variable.java
new file mode 100644
index 0000000..4257c2c
--- /dev/null
+++ b/open-nars/src/com/googlecode/opennars/language/logic/Variable.java
@@ -0,0 +1,24 @@
+/**
+ * 
+ */
+package com.googlecode.opennars.language.logic;
+
+/**
+ * A variable term in the system; either a query variable or a logical
+ * variable.
+ * @author jgeldart
+ *
+ */
+public abstract class Variable extends AtomicTerm {
+
+  private String variableName;
+
+  /**
+   * Get the name of this variable.
+   * @return The variable name
+   */
+  public String getVariableName() {
+    return variableName;
+  }
+  
+}
-- 
GitLab