# HG changeset patch # User berghofe # Date 1229183973 -3600 # Node ID 933145f5a9ba960c869ad9b77490dd996c165dfc # Parent bebd671c6055c496e87e653e192e549d3761d7d7# Parent 6b23a58cc67c80442daeb7f36f116172dd15f8d6 merged diff -r bebd671c6055 -r 933145f5a9ba src/HOL/Nominal/Examples/Class.thy --- a/src/HOL/Nominal/Examples/Class.thy Sat Dec 13 16:29:33 2008 +0100 +++ b/src/HOL/Nominal/Examples/Class.thy Sat Dec 13 16:59:33 2008 +0100 @@ -1,5 +1,3 @@ -(* $Id$ *) - theory Class imports "../Nominal" begin @@ -17,16 +15,22 @@ | OR "ty" "ty" ("_ OR _" [100,100] 100) | IMP "ty" "ty" ("_ IMP _" [100,100] 100) -instance ty :: size .. - -nominal_primrec +instantiation ty :: size +begin + +nominal_primrec size_ty +where "size (PR s) = (1::nat)" - "size (NOT T) = 1 + size T" - "size (T1 AND T2) = 1 + size T1 + size T2" - "size (T1 OR T2) = 1 + size T1 + size T2" - "size (T1 IMP T2) = 1 + size T1 + size T2" +| "size (NOT T) = 1 + size T" +| "size (T1 AND T2) = 1 + size T1 + size T2" +| "size (T1 OR T2) = 1 + size T1 + size T2" +| "size (T1 IMP T2) = 1 + size T1 + size T2" by (rule TrueI)+ +instance .. + +end + lemma ty_cases: fixes T::ty shows "(\s. T=PR s) \ (\T'. T=NOT T') \ (\S U. T=S OR U) \ (\S U. T=S AND U) \ (\S U. T=S IMP U)" @@ -66,25 +70,23 @@ text {* renaming functions *} -consts - nrename :: "trm \ name \ name \ trm" ("_[_\n>_]" [100,100,100] 100) +nominal_primrec (freshness_context: "(d::coname,e::coname)") crename :: "trm \ coname \ coname \ trm" ("_[_\c>_]" [100,100,100] 100) - -nominal_primrec (freshness_context: "(d::coname,e::coname)") +where "(Ax x a)[d\c>e] = (if a=d then Ax x e else Ax x a)" - "\a\(d,e,N);x\M\ \ (Cut .M (x).N)[d\c>e] = Cut .(M[d\c>e]) (x).(N[d\c>e])" - "(NotR (x).M a)[d\c>e] = (if a=d then NotR (x).(M[d\c>e]) e else NotR (x).(M[d\c>e]) a)" - "a\(d,e) \ (NotL .M x)[d\c>e] = (NotL .(M[d\c>e]) x)" - "\a\(d,e,N,c);b\(d,e,M,c);b\a\ \ (AndR .M .N c)[d\c>e] = +| "\a\(d,e,N);x\M\ \ (Cut .M (x).N)[d\c>e] = Cut .(M[d\c>e]) (x).(N[d\c>e])" +| "(NotR (x).M a)[d\c>e] = (if a=d then NotR (x).(M[d\c>e]) e else NotR (x).(M[d\c>e]) a)" +| "a\(d,e) \ (NotL .M x)[d\c>e] = (NotL .(M[d\c>e]) x)" +| "\a\(d,e,N,c);b\(d,e,M,c);b\a\ \ (AndR .M .N c)[d\c>e] = (if c=d then AndR .(M[d\c>e]) .(N[d \c>e]) e else AndR .(M[d\c>e]) .(N[d\c>e]) c)" - "x\y \ (AndL1 (x).M y)[d\c>e] = AndL1 (x).(M[d\c>e]) y" - "x\y \ (AndL2 (x).M y)[d\c>e] = AndL2 (x).(M[d\c>e]) y" - "a\(d,e,b) \ (OrR1 .M b)[d\c>e] = (if b=d then OrR1 .(M[d\c>e]) e else OrR1 .(M[d\c>e]) b)" - "a\(d,e,b) \ (OrR2 .M b)[d\c>e] = (if b=d then OrR2 .(M[d\c>e]) e else OrR2 .(M[d\c>e]) b)" - "\x\(N,z);y\(M,z);y\x\ \ (OrL (x).M (y).N z)[d\c>e] = OrL (x).(M[d\c>e]) (y).(N[d\c>e]) z" - "a\(d,e,b) \ (ImpR (x)..M b)[d\c>e] = +| "x\y \ (AndL1 (x).M y)[d\c>e] = AndL1 (x).(M[d\c>e]) y" +| "x\y \ (AndL2 (x).M y)[d\c>e] = AndL2 (x).(M[d\c>e]) y" +| "a\(d,e,b) \ (OrR1 .M b)[d\c>e] = (if b=d then OrR1 .(M[d\c>e]) e else OrR1 .(M[d\c>e]) b)" +| "a\(d,e,b) \ (OrR2 .M b)[d\c>e] = (if b=d then OrR2 .(M[d\c>e]) e else OrR2 .(M[d\c>e]) b)" +| "\x\(N,z);y\(M,z);y\x\ \ (OrL (x).M (y).N z)[d\c>e] = OrL (x).(M[d\c>e]) (y).(N[d\c>e]) z" +| "a\(d,e,b) \ (ImpR (x)..M b)[d\c>e] = (if b=d then ImpR (x)..(M[d\c>e]) e else ImpR (x)..(M[d\c>e]) b)" - "\a\(d,e,N);x\(M,y)\ \ (ImpL .M (x).N y)[d\c>e] = ImpL .(M[d\c>e]) (x).(N[d\c>e]) y" +| "\a\(d,e,N);x\(M,y)\ \ (ImpL .M (x).N y)[d\c>e] = ImpL .(M[d\c>e]) (x).(N[d\c>e]) y" apply(finite_guess)+ apply(rule TrueI)+ apply(simp add: abs_fresh abs_supp fin_supp)+ @@ -92,19 +94,21 @@ done nominal_primrec (freshness_context: "(u::name,v::name)") + nrename :: "trm \ name \ name \ trm" ("_[_\n>_]" [100,100,100] 100) +where "(Ax x a)[u\n>v] = (if x=u then Ax v a else Ax x a)" - "\a\N;x\(u,v,M)\ \ (Cut .M (x).N)[u\n>v] = Cut .(M[u\n>v]) (x).(N[u\n>v])" - "x\(u,v) \ (NotR (x).M a)[u\n>v] = NotR (x).(M[u\n>v]) a" - "(NotL .M x)[u\n>v] = (if x=u then NotL .(M[u\n>v]) v else NotL .(M[u\n>v]) x)" - "\a\(N,c);b\(M,c);b\a\ \ (AndR .M .N c)[u\n>v] = AndR .(M[u\n>v]) .(N[u\n>v]) c" - "x\(u,v,y) \ (AndL1 (x).M y)[u\n>v] = (if y=u then AndL1 (x).(M[u\n>v]) v else AndL1 (x).(M[u\n>v]) y)" - "x\(u,v,y) \ (AndL2 (x).M y)[u\n>v] = (if y=u then AndL2 (x).(M[u\n>v]) v else AndL2 (x).(M[u\n>v]) y)" - "a\b \ (OrR1 .M b)[u\n>v] = OrR1 .(M[u\n>v]) b" - "a\b \ (OrR2 .M b)[u\n>v] = OrR2 .(M[u\n>v]) b" - "\x\(u,v,N,z);y\(u,v,M,z);y\x\ \ (OrL (x).M (y).N z)[u\n>v] = +| "\a\N;x\(u,v,M)\ \ (Cut .M (x).N)[u\n>v] = Cut .(M[u\n>v]) (x).(N[u\n>v])" +| "x\(u,v) \ (NotR (x).M a)[u\n>v] = NotR (x).(M[u\n>v]) a" +| "(NotL .M x)[u\n>v] = (if x=u then NotL .(M[u\n>v]) v else NotL .(M[u\n>v]) x)" +| "\a\(N,c);b\(M,c);b\a\ \ (AndR .M .N c)[u\n>v] = AndR .(M[u\n>v]) .(N[u\n>v]) c" +| "x\(u,v,y) \ (AndL1 (x).M y)[u\n>v] = (if y=u then AndL1 (x).(M[u\n>v]) v else AndL1 (x).(M[u\n>v]) y)" +| "x\(u,v,y) \ (AndL2 (x).M y)[u\n>v] = (if y=u then AndL2 (x).(M[u\n>v]) v else AndL2 (x).(M[u\n>v]) y)" +| "a\b \ (OrR1 .M b)[u\n>v] = OrR1 .(M[u\n>v]) b" +| "a\b \ (OrR2 .M b)[u\n>v] = OrR2 .(M[u\n>v]) b" +| "\x\(u,v,N,z);y\(u,v,M,z);y\x\ \ (OrL (x).M (y).N z)[u\n>v] = (if z=u then OrL (x).(M[u\n>v]) (y).(N[u\n>v]) v else OrL (x).(M[u\n>v]) (y).(N[u\n>v]) z)" - "\a\b; x\(u,v)\ \ (ImpR (x)..M b)[u\n>v] = ImpR (x)..(M[u\n>v]) b" - "\a\N;x\(u,v,M,y)\ \ (ImpL .M (x).N y)[u\n>v] = +| "\a\b; x\(u,v)\ \ (ImpR (x)..M b)[u\n>v] = ImpR (x)..(M[u\n>v]) b" +| "\a\N;x\(u,v,M,y)\ \ (ImpL .M (x).N y)[u\n>v] = (if y=u then ImpL .(M[u\n>v]) (x).(N[u\n>v]) v else ImpL .(M[u\n>v]) (x).(N[u\n>v]) y)" apply(finite_guess)+ apply(rule TrueI)+ @@ -766,32 +770,30 @@ apply(simp add: fin_supp) done -consts +nominal_primrec (freshness_context: "(y::name,c::coname,P::trm)") substn :: "trm \ name \ coname \ trm \ trm" ("_{_:=<_>._}" [100,100,100,100] 100) - substc :: "trm \ coname \ name \ trm \ trm" ("_{_:=(_)._}" [100,100,100,100] 100) - -nominal_primrec (freshness_context: "(y::name,c::coname,P::trm)") +where "(Ax x a){y:=.P} = (if x=y then Cut .P (y).Ax y a else Ax x a)" - "\a\(c,P,N);x\(y,P,M)\ \ (Cut .M (x).N){y:=.P} = +| "\a\(c,P,N);x\(y,P,M)\ \ (Cut .M (x).N){y:=.P} = (if M=Ax y a then Cut .P (x).(N{y:=.P}) else Cut .(M{y:=.P}) (x).(N{y:=.P}))" - "x\(y,P) \ (NotR (x).M a){y:=.P} = NotR (x).(M{y:=.P}) a" - "a\(c,P) \ (NotL .M x){y:=.P} = +| "x\(y,P) \ (NotR (x).M a){y:=.P} = NotR (x).(M{y:=.P}) a" +| "a\(c,P) \ (NotL .M x){y:=.P} = (if x=y then fresh_fun (\x'. Cut .P (x').NotL .(M{y:=.P}) x') else NotL .(M{y:=.P}) x)" - "\a\(c,P,N,d);b\(c,P,M,d);b\a\ \ +| "\a\(c,P,N,d);b\(c,P,M,d);b\a\ \ (AndR .M .N d){y:=.P} = AndR .(M{y:=.P}) .(N{y:=.P}) d" - "x\(y,P,z) \ (AndL1 (x).M z){y:=.P} = +| "x\(y,P,z) \ (AndL1 (x).M z){y:=.P} = (if z=y then fresh_fun (\z'. Cut .P (z').AndL1 (x).(M{y:=.P}) z') else AndL1 (x).(M{y:=.P}) z)" - "x\(y,P,z) \ (AndL2 (x).M z){y:=.P} = +| "x\(y,P,z) \ (AndL2 (x).M z){y:=.P} = (if z=y then fresh_fun (\z'. Cut .P (z').AndL2 (x).(M{y:=.P}) z') else AndL2 (x).(M{y:=.P}) z)" - "a\(c,P,b) \ (OrR1 .M b){y:=.P} = OrR1 .(M{y:=.P}) b" - "a\(c,P,b) \ (OrR2 .M b){y:=.P} = OrR2 .(M{y:=.P}) b" - "\x\(y,N,P,z);u\(y,M,P,z);x\u\ \ (OrL (x).M (u).N z){y:=.P} = +| "a\(c,P,b) \ (OrR1 .M b){y:=.P} = OrR1 .(M{y:=.P}) b" +| "a\(c,P,b) \ (OrR2 .M b){y:=.P} = OrR2 .(M{y:=.P}) b" +| "\x\(y,N,P,z);u\(y,M,P,z);x\u\ \ (OrL (x).M (u).N z){y:=.P} = (if z=y then fresh_fun (\z'. Cut .P (z').OrL (x).(M{y:=.P}) (u).(N{y:=.P}) z') else OrL (x).(M{y:=.P}) (u).(N{y:=.P}) z)" - "\a\(b,c,P); x\(y,P)\ \ (ImpR (x)..M b){y:=.P} = ImpR (x)..(M{y:=.P}) b" - "\a\(N,c,P);x\(y,P,M,z)\ \ (ImpL .M (x).N z){y:=.P} = +| "\a\(b,c,P); x\(y,P)\ \ (ImpR (x)..M b){y:=.P} = ImpR (x)..(M{y:=.P}) b" +| "\a\(N,c,P);x\(y,P,M,z)\ \ (ImpL .M (x).N z){y:=.P} = (if y=z then fresh_fun (\z'. Cut .P (z').ImpL .(M{y:=.P}) (x).(N{y:=.P}) z') else ImpL .(M{y:=.P}) (x).(N{y:=.P}) z)" apply(finite_guess)+ @@ -842,27 +844,29 @@ done nominal_primrec (freshness_context: "(d::name,z::coname,P::trm)") + substc :: "trm \ coname \ name \ trm \ trm" ("_{_:=(_)._}" [100,100,100,100] 100) +where "(Ax x a){d:=(z).P} = (if d=a then Cut .(Ax x a) (z).P else Ax x a)" - "\a\(d,P,N);x\(z,P,M)\ \ (Cut .M (x).N){d:=(z).P} = +| "\a\(d,P,N);x\(z,P,M)\ \ (Cut .M (x).N){d:=(z).P} = (if N=Ax x d then Cut .(M{d:=(z).P}) (z).P else Cut .(M{d:=(z).P}) (x).(N{d:=(z).P}))" - "x\(z,P) \ (NotR (x).M a){d:=(z).P} = +| "x\(z,P) \ (NotR (x).M a){d:=(z).P} = (if d=a then fresh_fun (\a'. Cut .NotR (x).(M{d:=(z).P}) a' (z).P) else NotR (x).(M{d:=(z).P}) a)" - "a\(d,P) \ (NotL .M x){d:=(z).P} = NotL .(M{d:=(z).P}) x" - "\a\(P,c,N,d);b\(P,c,M,d);b\a\ \ (AndR .M .N c){d:=(z).P} = +| "a\(d,P) \ (NotL .M x){d:=(z).P} = NotL .(M{d:=(z).P}) x" +| "\a\(P,c,N,d);b\(P,c,M,d);b\a\ \ (AndR .M .N c){d:=(z).P} = (if d=c then fresh_fun (\a'. Cut .(AndR .(M{d:=(z).P}) .(N{d:=(z).P}) a') (z).P) else AndR .(M{d:=(z).P}) .(N{d:=(z).P}) c)" - "x\(y,z,P) \ (AndL1 (x).M y){d:=(z).P} = AndL1 (x).(M{d:=(z).P}) y" - "x\(y,P,z) \ (AndL2 (x).M y){d:=(z).P} = AndL2 (x).(M{d:=(z).P}) y" - "a\(d,P,b) \ (OrR1 .M b){d:=(z).P} = +| "x\(y,z,P) \ (AndL1 (x).M y){d:=(z).P} = AndL1 (x).(M{d:=(z).P}) y" +| "x\(y,P,z) \ (AndL2 (x).M y){d:=(z).P} = AndL2 (x).(M{d:=(z).P}) y" +| "a\(d,P,b) \ (OrR1 .M b){d:=(z).P} = (if d=b then fresh_fun (\a'. Cut .OrR1 .(M{d:=(z).P}) a' (z).P) else OrR1 .(M{d:=(z).P}) b)" - "a\(d,P,b) \ (OrR2 .M b){d:=(z).P} = +| "a\(d,P,b) \ (OrR2 .M b){d:=(z).P} = (if d=b then fresh_fun (\a'. Cut .OrR2 .(M{d:=(z).P}) a' (z).P) else OrR2 .(M{d:=(z).P}) b)" - "\x\(N,z,P,u);y\(M,z,P,u);x\y\ \ (OrL (x).M (y).N u){d:=(z).P} = +| "\x\(N,z,P,u);y\(M,z,P,u);x\y\ \ (OrL (x).M (y).N u){d:=(z).P} = OrL (x).(M{d:=(z).P}) (y).(N{d:=(z).P}) u" - "\a\(b,d,P); x\(z,P)\ \ (ImpR (x)..M b){d:=(z).P} = +| "\a\(b,d,P); x\(z,P)\ \ (ImpR (x)..M b){d:=(z).P} = (if d=b then fresh_fun (\a'. Cut .ImpR (x)..(M{d:=(z).P}) a' (z).P) else ImpR (x)..(M{d:=(z).P}) b)" - "\a\(N,d,P);x\(y,z,P,M)\ \ (ImpL .M (x).N y){d:=(z).P} = +| "\a\(N,d,P);x\(y,z,P,M)\ \ (ImpL .M (x).N y){d:=(z).P} = ImpL .(M{d:=(z).P}) (x).(N{d:=(z).P}) y" apply(finite_guess)+ apply(rule TrueI)+ @@ -10305,11 +10309,10 @@ lemma BINDINGc_decreasing: shows "X\Y \ BINDINGc B Y \ BINDINGc B X" by (simp add: BINDINGc_def) (blast) - -consts - NOTRIGHT::"ty \ ntrm set \ ctrm set" nominal_primrec + NOTRIGHT :: "ty \ ntrm set \ ctrm set" +where "NOTRIGHT (NOT B) X = { :NotR (x).M a | a x M. fic (NotR (x).M a) a \ (x):M \ X }" apply(rule TrueI)+ done @@ -10365,11 +10368,10 @@ apply(drule pt_bij1[OF pt_coname_inst, OF at_coname_inst]) apply(simp add: swap_simps) done - -consts - NOTLEFT::"ty \ ctrm set \ ntrm set" nominal_primrec + NOTLEFT :: "ty \ ctrm set \ ntrm set" +where "NOTLEFT (NOT B) X = { (x):NotL .M x | a x M. fin (NotL .M x) x \ :M \ X }" apply(rule TrueI)+ done @@ -10425,11 +10427,10 @@ apply(drule pt_bij1[OF pt_coname_inst, OF at_coname_inst]) apply(simp add: swap_simps) done - -consts - ANDRIGHT::"ty \ ctrm set \ ctrm set \ ctrm set" nominal_primrec + ANDRIGHT :: "ty \ ctrm set \ ctrm set \ ctrm set" +where "ANDRIGHT (B AND C) X Y = { :AndR .M .N c | c a b M N. fic (AndR .M .N c) c \ :M \ X \ :N \ Y }" apply(rule TrueI)+ @@ -10505,10 +10506,9 @@ apply(simp) done -consts - ANDLEFT1::"ty \ ntrm set \ ntrm set" - nominal_primrec + ANDLEFT1 :: "ty \ ntrm set \ ntrm set" +where "ANDLEFT1 (B AND C) X = { (y):AndL1 (x).M y | x y M. fin (AndL1 (x).M y) y \ (x):M \ X }" apply(rule TrueI)+ done @@ -10565,10 +10565,9 @@ apply(simp add: swap_simps) done -consts - ANDLEFT2::"ty \ ntrm set \ ntrm set" - nominal_primrec + ANDLEFT2 :: "ty \ ntrm set \ ntrm set" +where "ANDLEFT2 (B AND C) X = { (y):AndL2 (x).M y | x y M. fin (AndL2 (x).M y) y \ (x):M \ X }" apply(rule TrueI)+ done @@ -10625,10 +10624,9 @@ apply(simp add: swap_simps) done -consts - ORLEFT::"ty \ ntrm set \ ntrm set \ ntrm set" - nominal_primrec + ORLEFT :: "ty \ ntrm set \ ntrm set \ ntrm set" +where "ORLEFT (B OR C) X Y = { (z):OrL (x).M (y).N z | x y z M N. fin (OrL (x).M (y).N z) z \ (x):M \ X \ (y):N \ Y }" apply(rule TrueI)+ @@ -10704,10 +10702,9 @@ apply(simp add: swap_simps) done -consts - ORRIGHT1::"ty \ ctrm set \ ctrm set" - nominal_primrec + ORRIGHT1 :: "ty \ ctrm set \ ctrm set" +where "ORRIGHT1 (B OR C) X = { :OrR1 .M b | a b M. fic (OrR1 .M b) b \ :M \ X }" apply(rule TrueI)+ done @@ -10764,10 +10761,9 @@ apply(simp) done -consts - ORRIGHT2::"ty \ ctrm set \ ctrm set" - nominal_primrec + ORRIGHT2 :: "ty \ ctrm set \ ctrm set" +where "ORRIGHT2 (B OR C) X = { :OrR2 .M b | a b M. fic (OrR2 .M b) b \ :M \ X }" apply(rule TrueI)+ done @@ -10824,10 +10820,9 @@ apply(simp) done -consts - IMPRIGHT::"ty \ ntrm set \ ctrm set \ ntrm set \ ctrm set \ ctrm set" - nominal_primrec + IMPRIGHT :: "ty \ ntrm set \ ctrm set \ ntrm set \ ctrm set \ ctrm set" +where "IMPRIGHT (B IMP C) X Y Z U= { :ImpR (x)..M b | x a b M. fic (ImpR (x)..M b) b \ (\z P. x\(z,P) \ (z):P \ Z \ (x):(M{a:=(z).P}) \ X) @@ -10954,10 +10949,9 @@ apply(perm_simp add: nsubst_eqvt fresh_right) done -consts - IMPLEFT::"ty \ ctrm set \ ntrm set \ ntrm set" - nominal_primrec + IMPLEFT :: "ty \ ctrm set \ ntrm set \ ntrm set" +where "IMPLEFT (B IMP C) X Y = { (y):ImpL .M (x).N y | x a y M N. fin (ImpL .M (x).N y) y \ :M \ X \ (x):N \ Y }" apply(rule TrueI)+ @@ -17800,23 +17794,21 @@ apply(auto) done -consts +nominal_primrec (freshness_context: "\n::(name\coname\trm)") stn :: "trm\(name\coname\trm) list\trm" - stc :: "trm\(coname\name\trm) list\trm" - -nominal_primrec (freshness_context: "\n::(name\coname\trm)") +where "stn (Ax x a) \n = lookupc x a \n" - "\a\(N,\n);x\(M,\n)\ \ stn (Cut .M (x).N) \n = (Cut .M (x).N)" - "x\\n \ stn (NotR (x).M a) \n = (NotR (x).M a)" - "a\\n \stn (NotL .M x) \n = (NotL .M x)" - "\a\(N,d,b,\n);b\(M,d,a,\n)\ \ stn (AndR .M .N d) \n = (AndR .M .N d)" - "x\(z,\n) \ stn (AndL1 (x).M z) \n = (AndL1 (x).M z)" - "x\(z,\n) \ stn (AndL2 (x).M z) \n = (AndL2 (x).M z)" - "a\(b,\n) \ stn (OrR1 .M b) \n = (OrR1 .M b)" - "a\(b,\n) \ stn (OrR2 .M b) \n = (OrR2 .M b)" - "\x\(N,z,u,\n);u\(M,z,x,\n)\ \ stn (OrL (x).M (u).N z) \n = (OrL (x).M (u).N z)" - "\a\(b,\n);x\\n\ \ stn (ImpR (x)..M b) \n = (ImpR (x)..M b)" - "\a\(N,\n);x\(M,z,\n)\ \ stn (ImpL .M (x).N z) \n = (ImpL .M (x).N z)" +| "\a\(N,\n);x\(M,\n)\ \ stn (Cut .M (x).N) \n = (Cut .M (x).N)" +| "x\\n \ stn (NotR (x).M a) \n = (NotR (x).M a)" +| "a\\n \stn (NotL .M x) \n = (NotL .M x)" +| "\a\(N,d,b,\n);b\(M,d,a,\n)\ \ stn (AndR .M .N d) \n = (AndR .M .N d)" +| "x\(z,\n) \ stn (AndL1 (x).M z) \n = (AndL1 (x).M z)" +| "x\(z,\n) \ stn (AndL2 (x).M z) \n = (AndL2 (x).M z)" +| "a\(b,\n) \ stn (OrR1 .M b) \n = (OrR1 .M b)" +| "a\(b,\n) \ stn (OrR2 .M b) \n = (OrR2 .M b)" +| "\x\(N,z,u,\n);u\(M,z,x,\n)\ \ stn (OrL (x).M (u).N z) \n = (OrL (x).M (u).N z)" +| "\a\(b,\n);x\\n\ \ stn (ImpR (x)..M b) \n = (ImpR (x)..M b)" +| "\a\(N,\n);x\(M,z,\n)\ \ stn (ImpL .M (x).N z) \n = (ImpL .M (x).N z)" apply(finite_guess)+ apply(rule TrueI)+ apply(simp add: abs_fresh abs_supp fin_supp)+ @@ -17824,18 +17816,20 @@ done nominal_primrec (freshness_context: "\c::(coname\name\trm)") + stc :: "trm\(coname\name\trm) list\trm" +where "stc (Ax x a) \c = lookupd x a \c" - "\a\(N,\c);x\(M,\c)\ \ stc (Cut .M (x).N) \c = (Cut .M (x).N)" - "x\\c \ stc (NotR (x).M a) \c = (NotR (x).M a)" - "a\\c \ stc (NotL .M x) \c = (NotL .M x)" - "\a\(N,d,b,\c);b\(M,d,a,\c)\ \ stc (AndR .M .N d) \c = (AndR .M .N d)" - "x\(z,\c) \ stc (AndL1 (x).M z) \c = (AndL1 (x).M z)" - "x\(z,\c) \ stc (AndL2 (x).M z) \c = (AndL2 (x).M z)" - "a\(b,\c) \ stc (OrR1 .M b) \c = (OrR1 .M b)" - "a\(b,\c) \ stc (OrR2 .M b) \c = (OrR2 .M b)" - "\x\(N,z,u,\c);u\(M,z,x,\c)\ \ stc (OrL (x).M (u).N z) \c = (OrL (x).M (u).N z)" - "\a\(b,\c);x\\c\ \ stc (ImpR (x)..M b) \c = (ImpR (x)..M b)" - "\a\(N,\c);x\(M,z,\c)\ \ stc (ImpL .M (x).N z) \c = (ImpL .M (x).N z)" +| "\a\(N,\c);x\(M,\c)\ \ stc (Cut .M (x).N) \c = (Cut .M (x).N)" +| "x\\c \ stc (NotR (x).M a) \c = (NotR (x).M a)" +| "a\\c \ stc (NotL .M x) \c = (NotL .M x)" +| "\a\(N,d,b,\c);b\(M,d,a,\c)\ \ stc (AndR .M .N d) \c = (AndR .M .N d)" +| "x\(z,\c) \ stc (AndL1 (x).M z) \c = (AndL1 (x).M z)" +| "x\(z,\c) \ stc (AndL2 (x).M z) \c = (AndL2 (x).M z)" +| "a\(b,\c) \ stc (OrR1 .M b) \c = (OrR1 .M b)" +| "a\(b,\c) \ stc (OrR2 .M b) \c = (OrR2 .M b)" +| "\x\(N,z,u,\c);u\(M,z,x,\c)\ \ stc (OrL (x).M (u).N z) \c = (OrL (x).M (u).N z)" +| "\a\(b,\c);x\\c\ \ stc (ImpR (x)..M b) \c = (ImpR (x)..M b)" +| "\a\(N,\c);x\(M,z,\c)\ \ stc (ImpL .M (x).N z) \c = (ImpL .M (x).N z)" apply(finite_guess)+ apply(rule TrueI)+ apply(simp add: abs_fresh abs_supp fin_supp)+ @@ -17926,51 +17920,50 @@ apply(perm_simp) done -consts +nominal_primrec (freshness_context: "(\n::(name\coname\trm) list,\c::(coname\name\trm) list)") psubst :: "(name\coname\trm) list\(coname\name\trm) list\trm\trm" ("_,_<_>" [100,100,100] 100) - -nominal_primrec (freshness_context: "(\n::(name\coname\trm) list,\c::(coname\name\trm) list)") +where "\n,\c = lookup x a \n \c" - "\a\(N,\n,\c);x\(M,\n,\c)\ \ \n,\c.M (x).N> = +| "\a\(N,\n,\c);x\(M,\n,\c)\ \ \n,\c.M (x).N> = Cut .(if \x. M=Ax x a then stn M \n else \n,\c) (x).(if \a. N=Ax x a then stc N \c else \n,\c)" - "x\(\n,\c) \ \n,\c = +| "x\(\n,\c) \ \n,\c = (case (findc \c a) of Some (u,P) \ fresh_fun (\a'. Cut .NotR (x).(\n,\c) a' (u).P) | None \ NotR (x).(\n,\c) a)" - "a\(\n,\c) \ \n,\c.M x> = +| "a\(\n,\c) \ \n,\c.M x> = (case (findn \n x) of Some (c,P) \ fresh_fun (\x'. Cut .P (x').(NotL .(\n,\c) x')) | None \ NotL .(\n,\c) x)" - "\a\(N,c,\n,\c);b\(M,c,\n,\c);b\a\ \ (\n,\c.M .N c>) = +| "\a\(N,c,\n,\c);b\(M,c,\n,\c);b\a\ \ (\n,\c.M .N c>) = (case (findc \c c) of Some (x,P) \ fresh_fun (\a'. Cut .(AndR .(\n,\c) .(\n,\c) a') (x).P) | None \ AndR .(\n,\c) .(\n,\c) c)" - "x\(z,\n,\c) \ (\n,\c) = +| "x\(z,\n,\c) \ (\n,\c) = (case (findn \n z) of Some (c,P) \ fresh_fun (\z'. Cut .P (z').AndL1 (x).(\n,\c) z') | None \ AndL1 (x).(\n,\c) z)" - "x\(z,\n,\c) \ (\n,\c) = +| "x\(z,\n,\c) \ (\n,\c) = (case (findn \n z) of Some (c,P) \ fresh_fun (\z'. Cut .P (z').AndL2 (x).(\n,\c) z') | None \ AndL2 (x).(\n,\c) z)" - "\x\(N,z,\n,\c);u\(M,z,\n,\c);x\u\ \ (\n,\c) = +| "\x\(N,z,\n,\c);u\(M,z,\n,\c);x\u\ \ (\n,\c) = (case (findn \n z) of Some (c,P) \ fresh_fun (\z'. Cut .P (z').OrL (x).(\n,\c) (u).(\n,\c) z') | None \ OrL (x).(\n,\c) (u).(\n,\c) z)" - "a\(b,\n,\c) \ (\n,\c.M b>) = +| "a\(b,\n,\c) \ (\n,\c.M b>) = (case (findc \c b) of Some (x,P) \ fresh_fun (\a'. Cut .OrR1 .(\n,\c) a' (x).P) | None \ OrR1 .(\n,\c) b)" - "a\(b,\n,\c) \ (\n,\c.M b>) = +| "a\(b,\n,\c) \ (\n,\c.M b>) = (case (findc \c b) of Some (x,P) \ fresh_fun (\a'. Cut .OrR2 .(\n,\c) a' (x).P) | None \ OrR2 .(\n,\c) b)" - "\a\(b,\n,\c); x\(\n,\c)\ \ (\n,\c.M b>) = +| "\a\(b,\n,\c); x\(\n,\c)\ \ (\n,\c.M b>) = (case (findc \c b) of Some (z,P) \ fresh_fun (\a'. Cut .ImpR (x)..(\n,\c) a' (z).P) | None \ ImpR (x)..(\n,\c) b)" - "\a\(N,\n,\c); x\(z,M,\n,\c)\ \ (\n,\c.M (x).N z>) = +| "\a\(N,\n,\c); x\(z,M,\n,\c)\ \ (\n,\c.M (x).N z>) = (case (findn \n z) of Some (c,P) \ fresh_fun (\z'. Cut .P (z').ImpL .(\n,\c) (x).(\n,\c) z') | None \ ImpL .(\n,\c) (x).(\n,\c) z)" diff -r bebd671c6055 -r 933145f5a9ba src/HOL/Nominal/Examples/W.thy --- a/src/HOL/Nominal/Examples/W.thy Sat Dec 13 16:29:33 2008 +0100 +++ b/src/HOL/Nominal/Examples/W.thy Sat Dec 13 16:59:33 2008 +0100 @@ -1,5 +1,3 @@ -(* "$Id$" *) - theory W imports Nominal begin @@ -50,26 +48,68 @@ Ctxt = "(var\tyS) list" text {* free type variables *} -consts - ftv :: "'a \ tvar list" + +class ftv = type + + fixes ftv :: "'a \ tvar list" + +instantiation * :: (ftv, ftv) ftv +begin + +primrec ftv_prod +where + "ftv (x::'a::ftv, y::'b::ftv) = (ftv x)@(ftv y)" + +instance .. + +end -primrec (ftv_of_prod) - "ftv (x,y) = (ftv x)@(ftv y)" +instantiation tvar :: ftv +begin + +definition + ftv_of_tvar[simp]: "ftv X \ [(X::tvar)]" -defs (overloaded) - ftv_of_tvar[simp]: "ftv X \ [(X::tvar)]" +instance .. + +end + +instantiation var :: ftv +begin + +definition ftv_of_var[simp]: "ftv (x::var) \ []" -primrec (ftv_of_list) +instance .. + +end + +instantiation list :: (ftv) ftv +begin + +primrec ftv_list +where "ftv [] = []" - "ftv (x#xs) = (ftv x)@(ftv xs)" +| "ftv (x#xs) = (ftv x)@(ftv xs)" + +instance .. + +end (* free type-variables of types *) -nominal_primrec (ftv_ty) + +instantiation ty :: ftv +begin + +nominal_primrec ftv_ty +where "ftv (TVar X) = [X]" - "ftv (T\<^isub>1\T\<^isub>2) = (ftv T\<^isub>1)@(ftv T\<^isub>2)" +| "ftv (T\<^isub>1\T\<^isub>2) = (ftv T\<^isub>1)@(ftv T\<^isub>2)" by (rule TrueI)+ +instance .. + +end + lemma ftv_ty_eqvt[eqvt]: fixes pi::"tvar prm" and T::"ty" @@ -77,9 +117,13 @@ by (nominal_induct T rule: ty.strong_induct) (perm_simp add: append_eqvt)+ -nominal_primrec (ftv_tyS) +instantiation tyS :: ftv +begin + +nominal_primrec ftv_tyS +where "ftv (Ty T) = ftv T" - "ftv (\[X].S) = (ftv S) - [X]" +| "ftv (\[X].S) = (ftv S) - [X]" apply(finite_guess add: ftv_ty_eqvt fs_tvar1)+ apply(rule TrueI)+ apply(rule difference_fresh) @@ -87,6 +131,10 @@ apply(fresh_guess add: ftv_ty_eqvt fs_tvar1)+ done +instance .. + +end + lemma ftv_tyS_eqvt[eqvt]: fixes pi::"tvar prm" and S::"tyS" @@ -140,11 +188,11 @@ types Subst = "(tvar\ty) list" -consts - psubst :: "Subst \ 'a \ 'a" ("_<_>" [100,60] 120) +class psubst = + fixes psubst :: "Subst \ 'a \ 'a" ("_<_>" [100,60] 120) abbreviation - subst :: "'a \ tvar \ ty \ 'a" ("_[_::=_]" [100,100,100] 100) + subst :: "'a::psubst \ tvar \ ty \ 'a" ("_[_::=_]" [100,100,100] 100) where "smth[X::=T] \ ([(X,T)])" @@ -159,11 +207,19 @@ shows "pi\(lookup \ X) = lookup (pi\\) (pi\X)" by (induct \) (auto simp add: eqvts) -nominal_primrec (psubst_ty) +instantiation ty :: psubst +begin + +nominal_primrec psubst_ty +where "\ = lookup \ X" - "\1 \ T\<^isub>2> = (\1>) \ (\2>)" +| "\1 \ T\<^isub>2> = (\1>) \ (\2>)" by (rule TrueI)+ +instance .. + +end + lemma psubst_ty_eqvt[eqvt]: fixes pi1::"tvar prm" and \::"Subst"