[rfc-i] An RFC database in Prolog

Marc Petit-Huguenin marc at petit-huguenin.org
Mon Sep 13 05:31:48 PDT 2021


FWIW the rfc-prolog git repo was just updated with a new Prolog table containing the references for RFCs 4001 and up.  References in RFCs lower than 4000 are less consistent, so it'll take more work to extract the references from these.  The classification of references (i-d, iso, itu-t and so on) will also improve as I improve my scripts.

On 8/27/21 6:06 AM, Marc Petit-Huguenin wrote:
> On 8/27/21 4:32 AM, Marc Petit-Huguenin wrote:
>> On 8/27/21 4:14 AM, Michael Richardson wrote:
>>> Marc Petit-Huguenin <marc at petit-huguenin.org> 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.
>>
> 
> 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).
> ----
> 


-- 
Marc Petit-Huguenin
Email: marc at petit-huguenin.org
Blog: https://marc.petit-huguenin.org
Profile: https://www.linkedin.com/in/petithug


More information about the rfc-interest mailing list