Debian Codegraph @

FaCT++.Python/lib/Kernel/tDag2Interface.cpp

raw symbols SCIP
1 /* This file is part of the FaCT++ DL reasoner
2 Copyright (C) 2011-2015 Dmitry Tsarkov and The University of Manchester
3 Copyright (C) 2015-2017 Dmitry Tsarkov
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #include "tDag2Interface.h"
21
22 /// build concept expression by a vertex V
23 const TDLConceptExpression*
24 TDag2Interface :: buildCExpr ( const DLVertex& v )
25 {
26 switch ( v.Type() )
27 {
28 case dtTop:
29 return Manager->Top();
30 case dtNConcept:
31 case dtPConcept:
32 return CName(v.getConcept());
33 case dtPSingleton:
34 case dtNSingleton:
35 return Manager->OneOf(IName(v.getConcept()));
36 case dtAnd:
37 {
38 Manager->newArgList();
39 for ( DLVertex::const_iterator p = v.begin(), p_end = v.end(); p != p_end; ++p )
40 Manager->addArg(getCExpr(*p));
41 return Manager->And();
42 }
43 case dtForall:
44 if ( v.getRole()->isDataRole() )
45 return Manager->Forall ( DRName(v.getRole()), getDExpr(v.getC()) );
46 else
47 return Manager->Forall ( ORName(v.getRole()), getCExpr(v.getC()) );
48 case dtLE:
49 if ( v.getRole()->isDataRole() )
50 return Manager->MaxCardinality ( v.getNumberLE(), DRName(v.getRole()), getDExpr(v.getC()) );
51 else
52 return Manager->MaxCardinality ( v.getNumberLE(), ORName(v.getRole()), getCExpr(v.getC()) );
53 case dtIrr:
54 return Manager->Not(Manager->SelfReference(ORName(v.getRole())));
55 case dtProj:
56 case dtNN:
57 case dtChoose: // these are artificial constructions and shouldn't be visible
58 return Manager->Top();
59 default:
60 fpp_unreachable();
61 }
62 }
63
64 /// build data expression by a vertex V
65 const TDLDataExpression*
66 TDag2Interface :: buildDExpr ( const DLVertex& v )
67 {
68 switch ( v.Type() )
69 {
70 case dtTop:
71 return Manager->DataTop();
72 case dtDataType:
73 case dtDataValue:
74 case dtDataExpr: // TODO: no data stuff yet
75 return Manager->DataTop();
76 case dtAnd:
77 {
78 Manager->newArgList();
79 for ( DLVertex::const_iterator p = v.begin(), p_end = v.end(); p != p_end; ++p )
80 Manager->addArg(getDExpr(*p));
81 return Manager->DataAnd();
82 }
83 default:
84 fpp_unreachable();
85 }
86 }