File: Test104.ML

package info (click to toggle)
polyml 5.6-8
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 31,892 kB
  • ctags: 34,453
  • sloc: cpp: 44,983; ansic: 24,520; asm: 14,850; sh: 11,730; makefile: 551; exp: 484; python: 253; awk: 91; sed: 9
file content (35 lines) | stat: -rw-r--r-- 806 bytes parent folder | download | duplicates (5)
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
(* This caused an InternalError exception in the compiler. *)

PolyML.Compiler.maxInlineSize := 80;
type typ = string;
type indexname = int;

datatype term =
    Const of string * typ |
    Abs of string * typ * term |
    $ of term * term;

infix 9 $;
exception TERM of string * term list;

fun dest_equals (Const ("==", _) $ t $ u) = (t, u)
  | dest_equals t = raise TERM ("dest_equals", [t]);
  
fun term_depth (Abs (_, _, t)) = 1 + term_depth t
  | term_depth _ = 0;

datatype thm = Thm of int *  {maxidx: int, prop: term}

fun rep_thm (Thm (_, args)) = args;

val lhs_of_thm = #1 o dest_equals o #prop o rep_thm;

fun make keyfun =
  let fun keypair x = (x, keyfun x) in map keypair end;

fun sort_lhs_depths defs =
let
    val keylist = make (term_depth o lhs_of_thm) defs
in
    map #2 keylist
end;