(Isabelle/HOL)
definition "ReducedRelation2 ReflPartialOrder == (let min = (List.find (%x. x : (snd`((set ReflPartialOrder)-{(x, x)}))) (map fst ReflPartialOrder)) in (min, filter (%(x, y). x ~= the min & y ~= the min) ReflPartialOrder))"
definition "generateConflicts5 Or m c ==
[c Int ({m}×Y) Int (Y×{m}). Y <- map (Image {z:Or. fst z ~= m & snd z ~= m})
(map set (sublists (if (Or``{m})-{m}={} then (sorted_list_of_set (Domain Or)) else
sorted_list_of_set (Inter {c``{M}|M. M ? next1 Or {m}}))))]"
function conflictsFor2 where "conflictsFor2 Or=(let (M, or)=ReducedRelation2 Or in if M=None then [{}]
else let m=the M in concat [remdups (generateConflicts5 (set Or) m c). c <- conflictsFor2 or])"
value "map (%n. listsum (map (size o conflictsFor2 o adj2PairList) (allReflPartialOrders n))) [1..<7]
(*Correctness theorem*)
theorem assumes "N>0" shows "card (esOver {0..<N}) =
listsum (map (size o remdups o conflictsFor2 o adj2PairList) (allReflPartialOrders N))"