All Projects → whonore → Coqtail

whonore / Coqtail

Licence: mit
Interactive Coq Proofs in Vim

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Coqtail

Collapsing Towers
Collapsing Towers of Interpreters
Stars: ✭ 61 (-44.04%)
Mutual labels:  coq
Typetheory
The mathematical study of type theories, in univalent foundations
Stars: ✭ 86 (-21.1%)
Mutual labels:  coq
Coq Pipes
Stars: ✭ 101 (-7.34%)
Mutual labels:  coq
Scallina
A Coq-based synthesis of Scala programs which are correct-by-construction
Stars: ✭ 65 (-40.37%)
Mutual labels:  coq
Ch2o
Stars: ✭ 75 (-31.19%)
Mutual labels:  coq
Fourcolor
Formal proof of the Four Color Theorem
Stars: ✭ 87 (-20.18%)
Mutual labels:  coq
Perennial
Verifying concurrent crash-safe systems
Stars: ✭ 57 (-47.71%)
Mutual labels:  coq
Ceramist
Verified hash-based AMQ structures in Coq
Stars: ✭ 107 (-1.83%)
Mutual labels:  coq
Disel
Distributed Separation Logic: a framework for compositional verification of distributed protocols and their implementations in Coq
Stars: ✭ 85 (-22.02%)
Mutual labels:  coq
Peacoq
PeaCoq is a pretty Coq, isn't it?
Stars: ✭ 99 (-9.17%)
Mutual labels:  coq
Sfja
SoftwareFoundations(Ja)
Stars: ✭ 65 (-40.37%)
Mutual labels:  coq
Formal Type Theory
Formalising Type Theory in a modular way for translations between type theories
Stars: ✭ 74 (-32.11%)
Mutual labels:  coq
Coq Serapi
Coq Protocol Playground with Se(xp)rialization of Internal Structures.
Stars: ✭ 87 (-20.18%)
Mutual labels:  coq
Riscv Coq
RISC-V Specification in Coq
Stars: ✭ 63 (-42.2%)
Mutual labels:  coq
Coq Ext Lib
A library of Coq definitions, theorems, and tactics. [[email protected],@liyishuai]
Stars: ✭ 102 (-6.42%)
Mutual labels:  coq
Scala Escape
A compiler plug-in to control object lifetimes in Scala
Stars: ✭ 60 (-44.95%)
Mutual labels:  coq
Vscoq
Coq Support for Visual Studio Code
Stars: ✭ 85 (-22.02%)
Mutual labels:  coq
Ergo
The Language for Smart Legal Contracts
Stars: ✭ 108 (-0.92%)
Mutual labels:  coq
Mindless Coding
Mindless, verified (erasably) coding using dependent types
Stars: ✭ 104 (-4.59%)
Mutual labels:  coq
Ttlite
A SuperCompiler for Martin-Löf's Type Theory
Stars: ✭ 94 (-13.76%)
Mutual labels:  coq

Coqtail

Code style: black Build Status

Interactive Coq Proofs in Vim

Coqtail enables interactive Coq proof development in Vim similar to CoqIDE or ProofGeneral.

It supports:

  • Coq 8.4 - 8.13
  • Python 21 and 3
  • Vim >=7.4 and Neovim >=0.3
  • Simultaneous Coq sessions in different buffers
  • Non-blocking communication between Vim and Coq (Vim >=8.0 and NeoVim only)

Installation and Requirements

As a vim package:

mkdir -p ~/.vim/pack/coq/start
git clone https://github.com/whonore/Coqtail.git ~/.vim/pack/coq/start/Coqtail
vim +helptags\ ~/.vim/pack/coq/start/Coqtail/doc +q

Using pathogen:

git clone https://github.com/whonore/Coqtail.git ~/.vim/bundle/Coqtail
vim +Helptags +q

Using Vundle:

Plugin 'whonore/Coqtail' (add this line in .vimrc)
vim +PluginInstall +qa

Using VimPlug:

Plug 'whonore/Coqtail' (add this line in .vimrc)
vim +PlugInstall +qa

Requirements:

  • Vim compiled with either +python1 or +python3
  • Vim configuration options filetype plugin on, and optionally filetype indent on and syntax on (e.g. in .vimrc)
  • Coq 8.4 - 8.13

Newer versions of Coq have not yet been tested, but should still work as long as there are no major changes made to the XML protocol Coqtail uses to communicate with coqtop.

Usage

Coqtail provides the following commands (see :help coqtail for more details):

Command Mapping Description
Starting and Stopping
CoqStart <leader>cc Launch Coqtail in the current buffer.
CoqStop <leader>cq Quit Coqtail in the current buffer.
CoqInterrupt CTRL-C Send SIGINT to coqtop.
Movement
{n}CoqNext <leader>cj Send the next n (1 by default) sentences to Coq.
{n}CoqUndo <leader>ck Step back n (1 by default) sentences.
{n}CoqToLine <leader>cl Send/rewind all sentences up to line n (cursor position by default). n can also be $ to check the entire buffer.
CoqToTop <leader>cT Rewind to the beginning of the file.
CoqJumpToEnd <leader>cG Move the cursor to the end of the checked region.
CoqGotoDef[!] <arg> <leader>cg Populate the quickfix list with possible locations of the definition of <arg> and try to jump to the first one. If your Vim supports 'tagfunc' you can also use CTRL-], :tag, and friends.
Queries
Coq <args> Send arbitrary queries to Coq (e.g. Check, About, Print, etc.).
Coq Check <arg> <leader>ch Show the type of <arg> (the mapping will use the term under the cursor or the highlighted range in visual mode).
Coq About <arg> <leader>ca Show information about <arg>.
Coq Print <arg> <leader>cp Show the definition of <arg>.
Coq Locate <arg> <leader>cf Show where <arg> is defined.
Coq Search <args> <leader>cs Show theorems about <args>.
Panel Management
CoqRestorePanels <leader>cr Re-open the Goal and Info panels.
{n}CoqGotoGoal <leader>cgg Scroll the Goal panel to the start of the nth goal (defaults to 1). Number of lines shown is controlled by g:coqtail_goal_lines.
{n}CoqGotoGoal! <leader>cGG Scroll the Goal panel to the end of the nth goal.
CoqGotoGoalNext g] Scroll the Goal panel to the start of the next goal.
CoqGotoGoalNext! G] Scroll the Goal panel to the end of the next goal.
CoqGotoGoalPrev g[ Scroll the Goal panel to the start of the previous goal.
CoqGotoGoalPrev! G[ Scroll the Goal panel to the end of the previous goal.

Configuration

Mappings

The mappings above are set by default, but you can disable them all and define your own by setting g:coqtail_nomap = 1 in your .vimrc. Some of the commands, such as CoqNext, also have insert-mode mappings by default, which can be disabled with g:coqtail_noimap. Alternatively, you can keep the defaults but remap specific commands. For example, use map <leader>ci <Plug>CoqInterrupt to avoid hijacking CTRL-C. The <leader>c prefix may be inconvenient depending on your mapleader setting. In that case you can set a custom prefix with g:coqtail_map_prefix (or g:coqtail_imap_prefix for just insert-mode mappings).

Coq Executable

By default Coqtail uses the first coq(ide)top(.opt) found in your PATH. Use b:coqtail_coq_path (or g:coqtail_coq_path) to specify a different directory to search in. You can also override the name of the Coq executable to use with b:coqtail_coq_prog (or g:coqtail_coq_prog). For example, to use the HoTT library:

let b:coqtail_coq_path = '/path/to/HoTT'
let b:coqtail_coq_prog = 'hoqidetop'

_CoqProject

Coqtail understands and will search for _CoqProject files on :CoqStart. Additional or different project files can be specified with g:coqtail_project_files. For example, to include arguments from both _CoqProject and _CoqProject.local:

let g:coqtail_project_files = ['_CoqProject', '_CoqProject.local']

Syntax Highlighting and Indentation

Coqtail also comes with an ftdetect script for Coq, as well as modified versions of Vincent Aravantinos' syntax and indent scripts for Coq. These scripts are used by default but can be disabled by setting g:coqtail_nosyntax = 1 and g:coqtail_noindent = 1 respectively. Formatting of comments can be disabled with g:coqtail_noindent_comment.

In addition to the Coq syntax, Coqtail defines highlighting groups for the sentences that are currently or have already been checked by Coq (CoqtailSent and CoqtailChecked) as well as any lines that raised an error (CoqtailError). By default these are defined as:

if &t_Co > 16
  hi def CoqtailChecked ctermbg=17 guibg=LightGreen
  hi def CoqtailSent    ctermbg=60 guibg=LimeGreen
else
  hi def CoqtailChecked ctermbg=4 guibg=LightGreen
  hi def CoqtailSent    ctermbg=7 guibg=LimeGreen
endif
hi def link CoqtailError Error

To override these defaults simply set your own highlighting (:help :hi) before syntax/coq.vim is sourced (e.g., in your .vimrc). Note, however, that many colorschemes call syntax clear, which clears user-defined highlighting, so it is recommended to place your settings in a ColorScheme autocommand. For example:

augroup CoqtailHighlights
  autocmd!
  autocmd ColorScheme *
    \  hi def CoqtailChecked ctermbg=236
    \| hi def CoqtailSent    ctermbg=237
augroup END

Proof Diffs

Since 8.9, Coq can generate proof diffs to highlight the differences in the proof context between successive steps. To enable proof diffs manually, use :Coq Set Diffs "on" or :Coq Set Diffs "removed". To automatically enable proof diffs on every :CoqStart, set g:coqtail_auto_set_proof_diffs = 'on' (or = 'removed'). By default, Coqtail highlights these diffs as follows:

hi def link CoqtailDiffAdded DiffText
hi def link CoqtailDiffAddedBg DiffChange
hi def link CoqtailDiffRemoved DiffDelete
hi def link CoqtailDiffRemovedBg DiffDelete

See the above instructions on how to override these defaults.

More Options

See :help coqtail-configuration for a description of all the configuration options.

Vim Plugin Interoperability

Jumping between matches

Coqtail defines b:match_words patterns to support jumping between matched text with % using the matchup or matchit plugins.

Automatically closing blocks

Coqtail defines patterns to enable automatic insertion of the appropriate End command for code blocks such as Sections, Modules, and match expressions with endwise.

Thanks

Parts of Coqtail were originally inspired by/adapted from Coquille (MIT License, Copyright (c) 2013, Thomas Refis).


Python 2 Support

Because Python 2 has reached its end-of-life and supporting it alongside Python 3 makes it difficult to improve and maintain the code, Coqtail will drop support for Python 2 in the near future. At that time a stable version will be tagged and all future versions will be Python 3-only. See YouCompleteMe for help building Vim with Python 3 support.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].