Skip to content

Commit de2cca2

Browse files
Load the shared RocqRefRunner JTS↔NTS equivalence vectors.
Pin Java refSign to the Proofs corpus that NTS also loads (oracle/rocqref/jts_nts_equiv_vectors.txt). Co-authored-by: jbloemscheer <jbloemscheer@gmail.com>
1 parent 1e2b919 commit de2cca2

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

modules/core/src/test/java/org/locationtech/jts/algorithm/RocqRefRunnerTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ public class RocqRefRunnerTest extends TestCase {
3434
private static final String PROOF_VECTORS_RESOURCE =
3535
"/org/locationtech/jts/algorithm/rocqref/orientation_proof_vectors.txt";
3636

37+
/**
38+
* Shared JTS ↔ NTS RocqRefRunner corpus from
39+
* {@code NetTopologySuite.Proofs/oracle/rocqref/jts_nts_equiv_vectors.txt}.
40+
*/
41+
private static final String JTS_NTS_EQUIV_RESOURCE =
42+
"/org/locationtech/jts/algorithm/rocqref/jts_nts_equiv_vectors.txt";
43+
3744
public static void main(String[] args) {
3845
TestRunner.run(RocqRefRunnerTest.class);
3946
}
@@ -109,6 +116,24 @@ public void testExportedProofVectors() throws Exception {
109116
}
110117
}
111118

119+
/**
120+
* The catalyst port-equivalence gate: Java {@link RocqRefRunner#refSign}
121+
* must match the Coq {@code rocqref_refSign} signs shipped in the shared
122+
* Proofs corpus (the same file NTS loads).
123+
*/
124+
public void testJtsNtsEquivVectors() throws Exception {
125+
InputStream in = getClass().getResourceAsStream(JTS_NTS_EQUIV_RESOURCE);
126+
assertNotNull("shared JTS↔NTS RocqRefRunner vectors missing", in);
127+
try {
128+
List<RocqRefRunner.RefCase> cases = RocqRefRunner.loadProofCases(in);
129+
assertTrue("shared equiv corpus is empty", cases.size() > 0);
130+
RocqRefRunner.Result r = RocqRefRunner.run(cases);
131+
assertTrue("JTS disagrees with RocqRefRunner JTS↔NTS vectors:\n" + r, r.isSound());
132+
} finally {
133+
in.close();
134+
}
135+
}
136+
112137
private static long rndIn(Random rnd, long bound) {
113138
long span = 2 * bound + 1;
114139
return Math.floorMod(rnd.nextLong(), span) - bound;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Shared RocqRefRunner JTS ↔ NTS equivalence vectors.
2+
# Provenance: theories/RocqRefRunner.v
3+
# rocqref_refSign_eq_cross
4+
# rocqref_idet_fits_int64
5+
#
6+
# Format (whitespace-separated; '#' comments and blank lines ignored):
7+
# p0x p0y p1x p1y qx qy expected
8+
# expected in {-1, 0, 1}: -1 = CW, 0 = collinear, +1 = CCW.
9+
# Every coordinate is an integer in [-2^25, 2^25] (RocqRefRunner.SAFE_BOUND).
10+
# The expected sign is Z.sgn of the integer 2x2 determinant — the algorithm
11+
# both language ports implement. Production Orientation.index is NOT the
12+
# reference; these rows pin the ports to each other and to the Qed formula.
13+
14+
# --- unit turns (locked Examples in RocqRefRunner.v) ---
15+
0 0 1 0 0 1 1
16+
0 0 1 0 0 -1 -1
17+
0 0 2 2 1 1 0
18+
19+
# --- basic / JTS RocqRefRunnerTest resource ---
20+
0 0 0 1 1 0 -1
21+
0 0 4 2 2 1 0
22+
-33554432 -33554432 33554432 33554432 0 0 0
23+
24+
# --- near-collinear (one unit off a long diagonal) ---
25+
0 0 1000000 1000000 1000001 1000000 -1
26+
0 0 1000000 1000000 1000000 1000001 1
27+
28+
# --- domain boundary (largest representable determinants) ---
29+
33554432 33554432 -33554432 -33554432 33554432 -33554432 1
30+
-33554432 33554432 33554432 -33554432 33554431 -33554432 -1
31+
32+
# --- coincident / zero-length ---
33+
0 0 0 0 1 1 0
34+
5 5 5 5 5 5 0
35+
3 4 3 4 0 0 0

0 commit comments

Comments
 (0)