• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • C
          • Syntax-for-tools
          • Atc
          • Transformation-tools
            • Simpadd0
              • Simpadd0-dirdeclor
              • Simpadd0-implementation
              • Simpadd0-declor
              • Simpadd0-initdeclor
              • Simpadd0-initdeclor-list
              • Simpadd0-decl
              • Simpadd0-comp-stmt
              • Simpadd0-param-declor
              • Simpadd0-param-declon-list
              • Simpadd0-param-declon
              • Simpadd0-expr-option
              • Simpadd0-struct-declor-list
              • Simpadd0-struct-declon-list
              • Simpadd0-dirabsdeclor-option
              • Simpadd0-desiniter-list
              • Simpadd0-struni-spec
              • Simpadd0-struct-declor
              • Simpadd0-struct-declon
              • Simpadd0-statassert
              • Simpadd0-spec/qual-list
              • Simpadd0-spec/qual
              • Simpadd0-genassoc-list
              • Simpadd0-dirabsdeclor
              • Simpadd0-desiniter
              • Simpadd0-designor-list
              • Simpadd0-decl-spec-list
              • Simpadd0-const-expr-option
              • Simpadd0-align-spec
              • Simpadd0-absdeclor-option
              • Simpadd0-type-spec
              • Simpadd0-tyname
              • Simpadd0-member-designor
              • Simpadd0-initer-option
              • Simpadd0-initer
              • Simpadd0-genassoc
              • Simpadd0-expr-list
              • Simpadd0-enumer-list
              • Simpadd0-enumer
              • Simpadd0-enum-spec
              • Simpadd0-designor
              • Simpadd0-declor-option
              • Simpadd0-decl-spec
              • Simpadd0-decl-list
              • Simpadd0-const-expr
              • Simpadd0-block-item-list
              • Simpadd0-block-item
              • Simpadd0-absdeclor
              • Simpadd0-stmt
              • Simpadd0-label
              • Simpadd0-expr
            • Proof-generation
            • Split-gso
            • Wrap-fn
            • Constant-propagation
            • Specialize
            • Split-fn
            • Split-fn-when
            • Split-all-gso
            • Copy-fn
            • Variables-in-computation-states
            • Rename
            • Utilities
            • Proof-generation-theorems
            • Input-processing
          • Language
          • Representation
          • Insertion-sort
          • Pack
        • Soft
        • Bv
        • Imp-language
        • Ethereum
        • Event-macros
        • Java
        • Riscv
        • Bitcoin
        • Zcash
        • Yul
        • ACL2-programming-language
        • Prime-fields
        • Json
        • Syntheto
        • File-io-light
        • Cryptography
        • Number-theory
        • Axe
        • Lists-light
        • Builtins
        • Solidity
        • Helpers
        • Htclient
        • Typed-lists-light
        • Arithmetic-light
      • X86isa
      • Axe
      • Execloader
    • Math
    • Testing-utilities
  • Transformation-tools

Simpadd0

A transformation to simplify E + 0 to E.

Introduction

This is a simple proof-of-concept transformation, which replaces expressions of the form E + 0 with E, when E is an expression that our current c$::validator annotates as having type int, and 0 is the octal constant for zero without other leading zeros and without suffixes.

The transformation also generates proofs of equivalence between old (original) and new (transformed) constructs, for a growing subset of the constructs. In particular, the transformation generates equivalence proofs for C functions of a certain form, detailed below.

General Form

(simpadd0 :const-old ...  ; required, no default
          :const-new ...  ; required, no default
  )

Inputs

:const-old — required, no default

Specifies the code to the transformed.

This must be a symbol that names an existing ACL2 constant that contains avalidated (and thus unambiguous) code ensemble, in particular containing validation information. This constant could result from c$::input-files or from some other transformation.

In the rest of this documentation page, we refer to this constant as *old*.

:const-new — required, no default

Specifies the name of the constant for the transformed code.

This must be a symbol that is valid name for a new ACL2 constant.

In the rest of this documentation page, we refer to this constant as *new*.

Generated Events

*new*

The named constant containing the result of the transformation. This is a code ensemble that is the same as the one in *old*, except that, in the translation unit ensemble, every occurrence of an expression of the form E + 0, when E is an expression that our current c$::validator annotates as having type int, and 0 is the octal constant for zero without other leading zeros and without suffixes, is turned into just the expression E.

The file paths that are the keys of translation unit map are unchanged by the transformation.

Equivalence theorems.

One theorem is generated for every function definition in *old* that has all integer parameters (except plain char and except _Bool) and whose body only contains the following constructs:

  • Declarations of integer variables.
  • Assignment expression statements.
  • The null statement, compound statements, return (with or without expression) statements, conditional (if and if-else statements, and while loop statements.
  • Expressions consisting of integer constants, integer variables, the unary operators that do not involve pointers (i.e. +, -, ~, !), the binary operators that are pure (i.e. *, /, %, +, -, <<, >>, <, >, <=, >=, ==, !=, &, ^, |, &&, ||), the ternary conditional operator ? :, casts to integer types, and parentheses. These are all pure and may be used anywhere.
  • Simple (not compound) integer assignment expressions, only as expression statements.

These theorems are proved by proving a sequence of theorems, in a bottom-up fashion, for the sub-constructs of the functions. Theorems for sub-constructs in the supported subset of C are also generated for functions that are not in the subset.

The generated theorems are designed to always prove. It is a bug in the transformation if a generated theorem fails to prove.

The generated theorems have names of the form *new*-thm-<i>, where <i> are increasing positive integers.

Subtopics

Simpadd0-dirdeclor
Transform a direct declarator.
Simpadd0-implementation
Implementation of simpadd0.
Simpadd0-declor
Transform a declarator.
Simpadd0-initdeclor
Transform an initializer declarator.
Simpadd0-initdeclor-list
Transform a list of initializer declarators.
Simpadd0-decl
Transform a declaration.
Simpadd0-comp-stmt
Transform a compound-statement.
Simpadd0-param-declor
Transform a parameter declarator.
Simpadd0-param-declon-list
Transform a list of parameter declarations.
Simpadd0-param-declon
Transform a parameter declaration.
Simpadd0-expr-option
Transform an optional expression.
Simpadd0-struct-declor-list
Transform a list of structure declarators.
Simpadd0-struct-declon-list
Transform a list of structure declarations.
Simpadd0-dirabsdeclor-option
Transform an optional direct abstract declarator.
Simpadd0-desiniter-list
Transform a list of initializers with optional designations.
Simpadd0-struni-spec
Transform a structure or union specifier.
Simpadd0-struct-declor
Transform a structure declarator.
Simpadd0-struct-declon
Transform a structure declaration.
Simpadd0-statassert
Transform an static assertion declaration.
Simpadd0-spec/qual-list
Transform a list of type specifiers and qualifiers.
Simpadd0-spec/qual
Transform a type specifier or qualifier.
Simpadd0-genassoc-list
Transform a list of generic associations.
Simpadd0-dirabsdeclor
Transform a direct abstract declarator.
Simpadd0-desiniter
Transform an initializer with optional designations.
Simpadd0-designor-list
Transform a list of designators.
Simpadd0-decl-spec-list
Transform a list of declaration specifiers.
Simpadd0-const-expr-option
Transform an optional constant expression.
Simpadd0-align-spec
Transform an alignment specifier.
Simpadd0-absdeclor-option
Transform an optional abstract declarator.
Simpadd0-type-spec
Transform a type specifier.
Simpadd0-tyname
Transform a type name.
Simpadd0-member-designor
Transform a member designator.
Simpadd0-initer-option
Transform an optional initializer.
Simpadd0-initer
Transform an initializer.
Simpadd0-genassoc
Transform a generic association.
Simpadd0-expr-list
Transform a list of expressions.
Simpadd0-enumer-list
Transform a list of enumerators.
Simpadd0-enumer
Transform an enumerator.
Simpadd0-enum-spec
Transform an enumeration specifier.
Simpadd0-designor
Transform a designator.
Simpadd0-declor-option
Transform an optional declarator.
Simpadd0-decl-spec
Transform a declaration specifier.
Simpadd0-decl-list
Transform a list of declarations.
Simpadd0-const-expr
Transform a constant expression.
Simpadd0-block-item-list
Transform a list of block items.
Simpadd0-block-item
Transform a block item.
Simpadd0-absdeclor
Transform an abstract declarator.
Simpadd0-stmt
Transform a statement.
Simpadd0-label
Transform a label.
Simpadd0-expr
Transform an expression.