internal Operator(string surfaceForm, NaturalLogicRelation deleteRelation, string subjMono) { this.surfaceForm = surfaceForm; this.deleteRelation = deleteRelation; Pair <Monotonicity, MonotonicityType> subj = MonoFromString(subjMono); this.subjMono = subj.first; this.subjType = subj.second; this.objMono = Monotonicity.Invalid; this.objType = MonotonicityType.None; }
public static string MonotonicitySignature(Monotonicity mono, MonotonicityType type) { switch (mono) { case Monotonicity.Monotone: { switch (type) { case MonotonicityType.None: { return("nonmonotone"); } case MonotonicityType.Additive: { return("additive"); } case MonotonicityType.Multiplicative: { return("multiplicative"); } case MonotonicityType.Both: { return("additive-multiplicative"); } } goto case Monotonicity.Antitone; } case Monotonicity.Antitone: { switch (type) { case MonotonicityType.None: { return("nonmonotone"); } case MonotonicityType.Additive: { return("anti-additive"); } case MonotonicityType.Multiplicative: { return("anti-multiplicative"); } case MonotonicityType.Both: { return("anti-additive-multiplicative"); } } goto case Monotonicity.Nonmonotone; } case Monotonicity.Nonmonotone: { return("nonmonotone"); } } throw new InvalidOperationException("Unhandled case: " + mono + " and " + type); }
/// <summary>Encode the projection table in painful detail.</summary> /// <param name="input">The input natural logic relation to project up through the operator.</param> /// <param name="mono">The monotonicity of the operator we are projecting through.</param> /// <param name="type">The monotonicity type of the operator we are projecting through.</param> /// <returns>The projected relation, once passed through an operator with the given specifications.</returns> private NaturalLogicRelation Project(NaturalLogicRelation input, Monotonicity mono, MonotonicityType type) { switch (input) { case NaturalLogicRelation.Equivalent: { return(NaturalLogicRelation.Equivalent); } case NaturalLogicRelation.ForwardEntailment: { switch (mono) { case Monotonicity.Monotone: { return(NaturalLogicRelation.ForwardEntailment); } case Monotonicity.Antitone: { return(NaturalLogicRelation.ReverseEntailment); } case Monotonicity.Nonmonotone: case Monotonicity.Invalid: { return(NaturalLogicRelation.Independence); } } goto case NaturalLogicRelation.ReverseEntailment; } case NaturalLogicRelation.ReverseEntailment: { switch (mono) { case Monotonicity.Monotone: { return(NaturalLogicRelation.ReverseEntailment); } case Monotonicity.Antitone: { return(NaturalLogicRelation.ForwardEntailment); } case Monotonicity.Nonmonotone: case Monotonicity.Invalid: { return(NaturalLogicRelation.Independence); } } goto case NaturalLogicRelation.Negation; } case NaturalLogicRelation.Negation: { switch (type) { case MonotonicityType.None: { return(NaturalLogicRelation.Independence); } case MonotonicityType.Additive: { switch (mono) { case Monotonicity.Monotone: { return(NaturalLogicRelation.Cover); } case Monotonicity.Antitone: { return(NaturalLogicRelation.Alternation); } case Monotonicity.Nonmonotone: case Monotonicity.Invalid: { return(NaturalLogicRelation.Independence); } } goto case MonotonicityType.Multiplicative; } case MonotonicityType.Multiplicative: { switch (mono) { case Monotonicity.Monotone: { return(NaturalLogicRelation.Alternation); } case Monotonicity.Antitone: { return(NaturalLogicRelation.Cover); } case Monotonicity.Nonmonotone: case Monotonicity.Invalid: { return(NaturalLogicRelation.Independence); } } break; } case MonotonicityType.Both: { return(NaturalLogicRelation.Negation); } } break; } case NaturalLogicRelation.Alternation: { switch (mono) { case Monotonicity.Monotone: { switch (type) { case MonotonicityType.None: case MonotonicityType.Additive: { return(NaturalLogicRelation.Independence); } case MonotonicityType.Multiplicative: case MonotonicityType.Both: { return(NaturalLogicRelation.Alternation); } } goto case Monotonicity.Antitone; } case Monotonicity.Antitone: { switch (type) { case MonotonicityType.None: case MonotonicityType.Additive: { return(NaturalLogicRelation.Independence); } case MonotonicityType.Multiplicative: case MonotonicityType.Both: { return(NaturalLogicRelation.Cover); } } goto case Monotonicity.Nonmonotone; } case Monotonicity.Nonmonotone: case Monotonicity.Invalid: { return(NaturalLogicRelation.Independence); } } goto case NaturalLogicRelation.Cover; } case NaturalLogicRelation.Cover: { switch (mono) { case Monotonicity.Monotone: { switch (type) { case MonotonicityType.None: case MonotonicityType.Multiplicative: { return(NaturalLogicRelation.Independence); } case MonotonicityType.Additive: case MonotonicityType.Both: { return(NaturalLogicRelation.Cover); } } goto case Monotonicity.Antitone; } case Monotonicity.Antitone: { switch (type) { case MonotonicityType.None: case MonotonicityType.Multiplicative: { return(NaturalLogicRelation.Independence); } case MonotonicityType.Additive: case MonotonicityType.Both: { return(NaturalLogicRelation.Alternation); } } goto case Monotonicity.Nonmonotone; } case Monotonicity.Nonmonotone: case Monotonicity.Invalid: { return(NaturalLogicRelation.Independence); } } goto case NaturalLogicRelation.Independence; } case NaturalLogicRelation.Independence: { return(NaturalLogicRelation.Independence); } } throw new InvalidOperationException("[should not happen!] Projection table is incomplete for " + mono + " : " + type + " on relation " + input); }