src/HOL/Nominal/Examples/Crary.thy
changeset 24088 c2d8270e53a5
parent 24070 ff4c715a11cd
child 24231 85fb973a8207
equal deleted inserted replaced
24087:eb025d149a34 24088:c2d8270e53a5
    39 lemma fresh_ty[simp]:
    39 lemma fresh_ty[simp]:
    40   fixes x::"name" 
    40   fixes x::"name" 
    41   and   T::"ty"
    41   and   T::"ty"
    42   shows "x\<sharp>T"
    42   shows "x\<sharp>T"
    43   by (simp add: fresh_def supp_def)
    43   by (simp add: fresh_def supp_def)
    44 
       
    45 
       
    46 
    44 
    47 lemma ty_cases:
    45 lemma ty_cases:
    48   fixes T::ty
    46   fixes T::ty
    49   shows "(\<exists> T\<^isub>1 T\<^isub>2. T=T\<^isub>1\<rightarrow>T\<^isub>2) \<or> T=TUnit \<or> T=TBase"
    47   shows "(\<exists> T\<^isub>1 T\<^isub>2. T=T\<^isub>1\<rightarrow>T\<^isub>2) \<or> T=TUnit \<or> T=TBase"
    50 by (induct T rule:ty.weak_induct) (auto)
    48 by (induct T rule:ty.weak_induct) (auto)
   316 lemma typing_implies_valid:
   314 lemma typing_implies_valid:
   317   assumes a: "\<Gamma> \<turnstile> t : T"
   315   assumes a: "\<Gamma> \<turnstile> t : T"
   318   shows "valid \<Gamma>"
   316   shows "valid \<Gamma>"
   319   using a by (induct) (auto)
   317   using a by (induct) (auto)
   320 
   318 
   321 (*
       
   322 declare trm.inject [simp add]
   319 declare trm.inject [simp add]
   323 declare ty.inject  [simp add]
   320 declare ty.inject  [simp add]
   324 
   321 
   325 inductive_cases2 t_Lam_elim_auto[elim]: "\<Gamma> \<turnstile> Lam [x].t : T"
   322 inductive_cases typing_inv_auto[elim]:
   326 inductive_cases2 t_Var_elim_auto[elim]: "\<Gamma> \<turnstile> Var x : T"
   323   "\<Gamma> \<turnstile> Lam [x].t : T"
   327 inductive_cases2 t_App_elim_auto[elim]: "\<Gamma> \<turnstile> App x y : T"
   324   "\<Gamma> \<turnstile> Var x : T"
   328 inductive_cases2 t_Const_elim_auto[elim]: "\<Gamma> \<turnstile> Const n : T"
   325   "\<Gamma> \<turnstile> App x y : T"
   329 inductive_cases2 t_Unit_elim_auto[elim]: "\<Gamma> \<turnstile> Unit : TUnit"
   326   "\<Gamma> \<turnstile> Const n : T"
   330 inductive_cases2 t_Unit_elim_auto'[elim]: "\<Gamma> \<turnstile> s : TUnit"
   327   "\<Gamma> \<turnstile> Unit : TUnit"
       
   328   "\<Gamma> \<turnstile> s : TUnit"
   331 
   329 
   332 declare trm.inject [simp del]
   330 declare trm.inject [simp del]
   333 declare ty.inject [simp del]
   331 declare ty.inject [simp del]
   334 *)
   332 
   335 
   333 
   336 section {* Definitional Equivalence *}
   334 section {* Definitional Equivalence *}
   337 
   335 
   338 inductive
   336 inductive
   339   def_equiv :: "Ctxt\<Rightarrow>trm\<Rightarrow>trm\<Rightarrow>ty\<Rightarrow>bool" ("_ \<turnstile> _ \<equiv> _ : _" [60,60] 60) 
   337   def_equiv :: "Ctxt\<Rightarrow>trm\<Rightarrow>trm\<Rightarrow>ty\<Rightarrow>bool" ("_ \<turnstile> _ \<equiv> _ : _" [60,60] 60) 
   488 | QAR_App[intro]:  "t\<^isub>1 \<leadsto> t\<^isub>1' \<Longrightarrow> App t\<^isub>1 t\<^isub>2 \<leadsto> App t\<^isub>1' t\<^isub>2"
   486 | QAR_App[intro]:  "t\<^isub>1 \<leadsto> t\<^isub>1' \<Longrightarrow> App t\<^isub>1 t\<^isub>2 \<leadsto> App t\<^isub>1' t\<^isub>2"
   489 
   487 
   490 declare trm.inject  [simp add]
   488 declare trm.inject  [simp add]
   491 declare ty.inject  [simp add]
   489 declare ty.inject  [simp add]
   492 
   490 
   493 inductive_cases whr_Gen[elim]: "t \<leadsto> t'"
   491 inductive_cases whr_inv_auto[elim]: 
   494 inductive_cases whr_Lam[elim]: "Lam [x].t \<leadsto> t'"
   492   "t \<leadsto> t'"
   495 inductive_cases whr_App_Lam[elim]: "App (Lam [x].t12) t2 \<leadsto> t"
   493   "Lam [x].t \<leadsto> t'"
   496 inductive_cases whr_Var[elim]: "Var x \<leadsto> t"
   494   "App (Lam [x].t12) t2 \<leadsto> t"
   497 inductive_cases whr_Const[elim]: "Const n \<leadsto> t"
   495   "Var x \<leadsto> t"
   498 inductive_cases whr_App[elim]: "App p q \<leadsto> t"
   496   "Const n \<leadsto> t"
   499 inductive_cases whr_Const_Right[elim]: "t \<leadsto> Const n"
   497   "App p q \<leadsto> t"
   500 inductive_cases whr_Var_Right[elim]: "t \<leadsto> Var x"
   498   "t \<leadsto> Const n"
   501 inductive_cases whr_App_Right[elim]: "t \<leadsto> App p q"
   499   "t \<leadsto> Var x"
       
   500   "t \<leadsto> App p q"
   502 
   501 
   503 declare trm.inject  [simp del]
   502 declare trm.inject  [simp del]
   504 declare ty.inject  [simp del]
   503 declare ty.inject  [simp del]
   505 
   504 
   506 equivariance whr_def
   505 equivariance whr_def
   543   assumes a: "x \<leadsto> a" 
   542   assumes a: "x \<leadsto> a" 
   544   and     b: "x \<leadsto> b"
   543   and     b: "x \<leadsto> b"
   545   shows "a=b"
   544   shows "a=b"
   546   using a b
   545   using a b
   547 apply (induct arbitrary: b)
   546 apply (induct arbitrary: b)
   548 apply (erule whr_App_Lam)
   547 apply (erule whr_inv_auto(3))
   549 apply (clarify)
   548 apply (clarify)
   550 apply (rule subst_fun_eq)
   549 apply (rule subst_fun_eq)
   551 apply (simp)
   550 apply (simp)
   552 apply (force)
   551 apply (force)
   553 apply (erule whr_App)
   552 apply (erule whr_inv_auto(6))
   554 apply (blast)+
   553 apply (blast)+
   555 done
   554 done
   556 
   555 
   557 lemma nf_unicity :
   556 lemma nf_unicity :
   558   assumes "x \<Down> a" and "x \<Down> b"
   557   assumes "x \<Down> a" and "x \<Down> b"
   601 
   600 
   602 nominal_inductive alg_equiv
   601 nominal_inductive alg_equiv
   603   avoids QAT_Arrow: x
   602   avoids QAT_Arrow: x
   604   by simp_all
   603   by simp_all
   605 
   604 
   606 
       
   607 declare trm.inject [simp add]
   605 declare trm.inject [simp add]
   608 declare ty.inject  [simp add]
   606 declare ty.inject  [simp add]
   609 
   607 
   610 inductive_cases alg_equiv_Base_inv_auto[elim]: "\<Gamma> \<turnstile> s\<Leftrightarrow>t : TBase"
   608 inductive_cases alg_equiv_inv_auto[elim]: 
   611 inductive_cases alg_equiv_Arrow_inv_auto[elim]: "\<Gamma> \<turnstile> s\<Leftrightarrow>t : T\<^isub>1 \<rightarrow> T\<^isub>2"
   609   "\<Gamma> \<turnstile> s\<Leftrightarrow>t : TBase"
   612 
   610   "\<Gamma> \<turnstile> s\<Leftrightarrow>t : T\<^isub>1 \<rightarrow> T\<^isub>2"
   613 inductive_cases alg_path_equiv_Base_inv_auto[elim]: "\<Gamma> \<turnstile> s\<leftrightarrow>t : TBase"
   611   "\<Gamma> \<turnstile> s\<leftrightarrow>t : TBase"
   614 inductive_cases alg_path_equiv_Unit_inv_auto[elim]: "\<Gamma> \<turnstile> s\<leftrightarrow>t : TUnit"
   612   "\<Gamma> \<turnstile> s\<leftrightarrow>t : TUnit"
   615 inductive_cases alg_path_equiv_Arrow_inv_auto[elim]: "\<Gamma> \<turnstile> s\<leftrightarrow>t : T\<^isub>1 \<rightarrow> T\<^isub>2"
   613   "\<Gamma> \<turnstile> s\<leftrightarrow>t : T\<^isub>1 \<rightarrow> T\<^isub>2"
   616 
   614 
   617 inductive_cases alg_path_equiv_Var_left_inv_auto[elim]: "\<Gamma> \<turnstile> Var x \<leftrightarrow> t : T"
   615   "\<Gamma> \<turnstile> Var x \<leftrightarrow> t : T"
   618 inductive_cases alg_path_equiv_Var_left_inv_auto'[elim]: "\<Gamma> \<turnstile> Var x \<leftrightarrow> t : T'"
   616   "\<Gamma> \<turnstile> Var x \<leftrightarrow> t : T'"
   619 inductive_cases alg_path_equiv_Var_right_inv_auto[elim]: "\<Gamma> \<turnstile> s \<leftrightarrow> Var x : T"
   617   "\<Gamma> \<turnstile> s \<leftrightarrow> Var x : T"
   620 inductive_cases alg_path_equiv_Var_right_inv_auto'[elim]: "\<Gamma> \<turnstile> s \<leftrightarrow> Var x : T'"
   618   "\<Gamma> \<turnstile> s \<leftrightarrow> Var x : T'"
   621 inductive_cases alg_path_equiv_Const_left_inv_auto[elim]: "\<Gamma> \<turnstile> Const n \<leftrightarrow> t : T"
   619   "\<Gamma> \<turnstile> Const n \<leftrightarrow> t : T"
   622 inductive_cases alg_path_equiv_Const_right_inv_auto[elim]: "\<Gamma> \<turnstile> s \<leftrightarrow> Const n : T"
   620   "\<Gamma> \<turnstile> s \<leftrightarrow> Const n : T"
   623 inductive_cases alg_path_equiv_App_left_inv_auto[elim]: "\<Gamma> \<turnstile> App p s \<leftrightarrow> t : T"
   621   "\<Gamma> \<turnstile> App p s \<leftrightarrow> t : T"
   624 inductive_cases alg_path_equiv_App_right_inv_auto[elim]: "\<Gamma> \<turnstile> s \<leftrightarrow> App q t : T"
   622   "\<Gamma> \<turnstile> s \<leftrightarrow> App q t : T"
   625 inductive_cases alg_path_equiv_Lam_left_inv_auto[elim]: "\<Gamma> \<turnstile> Lam[x].s \<leftrightarrow> t : T"
   623   "\<Gamma> \<turnstile> Lam[x].s \<leftrightarrow> t : T"
   626 inductive_cases alg_path_equiv_Lam_right_inv_auto[elim]: "\<Gamma> \<turnstile> t \<leftrightarrow> Lam[x].s : T"
   624   "\<Gamma> \<turnstile> t \<leftrightarrow> Lam[x].s : T"
   627 
   625 
   628 declare trm.inject [simp del]
   626 declare trm.inject [simp del]
   629 declare ty.inject [simp del]
   627 declare ty.inject [simp del]
   630 
   628 
   631 lemma Q_Arrow_strong_inversion:
   629 lemma Q_Arrow_strong_inversion: