Skip to content

Commit

Permalink
using lingua:if to describe backward rules
Browse files Browse the repository at this point in the history
  • Loading branch information
josd committed Mar 23, 2024
1 parent e7c3572 commit bda11f5
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 73 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:backimplication _:ng2.
_:ng1 lingua:if _: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.5
1.0.6
12 changes: 6 additions & 6 deletions lingua/ackermann.trig
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@prefix : <#>.

# ackermann(x, y)
_:ng1 lingua:backimplication _:ng2.
_:ng1 lingua:if _:ng2.

_:ng1 {
(var:X var:Y) :ackermann var:A.
Expand All @@ -41,7 +41,7 @@ _:ng2 {

# ackermann(x, y, z)
# succ (x=0)
_:ng3 lingua:backimplication _:ng4.
_:ng3 lingua:if _:ng4.

_:ng3 {
(0 var:Y var:Z) :ackermann var:A.
Expand All @@ -53,7 +53,7 @@ _:ng4 {
}

# sum (x=1)
_:ng5 lingua:backimplication _:ng6.
_:ng5 lingua:if _:ng6.

_:ng5 {
(1 var:Y var:Z) :ackermann var:A.
Expand All @@ -65,7 +65,7 @@ _:ng6 {
}

# product (x=2)
_:ng7 lingua:backimplication _:ng8.
_:ng7 lingua:if _:ng8.

_:ng7 {
(2 var:Y var:Z) :ackermann var:A.
Expand All @@ -77,7 +77,7 @@ _:ng8 {
}

# exponentiation (x=3), tetration (x=4), pentation (x=5), hexation (x=6), etc
_:ng9 lingua:backimplication _:ng10.
_:ng9 lingua:if _:ng10.

_:ng9 {
(var:X 0 var:Z) :ackermann 1.
Expand All @@ -87,7 +87,7 @@ _:ng10 {
_:ng13 log:callWithCut true.
}

_:ng11 lingua:backimplication _:ng12.
_:ng11 lingua:if _:ng12.

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

_:ng1 lingua:backimplication _:ng2.
_:ng1 lingua:if _:ng2.

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

_:ng5 lingua:backimplication _:ng6.
_:ng5 lingua:if _:ng6.

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

_:ng8 lingua:backimplication _:ng9.
_:ng8 lingua:if _:ng9.

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

# something is more interesting if it is greater
_:ng1 lingua:backimplication _:ng2.
_:ng1 lingua:if _:ng2.

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

# exponentiation
_:ng1 lingua:backimplication _:ng2.
_:ng1 lingua:if _:ng2.

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

# asin
_:ng3 lingua:backimplication _:ng4.
_:ng3 lingua:if _:ng4.

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

# acos
_:ng5 lingua:backimplication _:ng6.
_:ng5 lingua:if _:ng6.

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

# polar
_:ng7 lingua:backimplication _:ng8.
_:ng7 lingua:if _:ng8.

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

# dial
_:ng9 lingua:backimplication _:ng10.
_:ng9 lingua:if _:ng10.

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

_:ng11 lingua:backimplication _:ng12.
_:ng11 lingua:if _:ng12.

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

_:ng13 lingua:backimplication _:ng14.
_:ng13 lingua:if _:ng14.

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

_:ng15 lingua:backimplication _:ng16.
_:ng15 lingua:if _:ng16.

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

# calculate easter day
_:ng1 lingua:backimplication _:ng2.
_:ng1 lingua:if _:ng2.

_:ng1 {
(var:x0) :easter (var:x34 var:x32).
Expand Down
2 changes: 1 addition & 1 deletion lingua/edt.trig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ _:ng1 {
<> log:imports <../../eye/reasoning/edt/test-dl.ttl>.
}

_:ng2 lingua:backimplication _:ng3.
_:ng2 lingua:if _:ng3.

_:ng2 {
var:X a var:D.
Expand Down
8 changes: 4 additions & 4 deletions lingua/fibonacci.trig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@prefix : <#>.

# backward rules
_:ng1 lingua:backimplication _:ng2.
_:ng1 lingua:if _:ng2.

_:ng1 {
(var:X) :fibonacci var:Y.
Expand All @@ -20,19 +20,19 @@ _:ng2 {
(var:X 0 1) :fib var:Y.
}

_:ng3 lingua:backimplication true.
_:ng3 lingua:if true.

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

_:ng4 lingua:backimplication true.
_:ng4 lingua:if true.

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

_:ng5 lingua:backimplication _:ng6.
_:ng5 lingua:if _:ng6.

_:ng5 {
(var:X var:A var:B) :fib var:Y.
Expand Down
22 changes: 11 additions & 11 deletions lingua/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
_:ng1 lingua:backimplication _:ng2.
_:ng1 lingua:if _:ng2.

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

_:ng3 lingua:backimplication _:ng4.
_:ng3 lingua:if _:ng4.

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

_:ng5 lingua:backimplication _:ng6.
_:ng5 lingua:if _:ng6.

_:ng5 {
() 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 @@ _:ng6 {
var:Goal log:call true.
}

_:ng7 lingua:backimplication _:ng8.
_:ng7 lingua:if _:ng8.

_:ng7 {
() 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 @@ _:ng10 {
}

# counting the number of stages (a stage is a sequence of gps in the same map)
_:ng11 lingua:backimplication true.
_:ng11 lingua:if true.

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

_:ng12 lingua:backimplication _:ng13.
_:ng12 lingua:if _:ng13.

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

_:ng14 lingua:backimplication _:ng15.
_:ng14 lingua:if _:ng15.

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

# map of Belgium
_:ng16 lingua:backimplication _:ng17.
_:ng16 lingua:if _:ng17.

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

_:ng20 lingua:backimplication _:ng21.
_:ng20 lingua:if _:ng21.

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

_:ng24 lingua:backimplication _:ng25.
_:ng24 lingua:if _:ng25.

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

_:ng28 lingua:backimplication _:ng29.
_:ng28 lingua:if _:ng29.

_:ng28 {
:map-BE gps:description (_:ng30 true _:ng31 :drive_brugge_oostende 900.0 0.004 0.98 1.0).
Expand Down
14 changes: 7 additions & 7 deletions lingua/mi.trig
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
@prefix : <#>.

# meta-interpreter rules
_:mi_rule1_head lingua:backimplication true.
_:mi_rule1_head lingua:if true.

_:mi_rule1_head {
() :mi ().
}

_:mi_rule2_head lingua:backimplication _:mi_rule2_body.
_:mi_rule2_head lingua:if _:mi_rule2_body.

_:mi_rule2_head {
() :mi var:A.
Expand All @@ -29,7 +29,7 @@ _:mi_rule2_body {
}

# general head-body rules
_:hb_rule1_head lingua:backimplication true.
_:hb_rule1_head lingua:if true.

_:hb_rule1_head {
() :headBody (_:hb_rule1_head_graph1 var:Rs var:Rs).
Expand All @@ -39,7 +39,7 @@ _:hb_rule1_head_graph1 {
() :mi ().
}

_:hb_rule2_head lingua:backimplication _:hb_rule2_body.
_:hb_rule2_head lingua:if _:hb_rule2_body.

_:hb_rule2_head {
() :headBody (_:hb_rule2_head_graph1 var:B var:Rs).
Expand All @@ -63,7 +63,7 @@ _:hb_rule2_body_graph2 {
() :mi var:Goals.
}

_:hb_rule3_head lingua:backimplication _:hb_rule3_body.
_:hb_rule3_head lingua:if _:hb_rule3_body.

_:hb_rule3_head {
() :headBody (_:hb_rule3_head_graph1 var:Rs var:Rs).
Expand All @@ -78,7 +78,7 @@ _:hb_rule3_body {
}

# natnum head-body rules
_:natnum_hb_rule1_head lingua:backimplication true.
_:natnum_hb_rule1_head lingua:if true.

_:natnum_hb_rule1_head {
() :headBody (_:natnum_hb_rule1_head_graph1 var:Rs var:Rs).
Expand All @@ -88,7 +88,7 @@ _:natnum_hb_rule1_head_graph1 {
() :natnum (0).
}

_:natnum_hb_rule2_head lingua:backimplication _:natnum_hb_rule2_body.
_:natnum_hb_rule2_head lingua:if _:natnum_hb_rule2_body.

_:natnum_hb_rule2_head {
() :headBody (_:natnum_hb_rule2_head_graph1 var:A var:Rs).
Expand Down
Loading

0 comments on commit bda11f5

Please sign in to comment.