diff --git a/src/main/java/edu/kit/typicalc/model/term/AbsTerm.java b/src/main/java/edu/kit/typicalc/model/term/AbsTerm.java index 6abfe3e..f333519 100644 --- a/src/main/java/edu/kit/typicalc/model/term/AbsTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/AbsTerm.java @@ -12,7 +12,7 @@ import java.util.Set; /** * Representation of an abstraction term with its two sub-lambda terms. */ -public class AbsTerm implements LambdaTerm { +public class AbsTerm extends LambdaTerm { private final VarTerm var; private final LambdaTerm body; diff --git a/src/main/java/edu/kit/typicalc/model/term/AppTerm.java b/src/main/java/edu/kit/typicalc/model/term/AppTerm.java index dd4285c..03f53ca 100644 --- a/src/main/java/edu/kit/typicalc/model/term/AppTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/AppTerm.java @@ -9,7 +9,7 @@ import java.util.*; /** * Representation of an application term consisting of a function and the parameter passed to it. */ -public class AppTerm implements LambdaTerm { +public class AppTerm extends LambdaTerm { private final LambdaTerm left; private final LambdaTerm right; diff --git a/src/main/java/edu/kit/typicalc/model/term/ConstTerm.java b/src/main/java/edu/kit/typicalc/model/term/ConstTerm.java index 5597015..1bb35e1 100644 --- a/src/main/java/edu/kit/typicalc/model/term/ConstTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/ConstTerm.java @@ -12,7 +12,7 @@ import java.util.Set; /** * Abstract representation of a constant lambda term that has a predetermined type and a value of that type. */ -public abstract class ConstTerm implements LambdaTerm { +public abstract class ConstTerm extends LambdaTerm { /** * Returns the named type of the constant diff --git a/src/main/java/edu/kit/typicalc/model/term/LambdaTerm.java b/src/main/java/edu/kit/typicalc/model/term/LambdaTerm.java index 36d5775..e386ce3 100644 --- a/src/main/java/edu/kit/typicalc/model/term/LambdaTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/LambdaTerm.java @@ -12,27 +12,27 @@ import java.util.Set; * Depending on the subclass used, a lambda term may contain several other lambda terms * and thus form a tree-like structure of lambda terms. */ - public interface LambdaTerm { + public abstract class LambdaTerm { /** * Returns whether the lambda term contains a let expression * * @return whether the lambda term contains a let expression */ - boolean hasLet(); + public abstract boolean hasLet(); /** * Returns a set of all free variables occurring in the lambda term. * * @return all free variables */ - Set getFreeVariables(); + public abstract Set getFreeVariables(); /** * Calls exactly one method on the visitor depending on the lambda term type. * * @param termVisitor a visitor */ - void accept(TermVisitor termVisitor); + public abstract void accept(TermVisitor termVisitor); /** * Uses exactly one method of the visitor and provides the arguments passed. @@ -42,6 +42,6 @@ import java.util.Set; * @param type a type * @return the result returned by the visitor */ - InferenceStep accept(TermVisitorTree termVisitorTree, + public abstract InferenceStep accept(TermVisitorTree termVisitorTree, Map assumptions, Type type); } diff --git a/src/main/java/edu/kit/typicalc/model/term/LetTerm.java b/src/main/java/edu/kit/typicalc/model/term/LetTerm.java index 105492e..3da544c 100644 --- a/src/main/java/edu/kit/typicalc/model/term/LetTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/LetTerm.java @@ -13,7 +13,7 @@ import java.util.Set; * Representation of a let term with its variable, the lambda term assigned * to this variable and the lambda term the variable is used in. */ -public class LetTerm implements LambdaTerm { +public class LetTerm extends LambdaTerm { private final VarTerm variable; private final LambdaTerm definition; private final LambdaTerm body; diff --git a/src/main/java/edu/kit/typicalc/model/term/VarTerm.java b/src/main/java/edu/kit/typicalc/model/term/VarTerm.java index 303f368..8d1da7a 100644 --- a/src/main/java/edu/kit/typicalc/model/term/VarTerm.java +++ b/src/main/java/edu/kit/typicalc/model/term/VarTerm.java @@ -9,7 +9,7 @@ import java.util.*; /** * Representation of a variable term with its name. */ -public class VarTerm implements LambdaTerm { +public class VarTerm extends LambdaTerm { private final String name; /** diff --git a/src/main/java/edu/kit/typicalc/model/type/FunctionType.java b/src/main/java/edu/kit/typicalc/model/type/FunctionType.java index 2081d9d..bfa8500 100644 --- a/src/main/java/edu/kit/typicalc/model/type/FunctionType.java +++ b/src/main/java/edu/kit/typicalc/model/type/FunctionType.java @@ -10,7 +10,7 @@ import java.util.Set; /** * Models the type of an abstraction/function. */ -public class FunctionType implements Type { +public class FunctionType extends Type { private final Type parameter; private final Type output; diff --git a/src/main/java/edu/kit/typicalc/model/type/NamedType.java b/src/main/java/edu/kit/typicalc/model/type/NamedType.java index 6fd7220..e814c1d 100644 --- a/src/main/java/edu/kit/typicalc/model/type/NamedType.java +++ b/src/main/java/edu/kit/typicalc/model/type/NamedType.java @@ -10,7 +10,7 @@ import java.util.Set; /** * Models a simple named type. */ -public class NamedType implements Type { +public class NamedType extends Type { /** * boolean type */ diff --git a/src/main/java/edu/kit/typicalc/model/type/Type.java b/src/main/java/edu/kit/typicalc/model/type/Type.java index b501e8b..f87a578 100644 --- a/src/main/java/edu/kit/typicalc/model/type/Type.java +++ b/src/main/java/edu/kit/typicalc/model/type/Type.java @@ -9,21 +9,21 @@ import java.util.Set; /** * Models the type of a lambda term. */ -public interface Type { +public abstract class Type { /** * Checks whether some type occurs in this type. * * @param x the type to look for * @return whether the specified type occurs in this type */ - boolean contains(Type x); + public abstract boolean contains(Type x); /** * Returns a set of all free type variables occurring in the type. * * @return all free type variables */ - Set getFreeTypeVariables(); + public abstract Set getFreeTypeVariables(); /** * Substitutes a type Variable for a different type. @@ -32,7 +32,7 @@ public interface Type { * @param b the type to insert * @return a Type that is created by replacing a with b */ - Type substitute(TypeVariable a, Type b); + public abstract Type substitute(TypeVariable a, Type b); /** * Applies the given substitution to the type. @@ -40,7 +40,7 @@ public interface Type { * @param substitution the substitution to apply to the type * @return the substituted type */ - default Type substitute(Substitution substitution) { + public Type substitute(Substitution substitution) { return substitute(substitution.getVariable(), substitution.getType()); } @@ -49,7 +49,7 @@ public interface Type { * * @param typeVisitor the visitor that wants to visit this */ - void accept(TypeVisitor typeVisitor); + public abstract void accept(TypeVisitor typeVisitor); /** * Computes the necessary constraints (and substitution) to unify this type with @@ -58,7 +58,7 @@ public interface Type { * @param type the other type * @return unification steps necessary, or an error if that is impossible */ - Result constrainEqualTo(Type type); + public abstract Result constrainEqualTo(Type type); /** * Computes the necessary constraints (and substitution) to unify this type with a @@ -67,7 +67,7 @@ public interface Type { * @param type the function type * @return unification steps necessary, or an error if that is impossible */ - Result constrainEqualToFunction(FunctionType type); + public abstract Result constrainEqualToFunction(FunctionType type); /** * Computes the necessary constraints (and substitution) to unify this type with a @@ -76,7 +76,7 @@ public interface Type { * @param type the named type * @return unification steps necessary, or an error if that is impossible */ - Result constrainEqualToNamedType(NamedType type); + public abstract Result constrainEqualToNamedType(NamedType type); /** * Computes the necessary constraints (and substitution) to unify this type with a @@ -85,5 +85,5 @@ public interface Type { * @param type the type variable * @return the unification steps necessary, or an error if that is impossible */ - Result constrainEqualToVariable(TypeVariable type); + public abstract Result constrainEqualToVariable(TypeVariable type); } diff --git a/src/main/java/edu/kit/typicalc/model/type/TypeVariable.java b/src/main/java/edu/kit/typicalc/model/type/TypeVariable.java index bf68f9a..dedf1ae 100644 --- a/src/main/java/edu/kit/typicalc/model/type/TypeVariable.java +++ b/src/main/java/edu/kit/typicalc/model/type/TypeVariable.java @@ -8,7 +8,7 @@ import java.util.*; /** * Models a type variable */ -public class TypeVariable implements Type, Comparable { +public class TypeVariable extends Type implements Comparable { private final TypeVariableKind kind; private final int index;