All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cvc5-cvc5-1.2.0.proofs.lfsc.signatures.arith_rules.plf Maven / Gradle / Ivy

The newest version!
; depends: arith_programs.plf

; Computes the conclusion of the ProofRule::ARITH_SUM_UB rule.
; Note that f2 is a a.+ application in n-ary form.
(function sc_arith_sum_ub ((f1 term) (f2 term)) term
  (let r1 (sc_arith_get_rel f1)
  (let lhs1 (sc_arith_get_lhs f1)
  (let rhs1 (sc_arith_get_rhs f1)
  (let r2 (sc_arith_get_rel f2)
  (let lhs2 (sc_arith_get_lhs f2)
  (let rhs2 (sc_arith_get_rhs f2)
    (apply (apply (sc_arith_sum_rels r1 r2) (sc_arith_add_nary lhs1 lhs2)) (sc_arith_add_nary rhs1 rhs2)))))))))

(declare arith_sum_ub
  (! f1 term
  (! f2 term
  (! res term
  (! p (holds f1)
  (! p (holds f2)
  (! r (^ (sc_arith_sum_ub f1 f2) res)
    (holds res))))))))

; Computes the conclusion of the ProofRule::ARITH_MULT_POS rule.
(function sc_arith_mult_pos ((m term) (f term) (u sort)) term
  (let r (sc_arith_get_rel f)
  (let lhs (sc_arith_get_lhs f)
  (let rhs (sc_arith_get_rhs f)
    (=> (and (sc_arith_>_zero m u) (and f true))
        (apply (apply r (sc_arith_mult m lhs)) (sc_arith_mult m rhs)))))))

(declare arith_mult_pos
  (! res term
  (! m term
  (! f term
  (! u sort
  (! r (^ (sc_arith_mult_pos m f u) res)
    (holds res)))))))

; Computes the conclusion of the ProofRule::ARITH_MULT_NEG rule.
(function sc_arith_mult_neg ((m term) (f term) (u sort)) term
  (let r (sc_arith_get_rel f)
  (let lhs (sc_arith_get_lhs f)
  (let rhs (sc_arith_get_rhs f)
    (=> (and (sc_arith_<_zero m u) (and f true))
        (apply (apply (sc_arith_rel_inv r) (sc_arith_mult m lhs)) (sc_arith_mult m rhs)))))))
        
(declare arith_mult_neg
  (! res term
  (! m term
  (! f term
  (! u sort
  (! r (^ (sc_arith_mult_neg m f u) res)
    (holds res)))))))

; Computes the conclusion of the ProofRule::ARITH_TRICHOTOMY rule.
(function sc_arith_trichotomy ((f1 term) (f2 term)) term
  (let r1 (sc_arith_get_rel_neg f1)
  (let a1 (sc_arith_get_atom f1)
  (let lhs1 (sc_arith_get_lhs a1)
  (let rhs1 (sc_arith_get_rhs a1)
  (let r2 (sc_arith_get_rel_neg f2)
  (let a2 (sc_arith_get_atom f1)
  (let lhs2 (sc_arith_get_lhs a2)
  (let rhs2 (sc_arith_get_rhs a2)
    (ifequal lhs1 lhs2
      (ifequal rhs1 rhs2
        (apply (apply (sc_arith_rel_trichotomy r1 r2) lhs1) rhs1)
        (fail term))
      (fail term)))))))))))

(declare arith_trichotomy
  (! res term
  (! f1 term
  (! f2 term
  (! p1 (holds f1)
  (! p2 (holds f2)
  (! r (^ (sc_arith_trichotomy f1 f2) res)
    (holds res))))))))

; Returns ok if c is the greatest integer less than (integer or real) constant
; t. We compute this via conditions 0 <= c-t ^ (c-t)-1 <= 0.
(function sc_check_int_tight_ub ((t term) (c term)) Ok
  (mpq_between_zero_one (mp_add (match t ((int ct) (mpz_to_mpq ct)) ((real ct) ct))
                                (mp_neg (mpz_to_mpq (sc_arith_get_mpz c))))))

; Integer tight upper bound rule, which uses the above side condition to
; compute whether c is the greatest integer less than t. The constant c must
; be provided to applications of this rule.
(declare int_tight_ub
  (! s term
  (! t term
  (! c term
  (! p (holds (a.< s t))
  (! r (^ (sc_check_int_tight_ub t c) ok)
    (holds (a.<= s c))))))))

; Returns ok if c2 is the least integer greater than c1. We compute this
; via conditions 0 <= c1-c2 ^ (c1-c2)-1 <= 0.
(function sc_check_int_tight_lb ((t term) (c term)) Ok
  (mpq_between_zero_one (mp_add (mpz_to_mpq (sc_arith_get_mpz c))
                                (mp_neg (match t ((int ct) (mpz_to_mpq ct)) ((real ct) ct))))))

; Similar to int_tight_ub, but for lower bound.
(declare int_tight_lb
  (! s term
  (! t term
  (! c term
  (! p (holds (a.> s t))
  (! r (^ (sc_check_int_tight_lb t c) ok)
    (holds (a.>= s c))))))))




© 2015 - 2024 Weber Informatics LLC | Privacy Policy