Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7),...

14
Coq on iPad by Keigo IMAI @keigoi Proof Summit 2013 at 多元 503 Nagoya Univ. 24 Aug, 2013

Transcript of Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7),...

Page 1: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

Coq on iPadby Keigo IMAI @keigoi

Proof Summit 2013 at 多元 503 Nagoya Univ.

24 Aug, 2013

Page 2: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

Why Coq on iPad?

• Prove everywhere!

• on a train, in a cafe, or even in your bed!

• Good for poster sessions (maybe)

And because there’s excellent OCamlXARM by psellos.com!(OCaml now runs on iOS!)

Page 3: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

History• Dec 2011:

@mzp put the first Coq-on-iOS implementation public on Githubhttps://github.com/mzp/coq-ide-for-ios/

• Mar 2012:OCamlXARM (and Card game built by this) is published on the web by Psellos.com

• Feb 2013:I started this project! (almost complete rewrite from @mzp’s version)

Page 4: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

Coq for iPad’s main UIconsole output

.vsource editor evaluate / roll back

one step

eval’d lines are colored blue(like coqide)

(opens the file browser)

Page 5: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

The file browser

List of files• Files are saved as you

type in the editor

• Each .v file can’t refer to other files (currently)

create a new .v file

delete a file

Page 6: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

Download / Build

$ git clone --recursive https://github.com/keigoi/coq4ios(will also clone OCamlXARM/XSIM, Coq and lzmaSDK repo)

Prerequisites:Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional),Host OCaml 4.00.1 and Camlp5 6.07

See README.md for details

1. Compile & Install OCamlXSIM (ocamlopt for iOS simulator) and Camlp5

2. Compile Coq *.cma for iOS simulator

3. Compile Coq *.v files

4. Compile Coq4iOS (OCaml-part)

5. Then, open coq4ios.xcodeproj with Xcode, compile & run!

Page 7: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

Idea

• Multiple file support - Compiling .v on iPad

• コンパイルしたファイルをRequire Import できるように

• Save proofs on cloud

• Download proofs from the web

• UI improvements

• SSReflect support

Page 8: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

Issues

• Heavy proof will hang the whole app

Page 9: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

UI idea• Shortcut keys to Coq commands

• ‘move’ symbols by hand

============================ forall P : Prop, P -> P

P : Prop============================ P -> P

tap & move up to premise... or put then back!

Page 10: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

UI Idea: navigate graphically on the proof tree

Pic: Proof tree visualization for Proof General, by Hendrik Tews Available from: http://askra.de/software/prooftree/

Page 11: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

Inside Coq4iOS

OCaml part:

- src/main.ml

Objective-C (Xcode) part:

bunch of ObjC files and OCaml/Coq runtime

binaries

Page 12: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

OCaml part:(* start Coq (same effect as typing ‘coqtop’ in the shell) *)val start : string -> bool

(* try to parse the text and returns the range of the next parsable phrase *)val next_phrase_range : string -> int * int

(* evaluates Coq phrase and returns the console output *)val eval : string -> bool * string

(* Undo for given steps *)val rewind : int -> int

Page 13: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

Initializing sequence Coq4iOSuncompress Coq stdlib .vofrom coq-8.4pl2-standard-libs-for-coq4ios.7z

30 Mbytes (takes a few minutes, first time only)

Call caml_main (in C) which initializes all OCaml modules

Run Coqtop.init_toplevel(in OCaml)

Eval phrase / Undo / ... on Coq

(OCaml part runsin a separate thread)

App store limitation: bundle must be < 50 MB

Page 14: Coq on iPad - ProofCafeproofcafe.org/~keigoi/coq4ipad-proofsumitt2013.pdf · Mac OS X Lion (10.7), latest Xcode (4.6), iPad 2 or later (optional), Host OCaml 4.00.1 and Camlp5 6.07

Summary

• An implementation of Coq on iOS (iPad)

• Several UI ideas

Join us!• Coq for iPad:

https://github.com/keigoi/coq4ios