Skip to content
Snippets Groups Projects
logic.lp 3.69 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
require open personoj.encodings.builtins
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)
gabrielhdt's avatar
gabrielhdt committed
// symbol neq: χ (∀S (λt, scheme (t ~> t ~> bool)))
// rule neq _ $x $y ↪ ¬ ($x = $y)
// set infix left 2 "/=" ≔ neq
// set infix left 2 "≠" ≔ neq
/// Defined in builtins
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)
gabrielhdt's avatar
gabrielhdt committed
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
// PVS solves that kind of things thanks to the (bddsimp) tactic which uses an
// external C program
gabrielhdt's avatar
gabrielhdt committed
theorem xor_def
      : ε (∀ {bool} (λa, ∀ {bool} (λb, eq {bool} (xor a b)
                                          (if {bool} a (λ_, ¬ b) (λ_, b)))))
gabrielhdt's avatar
gabrielhdt committed
proof
gabrielhdt's avatar
gabrielhdt committed
  set prover "Alt-Ergo"
  set prover_timeout 12
  assume a b p
  simpl
  assume hxor
gabrielhdt's avatar
gabrielhdt committed
admit
//
gabrielhdt's avatar
gabrielhdt committed
// Quantifier props[t: TYPE], built in
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
constant
symbol If_true
gabrielhdt's avatar
gabrielhdt committed
     : ε (∀B (λt, ∀ (λx, ∀ {t} (λy, if true (λ_, x) (λ_, y) = x))))
gabrielhdt's avatar
gabrielhdt committed
constant
symbol If_false
gabrielhdt's avatar
gabrielhdt committed
     : ε (∀B (λt, ∀ (λx, ∀ {t} (λy, if false (λ_, x) (λ_, y) = y))))
gabrielhdt's avatar
gabrielhdt committed

theorem if_same
gabrielhdt's avatar
gabrielhdt committed
      : ε (∀B (λt, ∀ {bool} (λb, ∀ (λx: η t, 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
                ∀(λx: η t,
                    ∀(λy: η t,
                        ∀(λ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
//
gabrielhdt's avatar
gabrielhdt committed

theorem lift_if1:
  ε (∀B (λs: θ {|set|},
           ∀B (λt: θ {|set|},
                 ∀ {bool}
                   (λa,
                      ∀ (λx: η s,
                           ∀ (λy: η s,
                                ∀ (λf: η (s ~> t),
                                     f (if a (λ_, x) (λ_, y))
                                     = if a (λ_, f x) (λ_, f y))))))))
proof
admit

theorem lift_if2:
  ε (∀B (λs,
           ∀ {bool}
             (λa,
                ∀ {bool}
                  (λb,
                     ∀ {bool}
                       (λc,
                          ∀ (λx: η s,
                               ∀ (λy: η s,
                                    if (if {bool} a (λ_, b) (λ_, c))
                                       (λ_, x)
                                       (λ_, y)
                                     = if a
                                       (λ_, if b (λ_, x) (λ_, y))
                                       (λ_, if c (λ_, x) (λ_, y)))))))))
proof
admit