📄 relationantisymmetry.java
字号:
package toocom.ocgl;
import java.util.*;
import java.awt.Graphics;
/**
* This class represents the antisymmetry of a relation.
*
* @author Fr閐閞ic F黵st
*/
public class RelationAntisymmetry extends AxiomSchemaOne{
public RelationAntisymmetry(RelationType r){
super(CGConstants.getRelationAntisymmetryTerms(),r);
}
/** A primitive can be antisymmetric if it is a relation, if its arity is 2, if the two
* concepts of its signature are defined and have the same type, if it is not symmetric
* and not reflexive. */
public boolean isValid(){
return (super.cp instanceof RelationType) &&
(((RelationType) super.cp).getArity() == 2) &&
(((RelationType) super.cp).getSignature().getConceptType(1) != null) &&
(((RelationType) super.cp).getSignature().getConceptType(2) != null) &&
((RelationType) super.cp).getSignature().getConceptType(1).equals(((RelationType) super.cp).getSignature().getConceptType(2)) &&
!super.cp.hasAxiomSchema("toocom.ocgl.RelationSymmetry") &&
!super.cp.hasAxiomSchema("toocom.ocgl.RelationReflexivity");
}
public Axiom getAxiomForm(){
Axiom axiom = new Axiom(CGConstants.getRelationAntisymmetryTerms());
axiom.getTerms().appendWithSeparator(((RelationType) super.cp).getTerms()," - ");
Relation r1 = new Relation((RelationType) super.cp);
Relation r2 = new Relation((RelationType) super.cp);
r2.setTerms(r2.getTerms().denyTerms());
axiom.addHypothesisRelation(r1);
axiom.addConclusionRelation(r2);
ConceptType ct1 = ((RelationType) super.cp).getSignature().getConceptType(1);
ConceptType ct2 = ((RelationType) super.cp).getSignature().getConceptType(2);
Concept c1 = new Concept(ct1);
Concept c2 = new Concept(ct2);
r1.setLinkedConcept(c1,1);
r1.setLinkedConcept(c2,2);
r2.setLinkedConcept(c2,1);
r2.setLinkedConcept(c1,2);
axiom.addHypothesisConcept(c1);
axiom.addHypothesisConcept(c2);
return axiom;
}
/** An antisymmetry axiom schema is operationalized, in an inferential context of use,
* by a rule, and, in a validation context of use, by a negative constraint. */
public LinkedList getOperationalForm(Ontology onto,Language l){
LinkedList result = new LinkedList();
if(this.isValid()){
if(this.cou.isInferential() && (onto.getIdentityRelationType() != null)){
Rule rule = new Rule(CGConstants.getRuleTerms().appendAndCopy(CGConstants.getRelationAntisymmetryTerms()," : ").appendAndCopy(super.cp.getTerms()," - "));
Concept c1 = new Concept(((RelationType) this.cp).getSignature().getConceptType(1));
Concept c2 = new Concept(((RelationType) this.cp).getSignature().getConceptType(2));
Relation r1 = new Relation((RelationType) this.cp);
Relation r2 = new Relation((RelationType) this.cp);
Relation r3 = new Relation(onto.getIdentityRelationType());
r1.setLinkedConcept(c1,1);
r1.setLinkedConcept(c2,2);
r2.setLinkedConcept(c2,1);
r2.setLinkedConcept(c1,2);
r3.setLinkedConcept(c1,1);
r3.setLinkedConcept(c2,2);
rule.addHypothesisConcept(c1);
rule.addHypothesisConcept(c2);
rule.addHypothesisRelation(r1);
rule.addHypothesisRelation(r2);
rule.addConclusionRelation(r3);
result.add(rule);
}
else{
NegativeConstraint cons = new NegativeConstraint(CGConstants.getNegativeConstraintTerms().appendAndCopy(CGConstants.getRelationAntisymmetryTerms()," : ").appendAndCopy(super.cp.getTerms()," - "));
Concept c1 = new Concept(((RelationType) this.cp).getSignature().getConceptType(1));
Concept c2 = new Concept(((RelationType) this.cp).getSignature().getConceptType(2));
Relation r1 = new Relation((RelationType) this.cp);
Relation r2 = new Relation((RelationType) this.cp);
r1.setLinkedConcept(c1,1);
r1.setLinkedConcept(c2,2);
r2.setLinkedConcept(c2,1);
r2.setLinkedConcept(c1,2);
cons.addHypothesisConcept(c1);
cons.addHypothesisConcept(c2);
cons.addHypothesisRelation(r1);
cons.addConclusionRelation(r2);
result.add(cons);
}
}
return result;
}
public void paint(Graphics g,Language l){
g.setColor(CGConstants.ANTISYMMETRY_COLOR);
g.drawString("A",super.cp.x - (CGConstants.PROPERTY_SYMBOLS_SPACING * 3),super.cp.y - (CGConstants.PROPERTY_SYMBOLS_SPACING * 4));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -