Subject: [rfc-i] An RFC database in Prolog

From: Marc Petit-Huguenin <[email-masked]>
Date: Thu, 26 Aug 2021 13:15:01 -0700

Hello,

I have been working on a Prolog database that would permit to do various queries on RFC metadata and on Errata.

Some people expressed interest in that database and in the scripts I wrote to build it, so I just pushed a git repository that contains that:

git clone git://shalmaneser.org/rfc-prolog

I'll suggest to read first the README.adoc and the FAQ.adoc documents.  I'll be happy to take suggestions and questions on this mailing or directly.  Any response to a question will probably end in the FAQ, especially if it is about providing a Prolog program that does a specific query or processing.  The git repository will be updated weekly with new RFC/Errata.

This work is related to FDT as my goal is to find insights about the usage of FDTs at the IETF in that database.  Questions about that should be sent to [email-masked] or directly.

Thanks.

-- 
Marc Petit-Huguenin
Email: [email-masked]
Blog: https://marc.petit-huguenin.org
Profile: https://www.linkedin.com/in/petithug
_______________________________________________
rfc-interest mailing list
[email-masked]
https://www.rfc-editor.org/mailman/listinfo/rfc-interest

---

From: Lars Eggert <[email-masked]>
Date: Fri, 27 Aug 2021 09:39:05 +0300

Hi,

On 2021-8-26, at 23:15, Marc Petit-Huguenin <[email-masked]> wrote:
> I'll suggest to read first the README.adoc and the FAQ.adoc documents.

is there a way to read those without cloning the repo? http://shalmaneser.org/rfc-prolog doesn't seem to have a web page.

Thanks,
Lars

---

From: Marc Petit-Huguenin <[email-masked]>
Date: Fri, 27 Aug 2021 01:44:39 -0700

Hi,

> is there a way to read those without cloning the repo? http://shalmaneser.org/rfc-prolog doesn't seem to have a web page.

I could overcome my profound dislike of everything web related and install a gitweb daemon, but I am not sure that's worth it.  This is after all just 3 large files that are meant to be loaded in a Prolog REPL, and I am pretty sure that browsing their content outside of a Prolog REPL will be a very boring experience.

---

From: Marc Petit-Huguenin <[email-masked]>
Date: Fri, 27 Aug 2021 04:32:53 -0700

On 8/27/21 4:14 AM, Michael Richardson wrote:
> Marc Petit-Huguenin <[email-masked]> wrote:
>      > I have been working on a Prolog database that would permit to do
>      > various queries on RFC metadata and on Errata.
> 
> Can you give us some examples to wet our appetite?

Here's one that exports the errata database as a CSV file:

[source,prolog]
----
:- import format/2 from format.
:- [errata].
:- [rfcs].

month(1, 'January').
month(2, 'February').
month(3, 'March').
month(4, 'April').
month(5, 'May').
month(6, 'June').
month(7, 'July').
month(8, 'August').
month(9, 'September').
month(10, 'October').
month(11, 'November').
month(12, 'December').

:- erratum(Id, Formats, Rfc, Reporter, Date, Type, Status),
    rfc(Rfc, Title, _, _, _, date(Y, M), Wg, Area, _),
    month(M, MM),
    functor(Status, S, _),
    format("\"RFC~d\", \"~a\", \"~a ~d\", \"~a\"~n", [Rfc, Title, MM, Y, S]),
    fail.
----

Another that lists all the RFCs that changed status:

[source,prolog]
----
:- import format/2 from format.
:- [metadata].
:- [rfcs].

:- rfc(Rfc, Title, _, Status, _, _, _, _, _),
    metadatum(Rfc, Status2), Status \= Status2,
    format("RFC~d ~a from ~a to ~a~n", [Rfc, Title, Status, Status2]),
    fail.
----

Just copy the one of the content above (between the "----") in a file with the ".P" extension, then you just have to `xsb <file>` (without the .P extension) to run it.

This is code, so the possibilities are endless.

> 
> Does this system know why RFC8990 took 4.5 years to publish, for instance?

Not with the current database, as that would require to add the content of the datatracker database in it.

The table I am currently preparing is the reference table, which looks like this:

:- auto_table.

[source,prolog]
----
reference(9047, 'Normative', rfc(2119)).
reference(9047, 'Normative', rfc(4861)).
reference(9047, 'Normative', rfc(7432)).
reference(9047, 'Normative', rfc(8174)).
reference(9047, 'Informative', i-d('draft-rbickhart-evpn-ip-mac-proxy-adv-01')).
reference(9047, 'Informative', i-d('draft-ietf-bess-evpn-irb-extended-mobility-05')).
reference(9047, 'Informative', iana('bgp-extended-communities')).
reference(9047, 'Informative', rfc(8126)).
...
----

After that I was thinking of adding a table for IPR declarations but, time permitting, I can work on other content.

---

From: Marc Petit-Huguenin <[email-masked]>
Date: Fri, 27 Aug 2021 06:06:04 -0700

On 8/27/21 4:32 AM, Marc Petit-Huguenin wrote:
>>      > I have been working on a Prolog database that would permit to do
>>      > various queries on RFC metadata and on Errata.
>>

Do it again! Do it again!

OK.  What is the longest obsolescence chain of RFCs?

[source,prolog]
----
:- import format/2 from format.
:- import length/2 from basics.
:- import concat_atom/3 from string.
:- [metadata].
:- [rfcs].

chain(Rfc, List) :-
   obsoletes(Rfc, Prev),
   chain(Prev, L),
   List = [Rfc|L].
chain(Rfc, [Rfc]).

chains(Length - Chain) :-
   rfc(Rfc, _, _, _, _, _, _, _, _),
   chain(Rfc, List),
   length(List, Length),
   concat_atom(List, ' ', Chain).

print_chains([]).
print_chains([_ - L|Xs]) :-
   writeln(L),
   print_chains(Xs).
   
:-
   findall(X, chains(X), List),
   keysort(List, Sorted),
   print_chains(Sorted).
----