fact
stringlengths
5
2k
type
stringclasses
22 values
library
stringclasses
1 value
imports
listlengths
0
15.1k
filename
stringlengths
13
83
symbolic_name
stringlengths
1
82
docstring
stringclasses
1 value
wf_wf : "Wfd(wf(R))" unfolding wf_def apply (rule_tac Q = "Wfd(R)" in excluded_middle [THEN disjE]) apply simp_all apply (rule Empty_wf) done
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
wf_wf
NatPRXH : "p : NatPR \<longleftrightarrow> (EX x:Nat. p=<x,succ(x)>)" unfolding NatPR_def by blast
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
NatPRXH
ListPRXH : "p : ListPR(A) \<longleftrightarrow> (EX h:A. EX t:List(A).p=<t,h$t>)" unfolding ListPR_def by blast
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
ListPRXH
NatPRI : "x : Nat \<Longrightarrow> <x,succ(x)> : NatPR" by (auto simp: NatPRXH)
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
NatPRI
ListPRI : "\<lbrakk>t : List(A); h : A\<rbrakk> \<Longrightarrow> <t,h $ t> : ListPR(A)" by (auto simp: ListPRXH)
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
ListPRI
NatPR_wf : "Wfd(NatPR)" apply (unfold Wfd_def) apply clarify apply (wfd_strengthen "\<lambda>x. x:Nat") apply (fastforce iff: NatPRXH) apply (erule Nat_ind) apply (fastforce iff: NatPRXH)+ done
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
NatPR_wf
ListPR_wf : "Wfd(ListPR(A))" apply (unfold Wfd_def) apply clarify apply (wfd_strengthen "\<lambda>x. x:List (A)") apply (fastforce iff: ListPRXH) apply (erule List_ind) apply (fastforce iff: ListPRXH)+ done
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
ListPR_wf
letrecT : assumes 1: "a : A" and 2: "\<And>p g. \<lbrakk>p:A; ALL x:{x: A. <x,p>:wf(R)}. g(x) : D(x)\<rbrakk> \<Longrightarrow> h(p,g) : D(p)" shows "letrec g x be h(x,g) in g(a) : D(a)" apply (rule 1 [THEN rev_mp]) apply (rule wf_wf [THEN wfd_induct]) apply (subst letrecB) apply (rule impI) apply (erule 2) apply blast...
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
letrecT
SPLITB : "SPLIT(<a,b>,B) = B(a,b)" unfolding SPLIT_def apply (rule set_ext) apply blast done
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
SPLITB
letrec2T : assumes "a : A" and "b : B" and "\<And>p q g. \<lbrakk>p:A; q:B; ALL x:A. ALL y:{y: B. <<x,y>,<p,q>>:wf(R)}. g(x,y) : D(x,y)\<rbrakk> \<Longrightarrow> h(p,q,g) : D(p,q)" shows "letrec g x y be h(x,y,g) in g(a,b) : D(a,b)" apply (unfold letrec2_def) apply (rule SPLITB [THEN subst]) apply (assumption | rule l...
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
letrec2T
lem : "SPLIT(<a,<b,c>>,\<lambda>x xs. SPLIT(xs,\<lambda>y z. B(x,y,z))) = B(a,b,c)" by (simp add: SPLITB)
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
lem
letrec3T : assumes "a : A" and "b : B" and "c : C" and "\<And>p q r g. \<lbrakk>p:A; q:B; r:C; ALL x:A. ALL y:B. ALL z:{z:C. <<x,<y,z>>,<p,<q,r>>> : wf(R)}. g(x,y,z) : D(x,y,z) \<rbrakk> \<Longrightarrow> h(p,q,r,g) : D(p,q,r)" shows "letrec g x y z be h(x,y,z,g) in g(a,b,c) : D(a,b,c)" apply (unfold letrec3_def) apply...
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
letrec3T
rcallT : "\<lbrakk>ALL x:{x:A.<x,p>:wf(R)}.g(x):D(x); g(a) : D(a) \<Longrightarrow> g(a) : E; a:A; <a,p>:wf(R)\<rbrakk> \<Longrightarrow> g(a) : E" by blast
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
rcallT
rcall2T : "\<lbrakk>ALL x:A. ALL y:{y:B.<<x,y>,<p,q>>:wf(R)}.g(x,y):D(x,y); g(a,b) : D(a,b) \<Longrightarrow> g(a,b) : E; a:A; b:B; <<a,b>,<p,q>>:wf(R)\<rbrakk> \<Longrightarrow> g(a,b) : E" by blast
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
rcall2T
rcall3T : "\<lbrakk>ALL x:A. ALL y:B. ALL z:{z:C.<<x,<y,z>>,<p,<q,r>>>:wf(R)}. g(x,y,z):D(x,y,z); g(a,b,c) : D(a,b,c) \<Longrightarrow> g(a,b,c) : E; a:A; b:B; c:C; <<a,<b,c>>,<p,<q,r>>> : wf(R)\<rbrakk> \<Longrightarrow> g(a,b,c) : E" by blast lemmas rcallTs = rcallT rcall2T rcall3T
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
rcall3T
hyprcallT : assumes 1: "g(a) = b" and 2: "ALL x:{x:A.<x,p>:wf(R)}.g(x):D(x)" and 3: "ALL x:{x:A.<x,p>:wf(R)}.g(x):D(x) \<Longrightarrow> b=g(a) \<Longrightarrow> g(a) : D(a) \<Longrightarrow> P" and 4: "ALL x:{x:A.<x,p>:wf(R)}.g(x):D(x) \<Longrightarrow> a:A" and 5: "ALL x:{x:A.<x,p>:wf(R)}.g(x):D(x) \<Longrightarrow> ...
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
hyprcallT
hyprcall2T : assumes 1: "g(a,b) = c" and 2: "ALL x:A. ALL y:{y:B.<<x,y>,<p,q>>:wf(R)}.g(x,y):D(x,y)" and 3: "\<lbrakk>c = g(a,b); g(a,b) : D(a,b)\<rbrakk> \<Longrightarrow> P" and 4: "a:A" and 5: "b:B" and 6: "<<a,b>,<p,q>>:wf(R)" shows P apply (rule 3) apply (rule 1 [symmetric]) apply (rule rcall2T) apply (rule 2) app...
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
hyprcall2T
hyprcall3T : assumes 1: "g(a,b,c) = d" and 2: "ALL x:A. ALL y:B. ALL z:{z:C.<<x,<y,z>>,<p,<q,r>>>:wf(R)}.g(x,y,z):D(x,y,z)" and 3: "\<lbrakk>d = g(a,b,c); g(a,b,c) : D(a,b,c)\<rbrakk> \<Longrightarrow> P" and 4: "a:A" and 5: "b:B" and 6: "c:C" and 7: "<<a,<b,c>>,<p,<q,r>>> : wf(R)" shows P apply (rule 3) apply (rule 1 ...
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
hyprcall3T
rmIH1 : "\<lbrakk>ALL x:{x:A.<x,p>:wf(R)}.g(x):D(x); P\<rbrakk> \<Longrightarrow> P" .
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
rmIH1
rmIH2 : "\<lbrakk>ALL x:A. ALL y:{y:B.<<x,y>,<p,q>>:wf(R)}.g(x,y):D(x,y); P\<rbrakk> \<Longrightarrow> P" .
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
rmIH2
rmIH3 : "\<lbrakk>ALL x:A. ALL y:B. ALL z:{z:C.<<x,<y,z>>,<p,<q,r>>>:wf(R)}.g(x,y,z):D(x,y,z); P\<rbrakk> \<Longrightarrow> P" . lemmas rmIHs = rmIH1 rmIH2 rmIH3
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
rmIH3
Subtype_canTs : "\<And>a b A B P. a : {x:A. b:{y:B(a).P(<x,y>)}} \<Longrightarrow> <a,b> : {x:Sigma(A,B).P(x)}" "\<And>a A B P. a : {x:A. P(inl(x))} \<Longrightarrow> inl(a) : {x:A+B. P(x)}" "\<And>b A B P. b : {x:B. P(inr(x))} \<Longrightarrow> inr(b) : {x:A+B. P(x)}" "\<And>a P. a : {x:Nat. P(succ(x))} \<Longrightarr...
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
Subtype_canTs
letT : "\<lbrakk>f(t):B; \<not>t=bot\<rbrakk> \<Longrightarrow> let x be t in f(x) : B" apply (erule letB [THEN ssubst]) apply assumption done
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
letT
applyT2 : "\<lbrakk>a:A; f : Pi(A,B)\<rbrakk> \<Longrightarrow> f ` a : B(a)" apply (erule applyT) apply assumption done
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
applyT2
rcall_lemma1 : "\<lbrakk>a:A; a:A \<Longrightarrow> P(a)\<rbrakk> \<Longrightarrow> a : {x:A. P(x)}" by blast
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
rcall_lemma1
rcall_lemma2 : "\<lbrakk>a:{x:A. Q(x)}; \<lbrakk>a:A; Q(a)\<rbrakk> \<Longrightarrow> P(a)\<rbrakk> \<Longrightarrow> a : {x:A. P(x)}" by blast lemmas rcall_lemmas = asm_rl rcall_lemma1 SubtypeD1 rcall_lemma2
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
rcall_lemma2
bvars \<^Const_>\<open>Pure.all _ for \<open>Abs(s,_,t)\<close>\<close> l = bvars t (s::l) | bvars _ l = l
fun
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
bvars
get_bno l n \<^Const_>\<open>Pure.all _ for \<open>Abs(s,_,t)\<close>\<close> = get_bno (s::l) n t | get_bno l n \<^Const_>\<open>Trueprop for t\<close> = get_bno l n t | get_bno l n \<^Const_>\<open>Ball _ for _ \<open>Abs(s,_,t)\<close>\<close> = get_bno (s::l) (n+1) t | get_bno l n \<^Const_>\<open>mem _ for t _\<cl...
fun
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
get_bno
could_IH x = Term.could_unify(x,hd (Thm.take_prems_of 1 @{thm rcallT})) orelse Term.could_unify(x,hd (Thm.take_prems_of 1 @{thm rcall2T})) orelse Term.could_unify(x,hd (Thm.take_prems_of 1 @{thm rcall3T}))
fun
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
could_IH
IHinst tac rls = SUBGOAL (fn (Bi,i) => let val bvs = bvars Bi [] val ihs = filter could_IH (Logic.strip_assums_hyp Bi) val rnames = map (fn x => let val (a,b) = get_bno [] 0 x in (nth bvs a, b) end) ihs
fun
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
IHinst
is_rigid_prog t = (case (Logic.strip_assums_concl t) of \<^Const_>\<open>Trueprop for \<^Const_>\<open>mem _ for a _\<close>\<close> => null (Term.add_vars a []) | _ => false) in
fun
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
is_rigid_prog
rcall_tac ctxt i = let fun tac ps rl i = Rule_Insts.res_inst_tac ctxt ps [] rl i THEN assume_tac ctxt i in IHinst tac @{thms rcallTs} i end THEN eresolve_tac ctxt @{thms rcall_lemmas} i
fun
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
rcall_tac
raw_step_tac ctxt prems i = assume_tac ctxt i ORELSE resolve_tac ctxt (prems @ type_rls) i ORELSE rcall_tac ctxt i ORELSE ematch_tac ctxt @{thms SubtypeE} i ORELSE match_tac ctxt @{thms SubtypeI} i
fun
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
raw_step_tac
tc_step_tac ctxt prems = SUBGOAL (fn (Bi,i) => if is_rigid_prog Bi then raw_step_tac ctxt prems i else no_tac)
fun
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
tc_step_tac
typechk_tac ctxt rls i = SELECT_GOAL (REPEAT_FIRST (tc_step_tac ctxt rls)) i (*** Clean up Correctness Condictions ***)
fun
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
typechk_tac
clean_ccs_tac ctxt = let fun tac ps rl i = Rule_Insts.eres_inst_tac ctxt ps [] rl i THEN assume_tac ctxt i in TRY (REPEAT_FIRST (IHinst tac @{thms hyprcallTs} ORELSE' eresolve_tac ctxt ([asm_rl, @{thm SubtypeE}] @ @{thms rmIHs}) ORELSE' hyp_subst_tac ctxt))
fun
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
clean_ccs_tac
gen_ccs_tac ctxt rls i = SELECT_GOAL (REPEAT_FIRST (tc_step_tac ctxt rls) THEN clean_ccs_tac ctxt) i
fun
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
gen_ccs_tac
eval_tac ths = Subgoal.FOCUS_PREMS (fn {context = ctxt, prems, ...} => let val eval_rules = Named_Theorems.get ctxt \<^named_theorems>\<open>eval\<close> in DEPTH_SOLVE_1 (resolve_tac ctxt (ths @ prems @ rev eval_rules) 1) end) \<close> method_setup eval = \<open> Attrib.thms >> (fn ths => fn ctxt => SIMPLE_METHOD' (CH...
fun
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
eval_tac
applyV [eval]: assumes "f \<longlongrightarrow> lam x. b(x)" and "b(a) \<longlongrightarrow> c" shows "f ` a \<longlongrightarrow> c" unfolding apply_def by (eval assms)
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
applyV
letV : assumes 1: "t \<longlongrightarrow> a" and 2: "f(a) \<longlongrightarrow> c" shows "let x be t in f(x) \<longlongrightarrow> c" apply (unfold let_def) apply (rule 1 [THEN canonical]) apply (tactic \<open> REPEAT (DEPTH_SOLVE_1 (resolve_tac \<^context> (@{thms assms} @ @{thms eval_rls}) 1 ORELSE eresolve_tac \<^c...
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
letV
fixV : "f(fix(f)) \<longlongrightarrow> c \<Longrightarrow> fix(f) \<longlongrightarrow> c" apply (unfold fix_def) apply (rule applyV) apply (rule lamV) apply assumption done
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
fixV
letrecV : "h(t,\<lambda>y. letrec g x be h(x,g) in g(y)) \<longlongrightarrow> c \<Longrightarrow> letrec g x be h(x,g) in g(t) \<longlongrightarrow> c" apply (unfold letrec_def) apply (assumption | rule fixV applyV lamV)+ done lemmas [eval] = letV letrecV fixV
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
letrecV
V_rls [eval]: "true \<longlongrightarrow> true" "false \<longlongrightarrow> false" "\<And>b c t u. \<lbrakk>b\<longlongrightarrow>true; t\<longlongrightarrow>c\<rbrakk> \<Longrightarrow> if b then t else u \<longlongrightarrow> c" "\<And>b c t u. \<lbrakk>b\<longlongrightarrow>false; u\<longlongrightarrow>c\<rbrakk> \...
lemma
src
[ "Trancl", "Type", "Hered" ]
src/CCL/Wfd.thy
V_rls
Arrow :: "[t,t]\<Rightarrow>t" (infixr \<open>\<longrightarrow>\<close> 30) where "A \<longrightarrow> B \<equiv> \<Prod>_:A. B"
abbreviation
src
[ "Pure" ]
src/CTT/CTT.thy
Arrow
Times :: "[t,t]\<Rightarrow>t" (infixr \<open>\<times>\<close> 50) where "A \<times> B \<equiv> \<Sum>_:A. B" text \<open> Reduction: a weaker notion than equality; a hack for simplification. \<open>Reduce[a,b]\<close> means either that \<open>a = b : A\<close> for some \<open>A\<close> or else that \<open>a\<close> an...
abbreviation
src
[ "Pure" ]
src/CTT/CTT.thy
Times
where refl_red: "\<And>a. Reduce[a,a]" and red_if_equal: "\<And>a b A. a = b : A \<Longrightarrow> Reduce[a,b]" and trans_red: "\<And>a b c A. \<lbrakk>a = b : A; Reduce[b,c]\<rbrakk> \<Longrightarrow> a = c : A" and \<comment> \<open>Reflexivity\<close> refl_type: "\<And>A. A type \<Longrightarrow> A = A" and refl_ele...
axiomatization
src
[ "Pure" ]
src/CTT/CTT.thy
where
SumIL2 : "\<lbrakk>c = a : A; d = b : B(a)\<rbrakk> \<Longrightarrow> <c,d> = <a,b> : Sum(A,B)" by (rule sym_elem) (rule SumIL; rule sym_elem) lemmas intrL2_rls = NI_succL ProdIL SumIL2 PlusI_inlL PlusI_inrL text \<open> Exploit \<open>p:Prod(A,B)\<close> to create the assumption \<open>z:B(a)\<close>. A more natural f...
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
SumIL2
subst_prodE : assumes "p: Prod(A,B)" and "a: A" and "\<And>z. z: B(a) \<Longrightarrow> c(z): C(z)" shows "c(p`a): C(p`a)" by (rule assms ProdE)+
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
subst_prodE
is_rigid_elem \<^Const_>\<open>Elem for a _\<close> = not(is_Var (head_of a)) | is_rigid_elem \<^Const_>\<open>Eqelem for a _ _\<close> = not(is_Var (head_of a)) | is_rigid_elem \<^Const_>\<open>Type for a\<close> = not(is_Var (head_of a)) | is_rigid_elem _ = false in (*Try solving a:A or a=b:A by assumption provided a...
fun
src
[ "Pure" ]
src/CTT/CTT.thy
is_rigid_elem
test_assume_tac ctxt = SUBGOAL (fn (prem, i) => if is_rigid_elem (Logic.strip_assums_concl prem) then assume_tac ctxt i else no_tac)
fun
src
[ "Pure" ]
src/CTT/CTT.thy
test_assume_tac
ASSUME ctxt tf i = test_assume_tac ctxt i ORELSE tf i
fun
src
[ "Pure" ]
src/CTT/CTT.thy
ASSUME
routine_tac rls ctxt prems = ASSUME ctxt (Bires.filt_resolve_from_net_tac ctxt 4 (Bires.build_net (prems @ rls))); (*Solve all subgoals "A type" using formation rules. *) val form_net = Bires.build_net @{thms form_rls};
fun
src
[ "Pure" ]
src/CTT/CTT.thy
routine_tac
form_tac ctxt = REPEAT_FIRST (ASSUME ctxt (Bires.filt_resolve_from_net_tac ctxt 1 form_net)); (*Type checking: solve a:A (a rigid, A flexible) by intro and elim rules. *)
fun
src
[ "Pure" ]
src/CTT/CTT.thy
form_tac
typechk_tac ctxt thms = let val tac = Bires.filt_resolve_from_net_tac ctxt 3 (Bires.build_net (thms @ @{thms form_rls} @ @{thms element_rls})) in REPEAT_FIRST (ASSUME ctxt tac) end (*Solve a:A (a flexible, A rigid) by introduction rules. Cannot use stringtrees (filt_resolve_tac) since goals like ?a:SUM(A,B) have a triv...
fun
src
[ "Pure" ]
src/CTT/CTT.thy
typechk_tac
intr_tac ctxt thms = let val tac = Bires.filt_resolve_from_net_tac ctxt 1 (Bires.build_net (thms @ @{thms form_rls} @ @{thms intr_rls})) in REPEAT_FIRST (ASSUME ctxt tac) end (*Equality proving: solve a=b:A (where a is rigid) by long rules. *)
fun
src
[ "Pure" ]
src/CTT/CTT.thy
intr_tac
equal_tac ctxt thms = REPEAT_FIRST (ASSUME ctxt (Bires.filt_resolve_from_net_tac ctxt 3 (Bires.build_net (thms @ @{thms form_rls element_rls intrL_rls elimL_rls refl_elem})))) \<close> method_setup form = \<open>Scan.succeed (fn ctxt => SIMPLE_METHOD (form_tac ctxt))\<close> method_setup typechk = \<open>Attrib.thms >>...
fun
src
[ "Pure" ]
src/CTT/CTT.thy
equal_tac
replace_type : "\<lbrakk>B = A; a : A\<rbrakk> \<Longrightarrow> a : B" apply (rule equal_types) apply (rule_tac [2] sym_type) apply assumption+ done text \<open>Simplify the parameter of a unary type operator.\<close>
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
replace_type
subst_eqtyparg : assumes 1: "a=c : A" and 2: "\<And>z. z:A \<Longrightarrow> B(z) type" shows "B(a) = B(c)" apply (rule subst_typeL) apply (rule_tac [2] refl_type) apply (rule 1) apply (erule 2) done text \<open>Simplification rules for Constructive Type Theory.\<close> lemmas reduction_rls = comp_rls [THEN trans_elem]...
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
subst_eqtyparg
eqintr_tac ctxt = REPEAT_FIRST (ASSUME ctxt (Bires.filt_resolve_from_net_tac ctxt 1 eqintr_net)) (** Tactics that instantiate CTT-rules. Vars in the given terms will be incremented! The (rtac EqE i) lets them apply to equality judgments. **)
fun
src
[ "Pure" ]
src/CTT/CTT.thy
eqintr_tac
NE_tac ctxt sp i = TRY (resolve_tac ctxt @{thms EqE} i) THEN Rule_Insts.res_inst_tac ctxt [((("p", 0), Position.none), sp)] [] @{thm NE} i
fun
src
[ "Pure" ]
src/CTT/CTT.thy
NE_tac
SumE_tac ctxt sp i = TRY (resolve_tac ctxt @{thms EqE} i) THEN Rule_Insts.res_inst_tac ctxt [((("p", 0), Position.none), sp)] [] @{thm SumE} i
fun
src
[ "Pure" ]
src/CTT/CTT.thy
SumE_tac
PlusE_tac ctxt sp i = TRY (resolve_tac ctxt @{thms EqE} i) THEN Rule_Insts.res_inst_tac ctxt [((("p", 0), Position.none), sp)] [] @{thm PlusE} i (** Predicate logic reasoning, WITH THINNING!! Procedures adapted from NJ. **) (*Finds f:Prod(A,B) and a:A in the assumptions, concludes there is z:B(a) *)
fun
src
[ "Pure" ]
src/CTT/CTT.thy
PlusE_tac
add_mp_tac ctxt i = resolve_tac ctxt @{thms subst_prodE} i THEN assume_tac ctxt i THEN assume_tac ctxt i (*Finds P\<longrightarrow>Q and P in the assumptions, replaces implication by Q *)
fun
src
[ "Pure" ]
src/CTT/CTT.thy
add_mp_tac
mp_tac ctxt i = eresolve_tac ctxt @{thms subst_prodE} i THEN assume_tac ctxt i (*"safe" when regarded as predicate calculus rules*) val safe_brls = sort Bires.subgoals_ord [ (true, @{thm FE}), (true,asm_rl), (false, @{thm ProdI}), (true, @{thm SumE}), (true, @{thm PlusE}) ] val unsafe_brls = [ (false, @{thm PlusI_inl})...
fun
src
[ "Pure" ]
src/CTT/CTT.thy
mp_tac
safestep_tac ctxt thms i = form_tac ctxt ORELSE resolve_tac ctxt thms i ORELSE biresolve_tac ctxt safe0_brls i ORELSE mp_tac ctxt i ORELSE DETERM (biresolve_tac ctxt safep_brls i)
fun
src
[ "Pure" ]
src/CTT/CTT.thy
safestep_tac
safe_tac ctxt thms i = DEPTH_SOLVE_1 (safestep_tac ctxt thms i)
fun
src
[ "Pure" ]
src/CTT/CTT.thy
safe_tac
step_tac ctxt thms = safestep_tac ctxt thms ORELSE' biresolve_tac ctxt unsafe_brls (*Fails unless it solves the goal!*)
fun
src
[ "Pure" ]
src/CTT/CTT.thy
step_tac
pc_tac ctxt thms = DEPTH_SOLVE_1 o (step_tac ctxt thms) \<close> method_setup eqintr = \<open>Scan.succeed (SIMPLE_METHOD o eqintr_tac)\<close> method_setup NE = \<open> Scan.lift Parse.embedded_inner_syntax >> (fn s => fn ctxt => SIMPLE_METHOD' (NE_tac ctxt s)) \<close> method_setup pc = \<open>Attrib.thms >> (fn ths ...
fun
src
[ "Pure" ]
src/CTT/CTT.thy
pc_tac
SumE_fst : "p : Sum(A,B) \<Longrightarrow> fst(p) : A" unfolding basic_defs apply (erule SumE) apply assumption done text \<open>The first premise must be \<open>p:Sum(A,B)\<close>!!.\<close>
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
SumE_fst
SumE_snd : assumes major: "p: Sum(A,B)" and "A type" and "\<And>x. x:A \<Longrightarrow> B(x) type" shows "snd(p) : B(fst(p))" unfolding basic_defs apply (rule major [THEN SumE]) apply (rule SumC [THEN subst_eqtyparg, THEN replace_type]) apply (typechk assms) done
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
SumE_snd
Bool :: "t" where "Bool \<equiv> T+T"
definition
src
[ "Pure" ]
src/CTT/CTT.thy
Bool
true :: "i" where "true \<equiv> inl(tt)"
definition
src
[ "Pure" ]
src/CTT/CTT.thy
true
false :: "i" where "false \<equiv> inr(tt)"
definition
src
[ "Pure" ]
src/CTT/CTT.thy
false
cond :: "[i,i,i]\<Rightarrow>i" where "cond(a,b,c) \<equiv> when(a, \<lambda>_. b, \<lambda>_. c)" lemmas bool_defs = Bool_def true_def false_def cond_def
definition
src
[ "Pure" ]
src/CTT/CTT.thy
cond
boolF : "Bool type" unfolding bool_defs by typechk text \<open>Introduction rules for \<open>true\<close>, \<open>false\<close>.\<close>
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
boolF
boolI_true : "true : Bool" unfolding bool_defs by typechk
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
boolI_true
boolI_false : "false : Bool" unfolding bool_defs by typechk text \<open>Elimination rule: typing of \<open>cond\<close>.\<close>
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
boolI_false
boolE : "\<lbrakk>p:Bool; a : C(true); b : C(false)\<rbrakk> \<Longrightarrow> cond(p,a,b) : C(p)" unfolding bool_defs apply (typechk; erule TE) apply typechk done
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
boolE
boolEL : "\<lbrakk>p = q : Bool; a = c : C(true); b = d : C(false)\<rbrakk> \<Longrightarrow> cond(p,a,b) = cond(q,c,d) : C(p)" unfolding bool_defs apply (rule PlusEL) apply (erule asm_rl refl_elem [THEN TEL])+ done text \<open>Computation rules for \<open>true\<close>, \<open>false\<close>.\<close>
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
boolEL
boolC_true : "\<lbrakk>a : C(true); b : C(false)\<rbrakk> \<Longrightarrow> cond(true,a,b) = a : C(true)" unfolding bool_defs apply (rule comp_rls) apply typechk apply (erule_tac [!] TE) apply typechk done
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
boolC_true
boolC_false : "\<lbrakk>a : C(true); b : C(false)\<rbrakk> \<Longrightarrow> cond(false,a,b) = b : C(false)" unfolding bool_defs apply (rule comp_rls) apply typechk apply (erule_tac [!] TE) apply typechk done
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
boolC_false
add :: "[i,i]\<Rightarrow>i" (infixr \<open>#+\<close> 65) where "a#+b \<equiv> rec(a, b, \<lambda>u v. succ(v))"
definition
src
[ "Pure" ]
src/CTT/CTT.thy
add
diff :: "[i,i]\<Rightarrow>i" (infixr \<open>-\<close> 65) where "a-b \<equiv> rec(b, a, \<lambda>u v. rec(v, 0, \<lambda>x y. x))"
definition
src
[ "Pure" ]
src/CTT/CTT.thy
diff
absdiff :: "[i,i]\<Rightarrow>i" (infixr \<open>|-|\<close> 65) where "a|-|b \<equiv> (a-b) #+ (b-a)"
definition
src
[ "Pure" ]
src/CTT/CTT.thy
absdiff
mult :: "[i,i]\<Rightarrow>i" (infixr \<open>#*\<close> 70) where "a#*b \<equiv> rec(a, 0, \<lambda>u v. b #+ v)"
definition
src
[ "Pure" ]
src/CTT/CTT.thy
mult
mod :: "[i,i]\<Rightarrow>i" (infixr \<open>mod\<close> 70) where "a mod b \<equiv> rec(a, 0, \<lambda>u v. rec(succ(v) |-| b, 0, \<lambda>x y. succ(v)))"
definition
src
[ "Pure" ]
src/CTT/CTT.thy
mod
div :: "[i,i]\<Rightarrow>i" (infixr \<open>div\<close> 70) where "a div b \<equiv> rec(a, 0, \<lambda>u v. rec(succ(u) mod b, succ(v), \<lambda>x y. v))" lemmas arith_defs = add_def diff_def absdiff_def mult_def mod_def div_def
definition
src
[ "Pure" ]
src/CTT/CTT.thy
div
add_typing : "\<lbrakk>a:N; b:N\<rbrakk> \<Longrightarrow> a #+ b : N" unfolding arith_defs by typechk
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
add_typing
add_typingL : "\<lbrakk>a = c:N; b = d:N\<rbrakk> \<Longrightarrow> a #+ b = c #+ d : N" unfolding arith_defs by equal text \<open>Computation for \<open>add\<close>: 0 and successor cases.\<close>
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
add_typingL
addC0 : "b:N \<Longrightarrow> 0 #+ b = b : N" unfolding arith_defs by rew
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
addC0
addC_succ : "\<lbrakk>a:N; b:N\<rbrakk> \<Longrightarrow> succ(a) #+ b = succ(a #+ b) : N" unfolding arith_defs by rew subsubsection \<open>Multiplication\<close> text \<open>Typing of \<open>mult\<close>: short and long versions.\<close>
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
addC_succ
mult_typing : "\<lbrakk>a:N; b:N\<rbrakk> \<Longrightarrow> a #* b : N" unfolding arith_defs by (typechk add_typing)
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
mult_typing
mult_typingL : "\<lbrakk>a = c:N; b = d:N\<rbrakk> \<Longrightarrow> a #* b = c #* d : N" unfolding arith_defs by (equal add_typingL) text \<open>Computation for \<open>mult\<close>: 0 and successor cases.\<close>
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
mult_typingL
multC0 : "b:N \<Longrightarrow> 0 #* b = 0 : N" unfolding arith_defs by rew
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
multC0
multC_succ : "\<lbrakk>a:N; b:N\<rbrakk> \<Longrightarrow> succ(a) #* b = b #+ (a #* b) : N" unfolding arith_defs by rew subsubsection \<open>Difference\<close> text \<open>Typing of difference.\<close>
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
multC_succ
diff_typing : "\<lbrakk>a:N; b:N\<rbrakk> \<Longrightarrow> a - b : N" unfolding arith_defs by typechk
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
diff_typing
diff_typingL : "\<lbrakk>a = c:N; b = d:N\<rbrakk> \<Longrightarrow> a - b = c - d : N" unfolding arith_defs by equal text \<open>Computation for difference: 0 and successor cases.\<close>
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
diff_typingL
diffC0 : "a:N \<Longrightarrow> a - 0 = a : N" unfolding arith_defs by rew text \<open>Note: \<open>rec(a, 0, \<lambda>z w.z)\<close> is \<open>pred(a).\<close>\<close>
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
diffC0
diff_0_eq_0 : "b:N \<Longrightarrow> 0 - b = 0 : N" unfolding arith_defs by (NE b) hyp_rew text \<open> Essential to simplify FIRST!! (Else we get a critical pair) \<open>succ(a) - succ(b)\<close> rewrites to \<open>pred(succ(a) - b)\<close>. \<close>
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
diff_0_eq_0
diff_succ_succ : "\<lbrakk>a:N; b:N\<rbrakk> \<Longrightarrow> succ(a) - succ(b) = a - b : N" unfolding arith_defs apply hyp_rew apply (NE b) apply hyp_rew done
lemma
src
[ "Pure" ]
src/CTT/CTT.thy
diff_succ_succ