Skip to content

Commit

Permalink
using lingua:component to describe backward rules
Browse files Browse the repository at this point in the history
  • Loading branch information
josd committed Apr 4, 2024
1 parent 0d9c8a5 commit 29869a5
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 79 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ A forward rule with `lingua:implication false` is an inference fuse.

Lingua also supports reasoning with backward rules described in RDF as
```
_:ng1 lingua:hornb _:ng2. # hornb is an acronym for "head or not body"
_:ng1 lingua:component _:ng2.
_:ng1 {
RDF triples
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.1
1.0.2
12 changes: 6 additions & 6 deletions etc/ackermann.trig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
[] lingua:explanation [].

# ackermann(x, y)
_:bng_1 lingua:hornb _:bng_2.
_:bng_1 lingua:component _:bng_2.

_:bng_1 {
(var:X var:Y) :ackermann var:A.
Expand All @@ -45,7 +45,7 @@ _:bng_2 {

# ackermann(x, y, z)
# succ (x=0)
_:bng_3 lingua:hornb _:bng_4.
_:bng_3 lingua:component _:bng_4.

_:bng_3 {
(0 var:Y var:Z) :ackermann var:A.
Expand All @@ -57,7 +57,7 @@ _:bng_4 {
}

# sum (x=1)
_:bng_5 lingua:hornb _:bng_6.
_:bng_5 lingua:component _:bng_6.

_:bng_5 {
(1 var:Y var:Z) :ackermann var:A.
Expand All @@ -69,7 +69,7 @@ _:bng_6 {
}

# product (x=2)
_:bng_7 lingua:hornb _:bng_8.
_:bng_7 lingua:component _:bng_8.

_:bng_7 {
(2 var:Y var:Z) :ackermann var:A.
Expand All @@ -81,7 +81,7 @@ _:bng_8 {
}

# exponentiation (x=3), tetration (x=4), pentation (x=5), hexation (x=6), etc
_:bng_9 lingua:hornb _:bng_10.
_:bng_9 lingua:component _:bng_10.

_:bng_9 {
(var:X 0 var:Z) :ackermann 1.
Expand All @@ -91,7 +91,7 @@ _:bng_10 {
[] rdf:value true; log:callWithCut true.
}

_:bng_11 lingua:hornb _:bng_12.
_:bng_11 lingua:component _:bng_12.

_:bng_11 {
(var:X var:Y var:Z) :ackermann var:A.
Expand Down
6 changes: 3 additions & 3 deletions etc/acp.trig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
:anyOf :C;
:noneOf :D.

_:bng_1 lingua:hornb _:bng_2.
_:bng_1 lingua:component _:bng_2.

_:bng_1 {
var:Pol :pass :allOfTest.
Expand All @@ -36,7 +36,7 @@ _:bng_4 {
var:Test :has var:Field.
}

_:bng_5 lingua:hornb _:bng_6.
_:bng_5 lingua:component _:bng_6.

_:bng_5 {
var:Pol :pass :anyOfTest.
Expand All @@ -55,7 +55,7 @@ _:bng_7 {
var:Test :has var:Field.
}

_:bng_8 lingua:hornb _:bng_9.
_:bng_8 lingua:component _:bng_9.

_:bng_8 {
var:Pol :pass :noneOfTest.
Expand Down
2 changes: 1 addition & 1 deletion etc/backward.trig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@prefix : <#>.

# something is more interesting if it is greater
_:bng_1 lingua:hornb _:bng_2.
_:bng_1 lingua:component _:bng_2.

_:bng_1 {
var:X :moreInterestingThan var:Y.
Expand Down
16 changes: 8 additions & 8 deletions etc/complex.trig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@prefix : <#>.

# exponentiation
_:bng_1 lingua:hornb _:bng_2.
_:bng_1 lingua:component _:bng_2.

_:bng_1 {
((var:A var:B) (var:C var:D)) complex:exponentiation (var:E var:F).
Expand All @@ -34,7 +34,7 @@ _:bng_2 {
}

# asin
_:bng_3 lingua:hornb _:bng_4.
_:bng_3 lingua:component _:bng_4.

_:bng_3 {
(var:A var:B) complex:asin (var:C var:D).
Expand Down Expand Up @@ -63,7 +63,7 @@ _:bng_4 {
}

# acos
_:bng_5 lingua:hornb _:bng_6.
_:bng_5 lingua:component _:bng_6.

_:bng_5 {
(var:A var:B) complex:acos (var:C var:D).
Expand Down Expand Up @@ -93,7 +93,7 @@ _:bng_6 {
}

# polar
_:bng_7 lingua:hornb _:bng_8.
_:bng_7 lingua:component _:bng_8.

_:bng_7 {
(var:X var:Y) complex:polar(var:R var:Tp).
Expand All @@ -111,7 +111,7 @@ _:bng_8 {
}

# dial
_:bng_9 lingua:hornb _:bng_10.
_:bng_9 lingua:component _:bng_10.

_:bng_9 {
(var:X var:Y var:T) complex:dial var:Tp.
Expand All @@ -123,7 +123,7 @@ _:bng_10 {
(0 var:T) math:sum var:Tp.
}

_:bng_11 lingua:hornb _:bng_12.
_:bng_11 lingua:component _:bng_12.

_:bng_11 {
(var:X var:Y var:T) complex:dial var:Tp.
Expand All @@ -135,7 +135,7 @@ _:bng_12 {
(3.141592653589793 var:T) math:difference var:Tp.
}

_:bng_13 lingua:hornb _:bng_14.
_:bng_13 lingua:component _:bng_14.

_:bng_13 {
(var:X var:Y var:T) complex:dial var:Tp.
Expand All @@ -147,7 +147,7 @@ _:bng_14 {
(3.141592653589793 var:T) math:sum var:Tp.
}

_:bng_15 lingua:hornb _:bng_16.
_:bng_15 lingua:component _:bng_16.

_:bng_15 {
(var:X var:Y var:T) complex:dial var:Tp.
Expand Down
2 changes: 1 addition & 1 deletion etc/easter.trig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@prefix : <#>.

# calculate easter day
_:bng_1 lingua:hornb _:bng_2.
_:bng_1 lingua:component _:bng_2.

_:bng_1 {
var:x0 :easter (var:x34 var:x32).
Expand Down
2 changes: 1 addition & 1 deletion etc/edt.trig
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ _:bng_1 {
}

# rdfs subclass rule
_:bng_2 lingua:hornb _:bng_3.
_:bng_2 lingua:component _:bng_3.

_:bng_2 {
var:X a var:D.
Expand Down
8 changes: 4 additions & 4 deletions etc/fibonacci.trig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[] lingua:explanation [].

# backward rules
_:bng_1 lingua:hornb _:bng_2.
_:bng_1 lingua:component _:bng_2.

_:bng_1 {
var:X :fibonacci var:Y.
Expand All @@ -25,19 +25,19 @@ _:bng_2 {
(var:X 0 1) :fib var:Y.
}

_:bng_3 lingua:hornb true.
_:bng_3 lingua:component true.

_:bng_3 {
(0 var:A var:B) :fib var:A.
}

_:bng_4 lingua:hornb true.
_:bng_4 lingua:component true.

_:bng_4 {
(1 var:A var:B) :fib var:B.
}

_:bng_5 lingua:hornb _:bng_6.
_:bng_5 lingua:component _:bng_6.

_:bng_5 {
(var:X var:A var:B) :fib var:Y.
Expand Down
14 changes: 7 additions & 7 deletions etc/gcc.trig
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
[] rdf:value 0; :inv 1.
[] rdf:value 1; :inv 0.

_:bng_1 lingua:hornb true.
_:bng_1 lingua:component true.

_:bng_1 {
(var:D 0 var:Q) :dff var:Q.
}

_:bng_2 lingua:hornb true.
_:bng_2 lingua:component true.

_:bng_2 {
(var:D 1 var:Q) :dff var:D.
}

_:bng_3 lingua:hornb _:bng_4.
_:bng_3 lingua:component _:bng_4.

_:bng_3 {
(var:A var:B) :neta var:Q.
Expand All @@ -46,7 +46,7 @@ _:bng_4 {
(var:T1 var:T2) :or var:Q.
}

_:bng_5 lingua:hornb _:bng_6.
_:bng_5 lingua:component _:bng_6.

_:bng_5 {
(var:A var:B var:C) :netb (var:Q1 var:Q2).
Expand All @@ -62,7 +62,7 @@ _:bng_6 {
(var:T2 var:T3) :or var:Q2.
}

_:bng_7 lingua:hornb _:bng_8.
_:bng_7 lingua:component _:bng_8.

_:bng_7 {
(var:C (var:Qa var:Qb var:Qc)) :gcc (var:Za var:Zb var:Zc).
Expand All @@ -76,13 +76,13 @@ _:bng_8 {
(var:D3 var:C var:Qc) :dff var:Zc.
}

_:bng_9 lingua:hornb true.
_:bng_9 lingua:component true.

_:bng_9 {
(() var:S) :testgcc ().
}

_:bng_10 lingua:hornb _:bng_11.
_:bng_10 lingua:component _:bng_11.

_:bng_10 {
(var:Cc var:S) :testgcc var:Nc.
Expand Down
22 changes: 11 additions & 11 deletions etc/gps.trig
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@prefix : <#>.

# find paths in the state space from initial state to goal state within limits
_:bng_1 lingua:hornb _:bng_2.
_:bng_1 lingua:component _:bng_2.

_:bng_1 {
() gps:findpath (var:Goal var:Path var:Duration var:Cost var:Belief var:Comfort
Expand All @@ -40,7 +40,7 @@ _:bng_2 {
(var:MaxDuration var:MaxCost var:MinBelief var:MinComfort 1)).
}

_:bng_3 lingua:hornb _:bng_4.
_:bng_3 lingua:component _:bng_4.

_:bng_3 {
() gps:findpath (var:Goal var:Path var:Duration var:Cost var:Belief var:Comfort
Expand All @@ -52,7 +52,7 @@ _:bng_4 {
(var:MaxDuration var:MaxCost var:MinBelief var:MinComfort var:MaxStagecount)).
}

_:bng_5 lingua:hornb _:bng_6.
_:bng_5 lingua:component _:bng_6.

_:bng_5 {
() gps:findpaths (var:Maps var:Goal var:Path var:Duration var:Cost var:Belief var:Comfort var:Path var:Duration var:Cost var:Belief var:Comfort
Expand All @@ -63,7 +63,7 @@ _:bng_6 {
var:Goal log:call true.
}

_:bng_7 lingua:hornb _:bng_8.
_:bng_7 lingua:component _:bng_8.

_:bng_7 {
() gps:findpaths (var:Maps_s var:Goal var:Path_s var:Duration_s var:Cost_s var:Belief_s var:Comfort_s var:Path var:Duration var:Cost var:Belief var:Comfort
Expand Down Expand Up @@ -98,13 +98,13 @@ _:bng_10 {
}

# counting the number of stages (a stage is a sequence of gps in the same map)
_:bng_11 lingua:hornb true.
_:bng_11 lingua:component true.

_:bng_11 {
() gps:stagecount 1.
}

_:bng_12 lingua:hornb _:bng_13.
_:bng_12 lingua:component _:bng_13.

_:bng_12 {
var:A gps:stagecount var:B.
Expand All @@ -118,7 +118,7 @@ _:bng_13 {
(var:G 1) math:sum var:B.
}

_:bng_14 lingua:hornb _:bng_15.
_:bng_14 lingua:component _:bng_15.

_:bng_14 {
var:A gps:stagecount var:B.
Expand All @@ -133,7 +133,7 @@ _:bng_15 {
:i1 :location :Gent.

# map of Belgium
_:bng_16 lingua:hornb _:bng_17.
_:bng_16 lingua:component _:bng_17.

_:bng_16 {
:map-BE gps:description (_:bng_18 true _:bng_19 :drive_gent_brugge 1500.0 0.006 0.96 0.99).
Expand All @@ -151,7 +151,7 @@ _:bng_19 {
var:S :location :Brugge.
}

_:bng_20 lingua:hornb _:bng_21.
_:bng_20 lingua:component _:bng_21.

_:bng_20 {
:map-BE gps:description (_:bng_22 true _:bng_23 :drive_gent_kortrijk 1600.0 0.007 0.96 0.99).
Expand All @@ -169,7 +169,7 @@ _:bng_23 {
var:S :location :Kortrijk.
}

_:bng_24 lingua:hornb _:bng_25.
_:bng_24 lingua:component _:bng_25.

_:bng_24 {
:map-BE gps:description (_:bng_26 true _:bng_27 :drive_kortrijk_brugge 1600.0 0.007 0.96 0.99).
Expand All @@ -187,7 +187,7 @@ _:bng_27 {
var:S :location :Brugge.
}

_:bng_28 lingua:hornb _:bng_29.
_:bng_28 lingua:component _:bng_29.

_:bng_28 {
:map-BE gps:description (_:bng_30 true _:bng_31 :drive_brugge_oostende 900.0 0.004 0.98 1.0).
Expand Down
Loading

0 comments on commit 29869a5

Please sign in to comment.