(* Title: CCL/CCL.thy Author: Martin Coen Copyright 1993 University of Cambridge *)
section‹Classical Computational Logic for Untyped Lambda Calculus with reduction to weak head-normal form›
theory CCL imports Gfp begin
text‹ Based on FOL extended with set collection, a primitive higher-order logic. HOL is too strong - descriptions prevent a type of programs being defined which contains only executable terms. ›
(** This is the evaluation semantics from which the axioms below were derived. **) (** It is included here just as an evaluator for FUN and has no influence on **) (** inference in the theory CCL. **)
(* The pre-order ([=) is defined as a simulation, and behavioural equivalence (=) *) (* as a bisimulation. They can both be expressed as (bi)simulations up to *) (* behavioural equivalence (ie the relations PO and EQ defined below). *)
(** The theory is non-trivial **) axiomatizationwhere
distinctness: "¬ lam x. b(x) = bot"
(*** Definitions of Termination and Divergence ***)
definition Dvg :: "i ==> o" where"Dvg(t) == t = bot"
definition Trm :: "i ==> o" where"Trm(t) == ¬ Dvg(t)"
text‹ Would be interesting to build a similar theory for a typed programming language: ie. true :: bool, fix :: ('a==>'a)==>'a etc...... This is starting to look like LCF. What are the advantages of this approach? - less axiomatic - wfd induction / coinduction and fixed point induction available ›
lemmas ccl_data_defs = apply_def fix_def
declare po_refl [simp]
subsection‹Congruence Rules›
(*similar to AP_THM in Gordon's HOL*) lemma fun_cong: "(f::'a==>'b) = g ==> f(x)=g(x)" by simp
(*similar to AP_TERM in Gordon's HOL and FOL's subst_context*) lemma arg_cong: "x=y ==> f(x)=f(y)" by simp
lemma lem: "t=t' ==> case(t,b,c,d,e) = case(t',b,c,d,e)" by simp
ML ‹ local fun pairs_of _ _ [] = [] | pairs_of f x (y::ys) = (f x y) :: (f y x) :: (pairs_of f x ys) fun mk_combs _ [] = [] | mk_combs ff (x::xs) = (pairs_of ff x xs) @ mk_combs ff xs (* Doesn't handle binder types correctly *) fun saturate thy sy name = letfun arg_str 0 _ s = s
| arg_str 1 a s = "(" ^ a ^ "a" ^ s ^ ")"
| arg_str n a s = arg_str (n-1) a ("," ^ a ^ (chr((ord "a")+n-1)) ^ s)
val T = Sign.the_const_type thy (Sign.intern_const thy sy);
val arity = length (binder_types T) in sy ^ (arg_str arity name "") end
fun mk_thm_str thy a b = "¬ " ^ (saturate thy a "a") ^ " = " ^ (saturate thy b "b")
val lemma = @{thm lem};
val eq_lemma = @{thm eq_lemma};
val distinctness = @{thm distinctness}; fun mk_lemma (ra,rb) =
[lemma] RL [ra RS (rb RS eq_lemma)] RL
[distinctness RS @{thmnotE}, @{thm sym} RS (distinctness RS @{thmnotE})] in fun mk_lemmas rls = maps mk_lemma (mk_combs pair rls) fun mk_dstnct_rls thy xs = mk_combs (mk_thm_str thy) xs end ›
ML ‹ val caseB_lemmas = mk_lemmas @{thms caseBs} val ccl_dstncts = let fun mk_raw_dstnct_thm rls s = Goal.prove_global 🍋 [] [] (Syntax.read_prop_global 🍋 s) (fn {context = ctxt, ...} => resolve_tac ctxt @{thms notI} 1 THEN eresolve_tac ctxt rls 1) in map (mk_raw_dstnct_thm caseB_lemmas) (mk_dstnct_rls 🍋 ["bot","true","false","pair","lambda"]) end fun mk_dstnct_thms ctxt defs inj_rls xs = let val thy = Proof_Context.theory_of ctxt; fun mk_dstnct_thm rls s = Goal.prove_global thy [] [] (Syntax.read_prop ctxt s) (fn _ => rewrite_goals_tac ctxt defs THEN simp_tac (ctxt |> Simplifier.add_simps (rls @ inj_rls)) 1) in map (mk_dstnct_thm ccl_dstncts) (mk_dstnct_rls thy xs) end fun mkall_dstnct_thms ctxt defs i_rls xss = maps (mk_dstnct_thms ctxt defs i_rls) xss (*** Rewriting and Proving ***)
fun XH_to_I rl = rl RS @{thm iffD2} fun XH_to_D rl = rl RS @{thm iffD1}
val XH_to_E = make_elim o XH_to_D
val XH_to_Is = map XH_to_I
val XH_to_Ds = map XH_to_D
val XH_to_Es = map XH_to_E;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.