-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding --logic-program <pl-file> option
- Loading branch information
Showing
84 changed files
with
134,717 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
11.1.4 | ||
11.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Logic Programming | ||
|
||
- Using webized prolog which basically means that atoms can be IRIs. | ||
- Besides top-down reasoning with `conclusion :- premise` rules, it also does bottom-up reasoning with `conclusion := premise` rules. | ||
- Bottum-up reasoning can use `stable(n)` to fail if the deductive closure at level `n` is not yet stable. | ||
- Proofs steps are `step((conclusion := premise), premise_inst, conclusion_inst)` and `conclusion_inst` is asserted. | ||
- Variables are interpreted as universally quantified variables except for `conclusion := premise` conclusion-only variables which are interpreted existentially. | ||
- Queries are posed as `true := premise` and answered as `answer(premise_inst)`. | ||
- Inference fuses are defined as `false := premise` and blown as `fuse(premise_inst)` with return code 2. | ||
|
||
## Rationale for bottom-up reasoning with `conclusion := premise` rules | ||
|
||
- conclusion can be a conjunction | ||
- conclusion can be `false` to blow an inference fuse | ||
- conclusion can be `true` to pose a query | ||
- conclusion can not be any other built-in | ||
- conclusion-only variables are existentials | ||
- generating proofs using `step/3` proof steps | ||
- avoiding loops that could occur with backward chaining |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
% Ackermann function | ||
% See https://en.wikipedia.org/wiki/Ackermann_function | ||
|
||
% ackermann(x, y, z) | ||
'urn:example:ackermann'([A, B], C) :- | ||
D is B+3, | ||
ackermann(A, D, 2, E), | ||
C is E-3. | ||
|
||
% succ (x=0) | ||
ackermann(0, A, _, B) :- | ||
!, | ||
B is A+1. | ||
|
||
% sum (x=1) | ||
ackermann(1, A, B, C) :- | ||
!, | ||
C is A+B. | ||
|
||
% product (x=2) | ||
ackermann(2, A, B, C) :- | ||
!, | ||
C is A*B. | ||
|
||
% exponentiation (x=3), tetration (x=4), pentation (x=5), hexation (x=6), etc | ||
ackermann(_, 0, _, 1) :- | ||
!. | ||
ackermann(A, B, C, D) :- | ||
E is B-1, | ||
ackermann(A, E, C, F), | ||
G is A-1, | ||
ackermann(G, F, C, D). | ||
|
||
% queries | ||
true := 'urn:example:ackermann'([0, 6], _). | ||
true := 'urn:example:ackermann'([1, 2], _). | ||
true := 'urn:example:ackermann'([1, 7], _). | ||
true := 'urn:example:ackermann'([2, 2], _). | ||
true := 'urn:example:ackermann'([2, 9], _). | ||
true := 'urn:example:ackermann'([3, 4], _). | ||
true := 'urn:example:ackermann'([3, 14], _). | ||
true := 'urn:example:ackermann'([4, 0], _). | ||
true := 'urn:example:ackermann'([4, 1], _). | ||
true := 'urn:example:ackermann'([4, 2], _). | ||
true := 'urn:example:ackermann'([5, 0], _). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
% Access control policy example | ||
|
||
'urn:example:policy'('urn:example:test1', 'urn:example:PolicyX'). | ||
'urn:example:has'('urn:example:test1', 'urn:example:A'). | ||
'urn:example:has'('urn:example:test1', 'urn:example:B'). | ||
'urn:example:has'('urn:example:test1', 'urn:example:C'). | ||
'urn:example:Policy'('urn:example:PolicyX'). | ||
'urn:example:allOf'('urn:example:PolicyX', 'urn:example:A'). | ||
'urn:example:allOf'('urn:example:PolicyX', 'urn:example:B'). | ||
'urn:example:anyOf'('urn:example:PolicyX', 'urn:example:C'). | ||
'urn:example:noneOf'('urn:example:PolicyX', 'urn:example:D'). | ||
|
||
'urn:example:pass'(A, 'urn:example:allOfTest') :- | ||
'urn:example:policy'(B, A), | ||
'urn:example:Policy'(A), | ||
forall( | ||
'urn:example:allOf'(A, C), | ||
'urn:example:has'(B, C) | ||
). | ||
|
||
'urn:example:pass'(A, 'urn:example:anyOfTest') :- | ||
'urn:example:policy'(B, A), | ||
'urn:example:Policy'(A), | ||
findall(C, | ||
( | ||
'urn:example:anyOf'(A, C), | ||
'urn:example:has'(B, C) | ||
), | ||
D | ||
), | ||
length(D, E), | ||
E \= 0. | ||
|
||
'urn:example:pass'(A, 'urn:example:noneOfTest') :- | ||
'urn:example:policy'(B, A), | ||
'urn:example:Policy'(A), | ||
findall(C, | ||
( | ||
'urn:example:noneOf'(A, C), | ||
'urn:example:has'(B, C) | ||
), | ||
D | ||
), | ||
length(D, 0). | ||
|
||
% query | ||
true := | ||
'urn:example:Policy'(A), | ||
'urn:example:pass'(A, 'urn:example:allOfTest'), | ||
'urn:example:pass'(A, 'urn:example:anyOfTest'), | ||
'urn:example:pass'(A, 'urn:example:noneOfTest'). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
% age checker | ||
|
||
% person data | ||
'urn:example:birthDay'('urn:example:patH', [1944, 8, 21]). | ||
|
||
% is the age of a person above some years? | ||
'urn:example:ageAbove'(S, A) :- | ||
'urn:example:birthDay'(S, [Yb, Mb, Db]), | ||
Ya is Yb+A, | ||
date_time_stamp(date(Ya, Mb, Db, 22, 0, 0, _, _, _), Tc), | ||
get_time(T), | ||
Tc =< T. | ||
|
||
% query | ||
true := 'urn:example:ageAbove'(_, 80). |
Oops, something went wrong.