]> matita.cs.unibo.it Git - logicplayer.git/blob - mainActivity/src/com/example/furt/myapplication/FormulaNot.java
JOURNAL updated
[logicplayer.git] / mainActivity / src / com / example / furt / myapplication / FormulaNot.java
1 package com.example.furt.myapplication;
2
3 import android.graphics.Paint;
4
5 import java.util.ArrayList;
6 import java.util.List;
7
8 public class FormulaNot extends GenericFormula implements Formula{
9     Paint p=new Paint();
10     Formula Operand;
11     int priority;
12     int argPriority;
13     FormulaNot(Formula F)
14     {
15         Operand=F;
16         priority=20;
17         argPriority=100;
18     }
19     @Override
20     public String Draw(int p)
21     {
22         if (priority >= p)
23             return "¬"+Operand.Draw(20);
24         else
25             return("¬("+Operand.Draw(20)+")");
26     }
27
28     public List<IntroductionRule> introductionRules(){
29         List<IntroductionRule> nodes=new ArrayList<IntroductionRule>();
30
31         //Introduzione del not (NOTA: il not non eredita la regola di riduzione ad assurdo)
32         RuleIntroduction notIntro=new RuleIntroduction("¬i",4);
33         Node notN=new Node(new FormulaBOT());
34         List<Formula> notHP=new ArrayList<Formula>();
35         notHP.add(Operand);
36         notN.addHPFormula(notHP,true);
37         Node thisNode=new Node(this);
38         thisNode.addChild(notN);
39         notIntro.tempRule=thisNode;
40         nodes.add(notIntro);
41         return nodes;
42     }
43     public List<EliminationRule> EliminationRules()
44     {
45         List<EliminationRule> nodes=new ArrayList<EliminationRule>();
46         nodes.add(new RuleNotElimination(this));
47         return nodes;
48     }
49
50     @Override
51     public boolean Fill(Formula Filler) {
52         if(Operand.toString().equals("_")) {
53             Operand = Filler;
54             return true;
55         }
56         return Operand.Fill(Filler);
57     }
58
59     @Override
60     public boolean setCursor() {
61         return Operand.setCursor();
62     }
63
64     @Override
65     public Formula duplicate() {
66         return new FormulaNot(Operand.duplicate());
67     }
68 }