Skip to main content
v2026.11,986 entries · CC-BY 4.0

Separation Logic: Using Infer, VeriFast and Viper

What separation logic is, how to run Infer on a small file and read its report, and how VeriFast and Viper apply the same ideas.

Written and maintained by CASRAI Editorial Board

Published

On this page

Separation logic is a program logic for reasoning about code that changes computer memory through pointers. It extends Hoare-style reasoning with a separating conjunction, written *, that says two assertions hold about disjoint parts of memory, so a proof about one part of the heap stays valid when the rest of the heap is untouched. Researchers meet it mostly through verification tools such as Infer, VeriFast and Viper, and this guide shows what it is for, how to run Infer on a small file, and how to read what the tool reports.

What separation logic is used for in research

The Infer documentation describes separation logic as a logic for reasoning about mutations to computer memory. Ordinary program logics struggle when two pointers might refer to the same cell, because a write through one pointer can silently change what the other one sees. Separation logic addresses this by letting an assertion say which part of memory it talks about and, with *, that two parts do not overlap.

The separating conjunction

The assertion A * B reads as “A and, separately, B”: A describes one portion of the heap and B describes a different portion. The Infer documentation gives the example x |-> y * y |-> x, which says that x points to a cell containing y and, separately, that y points to a cell containing x. Because the two cells are described as separate, they are at different addresses, so the two pointers cannot be aliases for the same cell.

The frame rule and local reasoning

The same documentation calls the frame rule the key to the principle of local reasoning. In practice this means a specification for a procedure only has to mention the memory the procedure actually uses. Whatever the procedure does not touch, called the frame, can be carried along unchanged, so each procedure can be analysed or verified on its own and its result reused wherever it is called. This is the property that lets analysers built on separation logic handle each procedure separately instead of re-analysing a whole program at once.

Separation logic belongs to the family of program-verification techniques covered in the CASRAI guides to formal methods and formal verification. For the broader study of formal languages and the structures that satisfy them, see the guide to model theory. Within research tooling more broadly, the research tools hub lists the other software guides in this cluster.

Three tools, three ways to use it

Three actively documented projects put separation logic into practice. Infer is a static analyser that infers specifications automatically; VeriFast verifies programs against specifications written by the user; Viper is an infrastructure for permission-based reasoning on which other language verifiers are built. The data table at the end of this guide compares them side by side, and the sections below take Infer through installation and a first run because its documentation gives complete commands for both.

How to install or access Infer

Infer is distributed by its authors as a binary release, as source code and as Docker images. The Infer getting-started page lists these routes; the notes below follow it.

  1. Download the latest release from the binary release page on GitHub (github.com/facebook/infer/releases/latest) and extract it anywhere on your system.
  2. The documentation’s Linux example extracts the archive to /opt and then links the bin/infer executable from the extracted folder into /usr/local/bin/infer, using the release version number in the archive name infer-linux-x86_64-vVERSION.tar.xz.
  3. If the binaries do not work on your system, follow the “install from source” instructions in the INSTALL.md file of the Infer repository.
  4. Docker images are described in the docker directory of the repository.
  5. The getting-started page also links a Codeboard project where a small example can be tried in a browser without installing anything.

The documentation does not give a command for checking the installed version, so use infer --help to confirm that the executable runs; the Infer workflow page recommends the --help output for each subcommand.

How to run Infer step by step

Infer works in two phases. In the capture phase it hooks into your compilation command, so the files are compiled as usual and also translated into Infer’s internal language. In the analysis phase it analyses each function and method separately. If no file is compiled, no file is analysed, which is why the compiler command must be part of the Infer command.

  1. Open a terminal in the folder that contains your source file. Infer creates an infer-out/ directory in the folder where you start it; the -o option changes that location, as in infer run -o /tmp/out -- javac Test.java.
  2. For a C file, run infer run -- gcc -c hello.c. The Infer hello-world page also gives the equivalent for Java, infer run -- javac Hello.java, and for Clang.
  3. Read the report printed to standard output. The same errors are written to infer-out/report.txt.
  4. Fix the reported problems and run the same command again. The workflow page suggests exactly this loop: run Infer, fix the errors, and run again to see whether more appear.
  5. To see the trace behind each reported bug, run infer explore in the same directory.

infer run performs both phases. The workflow page states that infer run -- javac Hello.java is equivalent to infer capture -- javac Hello.java followed by infer analyze. Running infer analyze alone does not erase infer-out/, because it needs the captured files that are already there.

Global and differential runs

By default Infer runs globally: starting it deletes the previous infer-out/ and analyses the whole project. For a clean run, call the build tool’s clean command first, such as make clean or gradle clean, then run for example infer run -- gradle build. For repeated runs on a changing project, the differential workflow keeps infer-out/ so that only changed files and their dependencies are re-analysed: capture once on a clean project with infer capture -- gradle build, then run infer run --reactive -- gradle build after each change. The --continue option combines several changes into one analysis.

How to read the output

A report line names a file, a line number, a bug type and a short explanation. The hello-world page shows this for the C example: hello.c:5: error: NULL_DEREFERENCE pointer s last assigned on line 4 could be null and is dereferenced at line 5, column 10. The Java example gives a similar NULL_DEREFERENCE message. Read it from left to right: the error is reported at line 5 of hello.c; the bug type is a null dereference; the pointer s was last assigned at line 4, where it may have received a null value; and the dereference happens at line 5, column 10.

Connecting a report to separation logic

The Infer documentation on separation logic and bi-abduction explains why this report is possible without a hand-written specification. Infer analyses each procedure on its own. For a procedure it infers two pieces of heap description: the antiframe, which is the memory state the procedure needs in order to run safely, and the frame, which is the part of memory the procedure leaves untouched. This inference step is called bi-abduction. When the analysis finds a path on which the needed state cannot be guaranteed, such as a pointer that might be null when it is dereferenced, it reports a potential bug. Because each procedure is analysed separately and its result can be reused at every call site, the technique scales to large code bases, according to the same documentation.

Two cautions follow from that description. A report is a potential bug, so it should be checked against the program, and Infer’s workflow page says it filters its findings to show those most likely to be real. And an empty report is not a proof that the program is correct: Infer is an analyser that looks for classes of defects, whereas verifiers such as VeriFast check a program against a specification the author supplies.

Troubleshooting Infer

The Infer workflow and getting-started pages give a short list of causes for the most common surprises.

  • Nothing is analysed. Infer only analyses files that are compiled while it is watching the build, so the compiler or build command must follow the double dash. If the build system sees nothing to rebuild, nothing is captured: run the build tool’s clean command first.
  • Old results appear or results look stale. Either clean the project between runs or add --reactive in the differential workflow described above, after capturing once on a clean project.
  • The prebuilt binary does not run. Build Infer from source following INSTALL.md, or use one of the Docker images from the repository’s docker directory.
  • You want the trace behind a message. Run infer explore in the directory that holds infer-out/.
  • You need an option the page does not explain. Run infer --help or infer SUBCOMMAND --help; the documentation points there for the full option list.
  • One method fails to analyse. When Infer hits an error in a method, it stops analysing that method and continues with the others, so a single problem does not abandon the run.

Free alternatives to Infer

If you need specification-driven proofs rather than automatic bug-finding, or you work in a language other than the ones used in the Infer examples, two other separation-logic-based projects are documented openly. The data table below summarises all three tools; this section covers what each of the other two does and how to obtain it.

VeriFast

VeriFast is described on its GitHub page as a research prototype tool for modular formal verification of single-threaded and multithreaded C, Rust and Java programs, checked against specifications written in separation logic. It is published under the MIT licence. Nightly binaries are available from the repository’s releases (github.com/verifast/verifast/releases/tag/nightly); extract the archive anywhere. The command-line verifier is bin/verifast and the graphical environment is bin/vfide.

Viper

Viper, from the Programming Methodology Group at ETH Zurich, stands for Verification Infrastructure for Permission-based Reasoning. It expresses ownership of memory as permissions in a style related to separation logic. It provides two verifiers: Carbon, which generates verification conditions for Boogie, and Silicon, which uses symbolic execution with the Z3 solver. Other verifiers are built on top of it: Gobra for Go, Nagini for Python and Prusti for Rust. The Viper project page recommends its VS Code extension for working with the language.

Choosing between them

The three tools answer different questions. Use Infer when you have existing C or Java code and want defect reports without writing specifications. Use VeriFast when you want to prove properties of C, Rust or Java code against specifications you write yourself. Use Viper, or one of the language front ends built on it, when your code is in Go, Python or Rust or when you are building your own verifier on a permission-based intermediate language. This summary follows the languages and approaches stated on each project’s own page; it does not rank the tools.

Sources

Data: Separation-logic verification tools compared: Infer, VeriFast and Viper

Compares three openly documented separation-logic-based tools by the languages named on their own project pages, how they use separation logic and how they are obtained. Compiled from the Infer documentation, the VeriFast repository page and the Viper project page at ETH Zurich, read 2026-11-17.

Separation-logic verification tools compared: Infer, VeriFast and Viper
ToolLanguages named on the project pageApproachHow it is obtained
InferC and Java (examples in the official hello-world page)Static analysis; infers specifications by bi-abduction, procedure by procedureBinary release from GitHub, build from source, or Docker images
VeriFastC, Rust, Java (single-threaded and multithreaded)Modular verification against separation-logic specifications written by the userNightly binaries and releases on GitHub; MIT licence
ViperIntermediate language; front ends Gobra (Go), Nagini (Python), Prusti (Rust)Permission-based reasoning with verifiers Carbon (Boogie) and Silicon (symbolic execution, Z3)Project page at ETH Zurich; VS Code extension recommended

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Separation Logic: Using Infer, VeriFast and Viper

2 free questions a day, no account.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →