forked from metamath/set.mm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount-usage
executable file
·50 lines (39 loc) · 1.49 KB
/
count-usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
# Report the # of uses (direct or indirect) for each theorem ($p).
# We expect "syl" to be the winner.
# Usage:
# count-usage [--indirect] [mmfile=set.mm]
indirect='false'
if [ "$1" = '--indirect' ] ; then
indirect='true'
shift
fi
mmfile="${1:-set.mm}"
scripts/list-theorems "$mmfile" 1.tmp
# To debug:
# echo syl > 1.tmp
# echo a1ii >> 1.tmp
# OR:
# head 1.tmp > 2.tmp; mv 2.tmp 1.tmp
# Use "show usage NAME /recursive" which generates:
# Statement "syl" directly or indirectly affects the proofs of 32021 statements:
# 3syl 4syl a1d a2d a1iiALT sylcom syl5com com12 syl5 syl6 syl56 syl6com
# ...
# sed -e 's/^/show usage /' -e 's/$/ \/recursive/' < 1.tmp > 2.tmp
sed -e 's/^/show usage /' < 1.tmp > 2.tmp
# Add the "recursive" option if we wanted the indirect dependencies
if [ "$indirect" = 'true' ]; then
mv 2.tmp 1.tmp
sed -e 's/$/ \/recursive/' < 1.tmp > 2.tmp
fi
# Two possible formats:
# "(.*)" directly or indirectly affects the proofs of (.*) statements:/\2 \1
# Statement "a1ii" directly or indirectly affects the proofs of 8458 statements:
# "(.*)" is directly referenced in the proofs of (.*) statements:/\2 \1
metamath "read \"${mmfile}\"" 'set scroll continuous' 'set width 9999' \
'submit 2.tmp' quit | \
grep '^Statement .* proof' | \
grep -v ' is not referenced in the proof of any statement' | \
sed -E -e 's/^Statement "([^ "]+)" (is directly referenced in|directly or indirectly affects) the proofs? of ([0-9]+) statements?:/\3 \1/' | \
grep '^[1-9]' | \
sort -n