eyeling 1.15.8 → 1.15.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HANDBOOK.md +4 -0
- package/README.md +2 -0
- package/examples/composition-of-injective-functions-is-injective.n3 +241 -0
- package/examples/equivalence-classes-overlap-implies-same-class.n3 +183 -0
- package/examples/fft32-numeric.n3 +0 -0
- package/examples/french-cities.n3 +2 -0
- package/examples/greatest-lower-bound-uniqueness.n3 +202 -0
- package/examples/group-inverse-uniqueness.n3 +174 -0
- package/examples/jsonterm-advanced.n3 +92 -0
- package/examples/jsonterm.n3 +37 -0
- package/examples/library-and-path.n3 +499 -0
- package/examples/monoid-identity-uniqueness.n3 +182 -0
- package/examples/output/composition-of-injective-functions-is-injective.n3 +4 -0
- package/examples/output/equivalence-classes-overlap-implies-same-class.n3 +20 -0
- package/examples/output/french-cities.n3 +1 -18
- package/examples/output/greatest-lower-bound-uniqueness.n3 +4 -0
- package/examples/output/group-inverse-uniqueness.n3 +4 -0
- package/examples/output/jsonterm-advanced.n3 +8 -0
- package/examples/output/jsonterm.n3 +3 -0
- package/examples/output/library-and-path.n3 +33 -0
- package/examples/output/monoid-identity-uniqueness.n3 +3 -0
- package/examples/output/turing.n3 +4 -6
- package/examples/turing.n3 +5 -9
- package/eyeling.js +99 -25
- package/lib/engine.js +99 -25
- package/package.json +2 -2
- package/test/api.test.js +28 -0
package/HANDBOOK.md
CHANGED
|
@@ -376,6 +376,10 @@ That’s alpha-equivalence:
|
|
|
376
376
|
|
|
377
377
|
Eyeling implements alpha-equivalence by checking whether there exists a consistent renaming mapping between the two formulas’ variables/blanks that makes the triples match.
|
|
378
378
|
|
|
379
|
+
Important scope nuance: only blanks/variables that are local to the quoted formula participate in alpha-renaming. If a formula is being matched after an outer substitution has already instantiated part of it, those substituted terms are treated as fixed. In other words, alpha-equivalence may rename formula-local placeholders, but it must not rename names that came from the enclosing match. This prevents a substituted outer blank node from being confused with a local blank node inside the quoted formula.
|
|
380
|
+
|
|
381
|
+
So `{ _:x :p :o }` obtained by substituting `?A = _:x` into `{ ?A :p :o }` must not alpha-match `{ _:b :p :o }` by renaming `_:x` to `_:b`.
|
|
382
|
+
|
|
379
383
|
### 6.2 Groundness: “variables inside formulas don’t leak”
|
|
380
384
|
|
|
381
385
|
Eyeling makes a deliberate choice about _groundness_:
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# eyeling
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/eyereasoner) [](https://doi.org/10.5281/zenodo.19068086)
|
|
4
|
+
|
|
3
5
|
A compact [Notation3 (N3)](https://notation3.org/) reasoner in **JavaScript**.
|
|
4
6
|
|
|
5
7
|
- Single self-contained bundle (`eyeling.js`), no external runtime dependencies
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# ==========================================================
|
|
2
|
+
# File: composition-of-injective-functions-is-injective.n3
|
|
3
|
+
#
|
|
4
|
+
# Purpose
|
|
5
|
+
# -------
|
|
6
|
+
# This file expresses a standard pure mathematical fact:
|
|
7
|
+
#
|
|
8
|
+
# The composition of two injective functions is injective.
|
|
9
|
+
#
|
|
10
|
+
# Core idea
|
|
11
|
+
# ---------
|
|
12
|
+
# We choose a framework with:
|
|
13
|
+
# - functions represented by an application relation :app
|
|
14
|
+
# - a notion of injectivity
|
|
15
|
+
# - a notion of composition
|
|
16
|
+
#
|
|
17
|
+
# Once that framework is fixed, the theorem is forced:
|
|
18
|
+
#
|
|
19
|
+
# if f and g are injective,
|
|
20
|
+
# then g ∘ f is injective.
|
|
21
|
+
#
|
|
22
|
+
# This fits the general theme:
|
|
23
|
+
# the framework is chosen,
|
|
24
|
+
# but the consequence is not optional.
|
|
25
|
+
#
|
|
26
|
+
# Representation
|
|
27
|
+
# --------------
|
|
28
|
+
# (?f ?x) :app ?y
|
|
29
|
+
# means:
|
|
30
|
+
# f(x) = y
|
|
31
|
+
#
|
|
32
|
+
# ?h :compositeOf (?g ?f)
|
|
33
|
+
# means:
|
|
34
|
+
# h = g ∘ f
|
|
35
|
+
#
|
|
36
|
+
# (?x ?y) :sameTerm true
|
|
37
|
+
# records provable sameness as an ordinary derived fact.
|
|
38
|
+
# ==========================================================
|
|
39
|
+
|
|
40
|
+
@prefix : <http://examples.org/#>.
|
|
41
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
42
|
+
|
|
43
|
+
# ------------------
|
|
44
|
+
# Carrier membership
|
|
45
|
+
# ------------------
|
|
46
|
+
|
|
47
|
+
# We use:
|
|
48
|
+
#
|
|
49
|
+
# ?x :inX true.
|
|
50
|
+
# ?y :inY true.
|
|
51
|
+
# ?z :inZ true.
|
|
52
|
+
#
|
|
53
|
+
# for the three sets involved.
|
|
54
|
+
|
|
55
|
+
# -----------------------------------
|
|
56
|
+
# Basic facts about provable sameness
|
|
57
|
+
# -----------------------------------
|
|
58
|
+
|
|
59
|
+
# Reflexivity on each carrier
|
|
60
|
+
|
|
61
|
+
{
|
|
62
|
+
?x :inX true.
|
|
63
|
+
}
|
|
64
|
+
=>
|
|
65
|
+
{
|
|
66
|
+
(?x ?x) :sameTerm true.
|
|
67
|
+
}.
|
|
68
|
+
|
|
69
|
+
{
|
|
70
|
+
?y :inY true.
|
|
71
|
+
}
|
|
72
|
+
=>
|
|
73
|
+
{
|
|
74
|
+
(?y ?y) :sameTerm true.
|
|
75
|
+
}.
|
|
76
|
+
|
|
77
|
+
{
|
|
78
|
+
?z :inZ true.
|
|
79
|
+
}
|
|
80
|
+
=>
|
|
81
|
+
{
|
|
82
|
+
(?z ?z) :sameTerm true.
|
|
83
|
+
}.
|
|
84
|
+
|
|
85
|
+
# Symmetry
|
|
86
|
+
|
|
87
|
+
{
|
|
88
|
+
(?a ?b) :sameTerm true.
|
|
89
|
+
}
|
|
90
|
+
=>
|
|
91
|
+
{
|
|
92
|
+
(?b ?a) :sameTerm true.
|
|
93
|
+
}.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# ---------
|
|
97
|
+
# Functions
|
|
98
|
+
# ---------
|
|
99
|
+
|
|
100
|
+
# Functionality:
|
|
101
|
+
# if the same function sends the same input to two outputs,
|
|
102
|
+
# then those outputs are the same.
|
|
103
|
+
|
|
104
|
+
{
|
|
105
|
+
(?f ?x) :app ?u.
|
|
106
|
+
(?f ?x) :app ?v.
|
|
107
|
+
}
|
|
108
|
+
=>
|
|
109
|
+
{
|
|
110
|
+
(?u ?v) :sameTerm true.
|
|
111
|
+
}.
|
|
112
|
+
|
|
113
|
+
# Injectivity:
|
|
114
|
+
# if an injective function sends x and y to the same output,
|
|
115
|
+
# then x and y are the same.
|
|
116
|
+
|
|
117
|
+
{
|
|
118
|
+
?f :injective true.
|
|
119
|
+
(?f ?x) :app ?u.
|
|
120
|
+
(?f ?y) :app ?v.
|
|
121
|
+
(?u ?v) :sameTerm true.
|
|
122
|
+
}
|
|
123
|
+
=>
|
|
124
|
+
{
|
|
125
|
+
(?x ?y) :sameTerm true.
|
|
126
|
+
}.
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
# -----------
|
|
130
|
+
# Composition
|
|
131
|
+
# -----------
|
|
132
|
+
|
|
133
|
+
# If h = g ∘ f, and f(x) = y, and g(y) = z,
|
|
134
|
+
# then h(x) = z.
|
|
135
|
+
|
|
136
|
+
{
|
|
137
|
+
?h :compositeOf (?g ?f).
|
|
138
|
+
(?f ?x) :app ?y.
|
|
139
|
+
(?g ?y) :app ?z.
|
|
140
|
+
}
|
|
141
|
+
=>
|
|
142
|
+
{
|
|
143
|
+
(?h ?x) :app ?z.
|
|
144
|
+
}.
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
# -----------
|
|
148
|
+
# The theorem
|
|
149
|
+
# -----------
|
|
150
|
+
#
|
|
151
|
+
# Proof idea:
|
|
152
|
+
#
|
|
153
|
+
# suppose h = g ∘ f
|
|
154
|
+
# and h(x), h(y) are equal
|
|
155
|
+
#
|
|
156
|
+
# then g(f(x)) = g(f(y))
|
|
157
|
+
# since g is injective:
|
|
158
|
+
# f(x) = f(y)
|
|
159
|
+
# since f is injective:
|
|
160
|
+
# x = y
|
|
161
|
+
#
|
|
162
|
+
# So the composition is injective.
|
|
163
|
+
#
|
|
164
|
+
# In this file we record theorem instances with:
|
|
165
|
+
#
|
|
166
|
+
# (?h ?x ?y) :sameInputUnderEqualCompositeOutput true
|
|
167
|
+
#
|
|
168
|
+
|
|
169
|
+
{
|
|
170
|
+
?h :compositeOf (?g ?f).
|
|
171
|
+
?f :injective true.
|
|
172
|
+
?g :injective true.
|
|
173
|
+
|
|
174
|
+
(?f ?x) :app ?fx.
|
|
175
|
+
(?f ?y) :app ?fy.
|
|
176
|
+
|
|
177
|
+
(?g ?fx) :app ?u.
|
|
178
|
+
(?g ?fy) :app ?v.
|
|
179
|
+
|
|
180
|
+
(?u ?v) :sameTerm true.
|
|
181
|
+
(?x ?y) :sameTerm true.
|
|
182
|
+
}
|
|
183
|
+
=>
|
|
184
|
+
{
|
|
185
|
+
(?h ?x ?y) :sameInputUnderEqualCompositeOutput true.
|
|
186
|
+
}.
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
# -----------------
|
|
190
|
+
# Tiny example data
|
|
191
|
+
# -----------------
|
|
192
|
+
# We declare two injective functions f and g, and their
|
|
193
|
+
# composition h = g ∘ f.
|
|
194
|
+
#
|
|
195
|
+
# The data below says:
|
|
196
|
+
#
|
|
197
|
+
# f(a) = p
|
|
198
|
+
# f(b) = q
|
|
199
|
+
# g(p) = r
|
|
200
|
+
# g(q) = r
|
|
201
|
+
#
|
|
202
|
+
# Since g is injective, p and q must be the same.
|
|
203
|
+
# Since f is injective, a and b must be the same.
|
|
204
|
+
#
|
|
205
|
+
# So h sends a and b to the same value only because
|
|
206
|
+
# the framework forces a = b.
|
|
207
|
+
|
|
208
|
+
:a :inX true.
|
|
209
|
+
:b :inX true.
|
|
210
|
+
|
|
211
|
+
:p :inY true.
|
|
212
|
+
:q :inY true.
|
|
213
|
+
|
|
214
|
+
:r :inZ true.
|
|
215
|
+
|
|
216
|
+
:f :injective true.
|
|
217
|
+
:g :injective true.
|
|
218
|
+
|
|
219
|
+
:h :compositeOf (:g :f).
|
|
220
|
+
|
|
221
|
+
(:f :a) :app :p.
|
|
222
|
+
(:f :b) :app :q.
|
|
223
|
+
|
|
224
|
+
(:g :p) :app :r.
|
|
225
|
+
(:g :q) :app :r.
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
# -----
|
|
229
|
+
# Query
|
|
230
|
+
# -----
|
|
231
|
+
# Ask for non-trivial cases where equal composite output forces
|
|
232
|
+
# the inputs to be the same.
|
|
233
|
+
|
|
234
|
+
{
|
|
235
|
+
(?h ?x ?y) :sameInputUnderEqualCompositeOutput true.
|
|
236
|
+
?x log:notEqualTo ?y.
|
|
237
|
+
}
|
|
238
|
+
log:query
|
|
239
|
+
{
|
|
240
|
+
:result :sameInputByCompositeInjectivity (?h ?x ?y).
|
|
241
|
+
}.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# ===============================================================
|
|
2
|
+
# File: equivalence-classes-overlap-implies-same-class.n3
|
|
3
|
+
#
|
|
4
|
+
# Purpose
|
|
5
|
+
# -------
|
|
6
|
+
# This file expresses a small result about equivalence relations:
|
|
7
|
+
#
|
|
8
|
+
# If two equivalence classes share an element,
|
|
9
|
+
# then they are the same class.
|
|
10
|
+
#
|
|
11
|
+
# Core idea
|
|
12
|
+
# ---------
|
|
13
|
+
# We choose a framework with a relation :sim and the axioms:
|
|
14
|
+
# - reflexive
|
|
15
|
+
# - symmetric
|
|
16
|
+
# - transitive
|
|
17
|
+
#
|
|
18
|
+
# That is the creative step: we decide to study relations with
|
|
19
|
+
# exactly these properties.
|
|
20
|
+
#
|
|
21
|
+
# Once that framework is fixed, a consequence follows:
|
|
22
|
+
#
|
|
23
|
+
# if some element ?z belongs to both [x] and [y],
|
|
24
|
+
# then [x] and [y] are the same equivalence class.
|
|
25
|
+
#
|
|
26
|
+
# In this file:
|
|
27
|
+
#
|
|
28
|
+
# ?u :inClassOf ?x
|
|
29
|
+
#
|
|
30
|
+
# means that ?u belongs to the equivalence class of ?x,
|
|
31
|
+
# i.e. ?u is related to ?x by :sim.
|
|
32
|
+
#
|
|
33
|
+
# We record class equality using the ordinary relation:
|
|
34
|
+
#
|
|
35
|
+
# (?x ?y) :sameClass true.
|
|
36
|
+
# ===============================================================
|
|
37
|
+
|
|
38
|
+
@prefix : <http://example.org/#>.
|
|
39
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
40
|
+
|
|
41
|
+
# ------------------
|
|
42
|
+
# Carrier membership
|
|
43
|
+
# ------------------
|
|
44
|
+
# We use:
|
|
45
|
+
#
|
|
46
|
+
# ?x :inX true.
|
|
47
|
+
#
|
|
48
|
+
# to indicate that ?x belongs to the underlying set X.
|
|
49
|
+
|
|
50
|
+
# ---------------------------------
|
|
51
|
+
# Axioms of an equivalence relation
|
|
52
|
+
# ---------------------------------
|
|
53
|
+
|
|
54
|
+
# Reflexive:
|
|
55
|
+
# every element is related to itself
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
?x :inX true.
|
|
59
|
+
}
|
|
60
|
+
=>
|
|
61
|
+
{
|
|
62
|
+
?x :sim ?x.
|
|
63
|
+
}.
|
|
64
|
+
|
|
65
|
+
# Symmetric:
|
|
66
|
+
# if x ~ y then y ~ x
|
|
67
|
+
|
|
68
|
+
{
|
|
69
|
+
?x :sim ?y.
|
|
70
|
+
}
|
|
71
|
+
=>
|
|
72
|
+
{
|
|
73
|
+
?y :sim ?x.
|
|
74
|
+
}.
|
|
75
|
+
|
|
76
|
+
# Transitive:
|
|
77
|
+
# if x ~ y and y ~ z then x ~ z
|
|
78
|
+
|
|
79
|
+
{
|
|
80
|
+
?x :sim ?y.
|
|
81
|
+
?y :sim ?z.
|
|
82
|
+
}
|
|
83
|
+
=>
|
|
84
|
+
{
|
|
85
|
+
?x :sim ?z.
|
|
86
|
+
}.
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# -------------------
|
|
90
|
+
# Equivalence classes
|
|
91
|
+
# -------------------
|
|
92
|
+
# Membership in the class of x is just another way to say
|
|
93
|
+
# "is related to x".
|
|
94
|
+
|
|
95
|
+
{
|
|
96
|
+
?u :sim ?x.
|
|
97
|
+
}
|
|
98
|
+
=>
|
|
99
|
+
{
|
|
100
|
+
?u :inClassOf ?x.
|
|
101
|
+
}.
|
|
102
|
+
|
|
103
|
+
# If x ~ y, then x and y determine the same class.
|
|
104
|
+
|
|
105
|
+
{
|
|
106
|
+
?x :sim ?y.
|
|
107
|
+
}
|
|
108
|
+
=>
|
|
109
|
+
{
|
|
110
|
+
(?x ?y) :sameClass true.
|
|
111
|
+
}.
|
|
112
|
+
|
|
113
|
+
# Symmetry of class equality
|
|
114
|
+
|
|
115
|
+
{
|
|
116
|
+
(?x ?y) :sameClass true.
|
|
117
|
+
}
|
|
118
|
+
=>
|
|
119
|
+
{
|
|
120
|
+
(?y ?x) :sameClass true.
|
|
121
|
+
}.
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# -----------
|
|
125
|
+
# The theorem
|
|
126
|
+
# -----------
|
|
127
|
+
# Proof idea:
|
|
128
|
+
#
|
|
129
|
+
# if z is in [x] and z is in [y],
|
|
130
|
+
# then z ~ x and z ~ y
|
|
131
|
+
# so x ~ z by symmetry
|
|
132
|
+
# and x ~ y by transitivity
|
|
133
|
+
# hence [x] = [y]
|
|
134
|
+
#
|
|
135
|
+
# The actual class equality comes from the earlier rules.
|
|
136
|
+
# This rule simply packages the result as an explicit theorem
|
|
137
|
+
# instance with a witness ?z.
|
|
138
|
+
|
|
139
|
+
{
|
|
140
|
+
?z :inClassOf ?x.
|
|
141
|
+
?z :inClassOf ?y.
|
|
142
|
+
(?x ?y) :sameClass true.
|
|
143
|
+
}
|
|
144
|
+
=>
|
|
145
|
+
{
|
|
146
|
+
(?x ?y ?z) :sharedMemberShowsSameClass true.
|
|
147
|
+
}.
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
# -----------------
|
|
151
|
+
# Tiny example data
|
|
152
|
+
# -----------------
|
|
153
|
+
# Here :b belongs to both the class of :a and the class of :c,
|
|
154
|
+
# because we assert:
|
|
155
|
+
#
|
|
156
|
+
# b ~ a
|
|
157
|
+
# b ~ c
|
|
158
|
+
#
|
|
159
|
+
# From the axioms, the reasoner should conclude that
|
|
160
|
+
# the classes of :a and :c are the same.
|
|
161
|
+
|
|
162
|
+
:a :inX true.
|
|
163
|
+
:b :inX true.
|
|
164
|
+
:c :inX true.
|
|
165
|
+
|
|
166
|
+
:b :sim :a.
|
|
167
|
+
:b :sim :c.
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
# -----
|
|
171
|
+
# Query
|
|
172
|
+
# -----
|
|
173
|
+
# Ask for non-trivial cases where a shared member forces
|
|
174
|
+
# two classes to be the same.
|
|
175
|
+
|
|
176
|
+
{
|
|
177
|
+
(?x ?y ?z) :sharedMemberShowsSameClass true.
|
|
178
|
+
?x log:notEqualTo ?y.
|
|
179
|
+
}
|
|
180
|
+
log:query
|
|
181
|
+
{
|
|
182
|
+
:result :sameClassBecauseOfSharedMember (?x ?y ?z).
|
|
183
|
+
}.
|
|
File without changes
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# ===========================================================
|
|
2
|
+
# File: greatest-lower-bound-uniqueness.n3
|
|
3
|
+
#
|
|
4
|
+
# Purpose
|
|
5
|
+
# -------
|
|
6
|
+
# This file expresses a pure mathematical result:
|
|
7
|
+
#
|
|
8
|
+
# In a partial order, a greatest lower bound is unique.
|
|
9
|
+
#
|
|
10
|
+
# Core idea
|
|
11
|
+
# ---------
|
|
12
|
+
# We choose a framework with a relation :leq and the usual
|
|
13
|
+
# order-theoretic laws. Then we introduce the notion of a
|
|
14
|
+
# greatest lower bound of two elements.
|
|
15
|
+
#
|
|
16
|
+
# Once those choices are fixed, the following is no longer
|
|
17
|
+
# optional:
|
|
18
|
+
#
|
|
19
|
+
# if ?m and ?n are both greatest lower bounds of ?a and ?b,
|
|
20
|
+
# then they must be the same.
|
|
21
|
+
#
|
|
22
|
+
# So again:
|
|
23
|
+
# the framework is chosen,
|
|
24
|
+
# but the consequence is forced.
|
|
25
|
+
#
|
|
26
|
+
# Representation
|
|
27
|
+
# --------------
|
|
28
|
+
# ?x :leq ?y
|
|
29
|
+
# means:
|
|
30
|
+
# x ≤ y
|
|
31
|
+
#
|
|
32
|
+
# ?m :glbOf (?a ?b)
|
|
33
|
+
# means:
|
|
34
|
+
# m is a greatest lower bound of a and b
|
|
35
|
+
#
|
|
36
|
+
# (?x ?y) :sameTerm true
|
|
37
|
+
# records provable sameness as an ordinary derived fact.
|
|
38
|
+
# ===========================================================
|
|
39
|
+
|
|
40
|
+
@prefix : <http://example.org/#>.
|
|
41
|
+
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
42
|
+
|
|
43
|
+
# ------------------
|
|
44
|
+
# Carrier membership
|
|
45
|
+
# ------------------
|
|
46
|
+
|
|
47
|
+
# We use:
|
|
48
|
+
#
|
|
49
|
+
# ?x :inP true.
|
|
50
|
+
#
|
|
51
|
+
# to indicate that ?x belongs to the underlying partially
|
|
52
|
+
# ordered set.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# -------------------------
|
|
56
|
+
# Axioms of a partial order
|
|
57
|
+
# -------------------------
|
|
58
|
+
|
|
59
|
+
# Reflexive:
|
|
60
|
+
# every element is ≤ itself
|
|
61
|
+
|
|
62
|
+
{
|
|
63
|
+
?x :inP true.
|
|
64
|
+
}
|
|
65
|
+
=>
|
|
66
|
+
{
|
|
67
|
+
?x :leq ?x.
|
|
68
|
+
}.
|
|
69
|
+
|
|
70
|
+
# Transitive:
|
|
71
|
+
# if x ≤ y and y ≤ z then x ≤ z
|
|
72
|
+
|
|
73
|
+
{
|
|
74
|
+
?x :leq ?y.
|
|
75
|
+
?y :leq ?z.
|
|
76
|
+
}
|
|
77
|
+
=>
|
|
78
|
+
{
|
|
79
|
+
?x :leq ?z.
|
|
80
|
+
}.
|
|
81
|
+
|
|
82
|
+
# Antisymmetric:
|
|
83
|
+
# if x ≤ y and y ≤ x then x and y are the same
|
|
84
|
+
|
|
85
|
+
{
|
|
86
|
+
?x :leq ?y.
|
|
87
|
+
?y :leq ?x.
|
|
88
|
+
}
|
|
89
|
+
=>
|
|
90
|
+
{
|
|
91
|
+
(?x ?y) :sameTerm true.
|
|
92
|
+
}.
|
|
93
|
+
|
|
94
|
+
# Symmetry of provable sameness
|
|
95
|
+
|
|
96
|
+
{
|
|
97
|
+
(?x ?y) :sameTerm true.
|
|
98
|
+
}
|
|
99
|
+
=>
|
|
100
|
+
{
|
|
101
|
+
(?y ?x) :sameTerm true.
|
|
102
|
+
}.
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
# ------------
|
|
106
|
+
# Lower bounds
|
|
107
|
+
# ------------
|
|
108
|
+
|
|
109
|
+
# If m is declared to be a greatest lower bound of a and b,
|
|
110
|
+
# then m is in particular a lower bound of a and b.
|
|
111
|
+
|
|
112
|
+
{
|
|
113
|
+
?m :glbOf (?a ?b).
|
|
114
|
+
}
|
|
115
|
+
=>
|
|
116
|
+
{
|
|
117
|
+
?m :lowerBoundOf (?a ?b).
|
|
118
|
+
?m :leq ?a.
|
|
119
|
+
?m :leq ?b.
|
|
120
|
+
}.
|
|
121
|
+
|
|
122
|
+
# Greatestness:
|
|
123
|
+
# if m is a greatest lower bound of a and b, and l is any
|
|
124
|
+
# lower bound of a and b, then l ≤ m.
|
|
125
|
+
|
|
126
|
+
{
|
|
127
|
+
?m :glbOf (?a ?b).
|
|
128
|
+
?l :lowerBoundOf (?a ?b).
|
|
129
|
+
}
|
|
130
|
+
=>
|
|
131
|
+
{
|
|
132
|
+
?l :leq ?m.
|
|
133
|
+
}.
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
# -------------------------------------------
|
|
137
|
+
# Theorem: uniqueness of greatest lower bound
|
|
138
|
+
# -------------------------------------------
|
|
139
|
+
#
|
|
140
|
+
# Proof idea:
|
|
141
|
+
#
|
|
142
|
+
# Suppose m and n are both greatest lower bounds of a and b.
|
|
143
|
+
#
|
|
144
|
+
# Since n is a lower bound, and m is greatest among all lower
|
|
145
|
+
# bounds, we get:
|
|
146
|
+
#
|
|
147
|
+
# n ≤ m
|
|
148
|
+
#
|
|
149
|
+
# Similarly:
|
|
150
|
+
#
|
|
151
|
+
# m ≤ n
|
|
152
|
+
#
|
|
153
|
+
# By antisymmetry:
|
|
154
|
+
#
|
|
155
|
+
# m = n
|
|
156
|
+
#
|
|
157
|
+
# We record the result in two stages:
|
|
158
|
+
# 1. derive :sameTerm
|
|
159
|
+
# 2. package the theorem as :sameGlb
|
|
160
|
+
|
|
161
|
+
{
|
|
162
|
+
?m :glbOf (?a ?b).
|
|
163
|
+
?n :glbOf (?a ?b).
|
|
164
|
+
(?m ?n) :sameTerm true.
|
|
165
|
+
}
|
|
166
|
+
=>
|
|
167
|
+
{
|
|
168
|
+
(?a ?b ?m ?n) :sameGlb true.
|
|
169
|
+
}.
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
# -----------------
|
|
173
|
+
# Tiny example data
|
|
174
|
+
# -----------------
|
|
175
|
+
# We declare two differently named candidates :g1 and :g2
|
|
176
|
+
# as greatest lower bounds of the same pair (:a, :b).
|
|
177
|
+
#
|
|
178
|
+
# The theory should force them to coincide.
|
|
179
|
+
|
|
180
|
+
:a :inP true.
|
|
181
|
+
:b :inP true.
|
|
182
|
+
:g1 :inP true.
|
|
183
|
+
:g2 :inP true.
|
|
184
|
+
|
|
185
|
+
:g1 :glbOf (:a :b).
|
|
186
|
+
:g2 :glbOf (:a :b).
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
# -----
|
|
190
|
+
# Query
|
|
191
|
+
# -----
|
|
192
|
+
# Ask for non-trivial cases where two differently named
|
|
193
|
+
# greatest lower bounds must coincide.
|
|
194
|
+
|
|
195
|
+
{
|
|
196
|
+
(?a ?b ?m ?n) :sameGlb true.
|
|
197
|
+
?m log:notEqualTo ?n.
|
|
198
|
+
}
|
|
199
|
+
log:query
|
|
200
|
+
{
|
|
201
|
+
:result :sameGreatestLowerBound (?a ?b ?m ?n).
|
|
202
|
+
}.
|