diff --git a/.gitignore b/.gitignore index 33ea41d..5c0a968 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -/.build +/words/.build +/words/.mypy_cache +/words/.pytest_cache # Hypothesis example database. Could we move this to a new directory? -/.hypothesis +words/.hypothesis diff --git a/00-matching-logic.mm0 b/00-matching-logic.mm0 index d373b3d..ed7938e 100644 --- a/00-matching-logic.mm0 +++ b/00-matching-logic.mm0 @@ -32,6 +32,7 @@ notation ctxApp {box: SVar} (ctx: Pattern box) (psi: Pattern): Pattern = ($app[$:41) psi ($/$:0) box ($]$:0) ctx; -- Definitions of common logical connectives +infixl app: $@@$ prec 24; infixr imp: $->$ prec 24; def not (phi: Pattern): Pattern = $ phi -> bot $; prefix not: $~$ prec 41; diff --git a/01-propositional.mm1 b/01-propositional.mm1 index 814f8c7..6cb5897 100644 --- a/01-propositional.mm1 +++ b/01-propositional.mm1 @@ -6,7 +6,9 @@ do { (def dbg @ match-fn* [(x) (print x) x] [(x y) (display @ string-append (->string x) ": " (->string y)) y]) (def (foldl l z s) (if (null? l) z (foldl (tl l) (s z (hd l)) s))) + (def (foldli i l z s) (if (null? l) z (foldli {i + 1} (tl l) (s i z (hd l)) s))) (def (foldr l z s) (if (null? l) z (s (hd l) (foldr (tl l) z s)))) + (def (foldri i l z s) (if (null? l) z (s i (hd l) (foldri {i + 1} (tl l) z s)))) (def (range a b) (if {a = b} () (cons a (range {a + 1} b)))) (def (for a b f) (if {a = b} #undef (begin (f a) (for {a + 1} b f)))) (def last (match-fn [(a) a] [(_ . l) (last l)])) @@ -56,6 +58,10 @@ do { [_ (error "not a theorem")]) (def (pp-proof x) (display @ pp @ get-proof x)) + (def (get-def exp) @ match (get-decl exp) + [('def _ _ _ _ _ val) val] + [_ (error "not a definition")]) + --| This utility will take a verbatim proof and "unelaborate" it into a refine script --| using ! on every step. This is useful to get `refine` to re-typecheck a term when --| testing tactics which produce verbatim proofs. @@ -349,345 +355,352 @@ do { @ refine tgt (foldl ps (verb e) @ fn (acc p2) @ copy-span e '(mp ,acc ,p2))) }; -theorem a1i (h: $ b $): $ a -> b $ = '(prop_1 h); -theorem a2i (h: $ a -> b -> c $): $ (a -> b) -> (a -> c) $ = '(prop_2 h); -theorem mpd (h1: $ a -> b $) (h2: $ a -> b -> c $): $ a -> c $ = '(prop_2 h2 h1); -theorem mpi (h1: $ b $) (h2: $ a -> b -> c $): $ a -> c $ = '(mpd (a1i h1) h2); -theorem id: $ a -> a $ = '(mpd (! prop_1 _ a) prop_1); -theorem idd: $ a -> b -> b $ = '(a1i id); -theorem syl (h1: $ b -> c $) (h2: $ a -> b $): $ a -> c $ = '(mpd h2 (a1i h1)); -theorem rsyl (h1: $ a -> b $) (h2: $ b -> c $): $ a -> c $ = '(syl h2 h1); -theorem a1d (h: $ a -> b $): $ a -> c -> b $ = '(syl prop_1 h); -theorem a2d (h: $ a -> b -> c -> d $): $ a -> (b -> c) -> (b -> d) $ = '(syl prop_2 h); -theorem a3d (h: $ a -> ~b -> ~c $): $ a -> c -> b $ = '(syl prop_3 h); -theorem sylc (h: $ b -> c -> d $) (h1: $ a -> b $) (h2: $ a -> c $): $ a -> d $ = '(mpd h2 @ syl h h1); -theorem syld (h1: $ a -> b -> c $) (h2: $ a -> c -> d $): $ a -> b -> d $ = '(mpd h1 @ a2d @ a1d h2); -theorem syl5 (h1: $ b -> c $) (h2: $ a -> c -> d $): $ a -> b -> d $ = '(syld (a1i h1) h2); -theorem syl6 (h1: $ c -> d $) (h2: $ a -> b -> c $): $ a -> b -> d $ = '(syld h2 (a1i h1)); -theorem imim2: $ (b -> c) -> (a -> b) -> (a -> c) $ = '(a2d prop_1); -theorem imim2i (h: $ b -> c $): $ (a -> b) -> (a -> c) $ = '(imim2 h); -theorem imim2d (h: $ a -> c -> d $): $ a -> (b -> c) -> (b -> d) $ = '(syl imim2 h); -theorem absurd: $ ~a -> a -> b $ = '(a3d prop_1); -theorem com12 (h: $ a -> b -> c $): $ b -> a -> c $ = '(syl (a2i h) prop_1); -theorem mpcom: $ a -> (a -> b) -> b $ = '(com12 id); -theorem com23 (h: $ a -> b -> c -> d $): $ a -> c -> b -> d $ = '(syl (com12 @ imim2d mpcom) h); -theorem eimd (h1: $ a -> b $) (h2: $ a -> c -> d $): $ a -> (b -> c) -> d $ = '(syld (rsyl h1 mpcom) h2); -theorem absurdr: $ a -> ~a -> b $ = '(com12 absurd); -theorem imim1: $ (a -> b) -> (b -> c) -> (a -> c) $ = '(com12 imim2); -theorem imim1i (h: $ a -> b $): $ (b -> c) -> (a -> c) $ = '(imim1 h); -theorem imim1d (h: $ a -> b -> c $): $ a -> (c -> d) -> (b -> d) $ = '(syl imim1 h); -theorem imimd (h1: $ a -> b -> c $) (h2: $ a -> d -> e $): - $ a -> (c -> d) -> (b -> e) $ = '(syld (imim1d h1) (imim2d h2)); -theorem imim: $ (a -> b) -> (c -> d) -> (b -> c) -> (a -> d) $ = '(syl5 imim2 (imim2d imim1)); -theorem imidm: $ (a -> a -> b) -> a -> b $ = '(a2i mpcom); -theorem eim: $ a -> (b -> c) -> (a -> b) -> c $ = '(imim1d mpcom); -theorem contra: $ (~a -> a) -> a $ = '(imidm (a3d (a2i absurd))); -theorem dne: $ ~~a -> a $ = '(syl contra absurd); -theorem inot: $ (a -> ~a) -> ~a $ = '(syl contra (imim1 dne)); -theorem con2: $ (a -> ~b) -> (b -> ~a) $ = '(a3d (syl5 dne id)); -theorem notnot1: $ a -> ~~a $ = '(con2 id); -theorem con3: $ (a -> b) -> (~b -> ~a) $ = '(syl con2 (imim2i notnot1)); -theorem con1: $ (~a -> b) -> (~b -> a) $ = '(a3d (imim2i notnot1)); -theorem cases (h1: $ a -> b $) (h2: $ ~a -> b $): $ b $ = '(contra @ syl h1 @ con1 h2); -theorem casesd (h1: $ a -> b -> c $) (h2: $ a -> ~b -> c $): $ a -> c $ = +theorem a1i (h: $ bb $): $ aa -> bb $ = '(prop_1 h); +theorem a2i (h: $ aa -> bb -> c $): $ (aa -> bb) -> (aa -> c) $ = '(prop_2 h); +theorem mpd (h1: $ aa -> bb $) (h2: $ aa -> bb -> c $): $ aa -> c $ = '(prop_2 h2 h1); +theorem mpi (h1: $ bb $) (h2: $ aa -> bb -> c $): $ aa -> c $ = '(mpd (a1i h1) h2); +theorem id: $ aa -> aa $ = '(mpd (! prop_1 _ aa) prop_1); +theorem idd: $ aa -> bb -> bb $ = '(a1i id); +theorem syl (h1: $ bb -> c $) (h2: $ aa -> bb $): $ aa -> c $ = '(mpd h2 (a1i h1)); +theorem rsyl (h1: $ aa -> bb $) (h2: $ bb -> c $): $ aa -> c $ = '(syl h2 h1); +theorem a1d (h: $ aa -> bb $): $ aa -> c -> bb $ = '(syl prop_1 h); +theorem a2d (h: $ aa -> bb -> c -> d $): $ aa -> (bb -> c) -> (bb -> d) $ = '(syl prop_2 h); +theorem a3d (h: $ aa -> ~bb -> ~c $): $ aa -> c -> bb $ = '(syl prop_3 h); +theorem sylc (h: $ bb -> c -> d $) (h1: $ aa -> bb $) (h2: $ aa -> c $): $ aa -> d $ = '(mpd h2 @ syl h h1); +theorem syld (h1: $ aa -> bb -> c $) (h2: $ aa -> c -> d $): $ aa -> bb -> d $ = '(mpd h1 @ a2d @ a1d h2); +theorem syl5 (h1: $ bb -> c $) (h2: $ aa -> c -> d $): $ aa -> bb -> d $ = '(syld (a1i h1) h2); +theorem syl6 (h1: $ c -> d $) (h2: $ aa -> bb -> c $): $ aa -> bb -> d $ = '(syld h2 (a1i h1)); +theorem imim2: $ (bb -> c) -> (aa -> bb) -> (aa -> c) $ = '(a2d prop_1); +theorem imim2i (h: $ bb -> c $): $ (aa -> bb) -> (aa -> c) $ = '(imim2 h); +theorem imim2d (h: $ aa -> c -> d $): $ aa -> (bb -> c) -> (bb -> d) $ = '(syl imim2 h); +theorem absurd: $ ~aa -> aa -> bb $ = '(a3d prop_1); +theorem com12 (h: $ aa -> bb -> c $): $ bb -> aa -> c $ = '(syl (a2i h) prop_1); +theorem mpcom: $ aa -> (aa -> bb) -> bb $ = '(com12 id); +theorem com23 (h: $ aa -> bb -> c -> d $): $ aa -> c -> bb -> d $ = '(syl (com12 @ imim2d mpcom) h); +theorem eimd (h1: $ aa -> bb $) (h2: $ aa -> c -> d $): $ aa -> (bb -> c) -> d $ = '(syld (rsyl h1 mpcom) h2); +theorem absurdr: $ aa -> ~aa -> bb $ = '(com12 absurd); +theorem imim1: $ (aa -> bb) -> (bb -> c) -> (aa -> c) $ = '(com12 imim2); +theorem imim1i (h: $ aa -> bb $): $ (bb -> c) -> (aa -> c) $ = '(imim1 h); +theorem imim1d (h: $ aa -> bb -> c $): $ aa -> (c -> d) -> (bb -> d) $ = '(syl imim1 h); +theorem imimd (h1: $ aa -> bb -> c $) (h2: $ aa -> d -> e $): + $ aa -> (c -> d) -> (bb -> e) $ = '(syld (imim1d h1) (imim2d h2)); +theorem imim: $ (aa -> bb) -> (c -> d) -> (bb -> c) -> (aa -> d) $ = '(syl5 imim2 (imim2d imim1)); +theorem imidm: $ (aa -> aa -> bb) -> aa -> bb $ = '(a2i mpcom); +theorem eim: $ aa -> (bb -> c) -> (aa -> bb) -> c $ = '(imim1d mpcom); +theorem contra: $ (~aa -> aa) -> aa $ = '(imidm (a3d (a2i absurd))); +theorem dne: $ ~~aa -> aa $ = '(syl contra absurd); +theorem inot: $ (aa -> ~aa) -> ~aa $ = '(syl contra (imim1 dne)); +theorem con2: $ (aa -> ~bb) -> (bb -> ~aa) $ = '(a3d (syl5 dne id)); +theorem notnot1: $ aa -> ~~aa $ = '(con2 id); +theorem con3: $ (aa -> bb) -> (~bb -> ~aa) $ = '(syl con2 (imim2i notnot1)); +theorem con1: $ (~aa -> bb) -> (~bb -> aa) $ = '(a3d (imim2i notnot1)); +theorem con4: $ (~aa -> ~bb) -> (bb -> aa) $ = '(syl (imim1 notnot1) con1); +theorem cases (h1: $ aa -> bb $) (h2: $ ~aa -> bb $): $ bb $ = '(contra @ syl h1 @ con1 h2); +theorem casesd (h1: $ aa -> bb -> c $) (h2: $ aa -> ~bb -> c $): $ aa -> c $ = '(cases (com12 h1) (com12 h2)); -theorem con1d (h: $ a -> ~b -> c $): $ a -> ~c -> b $ = '(syl con1 h); -theorem con2d (h: $ a -> b -> ~c $): $ a -> c -> ~b $ = '(syl con2 h); -theorem con3d (h: $ a -> b -> c $): $ a -> ~c -> ~b $ = '(syl con3 h); -theorem con4d (h: $ a -> ~b -> ~c $): $ a -> c -> b $ = '(syl prop_3 h); -theorem mt (h1: $ b -> a $) (h2: $ ~a $): $ ~b $ = '(con3 h1 h2); -theorem mt2 (h1: $ b -> ~a $) (h2: $ a $): $ ~b $ = '(con2 h1 h2); -theorem mtd (h1: $ a -> ~b $) (h2: $ a -> c -> b $): $ a -> ~c $ = '(mpd h1 (con3d h2)); -theorem mti (h1: $ ~b $) (h2: $ a -> c -> b $): $ a -> ~c $ = '(mtd (a1i h1) h2); -theorem mt2d (h1: $ a -> c $) (h2: $ a -> b -> ~c $): $ a -> ~b $ = '(sylc con2 h2 h1); - -theorem anl: $ a /\ b -> a $ = '(con1 absurd); -theorem anr: $ a /\ b -> b $ = '(con1 prop_1); -theorem anli (h: $ a /\ b $): $ a $ = '(anl h); -theorem anri (h: $ a /\ b $): $ b $ = '(anr h); -theorem ian: $ a -> b -> a /\ b $ = '(con2d mpcom); -theorem iand (h1: $ a -> b $) (h2: $ a -> c $): $ a -> b /\ c $ = '(sylc ian h1 h2); -theorem anld (h: $ a -> b /\ c $): $ a -> b $ = '(syl anl h); -theorem anrd (h: $ a -> b /\ c $): $ a -> c $ = '(syl anr h); -theorem iani (h1: $ a $) (h2: $ b $): $ a /\ b $ = '(ian h1 h2); -theorem anwl (h: $ a -> c $): $ a /\ b -> c $ = '(syl h anl); -theorem anwr (h: $ b -> c $): $ a /\ b -> c $ = '(syl h anr); -theorem anll: $ a /\ b /\ c -> a $ = '(anwl anl); -theorem anlr: $ a /\ b /\ c -> b $ = '(anwl anr); -theorem anrl: $ a /\ (b /\ c) -> b $ = '(anwr anl); -theorem anrr: $ a /\ (b /\ c) -> c $ = '(anwr anr); -theorem anwll (h: $ a -> d $): $ a /\ b /\ c -> d $ = '(anwl (anwl h)); -theorem anw3l (h: $ a -> e $): $ a /\ b /\ c /\ d -> e $ = '(anwll (anwl h)); -theorem anw4l (h: $ a -> f $): $ a /\ b /\ c /\ d /\ e -> f $ = '(anw3l (anwl h)); -theorem anw5l (h: $ a -> g $): $ a /\ b /\ c /\ d /\ e /\ f -> g $ = '(anw4l (anwl h)); -theorem anw6l (x: $ a -> h $): $ a /\ b /\ c /\ d /\ e /\ f /\ g -> h $ = '(anw5l (anwl x)); -theorem anw7l (x: $ a -> i $): $ a /\ b /\ c /\ d /\ e /\ f /\ g /\ h -> i $ = '(anw6l (anwl x)); -theorem anllr: $ a /\ b /\ c /\ d -> b $ = '(anwll anr); -theorem an3l: $ a /\ b /\ c /\ d -> a $ = '(anwll anl); -theorem an3lr: $ a /\ b /\ c /\ d /\ e -> b $ = '(anwl anllr); -theorem an4l: $ a /\ b /\ c /\ d /\ e -> a $ = '(anwl an3l); -- TODO: automate these -theorem an4lr: $ a /\ b /\ c /\ d /\ e /\ f -> b $ = '(anwl an3lr); -theorem an5l: $ a /\ b /\ c /\ d /\ e /\ f -> a $ = '(anwl an4l); -theorem an5lr: $ a /\ b /\ c /\ d /\ e /\ f /\ g -> b $ = '(anwl an4lr); -theorem an6l: $ a /\ b /\ c /\ d /\ e /\ f /\ g -> a $ = '(anwl an5l); -theorem an6lr: $ a /\ b /\ c /\ d /\ e /\ f /\ g /\ h -> b $ = '(anwl an5lr); -theorem curry (h: $ a -> b -> c $): $ a /\ b -> c $ = '(sylc h anl anr); -theorem exp (h: $ a /\ b -> c $): $ a -> b -> c $ = '(syl6 h ian); -theorem impcom (h: $ a -> b -> c $): $ b /\ a -> c $ = '(curry (com12 h)); -theorem expcom (h: $ a /\ b -> c $): $ b -> a -> c $ = '(com12 (exp h)); -theorem syla (h1: $ (b -> c) -> d $) (h2: $ a /\ b -> c $): $ a -> d $ = '(syl h1 @ exp h2); -theorem sylan (h: $ b /\ c -> d $) (h1: $ a -> b $) (h2: $ a -> c $): - $ a -> d $ = '(syl h @ iand h1 h2); -theorem animd (h1: $ a -> b -> c $) (h2: $ a -> d -> e $): $ a -> b /\ d -> c /\ e $ = +theorem con1d (h: $ aa -> ~bb -> c $): $ aa -> ~c -> bb $ = '(syl con1 h); +theorem con2d (h: $ aa -> bb -> ~c $): $ aa -> c -> ~bb $ = '(syl con2 h); +theorem con3d (h: $ aa -> bb -> c $): $ aa -> ~c -> ~bb $ = '(syl con3 h); +theorem con4d (h: $ aa -> ~bb -> ~c $): $ aa -> c -> bb $ = '(syl prop_3 h); +theorem mt (h1: $ bb -> aa $) (h2: $ ~aa $): $ ~bb $ = '(con3 h1 h2); +theorem mt2 (h1: $ bb -> ~aa $) (h2: $ aa $): $ ~bb $ = '(con2 h1 h2); +theorem mtd (h1: $ aa -> ~bb $) (h2: $ aa -> c -> bb $): $ aa -> ~c $ = '(mpd h1 (con3d h2)); +theorem mti (h1: $ ~bb $) (h2: $ aa -> c -> bb $): $ aa -> ~c $ = '(mtd (a1i h1) h2); +theorem mt2d (h1: $ aa -> c $) (h2: $ aa -> bb -> ~c $): $ aa -> ~bb $ = '(sylc con2 h2 h1); + +theorem anl: $ aa /\ bb -> aa $ = '(con1 absurd); +theorem anr: $ aa /\ bb -> bb $ = '(con1 prop_1); +theorem anli (h: $ aa /\ bb $): $ aa $ = '(anl h); +theorem anri (h: $ aa /\ bb $): $ bb $ = '(anr h); +theorem ian: $ aa -> bb -> aa /\ bb $ = '(con2d mpcom); +theorem iand (h1: $ aa -> bb $) (h2: $ aa -> c $): $ aa -> bb /\ c $ = '(sylc ian h1 h2); +theorem anld (h: $ aa -> bb /\ c $): $ aa -> bb $ = '(syl anl h); +theorem anrd (h: $ aa -> bb /\ c $): $ aa -> c $ = '(syl anr h); +theorem iani (h1: $ aa $) (h2: $ bb $): $ aa /\ bb $ = '(ian h1 h2); +theorem anwl (h: $ aa -> c $): $ aa /\ bb -> c $ = '(syl h anl); +theorem anwr (h: $ bb -> c $): $ aa /\ bb -> c $ = '(syl h anr); +theorem anll: $ aa /\ bb /\ c -> aa $ = '(anwl anl); +theorem anlr: $ aa /\ bb /\ c -> bb $ = '(anwl anr); +theorem anrl: $ aa /\ (bb /\ c) -> bb $ = '(anwr anl); +theorem anrr: $ aa /\ (bb /\ c) -> c $ = '(anwr anr); +theorem anwll (h: $ aa -> d $): $ aa /\ bb /\ c -> d $ = '(anwl (anwl h)); +theorem anw3l (h: $ aa -> e $): $ aa /\ bb /\ c /\ d -> e $ = '(anwll (anwl h)); +theorem anw4l (h: $ aa -> f $): $ aa /\ bb /\ c /\ d /\ e -> f $ = '(anw3l (anwl h)); +theorem anw5l (h: $ aa -> g $): $ aa /\ bb /\ c /\ d /\ e /\ f -> g $ = '(anw4l (anwl h)); +theorem anw6l (x: $ aa -> h $): $ aa /\ bb /\ c /\ d /\ e /\ f /\ g -> h $ = '(anw5l (anwl x)); +theorem anw7l (x: $ aa -> i $): $ aa /\ bb /\ c /\ d /\ e /\ f /\ g /\ h -> i $ = '(anw6l (anwl x)); +theorem anllr: $ aa /\ bb /\ c /\ d -> bb $ = '(anwll anr); +theorem an3l: $ aa /\ bb /\ c /\ d -> aa $ = '(anwll anl); +theorem an3lr: $ aa /\ bb /\ c /\ d /\ e -> bb $ = '(anwl anllr); +theorem an4l: $ aa /\ bb /\ c /\ d /\ e -> aa $ = '(anwl an3l); -- TODO: automate these +theorem an4lr: $ aa /\ bb /\ c /\ d /\ e /\ f -> bb $ = '(anwl an3lr); +theorem an5l: $ aa /\ bb /\ c /\ d /\ e /\ f -> aa $ = '(anwl an4l); +theorem an5lr: $ aa /\ bb /\ c /\ d /\ e /\ f /\ g -> bb $ = '(anwl an4lr); +theorem an6l: $ aa /\ bb /\ c /\ d /\ e /\ f /\ g -> aa $ = '(anwl an5l); +theorem an6lr: $ aa /\ bb /\ c /\ d /\ e /\ f /\ g /\ h -> bb $ = '(anwl an5lr); +theorem an7l: $ aa /\ bb /\ c /\ d /\ e /\ f /\ g /\ h -> aa $ = '(anwl an6l); +theorem an7lr: $ aa /\ bb /\ c /\ d /\ e /\ f /\ g /\ h /\ i -> bb $ = '(anwl an6lr); +theorem an8l: $ aa /\ bb /\ c /\ d /\ e /\ f /\ g /\ h /\ i -> aa $ = '(anwl an7l); +theorem an8lr: $ aa /\ bb /\ c /\ d /\ e /\ f /\ g /\ h /\ i /\ j -> bb $ = '(anwl an7lr); +theorem an9l: $ aa /\ bb /\ c /\ d /\ e /\ f /\ g /\ h /\ i /\ j -> aa $ = '(anwl an8l); +theorem an9lr: $ aa /\ bb /\ c /\ d /\ e /\ f /\ g /\ h /\ i /\ j /\ k -> bb $ = '(anwl an8lr); +theorem curry (h: $ aa -> bb -> c $): $ aa /\ bb -> c $ = '(sylc h anl anr); +theorem exp (h: $ aa /\ bb -> c $): $ aa -> bb -> c $ = '(syl6 h ian); +theorem impcom (h: $ aa -> bb -> c $): $ bb /\ aa -> c $ = '(curry (com12 h)); +theorem expcom (h: $ aa /\ bb -> c $): $ bb -> aa -> c $ = '(com12 (exp h)); +theorem syla (h1: $ (bb -> c) -> d $) (h2: $ aa /\ bb -> c $): $ aa -> d $ = '(syl h1 @ exp h2); +theorem sylan (h: $ bb /\ c -> d $) (h1: $ aa -> bb $) (h2: $ aa -> c $): + $ aa -> d $ = '(syl h @ iand h1 h2); +theorem animd (h1: $ aa -> bb -> c $) (h2: $ aa -> d -> e $): $ aa -> bb /\ d -> c /\ e $ = '(exp (iand (curry (syl5 anl h1)) (curry (syl5 anr h2)))); -theorem anim1d (h: $ a -> b -> c $): $ a -> b /\ d -> c /\ d $ = '(animd h idd); -theorem anim2d (h: $ a -> c -> d $): $ a -> b /\ c -> b /\ d $ = '(animd idd h); -theorem anim1: $ (a -> b) -> a /\ c -> b /\ c $ = '(anim1d id); -theorem anim2: $ (b -> c) -> a /\ b -> a /\ c $ = '(anim2d id); -theorem anim: $ (a -> b) -> (c -> d) -> a /\ c -> b /\ d $ = +theorem anim1d (h: $ aa -> bb -> c $): $ aa -> bb /\ d -> c /\ d $ = '(animd h idd); +theorem anim2d (h: $ aa -> c -> d $): $ aa -> bb /\ c -> bb /\ d $ = '(animd idd h); +theorem anim1: $ (aa -> bb) -> aa /\ c -> bb /\ c $ = '(anim1d id); +theorem anim2: $ (bb -> c) -> aa /\ bb -> aa /\ c $ = '(anim2d id); +theorem anim: $ (aa -> bb) -> (c -> d) -> aa /\ c -> bb /\ d $ = '(exp @ syld (anim1d anl) (anim2d anr)); -theorem anim2a: $ (a -> b -> c) -> (a /\ b -> a /\ c) $ = +theorem anim2a: $ (aa -> bb -> c) -> (aa /\ bb -> aa /\ c) $ = '(exp @ iand anrl @ mpd anrr @ mpd anrl anl); -theorem ancom: $ a /\ b -> b /\ a $ = '(iand anr anl); -theorem anrasss (h: $ a /\ b /\ c -> d $): $ a /\ c /\ b -> d $ = +theorem ancom: $ aa /\ bb -> bb /\ aa $ = '(iand anr anl); +theorem anrasss (h: $ aa /\ bb /\ c -> d $): $ aa /\ c /\ bb -> d $ = '(sylan h (iand anll anr) anlr); -theorem anim1a: $ (a -> b -> c) -> (b /\ a -> c /\ a) $ = +theorem anim1a: $ (aa -> bb -> c) -> (bb /\ aa -> c /\ aa) $ = '(syl6 ancom @ syl5 ancom anim2a); -theorem casesda (h1: $ a /\ b -> c $) (h2: $ a /\ ~b -> c $): $ a -> c $ = +theorem casesda (h1: $ aa /\ bb -> c $) (h2: $ aa /\ ~bb -> c $): $ aa -> c $ = '(casesd (exp h1) (exp h2)); -theorem inotda (h: $ a /\ b -> ~b $): $ a -> ~b $ = '(syla inot h); -theorem mpand (h1: $ a -> b $) (h2: $ a /\ b -> c $): $ a -> c $ = '(mpd h1 (exp h2)); -theorem mtand (h1: $ a -> ~b $) (h2: $ a /\ c -> b $): $ a -> ~c $ = '(mtd h1 (exp h2)); -theorem mtani (h1: $ ~b $) (h2: $ a /\ c -> b $): $ a -> ~c $ = '(mtand (a1i h1) h2); - -theorem bi1: $ (a <-> b) -> a -> b $ = 'anl; -theorem bi1i (h: $ a <-> b $): $ a -> b $ = '(bi1 h); -theorem bi1d (h: $ a -> (b <-> c) $): $ a -> b -> c $ = '(syl bi1 h); -theorem bi1a (h: $ a -> (b <-> c) $): $ a /\ b -> c $ = '(curry @ bi1d h); -theorem bi2: $ (a <-> b) -> b -> a $ = 'anr; -theorem bi2i (h: $ a <-> b $): $ b -> a $ = '(bi2 h); -theorem bi2d (h: $ a -> (b <-> c) $): $ a -> c -> b $ = '(syl bi2 h); -theorem bi2a (h: $ a -> (b <-> c) $): $ a /\ c -> b $ = '(curry @ bi2d h); -theorem ibii (h1: $ a -> b $) (h2: $ b -> a $): $ a <-> b $ = '(iani h1 h2); -theorem ibid (h1: $ a -> b -> c $) (h2: $ a -> c -> b $): $ a -> (b <-> c) $ = '(iand h1 h2); -theorem ibida (h1: $ a /\ b -> c $) (h2: $ a /\ c -> b $): $ a -> (b <-> c) $ = '(ibid (exp h1) (exp h2)); -theorem biid: $ a <-> a $ = '(ibii id id); -theorem biidd: $ a -> (b <-> b) $ = '(a1i biid); -theorem mpbi (h1: $ a <-> b $) (h2: $ a $): $ b $ = '(bi1i h1 h2); -theorem mpbir (h1: $ b <-> a $) (h2: $ a $): $ b $ = '(bi2i h1 h2); -theorem mpbid (h1: $ a -> (b <-> c) $) (h2: $ a -> b $): $ a -> c $ = '(mpd h2 (bi1d h1)); -theorem mpbird (h1: $ a -> (c <-> b) $) (h2: $ a -> b $): $ a -> c $ = '(mpd h2 (bi2d h1)); -theorem mpbii (h1: $ b $) (h2: $ a -> (b <-> c) $): $ a -> c $ = '(mpbid h2 (a1i h1)); -theorem mpbiri (h1: $ b $) (h2: $ a -> (c <-> b) $): $ a -> c $ = '(mpbird h2 (a1i h1)); -theorem mtbi (h1: $ a <-> b $) (h2: $ ~a $): $ ~b $ = '(mt (bi2 h1) h2); -theorem mtbir (h1: $ b <-> a $) (h2: $ ~a $): $ ~b $ = '(mt (bi1 h1) h2); -theorem mtbid (h1: $ a -> (b <-> c) $) (h2: $ a -> ~b $): $ a -> ~c $ = '(mtd h2 (bi2d h1)); -theorem mtbird (h1: $ a -> (c <-> b) $) (h2: $ a -> ~b $): $ a -> ~c $ = '(mtd h2 (bi1d h1)); -theorem con1b: $ (~a <-> b) -> (~b <-> a) $ = '(ibid (con1d bi1) (con2d bi2)); -theorem con2b: $ (a <-> ~b) -> (b <-> ~a) $ = '(ibid (con2d bi1) (con1d bi2)); -theorem con3b: $ (a <-> b) -> (~a <-> ~b) $ = '(ibid (con3d bi2) (con3d bi1)); -theorem con4b: $ (~a <-> ~b) -> (a <-> b) $ = '(ibid (con4d bi2) (con4d bi1)); -theorem con1bb: $ (~a <-> b) <-> (~b <-> a) $ = '(ibii con1b con1b); -theorem con2bb: $ (a <-> ~b) <-> (b <-> ~a) $ = '(ibii con2b con2b); -theorem con3bb: $ (a <-> b) <-> (~a <-> ~b) $ = '(ibii con3b con4b); -theorem con1bi: $ (~a -> b) <-> (~b -> a) $ = '(ibii con1 con1); -theorem con2bi: $ (a -> ~b) <-> (b -> ~a) $ = '(ibii con2 con2); -theorem con3bi: $ (a -> b) <-> (~b -> ~a) $ = '(ibii con3 prop_3); -theorem notnot: $ a <-> ~~a $ = '(ibii notnot1 dne); -theorem bithd (h1: $ a -> b $) (h2: $ a -> c $): $ a -> (b <-> c) $ = '(ibid (a1d h2) (a1d h1)); -theorem binthd (h1: $ a -> ~b $) (h2: $ a -> ~c $): $ a -> (b <-> c) $ = '(syl con4b @ bithd h1 h2); -theorem bith: $ a -> b -> (a <-> b) $ = '(exp @ bithd anl anr); -theorem binth: $ ~a -> ~b -> (a <-> b) $ = '(exp @ binthd anl anr); -theorem bicom: $ (a <-> b) -> (b <-> a) $ = '(ibid bi2 bi1); -theorem bicomb: $ (a <-> b) <-> (b <-> a) $ = '(ibii bicom bicom); -theorem bicomd (h: $ a -> (b <-> c) $): $ a -> (c <-> b) $ = '(syl bicom h); -theorem bitrd (h1: $ a -> (b <-> c) $) (h2: $ a -> (c <-> d) $): $ a -> (b <-> d) $ = +theorem inotda (h: $ aa /\ bb -> ~bb $): $ aa -> ~bb $ = '(syla inot h); +theorem mpand (h1: $ aa -> bb $) (h2: $ aa /\ bb -> c $): $ aa -> c $ = '(mpd h1 (exp h2)); +theorem mtand (h1: $ aa -> ~bb $) (h2: $ aa /\ c -> bb $): $ aa -> ~c $ = '(mtd h1 (exp h2)); +theorem mtani (h1: $ ~bb $) (h2: $ aa /\ c -> bb $): $ aa -> ~c $ = '(mtand (a1i h1) h2); + +theorem bi1: $ (aa <-> bb) -> aa -> bb $ = 'anl; +theorem bi1i (h: $ aa <-> bb $): $ aa -> bb $ = '(bi1 h); +theorem bi1d (h: $ aa -> (bb <-> c) $): $ aa -> bb -> c $ = '(syl bi1 h); +theorem bi1a (h: $ aa -> (bb <-> c) $): $ aa /\ bb -> c $ = '(curry @ bi1d h); +theorem bi2: $ (aa <-> bb) -> bb -> aa $ = 'anr; +theorem bi2i (h: $ aa <-> bb $): $ bb -> aa $ = '(bi2 h); +theorem bi2d (h: $ aa -> (bb <-> c) $): $ aa -> c -> bb $ = '(syl bi2 h); +theorem bi2a (h: $ aa -> (bb <-> c) $): $ aa /\ c -> bb $ = '(curry @ bi2d h); +theorem ibii (h1: $ aa -> bb $) (h2: $ bb -> aa $): $ aa <-> bb $ = '(iani h1 h2); +theorem ibid (h1: $ aa -> bb -> c $) (h2: $ aa -> c -> bb $): $ aa -> (bb <-> c) $ = '(iand h1 h2); +theorem ibida (h1: $ aa /\ bb -> c $) (h2: $ aa /\ c -> bb $): $ aa -> (bb <-> c) $ = '(ibid (exp h1) (exp h2)); +theorem biid: $ aa <-> aa $ = '(ibii id id); +theorem biidd: $ aa -> (bb <-> bb) $ = '(a1i biid); +theorem mpbi (h1: $ aa <-> bb $) (h2: $ aa $): $ bb $ = '(bi1i h1 h2); +theorem mpbir (h1: $ bb <-> aa $) (h2: $ aa $): $ bb $ = '(bi2i h1 h2); +theorem mpbid (h1: $ aa -> (bb <-> c) $) (h2: $ aa -> bb $): $ aa -> c $ = '(mpd h2 (bi1d h1)); +theorem mpbird (h1: $ aa -> (c <-> bb) $) (h2: $ aa -> bb $): $ aa -> c $ = '(mpd h2 (bi2d h1)); +theorem mpbii (h1: $ bb $) (h2: $ aa -> (bb <-> c) $): $ aa -> c $ = '(mpbid h2 (a1i h1)); +theorem mpbiri (h1: $ bb $) (h2: $ aa -> (c <-> bb) $): $ aa -> c $ = '(mpbird h2 (a1i h1)); +theorem mtbi (h1: $ aa <-> bb $) (h2: $ ~aa $): $ ~bb $ = '(mt (bi2 h1) h2); +theorem mtbir (h1: $ bb <-> aa $) (h2: $ ~aa $): $ ~bb $ = '(mt (bi1 h1) h2); +theorem mtbid (h1: $ aa -> (bb <-> c) $) (h2: $ aa -> ~bb $): $ aa -> ~c $ = '(mtd h2 (bi2d h1)); +theorem mtbird (h1: $ aa -> (c <-> bb) $) (h2: $ aa -> ~bb $): $ aa -> ~c $ = '(mtd h2 (bi1d h1)); +theorem con1b: $ (~aa <-> bb) -> (~bb <-> aa) $ = '(ibid (con1d bi1) (con2d bi2)); +theorem con2b: $ (aa <-> ~bb) -> (bb <-> ~aa) $ = '(ibid (con2d bi1) (con1d bi2)); +theorem con3b: $ (aa <-> bb) -> (~aa <-> ~bb) $ = '(ibid (con3d bi2) (con3d bi1)); +theorem con4b: $ (~aa <-> ~bb) -> (aa <-> bb) $ = '(ibid (con4d bi2) (con4d bi1)); +theorem con1bb: $ (~aa <-> bb) <-> (~bb <-> aa) $ = '(ibii con1b con1b); +theorem con2bb: $ (aa <-> ~bb) <-> (bb <-> ~aa) $ = '(ibii con2b con2b); +theorem con3bb: $ (aa <-> bb) <-> (~aa <-> ~bb) $ = '(ibii con3b con4b); +theorem con1bi: $ (~aa -> bb) <-> (~bb -> aa) $ = '(ibii con1 con1); +theorem con2bi: $ (aa -> ~bb) <-> (bb -> ~aa) $ = '(ibii con2 con2); +theorem con3bi: $ (aa -> bb) <-> (~bb -> ~aa) $ = '(ibii con3 prop_3); +theorem notnot: $ aa <-> ~~aa $ = '(ibii notnot1 dne); +theorem bithd (h1: $ aa -> bb $) (h2: $ aa -> c $): $ aa -> (bb <-> c) $ = '(ibid (a1d h2) (a1d h1)); +theorem binthd (h1: $ aa -> ~bb $) (h2: $ aa -> ~c $): $ aa -> (bb <-> c) $ = '(syl con4b @ bithd h1 h2); +theorem bith: $ aa -> bb -> (aa <-> bb) $ = '(exp @ bithd anl anr); +theorem binth: $ ~aa -> ~bb -> (aa <-> bb) $ = '(exp @ binthd anl anr); +theorem bicom: $ (aa <-> bb) -> (bb <-> aa) $ = '(ibid bi2 bi1); +theorem bicomb: $ (aa <-> bb) <-> (bb <-> aa) $ = '(ibii bicom bicom); +theorem bicomd (h: $ aa -> (bb <-> c) $): $ aa -> (c <-> bb) $ = '(syl bicom h); +theorem bitrd (h1: $ aa -> (bb <-> c) $) (h2: $ aa -> (c <-> d) $): $ aa -> (bb <-> d) $ = '(ibid (syld (bi1d h1) (bi1d h2)) (syld (bi2d h2) (bi2d h1))); -theorem bitr2d (h1: $ a -> (b <-> c) $) (h2: $ a -> (c <-> d) $): $ a -> (d <-> b) $ = '(bicomd (bitrd h1 h2)); -theorem bitr3d (h1: $ a -> (c <-> b) $) (h2: $ a -> (c <-> d) $): $ a -> (b <-> d) $ = '(bitrd (bicomd h1) h2); -theorem bitr4d (h1: $ a -> (b <-> c) $) (h2: $ a -> (d <-> c) $): $ a -> (b <-> d) $ = '(bitrd h1 (bicomd h2)); -theorem bitr: $ (a <-> b) -> (b <-> c) -> (a <-> c) $ = '(exp (bitrd anl anr)); -theorem bitr2: $ (a <-> b) -> (b <-> c) -> (c <-> a) $ = '(exp (bitr2d anl anr)); -theorem bitr3: $ (b <-> a) -> (b <-> c) -> (a <-> c) $ = '(exp (bitr3d anl anr)); -theorem bitr4: $ (a <-> b) -> (c <-> b) -> (a <-> c) $ = '(exp (bitr4d anl anr)); -theorem bisylr: $ (c <-> b) -> (a <-> b) -> (a <-> c) $ = '(rsyl bicom @ com23 id bitr); -theorem sylib (h1: $ b <-> c $) (h2: $ a -> b $): $ a -> c $ = '(syl (bi1i h1) h2); -theorem sylibr (h1: $ c <-> b $) (h2: $ a -> b $): $ a -> c $ = '(syl (bi2i h1) h2); -theorem sylbi (h1: $ a <-> b $) (h2: $ b -> c $): $ a -> c $ = '(syl h2 (bi1i h1)); -theorem sylbir (h1: $ b <-> a $) (h2: $ b -> c $): $ a -> c $ = '(syl h2 (bi2i h1)); -theorem syl5bb (h1: $ b <-> c $) (h2: $ a -> (c <-> d) $): $ a -> (b <-> d) $ = '(bitrd (a1i h1) h2); -theorem syl5bbr (h1: $ c <-> b $) (h2: $ a -> (c <-> d) $): $ a -> (b <-> d) $ = '(syl5bb (bicom h1) h2); -theorem syl6bb (h1: $ c <-> d $) (h2: $ a -> (b <-> c) $): $ a -> (b <-> d) $ = '(bitrd h2 (a1i h1)); -theorem syl6bbr (h1: $ d <-> c $) (h2: $ a -> (b <-> c) $): $ a -> (b <-> d) $ = '(syl6bb (bicom h1) h2); -theorem syl5bi (h1: $ b <-> c $) (h2: $ a -> c -> d $): $ a -> b -> d $ = '(syl5 (bi1 h1) h2); -theorem syl5bir (h1: $ c <-> b $) (h2: $ a -> c -> d $): $ a -> b -> d $ = '(syl5bi (bicom h1) h2); -theorem syl6ib (h1: $ c <-> d $) (h2: $ a -> b -> c $): $ a -> b -> d $ = '(syl6 (bi1 h1) h2); -theorem syl6ibr (h1: $ d <-> c $) (h2: $ a -> b -> c $): $ a -> b -> d $ = '(syl6 (bi2 h1) h2); -theorem syl5ibrcom (h1: $ c -> (b <-> d) $) (h2: $ a -> d $): $ a -> c -> b $ = '(com12 @ syl5 h2 (bi2d h1)); -theorem sylbid (h1: $ a -> (b <-> c) $) (h2: $ a -> c -> d $): $ a -> b -> d $ = '(syld (bi1d h1) h2); -theorem sylibd (h1: $ a -> b -> c $) (h2: $ a -> (c <-> d) $): $ a -> b -> d $ = '(syld h1 (bi1d h2)); -theorem sylbird (h1: $ a -> (c <-> b) $) (h2: $ a -> c -> d $): $ a -> b -> d $ = '(syld (bi2d h1) h2); -theorem sylibrd (h1: $ a -> b -> c $) (h2: $ a -> (d <-> c) $): $ a -> b -> d $ = '(syld h1 (bi2d h2)); -theorem bitr3g (h1: $ b <-> d $) (h2: $ c <-> e $) (h: $ a -> (b <-> c) $): - $ a -> (d <-> e) $ = '(syl5bb (bicom h1) @ syl6bb h2 h); -theorem bitr4g (h1: $ d <-> b $) (h2: $ e <-> c $) (h: $ a -> (b <-> c) $): - $ a -> (d <-> e) $ = '(syl5bb h1 @ syl6bb (bicom h2) h); -theorem bitr3gi (h1: $ a <-> c $) (h2: $ b <-> d $) (h: $ a <-> b $): $ c <-> d $ = '(bitr3 h1 @ bitr h h2); -theorem bitr4gi (h1: $ c <-> a $) (h2: $ d <-> b $) (h: $ a <-> b $): $ c <-> d $ = '(bitr h1 @ bitr4 h h2); -theorem impbi (h: $ a -> (b <-> c) $): $ a /\ b -> c $ = '(curry @ bi1d h); -theorem impbir (h: $ a -> (c <-> b) $): $ a /\ b -> c $ = '(curry @ bi2d h); -theorem ancomb: $ a /\ b <-> b /\ a $ = '(ibii ancom ancom); -theorem anass: $ a /\ b /\ c <-> a /\ (b /\ c) $ = +theorem bitr2d (h1: $ aa -> (bb <-> c) $) (h2: $ aa -> (c <-> d) $): $ aa -> (d <-> bb) $ = '(bicomd (bitrd h1 h2)); +theorem bitr3d (h1: $ aa -> (c <-> bb) $) (h2: $ aa -> (c <-> d) $): $ aa -> (bb <-> d) $ = '(bitrd (bicomd h1) h2); +theorem bitr4d (h1: $ aa -> (bb <-> c) $) (h2: $ aa -> (d <-> c) $): $ aa -> (bb <-> d) $ = '(bitrd h1 (bicomd h2)); +theorem bitr: $ (aa <-> bb) -> (bb <-> c) -> (aa <-> c) $ = '(exp (bitrd anl anr)); +theorem bitr2: $ (aa <-> bb) -> (bb <-> c) -> (c <-> aa) $ = '(exp (bitr2d anl anr)); +theorem bitr3: $ (bb <-> aa) -> (bb <-> c) -> (aa <-> c) $ = '(exp (bitr3d anl anr)); +theorem bitr4: $ (aa <-> bb) -> (c <-> bb) -> (aa <-> c) $ = '(exp (bitr4d anl anr)); +theorem bisylr: $ (c <-> bb) -> (aa <-> bb) -> (aa <-> c) $ = '(rsyl bicom @ com23 id bitr); +theorem sylib (h1: $ bb <-> c $) (h2: $ aa -> bb $): $ aa -> c $ = '(syl (bi1i h1) h2); +theorem sylibr (h1: $ c <-> bb $) (h2: $ aa -> bb $): $ aa -> c $ = '(syl (bi2i h1) h2); +theorem sylbi (h1: $ aa <-> bb $) (h2: $ bb -> c $): $ aa -> c $ = '(syl h2 (bi1i h1)); +theorem sylbir (h1: $ bb <-> aa $) (h2: $ bb -> c $): $ aa -> c $ = '(syl h2 (bi2i h1)); +theorem syl5bb (h1: $ bb <-> c $) (h2: $ aa -> (c <-> d) $): $ aa -> (bb <-> d) $ = '(bitrd (a1i h1) h2); +theorem syl5bbr (h1: $ c <-> bb $) (h2: $ aa -> (c <-> d) $): $ aa -> (bb <-> d) $ = '(syl5bb (bicom h1) h2); +theorem syl6bb (h1: $ c <-> d $) (h2: $ aa -> (bb <-> c) $): $ aa -> (bb <-> d) $ = '(bitrd h2 (a1i h1)); +theorem syl6bbr (h1: $ d <-> c $) (h2: $ aa -> (bb <-> c) $): $ aa -> (bb <-> d) $ = '(syl6bb (bicom h1) h2); +theorem syl5bi (h1: $ bb <-> c $) (h2: $ aa -> c -> d $): $ aa -> bb -> d $ = '(syl5 (bi1 h1) h2); +theorem syl5bir (h1: $ c <-> bb $) (h2: $ aa -> c -> d $): $ aa -> bb -> d $ = '(syl5bi (bicom h1) h2); +theorem syl6ib (h1: $ c <-> d $) (h2: $ aa -> bb -> c $): $ aa -> bb -> d $ = '(syl6 (bi1 h1) h2); +theorem syl6ibr (h1: $ d <-> c $) (h2: $ aa -> bb -> c $): $ aa -> bb -> d $ = '(syl6 (bi2 h1) h2); +theorem syl5ibrcom (h1: $ c -> (bb <-> d) $) (h2: $ aa -> d $): $ aa -> c -> bb $ = '(com12 @ syl5 h2 (bi2d h1)); +theorem sylbid (h1: $ aa -> (bb <-> c) $) (h2: $ aa -> c -> d $): $ aa -> bb -> d $ = '(syld (bi1d h1) h2); +theorem sylibd (h1: $ aa -> bb -> c $) (h2: $ aa -> (c <-> d) $): $ aa -> bb -> d $ = '(syld h1 (bi1d h2)); +theorem sylbird (h1: $ aa -> (c <-> bb) $) (h2: $ aa -> c -> d $): $ aa -> bb -> d $ = '(syld (bi2d h1) h2); +theorem sylibrd (h1: $ aa -> bb -> c $) (h2: $ aa -> (d <-> c) $): $ aa -> bb -> d $ = '(syld h1 (bi2d h2)); +theorem bitr3g (h1: $ bb <-> d $) (h2: $ c <-> e $) (h: $ aa -> (bb <-> c) $): + $ aa -> (d <-> e) $ = '(syl5bb (bicom h1) @ syl6bb h2 h); +theorem bitr4g (h1: $ d <-> bb $) (h2: $ e <-> c $) (h: $ aa -> (bb <-> c) $): + $ aa -> (d <-> e) $ = '(syl5bb h1 @ syl6bb (bicom h2) h); +theorem bitr3gi (h1: $ aa <-> c $) (h2: $ bb <-> d $) (h: $ aa <-> bb $): $ c <-> d $ = '(bitr3 h1 @ bitr h h2); +theorem bitr4gi (h1: $ c <-> aa $) (h2: $ d <-> bb $) (h: $ aa <-> bb $): $ c <-> d $ = '(bitr h1 @ bitr4 h h2); +theorem impbi (h: $ aa -> (bb <-> c) $): $ aa /\ bb -> c $ = '(curry @ bi1d h); +theorem impbir (h: $ aa -> (c <-> bb) $): $ aa /\ bb -> c $ = '(curry @ bi2d h); +theorem ancomb: $ aa /\ bb <-> bb /\ aa $ = '(ibii ancom ancom); +theorem anass: $ aa /\ bb /\ c <-> aa /\ (bb /\ c) $ = '(ibii (iand anll (anim1 anr)) (iand (anim2 anl) anrr)); -theorem bian2a: $ (a -> b) -> (a /\ b <-> a) $ = '(ibid (a1i anl) (a2i ian)); -theorem bian1a: $ (b -> a) -> (a /\ b <-> b) $ = '(syl5bb ancomb bian2a); -theorem bian1: $ a -> (a /\ b <-> b) $ = '(syl bian1a prop_1); -theorem bian2: $ b -> (a /\ b <-> a) $ = '(syl bian2a prop_1); -theorem bibi1: $ a -> ((a <-> b) <-> b) $ = '(ibid (com12 bi1) bith); -theorem bibi2: $ b -> ((a <-> b) <-> a) $ = '(syl5bb bicomb bibi1); -theorem noteq: $ (a <-> b) -> (~a <-> ~b) $ = 'con3b; -theorem noteqi (h: $ a <-> b $): $ ~a <-> ~b $ = '(noteq h); -theorem noteqd (h: $ a -> (b <-> c) $): $ a -> (~b <-> ~c) $ = '(syl noteq h); +theorem bian2a: $ (aa -> bb) -> (aa /\ bb <-> aa) $ = '(ibid (a1i anl) (a2i ian)); +theorem bian1a: $ (bb -> aa) -> (aa /\ bb <-> bb) $ = '(syl5bb ancomb bian2a); +theorem bian1: $ aa -> (aa /\ bb <-> bb) $ = '(syl bian1a prop_1); +theorem bian2: $ bb -> (aa /\ bb <-> aa) $ = '(syl bian2a prop_1); +theorem bibi1: $ aa -> ((aa <-> bb) <-> bb) $ = '(ibid (com12 bi1) bith); +theorem bibi2: $ bb -> ((aa <-> bb) <-> aa) $ = '(syl5bb bicomb bibi1); +theorem noteq: $ (aa <-> bb) -> (~aa <-> ~bb) $ = 'con3b; +theorem noteqi (h: $ aa <-> bb $): $ ~aa <-> ~bb $ = '(noteq h); +theorem noteqd (h: $ aa -> (bb <-> c) $): $ aa -> (~bb <-> ~c) $ = '(syl noteq h); theorem imeqd - (h1: $ a -> (b <-> c) $) (h2: $ a -> (d <-> e) $): $ a -> (b -> d <-> c -> e) $ = + (h1: $ aa -> (bb <-> c) $) (h2: $ aa -> (d <-> e) $): $ aa -> (bb -> d <-> c -> e) $ = '(ibid (imimd (bi2d h1) (bi1d h2)) (imimd (bi1d h1) (bi2d h2))); -theorem bibin1: $ ~a -> ((a <-> b) <-> ~b) $ = '(ibid (com12 @ bi1d noteq) binth); -theorem bibin2: $ ~b -> ((a <-> b) <-> ~a) $ = '(syl5bb bicomb bibin1); -theorem imeq1d (h: $ a -> (b <-> c) $): $ a -> (b -> d <-> c -> d) $ = '(imeqd h biidd); -theorem imeq2d (h: $ a -> (c <-> d) $): $ a -> (b -> c <-> b -> d) $ = '(imeqd biidd h); -theorem imeq1i (h: $ a <-> b $): $ a -> c <-> b -> c $ = '(imeq1d id h); -theorem imeq2i (h: $ b <-> c $): $ a -> b <-> a -> c $ = '(imeq2d id h); -theorem imeqi (h1: $ a <-> b $) (h2: $ c <-> d $): $ a -> c <-> b -> d $ = '(bitr (imeq1i h1) (imeq2i h2)); +theorem bibin1: $ ~aa -> ((aa <-> bb) <-> ~bb) $ = '(ibid (com12 @ bi1d noteq) binth); +theorem bibin2: $ ~bb -> ((aa <-> bb) <-> ~aa) $ = '(syl5bb bicomb bibin1); +theorem imeq1d (h: $ aa -> (bb <-> c) $): $ aa -> (bb -> d <-> c -> d) $ = '(imeqd h biidd); +theorem imeq2d (h: $ aa -> (c <-> d) $): $ aa -> (bb -> c <-> bb -> d) $ = '(imeqd biidd h); +theorem imeq1i (h: $ aa <-> bb $): $ aa -> c <-> bb -> c $ = '(imeq1d id h); +theorem imeq2i (h: $ bb <-> c $): $ aa -> bb <-> aa -> c $ = '(imeq2d id h); +theorem imeqi (h1: $ aa <-> bb $) (h2: $ c <-> d $): $ aa -> c <-> bb -> d $ = '(bitr (imeq1i h1) (imeq2i h2)); theorem aneqd - (h1: $ a -> (b <-> c) $) (h2: $ a -> (d <-> e) $): $ a -> (b /\ d <-> c /\ e) $ = + (h1: $ aa -> (bb <-> c) $) (h2: $ aa -> (d <-> e) $): $ aa -> (bb /\ d <-> c /\ e) $ = '(ibid (animd (bi1d h1) (bi1d h2)) (animd (bi2d h1) (bi2d h2))); -theorem imeq2a: $ (a -> (b <-> c)) -> (a -> b <-> a -> c) $ = '(ibid (a2d @ imim2i bi1) (a2d @ imim2i bi2)); -theorem imeq1a: $ (~c -> (a <-> b)) -> (a -> c <-> b -> c) $ = '(bitr4g con3bi con3bi @ syl imeq2a @ imim2i noteq); -theorem imeq2da (h: $ G /\ a -> (b <-> c) $): $ G -> (a -> b <-> a -> c) $ = '(syl imeq2a @ exp h); -theorem aneq1d (h: $ a -> (b <-> c) $): $ a -> (b /\ d <-> c /\ d) $ = '(aneqd h biidd); -theorem aneq2d (h: $ a -> (c <-> d) $): $ a -> (b /\ c <-> b /\ d) $ = '(aneqd biidd h); -theorem aneq: $ (a <-> b) -> (c <-> d) -> (a /\ c <-> b /\ d) $ = '(exp @ aneqd anl anr); -theorem aneq1i (h: $ a <-> b $): $ a /\ c <-> b /\ c $ = '(aneq1d id h); -theorem aneq2i (h: $ b <-> c $): $ a /\ b <-> a /\ c $ = '(aneq2d id h); -theorem aneq2a: $ (a -> (b <-> c)) -> (a /\ b <-> a /\ c) $ = +theorem imeq2a: $ (aa -> (bb <-> c)) -> (aa -> bb <-> aa -> c) $ = '(ibid (a2d @ imim2i bi1) (a2d @ imim2i bi2)); +theorem imeq1a: $ (~c -> (aa <-> bb)) -> (aa -> c <-> bb -> c) $ = '(bitr4g con3bi con3bi @ syl imeq2a @ imim2i noteq); +theorem imeq2da (h: $ G /\ aa -> (bb <-> c) $): $ G -> (aa -> bb <-> aa -> c) $ = '(syl imeq2a @ exp h); +theorem aneq1d (h: $ aa -> (bb <-> c) $): $ aa -> (bb /\ d <-> c /\ d) $ = '(aneqd h biidd); +theorem aneq2d (h: $ aa -> (c <-> d) $): $ aa -> (bb /\ c <-> bb /\ d) $ = '(aneqd biidd h); +theorem aneq: $ (aa <-> bb) -> (c <-> d) -> (aa /\ c <-> bb /\ d) $ = '(exp @ aneqd anl anr); +theorem aneq1i (h: $ aa <-> bb $): $ aa /\ c <-> bb /\ c $ = '(aneq1d id h); +theorem aneq2i (h: $ bb <-> c $): $ aa /\ bb <-> aa /\ c $ = '(aneq2d id h); +theorem aneq2a: $ (aa -> (bb <-> c)) -> (aa /\ bb <-> aa /\ c) $ = '(ibid (syl anim2a @ imim2i bi1) (syl anim2a @ imim2i bi2)); -theorem aneq1a: $ (c -> (a <-> b)) -> (a /\ c <-> b /\ c) $ = '(syl5bb ancomb @ syl6bb ancomb aneq2a); -theorem aneq1da (h: $ G /\ c -> (a <-> b) $): $ G -> (a /\ c <-> b /\ c) $ = '(syl aneq1a @ exp h); -theorem aneq2da (h: $ G /\ a -> (b <-> c) $): $ G -> (a /\ b <-> a /\ c) $ = '(syl aneq2a @ exp h); -theorem anlass: $ a /\ (b /\ c) <-> b /\ (a /\ c) $ = +theorem aneq1a: $ (c -> (aa <-> bb)) -> (aa /\ c <-> bb /\ c) $ = '(syl5bb ancomb @ syl6bb ancomb aneq2a); +theorem aneq1da (h: $ G /\ c -> (aa <-> bb) $): $ G -> (aa /\ c <-> bb /\ c) $ = '(syl aneq1a @ exp h); +theorem aneq2da (h: $ G /\ aa -> (bb <-> c) $): $ G -> (aa /\ bb <-> aa /\ c) $ = '(syl aneq2a @ exp h); +theorem anlass: $ aa /\ (bb /\ c) <-> bb /\ (aa /\ c) $ = '(bitr3 anass @ bitr (aneq1i ancomb) anass); -theorem anrass: $ a /\ b /\ c <-> a /\ c /\ b $ = +theorem anrass: $ aa /\ bb /\ c <-> aa /\ c /\ bb $ = '(bitr anass @ bitr4 (aneq2i ancomb) anass); -theorem an4: $ (a /\ b) /\ (c /\ d) <-> (a /\ c) /\ (b /\ d) $ = +theorem an4: $ (aa /\ bb) /\ (c /\ d) <-> (aa /\ c) /\ (bb /\ d) $ = '(bitr4 anass @ bitr4 anass @ aneq2i anlass); -theorem anroti (h: $ a -> b /\ d $): $ a /\ c -> b /\ c /\ d $ = '(sylib anrass @ anim1 h); -theorem anrotri (h: $ b /\ d -> a $): $ b /\ c /\ d -> a /\ c $ = '(sylbi anrass @ anim1 h); -theorem bian11i (h: $ a <-> b /\ c $): $ a /\ d <-> b /\ (c /\ d) $ = '(bitr (aneq1i h) anass); -theorem bian21i (h: $ a <-> b /\ c $): $ a /\ d <-> (b /\ d) /\ c $ = '(bitr (aneq1i h) anrass); -theorem bian12i (h: $ a <-> b /\ c $): $ d /\ a <-> b /\ (d /\ c) $ = '(bitr (aneq2i h) anlass); -theorem bian22i (h: $ a <-> b /\ c $): $ d /\ a <-> (d /\ b) /\ c $ = '(bitr4 (aneq2i h) anass); -theorem bian11d (h: $ G -> (a <-> b /\ c) $): $ G -> (a /\ d <-> b /\ (c /\ d)) $ = '(syl6bb anass (aneq1d h)); -theorem bian21d (h: $ G -> (a <-> b /\ c) $): $ G -> (a /\ d <-> (b /\ d) /\ c) $ = '(syl6bb anrass (aneq1d h)); -theorem bian12d (h: $ G -> (a <-> b /\ c) $): $ G -> (d /\ a <-> b /\ (d /\ c)) $ = '(syl6bb anlass (aneq2d h)); -theorem bian22d (h: $ G -> (a <-> b /\ c) $): $ G -> (d /\ a <-> (d /\ b) /\ c) $ = '(syl6bbr anass (aneq2d h)); -theorem bian11da (h: $ G /\ d -> (a <-> b /\ c) $): $ G -> (a /\ d <-> b /\ (c /\ d)) $ = '(syl6bb anass (aneq1da h)); -theorem bian21da (h: $ G /\ d -> (a <-> b /\ c) $): $ G -> (a /\ d <-> (b /\ d) /\ c) $ = '(syl6bb anrass (aneq1da h)); -theorem bian12da (h: $ G /\ d -> (a <-> b /\ c) $): $ G -> (d /\ a <-> b /\ (d /\ c)) $ = '(syl6bb anlass (aneq2da h)); -theorem bian22da (h: $ G /\ d -> (a <-> b /\ c) $): $ G -> (d /\ a <-> (d /\ b) /\ c) $ = '(syl6bbr anass (aneq2da h)); -theorem anidm: $ a /\ a <-> a $ = '(ibii anl (iand id id)); -theorem anandi: $ a /\ (b /\ c) <-> (a /\ b) /\ (a /\ c) $ = '(bitr3 (aneq1i anidm) an4); -theorem anandir: $ (a /\ b) /\ c <-> (a /\ c) /\ (b /\ c) $ = '(bitr3 (aneq2i anidm) an4); -theorem imandi: $ (a -> b /\ c) <-> (a -> b) /\ (a -> c) $ = +theorem anroti (h: $ aa -> bb /\ d $): $ aa /\ c -> bb /\ c /\ d $ = '(sylib anrass @ anim1 h); +theorem anrotri (h: $ bb /\ d -> aa $): $ bb /\ c /\ d -> aa /\ c $ = '(sylbi anrass @ anim1 h); +theorem bian11i (h: $ aa <-> bb /\ c $): $ aa /\ d <-> bb /\ (c /\ d) $ = '(bitr (aneq1i h) anass); +theorem bian21i (h: $ aa <-> bb /\ c $): $ aa /\ d <-> (bb /\ d) /\ c $ = '(bitr (aneq1i h) anrass); +theorem bian12i (h: $ aa <-> bb /\ c $): $ d /\ aa <-> bb /\ (d /\ c) $ = '(bitr (aneq2i h) anlass); +theorem bian22i (h: $ aa <-> bb /\ c $): $ d /\ aa <-> (d /\ bb) /\ c $ = '(bitr4 (aneq2i h) anass); +theorem bian11d (h: $ G -> (aa <-> bb /\ c) $): $ G -> (aa /\ d <-> bb /\ (c /\ d)) $ = '(syl6bb anass (aneq1d h)); +theorem bian21d (h: $ G -> (aa <-> bb /\ c) $): $ G -> (aa /\ d <-> (bb /\ d) /\ c) $ = '(syl6bb anrass (aneq1d h)); +theorem bian12d (h: $ G -> (aa <-> bb /\ c) $): $ G -> (d /\ aa <-> bb /\ (d /\ c)) $ = '(syl6bb anlass (aneq2d h)); +theorem bian22d (h: $ G -> (aa <-> bb /\ c) $): $ G -> (d /\ aa <-> (d /\ bb) /\ c) $ = '(syl6bbr anass (aneq2d h)); +theorem bian11da (h: $ G /\ d -> (aa <-> bb /\ c) $): $ G -> (aa /\ d <-> bb /\ (c /\ d)) $ = '(syl6bb anass (aneq1da h)); +theorem bian21da (h: $ G /\ d -> (aa <-> bb /\ c) $): $ G -> (aa /\ d <-> (bb /\ d) /\ c) $ = '(syl6bb anrass (aneq1da h)); +theorem bian12da (h: $ G /\ d -> (aa <-> bb /\ c) $): $ G -> (d /\ aa <-> bb /\ (d /\ c)) $ = '(syl6bb anlass (aneq2da h)); +theorem bian22da (h: $ G /\ d -> (aa <-> bb /\ c) $): $ G -> (d /\ aa <-> (d /\ bb) /\ c) $ = '(syl6bbr anass (aneq2da h)); +theorem anidm: $ aa /\ aa <-> aa $ = '(ibii anl (iand id id)); +theorem anandi: $ aa /\ (bb /\ c) <-> (aa /\ bb) /\ (aa /\ c) $ = '(bitr3 (aneq1i anidm) an4); +theorem anandir: $ (aa /\ bb) /\ c <-> (aa /\ c) /\ (bb /\ c) $ = '(bitr3 (aneq2i anidm) an4); +theorem imandi: $ (aa -> bb /\ c) <-> (aa -> bb) /\ (aa -> c) $ = '(ibii (iand (imim2i anl) (imim2i anr)) (com12 @ animd mpcom mpcom)); -theorem imancom: $ a /\ (b -> c) -> b -> a /\ c $ = '(com12 @ anim2d mpcom); -theorem rbida (h1: $ a /\ c -> b $) (h2: $ a /\ d -> b $) - (h: $ a /\ b -> (c <-> d) $): $ a -> (c <-> d) $ = +theorem imancom: $ aa /\ (bb -> c) -> bb -> aa /\ c $ = '(com12 @ anim2d mpcom); +theorem rbida (h1: $ aa /\ c -> bb $) (h2: $ aa /\ d -> bb $) + (h: $ aa /\ bb -> (c <-> d) $): $ aa -> (c <-> d) $ = '(bitr3d (syla bian2a h1) @ bitrd (syla aneq1a h) (syla bian2a h2)); -theorem rbid (h1: $ b -> a $) (h2: $ c -> a $) (h: $ a -> (b <-> c) $): $ b <-> c $ = +theorem rbid (h1: $ bb -> aa $) (h2: $ c -> aa $) (h: $ aa -> (bb <-> c) $): $ bb <-> c $ = '(bitr3 (bian2a h1) @ bitr (aneq1a h) (bian2a h2)); theorem bieqd - (h1: $ a -> (b <-> c) $) (h2: $ a -> (d <-> e) $): $ a -> ((b <-> d) <-> (c <-> e)) $ = + (h1: $ aa -> (bb <-> c) $) (h2: $ aa -> (d <-> e) $): $ aa -> ((bb <-> d) <-> (c <-> e)) $ = '(aneqd (imeqd h1 h2) (imeqd h2 h1)); -theorem bieq1d (h: $ a -> (b <-> c) $): $ a -> ((b <-> d) <-> (c <-> d)) $ = '(bieqd h biidd); -theorem bieq2d (h: $ a -> (c <-> d) $): $ a -> ((b <-> c) <-> (b <-> d)) $ = '(bieqd biidd h); -theorem bieq: $ (a <-> b) -> (c <-> d) -> ((a <-> c) <-> (b <-> d)) $ = '(exp (bieqd anl anr)); -theorem bieq1: $ (a <-> b) -> ((a <-> c) <-> (b <-> c)) $ = '(bieq1d id); -theorem bieq2: $ (b <-> c) -> ((a <-> b) <-> (a <-> c)) $ = '(bieq2d id); -theorem impexp: $ (a /\ b -> c) <-> (a -> b -> c) $ = +theorem bieq1d (h: $ aa -> (bb <-> c) $): $ aa -> ((bb <-> d) <-> (c <-> d)) $ = '(bieqd h biidd); +theorem bieq2d (h: $ aa -> (c <-> d) $): $ aa -> ((bb <-> c) <-> (bb <-> d)) $ = '(bieqd biidd h); +theorem bieq: $ (aa <-> bb) -> (c <-> d) -> ((aa <-> c) <-> (bb <-> d)) $ = '(exp (bieqd anl anr)); +theorem bieq1: $ (aa <-> bb) -> ((aa <-> c) <-> (bb <-> c)) $ = '(bieq1d id); +theorem bieq2: $ (bb <-> c) -> ((aa <-> bb) <-> (aa <-> c)) $ = '(bieq2d id); +theorem impexp: $ (aa /\ bb -> c) <-> (aa -> bb -> c) $ = '(ibii (exp @ exp @ mpd (anim1 anr) anll) (exp @ mpd anrr @ mpd anrl anl)); -theorem impd (h: $ a -> b -> c -> d $): $ a -> b /\ c -> d $ = '(sylibr impexp h); -theorem expd (h: $ a -> b /\ c -> d $): $ a -> b -> c -> d $ = '(sylib impexp h); -theorem com12b: $ (a -> b -> c) <-> (b -> a -> c) $ = '(ibii (com23 id) (com23 id)); +theorem impd (h: $ aa -> bb -> c -> d $): $ aa -> bb /\ c -> d $ = '(sylibr impexp h); +theorem expd (h: $ aa -> bb /\ c -> d $): $ aa -> bb -> c -> d $ = '(sylib impexp h); +theorem com12b: $ (aa -> bb -> c) <-> (bb -> aa -> c) $ = '(ibii (com23 id) (com23 id)); -theorem orl: $ a -> a \/ b $ = 'absurdr; -theorem orr: $ b -> a \/ b $ = 'prop_1; -theorem eori (h1: $ a -> c $) (h2: $ b -> c $): $ a \/ b -> c $ = +theorem orl: $ aa -> aa \/ bb $ = 'absurdr; +theorem orr: $ bb -> aa \/ bb $ = 'prop_1; +theorem eori (h1: $ aa -> c $) (h2: $ bb -> c $): $ aa \/ bb -> c $ = '(casesd (a1i h1) (imim2i h2)); -theorem eord (h1: $ a -> b -> d $) (h2: $ a -> c -> d $): - $ a -> b \/ c -> d $ = '(com12 (eori (com12 h1) (com12 h2))); -theorem eorda (h1: $ a /\ b -> d $) (h2: $ a /\ c -> d $): - $ a -> b \/ c -> d $ = '(eord (exp h1) (exp h2)); -theorem orld (h: $ a -> b $): $ a -> b \/ c $ = '(syl orl h); -theorem orrd (h: $ a -> c $): $ a -> b \/ c $ = '(syl orr h); -theorem eor: $ (a -> c) -> (b -> c) -> a \/ b -> c $ = '(exp (eord anl anr)); -theorem orimd (h1: $ a -> b -> c $) (h2: $ a -> d -> e $): $ a -> b \/ d -> c \/ e $ = +theorem eord (h1: $ aa -> bb -> d $) (h2: $ aa -> c -> d $): + $ aa -> bb \/ c -> d $ = '(com12 (eori (com12 h1) (com12 h2))); +theorem eorda (h1: $ aa /\ bb -> d $) (h2: $ aa /\ c -> d $): + $ aa -> bb \/ c -> d $ = '(eord (exp h1) (exp h2)); +theorem orld (h: $ aa -> bb $): $ aa -> bb \/ c $ = '(syl orl h); +theorem orrd (h: $ aa -> c $): $ aa -> bb \/ c $ = '(syl orr h); +theorem eor: $ (aa -> c) -> (bb -> c) -> aa \/ bb -> c $ = '(exp (eord anl anr)); +theorem orimd (h1: $ aa -> bb -> c $) (h2: $ aa -> d -> e $): $ aa -> bb \/ d -> c \/ e $ = '(eord (syl6 orl h1) (syl6 orr h2)); -theorem orim1d (h: $ a -> b -> c $): $ a -> b \/ d -> c \/ d $ = '(orimd h idd); -theorem orim2d (h: $ a -> c -> d $): $ a -> b \/ c -> b \/ d $ = '(orimd idd h); -theorem orim1: $ (a -> b) -> a \/ c -> b \/ c $ = '(orim1d id); -theorem orim2: $ (b -> c) -> a \/ b -> a \/ c $ = '(orim2d id); -theorem oreq1d: $ (a <-> b) -> (a \/ c <-> b \/ c) $ = '(anim orim1 orim1); -theorem oreq2d: $ (a <-> b) -> (c \/ a <-> c \/ b) $ = '(anim orim2 orim2); -theorem oreq1i (h: $ a <-> b $): $ a \/ c <-> b \/ c $ = '(oreq1d h); -theorem oreq2i (h: $ b <-> c $): $ a \/ b <-> a \/ c $ = '(oreq2d h); -theorem orim: $ (a -> b) -> (c -> d) -> a \/ c -> b \/ d $ = '(exp @ syld (anwl orim1) (anwr orim2)); -theorem oreq: $ (a <-> b) -> (c <-> d) -> (a \/ c <-> b \/ d) $ = '(syl5 oreq2d @ syl bitr oreq1d); -theorem oreqi (h1: $ a <-> b $) (h2: $ c <-> d $): $ a \/ c <-> b \/ d $ = '(bitr (oreq1i h1) (oreq2i h2)); -theorem orcom: $ a \/ b -> b \/ a $ = 'con1; -theorem orcomb: $ a \/ b <-> b \/ a $ = '(ibii orcom orcom); -theorem or12: $ a \/ (b \/ c) <-> b \/ (a \/ c) $ = '(bitr3 impexp @ bitr (imeq1i ancomb) impexp); -theorem orass: $ a \/ b \/ c <-> a \/ (b \/ c) $ = '(bitr orcomb @ bitr or12 @ imeq2i orcomb); --- theorem or4: $ (a \/ b) \/ (c \/ d) <-> (a \/ c) \/ (b \/ d) $ = '(bitr4 orass @ bitr4 orass @ oreq2 or12); -theorem oridm: $ a \/ a <-> a $ = '(ibii (eor id id) orl); -theorem notan2: $ ~(a /\ b) <-> a -> ~b $ = '(bicom notnot); -theorem notan: $ ~(a /\ b) <-> (~a \/ ~b) $ = '(bitr notan2 (imeq1i notnot)); -theorem notor: $ ~(a \/ b) <-> (~a /\ ~b) $ = '(con1b (bitr4 notan (oreqi notnot notnot))); -theorem iman: $ a -> b <-> ~(a /\ ~b) $ = '(bitr4 (imeq2i notnot) notan2); -theorem imor: $ ((a \/ b) -> c) <-> ((a -> c) /\ (b -> c)) $ = +theorem orim1d (h: $ aa -> bb -> c $): $ aa -> bb \/ d -> c \/ d $ = '(orimd h idd); +theorem orim2d (h: $ aa -> c -> d $): $ aa -> bb \/ c -> bb \/ d $ = '(orimd idd h); +theorem orim1: $ (aa -> bb) -> aa \/ c -> bb \/ c $ = '(orim1d id); +theorem orim2: $ (bb -> c) -> aa \/ bb -> aa \/ c $ = '(orim2d id); +theorem oreq1d: $ (aa <-> bb) -> (aa \/ c <-> bb \/ c) $ = '(anim orim1 orim1); +theorem oreq2d: $ (aa <-> bb) -> (c \/ aa <-> c \/ bb) $ = '(anim orim2 orim2); +theorem oreq1i (h: $ aa <-> bb $): $ aa \/ c <-> bb \/ c $ = '(oreq1d h); +theorem oreq2i (h: $ bb <-> c $): $ aa \/ bb <-> aa \/ c $ = '(oreq2d h); +theorem orim: $ (aa -> bb) -> (c -> d) -> aa \/ c -> bb \/ d $ = '(exp @ syld (anwl orim1) (anwr orim2)); +theorem oreq: $ (aa <-> bb) -> (c <-> d) -> (aa \/ c <-> bb \/ d) $ = '(syl5 oreq2d @ syl bitr oreq1d); +theorem oreqi (h1: $ aa <-> bb $) (h2: $ c <-> d $): $ aa \/ c <-> bb \/ d $ = '(bitr (oreq1i h1) (oreq2i h2)); +theorem orcom: $ aa \/ bb -> bb \/ aa $ = 'con1; +theorem orcomb: $ aa \/ bb <-> bb \/ aa $ = '(ibii orcom orcom); +theorem or12: $ aa \/ (bb \/ c) <-> bb \/ (aa \/ c) $ = '(bitr3 impexp @ bitr (imeq1i ancomb) impexp); +theorem orass: $ aa \/ bb \/ c <-> aa \/ (bb \/ c) $ = '(bitr orcomb @ bitr or12 @ imeq2i orcomb); +-- theorem or4: $ (aa \/ bb) \/ (c \/ d) <-> (aa \/ c) \/ (bb \/ d) $ = '(bitr4 orass @ bitr4 orass @ oreq2 or12); +theorem oridm: $ aa \/ aa <-> aa $ = '(ibii (eor id id) orl); +theorem notan2: $ ~(aa /\ bb) <-> aa -> ~bb $ = '(bicom notnot); +theorem notan: $ ~(aa /\ bb) <-> (~aa \/ ~bb) $ = '(bitr notan2 (imeq1i notnot)); +theorem notor: $ ~(aa \/ bb) <-> (~aa /\ ~bb) $ = '(con1b (bitr4 notan (oreqi notnot notnot))); +theorem iman: $ aa -> bb <-> ~(aa /\ ~bb) $ = '(bitr4 (imeq2i notnot) notan2); +theorem imor: $ ((aa \/ bb) -> c) <-> ((aa -> c) /\ (bb -> c)) $ = '(ibii (iand (imim1i orl) (imim1i orr)) (curry eor)); -theorem andi: $ a /\ (b \/ c) <-> a /\ b \/ a /\ c $ = +theorem andi: $ aa /\ (bb \/ c) <-> aa /\ bb \/ aa /\ c $ = '(ibii (curry @ orimd ian ian) @ eor (anim2 orl) (anim2 orr)); -theorem andir: $ (a \/ b) /\ c <-> a /\ c \/ b /\ c $ = +theorem andir: $ (aa \/ bb) /\ c <-> aa /\ c \/ bb /\ c $ = '(bitr ancomb @ bitr andi @ oreqi ancomb ancomb); -theorem ordi: $ a \/ (b /\ c) <-> (a \/ b) /\ (a \/ c) $ = +theorem ordi: $ aa \/ (bb /\ c) <-> (aa \/ bb) /\ (aa \/ c) $ = '(ibii (iand (orim2 anl) (orim2 anr)) @ com12 @ animd mpcom mpcom); -theorem ordir: $ (a /\ b) \/ c <-> (a \/ c) /\ (b \/ c) $ = +theorem ordir: $ (aa /\ bb) \/ c <-> (aa \/ c) /\ (bb \/ c) $ = '(bitr orcomb @ bitr ordi @ aneq orcomb orcomb); -theorem oreq2a: $ (~a -> (b <-> c)) -> (a \/ b <-> a \/ c) $ = 'imeq2a; -theorem oreq1a: $ (~c -> (a <-> b)) -> (a \/ c <-> b \/ c) $ = '(syl5bb orcomb @ syl6bb orcomb oreq2a); -theorem biim1a: $ (~a -> b) -> (a -> b <-> b) $ = '(ibid (exp @ casesd anr anl) (a1i prop_1)); -theorem biim2a: $ (b -> ~a) -> (a -> b <-> ~a) $ = '(ibid (exp @ syl inot @ curry imim2) (a1i absurd)); -theorem bior1a: $ (a -> b) -> (a \/ b <-> b) $ = '(sylbi (imeq1i notnot) biim1a); -theorem bior2a: $ (b -> a) -> (a \/ b <-> a) $ = '(syl5bb orcomb bior1a); -theorem biim1: $ a -> (a -> b <-> b) $ = '(syl biim1a absurdr); -theorem biim2: $ ~b -> (a -> b <-> ~a) $ = '(syl biim2a absurd); -theorem bior1: $ ~a -> (a \/ b <-> b) $ = '(syl bior1a absurd); -theorem bior2: $ ~b -> (a \/ b <-> a) $ = '(syl bior2a absurd); +theorem oreq2a: $ (~aa -> (bb <-> c)) -> (aa \/ bb <-> aa \/ c) $ = 'imeq2a; +theorem oreq1a: $ (~c -> (aa <-> bb)) -> (aa \/ c <-> bb \/ c) $ = '(syl5bb orcomb @ syl6bb orcomb oreq2a); +theorem biim1a: $ (~aa -> bb) -> (aa -> bb <-> bb) $ = '(ibid (exp @ casesd anr anl) (a1i prop_1)); +theorem biim2a: $ (bb -> ~aa) -> (aa -> bb <-> ~aa) $ = '(ibid (exp @ syl inot @ curry imim2) (a1i absurd)); +theorem bior1a: $ (aa -> bb) -> (aa \/ bb <-> bb) $ = '(sylbi (imeq1i notnot) biim1a); +theorem bior2a: $ (bb -> aa) -> (aa \/ bb <-> aa) $ = '(syl5bb orcomb bior1a); +theorem biim1: $ aa -> (aa -> bb <-> bb) $ = '(syl biim1a absurdr); +theorem biim2: $ ~bb -> (aa -> bb <-> ~aa) $ = '(syl biim2a absurd); +theorem bior1: $ ~aa -> (aa \/ bb <-> bb) $ = '(syl bior1a absurd); +theorem bior2: $ ~bb -> (aa \/ bb <-> aa) $ = '(syl bior2a absurd); theorem em: $ p \/ ~p $ = 'id; theorem emr: $ ~p \/ p $ = '(orcom em); -theorem ian2: $ a -> b -> b /\ a $ = '(exp ancom); +theorem ian2: $ aa -> bb -> bb /\ aa $ = '(exp ancom); theorem absurdum: $ bot -> phi $ = '(prop_3 idd); theorem taut: $ top $ = 'absurdum; theorem imp_top: $ phi -> top $ = '(a1i taut); theorem top_or: $ top \/ phi $ = '(syl absurdum dne); -theorem bot_or: $ (bot \/ a) -> a $ = '(mpcom taut); +theorem bot_or: $ (bot \/ aa) -> aa $ = '(mpcom taut); theorem top_and: $ phi -> top /\ phi $ = '(com12 bot_or); -theorem imp_to_or (h: $(~a \/ b) -> c$): $(a -> b) -> c$ = '(rsyl con3 (rsyl orcom h)) ; +theorem imp_to_or (h: $(~aa \/ bb) -> c$): $(aa -> bb) -> c$ = '(rsyl con3 (rsyl orcom h)) ; -theorem not_distr_or: $ ~(a \/ b) <-> ~a /\ ~b $ = 'notor; -theorem and_distr: $ a /\ (b /\ c) <-> (a /\ b) /\ (a /\ c) $ = +theorem not_distr_or: $ ~(aa \/ bb) <-> ~aa /\ ~bb $ = 'notor; +theorem and_distr: $ aa /\ (bb /\ c) <-> (aa /\ bb) /\ (aa /\ c) $ = '(ibii ( rsyl (anim1 @ anr anidm) @ rsyl (anl anass) @@ -695,44 +708,44 @@ theorem and_distr: $ a /\ (b /\ c) <-> (a /\ b) /\ (a /\ c) $ = (anr anass)) (rsyl (rsyl (anl anass) anr) (anl anlass))); -theorem appl: $ (a /\ (a -> b)) -> b $ = '(con1 @ anl com12b @ con3d mpcom); +theorem appl: $ (aa /\ (aa -> bb)) -> bb $ = '(con1 @ anl com12b @ con3d mpcom); ---- analogs to anl and anr; Would prefer: $~(a -> b) <-> (a /\ ~b)$ -theorem neg_imp_left: $ ~(a -> b) -> a $ = '(con1 absurd); -theorem neg_imp_right: $~(a -> b) -> ~b $ = '(con1 (rsyl dne (a1d id))); -theorem neg_imp_wl(h: $ a -> c $): $ ~(a -> b) -> c $ = '(syl h neg_imp_left); -theorem neg_imp_wr(h: $ ~b -> c $): $ ~(a -> b) -> c $ = '(syl h neg_imp_right); +--- analogs to anl and anr; Would prefer: $~(aa -> bb) <-> (aa /\ ~bb)$ +theorem neg_imp_left: $ ~(aa -> bb) -> aa $ = '(con1 absurd); +theorem neg_imp_right: $ ~(aa -> bb) -> ~bb $ = '(con3 prop_1); +theorem neg_imp_wl(h: $ aa -> c $): $ ~(aa -> bb) -> c $ = '(syl h neg_imp_left); +theorem neg_imp_wr(h: $ ~bb -> c $): $ ~(aa -> bb) -> c $ = '(syl h neg_imp_right); -theorem or_imp_xor_and: $ a \/ b -> (~(a <-> b) \/ (a /\ b)) $ = - '( eori (! cases b _ (expcom orr) +theorem or_imp_xor_and: $ aa \/ bb -> (~(aa <-> bb) \/ (aa /\ bb)) $ = + '( eori (! cases bb _ (expcom orr) @ expcom @ syl orl @ com12 @ curry @ com23 @ impd @ a2i @ a1i absurdr ) - (! cases a _ (exp orr) + (! cases aa _ (exp orr) @ expcom @ syl orl @ com12 @ curry @ com12 @ com23 @ impd @ a2i @ a1i absurdr ) ); -theorem xor_and_imp_or: $ (~(a <-> b) \/ (a /\ b)) -> a \/ b $ = +theorem xor_and_imp_or: $ (~(aa <-> bb) \/ (aa /\ bb)) -> aa \/ bb $ = '(eori (syl (imp_to_or (eori (neg_imp_wl orl) (neg_imp_wl orr))) dne) (anwl orl) ); -theorem lemma_51: $ ((a /\ ~b) \/ (b /\ ~a)) <-> ~(a <-> b) $ = '(iani +theorem lemma_51: $ ((aa /\ ~bb) \/ (bb /\ ~aa)) <-> ~(aa <-> bb) $ = '(iani (eori (con3 @ rsyl anl @ imim2i notnot1) (rsyl ancom @ con3 @ rsyl anr con3)) (con1 @ rsyl (anl not_distr_or) @ anim (anr iman) (anr iman))); -theorem lemma_in_in_reverse_helper: $ (~a \/ b) -> (~a \/ (b /\ a)) $ = +theorem lemma_in_in_reverse_helper: $ (~aa \/ bb) -> (~aa \/ (bb /\ aa)) $ = '(syl (orim2 @ anim2 dne) @ syl anr bian1a); -theorem lemma_60_helper_1: $ a -> (a /\ ~b) \/ (a /\ b) $ = +theorem lemma_60_helper_1: $ aa -> (aa /\ ~bb) \/ (aa /\ bb) $ = '(syl (anl andi) @ iand id @ a1i emr); -theorem lemma_60_helper_2: $ a -> ~b \/ (a /\ b) $ = +theorem lemma_60_helper_2: $ aa -> ~bb \/ (aa /\ bb) $ = '(syl (imim1i dne) ian); -theorem bisquare (h1: $a <-> b$) (h2: $d <-> c$) (h3: $b <-> c$): $a <-> d$ = +theorem bisquare (h1: $aa <-> bb$) (h2: $d <-> c$) (h3: $bb <-> c$): $aa <-> d$ = '(bitr h1 @ bisylr h2 h3); -theorem Fprop: $ (a -> b) -> (c -> d) -> (b -> d -> e) -> (a -> c -> e) $ = +theorem Fprop: $ (aa -> bb) -> (c -> d) -> (bb -> d -> e) -> (aa -> c -> e) $ = '(syl (anl impexp) @ com12 @ imim2d @ curry @ imim2d imim1); theorem an_top_bi_l: $ phi /\ top <-> phi $ = '(ibii anl @ syl ancom top_and); @@ -743,8 +756,29 @@ theorem an_bot_bi_r: $ bot /\ phi <-> bot $ = '(ibii anl absurdum); theorem or_bot_bi_l: $ phi \/ bot <-> phi $ = '(ibii (eori id absurdum) orl); theorem or_bot_bi_r: $ bot \/ phi <-> phi $ = '(ibii (eori absurdum id) orr); -theorem or_or_not_an: $ a \/ b <-> a \/ (~a /\ b) $ = +theorem or_or_not_an: $ aa \/ bb <-> aa \/ (~aa /\ bb) $ = '(bitr (bitr (bicom an_top_bi_r) @ aneq1i @ ibii (a1i em) imp_top) @ bicom ordi); -theorem absurd_an: $~a /\ a <-> bot$ = '(ibii (impcom mpcom) absurdum); -theorem absurd_an_r: $a /\ ~a <-> bot$ = '(ibii (curry mpcom) absurdum); +theorem absurd_an: $~aa /\ aa <-> bot$ = '(ibii (impcom mpcom) absurdum); +theorem absurd_an_r: $aa /\ ~aa <-> bot$ = '(ibii (curry mpcom) absurdum); + +theorem imp_or_split: $ (aa -> bb \/ c) -> (aa -> bb) \/ (aa -> c) $ = + '(rsyl (anr impexp) @ orim (imim2 dne) prop_1); + +theorem iand3 (h1: $ aa -> bb $) (h2: $ aa -> c $) (h3: $ aa -> d $): $ aa -> bb /\ c /\ d $ = + '(iand (iand h1 h2) h3); + +theorem iand4 (h1: $ aa -> bb $) (h2: $ aa -> c $) (h3: $ aa -> d $) (h4: $ aa -> e $): $ aa -> bb /\ c /\ d /\ e $ = + '(iand (iand (iand h1 h2) h3) h4); + +theorem iand5 (h1: $ aa -> bb $) (h2: $ aa -> c $) (h3: $ aa -> d $) (h4: $ aa -> e $) (h5: $ aa -> f $): $ aa -> bb /\ c /\ d /\ e /\ f $ = + '(iand (iand (iand (iand h1 h2) h3) h4) h5); + +theorem iand6 (h1: $ aa -> bb $) (h2: $ aa -> c $) (h3: $ aa -> d $) (h4: $ aa -> e $) (h5: $ aa -> f $) (h6: $ aa -> g $): $ aa -> bb /\ c /\ d /\ e /\ f /\ g $ = + '(iand (iand (iand (iand (iand h1 h2) h3) h4) h5) h6); + +theorem iand7 (h1: $ aa -> bb $) (h2: $ aa -> c $) (h3: $ aa -> d $) (h4: $ aa -> e $) (h5: $ aa -> f $) (h6: $ aa -> g $) (h7: $ aa -> h $): $ aa -> bb /\ c /\ d /\ e /\ f /\ g /\ h $ = + '(iand (iand (iand (iand (iand (iand h1 h2) h3) h4) h5) h6) h7); + +theorem imp_or_extract: $ (aa -> bb) \/ (aa -> c) <-> (aa -> (bb \/ c)) $ = + '(ibii (eori (imim2 orl) (imim2 orr)) imp_or_split); diff --git a/02-ml-normalization.mm1 b/02-ml-normalization.mm1 index d8d3f75..2cd97ad 100644 --- a/02-ml-normalization.mm1 +++ b/02-ml-normalization.mm1 @@ -33,6 +33,10 @@ theorem eFresh_not {x: EVar} (phi: Pattern x) $ _eFresh x (~ phi) $ = '(eFresh_imp h eFresh_disjoint); +theorem eFresh_forall_same_var {x: EVar} (phi: Pattern x): + $ _eFresh x (forall x phi) $ = + '(eFresh_not eFresh_exists_same_var); + theorem sFresh_not {X: SVar} (phi: Pattern X) (h: $ _sFresh X phi $): $ _sFresh X (~ phi) $ = @@ -97,6 +101,11 @@ theorem norm_and_r (phi psi psi2: Pattern) $ Norm (phi /\ psi) (phi /\ psi2) $ = '(norm_and norm_refl h); +theorem norm_forall {x: EVar} (phi psi: Pattern x) + (h: $ Norm phi psi $): + $ Norm (forall x phi) (forall x psi) $ = + '(norm_not @ norm_exists @ norm_not h); + theorem eFresh_and {x: EVar} (phi1 phi2: Pattern x) (h1: $ _eFresh x phi1 $) (h2: $ _eFresh x phi2 $): @@ -173,19 +182,36 @@ theorem exists_framing {x: EVar} (phi1 phi2: Pattern x) $ (exists x phi1) -> exists x phi2 $ = '(exists_generalization eFresh_exists_same_var @ syl exists_intro_same_var h); -theorem or_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x): +theorem forall_framing {x: EVar} (phi1 phi2: Pattern x) + (h: $ phi1 -> phi2 $): + $ (forall x phi1) -> forall x phi2 $ = + '(con3 @ exists_framing @ con3 h); + +theorem disjoint_forall: $ phi -> forall x phi $ = '(con2 @ exists_generalization_disjoint id); + +theorem or_exists_fresh {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $): $ (phi1 \/ exists x phi2) <-> exists x (phi1 \/ phi2) $ = '(ibii (eori (syl exists_intro_same_var orl) (exists_generalization eFresh_exists_same_var @ syl exists_intro_same_var orr)) - (exists_generalization (eFresh_or eFresh_disjoint eFresh_exists_same_var) @ eori orl @ orrd exists_intro_same_var)); + (exists_generalization (eFresh_or freshness_phi1 eFresh_exists_same_var) @ eori orl @ orrd exists_intro_same_var)); -theorem imp_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x): +theorem or_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x): + $ (phi1 \/ exists x phi2) <-> exists x (phi1 \/ phi2) $ = + '(or_exists_fresh eFresh_disjoint); + +theorem exists_irrelevance: $ (exists x phi) -> phi $ = '(exists_generalization_disjoint id); + +theorem imp_exists_fresh {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $): $ (phi1 -> exists x phi2) <-> exists x (phi1 -> phi2) $ = '(ibii - (rsyl (imim1 dne) @ rsyl (anl or_exists_disjoint) @ exists_framing @ imim1 notnot1) - (rsyl (exists_framing @ imim1 dne) @ rsyl (anr or_exists_disjoint) @ imim1 notnot1)); + (rsyl (imim1 dne) @ rsyl (anl @ or_exists_fresh @ eFresh_not freshness_phi1) @ exists_framing @ imim1 notnot1) + (rsyl (exists_framing @ imim1 dne) @ rsyl (anr @ or_exists_fresh @ eFresh_not freshness_phi1) @ imim1 notnot1)); + +theorem imp_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x): + $ (phi1 -> exists x phi2) <-> exists x (phi1 -> phi2) $ = + '(imp_exists_fresh eFresh_disjoint); theorem and_exists {x: EVar} (phi1 phi2: Pattern x): $ (exists x (phi1 /\ phi2)) -> ((exists x phi1) /\ (exists x phi2)) $ = @@ -202,14 +228,23 @@ theorem or_exists_bi {x: EVar} (phi1 phi2: Pattern x): $ (exists x (phi1 \/ phi2)) <-> ((exists x phi1) \/ (exists x phi2)) $ = '(ibii or_exists_forwards or_exists_reverse); -theorem and_exists_disjoint_forwards {x: EVar} (phi1: Pattern) (phi2: Pattern x): +theorem and_exists_fresh_forwards {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $): $ (exists x (phi1 /\ phi2)) -> (phi1 /\ exists x phi2) $ = '(iand - (rsyl (exists_framing anl) (exists_generalization_disjoint id)) + (rsyl (exists_framing anl) (exists_generalization freshness_phi1 id)) (exists_framing anr)); +theorem and_exists_disjoint_forwards {x: EVar} (phi1: Pattern) (phi2: Pattern x): + $ (exists x (phi1 /\ phi2)) -> (phi1 /\ exists x phi2) $ = + '(and_exists_fresh_forwards eFresh_disjoint); +theorem and_exists_fresh_reverse {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $): + $ (phi1 /\ exists x phi2) -> (exists x (phi1 /\ phi2)) $ = + '(impcom @ syl (anr @ imp_exists_fresh freshness_phi1) (exists_framing ian2)); theorem and_exists_disjoint_reverse {x: EVar} (phi1: Pattern) (phi2: Pattern x): $ (phi1 /\ exists x phi2) -> (exists x (phi1 /\ phi2)) $ = - '(impcom @ syl (anr imp_exists_disjoint) (exists_framing ian2)); + '(and_exists_fresh_reverse eFresh_disjoint); +theorem and_exists_fresh {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $): + $ (exists x (phi1 /\ phi2)) <-> (phi1 /\ exists x phi2) $ = + '(ibii (and_exists_fresh_forwards freshness_phi1) (and_exists_fresh_reverse freshness_phi1)); theorem and_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x): $ (exists x (phi1 /\ phi2)) <-> (phi1 /\ exists x phi2) $ = '(ibii and_exists_disjoint_forwards and_exists_disjoint_reverse); @@ -258,6 +293,7 @@ do { [$and ,phi1 ,phi2$ '(_eSubst_and ,(propag_e_subst_adv x phi1 wo_x) ,(propag_e_subst_adv x phi2 wo_x))] [$_ceil ,phi$ '(_eSubst_ceil ,(propag_e_subst_adv x phi wo_x))] [$_floor ,phi$ '(_eSubst_floor ,(propag_e_subst_adv x phi wo_x))] + [$_in ,y ,phi$ (if (== x y) '(_eSubst_mem_same_var ,(propag_e_subst_adv x phi wo_x)) '(_eSubst_mem ,(propag_e_subst_adv x phi wo_x)))] [$_subset ,phi1 ,phi2$ '(_eSubst_subset ,(propag_e_subst_adv x phi1 wo_x) ,(propag_e_subst_adv x phi2 wo_x))] [$equiv ,phi1 ,phi2$ '(_eSubst_equiv ,(propag_e_subst_adv x phi1 wo_x) ,(propag_e_subst_adv x phi2 wo_x))] [$_eq ,phi1 ,phi2$ '(_eSubst_eq ,(propag_e_subst_adv x phi1 wo_x) ,(propag_e_subst_adv x phi2 wo_x))] @@ -269,8 +305,6 @@ do { [$epsilon$ 'eSubstitution_disjoint] [$top_letter$ 'eSubstitution_disjoint] - [$a$ 'eSubstitution_disjoint] - [$b$ 'eSubstitution_disjoint] [$top_word ,Y$ 'eSubstitution_disjoint] [$concat ,psi1 ,psi2$ '(_eSubst_concat ,(propag_e_subst_adv x psi1 wo_x) ,(propag_e_subst_adv x psi2 wo_x))] [$nnimp ,phi1 ,phi2$ '(_eSubst_nnimp ,(propag_e_subst_adv x phi1 wo_x) ,(propag_e_subst_adv x phi2 wo_x))] @@ -301,8 +335,6 @@ do { [$epsilon$ 'sSubstitution_disjoint] [$top_letter$ 'sSubstitution_disjoint] - [$a$ 'sSubstitution_disjoint] - [$b$ 'sSubstitution_disjoint] [$concat ,psi1 ,psi2$ '(sSubst_concat ,(propag_s_subst_adv X psi1 wo_X) ,(propag_s_subst_adv X psi2 wo_X))] [$top_word ,Y$ (if (== X Y) 'sSubstitution_in_same_mu 'sSubstitution_disjoint)] [$kleene ,Y ,psi$ (if (== X Y) diff --git a/10-theory-definedness.mm0 b/10-theory-definedness.mm0 index 5117835..96adf04 100644 --- a/10-theory-definedness.mm0 +++ b/10-theory-definedness.mm0 @@ -20,6 +20,30 @@ infixl _in: $in$ prec 35; axiom definedness {x: EVar}: $ |^ eVar x ^| $; +--- Functional Patterns +----------------------- + +def is_func {.x: EVar} (phi: Pattern): Pattern = $ exists x (eVar x == phi) $; + +--- Predicates + +def is_pred (phi: Pattern): Pattern = $ (phi == bot) \/ (phi == top) $; + +--- Domain Quantifiers +---------------------- + +def exists_in {x: EVar} (phi psi: Pattern x): Pattern = $ exists x ((eVar x C= phi) /\ psi) $; +notation exists_in {x: EVar} (phi psi: Pattern x): Pattern = ($E$:0) x ($:$:0) phi ($.$:0) psi; + +def forall_in {x: EVar} (phi psi: Pattern x): Pattern = $ forall x ((eVar x C= phi) -> psi) $; +notation forall_in {x: EVar} (phi psi: Pattern x): Pattern = ($A$:0) x ($:$:0) phi ($.$:0) psi; + + +def is_sorted_pred (phi psi: Pattern): Pattern = $ (psi == bot) \/ (psi == phi) $; + +def is_sorted_func {.x: EVar} (phi psi: Pattern): Pattern = $ E x : phi . eVar x == psi $; + + --- Contextual Implications --------------------------- diff --git a/11-definedness-normalization.mm1 b/11-definedness-normalization.mm1 index 754dda5..2f45a78 100644 --- a/11-definedness-normalization.mm1 +++ b/11-definedness-normalization.mm1 @@ -65,5 +65,5 @@ theorem propag_bot {box: SVar} (ctx: Pattern box): '(syl (! singleton_same_var _ x _ _ (eVar x)) @ iand (framing absurdum) (framing absurdum)); theorem propag_or_def (phi1 phi2: Pattern): - $ |^ phi1 \/ phi2 ^| -> |^ phi1 ^| \/ |^ phi2 ^| $ = - '(norm (norm_imp defNorm (norm_or defNorm defNorm)) (! propag_or x)); + $ |^ phi1 \/ phi2 ^| <-> |^ phi1 ^| \/ |^ phi2 ^| $ = + '(ibii (norm (norm_imp defNorm (norm_or defNorm defNorm)) (! propag_or x)) @ eori (framing_def orl) (framing_def orr)); diff --git a/12-proof-system-p.mm1 b/12-proof-system-p.mm1 index a66b8b5..eb7e00b 100644 --- a/12-proof-system-p.mm1 +++ b/12-proof-system-p.mm1 @@ -14,6 +14,10 @@ theorem eFresh_ceil {x: EVar} (phi: Pattern x) (h: $ _eFresh x phi $): $ _eFresh x (|^ phi ^|) $ = '(eFresh_app eFresh_disjoint h); +theorem eFresh_floor {x: EVar} (phi: Pattern x) + (h: $ _eFresh x phi $): + $ _eFresh x (|_ phi _|) $ = + '(eFresh_not @ eFresh_app eFresh_disjoint @ eFresh_not h); theorem eFresh_mem {x y: EVar} (phi: Pattern x y) (h: $ _eFresh x phi $): $ _eFresh x (y in phi) $ = @@ -21,6 +25,11 @@ theorem eFresh_mem {x y: EVar} (phi: Pattern x y) theorem eFresh_ctximp_same_var {box: SVar} (ctx phi: Pattern box): $ _eFresh x (ctximp_app box ctx phi) $ = '(eFresh_exists_same_var); +theorem eFresh_subset {x: EVar} (phi psi: Pattern x) + (h1: $ _eFresh x phi $) + (h2: $ _eFresh x psi $): + $ _eFresh x (phi C= psi) $ = + '(eFresh_not @ eFresh_ceil @ eFresh_not @ eFresh_imp h1 h2); theorem sFresh_ceil {X: SVar} (phi: Pattern X) (h: $ _sFresh X phi $): @@ -39,6 +48,10 @@ theorem _eSubst_floor {x: EVar} (phi psi rho: Pattern x) (h: $ Norm (e[ phi / x ] psi) rho $): $ Norm (e[ phi / x ] (|_ psi _|)) (|_ rho _|) $ = '(_eSubst_not @ _eSubst_ceil @ _eSubst_not h); +theorem _eSubst_mem {x y: EVar} (phi phi2 psi2: Pattern x y) + (h: $ Norm (e[ phi / x ] phi2) psi2 $): + $ Norm (e[ phi / x ] (y in phi2)) (y in psi2) $ = + '(_eSubst_ceil @ _eSubst_and eSubstitution_disjoint h); theorem _eSubst_mem_same_var {x: EVar} (phi phi2 psi2: Pattern x) (h: $ Norm (e[ phi / x ] phi2) psi2 $): $ Norm (e[ phi / x ] (x in phi2)) (|^ phi /\ psi2 ^|) $ = @@ -100,6 +113,19 @@ theorem propag_exists_def {x: EVar} (phi: Pattern x): $ |^ exists x phi ^| -> exists x (|^ phi ^|) $ = '(norm (norm_imp defNorm @ norm_exists defNorm) (! propag_exists_disjoint box)); +theorem swap_exists {x y: EVar} (phi: Pattern x y): $ exists x (exists y phi) -> exists y (exists x phi) $ = + '(exists_generalization (eFresh_exists eFresh_exists_same_var) @ exists_framing exists_intro_same_var); + +theorem swap_exists_bi {x y: EVar} (phi: Pattern x y): $ exists x (exists y phi) <-> exists y (exists x phi) $ = + '(ibii swap_exists swap_exists); + + +theorem swap_forall {x y: EVar} (phi: Pattern x y): $ forall x (forall y phi) -> forall y (forall x phi) $ = + '(con3 @ rsyl (exists_framing dne) @ rsyl swap_exists @ exists_framing notnot1); + +theorem swap_forall_bi {x y: EVar} (phi: Pattern x y): $ forall x (forall y phi) <-> forall y (forall x phi) $ = + '(ibii swap_forall swap_forall); + theorem prop_43_bot (rho: Pattern): $ bot -> rho $ = 'absurdum; theorem prop_43_or {box: SVar} (ctx: Pattern box) (phi1 phi2: Pattern): $ (app[ phi1 / box ] ctx \/ app[ phi2 / box ] ctx) -> app[ phi1 \/ phi2 / box ] ctx $ = @@ -108,6 +134,16 @@ theorem prop_43_exists {box: SVar} {x: EVar} (ctx: Pattern box) (phi: Pattern bo $ (exists x (app[ phi / box ] ctx)) -> app[ exists x phi / box ] ctx $ = '(exists_generalization (eFresh_appCtx eFresh_disjoint eFresh_exists_same_var) (framing exists_intro_same_var)); +theorem prop_43_exists_var_in_ctx {box: SVar} {x: EVar} (ctx phi: Pattern box x): + $ (exists x (app[ phi / box ] ctx)) -> exists x (app[ exists x phi / box ] ctx) $ = + '(exists_framing @ framing exists_intro_same_var); + +theorem prop_43_exists_fresh {box: SVar} {x: EVar} (ctx phi: Pattern box x) + (ctx_fresh: $ _eFresh x ctx $): + $ (exists x (app[ phi / box ] ctx)) -> app[ exists x phi / box ] ctx $ = + '(exists_generalization (eFresh_appCtx ctx_fresh eFresh_exists_same_var) (framing exists_intro_same_var)); + + theorem exists_appCtx {x: EVar} {box: SVar} (ctx: Pattern box) (phi: Pattern x): $ (app[ exists x phi / box ] ctx) <-> exists x (app[ phi / box ] ctx) $ = '(ibii propag_exists_disjoint prop_43_exists); @@ -128,6 +164,13 @@ theorem prop_43_exists_def {x: EVar} (phi: Pattern x): $ (exists x (|^ phi ^|)) -> |^ exists x phi ^| $ = '(exists_generalization (eFresh_app eFresh_disjoint eFresh_exists_same_var) (framing_def exists_intro_same_var)); + +theorem forall_floor {x: EVar} (phi: Pattern x): + $ |_ forall x phi _| <-> forall x (|_ phi _|) $ = + '(ian + (con3 @ rsyl (exists_framing dne) @ rsyl prop_43_exists_def @ framing_def notnot1) + (con3 @ rsyl (framing_def dne) @ rsyl propag_exists_def @ exists_framing notnot1)); + do { (def (ex_appCtx_subst subst) '(norm (norm_equiv ,subst @ norm_exists ,subst) exists_appCtx)) (def (or_appCtx_subst subst) '(norm (norm_equiv ,subst @ norm_or ,subst ,subst) or_appCtx)) @@ -136,6 +179,10 @@ do { (def (framing_subst hyp subst) '(norm (norm_imp ,subst ,subst) @ framing ,hyp)) }; +do { + (def (exists_intro_subst subst) '(norm (norm_imp_l ,subst) exists_intro)) +}; + theorem exists_intro_l_bi_disjoint {x: EVar} (phi: Pattern x) (psi: Pattern) (h: $ phi <-> psi $): $ (exists x phi) <-> psi $ = @@ -146,9 +193,13 @@ theorem exists_intro_l_bi_disjoint {x: EVar} (phi: Pattern x) (psi: Pattern) theorem propag_and_floor: $|_ phi /\ psi _| <-> |_ phi _| /\ |_ psi _|$ = '(ibii (iand (framing_floor anl) (framing_floor anr)) - (rsyl (anr notor) @ rsyl (con3 propag_or_def) @ con3 @ framing_def @ anl notan) + (rsyl (anr notor) @ rsyl (con3 @ anl propag_or_def) @ con3 @ framing_def @ anl notan) ); +theorem prop_43_or_def_rev (phi1 phi2: Pattern): + $ |^ phi1 \/ phi2 ^| -> (|^ phi1 ^| \/ |^ phi2 ^|) $ = + '(syl (orim (framing_def dne) (framing_def dne)) @ rsyl (framing_def @ orim notnot1 notnot1) @ con4 @ rsyl (anl notor) @ rsyl (anr propag_and_floor) @ con3 @ framing_def (anr notan)); + theorem appCtxLR {box: SVar} (phi2 phi3: Pattern) (phi1 phi4: Pattern box): $ Norm (app[ phi1 / box ] (app (app phi3 phi4) phi2)) (app (app phi3 (app[ phi1 / box ] phi4)) phi2) $ = '(norm_trans appCtxL_disjoint @ norm_app_l appCtxR_disjoint); @@ -161,6 +212,9 @@ theorem appCtxRVar {box: SVar} (phi1 phi2: Pattern): theorem appCtxLRVar {box: SVar} (phi1 phi2 phi3: Pattern): $ Norm (app[ phi1 / box ] (app (app phi3 (sVar box)) phi2)) (app (app phi3 phi1) phi2) $ = '(norm_trans appCtxL_disjoint @ norm_app appCtxRVar norm_refl); +theorem appCtxRLRVar {box: SVar} (phi1 phi2 phi3 phi4: Pattern): + $ Norm (app[ phi1 / box ] (app phi4 (app (app phi3 (sVar box)) phi2))) (app phi4 (app (app phi3 phi1) phi2)) $ = + '(norm_trans appCtxR_disjoint @ norm_app norm_refl appCtxLRVar); theorem app_framing_l (h: $phi1 -> phi2$): $(app phi1 psi) -> (app phi2 psi)$ = '(norm (norm_imp appCtxLVar appCtxLVar) (! framing box _ _ _ h)); @@ -192,6 +246,9 @@ theorem cong_of_equiv_app (h1: $phi1 <-> phi2$) (h2: $psi1 <-> psi2$): $(app phi theorem cong_of_equiv_exists {x: EVar} (phi1 phi2: Pattern x) (h: $ phi1 <-> phi2 $): $ (exists x phi1) <-> (exists x phi2) $ = '(iani (exists_framing @ anl h) (exists_framing @ anr h)); +theorem cong_of_equiv_forall {x: EVar} (phi1 phi2: Pattern x) + (h: $ phi1 <-> phi2 $): $ (forall x phi1) <-> (forall x phi2) $ = + '(cong_of_equiv_not @ cong_of_equiv_exists @ cong_of_equiv_not h); theorem cong_of_equiv_sSubst_ctx {X: SVar} (phi phi1 phi2: Pattern X) (h: $ phi1 <-> phi2 $): $ (s[ phi / X ] phi1) <-> (s[ phi / X ] phi2) $ = '(ibii (sSubst_ctx_framing @ anl h) @@ -223,11 +280,6 @@ theorem cong_of_equiv_mem {x: EVar} (phi1 phi2: Pattern x) theorem cong_of_equiv_eq (h1: $phi1 <-> phi2$) (h2: $psi1 <-> psi2$): $(phi1 == psi1) <-> (phi2 == psi2)$ = '(cong_of_equiv_not @ cong_of_equiv_def @ cong_of_equiv_not @ cong_of_equiv_equiv h1 h2); -do { - (def (cong_eq_lift pf to_eq) '(equiv_to_eq @ ,pf (corollary_57_floor ,to_eq))) - (def (cong_eq_lift2 pf to_eq1 to_eq2) '(equiv_to_eq @ ,pf (corollary_57_floor ,to_eq1) (corollary_57_floor ,to_eq2))) -}; - theorem univ_gene {x: EVar} (phi: Pattern x) (p: $ phi $): $ forall x phi $ = '(exists_generalization_disjoint @ notnot1 p); @@ -237,24 +289,61 @@ theorem var_subst {x y: EVar} (phi: Pattern x y): theorem var_subst_same_var {x: EVar} (phi: Pattern x): $ (forall x phi) -> phi $ = '(con1 exists_intro_same_var); + +theorem imp_forall_fresh {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $): + $ (phi1 -> forall x phi2) <-> forall x (phi1 -> phi2) $ = + '(con2b @ bitr (cong_of_equiv_exists @ con3b @ imeq2i notnot) @ and_exists_fresh freshness_phi1); + +theorem imp_r_forall_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x): + $ (phi1 -> forall x phi2) <-> forall x (phi1 -> phi2) $ = + '(imp_forall_fresh eFresh_disjoint); + +theorem or_r_forall_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x): + $ (phi1 \/ forall x phi2) <-> forall x (phi1 \/ phi2) $ = 'imp_r_forall_disjoint; + +theorem and_r_forall_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x): + $ (phi1 /\ forall x phi2) <-> forall x (phi1 /\ phi2) $ = + '(con3b @ bitr (cong_of_equiv_imp_r @ bicom notnot) @ bitr imp_exists_disjoint @ cong_of_equiv_exists notnot); + +theorem forall_ceil {x: EVar} (phi: Pattern x): + $ |^ forall x phi ^| -> forall x (|^ phi ^|) $ = + '(anr (imp_forall_fresh @ eFresh_ceil eFresh_forall_same_var) @ univ_gene @ framing_def var_subst_same_var); + + +theorem and_forall {x: EVar} (phi psi: Pattern x): + $ (forall x (phi /\ psi)) <-> (forall x phi) /\ (forall x psi) $ = + '(ibii + (iand (forall_framing anl) (forall_framing anr)) @ + anr (imp_forall_fresh @ eFresh_and eFresh_forall_same_var eFresh_forall_same_var) @ + univ_gene @ + anim var_subst_same_var var_subst_same_var); + +theorem forall_imp_distr {x: EVar} (phi psi: Pattern x): + $ (forall x (phi -> psi)) -> (forall x phi) -> (forall x psi) $ = + '(exp @ rsyl (anr and_forall) (forall_framing (rsyl ancom appl))); + +theorem s_forall_imp_distr {x: EVar} (phi psi rho: Pattern x): + $ (forall x (rho -> (phi -> psi))) -> (forall x (rho -> phi)) -> (forall x (rho -> psi)) $ = + '(rsyl (forall_framing prop_2) forall_imp_distr); + theorem lemma_46 (phi: Pattern) {box: SVar} (ctx: Pattern box) (p : $ phi $): $ ~ (app[ (~ phi) / box ] ctx) $ = '(syl propag_bot @ framing @ notnot1 p); -theorem lemma_46_floor - (h: $phi$) -: $|_ phi _|$ -= '(norm (norm_not @ ! defNorm box) @ lemma_46 h); +theorem lemma_46_floor (h: $ phi $): $ |_ phi _| $ = + '(norm (norm_not @ ! defNorm box) @ lemma_46 h); theorem imp_to_subset (h: $ phi -> psi $): $ phi C= psi $ = '(lemma_46_floor h); theorem equiv_to_eq (h: $ phi <-> psi $): $ phi == psi $ = '(lemma_46_floor h); theorem eq_imp_subset: $ (phi == psi) -> (phi C= psi) $ = '(framing_floor anl); theorem subset_to_eq: $ (phi C= psi) -> (psi C= phi) -> (phi == psi) $ = '(exp @ anr propag_and_floor); +theorem subset_refl: $ phi C= phi $ = '(imp_to_subset id); + theorem eq_refl: $ phi == phi $ = '(equiv_to_eq biid); theorem functional_same_var: $ exists x (eVar x == eVar x) $ = '(exists_intro_same_var eq_refl); -theorem functional_var: $ exists x (eVar x == eVar y) $ = - '(exists_intro @ norm (norm_sym @ _eSubst_eq eSubstitution_in_same_eVar eSubstitution_disjoint) eq_refl); +theorem functional_var: $ is_func (eVar x) $ = + (named '(exists_intro @ norm (norm_sym @ _eSubst_eq eSubstitution_in_same_eVar eSubstitution_disjoint) eq_refl)); theorem eq_sym: $ (phi1 == phi2) -> (phi2 == phi1) $ = '(con3 @ framing_def @ con3 bicom); @@ -266,9 +355,20 @@ theorem subset_imp_subset_or_r: $(phi C= psi) -> (phi C= (rho \/ psi))$ = '(framing_floor @ imim2i orr); +theorem subset_imp_or_subset_l: + $(phi C= psi) -> ((psi \/ phi) C= psi)$ = + '(framing_floor @ eor id); +theorem subset_imp_or_subset_r: + $(phi C= psi) -> ((phi \/ psi) C= psi)$ = + '(framing_floor @ com12 eor id); + theorem subset_and: $ (phi C= (psi1 /\ psi2)) -> (phi C= psi1) /\ (phi C= psi2) $ = '(iand (framing_subset id anl) (framing_subset id anr)); +theorem and_subset: $ (phi1 C= psi) /\ (phi2 C= psi) <-> (phi1 \/ phi2 C= psi) $ = + '(ibii (rsyl (anr propag_and_floor) @ framing_floor @ curry eor) @ + iand (framing_floor @ imim1 orl) (framing_floor @ imim1 orr)); + theorem taut_equiv_top (h: $ phi $): $ phi <-> top $ = '(ibii imp_top @ a1i h); theorem taut_and_equiv (h: $ phi $): $ phi /\ psi <-> psi $ = @@ -278,16 +378,6 @@ theorem taut_is_top (h: $ phi $): $ phi == top $ = theorem absurd_and_equiv_bot (h: $ ~ phi $): $ phi /\ psi <-> bot $ = '(ibii (syl h anl) absurdum); -theorem membership_intro_implicit {x: EVar} (phi: Pattern x) - (h: $ phi $): - $ x in phi $ = - '(framing_def (iand id (a1i h)) definedness); - -theorem membership_intro {x: EVar} (phi: Pattern x) - (h: $ phi $): - $ forall x (x in phi) $ = - '(univ_gene @ membership_intro_implicit h); - theorem membership_elim {x: EVar} (phi: Pattern) (h: $ forall x (x in phi) $): $ phi $ = @@ -306,7 +396,7 @@ theorem membership_var_forward {x y: EVar}: $ (x in (eVar y)) -> (eVar x == eVar @ norm (norm_imp defNorm norm_refl) (! framing box _ _ _ @ anr lemma_51)); theorem membership_var_reverse {x y: EVar}: $ (eVar x == eVar y) -> (x in (eVar y)) $ - = '(propag_or_def @ framing_def or_imp_xor_and @ norm defNorm @ prop_43_or @ norm (norm_sym @ norm_or defNorm (! defNorm box)) @ orl definedness); + = '(anl propag_or_def @ framing_def or_imp_xor_and @ norm defNorm @ prop_43_or @ norm (norm_sym @ norm_or defNorm (! defNorm box)) @ orl definedness); theorem membership_var_bi {x y: EVar}: $ (x in (eVar y)) <-> (eVar x == eVar y) $ = '(iani membership_var_forward membership_var_reverse); @@ -320,7 +410,7 @@ theorem membership_not_forward {x: EVar} (phi: Pattern x): $(x in ~phi) -> ~(x in phi) $ = '(con2 @ dne singletonDef); theorem membership_not_reverse {x: EVar} (phi: Pattern x): $~(x in phi) -> (x in ~phi) $ = - '(propag_or_def @ framing_def (exp @ iand anl @ curry @ com12 dne) definedness); + '(anl propag_or_def @ framing_def (exp @ iand anl @ curry @ com12 dne) definedness); theorem membership_not_bi {x: EVar} (phi: Pattern x): $ (x in ~phi) <-> ~(x in phi) $ = '(iani membership_not_forward membership_not_reverse); @@ -415,6 +505,20 @@ theorem eVars_subset_eq {x y: EVar}: $ (eVar x C= eVar y) <-> (eVar x == eVar y) $ = '(ibii eVars_subset_eq_forward eVars_subset_eq_reverse); +theorem membership_intro_implicit_imp {x: EVar} (phi: Pattern x): + $ |_ phi _| -> x in phi $ = + '(syl eVar_in_subset_reverse @ framing_floor prop_1); + +theorem membership_intro_implicit {x: EVar} (phi: Pattern x) + (h: $ phi $): + $ x in phi $ = + '(membership_intro_implicit_imp @ lemma_46_floor h); + +theorem membership_intro {x: EVar} (phi: Pattern x) + (h: $ phi $): + $ forall x (x in phi) $ = + '(univ_gene @ membership_intro_implicit h); + theorem lemma_exists_and: $ phi <-> exists x (eVar x /\ phi) $ = '(ibii (rsyl notnot1 @ anr or_exists_disjoint @ exists_framing @@ -432,7 +536,7 @@ theorem lemma_56 {box: SVar} (phi ctx: Pattern box) '(rsyl (rsyl (framing @ anl lemma_exists_and) @ propag_exists eFresh_disjoint) (exists_generalization eFresh_disjoint @ rsyl (dne @ singleton_norm norm_refl (! defNorm box2)) - (propag_or_def @ framing_def (anl com12b @ rsyl dne @ imim2i dne) (! definedness x)) + (anl propag_or_def @ framing_def (anl com12b @ rsyl dne @ imim2i dne) (! definedness x)) )); theorem corollary_57_ceil (phi: Pattern): $ phi -> |^ phi ^| $ = @@ -454,7 +558,7 @@ theorem lemma_60_forward {x: EVar} {box: SVar} (ctx phi1 phi2: Pattern box x): '(iand (framing anl) @ rsyl (framing anr) @ rsyl (norm ( norm_imp (norm_trans appCtxNested_disjoint @ norm_ctxApp_pt norm_refl (! defNorm box1)) @ norm_not (! defNorm box2) - ) @ dne singleton) @ propag_or_def @ framing_def lemma_60_helper_1 definedness); + ) @ dne singleton) @ anl propag_or_def @ framing_def lemma_60_helper_1 definedness); theorem lemma_60_reverse {x: EVar} {box: SVar} (ctx phi2: Pattern box x) (phi1: Pattern x): $ ((app[ phi1 / box ] ctx) /\ (x in phi2)) -> app[ phi1 /\ (x in phi2) / box ] ctx $ = @@ -539,7 +643,7 @@ theorem lemma_14 {box: SVar} (ctx psi phi1 phi2: Pattern box) (imim2 @ norm (norm_imp_l @ norm_trans appCtxNested_disjoint @ norm_ctxApp_pt norm_refl defNorm) (! lemma_56 box2)) ); -theorem appCtx_pointwise {box: SVar} (ctx: Pattern box) (phi: Pattern): +theorem appCtx_pointwise {box: SVar} {x: EVar} (ctx: Pattern box) (phi: Pattern): $ app[ phi / box ] ctx <-> exists x ((app[ eVar x / box ] ctx) /\ x in phi) $ = '(bitr (cong_of_equiv_appCtx (bicom lemma_62)) @ bitr exists_appCtx @ @@ -552,6 +656,15 @@ do { -- Equality reasoning +do { + (def (cong_eq_lift pf to_eq) '(equiv_to_eq @ ,pf (corollary_57_floor ,to_eq))) + (def (cong_eq_lift2 pf to_eq1 to_eq2) '(equiv_to_eq @ ,pf (corollary_57_floor ,to_eq1) (corollary_57_floor ,to_eq2))) +}; + +theorem cong_of_eq_exists {x: EVar} (phi1 phi2: Pattern x) + (h: $ phi1 == phi2 $): $ (exists x phi1) == (exists x phi2) $ = + (cong_eq_lift 'cong_of_equiv_exists 'h); + theorem in_refl: $ x in eVar x $ = '(framing_def (iand id id) definedness); @@ -651,10 +764,15 @@ theorem eq_to_app $ (phi1 == phi2) -> ((app psi1 rho1) -> (app psi2 rho2)) $ = '(syld (eq_to_app_l h1) (eq_to_app_r h2)); -theorem eq_to_exists {x: EVar} (phi1 phi2: Pattern) (psi1 psi2: Pattern x) - (h: $ (phi1 == phi2) -> (psi1 -> psi2) $): - $ (phi1 == phi2) -> ((exists x psi1) -> (exists x psi2)) $ = - '(exp @ rsyl and_exists_disjoint_reverse @ exists_framing @ curry h); +theorem eq_to_exists_fresh {x: EVar} (phi psi1 psi2: Pattern x) + (freshness: $_eFresh x phi$) + (h: $ phi -> (psi1 -> psi2) $): + $ phi -> ((exists x psi1) -> (exists x psi2)) $ = + '(exp @ rsyl (and_exists_fresh_reverse freshness) @ exists_framing @ curry h); +theorem eq_to_exists {x: EVar} (phi: Pattern) (psi1 psi2: Pattern x) + (h: $ phi -> (psi1 -> psi2) $): + $ phi -> ((exists x psi1) -> (exists x psi2)) $ = + '(eq_to_exists_fresh eFresh_disjoint h); do { (def (bi_lift pf to_equiv) '(iand (,pf @ syl anl ,to_equiv) (,pf @ syl anr ,to_equiv))) @@ -756,14 +874,22 @@ theorem eq_to_eq_r_bi (h: $ (phi1 == phi2) -> (psi1 <-> psi2) $): $ (phi1 == phi2) -> ((rho == psi1) <-> (rho == psi2)) $ = '(eq_to_eq_bi eq_to_id_bi h); -theorem eq_to_exists_bi {x: EVar} (phi1 phi2: Pattern) (psi1 psi2: Pattern x) - (h: $ (phi1 == phi2) -> (psi1 <-> psi2) $): - $ (phi1 == phi2) -> ((exists x psi1) <-> (exists x psi2)) $ = (bi_lift 'eq_to_exists 'h); +theorem eq_to_exists_bi_fresh {x: EVar} (phi psi1 psi2: Pattern x) + (freshness: $ _eFresh x phi $) + (h: $ phi -> (psi1 <-> psi2) $): + $ phi -> ((exists x psi1) <-> (exists x psi2)) $ = '(iand (eq_to_exists_fresh freshness @ syl anl h) (eq_to_exists_fresh freshness @ syl anr h)); +theorem eq_to_exists_bi {x: EVar} (phi: Pattern) (psi1 psi2: Pattern x) + (h: $ phi -> (psi1 <-> psi2) $): + $ phi -> ((exists x psi1) <-> (exists x psi2)) $ = '(eq_to_exists_bi_fresh eFresh_disjoint h); theorem eq_to_forall_bi {x: EVar} (phi1 phi2: Pattern) (psi1 psi2: Pattern x) (h: $ (phi1 == phi2) -> (psi1 <-> psi2) $): $ (phi1 == phi2) -> ((forall x psi1) <-> (forall x psi2)) $ = '(eq_to_not_bi @ eq_to_exists_bi @ eq_to_not_bi h); +theorem eq_to_func_bi + (h: $ (phi1 == phi2) -> (psi1 <-> psi2) $): + $ (phi1 == phi2) -> ((is_func psi1) <-> (is_func psi2)) $ = (named '(eq_to_exists_bi @ eq_to_eq_r_bi h)); + theorem eq_to_mem_bi {x: EVar} (phi1 phi2 psi1 psi2: Pattern x) (h: $ (phi1 == phi2) -> (psi1 <-> psi2) $): $ (phi1 == phi2) -> ((x in psi1) <-> (x in psi2)) $ = @@ -806,11 +932,11 @@ theorem lemma_in_in_forward_same_var {x: EVar} (phi: Pattern x): '(syl ceil_mem_imp_mem @ framing_def anr); theorem lemma_in_in_reverse {x y: EVar} (phi: Pattern x y): $ (y in phi) -> x in (y in phi) $ = - '(rsyl mem_imp_floor_mem @ propag_or_def @ + '(rsyl mem_imp_floor_mem @ anl propag_or_def @ framing_def lemma_in_in_reverse_helper @ prop_43_or_def @ orr definedness); theorem lemma_in_in_reverse_same_var {x: EVar} (phi: Pattern x): $ (x in phi) -> x in (x in phi) $ = - '(rsyl mem_imp_floor_mem @ propag_or_def @ + '(rsyl mem_imp_floor_mem @ anl propag_or_def @ framing_def lemma_in_in_reverse_helper @ prop_43_or_def @ orr definedness); theorem lemma_in_in {x y: EVar} (phi: Pattern x y): @@ -865,7 +991,7 @@ theorem membership_forall {x y: EVar} (phi: Pattern x y): theorem floor_imp_mem {x: EVar} (phi: Pattern x): $ |_ phi _| -> x in phi $ = - '(propag_or_def @ framing_def (imim1i dne) @ framing_def ian definedness); + '(anl propag_or_def @ framing_def (imim1i dne) @ framing_def ian definedness); theorem mem_floor_forward {x: EVar} (phi: Pattern x): $ (x in |_ phi _|) -> |_ phi _| $ = @@ -900,6 +1026,44 @@ theorem floor_ceil_ceil: $ |_ |^ phi ^| _| <-> |^ phi ^| $ = theorem simple_eq_subst: $ phi /\ (phi == psi) -> psi $ = '(rsyl ancom @ curry eq_to_intro); + +theorem appCtx_ceil_commute {box: SVar} (ctx: Pattern box) (phi psi: Pattern): + $ app[ phi /\ |^ psi ^| / box ] ctx -> app[ phi / box ] ctx /\ |^ psi ^| $ = + '(iand (framing anl) @ rsyl (framing anr) ceil_appCtx); +theorem appCtx_ceil_commute_b {box: SVar} (ctx: Pattern box) (phi psi: Pattern): + $ app[ |^ psi ^| /\ phi / box ] ctx -> |^ psi ^| /\ app[ phi / box ] ctx $ = + '(iand (rsyl (framing anl) ceil_appCtx) @ framing anr); +theorem appCtx_floor_commute {box: SVar} (ctx: Pattern box) (phi psi: Pattern): + $ app[ phi /\ |_ psi _| / box ] ctx -> app[ phi / box ] ctx /\ |_ psi _| $ = + '(rsyl (framing @ anim2 @ anr ceil_floor_floor) @ rsyl appCtx_ceil_commute @ anim2 @ anl ceil_floor_floor); +theorem appCtx_floor_commute_b {box: SVar} (ctx: Pattern box) (phi psi: Pattern): + $ app[ |_ psi _| /\ phi / box ] ctx -> |_ psi _| /\ app[ phi / box ] ctx $ = + '(rsyl (framing @ anim1 @ anr ceil_floor_floor) @ rsyl appCtx_ceil_commute_b @ anim1 @ anl ceil_floor_floor); + +do { + (def (appCtx_ceil_commute_subst subst) '(norm (norm_imp ,subst @ norm_and_l ,subst) appCtx_ceil_commute)) + (def (appCtx_ceil_commute_b_subst subst) '(norm (norm_imp ,subst @ norm_and_r ,subst) appCtx_ceil_commute_b)) + (def (appCtx_floor_commute_subst subst) '(norm (norm_imp ,subst @ norm_and_l ,subst) appCtx_floor_commute)) + (def (appCtx_floor_commute_b_subst subst) '(norm (norm_imp ,subst @ norm_and_r ,subst) appCtx_floor_commute_b)) +}; + + +theorem floor_appCtx_dual (phi: Pattern) {box: SVar} (ctx: Pattern box): + $ |_ phi _| -> ~ (app[ (~ (|_ phi _|)) / box ] ctx) $ = + '(exp @ rsyl (anim2 @ syl ceil_appCtx @ framing dne) @ notnot1 id); + +theorem ceil_appCtx_dual (phi: Pattern) {box: SVar} (ctx: Pattern box): + $ |^ phi ^| -> ~ (app[ (~ (|^ phi ^|)) / box ] ctx) $ = + '(rsyl (anr floor_ceil_ceil) @ rsyl floor_appCtx_dual @ con3 @ framing @ con3 @ anl floor_ceil_ceil); + +theorem floor_imp_in_appCtx (phi psi: Pattern) {box: SVar} (ctx: Pattern box): + $ (app[ |_ phi _| -> psi / box ] ctx) -> |_ phi _| -> app[ psi / box ] ctx $ = + '(exp @ rsyl (anim propag_or floor_appCtx_dual) @ rsyl (anl andir) @ eori (syl absurdum @ rsyl (anim1 @ framing notnot1) @ notnot1 notnot1) anl); + +do { + (def (floor_imp_in_appCtx_subst subst) '(norm (norm_imp ,subst @ norm_imp_r ,subst) floor_imp_in_appCtx)) +}; + theorem alpha_exists {x y: EVar} (phi: Pattern x y) (y_fresh: $ _eFresh y phi $): $ (exists x phi) <-> exists y (e[ eVar y / x ] phi) $ = @@ -916,20 +1080,24 @@ theorem alpha_exists_disjoint {x y: EVar} (phi: Pattern x): $ (exists x phi) <-> exists y (e[ eVar y / x ] phi) $ = '(alpha_exists eFresh_disjoint); -theorem subset_imp_subset_framing {box: SVar} (ctx phi psi: Pattern box): +theorem imp_subset_framing {box: SVar} (ctx phi psi: Pattern box): $ (phi C= psi) -> ((app[ phi / box ] ctx) C= (app[ psi / box ] ctx)) $ = '(rsyl (anr floor_idem) @ framing_floor @ lemma_14 subset_to_imp); -theorem eq_imp_eq_framing {box: SVar} (ctx phi psi: Pattern box): +theorem imp_eq_framing {box: SVar} (ctx phi psi: Pattern box): $ (phi == psi) -> ((app[ phi / box ] ctx) == (app[ psi / box ] ctx)) $ = - '(rsyl (iand eq_imp_subset @ rsyl eq_sym eq_imp_subset) @ rsyl (anim subset_imp_subset_framing subset_imp_subset_framing) @ curry subset_to_eq); + '(rsyl (iand eq_imp_subset @ rsyl eq_sym eq_imp_subset) @ rsyl (anim imp_subset_framing imp_subset_framing) @ curry subset_to_eq); do { - (def (subset_imp_subset_framing_subst subst) '(norm (norm_imp_r @ norm_subset ,subst ,subst) subset_imp_subset_framing)) - (def (eq_imp_eq_framing_subst subst) '(norm (norm_imp_r @ norm_eq ,subst ,subst) eq_imp_eq_framing)) + (def (imp_subset_framing_subst subst) '(norm (norm_imp_r @ norm_subset ,subst ,subst) (!! imp_subset_framing box))) + (def (imp_eq_framing_subst subst) '(norm (norm_imp_r @ norm_eq ,subst ,subst) imp_eq_framing)) }; - do { + (def (appCtx_constructor path) @ if (null? path) 'appCtxVar @ if {(hd path) = 0} + '(norm_trans appCtxL_disjoint @ norm_app ,(appCtx_constructor (tl path)) norm_refl) + '(norm_trans appCtxR_disjoint @ norm_app norm_refl ,(appCtx_constructor (tl path))) + ) + (def (cong_of_equiv_propag x equiv_pf ctx) @ match ctx [$eVar ,y$ (if (== x y) equiv_pf 'biid)] [$exists ,y ,psi$ (if (== x y) 'biid '(cong_of_equiv_exists ,(cong_of_equiv_propag x equiv_pf psi)))] @@ -953,6 +1121,7 @@ do { [_ 'biid] ) +-- x = phi -> C[x] <-> C[phi] (def (func_subst_explicit_helper x ctx) @ match ctx [$eVar ,y$ (if (== x y) 'eq_to_intro_bi 'eq_to_id_bi)] [$exists ,y ,psi$ (if (== x y) 'eq_to_id_bi '(eq_to_exists_bi ,(func_subst_explicit_helper x psi)))] @@ -968,6 +1137,9 @@ do { [$_subset ,phi1 ,phi2$ '(eq_to_subset_bi ,(func_subst_explicit_helper x phi1) ,(func_subst_explicit_helper x phi2))] [$equiv ,phi1 ,phi2$ '(eq_to_equiv_bi ,(func_subst_explicit_helper x phi1) ,(func_subst_explicit_helper x phi2))] [$_eq ,phi1 ,phi2$ '(eq_to_eq_bi ,(func_subst_explicit_helper x phi1) ,(func_subst_explicit_helper x phi2))] + [$is_func ,psi$ '(eq_to_func_bi ,(func_subst_explicit_helper x psi))] + [$bot$ 'eq_to_id_bi] + [$top$ 'eq_to_id_bi] [$nnimp ,phi1 ,phi2$ '(eq_to_nnimp_bi ,(func_subst_explicit_helper x phi1) ,(func_subst_explicit_helper X phi2))] [$concat ,phi1 ,phi2$ '(eq_to_concat_bi ,(func_subst_explicit_helper x phi1) ,(func_subst_explicit_helper x phi2))] @@ -976,15 +1148,47 @@ do { [_ 'eq_to_id_bi] ) +-- C[phi] -> x = phi -> C[x] (def (func_subst_imp_to_var x ctx) '(com12 @ syl anr ,(func_subst_explicit_helper x ctx))) +-- x = phi /\ C[phi] -> C[x] + (def (func_subst_imp_to_var_variant x ctx) '(curry @ syl anr ,(func_subst_explicit_helper x ctx))) + +-- forall x . phi1[x] +-- exists y . y = phi2 +---------------------- +-- phi1[phi2] (def (func_subst_explicit x y phi1 forall_x_phi1 func_phi2) '( exists_generalization_disjoint (mp (com12 @ syl anl ,(func_subst_explicit_helper x phi1)) (norm ,(propag_e_subst x phi1) (! var_subst ,x ,y ,phi1 ,forall_x_phi1))) ,func_phi2 )) +-- (exists y . y = phi2) -> (forall x . phi1[x]) -> phi1[phi2] + (def (func_subst_explicit_thm x phi1) '( + exists_generalization_disjoint (com12 (syl (com12 @ syl anl ,(func_subst_explicit_helper x phi1)) (norm (norm_imp_r ,(propag_e_subst x phi1)) (! var_subst ,x)))) + )) + +-- (s_exists y:S . y = phi2) -> (s_forall x:S . phi1[x]) -> phi1[phi2] + (def (func_subst_explicit_thm_sorted x phi1) '( + rsyl (iand domain_func_sorting @ exists_framing anr) @ rsyl (anim2 @ rsyl ,(func_subst_explicit_thm x phi1) @ anl com12b) appl + )) + +-- C[x] +-- exists x . x = phi2 +---------------------- +-- C[phi] (def (func_subst x phi1 phi1_pf func_phi2) '( exists_generalization_disjoint (mp (com12 @ syl anl ,(func_subst_explicit_helper x phi1)) ,phi1_pf) ,func_phi2 )) + +-- C[phi2] -> exists x . C[x] + (def (func_subst_alt x phi1 func_phi2) '( + anr imp_exists_disjoint (mp (exists_framing @ syl anr ,(func_subst_explicit_helper x phi1)) ,func_phi2) + )) + +-- (s_exists x . x = phi) -> C[phi] -> s_exists x . C[x] + (def (func_subst_alt_thm_sorted x phi1) '( + syl (rsyl (exists_framing imancom) (anr imp_exists_disjoint)) @ exists_framing @ anim2 @ syl anr ,(func_subst_explicit_helper x phi1) + )) (def (func_subst_thm func_phi2 x phi1) '( exists_generalization_disjoint (mp (com12 @ syl anl ,(func_subst_explicit_helper x (nth 4 @ get-decl phi1))) ,phi1) ,func_phi2 )) @@ -1003,31 +1207,33 @@ do { exists_generalization ,fre (mp (com12 @ syl anl ,(func_subst_explicit_helper x phi1)) ,phi1_pf) ,func_phi2 )) - (def (propag_mem x ctx) @ match ctx + -- x in (...) <-> ... + (def (propag_mem_w_fun x ctx fun_patterns) @ if (not (== (lookup fun_patterns ctx) #undef)) (func_subst_thm (lookup fun_patterns ctx) 'y 'membership_var_bi) @ match ctx -- special case for top and bottom? [$eVar ,y$ (if (== x y) '(taut_equiv_top membership_same_var) 'membership_var_bi)] - [$exists ,y ,psi$ (if (== x y) 'biid '(bitr membership_exists_bi @ cong_of_equiv_exists ,(propag_mem x psi)))] - [$forall ,y ,psi$ (if (== x y) 'biid '(bitr membership_forall_bi @ cong_of_equiv_forall ,(propag_mem x psi)))] + [$exists ,y ,psi$ (if (== x y) 'biid '(bitr membership_exists_bi @ cong_of_equiv_exists ,(propag_mem_w_fun x psi fun_patterns)))] + [$forall ,y ,psi$ (if (== x y) 'biid '(bitr membership_forall_bi @ cong_of_equiv_forall ,(propag_mem_w_fun x psi fun_patterns)))] [$_in ,y ,psi$ (if (== x y) 'lemma_in_in_same_var 'lemma_in_in)] - [$not ,psi$ '(bitr membership_not_bi @ cong_of_equiv_not ,(propag_mem x psi))] - [$imp ,phi1 ,phi2$ '(bitr membership_imp_bi @ cong_of_equiv_imp ,(propag_mem x phi1) ,(propag_mem x phi2))] - [$or ,phi1 ,phi2$ '(bitr membership_or_bi @ cong_of_equiv_or ,(propag_mem x phi1) ,(propag_mem x phi2))] - [$and ,phi1 ,phi2$ '(bitr membership_and_bi @ cong_of_equiv_and ,(propag_mem x phi1) ,(propag_mem x phi2))] - [$equiv ,phi1 ,phi2$ '(bitr membership_equiv_bi @ cong_of_equiv_equiv ,(propag_mem x phi1) ,(propag_mem x phi2))] - [$app ,phi1 ,phi2$ '(bitr membership_app @ cong_of_equiv_exists @ cong_of_equiv_and_l ,(propag_mem #undef phi2))] + [$not ,psi$ '(bitr membership_not_bi @ cong_of_equiv_not ,(propag_mem_w_fun x psi fun_patterns))] + [$imp ,phi1 ,phi2$ '(bitr membership_imp_bi @ cong_of_equiv_imp ,(propag_mem_w_fun x phi1 fun_patterns) ,(propag_mem_w_fun x phi2 fun_patterns))] + [$or ,phi1 ,phi2$ '(bitr membership_or_bi @ cong_of_equiv_or ,(propag_mem_w_fun x phi1 fun_patterns) ,(propag_mem_w_fun x phi2 fun_patterns))] + [$and ,phi1 ,phi2$ '(bitr membership_and_bi @ cong_of_equiv_and ,(propag_mem_w_fun x phi1 fun_patterns) ,(propag_mem_w_fun x phi2 fun_patterns))] + [$equiv ,phi1 ,phi2$ '(bitr membership_equiv_bi @ cong_of_equiv_equiv ,(propag_mem_w_fun x phi1 fun_patterns) ,(propag_mem_w_fun x phi2 fun_patterns))] + [$app ,phi1 ,phi2$ '(bitr membership_app @ cong_of_equiv_exists @ cong_of_equiv_and_l ,(propag_mem_w_fun #undef phi2 fun_patterns))] [$_ceil ,psi$ 'mem_def] [$_floor ,psi$ 'mem_floor] [$_subset ,phi1 ,phi2$ 'mem_floor] [$_eq ,phi1 ,phi2$ 'mem_floor] + [$_neq ,phi1 ,phi2$ '(bitr membership_not_bi @ cong_of_equiv_not mem_floor)] - -- [$nnimp ,phi1 ,phi2$ '(membership_nnimp ,(propag_mem x phi1) ,(propag_mem X phi2))] - [$a$ (func_subst 'y $(x in (eVar y)) <-> (eVar x == eVar y)$ 'membership_var_bi 'functional_a)] - [$b$ (func_subst 'y $(x in (eVar y)) <-> (eVar x == eVar y)$ 'membership_var_bi 'functional_b)] - [$epsilon$ (func_subst 'y $(x in (eVar y)) <-> (eVar x == eVar y)$ 'membership_var_bi 'functional_epsilon)] - [$concat ,phi1 ,phi2$ '(bitr membership_app2 @ cong_of_equiv_exists @ cong_of_equiv_and ,(propag_mem #undef phi1) @ cong_of_equiv_exists @ cong_of_equiv_and_l ,(propag_mem #undef phi2))] + -- [$nnimp ,phi1 ,phi2$ '(membership_nnimp ,(propag_mem_w_fun x phi1 fun_patterns) ,(propag_mem_w_fun X phi2 fun_patterns))] + [$epsilon$ (func_subst_thm 'functional_epsilon 'y 'membership_var_bi)] + [$concat ,phi1 ,phi2$ '(bitr membership_app2 @ cong_of_equiv_exists @ cong_of_equiv_and ,(propag_mem_w_fun #undef phi1 fun_patterns) @ cong_of_equiv_exists @ cong_of_equiv_and_l ,(propag_mem_w_fun #undef phi2 fun_patterns))] [_ 'biid] ) + + (def (propag_mem x ctx) @ propag_mem_w_fun x ctx (atom-map!)) }; theorem func_subst_explicit_test_1 {x y: EVar} (phi: Pattern) @@ -1057,3 +1263,346 @@ theorem propag_mem_test_11 {x y: EVar} (phi: Pattern x): theorem propag_mem_test_12 {x y z: EVar}: $ (x in ~(app (sym defSym) (bot -> eVar y))) <-> ~(exists z (((z in bot) -> (eVar z == eVar y)) /\ (x in app (sym defSym) (eVar z)))) $ = (propag_mem 'x $~(app (sym defSym) (bot -> eVar y))$); + + + +theorem eq_equiv_to_eq_eq + (eq_equiv: $ (phi1 == phi2) -> (psi1 <-> psi2) $): + $ (phi1 == phi2) -> (psi1 == psi2) $ = + '(syl (framing_floor eq_equiv) @ anr floor_idem); + +theorem lemma_14_subset {box: SVar} (ctx psi phi1 phi2: Pattern box) + (h: $ |_ psi _| -> (phi1 C= phi2) $): + $ |_ psi _| -> ((app[ phi1 / box ] ctx) C= app[ phi2 / box ] ctx) $ = + '(rsyl (anr floor_idem) @ framing_floor @ lemma_14 @ syl corollary_57_floor h); + +do { + (def (lemma_14_subset_subst h subst) '(norm (norm_imp_r @ norm_subset ,subst ,subst) @ lemma_14_subset ,h)) +}; + +theorem ceil_is_pred: $ (|^ phi ^| == bot) \/ (|^ phi ^| == top) $ = + '(orim + (anl + @ bitr (bicom @ cong_of_equiv_not def_idem) + @ bitr not_ceil_floor_bi + @ cong_of_equiv_floor + @ ibii (iand id @ a1i absurdum) + anl) + (anl + @ bitr (bicom floor_ceil_ceil) + @ cong_of_equiv_floor + @ ibii (iand (a1i imp_top) @ com12 @ a1i id) + @ rsyl anr @ mpcom taut) + emr); + +theorem floor_is_pred: $ (|_ phi _| == bot) \/ (|_ phi _| == top) $ = + '(orim + (anl + @ bitr (bicom @ cong_of_equiv_not @ ceil_floor_floor) + @ bitr not_ceil_floor_bi + @ cong_of_equiv_floor + @ ibii (iand id @ a1i absurdum) + anl) + (anl + @ bitr (bicom floor_idem) + @ cong_of_equiv_floor + @ ibii (iand (a1i imp_top) @ com12 @ a1i id) + @ rsyl anr @ mpcom taut) + emr); + +theorem ceil_idempotency_for_pred (phi: Pattern): $ ((phi == bot) \/ (phi == top)) <-> (phi == |^ phi ^|) $ = + (named '(ibii + (eori + (mp ,(func_subst_imp_to_var 'x $eVar x == |^ eVar x ^| $) @ lemma_46_floor @ ibii absurdum @ norm (norm_imp_l defNorm) propag_bot) + (mp ,(func_subst_imp_to_var 'x $eVar x == |^ eVar x ^| $) @ lemma_46_floor @ bicom @ taut_equiv_top @ framing_def imp_top definedness)) + (mp ,(func_subst_imp_to_var 'x $(eVar x == bot) \/ (eVar x == top)$) ceil_is_pred))); + +theorem subset_framing_imp {box: SVar} (ctx: Pattern box) (phi psi: Pattern): + $ (phi C= psi) -> ((app[ phi / box ] ctx) C= (app[ psi / box ] ctx)) $ = + '(rsyl subset_imp_or_subset_r @ + rsyl (com12 subset_to_eq @ subset_imp_subset_or_r subset_refl) @ + rsyl (eq_to_subset_bi eq_to_id_bi (eq_to_appCtx_bi eq_to_intro_bi)) @ + rsyl anl @ + mpcom @ + imp_to_subset @ + framing orl); + +theorem eq_framing_imp {box: SVar} (ctx: Pattern box) (phi psi: Pattern): + $ (phi == psi) -> ((app[ phi / box ] ctx) == (app[ psi / box ] ctx)) $ = + '(syl (curry subset_to_eq) @ iand (rsyl eq_imp_subset subset_framing_imp) @ rsyl eq_sym @ rsyl eq_imp_subset subset_framing_imp); + +do { + (def (subset_framing_imp_subst subst) '(norm (norm_imp_r @ norm_subset ,subst ,subst) subset_framing_imp)) + (def (eq_framing_imp_subst subst) '(norm (norm_imp_r @ norm_eq ,subst ,subst) eq_framing_imp)) +}; + +theorem under_domain_forall {x: EVar} (phi_a phi_b phi_c phi_d: Pattern x) + (h: $ phi_b -> phi_c $): + $ ((forall x (phi_a -> phi_c)) -> phi_d) -> (forall x (phi_a -> phi_b)) -> phi_d $ = + '(imim1 @ forall_framing @ imim2 h); + +theorem domain_func_sorting {x: EVar} (phi psi: Pattern): + $ (exists x ((eVar x C= psi) /\ (eVar x == phi))) -> (phi C= psi) $ = + '(exists_generalization_disjoint @ + rsyl (anim2 @ rsyl eq_sym eq_imp_subset) @ + impcom subset_trans); + +theorem forall_exists_lemma {x: EVar} (phi: Pattern x) (psi: Pattern): + $ ( forall x (phi C= psi)) -> + ((exists x phi) C= psi ) $ = + '(con3 @ + rsyl (framing_def @ con3 @ imim2 dne) @ + rsyl (framing_def and_exists_disjoint_r_reverse) @ + rsyl propag_exists_def @ + exists_framing @ + syl notnot1 @ + framing_def @ + con3 @ + imim2 notnot1); + +theorem forall_exists_lemma_rev {x: EVar} (phi: Pattern x) (psi: Pattern): + $ ((exists x phi) C= psi ) -> + ( forall x (phi C= psi)) $ = + '(con3 @ + syl (framing_def @ con3 @ imim2 notnot1) @ + syl (framing_def @ and_exists_disjoint_r_forwards) @ + syl prop_43_exists_def @ + exists_framing @ + con1 @ + framing_floor @ + imim2 dne); + +theorem forall_exists_lemma_domain {x: EVar} (phi rho: Pattern x) (psi: Pattern): + $ ( forall x (((eVar x) C= rho) -> (phi C= psi))) -> + ((exists x (((eVar x) C= rho) /\ phi)) C= psi ) $ = + '(con3 @ + rsyl (framing_def @ con3 @ imim2 dne) @ + rsyl (framing_def and_exists_disjoint_r_reverse) @ + rsyl propag_exists_def @ + exists_framing @ + rsyl (framing_def @ anl anass) @ + rsyl (iand (framing_def anl) (framing_def anr)) @ + syl (con3 @ imim2 notnot1) @ + anim (anl ceil_floor_floor) @ + syl notnot1 @ + framing_def @ + con3 @ + imim2 notnot1); + +theorem forall_imp_to_imp_exists {x: EVar} (phi psi: Pattern x): + $ (forall x (phi -> psi)) -> (exists x phi) -> (exists x psi) $ = + '(exp @ rsyl (and_exists_fresh_reverse eFresh_forall_same_var) @ exists_framing @ curry var_subst_same_var); + +theorem forall_eq_to_eq_exists {x: EVar} (phi psi: Pattern x): + $ (forall x (phi == psi)) -> ((exists x phi) == (exists x psi)) $ = + '(rsyl (forall_framing @ iand eq_imp_subset @ rsyl eq_sym eq_imp_subset) @ + rsyl (iand (forall_framing anl) (forall_framing anr)) @ + rsyl (anim (anr forall_floor) (anr forall_floor)) @ + rsyl (anim (framing_floor forall_imp_to_imp_exists) (framing_floor forall_imp_to_imp_exists)) @ + curry subset_to_eq); + +theorem pointwise_decomposition {box: SVar} {x: EVar} (ctx: Pattern box) (phi psi: Pattern) + (hyp: $ (x in phi) -> (app[ eVar x / box ] ctx C= psi) $): + $ app[ phi / box ] ctx C= psi $ = + '(imp_to_subset @ rsyl (anl appCtx_pointwise) @ + exists_generalization_disjoint @ + impcom @ + rsyl hyp subset_to_imp); + +theorem pointwise_decomposition_imp {box: SVar} {x: EVar} (ctx: Pattern box) (phi psi: Pattern): + $ (forall x (((eVar x) C= phi) -> (app[ eVar x / box ] ctx C= psi))) -> + (app[ phi / box ] ctx C= psi) $ = + '(rsyl forall_exists_lemma_domain @ + anl (mp ,(func_subst_explicit_helper 'y $ (eVar y) C= _ $) ( + equiv_to_eq @ + bitr + (cong_of_equiv_exists @ bitr (aneq1i eVar_in_subset_rev) ancomb) + (bicom appCtx_pointwise)))); + +do { + (def (pointwise_decomposition_imp_subst subst) '(norm (norm_imp (norm_forall @ norm_imp_r @ norm_subset ,subst norm_refl) @ norm_subset ,subst norm_refl) pointwise_decomposition_imp)) +}; + +theorem subset_mem_lemma_fresh {x: EVar} (phi: Pattern) (psi: Pattern x) + (freshness_psi: $ _eFresh x psi $): + $ (phi C= psi) -> forall x ((x in phi) -> x in psi) $ = + '(anr (imp_forall_fresh @ eFresh_subset eFresh_disjoint freshness_psi) @ univ_gene @ com12 @ rsyl eVar_in_subset_forward @ rsyl subset_trans @ imim2 eVar_in_subset_reverse); + +theorem subset_mem_lemma {x: EVar} (phi psi: Pattern): + $ (phi C= psi) -> forall x ((x in phi) -> x in psi) $ = + '(subset_mem_lemma_fresh eFresh_disjoint); + +do { + (def (forall_imp_climb n) (iterate n (fn (pf) '(syl (anl imp_r_forall_disjoint) @ imim2 ,pf)) 'id)) + + (def (forall_imp_push n) (iterate n (fn (pf) '(rsyl (anr imp_r_forall_disjoint) @ imim2 ,pf)) 'id)) + + (def (inst_foralls n) (if {n = 0} 'id + '(rsyl (rsyl ,(inst_foralls {n - 1}) ,(forall_imp_climb {n - 1})) var_subst_same_var) + )) +}; + +theorem imp_eq_to_conj_ceil_in_eq: + $ (|^ phi1 ^| -> (phi2 == phi3)) -> ((phi2 /\ |^ phi1 ^|) == (phi3 /\ |^ phi1 ^|)) $ = + '(rsyl (imim1 dne) @ eori + (rsyl (anl not_ceil_floor_bi) @ rsyl (anr floor_idem) @ + framing_floor @ rsyl (anr not_ceil_floor_bi) @ iand + (com12 @ rsyl anr @ com12 absurd) + (com12 @ rsyl anr @ com12 absurd) + ) @ + eq_equiv_to_eq_eq @ eq_to_and_l_bi eq_to_intro_bi); + +theorem s_forall_eq_lemma {x: EVar} {box: SVar} (phi1 phi2: Pattern box) (S: Pattern): + $ (forall x (((eVar x) C= S) -> ((app[ eVar x / box ] phi1) == (app[ eVar x / box ] phi2)))) -> ((app[ S / box ] phi1) == (app[ S / box ] phi2)) $ = + '(rsyl (forall_framing (rsyl (imim1 eVar_in_subset_forward) imp_eq_to_conj_ceil_in_eq)) @ + rsyl forall_eq_to_eq_exists @ + anl @ cong_of_equiv_eq (bicom appCtx_pointwise) (bicom appCtx_pointwise)); + +do { + (def (s_forall_eq_lemma_subst subst1 subst2) '(norm (norm_imp (norm_forall @ norm_imp_r @ norm_eq ,subst1 ,subst2) @ norm_eq ,subst1 ,subst2) s_forall_eq_lemma)) +}; + +theorem imp_var_nin_lemma: + $ (forall x (((eVar x) C= S) -> ~ ((eVar y) C= (app[ eVar x / box ] ctx)))) -> ~ ((eVar y) C= (app[ S / box ] ctx)) $ = + '(con2 @ syl notnot1 @ rsyl eVar_in_subset_reverse @ syl (exists_framing @ anim2 eVar_in_subset_forward) @ + anl ,(propag_mem 'y $_ -> exists x ((_ C= _) /\ _)$) @ membership_intro_implicit @ + rsyl (anl appCtx_pointwise) @ exists_framing @ rsyl ancom @ anim1 eVar_in_subset_forward); + +do { + (def (imp_var_nin_lemma_subst subst) '(norm (norm_imp (norm_forall @ norm_imp_r @ norm_not @ norm_subset norm_refl ,subst) @ norm_not @ norm_subset norm_refl ,subst) imp_var_nin_lemma)) +}; + +theorem swap_sorted_forall {x y: EVar} (phi: Pattern x y) (phi_x: Pattern x) (phi_y: Pattern y): + $ forall x (phi_x -> (forall y (phi_y -> phi))) -> forall y (phi_y -> (forall x (phi_x -> phi))) $ = + '( + rsyl (forall_framing @ anl imp_r_forall_disjoint) @ + rsyl swap_forall @ + forall_framing @ + rsyl (forall_framing @ anl com12b) @ + anr imp_r_forall_disjoint); + +theorem ceil_imp_lemma: + $ (|^ phi ^| -> |_ psi _|) -> |_ |^ phi ^| -> psi _| $ = + '(rsyl (imim (anl floor_ceil_ceil) (anr ceil_floor_floor)) @ rsyl prop_43_or_def @ rsyl (anr floor_ceil_ceil) @ framing_floor @ rsyl prop_43_or_def_rev @ imim (anr floor_ceil_ceil) (rsyl (anl ceil_floor_floor) corollary_57_floor)); + +theorem floor_imp_lemma: + $ (|_ phi _| -> |_ psi _|) -> |_ |_ phi _| -> psi _| $ = + '(rsyl (imim1 @ anl ceil_floor_floor) @ rsyl ceil_imp_lemma @ framing_floor @ imim1 @ anr ceil_floor_floor); + +theorem ceil_of_ceil_conj: + $ |^ phi ^| /\ |^ rho ^| <-> |^ |^ phi ^| /\ |^ rho ^| ^| $ = + '(bitr (cong_of_equiv_and (bicom floor_ceil_ceil) (bicom floor_ceil_ceil)) @ bitr (bicom propag_and_floor) @ bitr (bicom ceil_floor_floor) @ cong_of_equiv_def @ bitr propag_and_floor @ cong_of_equiv_and floor_ceil_ceil floor_ceil_ceil); + + +theorem floor_of_floor_and: + $ |_ phi _| /\ |_ rho _| <-> |_ |_ phi _| /\ |_ rho _| _| $ = + '(bitr (cong_of_equiv_and (bicom floor_idem) (bicom floor_idem)) @ bicom propag_and_floor); + +theorem floor_of_floor_not: + $ ~ |_ phi _| <-> |_ ~ |_ phi _| _| $ = + '(bitr (bicom notnot) @ bitr (bicom floor_ceil_ceil) @ cong_of_equiv_floor notnot); + +theorem floor_of_floor_or: + $ |_ phi _| \/ |_ rho _| <-> |_ |_ phi _| \/ |_ rho _| _| $ = + '(bitr (cong_of_equiv_or (bicom ceil_floor_floor) (bicom ceil_floor_floor)) @ bitr (bicom propag_or_def) @ bitr (bicom floor_ceil_ceil) @ cong_of_equiv_floor @ bitr propag_or_def @ cong_of_equiv_or ceil_floor_floor ceil_floor_floor); + +theorem floor_of_floor_imp: + $ (|_ phi _| -> |_ psi _|) <-> |_ |_ phi _| -> |_ psi _| _| $ = + '(ibii (rsyl (imim2 @ anr floor_idem) floor_imp_lemma) corollary_57_floor); + +theorem floor_of_floor_forall {x: EVar} (phi: Pattern x): + $ (forall x (|_ phi _|)) <-> |_ forall x (|_ phi _|) _| $ = + '(ibii (con3 @ rsyl (framing_def dne) @ rsyl propag_exists_def @ exists_framing @ rsyl (framing_def dne) @ rsyl (anl def_idem) notnot1) corollary_57_floor); + +theorem floor_of_floor_exists {x: EVar} (phi: Pattern x): + $ (exists x (|_ phi _|)) <-> |_ exists x (|_ phi _|) _| $ = + '(ibii (exists_generalization (eFresh_floor eFresh_exists_same_var) @ rsyl (anr floor_idem) @ framing_floor exists_intro_same_var) corollary_57_floor); + +theorem floor_of_floor_s_exists {x: EVar} (phi: Pattern x): + $ (exists x (((eVar x) C= sort) /\ |_ phi _|)) <-> |_ exists x (|_ ((eVar x) C= sort) /\ |_ phi _| _|) _| $ = + '(bitr (cong_of_equiv_exists floor_of_floor_and) floor_of_floor_exists); + +theorem floor_of_floor_s_forall {x: EVar} (phi: Pattern x): + $ (forall x (((eVar x) C= sort) -> |_ phi _|)) <-> |_ forall x (|_ ((eVar x) C= sort) -> |_ phi _| _|) _| $ = + '(bitr (cong_of_equiv_forall floor_of_floor_imp) floor_of_floor_forall); + + + +do { + (def (floor_wrap_equiv pred) @ match pred + [$exists ,x ,phi$ '(bitr (cong_of_equiv_exists ,(floor_wrap_equiv phi)) floor_of_floor_exists)] + [$forall ,x ,phi$ '(bitr (cong_of_equiv_forall ,(floor_wrap_equiv phi)) floor_of_floor_forall)] + [$imp ,phi1 ,phi2$ '(bitr (cong_of_equiv_imp ,(floor_wrap_equiv phi1) ,(floor_wrap_equiv phi2)) floor_of_floor_imp)] + [$not ,phi$ '(bitr (cong_of_equiv_not ,(floor_wrap_equiv phi)) floor_of_floor_not)] + [$or ,phi1 ,phi2$ '(bitr (cong_of_equiv_or ,(floor_wrap_equiv phi1) ,(floor_wrap_equiv phi2)) floor_of_floor_or)] + [$and ,phi1 ,phi2$ '(bitr (cong_of_equiv_and ,(floor_wrap_equiv phi1) ,(floor_wrap_equiv phi2)) floor_of_floor_and)] + [$_ceil ,phi$ '(bicom floor_ceil_ceil)] + [$_in ,x ,phi$ '(bicom floor_ceil_ceil)] + [$_floor ,phi$ '(bicom floor_idem)] + [$_subset ,phi1 ,phi2$ '(bicom floor_idem)] + [$_eq ,phi1 ,phi2$ '(bicom floor_idem)] + [$is_func ,phi$ '(floor_of_floor_exists)] + + [$s_exists ,s ,x ,phi$ '(bitr (cong_of_equiv_exists @ cong_of_equiv_and_r ,(floor_wrap_equiv phi)) floor_of_floor_s_exists)] + [$s_forall ,s ,x ,phi$ '(bitr (cong_of_equiv_forall @ cong_of_equiv_imp_r ,(floor_wrap_equiv phi)) floor_of_floor_s_forall)] + ) + + (def (extract_pred_from_appCtx_r pred subst) '(norm (norm_imp ,subst @ norm_and_l ,subst) @ rsyl (anl @ cong_of_equiv_appCtx @ cong_of_equiv_and_r ,(floor_wrap_equiv pred)) @ rsyl appCtx_floor_commute @ anr @ cong_of_equiv_and_r ,(floor_wrap_equiv pred))) +}; + +do { + (def (forall_extract ctx) @ match ctx + [$imp _ ,phi$ '(bitr (imeq2i ,(forall_extract phi)) imp_r_forall_disjoint)] + [$or _ ,phi$ '(bitr (oreq2i ,(forall_extract phi)) or_r_forall_disjoint)] + [$and _ ,phi$ '(bitr (aneq2i ,(forall_extract phi)) and_r_forall_disjoint)] + [$forall _ ,phi$ '(bitr (cong_of_equiv_forall ,(forall_extract phi)) swap_forall_bi)] + [$_in _ ,phi$ '(bitr (cong_of_equiv_mem ,(forall_extract phi)) membership_forall_bi)] + [$_floor ,phi$ '(bitr (cong_of_equiv_floor ,(forall_extract phi)) forall_floor)] + + [_ 'biid] + ) +}; + +theorem is_pred_floor: $ (is_pred phi) <-> (phi == |_ phi _|) $ = + '(ibii + (rsyl (anl floor_of_floor_or) @ framing_floor @ eori (rsyl (rsyl corollary_57_floor anl) @ iand (imim2 absurdum) @ a1i corollary_57_floor) @ iand (rsyl ,(func_subst_explicit_helper 'x $ (eVar x) -> |_ eVar x _| $) @ rsyl anr @ mpcom @ a1i @ lemma_46_floor taut) @ a1i corollary_57_floor) + (rsyl ,(func_subst_explicit_helper 'x $((eVar x) == bot) \/ ((eVar x) == top)$) @ rsyl anr @ mpcom floor_is_pred)); + +theorem KT_imp {X: SVar} (ctx ante phi: Pattern X) + (pos: $ _Positive X ctx $) + (propag: $ (s[ ante -> phi / X ] ctx) -> ante -> s[ phi / X ] ctx $) + (h: $ ante -> (s[ phi / X ] ctx) -> phi $): + $ ante -> (mu X ctx) -> phi $ = + '(com12 @ KT pos @ rsyl propag (prop_2 h)); + +theorem KT_subset {X: SVar} (ctx phi: Pattern X) + (pos: $ _Positive X ctx $) + (propag: $ (s[ ((s[ phi / X ] ctx) C= phi) -> phi / X ] ctx) -> ((s[ phi / X ] ctx) C= phi) -> s[ phi / X ] ctx $): + $ ((s[ phi / X ] ctx) C= phi) -> ((mu X ctx) C= phi) $ = + '(rsyl (anr floor_idem) @ framing_floor @ KT_imp pos propag corollary_57_floor); + +do { + (def (KT_subset_subst subst pos propag) '(norm (norm_imp_l @ norm_subset ,subst norm_refl) @ KT_subset ,pos @ norm (norm_sym @ norm_imp (norm_trans (norm_svSubst_pt norm_refl @ norm_imp_l @ norm_subset ,subst norm_refl) ,subst) @ norm_imp (norm_subset ,subst norm_refl) ,subst) ,propag)) +}; + + +theorem floor_extract_app + (h1: $ phi1 -> |_ psi _| -> rho1 $) + (h2: $ phi2 -> |_ psi _| -> rho2 $): + $ (app phi1 phi2) -> |_ psi _| -> app rho1 rho2 $ = + (named '(rsyl ,(framing_subst 'h1 'appCtxLVar) @ rsyl ,(floor_imp_in_appCtx_subst 'appCtxLVar) @ rsyl (imim2 (rsyl ,(framing_subst 'h2 'appCtxRVar) ,(floor_imp_in_appCtx_subst 'appCtxRVar))) imidm)); + +theorem floor_extract_or + (h1: $ phi1 -> |_ psi _| -> rho1 $) + (h2: $ phi2 -> |_ psi _| -> rho2 $): + $ phi1 \/ phi2 -> |_ psi _| -> rho1 \/ rho2 $ = + '(rsyl (orim h1 h2) @ anl imp_or_extract); + +do { + (def (floor_extract x ctx) @ match ctx + [$eVar ,y$ (if (== x y) 'id 'prop_1)] + [$app ,phi1 ,phi2$ '(floor_extract_app ,(floor_extract x phi1) ,(floor_extract x phi2))] + [$or ,phi1 ,phi2$ '(floor_extract_or ,(floor_extract x phi1) ,(floor_extract x phi2))] + [_ 'prop_1] + ) +}; diff --git a/nominal/core.mm1 b/nominal/core.mm1 new file mode 100644 index 0000000..df9a815 --- /dev/null +++ b/nominal/core.mm1 @@ -0,0 +1,168 @@ +import "../sorts.mm1"; + +-- Atom sorts +term atoms_sym: Symbol; +def atoms: Pattern = $ sym atoms_sym $; +axiom sort_atoms: $ is_sort atoms $; + +term nominal_sorts_sym: Symbol; +def nominal_sorts: Pattern = $ sym nominal_sorts_sym $; +axiom sort_nominal_sorts: $ is_sort nominal_sorts $; + +axiom atoms_nominal_sorts: $ dom atoms C= dom nominal_sorts $; + +term sort_abstraction_sym: Symbol; +def sort_abstraction (abs body: Pattern): Pattern = $ (sym sort_abstraction_sym) @@ abs @@ body $; +axiom function_sort_abstraction: $ ,(is_function '(sym sort_abstraction_sym) '[atoms nominal_sorts] 'nominal_sorts) $; + +def is_atom_sort (alpha: Pattern): Pattern = $ (is_func alpha) /\ (alpha C= dom atoms) $; +def is_nominal_sort (tau: Pattern): Pattern = $ (is_func tau) /\ (tau C= dom nominal_sorts) $; +def is_atom (a alpha: Pattern): Pattern = $ is_sorted_func (dom alpha) a $; + +axiom nominal_sorts_are_sorts: $ (is_nominal_sort phi) -> (is_sort phi) $; + +term swap_sym: Symbol; +def swap (a b phi: Pattern): Pattern = $ (sym swap_sym) @@ a @@ b @@ phi $; +term abstraction_sym: Symbol; +def abstraction (phi rho: Pattern): Pattern = $ (sym abstraction_sym) @@ phi @@ rho $; +term supp_sym: Symbol; +def supp (phi: Pattern): Pattern = $ (sym supp_sym) @@ phi $; +def fresh_for (phi psi: Pattern): Pattern = $ ~ (phi C= supp psi) $; +term comma_sym: Symbol; +def comma (phi psi: Pattern): Pattern = $ (sym comma_sym) @@ phi @@ psi $; +infixl comma: $,,$ prec 35; +term comma_sort_sym: Symbol; +def comma_sort: Pattern = $ sym comma_sort_sym $; + +axiom comma_sort_nominal: $ is_nominal_sort comma_sort $; + +def EV_pattern {.a .b: EVar} (alpha phi: Pattern): Pattern = +$ s_forall alpha a (s_forall alpha b ((swap (eVar a) (eVar b) phi) == phi)) $; + +axiom function_swap: + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ ,(is_function '(sym swap_sym) '[alpha alpha tau] 'tau) $; +axiom function_swap_atom: + $ is_atom_sort alpha $ > + $ ,(is_function '(sym swap_sym) '[alpha alpha alpha] 'alpha) $; +axiom function_abstraction: + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ ,(is_function '(sym abstraction_sym) '[alpha tau] '(sort_abstraction alpha tau)) $; +axiom multifunction_supp: + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ ,(is_multi_function '(sym supp_sym) '[tau] 'alpha) $; +axiom function_comma: + $ is_nominal_sort tau1 $ > + $ is_nominal_sort tau2 $ > + $ ,(is_function '(sym comma_sym) '[tau1 tau2] 'comma_sort) $; + +axiom EV_abstraction {a b: EVar} (alpha tau: Pattern) (phi psi: Pattern a b): + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ s_forall alpha a (s_forall alpha b ( + (is_of_sort phi alpha) -> + (is_of_sort psi tau) -> + ((swap (eVar a) (eVar b) (abstraction phi psi)) == abstraction (swap (eVar a) (eVar b) phi) (swap (eVar a) (eVar b) psi)))) $; + +axiom EV_swap {a b c d: EVar} (alpha tau: Pattern) (phi: Pattern a b c d): + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ s_forall alpha a (s_forall alpha b (s_forall alpha c (s_forall alpha d ( + (is_of_sort phi alpha) -> + (is_of_sort psi tau) -> + ((swap (eVar a) (eVar b) (swap (eVar c) (eVar d) phi)) == swap (swap (eVar a) (eVar b) (eVar c)) (swap (eVar a) (eVar b) (eVar d)) (swap (eVar a) (eVar b) phi)))))) $; + +axiom EV_supp {a b: EVar} (alpha tau: Pattern) (phi: Pattern a b): + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ s_forall alpha a (s_forall alpha b ( + (is_of_sort phi tau) -> + ((swap (eVar a) (eVar b) (supp phi)) == supp (swap (eVar a) (eVar b) phi)))) $; + +axiom EV_comma {a b: EVar} (alpha tau: Pattern) (phi1 phi2: Pattern a b): + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ s_forall alpha a (s_forall alpha b ( + (is_of_sort phi1 tau) -> + (is_of_sort phi2 tau) -> + ((swap (eVar a) (eVar b) (phi1 ,, phi2)) == ((swap (eVar a) (eVar b) phi1) ,, (swap (eVar a) (eVar b) phi2))))) $; + +axiom fresh_comma {a: EVar} (alpha tau1 tau2: Pattern) (phi1 phi2: Pattern a): + $ is_atom_sort alpha $ > + $ is_nominal_sort tau1 $ > + $ is_nominal_sort tau2 $ > + $ s_forall alpha a ( + (is_of_sort phi1 tau1) -> + (is_of_sort phi2 tau2) -> + (fresh_for (eVar a) (phi1 ,, phi2)) -> + (fresh_for (eVar a) phi1) /\ (fresh_for (eVar a) phi2)) $; + +axiom EV_pred (alpha tau: Pattern): + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ EV_pattern alpha (dom tau) $; +axiom S1 (alpha tau a phi: Pattern): + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ (is_atom a alpha) -> + (is_of_sort phi tau) -> + ((swap a a phi) == phi) $; +axiom S2 {a b: EVar} (alpha tau phi: Pattern a b): + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ s_forall alpha a ( + s_forall alpha b ( + (is_of_sort phi tau) -> + ((swap (eVar a) (eVar b) (swap (eVar a) (eVar b) phi)) == phi))) $; +axiom S3 {a b: EVar} (alpha: Pattern a b): + $ is_atom_sort alpha $ > + $ s_forall alpha a ( + s_forall alpha b ( + ((swap (eVar a) (eVar b) (eVar a)) == (eVar b)))) $; +axiom F1 {a b: EVar} (alpha tau phi: Pattern a b): + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ s_forall alpha a ( + s_forall alpha b ( + (is_of_sort phi tau) -> + ((fresh_for (eVar a) phi) /\ (fresh_for (eVar b) phi) -> + ((swap (eVar a) (eVar b) phi) == phi)))) $; +axiom F2 {a b: EVar} (alpha: Pattern a b): + $ is_atom_sort alpha $ > + $ s_forall alpha a ( + s_forall alpha b ( + (((eVar a) != (eVar b)) <-> (fresh_for (eVar a) (eVar b))))) $; +axiom F3 {a b: EVar} (alpha1 alpha2: Pattern a b): + $ is_atom_sort alpha1 $ > + $ is_atom_sort alpha2 $ > + $ s_forall alpha a ( + s_forall alpha b ( + (alpha1 != alpha2) -> ((eVar a) != (eVar b)))) $; +-- We restrict F4 to only accept singleton phi's to avoid inconsistencies +-- caused by using the full set of atoms in place of phi +axiom F4 {a: EVar} (alpha tau phi: Pattern): + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ (is_sorted_func (dom tau) phi) -> + (s_exists alpha a (fresh_for (eVar a) phi)) $; +axiom A1 {a b: EVar} (alpha tau phi rho: Pattern a b): + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ s_forall alpha a ( + s_forall alpha b ( + (is_of_sort phi tau) -> + (is_of_sort rho tau) -> + (((abstraction (eVar a) phi) == (abstraction (eVar b) rho)) <-> + (((eVar a) == (eVar b)) /\ (phi == rho)) \/ + ((fresh_for (eVar a) rho) /\ ((swap (eVar a) (eVar b) phi) == rho))))) $; +axiom A2 (alpha tau: Pattern) {x a y: EVar}: + $ is_atom_sort alpha $ > + $ is_nominal_sort tau $ > + $ s_forall (sort_abstraction alpha tau) x + (s_exists alpha a (s_exists tau y (eVar x == abstraction (eVar a) (eVar y)))) $; + +def coercion (a phi: Pattern) {.y: EVar}: Pattern = + $ exists y (eVar y /\ ((abstraction a (eVar y)) == phi)) $; diff --git a/nominal/lambda.mm1 b/nominal/lambda.mm1 new file mode 100644 index 0000000..c6ae993 --- /dev/null +++ b/nominal/lambda.mm1 @@ -0,0 +1,1075 @@ +import "core.mm1"; + +term Var_sym: Symbol; +def Var: Pattern = $ sym Var_sym $; +def Vars: Pattern = $ dom Var $; +def is_var (p: Pattern): Pattern = $ is_of_sort p Var $; +axiom Var_atom: $ is_atom_sort Var $; + +term Exp_sym: Symbol; +def Exp: Pattern = $ sym Exp_sym $; +def Exps: Pattern = $ dom Exp $; +def is_exp (p: Pattern): Pattern = $ is_of_sort p Exp $; +axiom Exp_sort: $ is_nominal_sort Exp $; + +term lc_var_sym: Symbol; +def lc_var (phi: Pattern): Pattern = $ (sym lc_var_sym) @@ phi $; +axiom function_lc_var: $ ,(is_function '(sym lc_var_sym) '[Var] 'Exp) $; +axiom EV_lc_var {a b: EVar} (c: Pattern a b): + $ s_forall Var a (s_forall Var b ( + (is_of_sort c Var) -> + ((swap (eVar a) (eVar b) (lc_var c)) == lc_var (swap (eVar a) (eVar b) c)))) $; + +term lc_app_sym: Symbol; +def lc_app (phi rho: Pattern): Pattern = $ (sym lc_app_sym) @@ phi @@ rho $; +axiom function_lc_app: $ ,(is_function '(sym lc_var_app) '[Exp Exp] 'Exp) $; +axiom EV_lc_app {a b: EVar} (phi psi: Pattern a b): + $ s_forall Var a (s_forall Var b ( + (is_of_sort phi Exp) -> + (is_of_sort psi Exp) -> + ((swap (eVar a) (eVar b) (lc_app phi psi)) == lc_app (swap (eVar a) (eVar b) phi) (swap (eVar a) (eVar b) psi)))) $; + +term lc_lam_sym: Symbol; +def lc_lam (phi: Pattern): Pattern = $ (sym lc_lam_sym) @@ phi $; +def lc_lam_a (a p: Pattern): Pattern = $ lc_lam (abstraction a p) $; +axiom function_lc_lam: $ ,(is_function '(sym lc_lam_sym) '[(sort_abstraction Var Exp)] 'Exp) $; +axiom EV_lc_lam {a b: EVar} (phi: Pattern a b): + $ s_forall Var a (s_forall Var b ( + (is_of_sort phi (sort_abstraction Var Exp)) -> + ((swap (eVar a) (eVar b) (lc_lam phi)) == lc_lam (swap (eVar a) (eVar b) phi)))) $; + +axiom no_junk {X: SVar}: + $ Exps == mu X ( (lc_var Vars) + \/ (lc_app (sVar X) (sVar X)) + \/ (lc_lam (abstraction Vars (sVar X)))) $; + +--- add no_confusion axioms for the symbols +--- add EV axioms for the symbols + +do { + (def (subst_at_depth n) (if {n = 0} 'appCtxVar @ if {n = 1} 'appCtxRVar '(norm_trans appCtxL_disjoint @ norm_app ,(subst_at_depth {n - 1}) norm_refl))) + (def (uncurry_n n) (if {n < 2} 'id '(rsyl (anl impexp) @ imim2 ,(uncurry_n {n - 1})))) + (def (function_sorting_full n) (if {n = 0} 'domain_func_sorting '(syl ,(pointwise_decomposition_imp_subst (subst_at_depth n)) @ forall_framing @ imim2 ,(function_sorting_full {n - 1})))) + (def (function_sorting_lemma n pf) (if {n = 0} pf @ + if {n = 1} '(rsyl ,(imp_subset_framing_subst 'appCtxRVar) (mp (com12 subset_trans) ,pf)) + '(syl (curry subset_trans) @ anim ,(imp_subset_framing_subst (subst_at_depth n)) ,(function_sorting_lemma {n - 1} pf)))) + (def (function_sorting n function_pf) '(mp ,(uncurry_n n) ,(function_sorting_lemma n '(mp ,(function_sorting_full n) ,function_pf)))) +}; + +theorem abstraction_sorting_full: + $ is_of_sort (abstraction Vars Exps) (sort_abstraction Var Exp) $ = + (named '(mp ,(function_sorting_full 2) @ + function_abstraction Var_atom Exp_sort)); + +theorem abstraction_sorting (phi rho: Pattern): + $ is_var phi -> is_exp rho -> is_of_sort (abstraction phi rho) (sort_abstraction Var Exp) $ = + (named (function_sorting 2 '(function_abstraction Var_atom Exp_sort))); + +theorem swap_sorting {a b: EVar} (phi: Pattern a b): + $ is_var (eVar a) -> is_var (eVar b) -> (is_exp phi) -> (is_exp (swap (eVar a) (eVar b) phi)) $ = + (named (function_sorting 3 '(function_swap Var_atom Exp_sort))); +theorem swap_sorting_var {a b: EVar} (phi: Pattern a b): + $ is_var (eVar a) -> is_var (eVar b) -> (is_var phi) -> (is_var (swap (eVar a) (eVar b) phi)) $ = + (named (function_sorting 3 '(function_swap_atom Var_atom))); + +theorem EV_lc_lam_abstraction {a b: EVar} (phi: Pattern a b): + $ s_forall Var a (s_forall Var b (is_exp phi -> ((swap (eVar a) (eVar b) (lc_lam_a (eVar a) phi)) == lc_lam_a (eVar b) (swap (eVar a) (eVar b) phi)))) $ = + (named '( + univ_gene @ + anr imp_r_forall_disjoint @ + univ_gene @ + syl (anl impexp) @ + exp @ + rsyl (anr anass) @ + rsyl ancom @ + sylc eq_trans ( + rsyl (anr anass) @ + curry @ + rsyl (iand (impcom abstraction_sorting) anr) @ + curry @ + com12 @ + imim2 (anl com12b) @ + -- unquantification of EV_lc_lam + var_subst_same_var @ + anl imp_r_forall_disjoint @ + var_subst_same_var EV_lc_lam + ) + ( sylc eq_trans ( + syl ,(imp_eq_framing_subst 'appCtxRVar) @ + rsyl (anr anass) @ + curry @ + rsyl (iand anr id) @ + rsyl (anr anass) @ + curry @ + curry @ + --- unquantification of EV_abstraction + rsyl (var_subst_same_var @ anl imp_r_forall_disjoint @ var_subst_same_var @ EV_abstraction Var_atom Exp_sort) @ + rsyl (imim2 @ anl com12b) @ + rsyl (anl com12b) @ + imim2 @ + anl com12b + ) ( + rsyl anr @ + syl ,(imp_eq_framing_subst 'appCtxRLRVar) @ + curry @ + var_subst_same_var @ + anl imp_r_forall_disjoint @ + var_subst_same_var @ + S3 Var_atom + )) + )); + +theorem EV_lc_var_lemma {a b: EVar} (phi: Pattern a b): + $ s_forall Var a (s_forall Var b (is_var phi -> ((swap (eVar a) (eVar b) (lc_var phi)) == lc_var (swap (eVar a) (eVar b) phi)))) $ = + '( + univ_gene @ + anr imp_r_forall_disjoint @ + univ_gene @ + syl (anl impexp) @ + exp @ + rsyl (anr anass) @ + rsyl ancom @ + rsyl (anr anass) @ + curry @ + curry @ + com12 @ + imim2 (anl com12b) @ + -- unquantification of EV_lc_var + var_subst_same_var @ + anl imp_r_forall_disjoint @ + var_subst_same_var EV_lc_var + ); + + +theorem exp_pred_ev_unquantified {x y: EVar} (exp_pred: Pattern): + $ EV_pattern Var exp_pred -> (is_var (eVar x)) /\ (is_var (eVar y)) -> ((swap (eVar x) (eVar y) exp_pred) == exp_pred) $ = + '(rsyl var_subst_same_var @ rsyl (imim2 var_subst_same_var) @ anr impexp); + +theorem lc_lemma_1 {x: EVar} (exp_pred exp_suff_fresh: Pattern): + $ is_var exp_suff_fresh -> + |^ exp_suff_fresh ^| -> + ((lc_lam (abstraction exp_suff_fresh exp_pred)) C= exp_pred) -> + s_exists Var x ((lc_lam_a (eVar x) exp_pred) C= exp_pred) $ = + '(exp @ exp @ + rsyl (anim1 @ anim2 @ anl lemma_ceil_exists_membership) @ + rsyl (anim1 and_exists_disjoint_reverse) @ + rsyl and_exists_disjoint_r_reverse @ + exists_framing @ + rsyl (anim1 @ iand anr @ rsyl (anim2 @ anl eVar_in_subset) @ impcom subset_trans) @ + rsyl (anl anass) @ + rsyl (anl anlass) @ + anim2 @ + curry @ + syl subset_trans @ + rsyl (anl eVar_in_subset) @ + syl ,(imp_subset_framing_subst 'appCtxRVar) + ,(imp_subset_framing_subst 'appCtxLRVar)); + +theorem lc_lmma_1_var {x: EVar} (exp_pred exp_suff_fresh: Pattern): + $ is_var exp_suff_fresh -> + |^ exp_suff_fresh ^| -> + ((lc_var exp_suff_fresh) C= exp_pred) -> + s_exists Var x ((lc_var (eVar x)) C= exp_pred) $ = + '(exp @ exp @ + rsyl (anim1 @ anim2 @ anl lemma_ceil_exists_membership) @ + rsyl (anim1 and_exists_disjoint_reverse) @ + rsyl and_exists_disjoint_r_reverse @ + exists_framing @ + rsyl (anim1 @ iand anr @ rsyl (anim2 @ anl eVar_in_subset) @ impcom subset_trans) @ + rsyl (anl anass) @ + rsyl (anl anlass) @ + anim2 @ + curry @ + syl subset_trans @ + rsyl (anl eVar_in_subset) + ,(imp_subset_framing_subst 'appCtxRVar) + ); + +theorem lc_lemma_2 {x y: EVar} (exp_pred: Pattern): + $ (is_exp exp_pred) -> + (EV_pattern Var exp_pred) -> + ((is_var (eVar x)) /\ (is_var (eVar y)) /\ ((lc_lam_a (eVar y) exp_pred) C= exp_pred)) -> + ((lc_lam_a (eVar x) exp_pred) C= exp_pred) $ = + '(exp @ exp @ + rsyl (anim2 @ anim2 ,(imp_subset_framing_subst 'appCtxRVar)) @ + rsyl (anim1 ancom) @ + rsyl (anl anass) @ + rsyl (anim2 @ iand (rsyl anr anl) @ + syl (curry subset_trans) @ + rsyl (anr anass) @ + anim1 @ + rsyl (anim2 ancom) @ + rsyl (curry @ com12 @ curry @ var_subst_same_var @ anl imp_r_forall_disjoint @ var_subst_same_var EV_lc_lam_abstraction) @ + rsyl eq_sym + eq_imp_subset) @ + rsyl (anr anass) @ + rsyl (anim1 @ anim2 ancom) @ + rsyl (anim1 @ curry exp_pred_ev_unquantified) @ + curry @ + syl anl ,(func_subst_explicit_helper 'hole $(_ @@ (_ @@ (eVar hole))) C= (eVar hole)$)); + +theorem lc_lemma_2_var {x y: EVar} (exp_pred: Pattern): + $ is_var (eVar y) /\ ((lc_var (eVar y)) C= exp_pred) -> + (EV_pattern Var exp_pred) -> + (is_var (eVar x)) -> + ((lc_var (eVar x)) C= exp_pred) $ = + '(com12 @ exp @ exp @ + rsyl (anl anass) @ + rsyl (anim2 @ rsyl ancom @ anr anass) @ + rsyl (anim2 @ anim2 ,(imp_subset_framing_subst 'appCtxRVar)) @ + rsyl (anim2 @ anim1 @ iand id @ rsyl (anim2 @ iand id id) @ rsyl (anr anass) @ rsyl (anim1 ancom) @ curry @ curry @ var_subst_same_var @ anl imp_r_forall_disjoint @ var_subst_same_var EV_lc_var_lemma) @ + rsyl (anim2 @ anl anass) @ + rsyl (anim2 @ anim2 @ anim1 @ rsyl eq_sym eq_imp_subset) @ + rsyl (anim2 @ anim2 @ curry subset_trans) @ + rsyl (anr anass) @ + rsyl (anim1 ancom) @ + rsyl (iand anl id) @ + rsyl (anim2 @ anim1 @ anim1 ancom) @ + rsyl (anim2 @ anim1 @ syl eq_imp_subset @ rsyl (anim2 @ rsyl (syl var_subst_same_var @ syl (anl imp_r_forall_disjoint) var_subst_same_var) @ anr impexp) appl) @ + rsyl (anim2 @ impcom subset_trans) @ + rsyl (anim1 @ rsyl anl @ rsyl ancom @ curry @ var_subst_same_var @ anl imp_r_forall_disjoint @ var_subst_same_var @ S3 Var_atom) @ + rsyl (anim1 @ rsyl eq_sym eq_imp_subset) @ + rsyl (anim1 ,(imp_subset_framing_subst 'appCtxRVar)) @ + curry subset_trans + ); + +theorem lc_lemma_3 {y: EVar} (exp_pred: Pattern): + $ is_var exp_suff_fresh -> + |^ exp_suff_fresh ^| -> + ((lc_lam (abstraction exp_suff_fresh exp_pred)) C= exp_pred) -> + is_exp exp_pred -> + EV_pattern Var exp_pred -> + is_var (eVar y) -> + ((lc_lam_a (eVar y) exp_pred) C= exp_pred) $ = (named + '(imim2 (imim2 @ imim2 @ + exp @ rsyl and_exists_disjoint_r_reverse @ + exp @ rsyl and_exists_disjoint_r_reverse @ + exp @ rsyl and_exists_disjoint_r_reverse @ + exists_generalization_disjoint @ + rsyl (anl anass) @ + rsyl (anl anass) @ + rsyl ancom @ + rsyl (anim1 @ anr anass) @ + rsyl (anl anass) @ + rsyl (anim2 @ anr anass) @ + curry @ curry lc_lemma_2 + ) lc_lemma_1)); + +theorem freshness_irrelevance_lam (exp_pred exp_suff_fresh: Pattern): + $ is_var exp_suff_fresh -> + |^ exp_suff_fresh ^| -> + ((lc_lam (abstraction exp_suff_fresh exp_pred)) C= exp_pred) -> + is_exp exp_pred -> + EV_pattern Var exp_pred -> + ((lc_lam (abstraction Vars exp_pred)) C= exp_pred) $ = (named + '(imim2 ( + rsyl (anr imp_r_forall_disjoint) @ imim2 @ + rsyl (anr imp_r_forall_disjoint) @ imim2 @ + rsyl (anr imp_r_forall_disjoint) @ imim2 @ + rsyl (anr imp_r_forall_disjoint) @ imim2 + ,(pointwise_decomposition_imp_subst 'appCtxRLRVar) + ) @ anr imp_r_forall_disjoint @ univ_gene lc_lemma_3)); + +theorem freshness_irrelevance_var (exp_pred exp_suff_fresh: Pattern): + $ is_var exp_suff_fresh -> + |^ exp_suff_fresh ^| -> + ((lc_var exp_suff_fresh) C= exp_pred) -> + EV_pattern Var exp_pred -> + ((lc_var Vars) C= exp_pred) $ = + (named '(imim2 (imim2 @ imim2 @ + exists_generalization_disjoint @ + imim2 (rsyl (anr imp_r_forall_disjoint) @ imim2 ,(pointwise_decomposition_imp_subst 'appCtxRVar)) @ anr imp_r_forall_disjoint @ univ_gene lc_lemma_2_var + ) lc_lmma_1_var)); + +theorem simple_induction_principle (exp_pred: Pattern): + $ (is_exp exp_pred) -> + ((lc_var Vars) C= exp_pred) -> + ((lc_app exp_pred exp_pred) C= exp_pred) -> + ((lc_lam (abstraction Vars exp_pred)) C= exp_pred) -> + (Exps == exp_pred) $ = + (named '(exp @ exp @ exp @ + syl (curry @ com12 subset_to_eq) @ + iand an3l @ + syl (subset_trans @ eq_imp_subset no_junk) @ + rsyl (anim1 @ anim1 anr) @ + rsyl (anim1 @ anl and_subset) @ + rsyl (anl and_subset) + ,(KT_subset_subst + (propag_s_subst 'X $bot \/ (bot @@ (sVar X) @@ (sVar X)) \/ (bot @@ (bot @@ bot @@ (sVar X)))$) + '(positive_in_or (positive_in_or positive_disjoint @ positive_in_app (positive_in_app positive_disjoint positive_in_same_sVar) positive_in_same_sVar) @ positive_in_app positive_disjoint @ positive_in_app positive_disjoint positive_in_same_sVar) + (floor_extract 'x $_ \/ (_ @@ (eVar x) @@ (eVar x)) \/ (_ @@ (_ @@ _ @@ (eVar x)))$)))); + +theorem induction_principle (exp_pred exp_suff_fresh_var exp_suff_fresh_lam: Pattern): + $ (is_var exp_suff_fresh_var) -> + |^ exp_suff_fresh_var ^| -> + (is_var exp_suff_fresh_lam) -> + |^ exp_suff_fresh_lam ^| -> + (is_exp exp_pred) -> + (EV_pattern Var exp_pred) -> + ((lc_var exp_suff_fresh_var) C= exp_pred) -> + ((lc_app exp_pred exp_pred) C= exp_pred) -> + ((lc_lam (abstraction exp_suff_fresh_lam exp_pred)) C= exp_pred) -> + (Exps == exp_pred) $ = + (named '(exp @ exp @ exp @ exp @ exp @ exp @ exp @ exp @ + syl (curry subset_to_eq) @ + iand (syl (subset_trans @ eq_imp_subset no_junk) @ rsyl (syl (anr floor_idem) @ + rsyl (anim (anim (anim (anim (anim (anim (anim (anim (anr floor_idem) (anr floor_ceil_ceil)) (anr floor_idem)) (anr floor_ceil_ceil)) (anr floor_idem)) (syl (anr forall_floor) @ forall_framing @ syl floor_imp_lemma @ imim2 @ syl (anr forall_floor) @ forall_framing @ syl floor_imp_lemma @ imim2 @ anr floor_idem)) (anr floor_idem)) (anr floor_idem)) (anr floor_idem)) @ + rsyl (anim1 ( + rsyl (anim1 ( + rsyl (anim1 ( + rsyl (anim1 ( + rsyl (anim1 ( + rsyl (anim1 ( + rsyl (anim1 ( + rsyl (anim1 id) @ + anr propag_and_floor)) @ + anr propag_and_floor)) @ + anr propag_and_floor)) @ + anr propag_and_floor)) @ + anr propag_and_floor)) @ + anr propag_and_floor)) @ + anr propag_and_floor)) @ + anr propag_and_floor + ) @ framing_floor @ com12 @ + KT_subst + (positive_in_or (positive_in_or positive_disjoint @ positive_in_app (positive_in_app positive_disjoint positive_in_same_sVar) positive_in_same_sVar) @ positive_in_app positive_disjoint @ positive_in_app positive_disjoint positive_in_same_sVar) + ,(propag_s_subst_adv 'X $a \/ (app (app a (sVar X)) (sVar X)) \/ (app a (app a (sVar X)))$ (atom-map! '[a #t])) @ + eori (eori + (com12 @ rsyl corollary_57_floor @ syl corollary_57_floor @ + prop_2 (prop_2 (prop_2 (prop_2 (prop_1 freshness_irrelevance_var) an8l) an7lr) anllr) an3lr + ) + (syl imidm @ imim2 (imim2 @ syl imidm @ imim2 (imim2 @ com12 @ rsyl corollary_57_floor @ syl corollary_57_floor @ + anlr + ) + ,(floor_imp_in_appCtx_subst 'appCtxLRVar)) + ,(floor_imp_in_appCtx_subst 'appCtxRVar))) + (syl imidm @ imim2 (imim2 @ com12 @ rsyl corollary_57_floor @ syl corollary_57_floor @ + prop_2 (prop_2 (prop_2 (prop_2 (prop_2 (prop_1 freshness_irrelevance_lam) an6lr) an5lr) anr) an4lr) an3lr + ) + ,(floor_imp_in_appCtx_subst @ appCtx_constructor '[1 1])) + ) + an4lr)); + + +---- Substitution + +-- base term and definition +term subst_sym: Symbol; +def subst (a phi1 phi2: Pattern): Pattern = $ (sym subst_sym) @@ a @@ phi1 @@ phi2 $; + +-- subst axioms +axiom function_subst: $ ,(is_function '(sym subst_sym) '[Var Exp Exp] 'Exp) $; +axiom EV_subst {a b: EVar} (c phi plug: Pattern a b): + $ s_forall Var a (s_forall Var b ( + (is_var c) -> + (is_exp phi) -> + (is_exp plug) -> + ((swap (eVar a) (eVar b) (subst c phi plug)) == subst (swap (eVar a) (eVar b) c) (swap (eVar a) (eVar b) phi) (swap (eVar a) (eVar b) plug)))) $; +axiom subst_fresh {a: EVar} (phi plug: Pattern a): + $ s_forall Var a ( + (is_exp phi) -> + (is_exp plug) -> + (fresh_for (eVar a) phi) -> + ((subst (eVar a) phi plug) == phi)) $; +axiom subst_same_var {a: EVar} (plug: Pattern a): + $ s_forall Var a ( + (is_exp plug) -> + ((subst (eVar a) (lc_var (eVar a)) plug) == plug)) $; +axiom subst_diff_var {a b: EVar} (plug: Pattern a b): + $ s_forall Var a ( + s_forall Var b ( + ((eVar a) != (eVar b)) -> + (is_exp plug) -> + ((subst (eVar b) (lc_var (eVar a)) plug) == (lc_var (eVar a))))) $; +axiom subst_var {a b: EVar} (plug: Pattern a b): + $ s_forall Var a ( + s_forall Var b ( + ((eVar a) == (eVar b)) -> + (is_exp plug) -> + ((subst (eVar b) (lc_var (eVar a)) plug) == plug))) $; +axiom subst_app {a: EVar} (phi1 phi2 plug: Pattern a): + $ s_forall Var a ( + (is_exp plug) -> + (is_exp phi1) -> + (is_exp phi2) -> + ((subst (eVar a) (lc_app phi1 phi2) plug) == (lc_app (subst (eVar a) phi1 plug) (subst (eVar a) phi2 plug)))) $; +axiom subst_lam {a b: EVar} (plug phi: Pattern a b): + $ s_forall Var a ( + s_forall Var b ( + ((eVar a) == (eVar b)) -> + (is_exp plug) -> + (is_exp phi) -> + ((subst (eVar b) (lc_lam (abstraction (eVar a) phi)) plug) == (lc_lam (abstraction (eVar a) phi))))) $; +axiom subst_lam_diff_var {a b: EVar} (plug phi: Pattern a b): + $ s_forall Var a ( + s_forall Var b ( + ((eVar a) != (eVar b)) -> + (fresh_for (eVar a) plug) -> + (is_exp plug) -> + (is_exp phi) -> + ((subst (eVar b) (lc_lam (abstraction (eVar a) phi)) plug) == (lc_lam (abstraction (eVar a) (subst (eVar b) phi plug)))))) $; + +theorem Var_nominal_sort: $ is_nominal_sort Var $ = + '(anim2 (com12 subset_trans atoms_nominal_sorts) Var_atom); + +theorem S2_lam {a b: EVar} (phi: Pattern a b): + $ (is_var (eVar a)) -> + (is_var (eVar b)) -> + (is_exp phi) -> + ((swap (eVar a) (eVar b) (swap (eVar a) (eVar b) phi)) == phi) $ = + '(mp ,(inst_foralls 2) @ S2 Var_atom Exp_sort); + +theorem S2_lam_var {a b: EVar} (phi: Pattern a b): + $ (is_var (eVar a)) -> + (is_var (eVar b)) -> + (is_var phi) -> + ((swap (eVar a) (eVar b) (swap (eVar a) (eVar b) phi)) == phi) $ = + '(mp ,(inst_foralls 2) @ S2 Var_atom Var_nominal_sort); + +theorem EV_supp_lam {a b: EVar} (phi: Pattern a b): + $ (is_var (eVar a)) -> + (is_var (eVar b)) -> + (is_exp phi) -> + ((swap (eVar a) (eVar b) (supp phi)) == supp (swap (eVar a) (eVar b) phi)) $ = + '(mp ,(inst_foralls 2) @ EV_supp Var_atom Exp_sort); + +theorem EV_subst_lam {a b: EVar} (c phi plug: Pattern a b): + $ (is_var (eVar a)) -> + (is_var (eVar b)) -> + (is_var c) -> + (is_exp phi) -> + (is_exp plug) -> + ((swap (eVar a) (eVar b) (subst c phi plug)) == subst (swap (eVar a) (eVar b) c) (swap (eVar a) (eVar b) phi) (swap (eVar a) (eVar b) plug)) $ = + '(mp ,(inst_foralls 2) EV_subst); + +theorem subst_sorting (c phi plug: Pattern): + $ (is_var c) -> + (is_exp phi) -> + (is_exp plug) -> + (is_exp (subst c phi plug)) $ = + (named (function_sorting 3 'function_subst)); + +-- induction proof +def subst_induction_pred (a b phi plug1 plug2: Pattern): Pattern = + $ (subst b (subst a phi plug1) plug2) == (subst a (subst b phi plug2) (subst b plug1 plug2)) $; +def satisfying_exps {.x .a .b .plug1 .plug2: EVar}: Pattern = + $ s_exists Exp x ((eVar x) /\ s_forall Var a (s_forall Var b (s_forall Exp plug1 (s_forall Exp plug2 ((fresh_for (eVar a) (eVar plug2)) /\ (eVar a != eVar b) -> subst_induction_pred (eVar a) (eVar b) (eVar x) (eVar plug1) (eVar plug2)))))) $; + +theorem satisfying_exps_sorting: $ is_exp satisfying_exps $ = + (named '(imp_to_subset @ rsyl (exists_framing @ rsyl (anr anass) anl) @ syl lemma_62_forward @ exists_framing @ anim1 eVar_in_subset_reverse)); + +theorem curried_function_swap {a b t: EVar}: + $ is_var (eVar a) /\ is_var (eVar b) /\ is_exp (eVar t) -> is_sorted_func Exps (swap (eVar a) (eVar b) (eVar t))$ = + (named '(curry @ curry @ mp ,(inst_foralls 3) @ function_swap Var_atom Exp_sort)); +theorem curried_function_swap_atom {a b c: EVar}: + $ is_var (eVar a) /\ is_var (eVar b) /\ is_var (eVar c) -> is_sorted_func Vars (swap (eVar a) (eVar b) (eVar c))$ = + (named '(curry @ curry @ mp ,(inst_foralls 3) @ function_swap_atom Var_atom)); + + + +theorem satisfying_exps_is_exp: $ is_exp satisfying_exps $ = + (named '(imp_to_subset @ exists_generalization_disjoint @ rsyl (anim2 anl) @ curry subset_to_imp)); + +theorem subset_trans_var_lemma {x: EVar} (phi psi: Pattern x): + $ (phi C= psi) -> (x in phi) -> ((eVar x) C= psi) $ = + '(rsyl (com12 subset_trans) @ imim1 eVar_in_subset_forward); + +theorem var_in_satisfying_exps: + $(x in satisfying_exps) <-> (is_exp (eVar x)) /\ s_forall Var a (s_forall Var b (s_forall Exp plug1 (s_forall Exp plug2 ((fresh_for (eVar a) (eVar plug2)) /\ (eVar a != eVar b) -> subst_induction_pred (eVar a) (eVar b) (eVar x) (eVar plug1) (eVar plug2)))))$ = + (named '(ibii + (iand (subset_trans_var_lemma satisfying_exps_is_exp) @ + rsyl (anl ,(propag_mem 'x $exists y (|_ _ _| /\ (eVar y /\ (forall _ (|_ _ _| -> forall _ (|_ _ _| -> forall _ (|_ _ _| -> forall _ (|_ _ _| -> ((~(|_ _ _|)) /\ ~(|_ _ _|)) -> |_ _ _|)))))))$)) @ + exists_generalization_disjoint @ + rsyl anr @ + curry @ + syl anr ,(func_subst_explicit_helper 'x $forall _ (bot -> (forall _ (bot -> (forall _ (bot -> (forall _ (bot -> bot -> ((app (app bot (app (app bot (eVar x)) bot)) bot) == (app (app bot (app (app bot (eVar x)) bot)) bot)))))))))$)) @ + + syl (anr ,(propag_mem 'x $exists y (|_ _ _| /\ (eVar y /\ (forall _ (|_ _ _| -> forall _ (|_ _ _| -> forall _ (|_ _ _| -> forall _ (|_ _ _| -> ((~(|_ _ _|)) /\ ~(|_ _ _|)) -> |_ _ _|)))))))$)) @ + syl ,(exists_intro_subst @ propag_e_subst 'x $((eVar x) C= bot) /\ ((bot == (eVar x)) /\ (forall _ (bot -> (forall _ (bot -> (forall _ (bot -> (forall _ (bot -> bot -> ((app (app bot (app (app bot (eVar x)) bot)) bot) == (app (app bot (app (app bot (eVar x)) bot)) bot)))))))))))$) @ + anim2 @ ian eq_refl)); + +theorem EV_set: $ EV_pattern Var satisfying_exps $ = + (named '(univ_gene @ anr imp_r_forall_disjoint @ univ_gene @ exp @ syl (curry subset_to_eq) @ syl + (iand anr @ rsyl (anim + (syl eq_imp_subset @ syl eq_sym @ com12 (curry S2_lam) satisfying_exps_sorting) + ,(imp_subset_framing_subst 'appCtxRVar)) @ + curry subset_trans) @ + iand id @ + syl (subset_trans @ imp_to_subset @ anl ,(ex_appCtx_subst 'appCtxRVar)) @ + rsyl (anl floor_of_floor_and) @ + framing_floor @ + exp @ + rsyl and_exists_disjoint_reverse @ + exists_generalization_disjoint @ + rsyl (anim2 ,(appCtx_floor_commute_b_subst 'appCtxRVar)) @ + sylc + ,(func_subst_alt_thm_sorted 'x $(eVar x) /\ forall _ (_ -> forall _ (_ -> forall _ (_ -> forall _ (_ -> _ -> ((_ @@ _ @@ (_ @@ _ @@ (eVar x) @@ _) @@ _) == (_ @@ _ @@ (_ @@ _ @@ (eVar x) @@ _) @@ _))))))$) + (rsyl (anim2 anl) curried_function_swap) @ + rsyl (anim2 @ anim2 ,(extract_pred_from_appCtx_r $s_forall _ _ (s_forall _ _ (s_forall _ _ (s_forall _ _ ((~ (_ == _)) /\ (~ (_ == _)) -> (_ == _)))))$ 'appCtxRVar)) @ + rsyl (anim2 @ anl anlass) @ + rsyl (anl anlass) @ + anim2 @ + mp ,(forall_imp_push 1) @ univ_gene @ + mp ,(forall_imp_push 2) @ univ_gene @ + mp ,(forall_imp_push 3) @ univ_gene @ + mp ,(forall_imp_push 4) @ univ_gene @ + expcom @ expcom @ expcom @ expcom @ expcom @ + rsyl (anr anass) @ + rsyl (anr anass) @ + rsyl (anr anass) @ + rsyl (anr anass) @ + rsyl (anr anass) @ + rsyl (anr anass) @ + rsyl (iand anl @ anim1 @ rsyl (iand anllr anlr) @ rsyl ancom curried_function_swap_atom) @ + rsyl (anim2 @ curry + ,(func_subst_explicit_thm_sorted 'x1 $((eVar x1) C= bot) -> forall y (((eVar y) C= bot) -> forall y (bot -> forall y (bot -> ((~((eVar x1) C= bot)) /\ ~((eVar x1) == bot)) -> ((bot @@ bot @@ (bot @@ (eVar x1) @@ bot @@ bot) @@ bot) == (bot @@ (eVar x1) @@ bot @@ bot)))))$)) @ + rsyl (iand anl @ anim1 @ rsyl (iand an3lr anlr) @ rsyl ancom curried_function_swap_atom) @ + rsyl (anim2 @ curry + ,(func_subst_explicit_thm_sorted 'x2 $((eVar x2) C= bot) -> forall y (bot -> forall y (bot -> (bot /\ ~(bot == (eVar x2))) -> ((bot @@ (eVar x2) @@ bot @@ bot) == (bot @@ bot @@ (bot @@ (eVar x2) @@ bot @@ bot) @@ (bot @@ (eVar x2) @@ bot @@ bot)))))$)) @ + rsyl (iand anl @ anim1 @ rsyl (iand an4lr anlr) @ rsyl ancom curried_function_swap) @ + rsyl (anim2 @ curry + ,(func_subst_explicit_thm_sorted 'x3 $((eVar x3) C= bot) -> forall y (bot -> bot -> ((bot @@ bot @@ (bot @@ bot @@ bot @@ (eVar x3)) @@ bot) == (bot @@ bot @@ bot @@ (bot @@ bot @@ (eVar x3) @@ bot))))$)) @ + rsyl (iand anl @ anim1 @ rsyl (iand an5lr anlr) @ rsyl ancom curried_function_swap) @ + rsyl (anim2 @ curry + ,(func_subst_explicit_thm_sorted 'x4 $((eVar x4) C= bot) -> ((~(bot C= (bot @@ (eVar x4)))) /\ bot) -> ((bot @@ bot @@ bot @@ (eVar x4)) == (bot @@ bot @@ (bot @@ (eVar x4)) @@ (bot @@ bot @@ bot @@ (eVar x4))))$) + ) @ + curry @ + eimd (iand + (rsyl + (iand + (iand + (rsyl (iand anlr anllr) @ curry @ curry S2_lam_var) + (rsyl (iand anlr an5lr) @ iand (curry @ curry S2_lam) (rsyl (iand anl @ curry @ curry swap_sorting) @ curry @ curry EV_supp_lam))) + an7l) @ + curry @ syl con3 @ exp @ + rsyl (anim2 ,(subset_framing_imp_subst 'appCtxRVar)) @ + rsyl (anim1 @ anim (rsyl eq_sym eq_imp_subset) @ anim (syl ,(subset_framing_imp_subst 'appCtxRVar) eq_imp_subset) eq_imp_subset) @ + rsyl (iand (syl (curry subset_trans) @ iand anll anr) @ rsyl anlr @ rsyl ancom @ curry subset_trans) @ + curry subset_trans) + (rsyl + (iand (iand + (rsyl (iand anlr anllr) @ curry @ curry S2_lam_var) + (rsyl (iand anlr an3lr) @ curry @ curry S2_lam_var)) + an6lr) @ + curry @ syl con3 @ exp @ + rsyl (anl anass) @ + rsyl (anim eq_sym @ rsyl ancom @ rsyl (anim1 ,(eq_framing_imp_subst 'appCtxRVar)) @ curry eq_trans) + @ curry eq_trans)) @ + exp @ + rsyl (anim2 ,(eq_framing_imp_subst 'appCtxRVar)) @ + rsyl (iand anl @ syl (curry eq_trans) @ + anim1 @ syl eq_sym @ syl (curry @ curry @ curry @ curry EV_subst_lam) @ iand (iand (iand anlr (syl (curry @ curry swap_sorting_var) @ iand anlr an3lr)) @ syl (curry @ curry subst_sorting) @ iand (iand (syl (curry @ curry swap_sorting_var) @ iand anlr anllr) anr) (syl (curry @ curry swap_sorting) @ iand anlr an4lr)) (syl (curry @ curry swap_sorting) @ iand anlr an5lr)) @ + rsyl (iand anl @ syl (curry eq_trans) @ + anim1 @ syl eq_sym @ syl ,(eq_framing_imp_subst @ appCtx_constructor '[0 0 1]) @ syl (curry @ curry S2_lam_var) @ iand anlr an3lr) @ + rsyl (iand anl @ syl (curry eq_trans) @ + anim1 @ syl eq_sym @ syl ,(eq_framing_imp_subst @ appCtx_constructor '[1]) @ syl (curry @ curry S2_lam) @ iand anlr an5lr) @ + rsyl (iand anl @ syl (curry eq_trans) @ + anim1 @ syl eq_sym @ syl ,(eq_framing_imp_subst @ appCtx_constructor '[0 1]) @ syl (curry @ curry @ curry @ curry EV_subst_lam) @ iand (iand (iand anlr @ syl (curry @ curry swap_sorting_var) @ iand anlr anllr) anr) @ syl (curry @ curry swap_sorting) @ iand anlr an4lr) @ + rsyl (iand anl @ syl (curry eq_trans) @ + anim1 @ syl eq_sym @ syl ,(eq_framing_imp_subst @ appCtx_constructor '[0 1]) @ + syl ,(eq_framing_imp_subst @ appCtx_constructor '[0 0 1]) @ syl (curry @ curry S2_lam_var) @ iand anlr anllr) @ + rsyl (iand anl @ syl (curry eq_trans) @ + anim1 @ syl eq_sym @ syl ,(eq_framing_imp_subst @ appCtx_constructor '[0 1]) @ + syl ,(eq_framing_imp_subst @ appCtx_constructor '[1]) @ syl (curry @ curry S2_lam) @ iand anlr an4lr) @ + curry @ + syl (com12 eq_trans) @ + sylc eq_trans (syl (curry @ curry @ curry @ curry EV_subst_lam) @ iand (iand (iand anlr @ syl (curry @ curry swap_sorting_var) @ iand anlr anllr) @ syl (curry @ curry subst_sorting) @ iand (iand (syl (curry @ curry swap_sorting_var) @ iand anlr an3lr) anr) @ syl (curry @ curry swap_sorting) @ iand anlr an5lr) @ syl (curry @ curry subst_sorting) @ iand (iand (syl (curry @ curry swap_sorting_var) @ iand anlr an3lr) (syl (curry @ curry swap_sorting) @ iand anlr an4lr)) (syl (curry @ curry swap_sorting) @ iand anlr an5lr)) @ + sylc eq_trans (syl ,(eq_framing_imp_subst @ appCtx_constructor '[0 0 1]) @ syl (curry @ curry S2_lam_var) @ iand anlr anllr) @ + sylc eq_trans (syl ,(eq_framing_imp_subst @ appCtx_constructor '[0 1]) @ + sylc eq_trans + (syl (curry @ curry @ curry @ curry EV_subst_lam) @ iand4 anlr (syl (curry @ curry swap_sorting_var) @ iand anlr an3lr) anr (syl (curry @ curry swap_sorting) @ iand anlr an5lr)) @ + sylc eq_trans + (syl ,(eq_framing_imp_subst @ appCtx_constructor '[0 0 1]) @ syl (curry @ curry S2_lam_var) @ iand anlr an3lr) + (syl ,(eq_framing_imp_subst @ appCtx_constructor '[1]) @ syl (curry @ curry S2_lam) @ iand anlr an5lr)) @ + sylc eq_trans (syl ,(eq_framing_imp_subst @ appCtx_constructor '[1]) @ + sylc eq_trans + (syl (curry @ curry @ curry @ curry EV_subst_lam) @ iand4 anlr (syl (curry @ curry swap_sorting_var) @ iand anlr an3lr) (syl (curry @ curry swap_sorting) @ iand anlr an4lr) (syl (curry @ curry swap_sorting) @ iand anlr an5lr)) @ + sylc eq_trans + (syl ,(eq_framing_imp_subst @ appCtx_constructor '[0 0 1]) @ syl (curry @ curry S2_lam_var) @ iand anlr an3lr) @ + sylc eq_trans + (syl ,(eq_framing_imp_subst @ appCtx_constructor '[0 1]) @ syl (curry @ curry S2_lam) @ iand anlr an4lr) + (syl ,(eq_framing_imp_subst @ appCtx_constructor '[1]) @ syl (curry @ curry S2_lam) @ iand anlr an5lr)) @ + a1i eq_refl)); + +theorem satisfying_exps_EV_conversion {a b x: EVar}: + $ (is_var (eVar a)) -> + (is_var (eVar b)) -> + (x in satisfying_exps) -> + ((swap (eVar a) (eVar b) (eVar x)) C= satisfying_exps) $ = + '(rsyl (mp ,(inst_foralls 2) EV_set) @ + imim2 @ + rsyl eq_sym @ + mp ,(func_subst_imp_to_var 'x $bot -> (bot C= (eVar x))$) @ + rsyl eVar_in_subset_forward ,(imp_subset_framing_subst 'appCtxRVar)); + +theorem satisfying_exps_EV_conversion_func {a b x y: EVar}: + $ (is_var (eVar a)) -> + (is_var (eVar b)) -> + (x in satisfying_exps) -> + (is_sorted_func satisfying_exps (swap (eVar a) (eVar b) (eVar x))) $ = + (named '(exp @ exp @ + rsyl (iand id @ curry @ curry satisfying_exps_EV_conversion) @ + rsyl (anim1 @ rsyl (anim2 @ subset_trans_var_lemma satisfying_exps_is_exp) curried_function_swap) @ + rsyl and_exists_disjoint_r_reverse @ + exists_framing @ + iand ( + rsyl (anim1 @ rsyl anr eq_imp_subset) @ + curry subset_trans + ) + anlr)); + +theorem case_analysis_lemma: + $ c -> a \/ (b \/ (c /\ ~a /\ ~b)) $ = + '(rsyl lemma_60_helper_1 @ rsyl orcom @ orim anr @ + rsyl lemma_60_helper_1 @ rsyl orcom @ orim1 anr); + +theorem case_analysis_var {x: EVar} (a b c: Pattern): + $ (x in c) -> (x in a) \/ ((x in b) \/ (x in (c /\ ~a /\ ~b))) $ = + '(rsyl (framing_def @ anim2 case_analysis_lemma) @ + rsyl (framing_def @ rsyl (anl andi) @ orim2 @ anl andi) @ + rsyl prop_43_or_def_rev @ + orim2 @ + prop_43_or_def_rev); + +theorem func_var_atom + (a_var: $ is_sorted_func Vars a $): + $ is_sorted_func Exps (lc_var a) $ = + (named '(mp ,(func_subst 'x $(eVar x C= _) -> exists _ (_ /\ (_ == (_ @@ (eVar x))))$ '(var_subst_same_var function_lc_var) '(exists_framing anr a_var)) @ domain_func_sorting a_var)); + + +theorem mem_func_lemma: + $ (is_func phi) -> (x in phi) -> ((eVar x) == phi) $ = + (named '(com12 ,(func_subst_explicit_thm 'y2 $(z in (eVar y2)) -> ((eVar z) == (eVar y2))$) @ univ_gene membership_var_forward)); + +theorem mem_func_lemma_neg: + $ (is_func phi) -> ~(x in phi) -> ((eVar x) != phi) $ = + (named '(com12 ,(func_subst_explicit_thm 'y2 $~(z in (eVar y2)) -> ~((eVar z) == (eVar y2))$) @ univ_gene @ con3 membership_var_reverse)); + +theorem subst_induction_var: $ (lc_var Vars) C= satisfying_exps $ = + (named '(imp_to_subset @ membership_elim_implicit @ membership_imp_reverse @ + syl (anr var_in_satisfying_exps) @ + iand (subset_trans_var_lemma @ mp ,(function_sorting_full 1) function_lc_var) @ + anr ,(forall_extract $_ -> _$) @ univ_gene @ + anr ,(forall_extract $_ -> _ -> _$) @ univ_gene @ + anr ,(forall_extract $_ -> _ -> _ -> _$) @ univ_gene @ + anr ,(forall_extract $_ -> _ -> _ -> _ -> _$) @ univ_gene @ + rsyl case_analysis_var @ + eori + (exp @ rsyl (iand (rsyl (anim2 @ + rsyl (var_subst_same_var function_lc_var) @ + rsyl (exists_framing anr) mem_func_lemma) appl) anr) @ + curry @ + mp ,(func_subst_imp_to_var 'y $bot -> bot -> bot -> bot -> bot -> ((bot @@ bot @@ (bot @@ bot @@ (eVar y) @@ bot) @@ bot) == (bot @@ bot @@ (bot @@ bot @@ (eVar y) @@ bot) @@ bot))$) @ + exp @ exp @ exp @ exp @ + sylc eq_trans ( + syl ,(imp_eq_framing_subst @ appCtx_constructor '[0 1]) @ + syl (curry @ var_subst_same_var subst_same_var) @ + iand an4l anllr) @ + syl eq_sym @ + sylc eq_trans ( + syl ,(imp_eq_framing_subst @ appCtx_constructor '[0 1]) @ + syl (curry @ curry @ curry @ mp ,(inst_foralls 2) @ subst_diff_var) @ + iand4 an4l an3lr anrr anlr) @ + syl (curry @ var_subst_same_var subst_same_var) @ + iand an4l @ + syl (curry @ curry subst_sorting) @ + iand3 an3lr anllr anlr) + @ eori + (exp @ exp @ + rsyl (iand4 + anll + (rsyl anr @ + rsyl (var_subst_same_var function_lc_var) @ + rsyl (exists_framing anr) mem_func_lemma) + anlr + anr) @ + curry @ curry @ + rsyl appl @ + mp ,(func_subst_imp_to_var 'y $bot -> bot -> bot -> bot -> bot -> ((bot @@ bot @@ (bot @@ bot @@ (eVar y) @@ bot) @@ bot) == (bot @@ bot @@ (bot @@ bot @@ (eVar y) @@ bot) @@ bot))$) @ + exp @ exp @ exp @ exp @ + sylc eq_trans ( + syl ,(imp_eq_framing_subst @ appCtx_constructor '[0 1]) @ + syl (curry @ curry @ curry @ mp ,(inst_foralls 2) @ subst_diff_var) @ + iand4 an3lr an4l (rsyl anrr @ con3 eq_sym) anllr) @ + sylc eq_trans ( + syl (curry @ var_subst_same_var subst_same_var) @ + iand an3lr anlr) @ + syl eq_sym @ + sylc eq_trans ( + syl ,(imp_eq_framing_subst @ appCtx_constructor '[0 1]) @ + syl (curry @ var_subst_same_var subst_same_var) @ + iand an3lr anlr) @ + syl (curry @ curry @ curry @ var_subst_same_var @ subst_fresh) @ + iand4 an4l anlr + (syl (curry @ curry subst_sorting) @ iand3 an3lr anllr anlr) + anrl) @ + + rsyl (anl ,(propag_mem _ $_ /\ (~ _) /\ (~ _)$)) @ + exp @ exp @ + rsyl (iand5 an4l (iand an3lr anlr) (iand anllr anr) anlr anr) @ + curry @ curry @ + rsyl (anim (anim2 @ + syl appl @ anim2 @ syl mem_func_lemma_neg @ rsyl (var_subst_same_var function_lc_var) @ exists_framing anr) @ + syl appl @ anim2 @ syl mem_func_lemma_neg @ rsyl (var_subst_same_var function_lc_var) @ exists_framing anr) @ + rsyl (anim1 @ anim1 @ anl ,(membership_appCtx_subst 'appCtxRVar)) @ + curry @ curry @ + exists_generalization_disjoint @ + rsyl (anim1 eVar_in_subset_forward) @ + rsyl (iand anl (iand anr anl)) @ + rsyl (anim2 @ syl appl @ anim2 @ syl mem_func_lemma @ rsyl (var_subst_same_var function_lc_var) @ exists_framing anr) @ + impcom @ + mp ,(func_subst_imp_to_var 'y3 $_ -> ~ (eVar y3 == bot) -> ~ (eVar y3 == bot) -> bot -> bot -> bot -> bot -> bot -> ((bot @@ bot @@ (bot @@ bot @@ (eVar y3) @@ bot) @@ bot) == (bot @@ bot @@ (bot @@ bot @@ (eVar y3) @@ bot) @@ bot))$) @ + syl (imim1 @ con3 ,(imp_eq_framing_subst 'appCtxRVar)) @ + syl (imim2 @ imim1 @ con3 ,(imp_eq_framing_subst 'appCtxRVar)) @ + exp @ exp @ exp @ exp @ exp @ exp @ exp @ + sylc eq_trans ( + syl ,(imp_eq_framing_subst @ appCtx_constructor '[0 1]) @ + syl (curry @ curry @ curry @ mp ,(inst_foralls 2) @ subst_diff_var) @ + iand4 an7l an4lr an6lr anllr) @ + sylc eq_trans ( + syl (curry @ curry @ curry @ mp ,(inst_foralls 2) @ subst_diff_var) @ + iand4 an7l an3lr an5lr anlr) @ + syl eq_sym @ + sylc eq_trans ( + syl ,(imp_eq_framing_subst @ appCtx_constructor '[0 1]) @ + syl (curry @ curry @ curry @ mp ,(inst_foralls 2) @ subst_diff_var) @ + iand4 an7l an3lr an5lr anlr) @ + sylc eq_trans ( + syl (curry @ curry @ curry @ mp ,(inst_foralls 2) @ subst_diff_var) @ + iand4 an7l an4lr an6lr @ syl (curry @ curry subst_sorting) @ iand3 an3lr anllr anlr) @ + a1i eq_refl)); + +theorem subst_induction_app: $ (lc_app satisfying_exps satisfying_exps) C= satisfying_exps $ = + (named '(imp_to_subset @ membership_elim_implicit @ membership_imp_reverse @ + syl (anr var_in_satisfying_exps) @ + iand (subset_trans_var_lemma @ mp ,(function_sorting 2 'function_lc_app) satisfying_exps_is_exp satisfying_exps_is_exp) @ + anr ,(forall_extract $_ -> _$) @ univ_gene @ + anr ,(forall_extract $_ -> _ -> _$) @ univ_gene @ + anr ,(forall_extract $_ -> _ -> _ -> _$) @ univ_gene @ + anr ,(forall_extract $_ -> _ -> _ -> _ -> _$) @ univ_gene @ + rsyl (anl ,(membership_appCtx_subst 'appCtxLRVar)) @ + rsyl (exists_framing @ anim2 @ anl ,(membership_appCtx_subst 'appCtxRVar)) @ + exists_generalization_disjoint @ + rsyl and_exists_disjoint_reverse @ + exists_generalization_disjoint @ + rsyl (anr anass) @ + rsyl (iand anl @ iand anr anl) @ + rsyl (anim2 @ syl appl @ anim2 @ syl mem_func_lemma @ syl (exists_framing anr) @ syl (curry @ mp ,(inst_foralls 2) function_lc_app) @ anim (subset_trans_var_lemma satisfying_exps_is_exp) (subset_trans_var_lemma satisfying_exps_is_exp)) @ + impcom @ + mp ,(func_subst_imp_to_var 'y3 $bot -> bot -> bot -> bot -> bot -> bot -> ((bot @@ bot @@ (bot @@ bot @@ (eVar y3) @@ bot) @@ bot) == (bot @@ bot @@ (bot @@ bot @@ (eVar y3) @@ bot) @@ bot))$) @ + exp @ exp @ exp @ exp @ exp @ + sylc eq_trans ( + syl ,(imp_eq_framing_subst @ appCtx_constructor '[0 1]) @ + syl (curry @ curry @ curry @ mp ,(inst_foralls 1) subst_app) @ + iand4 an4lr anllr (rsyl an6l @ subset_trans_var_lemma satisfying_exps_is_exp) (rsyl an5lr @ subset_trans_var_lemma satisfying_exps_is_exp)) @ + sylc eq_trans ( + syl (curry @ curry @ curry @ mp ,(inst_foralls 1) subst_app) @ + iand4 an3lr anlr (syl (curry @ curry subst_sorting) @ iand3 an4lr (rsyl an6l @ subset_trans_var_lemma satisfying_exps_is_exp) anllr) + (syl (curry @ curry subst_sorting) @ iand3 an4lr (rsyl an5lr @ subset_trans_var_lemma satisfying_exps_is_exp) anllr)) @ + syl eq_sym @ + sylc eq_trans ( + syl ,(imp_eq_framing_subst @ appCtx_constructor '[0 1]) @ + syl (curry @ curry @ curry @ mp ,(inst_foralls 1) subst_app) @ + iand4 an3lr anlr (rsyl an6l @ subset_trans_var_lemma satisfying_exps_is_exp) (rsyl an5lr @ subset_trans_var_lemma satisfying_exps_is_exp)) @ + sylc eq_trans ( + syl (curry @ curry @ curry @ mp ,(inst_foralls 1) subst_app) @ + iand4 an4lr (syl (curry @ curry subst_sorting) @ iand3 an3lr anllr anlr) (syl (curry @ curry subst_sorting) @ iand3 an3lr (rsyl an6l @ subset_trans_var_lemma satisfying_exps_is_exp) anlr) + (syl (curry @ curry subst_sorting) @ iand3 an3lr (rsyl an5lr @ subset_trans_var_lemma satisfying_exps_is_exp) anlr)) @ + syl (curry eq_trans) @ + syl (anim ,(eq_framing_imp_subst 'appCtxLRVar) ,(eq_framing_imp_subst 'appCtxRVar)) @ + iand + (curry @ curry @ curry @ curry @ curry @ + rsyl anl @ + rsyl (anl var_in_satisfying_exps) @ + rsyl anr @ + rsyl var_subst_same_var @ imim2 @ + rsyl var_subst_same_var @ imim2 @ + rsyl var_subst_same_var @ imim2 @ + rsyl var_subst_same_var @ imim2 @ + imim2 eq_sym) + (curry @ curry @ curry @ curry @ curry @ + rsyl anr @ + rsyl (anl var_in_satisfying_exps) @ + rsyl anr @ + rsyl var_subst_same_var @ imim2 @ + rsyl var_subst_same_var @ imim2 @ + rsyl var_subst_same_var @ imim2 @ + rsyl var_subst_same_var @ imim2 @ + imim2 eq_sym))); + +theorem A1_lemma: + $ (is_var (eVar a)) /\ + (is_var (eVar b)) /\ + (is_exp phi) /\ + (fresh_for (eVar b) phi) -> + ((abstraction (eVar a) phi) == (abstraction (eVar b) (swap (eVar b) (eVar a) phi))) $ = + '(syl (syl eq_sym @ curry @ syl anr @ curry @ curry @ curry @ mp ,(inst_foralls 2) @ A1 Var_atom Exp_sort) @ + iand5 + anllr + an3l + (syl (curry @ curry @ swap_sorting) @ rsyl anl @ anim1 ancom) + anlr + (syl orr @ iand anr @ rsyl anl @ syl (curry @ curry S2_lam) @ anim1 ancom)); + +theorem subst_induction_lam_lemma: + $ n in Vars /\ + (q in satisfying_exps /\ + o in (sym lc_lam_sym @@ (sym abstraction_sym @@ eVar n @@ eVar q))) /\ + (eVar i C= dom Var) /\ + (eVar j C= dom Var) /\ + (eVar k C= dom Exp) /\ + (eVar l C= dom Exp) /\ + (fresh_for (eVar i) (eVar l) /\ (eVar i != eVar j)) -> + (s_exists Var a ( + (fresh_for (eVar a) (eVar q)) /\ + (fresh_for (eVar a) (eVar i)) /\ + (fresh_for (eVar a) (eVar j)) /\ + (fresh_for (eVar a) (eVar k)) /\ + (fresh_for (eVar a) (eVar l)) /\ + (fresh_for (eVar a) (subst (eVar j) (eVar k) (eVar l))))) $ = + (named '( + syl (exists_framing @ + syl (anim2 @ anim1 @ anim1 @ anim1 @ anim1 @ curry @ curry @ curry @ mp var_subst_same_var @ fresh_comma Var_atom Exp_sort Var_nominal_sort) @ + syl (anim2 @ anim1 @ anim1 @ anim1 @ syl (anr anass) @ iand anll @ syl (curry @ curry @ curry @ var_subst_same_var @ fresh_comma Var_atom comma_sort_nominal Var_nominal_sort) @ anim1 @ anim1 @ rsyl (anl anass) @ anim2 @ curry ,(function_sorting 2 '(function_comma Exp_sort Var_nominal_sort))) @ + syl (anim2 @ anim1 @ anim1 @ syl (anr anass) @ iand anll @ syl (curry @ curry @ curry @ var_subst_same_var @ fresh_comma Var_atom comma_sort_nominal Exp_sort) @ anim1 @ anim1 @ rsyl (anl anass) @ rsyl (anl anass) @ anim2 @ rsyl (anr anass) @ rsyl (anim1 @ curry ,(function_sorting 2 '(function_comma Exp_sort Var_nominal_sort))) @ curry ,(function_sorting 2 '(function_comma comma_sort_nominal Var_nominal_sort))) @ + syl (anim2 @ anim1 @ syl (anr anass) @ iand anll @ syl (curry @ curry @ curry @ var_subst_same_var @ fresh_comma Var_atom comma_sort_nominal Exp_sort) @ anim1 @ anim1 @ rsyl (anl anass) @ rsyl (anl anass) @ rsyl (anl anass) @ anim2 @ rsyl (anr anass) @ rsyl (anr anass) @ rsyl (anim1 @ rsyl (anim1 @ curry ,(function_sorting 2 '(function_comma Exp_sort Var_nominal_sort))) @ curry ,(function_sorting 2 '(function_comma comma_sort_nominal Var_nominal_sort))) @ curry ,(function_sorting 2 '(function_comma comma_sort_nominal Exp_sort))) @ + syl (anim2 @ syl (anr anass) @ iand anll @ syl (curry @ curry @ curry @ var_subst_same_var @ fresh_comma Var_atom comma_sort_nominal Exp_sort) @ anim1 @ anim1 @ rsyl (anl anass) @ rsyl (anl anass) @ rsyl (anl anass) @ rsyl (anl anass) @ anim2 @ rsyl (anr anass) @ rsyl (anr anass) @ rsyl (anr anass) @ rsyl (anim1 @ rsyl (anim1 @ rsyl (anim1 @ curry ,(function_sorting 2 '(function_comma Exp_sort Var_nominal_sort))) @ curry ,(function_sorting 2 '(function_comma comma_sort_nominal Var_nominal_sort))) @ curry ,(function_sorting 2 '(function_comma comma_sort_nominal Exp_sort))) @ curry ,(function_sorting 2 '(function_comma comma_sort_nominal Exp_sort))) @ + syl (anim2 @ anim1 @ anim1 @ anim1 @ anim1 @ anim1 @ anim1 @ ancom) @ + syl (anim2 @ anim1 @ anim1 @ anim1 @ anim1 @ anim1 @ anl anrass) @ + syl (anim2 @ anim1 @ anim1 @ anim1 @ anim1 @ anl anrass) @ + syl (anim2 @ anim1 @ anim1 @ anim1 @ anl anrass) @ + syl (anim2 @ anim1 @ anim1 @ anl anrass) @ + syl (anim2 @ anim1 @ anl anrass) @ + syl (anim2 @ anl anrass) @ + syl (anim2 @ ancom) @ + syl (anl anass) @ + syl (anim1 @ anr anidm) @ + syl (ancom) @ + anr anass) @ + syl and_exists_disjoint_reverse @ + syl (anim2 @ exists_framing ancom) @ + iand7 + (rsyl an5lr @ rsyl anl @ subset_trans_var_lemma satisfying_exps_is_exp) + an4lr + an3lr + anllr + anlr + (syl (curry @ curry subst_sorting) @ iand3 an3lr anllr anlr) @ + syl (F4 Var_atom comma_sort_nominal) @ + rsyl (iand (syl (curry @ curry @ mp ,(inst_foralls 3) function_subst) @ iand3 an3lr anllr anlr) id) @ + rsyl and_exists_disjoint_r_reverse @ + exists_generalization_disjoint @ + rsyl (anim1 ancom) @ + rsyl (anim1 @ anim1 eq_sym) @ + rsyl (anl anass) @ + curry @ + mp ,(func_subst_imp_to_var 'x1 $bot -> exists _ (bot /\ (bot == (bot @@ (eVar x1))))$) @ + rsyl ancom @ + rsyl (iand (syl (curry @ mp ,(inst_foralls 2) @ function_comma Exp_sort Var_nominal_sort) @ iand (rsyl an6lr @ rsyl anl @ subset_trans_var_lemma satisfying_exps_is_exp) an5lr) id) @ + rsyl and_exists_disjoint_r_reverse @ + exists_generalization_disjoint @ + rsyl (anim1 ancom) @ + rsyl (anim1 @ anim1 eq_sym) @ + rsyl (iand (syl (curry @ mp ,(inst_foralls 2) @ function_comma comma_sort_nominal Var_nominal_sort) @ iand anlr (rsyl anr an4lr)) id) @ + rsyl and_exists_disjoint_r_reverse @ + exists_generalization_disjoint @ + rsyl (anim1 ancom) @ + rsyl (anim1 @ anim1 eq_sym) @ + rsyl (iand (syl (curry @ mp ,(inst_foralls 2) @ function_comma comma_sort_nominal Exp_sort) @ iand anlr (rsyl anrr an3lr)) id) @ + rsyl and_exists_disjoint_r_reverse @ + exists_generalization_disjoint @ + rsyl (anim1 ancom) @ + rsyl (anim1 @ anim1 eq_sym) @ + rsyl (iand (syl (curry @ mp ,(inst_foralls 2) @ function_comma comma_sort_nominal Exp_sort) @ iand anlr (rsyl (rsyl anr anrr) anllr)) id) @ + rsyl and_exists_disjoint_r_reverse @ + exists_generalization_disjoint @ + rsyl (anim1 ancom) @ + rsyl (anim1 @ anim1 eq_sym) @ + rsyl (anr anass) @ + rsyl (anr anass) @ + rsyl (anr anass) @ + rsyl (anim1 @ anim (anim (anim2 anl) anl) anl) @ + rsyl (anim1 @ anim (anim (anim2 ,(imp_eq_framing_subst @ appCtx_constructor '[0 1])) ,(imp_eq_framing_subst @ appCtx_constructor '[0 1 0 1])) ,(imp_eq_framing_subst @ appCtx_constructor '[0 1 0 1 0 1])) @ + rsyl (anim1 @ anim (anim (anim (anim1 eq_sym) eq_sym) eq_sym) eq_sym) @ + rsyl (anim1 @ anl anass) @ + rsyl (anim1 @ anim2 @ curry eq_trans) @ + rsyl (anim1 @ anl anass) @ + rsyl (anim1 @ anim2 @ curry eq_trans) @ + rsyl (anim1 @ anl anrass) @ + rsyl (anim1 @ anim1 @ curry eq_trans) @ + rsyl (anl anass) @ + curry @ + rsyl eq_sym @ + mp ,(func_subst_imp_to_var 'x2 $bot -> exists _ (bot /\ (bot == (bot @@ (eVar x2) @@ bot)))$) @ + syl (curry @ mp ,(inst_foralls 2) @ function_comma comma_sort_nominal Exp_sort) @ + iand anl anrr)); + +theorem subst_induction_lam: $ (lc_lam (abstraction Vars satisfying_exps)) C= satisfying_exps $ = + (named '(imp_to_subset @ membership_elim_implicit @ membership_imp_reverse @ + syl (anr var_in_satisfying_exps) @ + iand (subset_trans_var_lemma @ mp ,(function_sorting 1 'function_lc_lam) @ mp ,(function_sorting 2 '(function_abstraction Var_atom Exp_sort)) subset_refl satisfying_exps_is_exp) @ + anr ,(forall_extract $_ -> _$) @ univ_gene @ + anr ,(forall_extract $_ -> _ -> _$) @ univ_gene @ + anr ,(forall_extract $_ -> _ -> _ -> _$) @ univ_gene @ + anr ,(forall_extract $_ -> _ -> _ -> _ -> _$) @ univ_gene @ + rsyl (anl ,(membership_appCtx_subst 'appCtxRLRVar)) @ + exists_generalization_disjoint @ + rsyl (anim2 @ anl ,(membership_appCtx_subst @ appCtx_constructor '[1 1])) @ + rsyl and_exists_disjoint_reverse @ + exists_generalization_disjoint @ + exp @ exp @ exp @ exp @ exp @ + rsyl (iand subst_induction_lam_lemma id) @ + curry @ exists_generalization_disjoint @ exp @ + rsyl (iand (syl A1_lemma @ iand4 + (rsyl anrl @ rsyl an5l eVar_in_subset_forward) + anll + (rsyl anrl @ rsyl an4lr @ rsyl anl @ subset_trans_var_lemma satisfying_exps_is_exp) + (rsyl anlr an5l)) id) @ + rsyl (iand (syl (curry @ curry satisfying_exps_EV_conversion_func) @ iand3 (rsyl anr anll) (rsyl anr @ rsyl anrl @ rsyl an5l eVar_in_subset_forward) (rsyl anr @ rsyl anrl @ rsyl an4lr anl)) id) @ + curry @ exists_generalization_disjoint @ + impcom @ + rsyl eq_sym @ + mp ,(func_subst_imp_to_var 'x2 $bot -> (bot == (bot @@ (eVar x2))) /\ bot -> bot$) @ + syl (anr impexp) @ com12 @ + mp ,(func_subst_imp_to_var 'x3 $bot -> bot /\ bot /\ (bot /\ (bot /\ (_ in (bot @@ (eVar x3)))) /\ bot /\ bot /\ bot /\ bot /\ bot) -> bot$) @ + exp @ + rsyl (syl (anl anlass) @ anim2 @ syl (anl anlass) @ anim2 @ syl ancom @ iand6 an4lr an3lr anllr anlr anr (rsyl an5l (rsyl anr anr))) @ + rsyl (iand (syl (curry mem_func_lemma) @ iand (syl (exists_framing anr) @ rsyl (anim2 @ rsyl (iand (rsyl anr anll) (rsyl anl @ com12 subset_trans satisfying_exps_is_exp)) @ curry @ mp ,(inst_foralls 2) @ function_abstraction Var_atom Exp_sort) @ rsyl ancom @ rsyl and_exists_disjoint_r_reverse @ exists_generalization_disjoint @ + rsyl (anim1 ancom) @ rsyl (anl anass) @ curry @ rsyl eq_sym @ mp ,(func_subst_imp_to_var 'x4 $bot /\ (_ in (bot @@ eVar x4)) -> exists _ (bot /\ (bot == (bot @@ eVar x4)))$) @ syl (mp ,(inst_foralls 1) function_lc_lam) anl) anl) anr) @ + curry @ + mp ,(func_subst_imp_to_var 'x5 $bot -> ((bot @@ (bot @@ (eVar x5) @@ bot) @@ bot) == (bot @@ (bot @@ (eVar x5) @@ bot) @@ bot))$) @ + sylc eq_trans ( + syl ,(imp_eq_framing_subst @ appCtx_constructor '[0 1]) @ + syl (curry @ curry @ curry @ curry @ curry @ mp ,(inst_foralls 2) subst_lam_diff_var) @ + iand6 + (rsyl anrl anl) + (rsyl anrr an4l) + (syl (curry @ syl anr @ curry @ mp ,(inst_foralls 2) @ F2 Var_atom) @ iand3 (rsyl anrl anl) (rsyl anrr an4l) (rsyl anrl @ rsyl anr an4lr)) + (rsyl anrl @ rsyl anr anllr) + (rsyl anrr anllr) + (rsyl anl @ com12 subset_trans @ satisfying_exps_is_exp)) @ + sylc eq_trans ( + syl (curry @ curry @ curry @ curry @ curry @ mp ,(inst_foralls 2) subst_lam_diff_var) @ + iand6 + (rsyl anrl anl) + (rsyl anrr an3lr) + (syl (curry @ syl anr @ curry @ mp ,(inst_foralls 2) @ F2 Var_atom) @ iand3 (rsyl anrl anl) (rsyl anrr an3lr) (rsyl anrl @ rsyl anr an3lr)) + (rsyl anrl @ rsyl anr anlr) + (rsyl anrr anlr) + (syl (curry @ curry subst_sorting) @ iand3 (rsyl anrr an4l) (rsyl anl @ com12 subset_trans @ satisfying_exps_is_exp) (rsyl anrr anllr))) @ + syl eq_sym @ + sylc eq_trans ( + syl ,(imp_eq_framing_subst @ appCtx_constructor '[0 1]) @ + syl (curry @ curry @ curry @ curry @ curry @ mp ,(inst_foralls 2) subst_lam_diff_var) @ + iand6 + (rsyl anrl anl) + (rsyl anrr an3lr) + (syl (curry @ syl anr @ curry @ mp ,(inst_foralls 2) @ F2 Var_atom) @ iand3 (rsyl anrl anl) (rsyl anrr an3lr) (rsyl anrl @ rsyl anr an3lr)) + (rsyl anrl @ rsyl anr anlr) + (rsyl anrr anlr) + (rsyl anl @ com12 subset_trans @ satisfying_exps_is_exp)) @ + sylc eq_trans ( + syl (curry @ curry @ curry @ curry @ curry @ mp ,(inst_foralls 2) subst_lam_diff_var) @ + iand6 + (rsyl anrl anl) + (rsyl anrr an4l) + (syl (curry @ syl anr @ curry @ mp ,(inst_foralls 2) @ F2 Var_atom) @ iand3 (rsyl anrl anl) (rsyl anrr an4l) (rsyl anrl @ rsyl anr an4lr)) + (rsyl anrl anrr) + (syl (curry @ curry subst_sorting) @ iand3 (rsyl anrr an3lr) (rsyl anrr anllr) (rsyl anrr anlr)) + (syl (curry @ curry subst_sorting) @ iand3 (rsyl anrr an3lr) (rsyl anl @ com12 subset_trans @ satisfying_exps_is_exp) (rsyl anrr anlr))) @ + syl eq_sym @ + syl ,(eq_framing_imp_subst @ appCtx_constructor '[1 1]) @ + curry @ + rsyl eVar_in_subset_reverse @ + rsyl (anl var_in_satisfying_exps) @ + rsyl anr @ + syl (imim1 anr) @ + rsyl ,(inst_foralls 4) @ + rsyl (anr impexp) @ + rsyl (anr impexp) @ + rsyl (anr impexp) @ + rsyl (anr impexp) @ + id)); + +theorem subst_induction_lemma: + $ Exps == satisfying_exps $ = + '(simple_induction_principle + satisfying_exps_is_exp + subst_induction_var + subst_induction_app + subst_induction_lam); + +do { + (def (satisfying_exps_expanded) $((exists x (((eVar x) C= Exps) /\ (and (eVar x) (forall a (((eVar a) C= Vars) -> (forall b (((eVar b) C= Vars) -> (forall plug1 (((eVar plug1) C= Exps) -> (forall plug2 (((eVar plug2) C= Exps) -> (imp (and (~ ((eVar a) C= ((sym supp_sym) @@ (eVar plug2)))) (_neq (eVar a) (eVar b))) ((subst (eVar b) (subst (eVar a) (eVar x) (eVar plug1)) (eVar plug2)) == (subst (eVar a) (subst (eVar b) (eVar x) (eVar plug2)) (subst (eVar b) (eVar plug1) (eVar plug2)))))))))))))))))$) +}; + +theorem subst_induction (a b phi plug1 plug2: Pattern) + (diff_atoms_ab: $ a != b $) + (a_var: $ is_sorted_func Vars a $) + (b_var: $ is_sorted_func Vars b $) + (phi_exp: $ is_exp phi $) + (plug1_exp: $ is_exp plug1 $) + (plug2_exp: $ is_sorted_func Exps plug2 $) + (a_fresh: $ fresh_for a plug2 $): + $ (subst b (subst a phi plug1) plug2) == (subst a (subst b phi plug2) (subst b plug1 plug2)) $ = + (named '(mp ,(s_forall_eq_lemma_subst (appCtx_constructor '[0 1 0 1]) (appCtx_constructor '[0 1 0 1])) @ univ_gene @ + mp (mp (exp @ com12 @ + imim2 ( + mp ,(func_subst_explicit_thm_sorted 'y1 $((eVar y1) C= bot) -> ((~ ((eVar y1) C= bot)) /\ ~ ((eVar y1) == bot)) -> + ((bot @@ + bot @@ + (bot @@ (eVar y1) @@ bot @@ bot) @@ + bot) == + (bot @@ + (eVar y1) @@ + (bot @@ bot @@ bot @@ bot) @@ + (bot @@ bot @@ bot @@ bot)))$) a_var) @ + imim2 (forall_framing @ imim2 @ + mp ,(func_subst_explicit_thm_sorted 'y2 $((eVar y2) C= bot) -> (bot /\ ~ (bot == (eVar y2))) -> + ((bot @@ + (eVar y2) @@ + bot @@ + bot) == + (bot @@ + bot @@ + (bot @@ (eVar y2) @@ bot @@ bot) @@ + (bot @@ (eVar y2) @@ bot @@ bot)))$) b_var) @ + imim2 (forall_framing @ imim2 @ forall_framing @ imim2 @ + rsyl (forall_framing @ rsyl (imim1 @ com12 subset_trans plug1_exp) @ anl com12b) @ rsyl (anr imp_r_forall_disjoint) @ imim2 + ,(s_forall_eq_lemma_subst (appCtx_constructor '[0 1 1]) (appCtx_constructor '[1 0 1]))) @ + imim2 (forall_framing @ imim2 @ forall_framing @ imim2 @ forall_framing @ imim2 @ + mp ,(func_subst_explicit_thm_sorted 'y $((eVar y) C= bot) -> ((~(bot C= (bot @@ eVar y))) /\ bot) -> + ((bot @@ + bot @@ + bot @@ + eVar y) == + (bot @@ + bot @@ + (bot @@ bot @@ bot @@ eVar y) @@ + (bot @@ bot @@ bot @@ eVar y)))$) plug2_exp) @ + anrd @ syl exists_irrelevance @ + syl (exists_framing @ rsyl (anl anlass) ,(func_subst_imp_to_var_variant 'x + $|_ eVar x -> dom Exp _| /\ + forall _ + (|_ eVar _ -> dom Var _| -> + forall _ + (|_ eVar _ -> dom Var _| -> + forall _ + (|_ eVar _ -> dom Exp _| -> + forall _ + (|_ eVar _ -> dom Exp _| -> + ~|_ eVar _ -> (_ @@ (eVar _)) _| /\ + (eVar _ != eVar _) -> + |_ (_ @@ + (eVar _) @@ + (_ @@ (eVar _) @@ (eVar x) @@ (eVar _)) @@ + (eVar _)) <-> + (_ @@ + (eVar _) @@ + (_ @@ (eVar _) @@ (eVar x) @@ (eVar _)) @@ + (_ (eVar _) @@ (eVar _) @@ (eVar _))) _|))))$ + )) @ mp (anl @ bitr membership_imp_bi @ cong_of_equiv_imp eVar_in_subset ,(propag_mem 'y + $((exists x (((eVar x) C= Exps) /\ (and (eVar x) (forall a (((eVar a) C= Vars) -> (forall b (((eVar b) C= Vars) -> (forall plug1 (((eVar plug1) C= Exps) -> (forall plug2 (((eVar plug2) C= Exps) -> (imp (and (~ ((eVar a) C= ((sym supp_sym) @@ (eVar plug2)))) (_neq (eVar a) (eVar b))) ((subst (eVar b) (subst (eVar a) (eVar x) (eVar plug1)) (eVar plug2)) == (subst (eVar a) (subst (eVar b) (eVar x) (eVar plug2)) (subst (eVar b) (eVar plug1) (eVar plug2)))))))))))))))))$ + )) @ membership_intro_implicit @ rsyl (subset_to_imp phi_exp) @ eq_to_intro subst_induction_lemma) + a_fresh) diff_atoms_ab + )); diff --git a/poetry.lock b/poetry.lock deleted file mode 100644 index a5b531d..0000000 --- a/poetry.lock +++ /dev/null @@ -1,271 +0,0 @@ -# This file is automatically @generated by Poetry and should not be changed by hand. - -[[package]] -name = "attrs" -version = "22.2.0" -description = "Classes Without Boilerplate" -category = "main" -optional = false -python-versions = ">=3.6" -files = [ - {file = "attrs-22.2.0-py3-none-any.whl", hash = "sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836"}, - {file = "attrs-22.2.0.tar.gz", hash = "sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99"}, -] - -[package.extras] -cov = ["attrs[tests]", "coverage-enable-subprocess", "coverage[toml] (>=5.3)"] -dev = ["attrs[docs,tests]"] -docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope.interface"] -tests = ["attrs[tests-no-zope]", "zope.interface"] -tests-no-zope = ["cloudpickle", "cloudpickle", "hypothesis", "hypothesis", "mypy (>=0.971,<0.990)", "mypy (>=0.971,<0.990)", "pympler", "pympler", "pytest (>=4.3.0)", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-mypy-plugins", "pytest-xdist[psutil]", "pytest-xdist[psutil]"] - -[[package]] -name = "colorama" -version = "0.4.6" -description = "Cross-platform colored terminal text." -category = "main" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" -files = [ - {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, - {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, -] - -[[package]] -name = "exceptiongroup" -version = "1.1.1" -description = "Backport of PEP 654 (exception groups)" -category = "main" -optional = false -python-versions = ">=3.7" -files = [ - {file = "exceptiongroup-1.1.1-py3-none-any.whl", hash = "sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e"}, - {file = "exceptiongroup-1.1.1.tar.gz", hash = "sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785"}, -] - -[package.extras] -test = ["pytest (>=6)"] - -[[package]] -name = "hypothesis" -version = "6.70.0" -description = "A library for property-based testing" -category = "main" -optional = false -python-versions = ">=3.7" -files = [ - {file = "hypothesis-6.70.0-py3-none-any.whl", hash = "sha256:be395f71d6337a5e8ed2f695c568360a686056c3b00c98bd818874c674b24586"}, - {file = "hypothesis-6.70.0.tar.gz", hash = "sha256:f5cae09417d0ffc7711f602cdcfa3b7baf344597a672a84658186605b04f4a4f"}, -] - -[package.dependencies] -attrs = ">=19.2.0" -exceptiongroup = {version = ">=1.0.0", markers = "python_version < \"3.11\""} -sortedcontainers = ">=2.1.0,<3.0.0" - -[package.extras] -all = ["backports.zoneinfo (>=0.2.1)", "black (>=19.10b0)", "click (>=7.0)", "django (>=3.2)", "dpcontracts (>=0.4)", "importlib-metadata (>=3.6)", "lark (>=0.10.1)", "libcst (>=0.3.16)", "numpy (>=1.9.0)", "pandas (>=1.0)", "pytest (>=4.6)", "python-dateutil (>=1.4)", "pytz (>=2014.1)", "redis (>=3.0.0)", "rich (>=9.0.0)", "tzdata (>=2022.7)"] -cli = ["black (>=19.10b0)", "click (>=7.0)", "rich (>=9.0.0)"] -codemods = ["libcst (>=0.3.16)"] -dateutil = ["python-dateutil (>=1.4)"] -django = ["django (>=3.2)"] -dpcontracts = ["dpcontracts (>=0.4)"] -ghostwriter = ["black (>=19.10b0)"] -lark = ["lark (>=0.10.1)"] -numpy = ["numpy (>=1.9.0)"] -pandas = ["pandas (>=1.0)"] -pytest = ["pytest (>=4.6)"] -pytz = ["pytz (>=2014.1)"] -redis = ["redis (>=3.0.0)"] -zoneinfo = ["backports.zoneinfo (>=0.2.1)", "tzdata (>=2022.7)"] - -[[package]] -name = "iniconfig" -version = "2.0.0" -description = "brain-dead simple config-ini parsing" -category = "main" -optional = false -python-versions = ">=3.7" -files = [ - {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, - {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, -] - -[[package]] -name = "mypy" -version = "1.1.1" -description = "Optional static typing for Python" -category = "main" -optional = false -python-versions = ">=3.7" -files = [ - {file = "mypy-1.1.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:39c7119335be05630611ee798cc982623b9e8f0cff04a0b48dfc26100e0b97af"}, - {file = "mypy-1.1.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:61bf08362e93b6b12fad3eab68c4ea903a077b87c90ac06c11e3d7a09b56b9c1"}, - {file = "mypy-1.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dbb19c9f662e41e474e0cff502b7064a7edc6764f5262b6cd91d698163196799"}, - {file = "mypy-1.1.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:315ac73cc1cce4771c27d426b7ea558fb4e2836f89cb0296cbe056894e3a1f78"}, - {file = "mypy-1.1.1-cp310-cp310-win_amd64.whl", hash = "sha256:5cb14ff9919b7df3538590fc4d4c49a0f84392237cbf5f7a816b4161c061829e"}, - {file = "mypy-1.1.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:26cdd6a22b9b40b2fd71881a8a4f34b4d7914c679f154f43385ca878a8297389"}, - {file = "mypy-1.1.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5b5f81b40d94c785f288948c16e1f2da37203c6006546c5d947aab6f90aefef2"}, - {file = "mypy-1.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:21b437be1c02712a605591e1ed1d858aba681757a1e55fe678a15c2244cd68a5"}, - {file = "mypy-1.1.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:d809f88734f44a0d44959d795b1e6f64b2bbe0ea4d9cc4776aa588bb4229fc1c"}, - {file = "mypy-1.1.1-cp311-cp311-win_amd64.whl", hash = "sha256:a380c041db500e1410bb5b16b3c1c35e61e773a5c3517926b81dfdab7582be54"}, - {file = "mypy-1.1.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b7c7b708fe9a871a96626d61912e3f4ddd365bf7f39128362bc50cbd74a634d5"}, - {file = "mypy-1.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c1c10fa12df1232c936830839e2e935d090fc9ee315744ac33b8a32216b93707"}, - {file = "mypy-1.1.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:0a28a76785bf57655a8ea5eb0540a15b0e781c807b5aa798bd463779988fa1d5"}, - {file = "mypy-1.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:ef6a01e563ec6a4940784c574d33f6ac1943864634517984471642908b30b6f7"}, - {file = "mypy-1.1.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d64c28e03ce40d5303450f547e07418c64c241669ab20610f273c9e6290b4b0b"}, - {file = "mypy-1.1.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:64cc3afb3e9e71a79d06e3ed24bb508a6d66f782aff7e56f628bf35ba2e0ba51"}, - {file = "mypy-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ce61663faf7a8e5ec6f456857bfbcec2901fbdb3ad958b778403f63b9e606a1b"}, - {file = "mypy-1.1.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:2b0c373d071593deefbcdd87ec8db91ea13bd8f1328d44947e88beae21e8d5e9"}, - {file = "mypy-1.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:2888ce4fe5aae5a673386fa232473014056967f3904f5abfcf6367b5af1f612a"}, - {file = "mypy-1.1.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:19ba15f9627a5723e522d007fe708007bae52b93faab00f95d72f03e1afa9598"}, - {file = "mypy-1.1.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:59bbd71e5c58eed2e992ce6523180e03c221dcd92b52f0e792f291d67b15a71c"}, - {file = "mypy-1.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9401e33814cec6aec8c03a9548e9385e0e228fc1b8b0a37b9ea21038e64cdd8a"}, - {file = "mypy-1.1.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:4b398d8b1f4fba0e3c6463e02f8ad3346f71956b92287af22c9b12c3ec965a9f"}, - {file = "mypy-1.1.1-cp39-cp39-win_amd64.whl", hash = "sha256:69b35d1dcb5707382810765ed34da9db47e7f95b3528334a3c999b0c90fe523f"}, - {file = "mypy-1.1.1-py3-none-any.whl", hash = "sha256:4e4e8b362cdf99ba00c2b218036002bdcdf1e0de085cdb296a49df03fb31dfc4"}, - {file = "mypy-1.1.1.tar.gz", hash = "sha256:ae9ceae0f5b9059f33dbc62dea087e942c0ccab4b7a003719cb70f9b8abfa32f"}, -] - -[package.dependencies] -mypy-extensions = ">=1.0.0" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = ">=3.10" - -[package.extras] -dmypy = ["psutil (>=4.0)"] -install-types = ["pip"] -python2 = ["typed-ast (>=1.4.0,<2)"] -reports = ["lxml"] - -[[package]] -name = "mypy-extensions" -version = "1.0.0" -description = "Type system extensions for programs checked with the mypy type checker." -category = "main" -optional = false -python-versions = ">=3.5" -files = [ - {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, - {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, -] - -[[package]] -name = "packaging" -version = "23.0" -description = "Core utilities for Python packages" -category = "main" -optional = false -python-versions = ">=3.7" -files = [ - {file = "packaging-23.0-py3-none-any.whl", hash = "sha256:714ac14496c3e68c99c29b00845f7a2b85f3bb6f1078fd9f72fd20f0570002b2"}, - {file = "packaging-23.0.tar.gz", hash = "sha256:b6ad297f8907de0fa2fe1ccbd26fdaf387f5f47c7275fedf8cce89f99446cf97"}, -] - -[[package]] -name = "pluggy" -version = "1.0.0" -description = "plugin and hook calling mechanisms for python" -category = "main" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, - {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, -] - -[package.extras] -dev = ["pre-commit", "tox"] -testing = ["pytest", "pytest-benchmark"] - -[[package]] -name = "pytest" -version = "7.2.2" -description = "pytest: simple powerful testing with Python" -category = "main" -optional = false -python-versions = ">=3.7" -files = [ - {file = "pytest-7.2.2-py3-none-any.whl", hash = "sha256:130328f552dcfac0b1cec75c12e3f005619dc5f874f0a06e8ff7263f0ee6225e"}, - {file = "pytest-7.2.2.tar.gz", hash = "sha256:c99ab0c73aceb050f68929bc93af19ab6db0558791c6a0715723abe9d0ade9d4"}, -] - -[package.dependencies] -attrs = ">=19.2.0" -colorama = {version = "*", markers = "sys_platform == \"win32\""} -exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} -iniconfig = "*" -packaging = "*" -pluggy = ">=0.12,<2.0" -tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} - -[package.extras] -testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] - -[[package]] -name = "sortedcontainers" -version = "2.4.0" -description = "Sorted Containers -- Sorted List, Sorted Dict, Sorted Set" -category = "main" -optional = false -python-versions = "*" -files = [ - {file = "sortedcontainers-2.4.0-py2.py3-none-any.whl", hash = "sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0"}, - {file = "sortedcontainers-2.4.0.tar.gz", hash = "sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88"}, -] - -[[package]] -name = "tabulate" -version = "0.9.0" -description = "Pretty-print tabular data" -category = "main" -optional = false -python-versions = ">=3.7" -files = [ - {file = "tabulate-0.9.0-py3-none-any.whl", hash = "sha256:024ca478df22e9340661486f85298cff5f6dcdba14f3813e8830015b9ed1948f"}, - {file = "tabulate-0.9.0.tar.gz", hash = "sha256:0095b12bf5966de529c0feb1fa08671671b3368eec77d7ef7ab114be2c068b3c"}, -] - -[package.extras] -widechars = ["wcwidth"] - -[[package]] -name = "tomli" -version = "2.0.1" -description = "A lil' TOML parser" -category = "main" -optional = false -python-versions = ">=3.7" -files = [ - {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, - {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, -] - -[[package]] -name = "types-tabulate" -version = "0.9.0.1" -description = "Typing stubs for tabulate" -category = "main" -optional = false -python-versions = "*" -files = [ - {file = "types-tabulate-0.9.0.1.tar.gz", hash = "sha256:e486292c279f19247865bdabe802419740a0e74b53444e7f7a8009e08129da5d"}, - {file = "types_tabulate-0.9.0.1-py3-none-any.whl", hash = "sha256:be2ea0de05f615ccfcbadf6206aa720e265955eb1de23e343aec9d8bf3fa9aaa"}, -] - -[[package]] -name = "typing-extensions" -version = "4.5.0" -description = "Backported and Experimental Type Hints for Python 3.7+" -category = "main" -optional = false -python-versions = ">=3.7" -files = [ - {file = "typing_extensions-4.5.0-py3-none-any.whl", hash = "sha256:fb33085c39dd998ac16d1431ebc293a8b3eedd00fd4a32de0ff79002c19511b4"}, - {file = "typing_extensions-4.5.0.tar.gz", hash = "sha256:5cb5f4a79139d699607b3ef622a1dedafa84e115ab0024e0d9c044a9479ca7cb"}, -] - -[metadata] -lock-version = "2.0" -python-versions = ">3.10" -content-hash = "c8c32d6d939f84fba99597310ca0ab7dd694230f7d21dc94064c02da6e423c45" diff --git a/sorts.mm0 b/sorts.mm0 new file mode 100644 index 0000000..ae567c1 --- /dev/null +++ b/sorts.mm0 @@ -0,0 +1,25 @@ +import "10-theory-definedness.mm0"; + +term sorts_sym: Symbol; +def sorts: Pattern = $ sym sorts_sym $; + +term domain_sym: Symbol; +def dom (s: Pattern): Pattern = $ (sym domain_sym) @@ s $; + +def is_sort (s: Pattern): Pattern = $ (is_func s) /\ (s C= dom sorts) $; + +def is_of_sort (phi s: Pattern): Pattern = $ phi C= dom s $; + +axiom sorts_is_sort: $ is_sort sorts $; + +axiom nonempty_domain (s: Pattern): $ (is_sort s) -> |^ dom s ^| $; + +def s_exists (s: Pattern) {x: EVar} (phi: Pattern x): Pattern = $ exists x ((eVar x C= dom s) /\ phi) $; +def s_forall (s: Pattern) {x: EVar} (phi: Pattern x): Pattern = $ forall x ((eVar x C= dom s) -> phi) $; + +-- Singleton sort +term pred_sym: Symbol; +def pred: Pattern = $ sym pred_sym $; + +axiom pred_is_sort: $ is_sort pred $; +axiom pred_dom: $ is_func (dom pred) $; diff --git a/sorts.mm1 b/sorts.mm1 new file mode 100644 index 0000000..49d6e9e --- /dev/null +++ b/sorts.mm1 @@ -0,0 +1,29 @@ +import "sorts.mm0"; +import "13-fixedpoints.mm1"; + +do { + (def (is_function symbol input_sorts output_sort) @ foldri + 0 + input_sorts + '(s_exists ,output_sort y (_eq (eVar y) ,(foldli 0 input_sorts symbol (fn (i phi s) '(app ,phi (eVar ,(string->atom @ string-append "x" i))))))) + (fn (i s phi) '(s_forall ,s ,(string->atom @ string-append "x" i) ,phi))) + + (def (is_partial_function symbol input_sorts output_sort) @ foldri + 0 + input_sorts + '(s_exists ,output_sort y (_subset ,(foldli 0 input_sorts symbol (fn (i phi s) '(app ,phi (eVar ,(string->atom @ string-append "x" i))))) (eVar y))) + (fn (i s phi) '(s_forall ,s ,(string->atom @ string-append "x" i) ,phi))) + + (def (is_multi_function symbol input_sorts output_sort) @ foldri + 0 + input_sorts + '(_subset ,(foldli 0 input_sorts symbol (fn (i phi s) '(app ,phi (eVar ,(string->atom @ string-append "x" i))))) (dom output_sort)) + (fn (i s phi) '(s_forall ,s ,(string->atom @ string-append "x" i) ,phi))) + + (def (is_rel symbol input_sorts output_sort) @ foldri + 0 + input_sorts + '(is_sorted_pred ,(dom 'output_sort) ,(foldli 0 input_sorts symbol (fn (i phi s) '(app ,phi (eVar ,(string->atom @ string-append "x" i)))))) + (fn (i s phi) '(s_forall ,s ,(string->atom @ string-append "x" i) ,phi))) +}; + diff --git a/20-theory-words.mm0 b/words/20-theory-words.mm0 similarity index 75% rename from 20-theory-words.mm0 rename to words/20-theory-words.mm0 index 5f227b3..be52ae9 100644 --- a/20-theory-words.mm0 +++ b/words/20-theory-words.mm0 @@ -1,9 +1,4 @@ -import "10-theory-definedness.mm0"; - -term a_symbol : Symbol ; -def a : Pattern = $sym a_symbol$ ; -term b_symbol : Symbol ; -def b : Pattern = $sym b_symbol$ ; +import "../10-theory-definedness.mm0"; def emptyset : Pattern = $bot$ ; @@ -18,9 +13,8 @@ def kleene_l {X: SVar} (alpha: Pattern X) : Pattern = $mu X (epsilon \/ sVar X . def kleene_r {X: SVar} (alpha: Pattern X) : Pattern = $mu X (epsilon \/ alpha . sVar X)$; def kleene {X: SVar} (alpha: Pattern X) : Pattern = $(kleene_r X alpha)$; ---- We assume that the alphabet has only two letters. ---- This, however, captures the full expressivity. -def top_letter : Pattern = $a \/ b$; +term top_letter_symbol: Symbol; +def top_letter: Pattern = $sym top_letter_symbol$; def top_word_l {X: SVar} : Pattern = $(kleene_l X top_letter )$ ; def top_word_r {X: SVar} : Pattern = $(kleene_r X top_letter )$ ; @@ -30,12 +24,9 @@ def top_word {X: SVar} : Pattern = $(kleene X top_letter )$ ; axiom domain_words {X: SVar} : $ top_word X $; -axiom functional_epsilon {x : EVar} : $exists x (eVar x == epsilon)$; -axiom functional_a {x : EVar} : $exists x (eVar x == a)$; -axiom functional_b {x : EVar} : $exists x (eVar x == b)$; -axiom functional_concat {w v x: EVar} : $exists x (eVar x == (eVar w . eVar v))$; +axiom functional_epsilon : $ is_func epsilon $; +axiom functional_concat {w v: EVar} : $ is_func (eVar w . eVar v)$; -axiom no_confusion_ab_e : $a != b$; axiom no_confusion_ae_e : $~(epsilon C= top_letter)$; axiom no_confusion_ec_e {u v: EVar} : $(epsilon == eVar u . eVar v) -> (epsilon == eVar u) /\ (epsilon == eVar v)$; axiom no_confusion_cc_e {u v x y: EVar} : $(x in top_letter) -> (y in top_letter) diff --git a/21-words-helpers.mm1 b/words/21-words-helpers.mm1 similarity index 97% rename from 21-words-helpers.mm1 rename to words/21-words-helpers.mm1 index 414cdf2..7eebc3c 100644 --- a/21-words-helpers.mm1 +++ b/words/21-words-helpers.mm1 @@ -1,6 +1,5 @@ -import "11-definedness-normalization.mm1"; +import "../13-fixedpoints.mm1"; import "20-theory-words.mm0"; -import "13-fixedpoints.mm1"; --- Helpers for concat theorem eFresh_concat {x: EVar} (phi psi: Pattern x) @@ -134,8 +133,7 @@ theorem cong_of_equiv_kleene {X: SVar} (phi1 phi2: Pattern X) --- Helpers for top_letter theorem positive_in_top_letter {X: SVar}: - $ _Positive X top_letter $ = - '(positive_in_or positive_disjoint positive_disjoint); + $ _Positive X top_letter $ = '(positive_disjoint); theorem sSubst_top_letter {X: SVar} (psi: Pattern X): $ Norm (s[ psi / X ] (top_letter)) (top_letter) $ = 'sSubstitution_disjoint; theorem eSubst_top_letter {X: EVar} (psi: Pattern X): @@ -145,7 +143,7 @@ theorem eSubst_top_letter {X: EVar} (psi: Pattern X): --- TODO: Define in terms of kleene_l theorem positive_in_top_word_l_body {X: SVar}: $_Positive X (epsilon \/ sVar X . top_letter)$ = '(positive_in_or positive_disjoint @ - positive_in_app (positive_in_app positive_disjoint positive_in_same_sVar) positive_in_top_letter); + positive_in_app (positive_in_app positive_disjoint positive_in_same_sVar) positive_disjoint); theorem kt_top_word_l {X: SVar} (psi: Pattern X) (base: $epsilon -> psi$) (rec: $psi . top_letter -> psi$): $top_word_l X -> psi$ = '(KT positive_in_top_word_l_body @ norm_lemma ,(propag_s_subst 'X $epsilon \/ sVar X . top_letter$) @ eori base rec); theorem unfold_r_top_word_l {X : SVar} (phi: Pattern X) (h: $phi -> epsilon \/ top_word_l X . top_letter$) : $phi -> top_word_l X$ = @@ -155,7 +153,7 @@ theorem unfold_r_top_word_l {X : SVar} (phi: Pattern X) (h: $phi -> epsilon \/ t --- TODO: Define in terms of kleene_r theorem positive_in_top_word_r_body {X: SVar}: $_Positive X (epsilon \/ top_letter . sVar X)$ = '(positive_in_or positive_disjoint @ - positive_in_app (positive_in_app positive_disjoint positive_in_top_letter) positive_in_same_sVar); + positive_in_app (positive_in_app positive_disjoint positive_disjoint) positive_in_same_sVar); theorem kt_top_word_r {X: SVar} (psi: Pattern X) (base: $epsilon -> psi$) (rec: $top_letter . psi -> psi$): $top_word_r X -> psi$ = '(KT positive_in_top_word_r_body @ norm_lemma ,(propag_s_subst 'X $epsilon \/ top_letter . sVar X$) @ eori base rec); theorem lemma_83_top_word_r_forward diff --git a/23-words-theorems.mm1 b/words/23-words-theorems.mm1 similarity index 57% rename from 23-words-theorems.mm1 rename to words/23-words-theorems.mm1 index 7264c54..c3cf940 100644 --- a/23-words-theorems.mm1 +++ b/words/23-words-theorems.mm1 @@ -1,48 +1,34 @@ -import "13-fixedpoints.mm1"; import "21-words-helpers.mm1"; --- Lift axioms to higher level constructs ------------------------------------------ -theorem def_a: $|^ a ^|$ = - (named @ func_subst_thm 'functional_a 'x 'definedness); -theorem def_b: $|^ b ^|$ = - (named @ func_subst_thm 'functional_b 'x 'definedness); - -theorem a_in_top_letter: $|^ a /\ top_letter ^|$ = - '(framing_def (iand id orl) def_a); -theorem b_in_top_letter: $|^ b /\ top_letter ^|$ = - '(framing_def (iand id orr) def_b); - ---- Lift functional axioms to $ a . [] $ and $ b . [] $. -theorem functional_l_concat {.w x y v: EVar} (l: Pattern v) - (func_l: $ exists x (eVar x == l) $): - $ exists y (eVar y == l . eVar v) $ = - (func_subst_thm 'func_l 'w 'functional_concat); -theorem functional_a_concat {.w x v: EVar} : - $ exists x (eVar x == a . eVar v) $ = - (named '(functional_l_concat functional_a)); -theorem functional_b_concat {.w x v: EVar} : - $ exists x (eVar x == b . eVar v) $ = - (named '(functional_l_concat functional_b)); - -theorem regex_eq_ewp_ab +do { + (def (in_to_mem func_phi phi_in) '(mp ,(func_subst_thm func_phi 'x 'eVar_in_subset_reverse) @ imp_to_subset ,phi_in)) +}; + +theorem functional_l_concat {v: EVar} (l: Pattern v) + (func_l: $ is_func l $): + $ is_func (l . eVar v) $ = + (named (func_subst_thm 'func_l 'w 'functional_concat)); + +theorem regex_eq_ewp_l (h: $ letter -> top_letter $): $ epsilon /\ letter <-> bot $ - = '(ibii + = (named '(ibii (exists_generalization_disjoint (com12 (eq_to_imp (eq_to_def @ eq_to_and_l eq_to_intro) (eq_to_not @ eq_to_and_l eq_to_intro)) - (con2 (dne @ singleton_norm (! appCtxVar box1) (! defNorm box2))) -- |^ x /\ ~a ^| <-> ~(x /\ a) - ) (exists_framing eq_sym (! functional_epsilon x)) + (con2 (dne @ singleton_norm appCtxVar defNorm)) -- |^ x /\ ~l ^| <-> ~(x /\ l) + ) (exists_framing eq_sym functional_epsilon) (framing_def (con3 @ imim2i @ syl h dne) @ dne no_confusion_ae_e)) - absurdum); + absurdum)); theorem no_confusion_cc_e_epsilon {u x y: EVar} : $(x in top_letter) -> (y in top_letter) -> (eVar x . eVar u == eVar y) -> (eVar x == eVar y) /\ (eVar u == epsilon)$ = - '(syl (imim2i @ imim1i @ com12 eq_trans @ eq_sym identity_right_e) - ,(func_subst 'v $(x in top_letter) -> (y in top_letter) -> (eVar x . eVar u == eVar y . eVar v) -> (eVar x == eVar y) /\ (eVar u == eVar v)$ 'no_confusion_cc_e '(! functional_epsilon w)) - ); + (named '(syl (imim2i @ imim1i @ com12 eq_trans @ eq_sym identity_right_e) + ,(func_subst 'v $(x in top_letter) -> (y in top_letter) -> (eVar x . eVar u == eVar y . eVar v) -> (eVar x == eVar y) /\ (eVar u == eVar v)$ 'no_confusion_cc_e 'functional_epsilon) + )); theorem assoc_concat (Alpha Beta Gamma: Pattern): $ ((Alpha . Beta) . Gamma) <-> (Alpha . (Beta . Gamma)) $ = (named '( @@ -92,8 +78,8 @@ theorem regex_eq_eps_concat_r: $ Alpha . epsilon <-> Alpha $ = 'id_concat_r; theorem concat_subset: $ (phi1 C= psi1) -> (phi2 C= psi2) -> (phi1 . phi2 C= psi1 . psi2) $ = (named '(Fprop - ,(subset_imp_subset_framing_subst 'appCtxLRVar) - ,(subset_imp_subset_framing_subst 'appCtxRVar) + ,(imp_subset_framing_subst 'appCtxLRVar) + ,(imp_subset_framing_subst 'appCtxRVar) subset_trans)); theorem epsilon_and_concat: $ ((epsilon /\ phi) . psi) <-> |^ epsilon /\ phi ^| /\ psi $ = @@ -154,10 +140,9 @@ theorem epsilon_implies_concat (phi psi : Pattern) id); theorem epsilon_implies_not_letter (letter : Pattern) - (h: $letter -> top_letter$) - : $epsilon -> ~ letter$ -= '(exp (bi1i @ regex_eq_ewp_ab h)) - ; + (h: $letter -> top_letter$): + $ epsilon -> ~ letter $ = + '(exp (bi1i @ regex_eq_ewp_l h)); theorem epsilon_implies_not_and_l (phi psi : Pattern) (h: $epsilon -> ~ phi$) @@ -179,10 +164,6 @@ theorem regex_eq_ewp_bot: $ (epsilon /\ bot) <-> bot $ = '(ibii anr absurdum); theorem regex_eq_ewp_epsilon: $ epsilon /\ epsilon <-> epsilon $ = 'anidm; -theorem regex_eq_ewp_a: - $ epsilon /\ a <-> bot $ = '(regex_eq_ewp_ab orl); -theorem regex_eq_ewp_b: - $ epsilon /\ b <-> bot $ = '(regex_eq_ewp_ab orr); theorem regex_eq_ewp_and: $ epsilon /\ (Alpha /\ Beta) <-> (epsilon /\ Alpha) /\ (epsilon /\ Beta) $ = 'anandi; theorem regex_eq_ewp_choice: @@ -196,10 +177,6 @@ theorem regex_eq_ewp_not_bot: $ (epsilon /\ ~bot) <-> epsilon $ = '(ibii anl @ syl ancom top_and); theorem regex_eq_ewp_not_eps: $ (epsilon /\ ~epsilon) <-> bot $ = '(ibii (notnot1 notnot1) absurdum); -theorem regex_eq_ewp_not_a: $ (epsilon /\ ~a) <-> epsilon $ = - '(ibii anl @ iand id @ dne @ anl regex_eq_ewp_a); -theorem regex_eq_ewp_not_b: $ (epsilon /\ ~b) <-> epsilon $ = - '(ibii anl @ iand id @ dne @ anl regex_eq_ewp_b); theorem regex_eq_ewp_not_and: $ (epsilon /\ ~(Alpha /\ Beta)) <-> ((epsilon /\ ~ Alpha) \/ (epsilon /\ ~ Beta)) $ = '(bitr (cong_of_equiv_and_r notan) andi); theorem regex_eq_ewp_not_choice: $ (epsilon /\ ~(Alpha \/ Beta)) <-> ((epsilon /\ ~ Alpha) /\ (epsilon /\ ~ Beta)) $ = @@ -262,8 +239,8 @@ theorem regex_eq_ewp_not_concat (Alpha Beta: Pattern): rsyl (anl ,(membership_var_func_subst 'functional_epsilon 'functional_concat)) no_confusion_ec_e) @ rsyl (exists_framing @ anr anass) @ rsyl (anl and_exists_disjoint_r) - @ rsyl (anim1 @ anr ,(func_subst_eps 'x 'membership_expand)) - @ anim id id))); + @ anim1 + @ anr ,(func_subst_eps 'x 'membership_expand)))); @@ -313,10 +290,10 @@ theorem regex_eq_bot_kleene: $ (kleene X bot) <-> epsilon $ = '(ibii (epsilon_implies_kleene positive_disjoint)); theorem regex_eq_eps_kleene {X: SVar}: $ (kleene X epsilon) <-> epsilon $ = - '(ibii - (KT (positive_in_kleene_r_body positive_disjoint) @ norm (norm_sym @ norm_imp_l ,(propag_s_subst 'Y $epsilon \/ (epsilon . sVar Y)$)) @ eori id @ eq_to_intro ,(func_subst 'u $(eVar u) . epsilon == (eVar u)$ 'identity_right_e '(! functional_epsilon w))) + (named '(ibii + (KT (positive_in_kleene_r_body positive_disjoint) @ norm (norm_sym @ norm_imp_l ,(propag_s_subst 'Y $epsilon \/ (epsilon . sVar Y)$)) @ eori id @ eq_to_intro ,(func_subst 'u $(eVar u) . epsilon == (eVar u)$ 'identity_right_e 'functional_epsilon)) (imim1i orl @ norm (norm_imp_l ,(propag_s_subst 'Y $epsilon \/ (epsilon . sVar Y)$)) @ pre_fixpoint (positive_in_kleene_r_body positive_disjoint)) - ); + )); theorem regex_eq_double_kleene_l_lemma {X: SVar} (Alpha: Pattern X) (h: $ _sFresh X Alpha $): $ (kleene_l X Alpha) . (kleene_l X Alpha) -> (kleene_l X Alpha) $ = @@ -377,6 +354,15 @@ theorem l_der_phi_imp_phi (l phi: Pattern): $ (l . derivative l phi) -> phi $ = (named '(unwrap_subst appctx_concat_r id)); +theorem der_ceil (h: $ is_func phi $): $ (derivative phi (|^ psi ^|)) <-> |^ psi ^| $ = + (named '(bitr der_expand + @ bitr (cong_of_equiv_exists @ cong_of_equiv_and_r + ,(func_subst 'x $ (eVar x . eVar y C= (|^ psi ^|)) <-> |^ psi ^|$ + '(bitr ,(func_subst_thm 'functional_concat 'x 'eVar_in_subset_rev) + ,(func_subst_thm 'functional_concat 'x 'mem_def)) + 'h)) + @ bicom lemma_exists_and)); + theorem der_equality_forward_lemma {x: EVar} (phi psi: Pattern x) (l: Pattern) (h: $ exists x (eVar x == l) $): $(l . psi) /\ phi -> l . derivative l phi$ = (named '(syl ,(framing_subst '(anr der_expand) 'appctx_concat_r) @ syl (anr ,(ex_appCtx_subst 'appctx_concat_r)) @ rsyl (anim1 @ syl (anl ,(ex_appCtx_subst 'appctx_concat_r)) ,(framing_subst '(anl lemma_exists_and) 'appctx_concat_r)) @ @@ -413,18 +399,6 @@ theorem der_equality_bi: $phi <-> (epsilon /\ phi) \/ exists l ((eVar l . (deriv theorem der_equality: $phi == (epsilon /\ phi) \/ exists l ((eVar l . (derivative (eVar l) phi)) /\ l in top_letter)$ = '(equiv_to_eq der_equality_bi); -theorem der_equality_bi_concrete: $phi <-> (epsilon /\ phi) \/ ((a . (derivative a phi)) \/ (b . (derivative b phi)))$ = - (named - '(bitr der_equality_bi - @ oreq2i - -- @ exists_intro_l_bi_disjoint - @ bitr (cong_of_equiv_exists @ aneq2i ,(propag_mem 'x $a \/ b$)) - @ bitr (cong_of_equiv_exists @ bitr ancomb andir) - @ bitr or_exists_bi - @ oreqi - (mp ,(func_to_and_ctx_bi 'x $eVar x . derivative (eVar x) phi$) functional_a) - (mp ,(func_to_and_ctx_bi 'x $eVar x . derivative (eVar x) phi$) functional_b))); - --- Derivatives: Syntactic Simplifications ------------------------------------------ @@ -443,8 +417,8 @@ theorem cong_of_equiv_der_r '(cong_of_equiv_der biid h); theorem der_l1_l2_phi (l1 l2 phi: Pattern) - (l1_func: $ exists x (eVar x == l1) $) - (l2_func: $ exists y (eVar y == l2) $) + (l1_func: $ is_func l1 $) + (l2_func: $ is_func l2 $) (h1: $ |^ l1 /\ top_letter ^| $) (h2: $ |^ l2 /\ top_letter ^| $): $ (derivative l1 (l2 . phi)) <-> (l1 == l2) /\ phi $ = @@ -459,7 +433,7 @@ theorem der_l1_l2_phi (l1 l2 phi: Pattern) mp (mp ,(func_subst 'x $(x in top_letter) -> |^ l2 /\ top_letter ^| -> (eVar x . eVar u == l2 . eVar v) -> (eVar x == l2) /\ (eVar u == eVar v)$ (func_subst 'y $(x in top_letter) -> (y in top_letter) -> (eVar x . eVar u == eVar y . eVar v) -> (eVar x == eVar y) /\ (eVar u == eVar v)$ 'no_confusion_cc_e 'l2_func) 'l1_func) h1) h2 - ) (rsyl (anim ,(eq_imp_eq_framing_subst 'appctx_concat_l) ,(eq_imp_eq_framing_subst 'appctx_concat_r)) @ curry eq_trans)) + ) (rsyl (anim ,(imp_eq_framing_subst 'appctx_concat_l) ,(imp_eq_framing_subst 'appctx_concat_r)) @ curry eq_trans)) (cong_of_equiv_and_r @ bicom membership_var_bi)) anlass) @ bitr and_exists_disjoint @ bicom @ cong_of_equiv_and_r ,(membership_appCtx_subst 'appCtxVar) @@ -468,6 +442,35 @@ theorem der_l1_l2_phi (l1 l2 phi: Pattern) bitr and_exists_disjoint @ cong_of_equiv_and_r lemma_62_b)); +theorem der_l1_l2_phi_and (l1 l2 phi: Pattern) + (l1_func: $ is_func l1 $) + (l2_func: $ is_func l2 $) + (h1: $ |^ l1 /\ top_letter ^| $): + $ (|^ l2 /\ top_letter ^| /\ derivative l1 (l2 . phi)) <-> (l1 == l2) /\ phi $ = + (named '(bitr (cong_of_equiv_and_r der_expand) @ + bitr (bicom and_exists_disjoint) @ + bitr (cong_of_equiv_exists @ bitr anlass @ cong_of_equiv_and_r @ + bitr + (cong_of_equiv_and_r ,(func_subst 'x $(eVar x C= (l2 . phi)) <-> exists z ((z in phi) /\ (eVar x == (l2 . eVar z)))$ '(bitr (bitr eVar_in_subset_rev membership_app) @ cong_of_equiv_exists @ cong_of_equiv_and_r + ,(func_subst 'y $(x in eVar y) <-> (eVar x == eVar y)$ 'membership_var_bi '(functional_l_concat l2_func))) + '(functional_l_concat l1_func))) @ + bitr (bicom and_exists_disjoint) @ + bitr (cong_of_equiv_exists @ + bitr anlass @ + bitr (cong_of_equiv_and_r @ bitr (ibii ( + curry (mp ,(func_subst 'x $(x in top_letter) -> |^ l2 /\ top_letter ^| -> (eVar x . eVar u == l2 . eVar v) -> (eVar x == l2) /\ (eVar u == eVar v)$ + (func_subst 'y $(x in top_letter) -> (y in top_letter) -> (eVar x . eVar u == eVar y . eVar v) -> (eVar x == eVar y) /\ (eVar u == eVar v)$ 'no_confusion_cc_e 'l2_func) + 'l1_func) h1) + ) (iand (rsyl anl (com12 (syl anl ,(func_subst_explicit_helper 'x $x in top_letter$)) h1)) (rsyl (anim ,(imp_eq_framing_subst 'appctx_concat_l) ,(imp_eq_framing_subst 'appctx_concat_r)) @ curry eq_trans))) (cong_of_equiv_and_r @ bicom membership_var_bi)) + anlass) @ + bitr and_exists_disjoint @ + bicom @ cong_of_equiv_and_r ,(membership_appCtx_subst 'appCtxVar) + ) @ + bitr (cong_of_equiv_exists anlass) @ + bitr and_exists_disjoint @ + cong_of_equiv_and_r lemma_62_b + )); + do { (def (der_transformer x y l phi) '(ibii (exists_generalization_disjoint @ curry @ syl anr ,(func_subst_explicit_helper 'y $(l . eVar y) C= phi$)) @@ -478,255 +481,144 @@ theorem der_transformer_test_1 {x y: EVar} (phi: Pattern): $ (exists x ((eVar y == eVar x) /\ ((a . eVar x) C= (~ phi)))) <-> ((a . eVar y) C= (~ phi)) $ = (der_transformer 'x 'y 'a $~ phi$); +theorem regex_eq_der_exists {x: EVar} (phi: Pattern) (psi: Pattern x) + (func_phi: $ is_func phi $): + $ (derivative phi (exists x psi)) <-> exists x (derivative phi psi) $ = + (named '(bisquare der_expand (cong_of_equiv_exists der_expand) + @ bitr (cong_of_equiv_exists + @ bitr (cong_of_equiv_and_r ,(func_subst 'x $ (eVar x . eVar y C= exists z psi) <-> exists z (eVar x . eVar y C= psi)$ '(bisquare ,(func_subst_thm 'functional_concat 'x 'eVar_in_subset_rev) (cong_of_equiv_exists ,(func_subst_thm 'functional_concat 'x 'eVar_in_subset_rev)) ,(func_subst_thm 'functional_concat 'x 'membership_exists_bi)) 'func_phi)) + @ bicom and_exists_disjoint + ) + swap_exists_bi)); theorem regex_eq_der_bot - (h: $ exists x (eVar x == A) $): - $ (derivative A bot) -> bot $ - = '(exists_generalization_disjoint @ con3 anr @ notnot1 @ framing_def notnot1 @ + (h: $ is_func phi $): + $ (derivative phi bot) -> bot $ + = (named '(exists_generalization_disjoint @ con3 anr @ notnot1 @ framing_def notnot1 @ exists_generalization_disjoint (com12 - (eq_to_def @ norm (norm_imp_r @ norm_imp_r @ norm_sym @ norm_trans appCtxR_disjoint @ norm_app norm_refl (! appCtxVar box)) @ eq_to_app_l @ eq_to_app_r eq_to_intro) + (eq_to_def @ norm (norm_imp_r @ norm_imp_r @ norm_sym @ norm_trans appCtxR_disjoint @ norm_app norm_refl appCtxVar) @ eq_to_app_l @ eq_to_app_r eq_to_intro) (exists_generalization_disjoint (com12 (eq_to_def eq_to_intro) definedness) - (! functional_concat x v1 x1)) + functional_concat) ) h - ); -theorem regex_eq_der_bot_wrt_a: - $ (derivative a bot) <-> bot $ = '(ibii (regex_eq_der_bot (! functional_a x)) absurdum); -theorem regex_eq_der_bot_wrt_b: - $ (derivative b bot) <-> bot $ = '(ibii (regex_eq_der_bot (! functional_b x)) absurdum); - -theorem regex_eq_der_epsilon_wrt_a: - $ (derivative a epsilon) <-> bot $ = - '(ibii (rsyl (anl der_expand) @ syl not_exists_bot @ exists_framing @ con3 anr @ - rsyl ,(func_subst 'x $((a . eVar d) C= eVar x) -> ((a . eVar d) == eVar x)$ ( - func_subst 'y $((eVar y . eVar d) C= eVar x) -> ((eVar y . eVar d) == eVar x)$ ( - func_subst 'z $(eVar z C= eVar x) -> (eVar z == eVar x)$ '(eVars_subset_eq_forward) '(! functional_concat _ _ k) - ) '(! functional_a w1) - ) '(! functional_epsilon w2)) @ - rsyl eq_sym @ - rsyl ,(func_subst 'x $(epsilon == eVar x . eVar d) -> ((epsilon == eVar x) /\ (epsilon == eVar d))$ '(! no_confusion_ec_e _ d) '(! functional_a w3)) @ - con3 anl @ con3 (rsyl eq_imp_subset subset_imp_subset_or_l) no_confusion_ae_e - ) absurdum); -theorem regex_eq_der_epsilon_wrt_b: - $ (derivative b epsilon) <-> bot $ = - '(ibii (rsyl (anl der_expand) @ syl not_exists_bot @ exists_framing @ con3 anr @ - rsyl ,(func_subst 'x $((b . eVar d) C= eVar x) -> ((b . eVar d) == eVar x)$ ( + )); + +theorem regex_eq_der_epsilon (phi: Pattern) + (func_phi: $ is_func phi $) + (phi_in_top_letter: $ phi -> top_letter $): + $ (derivative phi epsilon) <-> bot $ = + (named '(ibii (rsyl (anl der_expand) @ syl not_exists_bot @ exists_framing @ con3 anr @ + rsyl ,(func_subst 'x $((phi . eVar d) C= eVar x) -> ((phi . eVar d) == eVar x)$ ( func_subst 'y $((eVar y . eVar d) C= eVar x) -> ((eVar y . eVar d) == eVar x)$ ( - func_subst 'z $(eVar z C= eVar x) -> (eVar z == eVar x)$ '(eVars_subset_eq_forward) '(! functional_concat _ _ k) - ) '(! functional_b w1) - ) '(! functional_epsilon w2)) @ + func_subst_thm 'functional_concat 'x 'eVars_subset_eq_forward + ) 'func_phi + ) 'functional_epsilon) @ rsyl eq_sym @ - rsyl ,(func_subst 'x $(epsilon == eVar x . eVar d) -> ((epsilon == eVar x) /\ (epsilon == eVar d))$ '(! no_confusion_ec_e _ d) '(! functional_b w3)) @ - con3 anl @ con3 (rsyl eq_imp_subset subset_imp_subset_or_r) no_confusion_ae_e - ) absurdum); -theorem regex_eq_der_diff_a_wrt_a: - $ (derivative a b) <-> bot $ = - '(ibii (rsyl (anl der_expand) @ syl not_exists_bot @ exists_framing @ con3 anr @ - rsyl ,(func_subst 'x $((a . eVar d) C= eVar x) -> ((a . eVar d) == eVar x)$ ( + rsyl ,(func_subst_thm 'func_phi 'u 'no_confusion_ec_e) @ + anwl @ con3 eq_imp_subset @ con3 (com12 subset_trans @ imp_to_subset phi_in_top_letter) no_confusion_ae_e + ) absurdum)); +theorem regex_eq_der_diff_l + (func_phi: $ is_func phi $) + (func_psi: $ is_func psi $) + (phi_in_top_letter: $ phi -> top_letter $) + (psi_in_top_letter: $ psi -> top_letter $) + (diff: $ phi != psi $): + $ (derivative phi psi) <-> bot $ = + (named '(ibii (rsyl (anl der_expand) @ syl not_exists_bot @ exists_framing @ con3 anr @ + rsyl ,(func_subst 'x $((phi . eVar d) C= eVar x) -> ((phi . eVar d) == eVar x)$ ( func_subst 'y $((eVar y . eVar d) C= eVar x) -> ((eVar y . eVar d) == eVar x)$ ( - func_subst 'z $(eVar z C= eVar x) -> (eVar z == eVar x)$ '(eVars_subset_eq_forward) '(! functional_concat _ _ k) - ) '(! functional_a w1) - ) '(! functional_b w2)) @ - syl no_confusion_ab_e @ syl anl @ mp + func_subst 'z $(eVar z C= eVar x) -> (eVar z == eVar x)$ '(eVars_subset_eq_forward) 'functional_concat + ) 'func_phi + ) 'func_psi) @ + syl diff @ syl anl @ mp ,(func_subst 'y $|^ a /\ top_letter ^| -> (y in top_letter) -> (a . eVar u == eVar y) -> (a == eVar y) /\ (eVar u == epsilon)$ - (func_subst 'x $(x in top_letter) -> (y in top_letter) -> (eVar x . eVar u == eVar y) -> (eVar x == eVar y) /\ (eVar u == epsilon)$ '(! no_confusion_cc_e_epsilon w3) '(! functional_a w5)) - '(! functional_b w4)) a_in_top_letter b_in_top_letter - ) absurdum); -theorem regex_eq_der_diff_a_wrt_b: - $ (derivative b a) <-> bot $ = - '(ibii (rsyl (anl der_expand) @ syl not_exists_bot @ exists_framing @ con3 anr @ - rsyl ,(func_subst 'x $((b . eVar d) C= eVar x) -> ((b . eVar d) == eVar x)$ ( - func_subst 'y $((eVar y . eVar d) C= eVar x) -> ((eVar y . eVar d) == eVar x)$ ( - func_subst 'z $(eVar z C= eVar x) -> (eVar z == eVar x)$ '(eVars_subset_eq_forward) '(! functional_concat _ _ k) - ) '(! functional_b w1) - ) '(! functional_a w2)) @ - syl no_confusion_ab_e @ syl eq_sym @ syl anl @ mp - ,(func_subst 'y $|^ b /\ top_letter ^| -> (y in top_letter) -> (b . eVar u == eVar y) -> (b == eVar y) /\ (eVar u == epsilon)$ - (func_subst 'x $(x in top_letter) -> (y in top_letter) -> (eVar x . eVar u == eVar y) -> (eVar x == eVar y) /\ (eVar u == epsilon)$ '(! no_confusion_cc_e_epsilon w3) '(! functional_b w5)) - '(! functional_a w4)) b_in_top_letter a_in_top_letter - ) absurdum); -theorem regex_eq_der_same_a_wrt_a: - $ (derivative a a) <-> epsilon $ = + (func_subst 'x $(x in top_letter) -> (y in top_letter) -> (eVar x . eVar u == eVar y) -> (eVar x == eVar y) /\ (eVar u == epsilon)$ 'no_confusion_cc_e_epsilon 'func_phi) + 'func_psi) ,(in_to_mem 'func_phi 'phi_in_top_letter) ,(in_to_mem 'func_psi 'psi_in_top_letter) + ) absurdum)); +theorem regex_eq_der_same_l (phi: Pattern) + (func_phi: $ is_func phi $) + (phi_in_top_letter: $ phi -> top_letter $): + $ (derivative phi phi) <-> epsilon $ = (named '(ibii (rsyl (anl der_expand) @ exists_generalization_disjoint @ syl simple_eq_subst @ anim2 @ syl (syl anr @ mp ,(func_subst 'y $(y in top_letter) -> (a . eVar d == eVar y) -> (a == eVar y) /\ (eVar d == epsilon)$ '(mp - ,(func_subst 'x $(x in top_letter) -> (y in top_letter) -> (eVar x . eVar d == eVar y) -> (eVar x == eVar y) /\ (eVar d == epsilon)$ 'no_confusion_cc_e_epsilon 'functional_a) - a_in_top_letter) - 'functional_a) - a_in_top_letter) - ,(func_subst 'y $((a . eVar d) C= eVar y) -> ((a . eVar d) == eVar y)$ (func_subst 'v $((eVar v . eVar d) C= eVar y) -> ((eVar v . eVar d) == eVar y)$ (func_subst 'x $(eVar x C= eVar y) -> (eVar x == eVar y)$ 'eVars_subset_eq_forward 'functional_concat) 'functional_a) 'functional_a) + ,(func_subst_thm 'func_phi 'x 'no_confusion_cc_e_epsilon) + ,(in_to_mem 'func_phi 'phi_in_top_letter)) + 'func_phi) + ,(in_to_mem 'func_phi 'phi_in_top_letter)) + ,(func_subst 'y $((a . eVar d) C= eVar y) -> ((a . eVar d) == eVar y)$ (func_subst 'v $((eVar v . eVar d) C= eVar y) -> ((eVar v . eVar d) == eVar y)$ (func_subst 'x $(eVar x C= eVar y) -> (eVar x == eVar y)$ 'eVars_subset_eq_forward 'functional_concat) 'func_phi) 'func_phi) ) (syl (anr der_expand) @ syl ,(func_subst_fresh '(eFresh_imp eFresh_disjoint eFresh_exists_same_var) 'd $(eVar d /\ ((a . eVar d) C= a)) -> exists d (eVar d /\ ((a . eVar d) C= a))$ 'exists_intro_same_var 'functional_epsilon) @ iand id @ a1i @ imp_to_subset @ anl id_concat_r ) )); -theorem regex_eq_der_same_a_wrt_b: - $ (derivative b b) <-> epsilon $ = - (named '(ibii - (rsyl (anl der_expand) @ exists_generalization_disjoint @ syl simple_eq_subst @ anim2 @ syl - (syl anr @ mp - ,(func_subst 'y $(y in top_letter) -> (b . eVar d == eVar y) -> (b == eVar y) /\ (eVar d == epsilon)$ - '(mp - ,(func_subst 'x $(x in top_letter) -> (y in top_letter) -> (eVar x . eVar d == eVar y) -> (eVar x == eVar y) /\ (eVar d == epsilon)$ 'no_confusion_cc_e_epsilon 'functional_b) - b_in_top_letter) - 'functional_b) - b_in_top_letter) - ,(func_subst 'y $((b . eVar d) C= eVar y) -> ((b . eVar d) == eVar y)$ (func_subst 'v $((eVar v . eVar d) C= eVar y) -> ((eVar v . eVar d) == eVar y)$ (func_subst 'x $(eVar x C= eVar y) -> (eVar x == eVar y)$ 'eVars_subset_eq_forward 'functional_concat) 'functional_b) 'functional_b) - ) - (syl (anr der_expand) @ - syl ,(func_subst_fresh '(eFresh_imp eFresh_disjoint eFresh_exists_same_var) 'd $(eVar d /\ ((b . eVar d) C= b)) -> exists d (eVar d /\ ((b . eVar d) C= b))$ 'exists_intro_same_var 'functional_epsilon) @ - iand id @ a1i @ imp_to_subset @ anl id_concat_r - ) - )); -theorem regex_eq_der_choice_wrt_a: $ (derivative a (Alpha \/ Beta)) <-> (derivative a Alpha) \/ (derivative a Beta) $ = - '(bitr (! der_expand d1) @ +theorem regex_eq_der_choice (phi: Pattern) + (func_phi: $ is_func phi $): + $ (derivative phi (Alpha \/ Beta)) <-> (derivative phi Alpha) \/ (derivative phi Beta) $ = + (named '(bitr (! der_expand d1) @ bitr ( membership_elim_implicit @ anr - ,(propag_mem 'y $(exists x (eVar x /\ ((a . eVar x) C= (Alpha \/ Beta)))) <-> ((exists x (eVar x /\ ((a . eVar x) C= Alpha))) \/ (exists x (eVar x /\ ((a . eVar x) C= Beta))))$) @ - bitr ,(der_transformer 'x 'y 'a $Alpha \/ Beta$) @ + ,(propag_mem_w_fun 'y $(exists x (eVar x /\ ((phi . eVar x) C= (Alpha \/ Beta)))) <-> ((exists x (eVar x /\ ((phi . eVar x) C= Alpha))) \/ (exists x (eVar x /\ ((phi . eVar x) C= Beta))))$ (atom-map! '[phi func_phi])) @ + bitr ,(der_transformer 'x 'y 'phi $Alpha \/ Beta$) @ bitr ,(func_subst 'x $(eVar x C= Alpha \/ Beta) <-> (eVar x C= Alpha) \/ (eVar x C= Beta)$ '( bitr eVar_in_subset_rev @ bitr membership_or_bi (cong_of_equiv_or eVar_in_subset eVar_in_subset) - ) '(! functional_a_concat d2 x)) @ + ) '(functional_l_concat func_phi)) @ bicom @ cong_of_equiv_or ,(der_transformer 'x 'y 'a $Alpha$) ,(der_transformer 'x 'y 'a $Beta$)) @ - bicom @ cong_of_equiv_or (! der_expand d1) (! der_expand d1)); -theorem regex_eq_der_choice_wrt_b: $ (derivative b (Alpha \/ Beta)) <-> (derivative b Alpha) \/ (derivative b Beta) $ = - '(bitr (! der_expand d1) @ + bicom @ cong_of_equiv_or (! der_expand d1) (! der_expand d1))); +theorem regex_eq_der_conj (phi: Pattern) + (func_phi: $ is_func phi $): + $ (derivative phi (Alpha /\ Beta)) <-> (derivative phi Alpha) /\ (derivative phi Beta) $ = + (named '(bitr (! der_expand d1) @ bitr ( membership_elim_implicit @ anr - ,(propag_mem 'y $(exists x (eVar x /\ ((b . eVar x) C= (Alpha \/ Beta)))) <-> ((exists x (eVar x /\ ((b . eVar x) C= Alpha))) \/ (exists x (eVar x /\ ((b . eVar x) C= Beta))))$) @ - bitr ,(der_transformer 'x 'y 'b $Alpha \/ Beta$) @ - bitr ,(func_subst 'x $(eVar x C= Alpha \/ Beta) <-> (eVar x C= Alpha) \/ (eVar x C= Beta)$ '( - bitr eVar_in_subset_rev @ bitr membership_or_bi (cong_of_equiv_or eVar_in_subset eVar_in_subset) - ) '(! functional_b_concat d2 x)) @ - bicom @ cong_of_equiv_or ,(der_transformer 'x 'y 'b $Alpha$) ,(der_transformer 'x 'y 'b $Beta$)) @ - bicom @ cong_of_equiv_or (! der_expand d1) (! der_expand d1)); -theorem regex_eq_der_conj_wrt_a: $ (derivative a (Alpha /\ Beta)) <-> (derivative a Alpha) /\ (derivative a Beta) $ = - '(bitr (! der_expand d1) @ - bitr ( - membership_elim_implicit @ anr - ,(propag_mem 'y $(exists x (eVar x /\ ((a . eVar x) C= (Alpha /\ Beta)))) <-> ((exists x (eVar x /\ ((a . eVar x) C= Alpha))) /\ (exists x (eVar x /\ ((a . eVar x) C= Beta))))$) @ - bitr ,(der_transformer 'x 'y 'a $Alpha /\ Beta$) @ + ,(propag_mem_w_fun 'y $(exists x (eVar x /\ ((phi . eVar x) C= (Alpha /\ Beta)))) <-> ((exists x (eVar x /\ ((phi . eVar x) C= Alpha))) /\ (exists x (eVar x /\ ((phi . eVar x) C= Beta))))$ (atom-map! '[phi func_phi])) @ + bitr ,(der_transformer 'x 'y 'phi $Alpha /\ Beta$) @ bitr ,(func_subst 'x $(eVar x C= Alpha /\ Beta) <-> (eVar x C= Alpha) /\ (eVar x C= Beta)$ '( bitr eVar_in_subset_rev @ bitr membership_and_bi (cong_of_equiv_and eVar_in_subset eVar_in_subset) - ) '(! functional_a_concat d2 x)) @ + ) '(functional_l_concat func_phi)) @ bicom @ cong_of_equiv_and ,(der_transformer 'x 'y 'a $Alpha$) ,(der_transformer 'x 'y 'a $Beta$)) @ - bicom @ cong_of_equiv_and (! der_expand d1) (! der_expand d1)); -theorem regex_eq_der_conj_wrt_b: $ (derivative b (Alpha /\ Beta)) <-> (derivative b Alpha) /\ (derivative b Beta) $ = - '(bitr (! der_expand d1) @ + bicom @ cong_of_equiv_and (! der_expand d1) (! der_expand d1))); +theorem regex_eq_der_neg (phi: Pattern) + (func_phi: $ is_func phi $): + $ (derivative phi (~ Alpha)) <-> ~ (derivative phi Alpha) $ = + (named '(bitr (! der_expand d1) @ bitr ( membership_elim_implicit @ anr - ,(propag_mem 'y $(exists x (eVar x /\ ((b . eVar x) C= (Alpha /\ Beta)))) <-> ((exists x (eVar x /\ ((b . eVar x) C= Alpha))) /\ (exists x (eVar x /\ ((b . eVar x) C= Beta))))$) @ - bitr ,(der_transformer 'x 'y 'b $Alpha /\ Beta$) @ - bitr ,(func_subst 'x $(eVar x C= Alpha /\ Beta) <-> (eVar x C= Alpha) /\ (eVar x C= Beta)$ '( - bitr eVar_in_subset_rev @ bitr membership_and_bi (cong_of_equiv_and eVar_in_subset eVar_in_subset) - ) '(! functional_b_concat d2 x)) @ - bicom @ cong_of_equiv_and ,(der_transformer 'x 'y 'b $Alpha$) ,(der_transformer 'x 'y 'b $Beta$)) @ - bicom @ cong_of_equiv_and (! der_expand d1) (! der_expand d1)); -theorem regex_eq_der_neg_wrt_a: $ (derivative a (~ Alpha)) <-> ~ (derivative a Alpha) $ = - '(bitr (! der_expand d1) @ - bitr ( - membership_elim_implicit @ anr - ,(propag_mem 'y $(exists x (eVar x /\ ((a . eVar x) C= ~ Alpha))) <-> ~ (exists x (eVar x /\ ((a . eVar x) C= Alpha)))$) @ + ,(propag_mem_w_fun 'y $(exists x (eVar x /\ ((phi . eVar x) C= ~ Alpha))) <-> ~ (exists x (eVar x /\ ((phi . eVar x) C= Alpha)))$ (atom-map! '[phi func_phi])) @ bitr ,(der_transformer 'x 'y 'a $~ Alpha$) @ - bitr (cong_of_equiv_not ,(func_subst 'x $(x in Alpha) <-> (eVar x C= Alpha)$ 'eVar_in_subset '(! functional_a_concat d2 x))) @ - bicom @ cong_of_equiv_not ,(der_transformer 'x 'y 'b $Alpha$)) @ - bicom @ cong_of_equiv_not (! der_expand d1)); -theorem regex_eq_der_neg_wrt_b: $ (derivative b (~ Alpha)) <-> ~ (derivative b Alpha) $ = - '(bitr (! der_expand d1) @ - bitr ( - membership_elim_implicit @ anr - ,(propag_mem 'y $(exists x (eVar x /\ ((b . eVar x) C= ~ Alpha))) <-> ~ (exists x (eVar x /\ ((b . eVar x) C= Alpha)))$) @ - bitr ,(der_transformer 'x 'y 'b $~ Alpha$) @ - bitr (cong_of_equiv_not ,(func_subst 'x $(x in Alpha) <-> (eVar x C= Alpha)$ 'eVar_in_subset '(! functional_b_concat d2 x))) @ + bitr (cong_of_equiv_not ,(func_subst 'x $(x in Alpha) <-> (eVar x C= Alpha)$ 'eVar_in_subset '(functional_l_concat func_phi))) @ bicom @ cong_of_equiv_not ,(der_transformer 'x 'y 'b $Alpha$)) @ - bicom @ cong_of_equiv_not (! der_expand d1)); -theorem regex_eq_der_concat_wrt_a (Alpha Beta: Pattern) : - $ (derivative a (Alpha . Beta)) <-> ((derivative a Alpha) . Beta) \/ ((epsilon /\ Alpha) . (derivative a Beta)) $ = - (named '(ibii - (rsyl (anl @ - bitr (cong_of_equiv_der_r @ cong_of_equiv_concat_l der_equality_bi_concrete) @ - bitr (cong_of_equiv_der_r ,(or_appCtx2_r_subst 'appctx_concat_l)) @ - bitr regex_eq_der_choice_wrt_a @ - bitr (cong_of_equiv_or_r regex_eq_der_choice_wrt_a) @ - bitr (cong_of_equiv_or - ( bitr (cong_of_equiv_der_r epsilon_and_concat) - der_expand) - @ cong_of_equiv_or - ( bitr (cong_of_equiv_der_r assoc_concat) @ - bitr (der_l1_l2_phi functional_a functional_a a_in_top_letter a_in_top_letter) @ - taut_and_equiv eq_refl) - ( bitr (cong_of_equiv_der_r assoc_concat) @ - bitr (der_l1_l2_phi functional_a functional_b a_in_top_letter b_in_top_letter) @ - absurd_and_equiv_bot no_confusion_ab_e) - ) @ - bitr (cong_of_equiv_or_r or_bot_bi_l) @ - orcomb) @ - orim2 @ syl (anr epsilon_and_concat) @ syl (anim2 @ anr der_expand) @ rsyl - (exists_framing @ syl (anr anlass) @ anim2 @ rsyl subset_and @ anim1 - ,(func_subst 'x $(eVar x C= |^ phi ^|) -> |^ phi ^|$ '(rsyl eVar_in_subset_reverse mem_def_forward) 'functional_a_concat)) - and_exists_disjoint_forwards - ) - (rsyl (anl @ cong_of_equiv_or (cong_of_equiv_concat_l der_expand) (cong_of_equiv_concat_r der_expand)) @ syl (anr der_expand) @ eori - (rsyl (norm (norm_imp appCtxLRVar @ norm_exists appCtxLRVar) propag_exists_disjoint) @ exists_generalization_disjoint @ - rsyl (anl ,(appCtx_pointwise_subst 'appCtxRVar)) @ exists_generalization_disjoint @ rsyl (anim1 - ,(func_subst 'x $((eVar d /\ (eVar x C= Alpha)) . eVar beta) -> (eVar d . eVar beta /\ (eVar x C= Alpha))$ '(anl ,(lemma_60_subset_subst 'appCtxLRVar)) 'functional_a_concat)) @ - rsyl (anl anass) @ rsyl (anim2 @ syl (framing_subset (anr assoc_concat) id) @ rsyl (anim - ,(subset_imp_subset_framing_subst 'appCtxLRVar) - (rsyl eVar_in_subset_forward ,(subset_imp_subset_framing_subst 'appCtxRVar))) @ - curry subset_trans) @ anr imp_exists_disjoint @ exists_framing ( - syl anr ,(func_subst_explicit_helper 'x $eVar x /\ ((a . eVar x) C= Alpha . Beta)$) - ) functional_concat) - (rsyl (anl ,(ex_appCtx_subst 'appCtxRVar)) @ exists_framing @ iand - (rsyl ,(framing_subst 'anl 'appCtxLRVar) @ syl anl @ anl id_concat_l) - (rsyl (iand (norm (norm_imp_l appCtxLRVar) lemma_56) (syl anr @ syl (anl id_concat_l) ,(framing_subst 'anl 'appCtxLRVar))) @ - rsyl (anim1 ,(func_subst 'x $(x in Alpha) -> (eVar x C= Alpha)$ 'eVar_in_subset_forward 'functional_epsilon)) @ - rsyl (curry concat_subset) @ framing_subset (anr id_concat_l) id)) - ))); -theorem regex_eq_der_concat_wrt_b (Alpha Beta: Pattern) : - $ (derivative b (Alpha . Beta)) <-> ((derivative b Alpha) . Beta) \/ ((epsilon /\ Alpha) . (derivative b Beta)) $ = - (named '(ibii - (rsyl (anl @ - bitr (cong_of_equiv_der_r @ cong_of_equiv_concat_l der_equality_bi_concrete) @ - bitr (cong_of_equiv_der_r ,(or_appCtx2_r_subst 'appctx_concat_l)) @ - bitr regex_eq_der_choice_wrt_b @ - bitr (cong_of_equiv_or_r regex_eq_der_choice_wrt_b) @ - bitr (cong_of_equiv_or - ( bitr (cong_of_equiv_der_r epsilon_and_concat) - der_expand) - @ cong_of_equiv_or - ( bitr (cong_of_equiv_der_r assoc_concat) @ - bitr (der_l1_l2_phi functional_b functional_a b_in_top_letter a_in_top_letter) @ - absurd_and_equiv_bot @ rsyl eq_sym no_confusion_ab_e) - ( bitr (cong_of_equiv_der_r assoc_concat) @ - bitr (der_l1_l2_phi functional_b functional_b b_in_top_letter b_in_top_letter) @ - taut_and_equiv eq_refl) - ) @ - bitr (cong_of_equiv_or_r or_bot_bi_r) @ - orcomb) @ - orim2 @ syl (anr epsilon_and_concat) @ syl (anim2 @ anr der_expand) @ rsyl - (exists_framing @ syl (anr anlass) @ anim2 @ rsyl subset_and @ anim1 - ,(func_subst 'x $(eVar x C= |^ phi ^|) -> |^ phi ^|$ '(rsyl eVar_in_subset_reverse mem_def_forward) 'functional_b_concat)) - and_exists_disjoint_forwards - ) - (rsyl (anl @ cong_of_equiv_or (cong_of_equiv_concat_l der_expand) (cong_of_equiv_concat_r der_expand)) @ syl (anr der_expand) @ eori - (rsyl (norm (norm_imp appCtxLRVar @ norm_exists appCtxLRVar) propag_exists_disjoint) @ exists_generalization_disjoint @ - rsyl (anl ,(appCtx_pointwise_subst 'appCtxRVar)) @ exists_generalization_disjoint @ rsyl (anim1 - ,(func_subst 'x $((eVar d /\ (eVar x C= Alpha)) . eVar beta) -> (eVar d . eVar beta /\ (eVar x C= Alpha))$ '(anl ,(lemma_60_subset_subst 'appCtxLRVar)) 'functional_b_concat)) @ - rsyl (anl anass) @ rsyl (anim2 @ syl (framing_subset (anr assoc_concat) id) @ rsyl (anim - ,(subset_imp_subset_framing_subst 'appCtxLRVar) - (rsyl eVar_in_subset_forward ,(subset_imp_subset_framing_subst 'appCtxRVar))) @ - curry subset_trans) @ anr imp_exists_disjoint @ exists_framing ( - syl anr ,(func_subst_explicit_helper 'x $eVar x /\ ((b . eVar x) C= Alpha . Beta)$) - ) functional_concat) - (rsyl (anl ,(ex_appCtx_subst 'appCtxRVar)) @ exists_framing @ iand - (rsyl ,(framing_subst 'anl 'appCtxLRVar) @ syl anl @ anl id_concat_l) - (rsyl (iand (norm (norm_imp_l appCtxLRVar) lemma_56) (syl anr @ syl (anl id_concat_l) ,(framing_subst 'anl 'appCtxLRVar))) @ - rsyl (anim1 ,(func_subst 'x $(x in Alpha) -> (eVar x C= Alpha)$ 'eVar_in_subset_forward 'functional_epsilon)) @ - rsyl (curry concat_subset) @ framing_subset (anr id_concat_l) id)) - ))); + bicom @ cong_of_equiv_not (! der_expand d1))); +theorem regex_eq_der_concat (phi: Pattern) + (func_phi: $ is_func phi $) + (phi_in_top_letter: $ phi -> top_letter $): + $ (derivative phi (Alpha . Beta)) <-> ((derivative phi Alpha) . Beta) \/ ((epsilon /\ Alpha) . (derivative phi Beta)) $ = + (named '( + bitr (cong_of_equiv_der_r @ cong_of_equiv_concat_l der_equality_bi) @ + bitr (cong_of_equiv_der_r ,(or_appCtx_subst 'appctx_concat_l)) @ + bitr (regex_eq_der_choice func_phi) @ + bitr orcomb @ + cong_of_equiv_or + ( bitr (cong_of_equiv_der_r ,(ex_appCtx_subst 'appctx_concat_l)) + @ bitr (regex_eq_der_exists func_phi) + @ bitr (cong_of_equiv_exists @ cong_of_equiv_der_r ,(lemma_60_subst 'appctx_concat_l)) + @ bitr (cong_of_equiv_exists @ cong_of_equiv_der_r @ cong_of_equiv_and_l assoc_concat) + @ bitr (cong_of_equiv_exists + ( bitr (regex_eq_der_conj func_phi) + @ bitr (cong_of_equiv_and_r @ der_ceil func_phi) + @ bitr ancomb + @ bitr (der_l1_l2_phi_and func_phi functional_var ,(in_to_mem 'func_phi 'phi_in_top_letter)) + @ cong_of_equiv_and_l @ ibii eq_sym eq_sym)) + @ mp ,(func_to_and_ctx_bi 'x $(derivative (eVar x) Alpha) . Beta$) func_phi + ) + ( bitr (cong_of_equiv_der_r epsilon_and_concat) + @ bitr (regex_eq_der_conj func_phi) + @ bitr (cong_of_equiv_and_l @ der_ceil func_phi) + @ bicom epsilon_and_concat) + )); theorem regex_eq_der_kleene_lemma {X: SVar} (Alpha: Pattern X) @@ -770,31 +662,19 @@ theorem regex_eq_der_kleene_lemma {X: SVar} (Alpha: Pattern X) @ rsyl and_exists_disjoint_forwards anl)) @ framing_concat_l anr)); -theorem regex_eq_der_kleene_wrt_a {X: SVar} (Alpha: Pattern X) - (X_fresh: $ _sFresh X Alpha $): - $ (derivative a (kleene X Alpha)) <-> ((derivative a Alpha) . (kleene X Alpha)) $ = - (named '(bitr (cong_of_equiv_der_r @ bitr (unfold_kleene X_fresh) or_or_not_an) @ - bitr regex_eq_der_choice_wrt_a @ - bitr (cong_of_equiv_or_l regex_eq_der_epsilon_wrt_a) @ - bitr or_bot_bi_r @ - bitr (cong_of_equiv_der_r @ regex_eq_der_kleene_lemma X_fresh) @ - bitr regex_eq_der_concat_wrt_a @ - bitr (cong_of_equiv_or - (cong_of_equiv_concat_l (bitr regex_eq_der_conj_wrt_a @ bitr (cong_of_equiv_and_l @ bitr regex_eq_der_neg_wrt_a @ cong_of_equiv_not regex_eq_der_epsilon_wrt_a) an_top_bi_r)) - (bitr (cong_of_equiv_concat_l @ bitr (bicom anass) @ bitr (cong_of_equiv_and_l absurd_an_r) an_bot_bi_r) (ibii (norm (norm_imp_l appctx_concat_l) propag_bot) absurdum))) @ - or_bot_bi_l)); - -theorem regex_eq_der_kleene_wrt_b {X: SVar} (Alpha: Pattern X) - (X_fresh: $ _sFresh X Alpha $): - $ (derivative b (kleene X Alpha)) <-> ((derivative b Alpha) . (kleene X Alpha)) $ = +theorem regex_eq_der_kleene {X: SVar} (Alpha: Pattern X) (phi: Pattern) + (X_fresh: $ _sFresh X Alpha $) + (func_phi: $ is_func phi $) + (phi_in_top_letter: $ phi -> top_letter $): + $ (derivative phi (kleene X Alpha)) <-> ((derivative phi Alpha) . (kleene X Alpha)) $ = (named '(bitr (cong_of_equiv_der_r @ bitr (unfold_kleene X_fresh) or_or_not_an) @ - bitr regex_eq_der_choice_wrt_b @ - bitr (cong_of_equiv_or_l regex_eq_der_epsilon_wrt_b) @ + bitr (regex_eq_der_choice func_phi) @ + bitr (cong_of_equiv_or_l @ regex_eq_der_epsilon func_phi phi_in_top_letter) @ bitr or_bot_bi_r @ bitr (cong_of_equiv_der_r @ regex_eq_der_kleene_lemma X_fresh) @ - bitr regex_eq_der_concat_wrt_b @ + bitr (regex_eq_der_concat func_phi phi_in_top_letter) @ bitr (cong_of_equiv_or - (cong_of_equiv_concat_l (bitr regex_eq_der_conj_wrt_b @ bitr (cong_of_equiv_and_l @ bitr regex_eq_der_neg_wrt_b @ cong_of_equiv_not regex_eq_der_epsilon_wrt_b) an_top_bi_r)) + (cong_of_equiv_concat_l (bitr (regex_eq_der_conj func_phi) @ bitr (cong_of_equiv_and_l @ bitr (regex_eq_der_neg func_phi) @ cong_of_equiv_not (regex_eq_der_epsilon func_phi phi_in_top_letter)) an_top_bi_r)) (bitr (cong_of_equiv_concat_l @ bitr (bicom anass) @ bitr (cong_of_equiv_and_l absurd_an_r) an_bot_bi_r) (ibii (norm (norm_imp_l appctx_concat_l) propag_bot) absurdum))) @ or_bot_bi_l)); @@ -856,59 +736,6 @@ theorem top_implies_fp_leaf {box: SVar} (phi : Pattern box) : $( ctximp_app box (sVar box . top_letter) phi) . top_letter -> phi $ = '(norm (norm_imp appctx_concat_l norm_refl) ctximp_in_ctx_forward); ---- fp-implies-alpha --------------------- - -theorem positive_in_fp_interior (phi_a phi_b: Pattern X) - (p_a: $ _Positive X phi_a $) - (p_b: $ _Positive X phi_b $): - $ _Positive X (epsilon \/ (a . phi_a \/ b . phi_b )) $ - = '(positive_in_or positive_disjoint (positive_in_or (positive_in_concat positive_disjoint p_a) - (positive_in_concat positive_disjoint p_b))); - --- TODO(MirceaS): Can't this be relaxed to allow eBox to show up in some or all of the patterns? -theorem top_implies_fp_interior {X: SVar} {box: SVar} (fp_unf_a fp_unf_b fp_ctximp_a fp_ctximp_b: Pattern X box) - (p_fp_unf_a: $ _Positive X fp_unf_a $) - (p_fp_unf_b: $ _Positive X fp_unf_b $) - (p_fp_ctximp_a: $ _Positive X fp_ctximp_a $) - (p_fp_ctximp_b: $ _Positive X fp_ctximp_b $) - - (he_a: $epsilon -> s[ (mu X (epsilon \/ ((a . fp_unf_a) \/ (b . fp_unf_b)))) / X ] fp_unf_a$) - (he_b: $epsilon -> s[ (mu X (epsilon \/ ((a . fp_unf_a) \/ (b . fp_unf_b)))) / X ] fp_unf_b$) - (ha: $((s[ (ctximp_app box (sVar box . top_letter) (mu X (epsilon \/ ((a . fp_unf_a) \/ (b . fp_unf_b))))) / X ] fp_ctximp_a) . top_letter) - -> (s[ (mu X (epsilon \/ ((a . fp_unf_a) \/ (b . fp_unf_b)))) / X ] fp_unf_a)$) - (hb: $((s[ (ctximp_app box (sVar box . top_letter) (mu X (epsilon \/ ((a . fp_unf_a) \/ (b . fp_unf_b))))) / X ] fp_ctximp_b) . top_letter) - -> (s[ (mu X (epsilon \/ ((a . fp_unf_a) \/ (b . fp_unf_b)))) / X ] fp_unf_b)$) - : ------------------------ - $(mu X (epsilon \/ ((a . fp_ctximp_a) \/ (b . fp_ctximp_b)))) . top_letter -> (mu X (epsilon \/ ((a . fp_unf_a) \/ (b . fp_unf_b))))$ - = (id - '(unwrap_subst appctx_concat_l - @ KT_subst (positive_in_fp_interior p_fp_ctximp_a p_fp_ctximp_b) ,(propag_s_subst 'X $epsilon \/ (a . _ \/ b . _)$) - @ eori - ( wrap_subst appctx_concat_l - @ rsyl (anl regex_eq_eps_concat_l) - @ unfold_r (positive_in_fp_interior p_fp_unf_a p_fp_unf_b) - @ norm (norm_sym @ norm_imp_r ,(propag_s_subst 'X $epsilon \/ (a . _ \/ b . _)$)) - @ orrd - @ orim - (rsyl (anr regex_eq_eps_concat_r) @ framing_concat_r he_a) - (rsyl (anr regex_eq_eps_concat_r) @ framing_concat_r he_b)) - @ eori - ( wrap_subst appctx_concat_l - @ rsyl (bi1i @ assoc_concat) - @ unfold_r (positive_in_fp_interior p_fp_unf_a p_fp_unf_b) - @ norm (norm_sym @ norm_imp_r ,(propag_s_subst 'X $epsilon \/ (a . _ \/ b . _)$)) - @ orrd @ orld - @ framing_concat_r ha) - ( wrap_subst appctx_concat_l - @ rsyl (bi1i @ assoc_concat) - @ unfold_r (positive_in_fp_interior p_fp_unf_a p_fp_unf_b) - @ norm (norm_sym @ norm_imp_r ,(propag_s_subst 'X $epsilon \/ (a . _ \/ b . _)$)) - @ orrd @ orrd - @ framing_concat_r hb) - )); - - --- Apply equivalence left to right theorem apply_equiv (eq: $phi <-> psi$) (cont: $rho -> psi$): $rho -> phi$ @@ -916,18 +743,3 @@ theorem apply_equiv (eq: $phi <-> psi$) (cont: $rho -> psi$): $rho -> phi$ theorem fp_implies_regex_leaf : $rho -> rho$ = 'id; - -theorem fp_implies_regex_interior {X: SVar} (phi_a phi_b: Pattern X) - (posa: $ _Positive X phi_a $) - (posb: $ _Positive X phi_b $) - (he: $epsilon -> rho$) - (ha: $s[ rho / X ] phi_a -> (derivative a rho)$) - (hb: $s[ rho / X ] phi_b -> (derivative b rho)$): - ---------------------------------------------- - $(mu X (epsilon \/ ((a . phi_a) \/ (b . phi_b)))) -> rho$ = - '(KT - (positive_in_or positive_disjoint @ positive_in_or (positive_in_concat positive_disjoint posa) (positive_in_concat positive_disjoint posb)) @ - apply_equiv der_equality_bi_concrete (norm - (norm_imp_l @ norm_sym @ _sSubst_or sSubstitution_disjoint @ _sSubst_or (sSubst_concat_r norm_refl) (sSubst_concat_r norm_refl)) - (orim (iand id he) @ orim (framing_concat_r ha) (framing_concat_r hb)) - )); diff --git a/conftest.py b/words/conftest.py similarity index 100% rename from conftest.py rename to words/conftest.py diff --git a/maude.py b/words/maude.py similarity index 100% rename from maude.py rename to words/maude.py diff --git a/proof-gen.py b/words/proof-gen.py similarity index 91% rename from proof-gen.py rename to words/proof-gen.py index 5d5bf0d..8cca629 100755 --- a/proof-gen.py +++ b/words/proof-gen.py @@ -21,12 +21,12 @@ def cleanup_maude_output(s: str) -> str: (mm01, theorem, regex) = sys.argv[1:] if mm01 == 'mm0': - print('import "../20-theory-words.mm0";') + print('import "../24-ab-alphabet.mm0";') print(cleanup_maude_output( reduce_in_module('regexp-proof-gen.maude', 'PROOF-GEN', 'MM0Decl', 'theorem-{0}-mm0({1})'.format(theorem, regex)))) elif mm01 == 'mm1': - print('import "../23-words-theorems.mm1";') + print('import "../24-ab-alphabet.mm1";') print(cleanup_maude_output( reduce_in_module('regexp-proof-gen.maude', 'PROOF-GEN', 'MM0Decl', 'theorem-{0}({1})'.format(theorem, regex)))) diff --git a/regexp-proof-gen.maude b/words/regexp-proof-gen.maude similarity index 98% rename from regexp-proof-gen.maude rename to words/regexp-proof-gen.maude index 80a8055..97bfb0a 100644 --- a/regexp-proof-gen.maude +++ b/words/regexp-proof-gen.maude @@ -261,10 +261,11 @@ mod ERE-THEOREMS is vars A B A1 A2 : Letter . vars X Y : Qid . - rl [regex_eq_der_bot] : (derivative A bot) => bot . - rl [regex_eq_der_epsilon] : (derivative A epsilon) => bot . - rl [regex_eq_der_same_a] : (derivative A A) => epsilon . - crl [regex_eq_der_diff_a] : (derivative A B) => bot if A =/= B . + rl [regex_eq_der_bot] : (derivative A bot) => bot . + rl [regex_eq_der_epsilon] : (derivative A epsilon) => bot . + rl [regex_eq_der_same_l] : (derivative A A) => epsilon . + crl [regex_eq_der_diff_l_a] : (derivative A a) => bot if A =/= a . + crl [regex_eq_der_diff_l_b] : (derivative A b) => bot if A =/= b . rl [regex_eq_der_kleene] : (derivative A [[kleene X Alpha]]) => (derivative A Alpha) . [[kleene X Alpha]] . @@ -418,8 +419,9 @@ mod PROOF-GEN is eq applyAnyEquation(S, SL, NAT) = applyEq(S, SL, NAT, 'regex_eq_der_bot) or-else applyEq(S, SL, NAT, 'regex_eq_der_epsilon) or-else - applyEq(S, SL, NAT, 'regex_eq_der_same_a) or-else - applyEq(S, SL, NAT, 'regex_eq_der_diff_a) or-else + applyEq(S, SL, NAT, 'regex_eq_der_same_l) or-else + applyEq(S, SL, NAT, 'regex_eq_der_diff_l_a) or-else + applyEq(S, SL, NAT, 'regex_eq_der_diff_l_b) or-else applyEq(S, SL, NAT, 'regex_eq_der_kleene) or-else applyEq(S, SL, NAT, 'regex_eq_der_concat) or-else applyEq(S, SL, NAT, 'regex_eq_der_choice) or-else @@ -681,8 +683,8 @@ mod PROOF-GEN is *** is-letter ************************************************************* op is-letter : Letter -> MM0SExpr . - eq is-letter(a) = 'orl . - eq is-letter(b) = 'orr . + eq is-letter(a) = 'a-in-top-letter . + eq is-letter(b) = 'b-in-top-letter . *** epsilon-implies-ewp *************************************************** --- MetaTheorem: diff --git a/test b/words/test similarity index 77% rename from test rename to words/test index 366c473..4b2f204 100755 --- a/test +++ b/words/test @@ -2,6 +2,8 @@ set -euo pipefail export PYTHONPYCACHEPREFIX='.build/' +./words-theory-gen.py 24-ab-alphabet a b + poetry install poetry run mypy *.py poetry run pytest ./test.py "$@" diff --git a/test.maude b/words/test.maude similarity index 100% rename from test.maude rename to words/test.maude diff --git a/test.py b/words/test.py similarity index 100% rename from test.py rename to words/test.py diff --git a/words/words-theory-gen.py b/words/words-theory-gen.py new file mode 100755 index 0000000..836e0a5 --- /dev/null +++ b/words/words-theory-gen.py @@ -0,0 +1,232 @@ +#!/usr/bin/env python3 + +import os, string, itertools, functools, sys +from textwrap import dedent + +def gen_mm0(letters, f, longest): + f.write('import "20-theory-words.mm0";\n') + for lname in letters: + space = ' '*(longest-len(lname)) + symbol_def = dedent(''' + term {0}_symbol{1}: Symbol; + def {0}{1}: Pattern = $ sym {0}_symbol {1}$;'''.format(lname, space)) + f.write(symbol_def) + f.write('\n') + for lname in letters: + space = ' '*(longest-len(lname)) + functional_let = dedent(''' + axiom functional_{0} {1}: $ is_func {0}{1} $;'''.format(lname, space)) + f.write(functional_let) + f.write('\n') + for (lname1, lname2) in itertools.combinations(letters, 2): + space1 = ' '*(longest-len(lname1)) + space2 = ' '*(longest-len(lname2)) + no_confusion = dedent(''' + axiom no_confusion_{0}_{1}{2}{3}: $ {0} {2}!= {1} {3}$;'''.format(lname1, lname2, space1, space2)) + f.write(no_confusion) + f.write('\n') + top_letter = 'axiom all_letters: $ top_letter == {} $;'.format(' \/ '.join(letters)) + f.write('\n{}\n'.format(top_letter)) + +def gen_thms(letters, f, longest, str_base): + for lname in letters: + thm = dedent(str_base.format(lname)) + f.write(thm) + f.write('\n') + +def build_str(letters, delim, part_format): + return delim.join(map(part_format.format, letters)) + +def bin_tree_list(n): + if n == 1: + return ['id'] + return [((('orld @ '*(n-2)) + 'orld') if i == 0 else (('orld @ '*(n-i-1)) + 'orrd')) for i in range(n)] + +def gen_mm1(letters, f, longest): + n = len(letters) + f.write('import "{}.mm0";\n'.format(filename)) + f.write('import "23-words-theorems.mm1";\n') + for (lname1, lname2) in itertools.combinations(letters, 2): + no_confusion = dedent(''' + theorem no_confusion_{1}_{0}: $ {1} != {0} $ = '(con3 eq_sym no_confusion_{0}_{1});'''.format(lname1, lname2)) + f.write(no_confusion) + f.write('\n') + for i, lname in enumerate(letters): + if n == 1: + proof = 'eq_to_intro_rev all_letters' + else: + if i == 0: + proof = ('@ syl orl '*(n-2)) + 'orl' + else: + proof = ('@ syl orl '*(n-i-1)) + 'orr' + proof = 'syl (eq_to_intro_rev all_letters) {}'.format(proof) + in_top_letter = dedent(''' + theorem {0}_in_top_letter: $ {0} -> top_letter $ = + \'({1});'''.format(lname, proof)) + f.write(in_top_letter) + f.write('\n') + gen_thms(letters, f, longest, ''' + theorem functional_{0}_concat {{x v: EVar}}: $ exists x (eVar x == {0} . eVar v) $ = + '(functional_l_concat functional_{0});''') + gen_thms(letters, f, longest, ''' + theorem regex_eq_ewp_{0}: $ epsilon /\ {0} <-> bot $ = + '(regex_eq_ewp_l {0}_in_top_letter);''') + gen_thms(letters, f, longest, ''' + theorem regex_eq_ewp_not_{0}: $ (epsilon /\ ~{0}) <-> epsilon $ = + '(ibii anl @ iand id @ dne @ anl regex_eq_ewp_{0});''') + gen_thms(letters, f, longest, ''' + theorem regex_eq_der_bot_wrt_{0}: $ (derivative {0} bot) <-> bot $ = + '(ibii (regex_eq_der_bot functional_{0}) absurdum);''') + gen_thms(letters, f, longest, ''' + theorem regex_eq_der_epsilon_wrt_{0}: $ (derivative {0} epsilon) <-> bot $ = + '(regex_eq_der_epsilon functional_{0} {0}_in_top_letter);''') + gen_thms(letters, f, longest, ''' + theorem regex_eq_der_choice_wrt_{0}: $ (derivative {0} (Alpha \/ Beta)) <-> (derivative {0} Alpha) \/ (derivative {0} Beta) $ = + '(regex_eq_der_choice functional_{0});''') + gen_thms(letters, f, longest, ''' + theorem regex_eq_der_conj_wrt_{0}: $ (derivative {0} (Alpha /\ Beta)) <-> (derivative {0} Alpha) /\ (derivative {0} Beta) $ = + '(regex_eq_der_conj functional_{0});''') + gen_thms(letters, f, longest, ''' + theorem regex_eq_der_neg_wrt_{0}: $ (derivative {0} (~ Alpha)) <-> ~ (derivative {0} Alpha) $ = + '(regex_eq_der_neg functional_{0});''') + gen_thms(letters, f, longest, ''' + theorem regex_eq_der_same_l_wrt_{0}: $ (derivative {0} {0}) <-> epsilon $ = + '(regex_eq_der_same_l functional_{0} {0}_in_top_letter);''') + + for (lname1, lname2) in itertools.permutations(letters, 2): + der_diff_letters = dedent(''' + theorem regex_eq_der_diff_l_{1}_wrt_{0}: $ (derivative {0} {1}) <-> bot $ = + '(regex_eq_der_diff_l functional_{0} functional_{1} {0}_in_top_letter {1}_in_top_letter no_confusion_{0}_{1});'''.format(lname1, lname2)) + f.write(der_diff_letters) + f.write('\n') + + gen_thms(letters, f, longest, ''' + theorem regex_eq_der_concat_wrt_{0}: $ (derivative {0} (Alpha . Beta)) <-> ((derivative {0} Alpha) . Beta) \/ ((epsilon /\ Alpha) . (derivative {0} Beta)) $ = + '(regex_eq_der_concat functional_{0} {0}_in_top_letter);''') + gen_thms(letters, f, longest, ''' + theorem regex_eq_der_kleene_wrt_{0} {{X: SVar}} (Alpha: Pattern X) (X_fresh: $ _sFresh X Alpha $): $ (derivative {0} (kleene X Alpha)) <-> ((derivative {0} Alpha) . (kleene X Alpha)) $ = + '(regex_eq_der_kleene X_fresh functional_{0} {0}_in_top_letter);''') + + der_equality_bi_concrete = dedent(''' + theorem der_equality_bi_concrete: $phi <-> (epsilon /\ phi) \/ ({0})$ = + (named + \'(bitr der_equality_bi + @ oreq2i + @ bitr ( cong_of_equiv_exists + @ bitr (aneq2i (bitr (cong_of_equiv_mem @ eq_to_intro_bi all_letters) + ,(propag_mem_w_fun \'x ${1}$ (atom-map! {2})))) + ancomb) + {3} + )); + '''.format(build_str(letters, ' \/ ', '({0} . (derivative {0} phi))'), + ' \/ '.join(letters), + build_str(letters, ' ', '\'[{0} functional_{0}]'), + functools.reduce('(bitr (cong_of_equiv_exists andir) @ bitr or_exists_bi @ oreqi {0} {1})'.format, + map("(mp ,(func_to_and_ctx_bi 'x $eVar x . derivative (eVar x) phi$) functional_{})".format, + letters)))) + f.write(der_equality_bi_concrete) + + positive_in_fp_interior = dedent(''' + theorem positive_in_fp_interior {{X: SVar}} ({0}: Pattern X) + {1}: + $ _Positive X (epsilon \/ ({2})) $ + = '(positive_in_or positive_disjoint {3}); + '''.format(build_str(letters, ' ', 'phi_{0}'), + build_str(letters, '\n ', '(pos_{0}: $ _Positive X phi_{0} $)'), + build_str(letters, ' \/ ', '{0} . phi_{0}'), + functools.reduce('(positive_in_or {0} {1})'.format, map('(positive_in_concat positive_disjoint pos_{0})'.format, letters)), + )) + f.write(positive_in_fp_interior) + + fp_implies_regex_interior = dedent(''' + theorem fp_implies_regex_interior {{X: SVar}} ({0} rho: Pattern X) + {1} + (he: $ epsilon -> rho $) + {2}: + ---------------------------------------------- + $(mu X (epsilon \/ ({3}))) -> rho$ = + '(KT (positive_in_fp_interior {4}) @ + apply_equiv der_equality_bi_concrete (norm + (norm_imp_l @ norm_sym @ _sSubst_or sSubstitution_disjoint {5}) + (orim (iand id he) {6}) + )); + '''.format(build_str(letters, ' ', 'phi_{0}'), + build_str(letters, '\n ', '(pos_{0}: $ _Positive X phi_{0} $)'), + build_str(letters, '\n ', '(h_{0}: $ s[ rho / X ] phi_{0} -> (derivative {0} rho) $)'), + build_str(letters, ' \/ ', '({0} . phi_{0})'), + build_str(letters, ' ', 'pos_{0}'), + functools.reduce('(_sSubst_or {0} {1})'.format, ['(sSubst_concat_r norm_refl)']*n), + functools.reduce('(orim {0} {1})'.format, map('(framing_concat_r h_{0})'.format, letters)), + )) + f.write(fp_implies_regex_interior) + + top_implies_fp_interior = dedent(''' + theorem top_implies_fp_interior {{X box: SVar}} ({0} {1}: Pattern X box) + {2} + {3} + + {4} + {5} + : ------------------------ + $(mu X (epsilon \/ ({6}))) . top_letter -> (mu X (epsilon \/ ({7})))$ + = '(unwrap_subst appctx_concat_l + @ KT_subst (positive_in_fp_interior {8}) ,(propag_s_subst_adv 'X $epsilon \/ ({9})$ (atom-map! {10})) + @ eori + ( wrap_subst appctx_concat_l + @ rsyl (anl regex_eq_eps_concat_l) + @ unfold_r (positive_in_fp_interior {11}) + @ norm (norm_sym @ norm_imp_r ,(propag_s_subst_adv 'X $epsilon \/ ({9})$ (atom-map! {10}))) + @ orrd + @ rsyl (eq_to_intro all_letters) + {12}) + {13} + ); + '''.format(build_str(letters, ' ', 'fp_unf_{0}'), + build_str(letters, ' ', 'fp_ctximp_{0}'), + build_str(letters, '\n ', '(p_fp_unf_{0}: $ _Positive X fp_unf_{0} $)'), + build_str(letters, '\n ', '(p_fp_ctximp_{0}: $ _Positive X fp_ctximp_{0} $)'), + build_str(letters, '\n ', '(he_{{0}}: $ epsilon -> s[ (mu X (epsilon \/ ({0}))) / X ] fp_unf_{{0}} $)' + .format(build_str(letters, ' \/ ', '{0} . fp_unf_{0}'))), + build_str(letters, '\n ', '(h{{0}}: $ ((s[ (ctximp_app box (sVar box . top_letter) (mu X (epsilon \/ ({0})))) / X ] fp_ctximp_{{0}}) . top_letter)\n -> (s[ (mu X (epsilon \/ ({0}))) / X ] fp_unf_{{0}}) $)' + .format(build_str(letters, ' \/ ', '{0} . fp_unf_{0}'))), + build_str(letters, ' \/ ', '{0} . fp_ctximp_{0}'), + build_str(letters, ' \/ ', '{0} . fp_unf_{0}'), + build_str(letters, ' ', 'p_fp_ctximp_{0}'), + build_str(letters, ' \/ ', '{0} . _'), + build_str(letters, ' ', '\'[{0} #t]'), + build_str(letters, ' ', 'p_fp_unf_{0}'), + functools.reduce('(orim {0} {1})'.format, map('(rsyl (anr regex_eq_eps_concat_r) @ framing_concat_r he_{0})'.format, letters)), + functools.reduce('(eori {0} {1})'.format, map(''' + ( wrap_subst appctx_concat_l + @ rsyl (bi1i @ assoc_concat) + @ unfold_r (positive_in_fp_interior {0}) + @ norm (norm_sym @ norm_imp_r ,(propag_s_subst_adv 'X $epsilon \/ ({1})$ (atom-map! {2}))) + @ orrd + @ {{1}} + @ framing_concat_r h{{0}})'''.format(build_str(letters, ' ', 'p_fp_unf_{0}'), + build_str(letters, ' \/ ', '{0} . _'), + build_str(letters, ' ', '\'[{0} #t]'), + ).format, letters, bin_tree_list(n))), + )) + f.write(top_implies_fp_interior) + + + +assert len(sys.argv) >= 3, "Usage: words-theory-gen *" +filename = sys.argv[1] +letters = sys.argv[2:] + +assert len(set(letters)) == len(letters), "List of letters may not contain duplicates" + +ascii = set(string.ascii_uppercase + string.ascii_lowercase) +assert all(ascii.issuperset(lname) for lname in letters), "Letter names may only be of the form 'a-Z'*" + +longest = max(map(len, letters)) + +f = open("{}.mm0".format(filename), "w") +gen_mm0(letters, f, longest) +f.close() + +f = open("{}.mm1".format(filename), "w") +gen_mm1(letters, f, longest) +f.close()