1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
  
     | 
    
      ; Milawa - A Reflective Theorem Prover
; Copyright (C) 2005-2009 Kookamara LLC
;
; Contact:
;
;   Kookamara LLC
;   11410 Windermere Meadows
;   Austin, TX 78759, USA
;   http://www.kookamara.com/
;
; License: (An MIT/X11-style license)
;
;   Permission is hereby granted, free of charge, to any person obtaining a
;   copy of this software and associated documentation files (the "Software"),
;   to deal in the Software without restriction, including without limitation
;   the rights to use, copy, modify, merge, publish, distribute, sublicense,
;   and/or sell copies of the Software, and to permit persons to whom the
;   Software is furnished to do so, subject to the following conditions:
;
;   The above copyright notice and this permission notice shall be included in
;   all copies or substantial portions of the Software.
;
;   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
;   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
;   DEALINGS IN THE SOFTWARE.
;
; Original author: Jared Davis <jared@kookamara.com>
(in-package "MILAWA")
(include-book "conditional-eqsubst")
(%interactive)
(defthm logic.strip-conclusions-of-restn
  ;; BOZO this seems to address some of the firstn/restn issues.  Move it where it
  ;; belongs and try using it globally.
  (equal (logic.strip-conclusions (restn n x))
         (restn n (logic.strip-conclusions x))))
(in-theory (disable restn-of-logic.strip-conclusions))
(ACL2::theory-invariant (ACL2::incompatible (:rewrite logic.strip-conclusions-of-restn)
                                            (:rewrite restn-of-logic.strip-conclusions)))
(%autoprove logic.strip-conclusions-of-restn)
(%disable default
          restn-of-logic.strip-conclusions
          [outside]restn-of-logic.strip-conclusions)
(defthm logic.strip-conclusions-of-firstn
  ;; BOZO this seems to address some of the firstn/restn issues.  Move it where it
  ;; belongs and try using it globally.
  (equal (logic.strip-conclusions (firstn n x))
         (firstn n (logic.strip-conclusions x))))
(in-theory (disable firstn-of-logic.strip-conclusions))
(ACL2::theory-invariant (ACL2::incompatible (:rewrite logic.strip-conclusions-of-firstn)
                                            (:rewrite firstn-of-logic.strip-conclusions)))
(%autoprove logic.strip-conclusions-of-firstn)
(%disable default
          firstn-of-logic.strip-conclusions
          [outside]firstn-of-logic.strip-conclusions)
(%autoprove logic.substitute-formula-of-logic.disjoin-formulas-free)
(%autoprove lemma-for-aggressive-forcing-logic.substitute-of-logic.replace-subterm
            (%logic.term-induction flag x)
            (%restrict default definition-of-logic.replace-subterm (equal x 'x)))
(%autoprove aggressive-forcing-logic.substitute-of-logic.replace-subterm
            (%use (%instance (%thm lemma-for-aggressive-forcing-logic.substitute-of-logic.replace-subterm)
                             (flag 'term))))
(%autoprove aggressive-forcing-logic.substitute-list-of-logic.replace-subterm-list
            (%use (%instance (%thm lemma-for-aggressive-forcing-logic.substitute-of-logic.replace-subterm)
                             (flag 'list))))
(%autoprove lemma-for-equal-of-logic.replace-subterm-and-logic.replace-subterm-when-same-term-and-old
            (%logic.term-induction flag x)
            (%restrict default definition-of-logic.replace-subterm (equal x 'x))
            (%restrict default definition-of-logic.subtermp (equal y 'x)))
(%autoprove equal-of-logic.replace-subterm-and-logic.replace-subterm-when-same-term-and-old
            (%use (%instance (%thm lemma-for-equal-of-logic.replace-subterm-and-logic.replace-subterm-when-same-term-and-old)
                             (flag 'term))))
(%autoprove equal-of-logic.replace-subterm-list-and-logic.replace-subterm-list-when-same-term-and-old
            (%use (%instance (%thm lemma-for-equal-of-logic.replace-subterm-and-logic.replace-subterm-when-same-term-and-old)
                             (flag 'list))))
(%autoprove forcing-logic.substitute-of-var-when-first-in-sigma
            (%restrict default definition-of-logic.substitute (equal x 'var)))
(%autoprove forcing-logic.substitute-of-var-when-second-in-sigma
            (%restrict default definition-of-logic.substitute (equal x 'var)))
(%autoprove equal-of-first-and-second-when-uniquep)
(%autoprove equal-of-second-and-first-when-uniquep) ;; probably unnecessary via term order??
(%autoprove memberp-of-first-of-difference-in-removed
            (%disable default
                      memberp-of-car
                      [outside]memberp-of-car)
            (%use (%instance (%thm memberp-of-car)
                             (x (difference x y)))))
(%autoprove memberp-of-second-of-difference-in-removed
            (%disable default memberp-of-second)
            (%use (%instance (%thm memberp-of-second)
                             (x (difference x y)))))
(%autoadmit elim.flag-collect-destructed-variables)
(%autoadmit elim.flag-slow-collect-destructed-variables)
(%autoadmit elim.collect-destructed-variables)
(%autoadmit elim.collect-destructed-variables-list)
(%autoprove true-listp-of-elim.flag-collect-destructed-variables
            (%autoinduct elim.flag-collect-destructed-variables flag x acc)
            (%restrict default elim.flag-collect-destructed-variables (equal x 'x)))
(%autoprove elim.flag-slow-collect-destructed-variables-equiv
            (%autoinduct elim.flag-collect-destructed-variables flag x acc)
            (%restrict default elim.flag-collect-destructed-variables (equal x 'x))
            (%restrict default elim.flag-slow-collect-destructed-variables (equal x 'x)))
(%autoprove definition-of-elim.collect-destructed-variables
            (%forcingp nil)
            (%restrict default elim.flag-slow-collect-destructed-variables (equal x 'x))
            (%enable default
                     elim.collect-destructed-variables
                     elim.collect-destructed-variables-list))
(%autoprove definition-of-elim.collect-destructed-variables-list
            (%restrict default elim.flag-slow-collect-destructed-variables (equal x 'x))
            (%enable default
                     elim.collect-destructed-variables
                     elim.collect-destructed-variables-list))
(%autoprove lemma-for-logic.variable-listp-of-elim.collect-destructed-variables
            (%logic.term-induction flag x)
            (%restrict default definition-of-elim.collect-destructed-variables (equal x 'x))
            (%restrict default definition-of-elim.collect-destructed-variables-list (equal x 'x)))
(%autoprove logic.variable-listp-of-elim.collect-destructed-variables
            (%use (%instance (%thm lemma-for-logic.variable-listp-of-elim.collect-destructed-variables)
                             (flag 'term))))
(%autoprove logic.variable-listp-of-elim.collect-destructed-variables-list
            (%use (%instance (%thm lemma-for-logic.variable-listp-of-elim.collect-destructed-variables)
                             (flag 'list))))
;; BOZO stupid name, should be called duplicity
(%autoadmit fast-count)
(%autoadmit slow-count)
(%autoadmit count)
(%autoprove fast-count-as-slow-count
            (%autoinduct fast-count a x acc)
            (%restrict default fast-count (equal x 'x))
            (%restrict default slow-count (equal x 'x)))
(%autoprove definition-of-count
            (%enable default count)
            (%restrict default slow-count (equal x 'x))
            (%enable default fast-count-as-slow-count))
(%autoprove count-when-not-consp
            (%restrict default definition-of-count (equal x 'x)))
(%autoprove count-of-cons
            (%restrict default definition-of-count (equal x '(cons b x))))
(%autoprove natp-of-count
            (%cdr-induction x))
(%autoprove count-of-zero
            (%cdr-induction x))
(%autoprove count-of-list-fix
            (%cdr-induction x))
(%autoprove count-of-app
            (%cdr-induction x))
(%autoprove count-of-rev
            (%cdr-induction x))
(%autoprove count-when-not-memberp
            (%cdr-induction x))
(%autoadmit aux-maximal-count)
(%autoprove memberp-of-aux-maximal-count
            (%autoinduct aux-maximal-count best best-count domain x)
            (%restrict default aux-maximal-count (equal domain 'domain)))
(%autoprove aux-maximal-count-when-not-consp-of-x
            (%autoinduct aux-maximal-count best best-count domain x)
            (%restrict default aux-maximal-count (equal domain 'domain)))
(%autoadmit maximal-count)
(%autoprove maximal-count-when-not-consp
            (%enable default maximal-count))
(%autoprove memberp-of-maximal-count
            (%enable default maximal-count))
(%autoadmit elim.find-backup-var)
(%autoprove logic.variablep-of-elim.find-backup-var
            (%autoinduct elim.find-backup-var)
            (%restrict default elim.find-backup-var (equal x 'x)))
(%autoadmit elim.choose-var-to-eliminate)
(%autoprove lemma-for-logic.variablep-of-elim.choose-var-to-eliminate
            (%disable default logic.variablep-when-memberp-of-logic.variable-listp)
            (%use (%instance (%thm logic.variablep-when-memberp-of-logic.variable-listp)
                             (a (maximal-count x))
                             (x x))))
(%autoprove logic.variablep-of-elim.choose-var-to-eliminate
            (%enable default
                     elim.choose-var-to-eliminate
                     lemma-for-logic.variablep-of-elim.choose-var-to-eliminate))
(%deflist logic.variable-list-listp (x)
          (logic.variable-listp x))
(%defmap :map (elim.namesp x)
         :key (logic.variablep x)
         :val (logic.variable-listp x)
         :key-list (logic.variable-listp x)
         :val-list (logic.variable-list-listp x)
         :val-of-nil t)
(%autoadmit elim.pick-fresh-vars)
(encapsulate
 ()
 (local (%disable default
                  unusual-consp-rules
                  unusual-memberp-rules
                  unusual-subsetp-rules
                  expensive-term/formula-inference
                  type-set-like-rules
                  list-of-first-and-second-when-len-2
                  ))
 (local (%enable default elim.pick-fresh-vars))
 (%autoprove forcing-logic.variablep-of-first-of-elim.pick-fresh-vars)
 (%autoprove forcing-logic.variablep-of-second-of-elim.pick-fresh-vars)
 (%autoprove forcing-logic.memberp-of-first-of-elim.pick-fresh-vars)
 (%autoprove forcing-logic.memberp-of-second-of-elim.pick-fresh-vars)
 (%autoprove forcing-equal-of-first-and-second-of-elim.pick-fresh-vars)
 (%autoprove forcing-equal-of-second-and-first-of-elim.pick-fresh-vars))
(%autoadmit elim.elim-clause)
(encapsulate
 ()
 (local (%enable default elim.elim-clause))
 (%autoprove forcing-logic.term-list-listp-of-elim.elim-clause)
 (%autoprove forcing-cons-listp-of-elim.elim-clause)
 (%autoprove forcing-logic.term-list-list-atblp-of-elim.elim-clause))
(%autoadmit elim.elim-clause-bldr)
(encapsulate
 ()
 (local (%enable default
                 axiom-cons-of-car-and-cdr
                 elim.elim-clause
                 logic.term-formula
                 redefinition-of-logic.term-list-formulas
                 elim.elim-clause-bldr))
 (%autoprove forcing-logic.appealp-of-elim.elim-clause-bldr)
 (%autoprove forcing-logic.conclusion-of-elim.elim-clause-bldr)
 (%autoprove forcing-logic.proofp-of-elim.elim-clause-bldr))
(%autoadmit elim.elim-clause-list)
(%autoprove true-listp-of-elim.elim-clause-list
            (%cdr-induction x)
            (%restrict default elim.elim-clause-list (equal x 'x)))
(%autoprove forcing-logic.term-list-listp-of-elim.elim-clause-list
            (%cdr-induction x)
            (%restrict default elim.elim-clause-list (equal x 'x)))
(%autoprove forcing-logic.term-list-list-atblp-of-elim.elim-clause-list
            (%cdr-induction x)
            (%restrict default elim.elim-clause-list (equal x 'x)))
(%autoprove forcing-cons-listp-of-elim.elim-clause-list
            (%cdr-induction x)
            (%restrict default elim.elim-clause-list (equal x 'x)))
(%autoadmit elim.elim-clause-list-bldr)
(encapsulate
 ()
 (%autoprove dangerous-decomposition-of-app
             (%cdr-cdr-induction x a)
             (%restrict default firstn (equal n '(len a)))
             (%restrict default restn (equal n '(len a))))
 (local (%enable default dangerous-decomposition-of-app))
 (%autoprove forcing-logic.appeal-listp-of-elim.elim-clause-list-bldr
             (%autoinduct elim.elim-clause-list-bldr)
             (%restrict default elim.elim-clause-list-bldr (equal x 'x))
             (%restrict default elim.elim-clause-list (equal x 'x)))
 (%autoprove forcing-logic.strip-conclusions-of-elim.elim-clause-list-bldr
             (%autoinduct elim.elim-clause-list-bldr)
             (%restrict default elim.elim-clause-list-bldr (equal x 'x))
             (%restrict default elim.elim-clause-list (equal x 'x)))
 (%autoprove forcing-logic.proof-listp-of-elim.elim-clause-list-bldr
             (%autoinduct elim.elim-clause-list-bldr)
             (%restrict default elim.elim-clause-list-bldr (equal x 'x))
             (%restrict default elim.elim-clause-list (equal x 'x))))
(%autoadmit tactic.elim-first-okp)
(%autoprove booleanp-of-tactic.elim-first-okp
            (%enable default tactic.elim-first-okp))
(%autoadmit tactic.elim-first-tac)
(%autoprove forcing-tactic.skeletonp-of-tactic.elim-first-tac
            (%enable default tactic.elim-first-tac))
(%autoprove forcing-tactic.elim-first-okp-of-tactic.elim-first-tac
            (%enable default tactic.elim-first-tac tactic.elim-first-okp))
(%autoadmit tactic.elim-first-compile)
(encapsulate
 ()
 (local (%enable default
                 tactic.elim-first-okp
                 tactic.elim-first-compile))
 (local (%enable default dangerous-decomposition-of-app))
 (%autoprove forcing-logic.appeal-listp-of-tactic.elim-first-compile
             (%auto :strategy (cleanup split urewrite crewrite))
             (%fertilize (LOGIC.STRIP-CONCLUSIONS PROOFS)
                         (LOGIC.DISJOIN-EACH-FORMULA-LIST
                          (LOGIC.TERM-LIST-LIST-FORMULAS (TACTIC.SKELETON->GOALS X)))))
 (%autoprove forcing-logic.strip-conclusions-of-tactic.elim-first-compile
             (%auto :strategy (cleanup split urewrite crewrite))
             (%fertilize (LOGIC.STRIP-CONCLUSIONS PROOFS)
                         (LOGIC.DISJOIN-EACH-FORMULA-LIST
                          (LOGIC.TERM-LIST-LIST-FORMULAS (TACTIC.SKELETON->GOALS X))))
             (%auto :strategy (cleanup split urewrite crewrite))
             (%fertilize (LOGIC.STRIP-CONCLUSIONS PROOFS)
                         (LOGIC.DISJOIN-EACH-FORMULA-LIST
                          (LOGIC.TERM-LIST-LIST-FORMULAS (TACTIC.SKELETON->GOALS X)))))
 (%autoprove forcing-logic.proof-listp-of-tactic.elim-first-compile
             (%auto :strategy (cleanup split urewrite crewrite))
             (%fertilize (LOGIC.STRIP-CONCLUSIONS PROOFS)
                         (LOGIC.DISJOIN-EACH-FORMULA-LIST
                          (LOGIC.TERM-LIST-LIST-FORMULAS (TACTIC.SKELETON->GOALS X))))))
(%autoadmit tactic.elim-all-okp)
(%autoprove booleanp-of-tactic.elim-all-okp
            (%enable default tactic.elim-all-okp))
(%autoadmit tactic.elim-all-tac)
(%autoprove forcing-tactic.skeletonp-of-tactic.elim-all-tac
            (%enable default tactic.elim-all-tac))
(%autoprove forcing-tactic.elim-all-okp-of-tactic.elim-all-tac
            (%enable default tactic.elim-all-tac tactic.elim-all-okp))
(%autoadmit tactic.elim-all-compile)
(encapsulate
 ()
 (local (%enable default tactic.elim-all-okp tactic.elim-all-compile))
 (%autoprove forcing-logic.appeal-listp-of-tactic.elim-all-compile)
 (%autoprove forcing-logic.strip-conclusions-of-tactic.elim-all-compile)
 (%autoprove forcing-logic.proof-listp-of-tactic.elim-all-compile))
(%ensure-exactly-these-rules-are-missing "../../tactics/elim") 
     |