skew_list law catalogue

View Source

Every export has a results law <export>_matches_<oracle>, an exceptions law <export>_raises_like_<oracle> when it can raise, and a validity law <export>_preserves_valid when it returns a skew list. The @catalogue map in verify.exs is the machine-checked copy of this table. A maintainer approves each law statement before its proof is written.

elements/1 is the trusted reference for "the elements of a skew list in order". It lives in src/skew_list_laws.erl and is reviewed like ref_update/3.

LawStatementUsesPhaseApprovedStatus
new_matches_listelements(new()) =:= []elements/11verified
new_preserves_validis_valid(new())is_valid/1, SkewList.new_valid1verified
cons_matches_listvalid S: elements(cons(X, S)) =:= [X | elements(S)]cons_refines, cons_correct2verified
cons_preserves_validvalid S: is_valid(cons(X, S))cons_valid2verified
hd_matches_erlangvalid non-empty S: hd(S) =:= erlang:hd(elements(S))hd_refines, hd_correct, hd_link2verified
hd_raises_like_erlangvalid S: hd(S) and erlang:hd(elements(S)) return or raise alikeas above2verified
tl_matches_erlangvalid non-empty S: elements(tl(S)) =:= erlang:tl(elements(S))tl_refines, tl_correct, tl_link2verified
tl_raises_like_erlangvalid S: tl(S) and erlang:tl(elements(S)) return or raise alikeas above2verified
tl_preserves_validvalid non-empty S: is_valid(tl(S))tl_valid2verified
length_matches_erlangvalid S: length(S) =:= erlang:length(elements(S))length_correct2verified
to_list_matches_listvalid S: to_list(S) =:= elements(S)to_list_refines2verified
from_list_matches_listproper L: elements(from_list(L)) =:= Lfrom_list_refines, fromList_correct2verified
from_list_raises_like_erlangany L: from_list(L) and erlang:length(L) succeed or raise alikelength_sound, length_error2verified
from_list_preserves_validproper L: is_valid(from_list(L))fromList_valid2verified
equal_iff_elements_equalvalid S1, S2: (S1 =:= S2) =:= (elements(S1) =:= elements(S2))canonical_unique, exactEq_encode2verified
obs_hd_consvalid S: hd(cons(X, S)) =:= Xcons_refines, hd_refines2verified
obs_tl_consvalid S: tl(cons(X, S)) =:= Stl_cons2verified
obs_length_consvalid S: length(cons(X, S)) =:= length(S) + 1cons_refines2verified
nth_matches_listsvalid S, integer 1 =< N =< length(S): nth(N, S) =:= lists:nth(N, elements(S))nth_refines, nth_correct, nth_link3verified
nth_raises_like_listsvalid S, any N: nth(N, S) and lists:nth(N, elements(S)) return or raise alikeas above3verified
update_matches_ref_updatevalid S, N in range: elements(update(N, X, S)) =:= ref_update(N, X, elements(S))update_refines, update_correct, ref_update_link3verified
update_raises_like_ref_updatevalid S, any N: update and ref_update return or raise alikeas above3verified
update_preserves_validvalid S, N in range: is_valid(update(N, X, S))update_valid3verified
obs_nth_1_is_hdvalid non-empty S: nth(1, S) =:= hd(S)nth_correct, hd_correct3verified
nthtail_matches_listsvalid S, integer 0 =< N =< length(S): elements(nthtail(N, S)) =:= lists:nthtail(N, elements(S))nthtail_refines, nthtail_correct, nthtail_link4verified
nthtail_raises_like_listsvalid S, any N: nthtail and lists:nthtail return or raise alikeas above4verified
nthtail_preserves_validvalid S, N in range: is_valid(nthtail(N, S))nthtail_valid (via dropTrees_eq: dropping equals N calls of tl)4verified
reverse_matches_listsvalid S: elements(reverse(S)) =:= lists:reverse(elements(S))reverse_refines, reverse_link (trusts Lynx's model of lists:reverse/2), fromList_correctT12026-11-28verified
reverse_preserves_validvalid S: is_valid(reverse(S))reverse_refines, fromList_validT12026-11-28verified
append_matches_listsvalid S1, S2: elements(append(S1, S2)) =:= lists:append(elements(S1), elements(S2))append_refines, append_spec, append_link (trusts Lynx's model of ++)T22026-11-28verified
append_preserves_validvalid S1, S2: is_valid(append(S1, S2))append_refines, append_specT22026-11-28verified
foldl_matches_listsvalid S, any F in the fun table, lists:foldl(F, Acc, elements(S)) returns¹: foldl(F, Acc, S) =:= lists:foldl(F, Acc, elements(S))foldl_agrees (for every dispatcher), foldl_refines, foldl_link, SkewList.foldlM_orderT32026-11-28verified
foldl_raises_like_listsvalid S, any F in the fun table, lists:foldl returns or raises¹: both return or raise alikeas aboveT32026-11-28verified
foldr_matches_listsvalid S, any F in the fun table, lists:foldr(F, Acc, elements(S)) returns¹: foldr(F, Acc, S) =:= lists:foldr(F, Acc, elements(S))foldr_agrees (for every dispatcher), foldr_refines, foldr_link, SkewList.foldrM_orderT42026-11-28verified
foldr_raises_like_listsvalid S, any F in the fun table, lists:foldr returns or raises¹: both return or raise alikeas aboveT42026-11-28verified
map_matches_listsvalid S, any F in the fun table, lists:map(F, elements(S)) returns¹: elements(map(F, S)) =:= lists:map(F, elements(S))map_agrees (for every dispatcher), map_refines, map_link, SkewList.mapM_order, mapM_validT52026-11-28verified
map_raises_like_listsvalid S, any F in the fun table, lists:map returns or raises¹: {ok, elements(V)} or {Class, Reason} alikeas aboveT52026-11-28verified
map_preserves_validas map_matches_lists: is_valid(map(F, S))map_agrees, mapM_validT52026-11-28verified
filter_matches_listsvalid S, any F in the fun table, lists:filter(F, elements(S)) returns¹: elements(filter(F, S)) =:= lists:filter(F, elements(S))filter_agrees (for every dispatcher), filter_refines, filter_link, foldl_filterL, SkewList.foldlM_orderT62026-11-28verified
filter_raises_like_listsvalid S, any F in the fun table, lists:filter returns or raises¹ (including {bad_filter, V}): {ok, elements(V)} or {Class, Reason} alikeas aboveT62026-11-28verified
filter_preserves_validas filter_matches_lists: is_valid(filter(F, S))filter_agrees, fromList_validT62026-11-28verified
last_matches_listsvalid non-empty S: last(S) =:= lists:last(elements(S))last_agrees, last_refines, last_link, SkewList.toList_getLast?U12026-11-28verified
last_raises_like_listsvalid S: last(S) and lists:last(elements(S)) return or raise alikeas aboveU12026-11-28verified
member_matches_listsvalid S: member(X, S) =:= lists:member(X, elements(S))member_agrees, member_refines, member_link (trusts Lynx's model of the lists:member/2 BIF)U22026-11-28verified
all_matches_listsvalid S, any F in the fun table, lists:all(F, elements(S)) returns¹: all(F, S) =:= lists:all(F, elements(S))all_agrees (for every dispatcher), all_refines, all_link, SkewList.allM_orderU32026-11-28verified
all_raises_like_listsvalid S, any F in the fun table, lists:all returns or raises¹: both return or raise alikeas aboveU32026-11-28verified
any_matches_listsas all_matches_lists, with anyany_agrees, any_refines, any_link, SkewList.anyM_orderU32026-11-28verified
any_raises_like_listsas all_raises_like_lists, with anyas aboveU32026-11-28verified
sublist_matches_listsvalid S, integer Len >= 0: elements(sublist(S, Len)) =:= lists:sublist(elements(S), Len)sublist2_refines, sublist2_link, take_encodeU42026-11-28verified
sublist_raises_like_listsvalid S, any Len: both return the same elements or raise alikeas above, sub2_errorU42026-11-28verified
sublist_preserves_validas sublist_matches_lists: is_valid(sublist(S, Len))sublist2_refines, fromList_validU42026-11-28verified
sublist_matches_lists_atvalid S, integers Start >= 1, Len >= 0: elements(sublist(S, Start, Len)) =:= lists:sublist(elements(S), Start, Len)sublist3_refines, sublist3_link, nthtail_specU42026-11-28verified
sublist_raises_like_lists_atvalid S, any Start, Len: both return the same elements or raise alikeas above, sub3_errorU42026-11-28verified
sublist_preserves_valid_atas sublist_matches_lists_at: is_valid(sublist(S, Start, Len))sublist3_refines, fromList_validU42026-11-28verified
split_matches_listsvalid S, integer 0 =< N =< length(S): {elements(P), elements(Q)} =:= lists:split(N, elements(S))split_agrees, split_link, split3_linkU42026-11-28verified
split_raises_like_listsvalid S, any N: both return the same parts or raise alikeas aboveU42026-11-28verified
split_preserves_validas split_matches_lists: both parts validsplit_agrees, nthtail_specU42026-11-28verified
duplicate_matches_listsinteger N >= 0: elements(duplicate(N, X)) =:= lists:duplicate(N, X)duplicate_refines, duplicate_link, SkewList.duplicate_spec (greedy spine is canonical)U52026-11-28verified
duplicate_raises_like_listsany N, X: both return the same elements or raise alikeas aboveU52026-11-28verified
duplicate_preserves_validinteger N >= 0: is_valid(duplicate(N, X))duplicate_refines, SkewList.duplicate_specU52026-11-28verified
zip_matches_listsvalid S1, S2 of equal length: elements(zip(S1, S2)) =:= lists:zip(elements(S1), elements(S2))zip_agrees, zip_refines, zip3_link, SkewList.same_sizesV12026-11-28verified
zip_raises_like_listsvalid S1, S2: both return the same pairs or raise alikeas aboveV12026-11-28verified
zip_preserves_validas zip_matches_lists: is_valid(zip(S1, S2))SkewList.zipWith_specV12026-11-28verified
unzip_matches_listsvalid S of 2-tuples: {elements(A), elements(B)} =:= lists:unzip(elements(S))unzip_agrees, unzip_spine_encode, unzip3_link, unzipS_specV22026-11-28verified
unzip_raises_like_listsvalid S: both return the same parts or raise alikeas aboveV22026-11-28verified
unzip_preserves_validas unzip_matches_lists: both parts validunzip_agreesV22026-11-28verified
mapfoldl_matches_listsvalid S, any F in the fun table, lists:mapfoldl(F, Acc, elements(S)) returns¹: {elements(T), A} =:= lists:mapfoldl(F, Acc, elements(S))mapfoldl_agrees (for every dispatcher), mapfoldl_refines, mapfoldl_link, SkewList.mapAccLM_orderV32026-11-28verified
mapfoldl_raises_like_listsvalid S, any F in the fun table, lists:mapfoldl returns or raises¹: both return or raise alikeas aboveV32026-11-28verified
mapfoldl_preserves_validas mapfoldl_matches_lists: is_valid(T)mapfoldl_agrees, SkewList.mapAccLM_validV32026-11-28verified
mapfoldr_matches_listsvalid S, any F in the fun table, lists:mapfoldr(F, Acc, elements(S)) returns¹: {elements(T), A} =:= lists:mapfoldr(F, Acc, elements(S))mapfoldr_agrees (for every dispatcher), mapfoldr_refines, mapfoldr_link, SkewList.mapAccRM_orderV32026-11-28verified
mapfoldr_raises_like_listsvalid S, any F in the fun table, lists:mapfoldr returns or raises¹: both return or raise alikeas aboveV32026-11-28verified
mapfoldr_preserves_validas mapfoldr_matches_lists: is_valid(T)mapfoldr_agrees, SkewList.mapAccRM_validV32026-11-28verified
obs_samples_reachablelength(samples()) =:= 9; puts the sample funs in the fun table—T32026-11-28verified

ref_update/3 (trusted) first evaluates lists:nth(N, L), then replaces position N by direct recursion, so its only OTP dependency is lists:nth/2.

Every law with a valid S precondition gets its model value from is_valid_sound (lynx_lean/LawHelpers.lean): a term that is_valid/1 accepts is the encoding of a valid model value.

¹ The requires runs the lists oracle on the law's own data (<fn>_returns / <fn>_finishes). A law claims nothing for an input on which the oracle runs out of Lynx depth, because that cannot be caught. The laws range over the program's fun table, which holds only the nine pure sample funs; the guarantee for callers' deterministic funs is *_agrees, a lemma stated for every Lynx.Dispatcher.