28 (Free v) => lambda (Free v) t |
28 (Free v) => lambda (Free v) t |
29 | (Var v) => lambda (Var v) t |
29 | (Var v) => lambda (Var v) t |
30 | (Const ("Pair", Type ("fun", [Ta, Type ("fun", [Tb, _])]))) $ us $ vs => |
30 | (Const ("Pair", Type ("fun", [Ta, Type ("fun", [Tb, _])]))) $ us $ vs => |
31 (HOLogic.split_const (Ta,Tb, fastype_of t)) $ (tupled_lambda us (tupled_lambda vs t)) |
31 (HOLogic.split_const (Ta,Tb, fastype_of t)) $ (tupled_lambda us (tupled_lambda vs t)) |
32 | _ => raise Match |
32 | _ => raise Match |
33 |
33 |
34 |
34 |
35 fun dest_all (Const ("all", _) $ Abs (a as (_,T,_))) = |
35 fun dest_all (Const ("all", _) $ Abs (a as (_,T,_))) = |
36 let |
36 let |
37 val (n, body) = Term.dest_abs a |
37 val (n, body) = Term.dest_abs a |
38 in |
38 in |
39 (Free (n, T), body) |
39 (Free (n, T), body) |
40 end |
40 end |
41 | dest_all _ = raise Match |
41 | dest_all _ = raise Match |
42 |
42 |
43 |
43 |
44 (* Removes all quantifiers from a term, replacing bound variables by frees. *) |
44 (* Removes all quantifiers from a term, replacing bound variables by frees. *) |
45 fun dest_all_all (t as (Const ("all",_) $ _)) = |
45 fun dest_all_all (t as (Const ("all",_) $ _)) = |
46 let |
46 let |
47 val (v,b) = dest_all t |
47 val (v,b) = dest_all t |
48 val (vs, b') = dest_all_all b |
48 val (vs, b') = dest_all_all b |
49 in |
49 in |
50 (v :: vs, b') |
50 (v :: vs, b') |
51 end |
51 end |
52 | dest_all_all t = ([],t) |
52 | dest_all_all t = ([],t) |
53 |
53 |
54 |
54 |
55 (* FIXME: similar to Variable.focus *) |
55 (* FIXME: similar to Variable.focus *) |
56 fun dest_all_all_ctx ctx (Const ("all", _) $ Abs (a as (n,T,b))) = |
56 fun dest_all_all_ctx ctx (Const ("all", _) $ Abs (a as (n,T,b))) = |
57 let |
57 let |
58 val [(n', _)] = Variable.variant_frees ctx [] [(n,T)] |
58 val [(n', _)] = Variable.variant_frees ctx [] [(n,T)] |
159 val thy = theory_of_cterm ct |
159 val thy = theory_of_cterm ct |
160 in |
160 in |
161 Goal.prove_internal [] |
161 Goal.prove_internal [] |
162 (cterm_of thy |
162 (cterm_of thy |
163 (Logic.mk_equals (t, |
163 (Logic.mk_equals (t, |
164 if is = [] |
164 if null is |
165 then mk (Const (neu, ty), foldr1 mk (map (nth xs) js)) |
165 then mk (Const (neu, ty), foldr1 mk (map (nth xs) js)) |
166 else if js = [] |
166 else if null js |
167 then mk (foldr1 mk (map (nth xs) is), Const (neu, ty)) |
167 then mk (foldr1 mk (map (nth xs) is), Const (neu, ty)) |
168 else mk (foldr1 mk (map (nth xs) is), foldr1 mk (map (nth xs) js))))) |
168 else mk (foldr1 mk (map (nth xs) is), foldr1 mk (map (nth xs) js))))) |
169 (K (rewrite_goals_tac ac |
169 (K (rewrite_goals_tac ac |
170 THEN rtac Drule.reflexive_thm 1)) |
170 THEN rtac Drule.reflexive_thm 1)) |
171 end |
171 end |