Skip to content
Snippets Groups Projects
logic.lp 2.81 KiB
Newer Older
gabrielhdt's avatar
gabrielhdt committed
require open personoj.encodings.lhol
require open personoj.encodings.pvs_cert
require open personoj.encodings.bool_hol
require open personoj.encodings.prenex
gabrielhdt's avatar
gabrielhdt committed
//
// Booleans
// In [adlib.cert_f.bootstrap]
gabrielhdt's avatar
gabrielhdt committed

//
// Equalities
//
gabrielhdt's avatar
gabrielhdt committed
//
// Notequal
//
gabrielhdt's avatar
gabrielhdt committed
// definition neq {T: Set} (x y: η T) ≔ ¬ (x = y)
symbol neq: χ (∀S (λt, scheme (t ~> t ~> bool)))
rule neq _ $x $y ↪ ¬ ($x = $y)
set infix left 2 "/=" ≔ neq
set infix left 2 "≠" ≔ neq
gabrielhdt's avatar
gabrielhdt committed

//
// if_def
//

//
// boolean_props
// Slightly modified from the prelude
gabrielhdt's avatar
gabrielhdt committed
constant symbol bool_exclusive: ε (neq bool false true)
constant
symbol bool_inclusive
gabrielhdt's avatar
gabrielhdt committed
     : ε (∀ {bool} (λa, ((eq {bool} a false) ∨ (λ_, eq {bool} a true))))
gabrielhdt's avatar
gabrielhdt committed
theorem excluded_middle: ε (∀ {bool} (λa, a ∨ (λ_, ¬ a)))
gabrielhdt's avatar
gabrielhdt committed
proof
gabrielhdt's avatar
gabrielhdt committed
  assume x f
  refine f
gabrielhdt's avatar
gabrielhdt committed

//
// xor_def
//
gabrielhdt's avatar
gabrielhdt committed
definition xor (a b: η bool) ≔ neq bool a b
gabrielhdt's avatar
gabrielhdt committed
set flag "print_implicits" on
gabrielhdt's avatar
gabrielhdt committed
theorem xor_def: ε (∀
gabrielhdt's avatar
gabrielhdt committed
                      {bool}
                      (λa,
gabrielhdt's avatar
gabrielhdt committed

gabrielhdt's avatar
gabrielhdt committed
                           {bool}
                           (λb, eq {bool} (xor a b)
                                   (if {bool} a (λ_, ¬ b) (λ_, b)))))
gabrielhdt's avatar
gabrielhdt committed
proof
admit

gabrielhdt's avatar
gabrielhdt committed

gabrielhdt's avatar
gabrielhdt committed
//
gabrielhdt's avatar
gabrielhdt committed
// Quantifier props[t: TYPE]
gabrielhdt's avatar
gabrielhdt committed
//
set declared "∃"
gabrielhdt's avatar
gabrielhdt committed
definition ∃ {T: Set} (P: η T → η bool) ≔ ¬ (∀ (λx, ¬ (P x)))
gabrielhdt's avatar
gabrielhdt committed

//
// Defined types
//
gabrielhdt's avatar
gabrielhdt committed
// FIXME: needs another prenex polymorphism to be encoded,
require open personoj.encodings.pvs_more
definition pred : ι ({|set|} *> {|set|}) ≔ λt: θ {|set|}, t ~> bool
definition PRED ≔ pred
definition predicate ≔ pred
definition PREDICATE ≔ pred
definition setof ≔ pred
definition SETOF ≔ pred
gabrielhdt's avatar
gabrielhdt committed

//
// exists1
//

//
// equality_props
//
gabrielhdt's avatar
gabrielhdt committed

gabrielhdt's avatar
gabrielhdt committed
constant
symbol If_true
     : ε (∀B
gabrielhdt's avatar
gabrielhdt committed
           (λt, ∀
                  (λx, ∀ {t} (λy, if true (λ_, x) (λ_, y) = x))))
gabrielhdt's avatar
gabrielhdt committed
constant
symbol If_false
     : ε (∀B
gabrielhdt's avatar
gabrielhdt committed
           (λt, ∀
                  (λx, ∀ {t} (λy, if false (λ_, x) (λ_, y) = y))))
gabrielhdt's avatar
gabrielhdt committed

theorem if_same
      : ε (∀B (λt,
gabrielhdt's avatar
gabrielhdt committed
                 ∀ {bool} (λb, ∀ (λx: η t,
gabrielhdt's avatar
gabrielhdt committed
                                              if b (λ_, x) (λ_, x) = x))))
gabrielhdt's avatar
gabrielhdt committed
proof
gabrielhdt's avatar
gabrielhdt committed
admit
gabrielhdt's avatar
gabrielhdt committed
constant symbol reflexivity_of_equals: ε (∀B (λt, ∀ (λx: η t, x = x)))
gabrielhdt's avatar
gabrielhdt committed
set builtin "refl" ≔ reflexivity_of_equals
gabrielhdt's avatar
gabrielhdt committed
constant
symbol transitivity_of_equals
     : ε (∀B (λt,
gabrielhdt's avatar
gabrielhdt committed

gabrielhdt's avatar
gabrielhdt committed
                  (λx: η t,
gabrielhdt's avatar
gabrielhdt committed

gabrielhdt's avatar
gabrielhdt committed
                       (λy: η t,
gabrielhdt's avatar
gabrielhdt committed

gabrielhdt's avatar
gabrielhdt committed
                            (λz: η t, (x = y) ∧ (λ_, y = z) ⊃ (λ_, x = z))))))
gabrielhdt's avatar
gabrielhdt committed
constant
symbol symmetry_of_equals
gabrielhdt's avatar
gabrielhdt committed
     : ε (∀B (λt, ∀ (λx: η t, (∀ (λy: η t, (x = y) ⊃ (λ_, y = x))))))
gabrielhdt's avatar
gabrielhdt committed
// Not in prelude!
theorem eqind {t} x y: ε (x = y) → Πp: η t → Bool, ε (p y) → ε (p x)
proof
  assume t x y heq
  apply symmetry_of_equals t x y heq
qed
set builtin "eqind" ≔ eqind

gabrielhdt's avatar
gabrielhdt committed
//
// if_props
//