doc: Update all examples to 0.2.23
This commit is contained in:
parent
4c559294d3
commit
04e40b6dfa
|
@ -53,7 +53,7 @@
|
|||
"project_path = Path(os.getcwd()).parent.resolve() / 'examples/Example'\n",
|
||||
"print(f\"$PWD: {project_path}\")\n",
|
||||
"server = Server(imports=['Example'], project_path=project_path)\n",
|
||||
"units, invocations = server.tactic_invocations(project_path / \"Example.lean\")"
|
||||
"units = server.tactic_invocations(project_path / \"Example.lean\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -61,7 +61,7 @@
|
|||
"id": "c3c1be91-27a5-4481-b09d-a32dbb94b058",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The function returns a tuple `([str], [TacticInvocation])`. The former element is a list of strings containing each compilation unit, comment data included."
|
||||
"The function returns a list of `CompilationUnit` objects, corresponding to each compilation unit in the input Lean file. For performance reasons only the text boundaries are loaded into `CompilationUnit`s."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -74,13 +74,13 @@
|
|||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"==== #0 ====\n",
|
||||
"#0: [14,85]\n",
|
||||
"/-- Ensure that Aesop is running -/\n",
|
||||
"example : α → α :=\n",
|
||||
" by aesop\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"==== #1 ====\n",
|
||||
"#1: [85,254]\n",
|
||||
"example : ∀ (p q: Prop), p ∨ q → q ∨ p := by\n",
|
||||
" intro p q h\n",
|
||||
" -- Here are some comments\n",
|
||||
|
@ -94,9 +94,12 @@
|
|||
}
|
||||
],
|
||||
"source": [
|
||||
"for i, u in enumerate(units):\n",
|
||||
" print(f\"==== #{i} ====\")\n",
|
||||
" print(u)"
|
||||
"with open(project_path / \"Example.lean\", 'rb') as f:\n",
|
||||
" content = f.read()\n",
|
||||
" for i, unit in enumerate(units):\n",
|
||||
" print(f\"#{i}: [{unit.i_begin},{unit.i_end}]\")\n",
|
||||
" unit_text = content[unit.i_begin:unit.i_end].decode('utf-8')\n",
|
||||
" print(unit_text)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -104,7 +107,7 @@
|
|||
"id": "52e650fc-4a87-445f-8aa8-707ed9e36c03",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The latter is a list of `TacticInvocation`, which contains the `.before` (corresponding to the state before the tactic), `.after` (corresponding to the state after the tactic), and `.tactic` (tactic executed) fields. "
|
||||
"Each `CompilationUnit` includes a list of `TacticInvocation`s, which contains the `.before` (corresponding to the state before the tactic), `.after` (corresponding to the state after the tactic), and `.tactic` (tactic executed) fields. "
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -122,13 +125,33 @@
|
|||
"⊢ α → α\n",
|
||||
"[Tactic]\n",
|
||||
"aesop (using [])\n",
|
||||
"[Afte]\n",
|
||||
"\n",
|
||||
"[After]\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for i in units[0].invocations:\n",
|
||||
" print(f\"[Before]\\n{i.before}\")\n",
|
||||
" print(f\"[Tactic]\\n{i.tactic} (using {i.used_constants})\")\n",
|
||||
" print(f\"[After]\\n{i.after}\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "51f5398b-5416-4dc1-81cd-6d2514758232",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[Before]\n",
|
||||
"⊢ ∀ (p q : Prop), p ∨ q → q ∨ p\n",
|
||||
"[Tactic]\n",
|
||||
"intro p q h (using [])\n",
|
||||
"[Afte]\n",
|
||||
"[After]\n",
|
||||
"p q : Prop\n",
|
||||
"h : p ∨ q\n",
|
||||
"⊢ q ∨ p\n",
|
||||
|
@ -138,7 +161,7 @@
|
|||
"⊢ q ∨ p\n",
|
||||
"[Tactic]\n",
|
||||
"cases h (using ['Eq.refl', 'Or'])\n",
|
||||
"[Afte]\n",
|
||||
"[After]\n",
|
||||
"case inl\n",
|
||||
"p q : Prop\n",
|
||||
"h✝ : p\n",
|
||||
|
@ -151,7 +174,7 @@
|
|||
"⊢ q ∨ p\n",
|
||||
"[Tactic]\n",
|
||||
"apply Or.inr (using ['Or.inr'])\n",
|
||||
"[Afte]\n",
|
||||
"[After]\n",
|
||||
"case inl.h\n",
|
||||
"p q : Prop\n",
|
||||
"h✝ : p\n",
|
||||
|
@ -163,7 +186,7 @@
|
|||
"⊢ p\n",
|
||||
"[Tactic]\n",
|
||||
"assumption (using [])\n",
|
||||
"[Afte]\n",
|
||||
"[After]\n",
|
||||
"\n",
|
||||
"[Before]\n",
|
||||
"case inr\n",
|
||||
|
@ -172,7 +195,7 @@
|
|||
"⊢ q ∨ p\n",
|
||||
"[Tactic]\n",
|
||||
"apply Or.inl (using ['Or.inl'])\n",
|
||||
"[Afte]\n",
|
||||
"[After]\n",
|
||||
"case inr.h\n",
|
||||
"p q : Prop\n",
|
||||
"h✝ : q\n",
|
||||
|
@ -184,25 +207,17 @@
|
|||
"⊢ q\n",
|
||||
"[Tactic]\n",
|
||||
"assumption (using [])\n",
|
||||
"[Afte]\n",
|
||||
"[After]\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for i in invocations:\n",
|
||||
"for i in units[1].invocations:\n",
|
||||
" print(f\"[Before]\\n{i.before}\")\n",
|
||||
" print(f\"[Tactic]\\n{i.tactic} (using {i.used_constants})\")\n",
|
||||
" print(f\"[Afte]\\n{i.after}\")"
|
||||
" print(f\"[After]\\n{i.after}\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "51f5398b-5416-4dc1-81cd-6d2514758232",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
@ -221,7 +236,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.6"
|
||||
"version": "3.12.7"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from pantograph.server import Server
|
||||
|
||||
def get_project_and_lean_path():
|
||||
cwd = Path(__file__).parent.resolve() / 'Example'
|
||||
p = subprocess.check_output(['lake', 'env', 'printenv', 'LEAN_PATH'], cwd=cwd)
|
||||
return cwd, p
|
||||
|
||||
if __name__ == '__main__':
|
||||
project_path, lean_path = get_project_and_lean_path()
|
||||
print(f"$PWD: {project_path}")
|
||||
print(f"$LEAN_PATH: {lean_path}")
|
||||
server = Server(imports=['Example'], project_path=project_path, lean_path=lean_path)
|
||||
units, invocations = server.tactic_invocations(project_path / "Example.lean")
|
||||
for i, u in enumerate(units):
|
||||
print(f"==== #{i} ====")
|
||||
print(u)
|
||||
print("==== Invocations ====")
|
||||
for i in invocations:
|
||||
print(f"{i.before}\n{i.tactic}\n{i.after}\n")
|
|
@ -32,5 +32,5 @@ theorem add_comm_proved_formal_sketch : ∀ n m : Nat, n + m = m + n := by
|
|||
|
||||
if __name__ == '__main__':
|
||||
server = Server()
|
||||
state0, = server.load_sorry(sketch)
|
||||
print(state0)
|
||||
unit, = server.load_sorry(sketch)
|
||||
print(unit.goal_state)
|
||||
|
|
|
@ -25,8 +25,10 @@ class TacticInvocation:
|
|||
@dataclass(frozen=True)
|
||||
class CompilationUnit:
|
||||
|
||||
# Byte boundaries [begin, end[ of each compilation unit.
|
||||
i_begin: int
|
||||
i_end: int
|
||||
|
||||
messages: list[str] = field(default_factory=list)
|
||||
|
||||
invocations: Optional[list[TacticInvocation]] = None
|
||||
|
|
Loading…
Reference in New Issue