src/Pure/Proof/extraction.ML
changeset 67721 5348bea4accd
parent 67522 9e712280cc37
child 69992 bd3c10813cc4
equal deleted inserted replaced
67718:17874d43d3b3 67721:5348bea4accd
    38   Sign.root_path
    38   Sign.root_path
    39   #> Sign.add_types_global
    39   #> Sign.add_types_global
    40     [(Binding.make ("Type", \<^here>), 0, NoSyn),
    40     [(Binding.make ("Type", \<^here>), 0, NoSyn),
    41      (Binding.make ("Null", \<^here>), 0, NoSyn)]
    41      (Binding.make ("Null", \<^here>), 0, NoSyn)]
    42   #> Sign.add_consts
    42   #> Sign.add_consts
    43     [(Binding.make ("typeof", \<^here>), typ "'b => Type", NoSyn),
    43     [(Binding.make ("typeof", \<^here>), typ "'b \<Rightarrow> Type", NoSyn),
    44      (Binding.make ("Type", \<^here>), typ "'a itself => Type", NoSyn),
    44      (Binding.make ("Type", \<^here>), typ "'a itself \<Rightarrow> Type", NoSyn),
    45      (Binding.make ("Null", \<^here>), typ "Null", NoSyn),
    45      (Binding.make ("Null", \<^here>), typ "Null", NoSyn),
    46      (Binding.make ("realizes", \<^here>), typ "'a => 'b => 'b", NoSyn)];
    46      (Binding.make ("realizes", \<^here>), typ "'a \<Rightarrow> 'b \<Rightarrow> 'b", NoSyn)];
    47 
    47 
    48 val nullT = Type ("Null", []);
    48 val nullT = Type ("Null", []);
    49 val nullt = Const ("Null", nullT);
    49 val nullt = Const ("Null", nullT);
    50 
    50 
    51 fun mk_typ T =
    51 fun mk_typ T =
   428 
   428 
   429 val _ = Theory.setup
   429 val _ = Theory.setup
   430   (add_types [("prop", ([], NONE))] #>
   430   (add_types [("prop", ([], NONE))] #>
   431 
   431 
   432    add_typeof_eqns
   432    add_typeof_eqns
   433      ["(typeof (PROP P)) == (Type (TYPE(Null))) ==>  \
   433      ["(typeof (PROP P)) \<equiv> (Type (TYPE(Null))) \<Longrightarrow>  \
   434     \  (typeof (PROP Q)) == (Type (TYPE('Q))) ==>  \
   434     \  (typeof (PROP Q)) \<equiv> (Type (TYPE('Q))) \<Longrightarrow>  \
   435     \    (typeof (PROP P ==> PROP Q)) == (Type (TYPE('Q)))",
   435     \    (typeof (PROP P \<Longrightarrow> PROP Q)) \<equiv> (Type (TYPE('Q)))",
   436 
   436 
   437       "(typeof (PROP Q)) == (Type (TYPE(Null))) ==>  \
   437       "(typeof (PROP Q)) \<equiv> (Type (TYPE(Null))) \<Longrightarrow>  \
   438     \    (typeof (PROP P ==> PROP Q)) == (Type (TYPE(Null)))",
   438     \    (typeof (PROP P \<Longrightarrow> PROP Q)) \<equiv> (Type (TYPE(Null)))",
   439 
   439 
   440       "(typeof (PROP P)) == (Type (TYPE('P))) ==>  \
   440       "(typeof (PROP P)) \<equiv> (Type (TYPE('P))) \<Longrightarrow>  \
   441     \  (typeof (PROP Q)) == (Type (TYPE('Q))) ==>  \
   441     \  (typeof (PROP Q)) \<equiv> (Type (TYPE('Q))) \<Longrightarrow>  \
   442     \    (typeof (PROP P ==> PROP Q)) == (Type (TYPE('P => 'Q)))",
   442     \    (typeof (PROP P \<Longrightarrow> PROP Q)) \<equiv> (Type (TYPE('P \<Rightarrow> 'Q)))",
   443 
   443 
   444       "(%x. typeof (PROP P (x))) == (%x. Type (TYPE(Null))) ==>  \
   444       "(\<lambda>x. typeof (PROP P (x))) \<equiv> (\<lambda>x. Type (TYPE(Null))) \<Longrightarrow>  \
   445     \    (typeof (!!x. PROP P (x))) == (Type (TYPE(Null)))",
   445     \    (typeof (\<And>x. PROP P (x))) \<equiv> (Type (TYPE(Null)))",
   446 
   446 
   447       "(%x. typeof (PROP P (x))) == (%x. Type (TYPE('P))) ==>  \
   447       "(\<lambda>x. typeof (PROP P (x))) \<equiv> (\<lambda>x. Type (TYPE('P))) \<Longrightarrow>  \
   448     \    (typeof (!!x::'a. PROP P (x))) == (Type (TYPE('a => 'P)))",
   448     \    (typeof (\<And>x::'a. PROP P (x))) \<equiv> (Type (TYPE('a \<Rightarrow> 'P)))",
   449 
   449 
   450       "(%x. typeof (f (x))) == (%x. Type (TYPE('f))) ==>  \
   450       "(\<lambda>x. typeof (f (x))) \<equiv> (\<lambda>x. Type (TYPE('f))) \<Longrightarrow>  \
   451     \    (typeof (f)) == (Type (TYPE('f)))"] #>
   451     \    (typeof (f)) \<equiv> (Type (TYPE('f)))"] #>
   452 
   452 
   453    add_realizes_eqns
   453    add_realizes_eqns
   454      ["(typeof (PROP P)) == (Type (TYPE(Null))) ==>  \
   454      ["(typeof (PROP P)) \<equiv> (Type (TYPE(Null))) \<Longrightarrow>  \
   455     \    (realizes (r) (PROP P ==> PROP Q)) ==  \
   455     \    (realizes (r) (PROP P \<Longrightarrow> PROP Q)) \<equiv>  \
   456     \    (PROP realizes (Null) (PROP P) ==> PROP realizes (r) (PROP Q))",
   456     \    (PROP realizes (Null) (PROP P) \<Longrightarrow> PROP realizes (r) (PROP Q))",
   457 
   457 
   458       "(typeof (PROP P)) == (Type (TYPE('P))) ==>  \
   458       "(typeof (PROP P)) \<equiv> (Type (TYPE('P))) \<Longrightarrow>  \
   459     \  (typeof (PROP Q)) == (Type (TYPE(Null))) ==>  \
   459     \  (typeof (PROP Q)) \<equiv> (Type (TYPE(Null))) \<Longrightarrow>  \
   460     \    (realizes (r) (PROP P ==> PROP Q)) ==  \
   460     \    (realizes (r) (PROP P \<Longrightarrow> PROP Q)) \<equiv>  \
   461     \    (!!x::'P. PROP realizes (x) (PROP P) ==> PROP realizes (Null) (PROP Q))",
   461     \    (\<And>x::'P. PROP realizes (x) (PROP P) \<Longrightarrow> PROP realizes (Null) (PROP Q))",
   462 
   462 
   463       "(realizes (r) (PROP P ==> PROP Q)) ==  \
   463       "(realizes (r) (PROP P \<Longrightarrow> PROP Q)) \<equiv>  \
   464     \  (!!x. PROP realizes (x) (PROP P) ==> PROP realizes (r (x)) (PROP Q))",
   464     \  (\<And>x. PROP realizes (x) (PROP P) \<Longrightarrow> PROP realizes (r (x)) (PROP Q))",
   465 
   465 
   466       "(%x. typeof (PROP P (x))) == (%x. Type (TYPE(Null))) ==>  \
   466       "(\<lambda>x. typeof (PROP P (x))) \<equiv> (\<lambda>x. Type (TYPE(Null))) \<Longrightarrow>  \
   467     \    (realizes (r) (!!x. PROP P (x))) ==  \
   467     \    (realizes (r) (\<And>x. PROP P (x))) \<equiv>  \
   468     \    (!!x. PROP realizes (Null) (PROP P (x)))",
   468     \    (\<And>x. PROP realizes (Null) (PROP P (x)))",
   469 
   469 
   470       "(realizes (r) (!!x. PROP P (x))) ==  \
   470       "(realizes (r) (\<And>x. PROP P (x))) \<equiv>  \
   471     \  (!!x. PROP realizes (r (x)) (PROP P (x)))"] #>
   471     \  (\<And>x. PROP realizes (r (x)) (PROP P (x)))"] #>
   472 
   472 
   473    Attrib.setup \<^binding>\<open>extraction_expand\<close> (Scan.succeed (extraction_expand false))
   473    Attrib.setup \<^binding>\<open>extraction_expand\<close> (Scan.succeed (extraction_expand false))
   474      "specify theorems to be expanded during extraction" #>
   474      "specify theorems to be expanded during extraction" #>
   475    Attrib.setup \<^binding>\<open>extraction_expand_def\<close> (Scan.succeed (extraction_expand true))
   475    Attrib.setup \<^binding>\<open>extraction_expand_def\<close> (Scan.succeed (extraction_expand true))
   476      "specify definitions to be expanded during extraction");
   476      "specify definitions to be expanded during extraction");