Skip to content

Commit 48b21e5

Browse files
authored
Merge pull request #341 from yushan87/prover-theorem-utils
Prover Immutable Theorem Representation
2 parents 5e2bf4b + 91fbc4a commit 48b21e5

File tree

8 files changed

+1006
-8
lines changed

8 files changed

+1006
-8
lines changed

src/main/java/edu/clemson/cs/rsrg/prover/utilities/ImmutableVC.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ public final ConjunctionOfNormalizedAtomicExpressions getConjunct() {
145145
return myConjunction;
146146
}
147147

148+
/**
149+
* <p>This method returns the current registry of symbols.</p>
150+
*
151+
* @return A {@link Registry}.
152+
*/
153+
public final Registry getRegistry() {
154+
return myRegistry;
155+
}
156+
148157
/**
149158
* <p>This method returns the current proving status for
150159
* this VC.</p>
@@ -287,6 +296,10 @@ private void seedDefaultTheorems() {
287296
myConjunction.addExpression(fandfeqf);
288297
}
289298

299+
// ===========================================================
300+
// Helper Constructs
301+
// ===========================================================
302+
290303
/**
291304
* <p>When building an {@link ImmutableVC}, both Mike and Hampton did a bunch of
292305
* conversions. This class allows us to keep the same logic, but not have a separate
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* PExpWithScore.java
3+
* ---------------------------------
4+
* Copyright (c) 2019
5+
* RESOLVE Software Research Group
6+
* School of Computing
7+
* Clemson University
8+
* All rights reserved.
9+
* ---------------------------------
10+
* This file is subject to the terms and conditions defined in
11+
* file 'LICENSE.txt', which is part of this source code package.
12+
*/
13+
package edu.clemson.cs.rsrg.prover.utilities;
14+
15+
import edu.clemson.cs.rsrg.prover.absyn.PExp;
16+
import java.util.Map;
17+
18+
/**
19+
* <p>This class allows us to create a comparable theorem with a score.</p>
20+
*
21+
* @author Mike Kabbani
22+
* @version 2.0
23+
*/
24+
public class PExpWithScore implements Comparable<PExpWithScore> {
25+
26+
// ===========================================================
27+
// Member Fields
28+
// ===========================================================
29+
30+
/** <p>A theorem expression</p> */
31+
private final PExp myTheorem;
32+
33+
/** <p>The theorem's definition.</p> */
34+
private final String myTheoremDefinitionString;
35+
36+
/** <p>A comparison score.</p> */
37+
private final Integer myScore;
38+
39+
/** <p>A map of symbols in this theorem.</p> */
40+
private final Map<String, String> myBMap;
41+
42+
// ===========================================================
43+
// Constructors
44+
// ===========================================================
45+
46+
/**
47+
* <p>This constructs a new expression that includes a score.</p>
48+
*
49+
* @param theorem A theorem represented as a {@link PExp}.
50+
* @param bMap A map of symbols in this theorem.
51+
* @param justification The theorem definition expressed as a string.
52+
*/
53+
public PExpWithScore(PExp theorem, Map<String, String> bMap,
54+
String justification) {
55+
myBMap = bMap;
56+
myScore = 1;
57+
myTheorem = theorem;
58+
myTheoremDefinitionString = justification;
59+
}
60+
61+
// ===========================================================
62+
// Public Methods
63+
// ===========================================================
64+
65+
/**
66+
* <p>Compares <code>this<code> and <code>o</code>.</p>
67+
*
68+
* @param o Another {@link PExpWithScore}.
69+
*
70+
* @return Comparison results expressed as an integer.
71+
*/
72+
@Override
73+
public final int compareTo(PExpWithScore o) {
74+
return myScore - o.myScore;
75+
}
76+
77+
/**
78+
* <p>This method returns a theorem expression.</p>
79+
*
80+
* @return A {@link PExp}.
81+
*/
82+
public final PExp getTheorem() {
83+
return myTheorem;
84+
}
85+
86+
/**
87+
* <p>This method returns the theorem definition.</p>
88+
*
89+
* @return A string.
90+
*/
91+
public final String getTheoremDefinitionString() {
92+
return myTheoremDefinitionString;
93+
}
94+
95+
/**
96+
* <p>This method returns this expression in string format.</p>
97+
*
98+
* @return A string.
99+
*/
100+
@Override
101+
public final String toString() {
102+
return myTheoremDefinitionString + "\n" + "\t[" + myScore + "]" + " "
103+
+ myTheorem.toString() + "\t" + myBMap + "\n";
104+
}
105+
}

src/main/java/edu/clemson/cs/rsrg/prover/utilities/Registry.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,6 @@ public final int findAndCompress(int index) {
246246
return index;
247247
}
248248

249-
//
250-
251249
/**
252250
* <p>This method gets the set of children symbol names.</p>
253251
*

src/main/java/edu/clemson/cs/rsrg/prover/utilities/expressions/ConjunctionOfNormalizedAtomicExpressions.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,16 @@ public final Set<Map<String, String>> getMatchesForOverrideSet(NormalizedAtomicE
313313
return rSet;
314314
}
315315

316+
/**
317+
* <p>This method returns the set of normalized atomic expressions
318+
* used as keys in this conjunction.</p>
319+
*
320+
* @return A set of {@link NormalizedAtomicExpression}.
321+
*/
322+
public final Set<NormalizedAtomicExpression> getNormalizedAtomicExpressionKeys() {
323+
return myExpressionSet.keySet();
324+
}
325+
316326
/**
317327
* <p>This method returns the set of expressions based on the
318328
* symbol number.</p>

0 commit comments

Comments
 (0)