• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • C
      • Proof-checker-array
      • Soft
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Ethereum
      • Leftist-trees
      • Java
      • Riscv
      • Taspi
      • Bitcoin
      • Zcash
      • Des
      • X86isa
      • Sha-2
      • Yul
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
      • Axe
      • Poseidon
      • Where-do-i-place-my-book
      • Aleo
        • Aleobft
        • Aleovm
          • Circuits
            • Circuits-pfcs
            • Circuits-r1cs
            • Field-div-flagged
            • Boolean-assert-true
            • Field-inv-flagged
            • Boolean-assert
            • Field-div-unchecked
            • Field-neq
              • Field-neq-correctness
                • Field-neq-spec
                • Field-neq-circuit
                • Field-neq-lifting
              • Boolean-not
              • Boolean-assert-all
              • Boolean-if
              • Field-if
              • Boolean-xor
              • Boolean-or
              • Boolean-nor
              • Boolean-and
              • Boolean-nand
              • Boolean-neq
              • Boolean-eq
              • Field-div-checked
              • Field-inv-checked
              • Boolean-assert-neq
              • Boolean-assert-eq
              • Field-eq
              • Field-assert-neq
              • Field-assert-eq
              • Field-mul
              • Field-sub
              • Field-square
              • Field-neg
              • Field-double
              • Field-add
            • Language
          • Leo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Field-neq

    Field-neq-correctness

    Correctness of the circuit.

    Soundness is proved by expanding predicate and specification, but we need to disable two distributive rules that interfere with the proof.

    Completeness is proved by expanding the specification and then using the suff theorem for the predicate. The witness is 0 if x and y are equal, otherwise it is the quotient of z and x - y. We also need to disable a distributive rule that interferes.

    The extension to the circuit is boilerplate.

    Definitions and Theorems

    Theorem: field-neq-pred-soundness

    (defthm field-neq-pred-soundness
      (implies (and (primep prime)
                    (pfield::fep x prime)
                    (pfield::fep y prime)
                    (pfield::fep z prime))
               (implies (field-neq-pred x y z prime)
                        (field-neq-spec x y z prime))))

    Theorem: field-neq-pred-completeness

    (defthm field-neq-pred-completeness
      (implies (and (primep prime)
                    (pfield::fep x prime)
                    (pfield::fep y prime)
                    (pfield::fep z prime))
               (implies (field-neq-spec x y z prime)
                        (field-neq-pred x y z prime))))

    Theorem: field-neq-pred-to-spec

    (defthm field-neq-pred-to-spec
      (implies (and (primep prime)
                    (pfield::fep x prime)
                    (pfield::fep y prime)
                    (pfield::fep z prime))
               (equal (field-neq-pred x y z prime)
                      (field-neq-spec x y z prime))))

    Theorem: field-neq-circuit-to-spec

    (defthm field-neq-circuit-to-spec
      (implies (and (equal (pfcs::lookup-definition (pfname "field_neq")
                                                    defs)
                           (field-neq-circuit))
                    (primep prime)
                    (pfield::fep x prime)
                    (pfield::fep y prime)
                    (pfield::fep z prime))
               (equal (pfcs::definition-satp (pfname "field_neq")
                                             defs (list x y z)
                                             prime)
                      (field-neq-spec x y z prime))))