open HolKernel Parse boolLib open testutils TotalDefn val _ = Feedback.emit_MESG := false val _ = tprint "Testing mutually recursive function definition" val f_def = require (check_result (K true)) Define` (f x = if x = 0 then T else ~g(x - 1)) /\ (g x = if x = 0 then F else ~f(x - 1)) ` val _ = tprint "Testing definition over literals" val h_def = Define` (h 0 = T) /\ (h 1 = F) `; val _ = let val cs = strip_conj (concl h_def) val _ = if length cs = 2 then () else die "FAILED!" val _ = if List.all (is_const o rhs) cs then () else die "FAILED!" in OK() end val _ = tprint "Testing form of derived induction principle" val fact_def = Define`fact n = if n < 2 then 1 else n * fact(n - 1)`; val desired_ind = ``!P. (!n. (~(n < 2) ==> P (n - 1)) ==> P n) ==> !v. P v`` val _ = if aconv desired_ind (concl (theorem "fact_ind")) then OK() else die "FAILED!\n" val _ = tprint "Define schema(1)" val _ = require (check_result (K true)) (quietly DefineSchema) `(fs 0 y = z + y) /\ (fs x y = x)`; val _ = tprint "Define schema(2)" val _ = require (check_result (K true)) (quietly DefineSchema) `(gs 0 y = x + y) /\ (gs x y = x)`; val _ = tprint "Testing 0-arg recursive function with lambda" val f1_def = require (check_result (K true)) (quietly Define)` f1 = \x. case x of 0 => 0n | SUC n => f1 n ` val _ = tprint "Testing 1-arg recursive function with lambda" val f1_def = require (check_result (K true)) (quietly Define)` f2 (y : 'a) = \x. case x of 0 => 0n | SUC n => f2 y n `; val _ = tprint "Testing 2-arg recursive function with lambda" val f1_def = require (check_result (K true)) (quietly Define)` f3 (y : 'a) (z : 'a) = \x. case x of 0 => 0n | SUC n => f3 y z n `;