Who Cites count pairs? | |
count_pairs | Def count(x < y in L | P(x;y)) == sum(if (i < j)P(L[i];L[j]) 1 else 0 fi | i < ||L||; j < ||L||) |
Thm* T:Type, L:T List, P:(TT). count(x < y in L | P(x,y)) | |
select | Def l[i] == hd(nth_tl(i;l)) |
Thm* A:Type, l:A List, n:. 0n n < ||l|| l[n] A | |
nth_tl | Def nth_tl(n;as) == if n0 as else nth_tl(n-1;tl(as)) fi (recursive) |
Thm* A:Type, as:A List, i:. nth_tl(i;as) A List | |
le_int | Def ij == j < i |
Thm* i,j:. (ij) | |
lt_int | Def i < j == if i < j true ; false fi |
Thm* i,j:. (i < j) | |
band | Def pq == if p q else false fi |
Thm* p,q:. (pq) | |
length | Def ||as|| == Case of as; nil 0 ; a.as' ||as'||+1 (recursive) |
Thm* A:Type, l:A List. ||l|| | |
Thm* ||nil|| | |
double_sum | Def sum(f(x;y) | x < n; y < m) == sum(sum(f(x;y) | y < m) | x < n) |
Thm* n,m:, f:(nm). sum(f(x,y) | x < n; y < m) | |
hd | Def hd(l) == Case of l; nil "?" ; h.t h |
Thm* A:Type, l:A List. ||l||1 hd(l) A | |
Thm* A:Type, l:A List. hd(l) A | |
sum | Def sum(f(x) | x < k) == primrec(k;0;x,n. n+f(x)) |
Thm* n:, f:(n). sum(f(x) | x < n) | |
tl | Def tl(l) == Case of l; nil nil ; h.t t |
Thm* A:Type, l:A List. tl(l) A List | |
primrec | Def primrec(n;b;c) == if n=0 b else c(n-1,primrec(n-1;b;c)) fi (recursive) |
Thm* T:Type, n:, b:T, c:(nTT). primrec(n;b;c) T | |
bnot | Def b == if b false else true fi |
Thm* b:. b | |
eq_int | Def i=j == if i=j true ; false fi |
Thm* i,j:. (i=j) |
Syntax: | count(x < y in L | P(x;y)) | has structure: | count_pairs(L; x,y.P(x;y)) |
About: