src/FOL/ex/mini.ML
author lcp
Fri, 25 Nov 1994 00:00:35 +0100
changeset 743 9dcce140bdfc
parent 663 dc3f0582e839
child 1459 d12da312eff4
permissions -rw-r--r--
prove_fun: new; no longer depends upon the version in simpdata.ML
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
663
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
     1
(*  Title: 	FOL/ex/mini
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
     2
    ID:         $Id$
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
     4
    Copyright   1994  University of Cambridge
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
     5
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
     6
Classical First-Order Logic
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
     7
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
     8
Conversion to nnf/miniscope format: pushing quantifiers in
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
     9
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    10
Demonstration of formula rewriting by proof
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    11
*)
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    12
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    13
val ccontr = FalseE RS classical;
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    14
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    15
(**** Negation Normal Form ****)
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    16
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    17
(*** de Morgan laws ***)
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    18
743
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    19
fun prove_fun s = 
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    20
 (writeln s;  
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    21
  prove_goal FOL.thy s
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    22
   (fn prems => [ (cut_facts_tac prems 1), 
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    23
		  (Cla.fast_tac FOL_cs 1) ]));
663
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    24
743
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    25
val demorgans = map prove_fun
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    26
    		  ["~(P&Q) <-> ~P | ~Q",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    27
		   "~(P|Q) <-> ~P & ~Q",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    28
		   "~~P <-> P",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    29
		   "~(ALL x.P(x)) <-> (EX x. ~P(x))",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    30
		   "~(EX x.P(x)) <-> (ALL x. ~P(x))"];
663
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    31
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    32
(*** Removal of --> and <-> (positive and negative occurrences) ***)
743
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    33
(*Last one is important for computing a compact CNF*)
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    34
val nnf_rews = map prove_fun
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    35
		["(P-->Q) <-> (~P | Q)",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    36
		 "~(P-->Q) <-> (P & ~Q)",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    37
		 "(P<->Q) <-> (~P | Q) & (~Q | P)",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    38
		 "~(P<->Q) <-> (P | Q) & (~P | ~Q)"];
663
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    39
743
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    40
(* BEWARE: rewrite rules for <-> can confuse the simplifier!! *)
663
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    41
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    42
(*** Pushing in the existential quantifiers ***)
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    43
743
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    44
val ex_rews = map prove_fun 
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    45
		["(EX x. P) <-> P",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    46
		 "(EX x. P(x) & Q) <-> (EX x.P(x)) & Q",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    47
		 "(EX x. P & Q(x)) <-> P & (EX x.Q(x))",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    48
		 "(EX x. P(x) | Q(x)) <-> (EX x.P(x)) | (EX x.Q(x))",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    49
		 "(EX x. P(x) | Q) <-> (EX x.P(x)) | Q",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    50
		 "(EX x. P | Q(x)) <-> P | (EX x.Q(x))"];
663
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    51
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    52
(*** Pushing in the universal quantifiers ***)
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    53
743
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    54
val all_rews = map prove_fun
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    55
		["(ALL x. P) <-> P",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    56
		 "(ALL x. P(x) & Q(x)) <-> (ALL x.P(x)) & (ALL x.Q(x))",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    57
		 "(ALL x. P(x) & Q) <-> (ALL x.P(x)) & Q",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    58
		 "(ALL x. P & Q(x)) <-> P & (ALL x.Q(x))",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    59
		 "(ALL x. P(x) | Q) <-> (ALL x.P(x)) | Q",
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    60
		 "(ALL x. P | Q(x)) <-> P | (ALL x.Q(x))"];
663
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    61
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    62
743
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    63
val mini_ss = 
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    64
  empty_ss 
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    65
  setmksimps (map mk_meta_eq o atomize o gen_all)
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    66
  setsolver  (fn prems => resolve_tac (triv_rls@prems) 
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    67
	                  ORELSE' assume_tac
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    68
	                  ORELSE' etac FalseE)
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    69
  setsubgoaler asm_simp_tac
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    70
  addsimps (demorgans @ nnf_rews @ ex_rews @ all_rews);
663
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    71
743
9dcce140bdfc prove_fun: new; no longer depends upon the version in simpdata.ML
lcp
parents: 663
diff changeset
    72
val mini_tac = rtac ccontr THEN' asm_full_simp_tac mini_ss;
663
dc3f0582e839 Miniscope conversoin; example of formula rewriting
lcp
parents:
diff changeset
    73