As of May 31, 2023, we have updated our Code of Conduct.

# Tag Info

### Example of an algorithm that lacks a proof of correctness

Here is an algorithm for the identity function: Input: $n$ Check if the $n$th binary string encodes a proof of $0 > 1$ in ZFC, and if so, output $n+1$ Otherwise, output $n$ Most people suspect ...
Accepted

### Difference between Dependent type , refinement type and Hoare Logic

There is recent work by Paul-André Melliès and Noam Zeilberger that explores this. In particular the papers Functors are Type Refinement Systems and An Isbell Duality Theorem for Type Refinement ...
Accepted

### What was the major breakthrough between Hoare-Floyd logic and Scott–Strachey semantics?

I don't know why people didn't develop Hoare logics for lambda-calculi earlier. The first work to get this right was Honda et al's A Compositional Program Logic for Polymorphic Higher-Order Functions ...

### Example of an algorithm that lacks a proof of correctness

Most algorithms have not been proven correct in Hoare logic. The main reason is that such correctness proofs are extremely expensive as of Jan 2017, probably by several orders of magnitude in ...

### What is a predicate transformer?

The predicate transformer is just a formalization of the idea that you can produce a precondition given a program and its postcondition. For example, given a program ...
Accepted

### Relation between Hoare Type Theory and pointers

A pointer to a variable creates an alias. When the alias is modified, the corresponding variable is modified as well. Therefore, the rule for an assignment in Hoare's logic is not just update the ...
Accepted

### What does it mean to "strengthen the precondition and weaken the postcondition" in Hoare logic?

Condition $A$ is stronger than condition $B$ if $A$ implies $B$. That is, if $B$ holds in all situations in which $A$ holds. Conversely, if $A$ is stronger than $B$, ...

### Intuitive explanation of Hoare assignment axiom

Hoare Logic proceeds backwards. It is a method to compute a precondition such that the desired postcondition holds. In fact, the inference rules given in your standard Hoare Logic deductions compute ...

### Example of an algorithm that lacks a proof of correctness

Problem: Print "Yes" if every even number ≥ 4 is the sum of two primes, and "No" if there is an even number ≥ 4 that is not the sum of two primes. Algorithm: Print "Yes" Most people think that the ...

Accepted

### Check whether loop invariants are correct?

Rather than telling you whether your specific invariants are correct, let me teach you the procedure for how you can check whether your invariants are correct on your own. Basically, you break it ...
Accepted

### Why precondition strengtening is sound in Hoare logic

The triple $\{Q\}C\{X\}$ states that if $Q$ holds, then after executing $C$, the condition $X$ holds. Now suppose that $\{Q\}C\{X\}$ and that $P \Longrightarrow Q$. We will prove that $\{P\}C\{X\}$. ...

### Example of an algorithm that lacks a proof of correctness

Any algorithm that is correct but we don't know how long it takes to run can be transformed into an algorithm that stops in a guaranteed amount of time but we aren't sure if it is correct. For ...
Accepted

### Developing invariants for comparing two strings

I would not simplify $(2)$ at all. Just apply the rules for if, =, and command composition. Use weakening (pre- or post- rules) ...
Accepted

### Hoare-Logic: Requirements for imperfect data types

No, when using Hoare logic properly, you make sure to account for integer overflow etc. and model the full semantics of the programming language. It is possible to use Hoare logic along the lines you ...
Accepted

### Understanding Hoare Logic Axioms

Here are some answers and hints to pursue your reflexions. $\mathtt{Assignment}$ What $\phi([x \leftarrow E])$ means. You said yourself that the semantic of the precondition confuses you that was ...

### The difference between a Hoare Triple/Assertion and a Typed Function

To be frank, it much more difficult to see how types and pre-/post-conditions are similar than how they differ. In Hoare Logic, for the Hoare triple $\{A\}\ f\ \{B\}$, $A$ and $B$ would be predicates ...
Accepted

### How to prove a side effect in a function

If the function has two outputs, a standard way to represent this is as a function $f: A \to (B \times C)$, i.e., $f$ outputs a pair of an AST and a symbol table. If the function updates an existing ...

### How to prove a side effect in a function

It depends on how you model the system and what proof approach you're using. For early versions of Hoare Logic, there isn't really any notion of "scope", so there's absolutely nothing special you need ...