From 8541c7d0748d06676e5eb52d61cf468858d590e2 Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Sat, 7 Jul 2018 22:59:13 +0200 Subject: Methods added and organized! --- HoTT_Methods.thy | 87 ++++++++++++++++++++++++++------------------------------ 1 file changed, 40 insertions(+), 47 deletions(-) (limited to 'HoTT_Methods.thy') diff --git a/HoTT_Methods.thy b/HoTT_Methods.thy index 81e2055..1f11230 100644 --- a/HoTT_Methods.thy +++ b/HoTT_Methods.thy @@ -10,11 +10,28 @@ theory HoTT_Methods "HOL-Eisbach.Eisbach" "HOL-Eisbach.Eisbach_Tools" HoTT_Base - Prod begin -section \Method setup\ +text "The methods \simple\, \wellformed\, \derive\, and \simplify\ should together should suffice to automatically prove most HoTT theorems. +We also provide a method +" + + +section \Setup\ + +text "Import the \subst\ method, used by \simplify\." + +ML_file "~~/src/Tools/misc_legacy.ML" +ML_file "~~/src/Tools/IsaPlanner/isand.ML" +ML_file "~~/src/Tools/IsaPlanner/rw_inst.ML" +ML_file "~~/src/Tools/IsaPlanner/zipper.ML" +ML_file "~~/src/Tools/eqsubst.ML" + + +section \Method definitions\ + +subsection \Simple type rule proof search\ text "Prove type judgments \A : U\ and inhabitation judgments \a : A\ using rules declared [intro] and [elim], as well as additional provided lemmas. @@ -23,9 +40,11 @@ Can also perform typechecking, and search for elements of a type." method simple uses lems = (assumption | standard | rule lems)+ -text "Find a proof of any valid typing judgment derivable from a given wellformed judgment." +subsection \Wellformedness checker\ + +text "Find a proof of any valid typing judgment derivable from a given wellformed judgment. +The named theorem \wellform\ is declared in HoTT_Base.thy." -\ \\wellform\ is declared in HoTT_Base.thy\ method wellformed uses jdgmt declares wellform = match wellform in rl: "PROP ?P" \ \( catch \rule rl[OF jdgmt]\ \fail\ | @@ -33,11 +52,11 @@ method wellformed uses jdgmt declares wellform = )\ -text "Combine \simple\ and \wellformed\ to search for derivations. -\wellformed\ uses the facts passed as \lems\ to derive any required typing judgments. -Definitions passed as \unfolds\ are unfolded throughout. +subsection \Derivation search\ -Roughly speaking \derive\ is more powerful than \simple\, but may fail to find a proof where \simple\ does if it reduces too eagerly." +text "Combine \simple\ and \wellformed\ to search for derivations of judgments. +\wellformed\ uses the facts passed as \lems\ to derive any required typing judgments. +Definitions passed as \unfolds\ are unfolded throughout." method derive uses lems unfolds = ( unfold unfolds | @@ -46,45 +65,19 @@ method derive uses lems unfolds = ( )+ -text "Simplify a function application." - -method simplify for expr::Term uses lems = match (expr) in - "(\<^bold>\x:?A. ?b x)`?a" \ \ - print_term "Single application", - rule Prod_comp, - derive lems: lems - \ \ - "(F`a)`b" for F a b \ \ - print_term "Repeated application", - simplify "F`a" - \ - - - -text "Verify a function application simplification." - -method verify_simp uses lems = ( - print_term "Attempting simplification", - ( rule comp | derive lems: lems | simp add: lems )+ - | print_fact lems, - match conclusion in - "F`a`b \ x" for F a b x \ \ - print_term "Chained application", - print_term F, - print_term a, - print_term b, - print_term x, - match (F) in - "\<^bold>\x:A. f x" for A f \ \ - print_term "Matched abstraction", - print_fact Prod_comp[where ?A = A and ?b = f and ?a = a] - \ \ - "?x" \ \ - print_term "Constant application", - print_fact comp - \ - \ - ) +subsection \Simplification\ + +text "The methods \rsimplify\ and \simplify\ simplify lambda applications and attempt to solve definitional equations. + +\rsimplify\ can also be used to search for lambda expressions inhabiting given types. + +Since these methods use \derive\, it is often (but not always) the case that theorems provable with \derive\ are also provable with them. +(Whether this is the case depends on whether the call to \subst (0) comp\ fails.)" + +method rsimplify uses lems = (subst (0) comp, derive lems: lems)+ + \ \\subst\ performs an equational rewrite according to some computation rule declared as [comp], after which \derive\ attempts to solve any new assumptions that arise.\ + +method simplify uses lems = (simp add: lems | rsimplify lems: lems)+ end \ No newline at end of file -- cgit v1.2.3