skew_list law catalogue
View SourceEvery 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.
| Law | Statement | Uses | Phase | Approved | Status |
|---|---|---|---|---|---|
new_matches_list | elements(new()) =:= [] | elements/1 | 1 | verified | |
new_preserves_valid | is_valid(new()) | is_valid/1, SkewList.new_valid | 1 | verified | |
cons_matches_list | valid S: elements(cons(X, S)) =:= [X | elements(S)] | cons_refines, cons_correct | 2 | verified | |
cons_preserves_valid | valid S: is_valid(cons(X, S)) | cons_valid | 2 | verified | |
hd_matches_erlang | valid non-empty S: hd(S) =:= erlang:hd(elements(S)) | hd_refines, hd_correct, hd_link | 2 | verified | |
hd_raises_like_erlang | valid S: hd(S) and erlang:hd(elements(S)) return or raise alike | as above | 2 | verified | |
tl_matches_erlang | valid non-empty S: elements(tl(S)) =:= erlang:tl(elements(S)) | tl_refines, tl_correct, tl_link | 2 | verified | |
tl_raises_like_erlang | valid S: tl(S) and erlang:tl(elements(S)) return or raise alike | as above | 2 | verified | |
tl_preserves_valid | valid non-empty S: is_valid(tl(S)) | tl_valid | 2 | verified | |
length_matches_erlang | valid S: length(S) =:= erlang:length(elements(S)) | length_correct | 2 | verified | |
to_list_matches_list | valid S: to_list(S) =:= elements(S) | to_list_refines | 2 | verified | |
from_list_matches_list | proper L: elements(from_list(L)) =:= L | from_list_refines, fromList_correct | 2 | verified | |
from_list_raises_like_erlang | any L: from_list(L) and erlang:length(L) succeed or raise alike | length_sound, length_error | 2 | verified | |
from_list_preserves_valid | proper L: is_valid(from_list(L)) | fromList_valid | 2 | verified | |
equal_iff_elements_equal | valid S1, S2: (S1 =:= S2) =:= (elements(S1) =:= elements(S2)) | canonical_unique, exactEq_encode | 2 | verified | |
obs_hd_cons | valid S: hd(cons(X, S)) =:= X | cons_refines, hd_refines | 2 | verified | |
obs_tl_cons | valid S: tl(cons(X, S)) =:= S | tl_cons | 2 | verified | |
obs_length_cons | valid S: length(cons(X, S)) =:= length(S) + 1 | cons_refines | 2 | verified | |
nth_matches_lists | valid S, integer 1 =< N =< length(S): nth(N, S) =:= lists:nth(N, elements(S)) | nth_refines, nth_correct, nth_link | 3 | verified | |
nth_raises_like_lists | valid S, any N: nth(N, S) and lists:nth(N, elements(S)) return or raise alike | as above | 3 | verified | |
update_matches_ref_update | valid S, N in range: elements(update(N, X, S)) =:= ref_update(N, X, elements(S)) | update_refines, update_correct, ref_update_link | 3 | verified | |
update_raises_like_ref_update | valid S, any N: update and ref_update return or raise alike | as above | 3 | verified | |
update_preserves_valid | valid S, N in range: is_valid(update(N, X, S)) | update_valid | 3 | verified | |
obs_nth_1_is_hd | valid non-empty S: nth(1, S) =:= hd(S) | nth_correct, hd_correct | 3 | verified | |
nthtail_matches_lists | valid S, integer 0 =< N =< length(S): elements(nthtail(N, S)) =:= lists:nthtail(N, elements(S)) | nthtail_refines, nthtail_correct, nthtail_link | 4 | verified | |
nthtail_raises_like_lists | valid S, any N: nthtail and lists:nthtail return or raise alike | as above | 4 | verified | |
nthtail_preserves_valid | valid S, N in range: is_valid(nthtail(N, S)) | nthtail_valid (via dropTrees_eq: dropping equals N calls of tl) | 4 | verified | |
reverse_matches_lists | valid S: elements(reverse(S)) =:= lists:reverse(elements(S)) | reverse_refines, reverse_link (trusts Lynx's model of lists:reverse/2), fromList_correct | T1 | 2026-11-28 | verified |
reverse_preserves_valid | valid S: is_valid(reverse(S)) | reverse_refines, fromList_valid | T1 | 2026-11-28 | verified |
append_matches_lists | valid S1, S2: elements(append(S1, S2)) =:= lists:append(elements(S1), elements(S2)) | append_refines, append_spec, append_link (trusts Lynx's model of ++) | T2 | 2026-11-28 | verified |
append_preserves_valid | valid S1, S2: is_valid(append(S1, S2)) | append_refines, append_spec | T2 | 2026-11-28 | verified |
foldl_matches_lists | valid 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_order | T3 | 2026-11-28 | verified |
foldl_raises_like_lists | valid S, any F in the fun table, lists:foldl returns or raises¹: both return or raise alike | as above | T3 | 2026-11-28 | verified |
foldr_matches_lists | valid 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_order | T4 | 2026-11-28 | verified |
foldr_raises_like_lists | valid S, any F in the fun table, lists:foldr returns or raises¹: both return or raise alike | as above | T4 | 2026-11-28 | verified |
map_matches_lists | valid 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_valid | T5 | 2026-11-28 | verified |
map_raises_like_lists | valid S, any F in the fun table, lists:map returns or raises¹: {ok, elements(V)} or {Class, Reason} alike | as above | T5 | 2026-11-28 | verified |
map_preserves_valid | as map_matches_lists: is_valid(map(F, S)) | map_agrees, mapM_valid | T5 | 2026-11-28 | verified |
filter_matches_lists | valid 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_order | T6 | 2026-11-28 | verified |
filter_raises_like_lists | valid S, any F in the fun table, lists:filter returns or raises¹ (including {bad_filter, V}): {ok, elements(V)} or {Class, Reason} alike | as above | T6 | 2026-11-28 | verified |
filter_preserves_valid | as filter_matches_lists: is_valid(filter(F, S)) | filter_agrees, fromList_valid | T6 | 2026-11-28 | verified |
last_matches_lists | valid non-empty S: last(S) =:= lists:last(elements(S)) | last_agrees, last_refines, last_link, SkewList.toList_getLast? | U1 | 2026-11-28 | verified |
last_raises_like_lists | valid S: last(S) and lists:last(elements(S)) return or raise alike | as above | U1 | 2026-11-28 | verified |
member_matches_lists | valid 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) | U2 | 2026-11-28 | verified |
all_matches_lists | valid 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_order | U3 | 2026-11-28 | verified |
all_raises_like_lists | valid S, any F in the fun table, lists:all returns or raises¹: both return or raise alike | as above | U3 | 2026-11-28 | verified |
any_matches_lists | as all_matches_lists, with any | any_agrees, any_refines, any_link, SkewList.anyM_order | U3 | 2026-11-28 | verified |
any_raises_like_lists | as all_raises_like_lists, with any | as above | U3 | 2026-11-28 | verified |
sublist_matches_lists | valid S, integer Len >= 0: elements(sublist(S, Len)) =:= lists:sublist(elements(S), Len) | sublist2_refines, sublist2_link, take_encode | U4 | 2026-11-28 | verified |
sublist_raises_like_lists | valid S, any Len: both return the same elements or raise alike | as above, sub2_error | U4 | 2026-11-28 | verified |
sublist_preserves_valid | as sublist_matches_lists: is_valid(sublist(S, Len)) | sublist2_refines, fromList_valid | U4 | 2026-11-28 | verified |
sublist_matches_lists_at | valid S, integers Start >= 1, Len >= 0: elements(sublist(S, Start, Len)) =:= lists:sublist(elements(S), Start, Len) | sublist3_refines, sublist3_link, nthtail_spec | U4 | 2026-11-28 | verified |
sublist_raises_like_lists_at | valid S, any Start, Len: both return the same elements or raise alike | as above, sub3_error | U4 | 2026-11-28 | verified |
sublist_preserves_valid_at | as sublist_matches_lists_at: is_valid(sublist(S, Start, Len)) | sublist3_refines, fromList_valid | U4 | 2026-11-28 | verified |
split_matches_lists | valid S, integer 0 =< N =< length(S): {elements(P), elements(Q)} =:= lists:split(N, elements(S)) | split_agrees, split_link, split3_link | U4 | 2026-11-28 | verified |
split_raises_like_lists | valid S, any N: both return the same parts or raise alike | as above | U4 | 2026-11-28 | verified |
split_preserves_valid | as split_matches_lists: both parts valid | split_agrees, nthtail_spec | U4 | 2026-11-28 | verified |
duplicate_matches_lists | integer N >= 0: elements(duplicate(N, X)) =:= lists:duplicate(N, X) | duplicate_refines, duplicate_link, SkewList.duplicate_spec (greedy spine is canonical) | U5 | 2026-11-28 | verified |
duplicate_raises_like_lists | any N, X: both return the same elements or raise alike | as above | U5 | 2026-11-28 | verified |
duplicate_preserves_valid | integer N >= 0: is_valid(duplicate(N, X)) | duplicate_refines, SkewList.duplicate_spec | U5 | 2026-11-28 | verified |
zip_matches_lists | valid S1, S2 of equal length: elements(zip(S1, S2)) =:= lists:zip(elements(S1), elements(S2)) | zip_agrees, zip_refines, zip3_link, SkewList.same_sizes | V1 | 2026-11-28 | verified |
zip_raises_like_lists | valid S1, S2: both return the same pairs or raise alike | as above | V1 | 2026-11-28 | verified |
zip_preserves_valid | as zip_matches_lists: is_valid(zip(S1, S2)) | SkewList.zipWith_spec | V1 | 2026-11-28 | verified |
unzip_matches_lists | valid S of 2-tuples: {elements(A), elements(B)} =:= lists:unzip(elements(S)) | unzip_agrees, unzip_spine_encode, unzip3_link, unzipS_spec | V2 | 2026-11-28 | verified |
unzip_raises_like_lists | valid S: both return the same parts or raise alike | as above | V2 | 2026-11-28 | verified |
unzip_preserves_valid | as unzip_matches_lists: both parts valid | unzip_agrees | V2 | 2026-11-28 | verified |
mapfoldl_matches_lists | valid 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_order | V3 | 2026-11-28 | verified |
mapfoldl_raises_like_lists | valid S, any F in the fun table, lists:mapfoldl returns or raises¹: both return or raise alike | as above | V3 | 2026-11-28 | verified |
mapfoldl_preserves_valid | as mapfoldl_matches_lists: is_valid(T) | mapfoldl_agrees, SkewList.mapAccLM_valid | V3 | 2026-11-28 | verified |
mapfoldr_matches_lists | valid 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_order | V3 | 2026-11-28 | verified |
mapfoldr_raises_like_lists | valid S, any F in the fun table, lists:mapfoldr returns or raises¹: both return or raise alike | as above | V3 | 2026-11-28 | verified |
mapfoldr_preserves_valid | as mapfoldr_matches_lists: is_valid(T) | mapfoldr_agrees, SkewList.mapAccRM_valid | V3 | 2026-11-28 | verified |
obs_samples_reachable | length(samples()) =:= 9; puts the sample funs in the fun table | — | T3 | 2026-11-28 | verified |
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.