package lambdapi

All checked builds pass
  1. Overview
  2. Docs
Proof assistant for the λΠ-calculus modulo rewriting

Install

dune-project
 Dependency

Authors

Maintainers

Sources

lambdapi-4.0.0.tbz
sha256=0e2e73e0ea0c674f1263bf85ed3453ed3d6084d38eea29974a03ba9e382d29d7
sha512=2831db57fcd09206687a92fc9ee7d363e87bcec5167949e9c8161d41c63d5887b9f3556bfd63a7a9a0c12e5a5dc61a397baf4f496ebdb2a2fce122142c05e7a1

doc/src/lambdapi.handle/proof.ml.html

Source file proof.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
(** Proof state. *)

open Lplib open Base
open Timed
open Core open Term
open Common open Pos
open Goal

(** Representation of the proof state of a theorem. *)
type proof_state =
  { proof_name  : strloc (** Name of the theorem. *)
  ; proof_term  : meta option
  (** Optional metavariable holding the goal associated to a symbol used as a
     theorem/definition and not just a simple declaration *)
  ; proof_goals : goal list (** Open goals (focused goal is first). *) }

(** [finished ps] tells whether there are unsolved goals in [ps]. *)
let finished : proof_state -> bool = fun ps -> ps.proof_goals = []

(** [goals ppf gl] prints the goal list [gl] to channel [ppf]. *)
let goals : proof_state pp = fun ppf ps ->
  match ps.proof_goals with
  | [] -> out ppf "No goal."
  | g::gs ->
      let idmap = Goal.get_names g in
      out ppf "%a0. %a" (Goal.hyps idmap) g (Goal.concl idmap) g;
      let goal ppf i g = out ppf "\n%d. %a" (i+1) Goal.pp_no_hyp g in
      List.iteri (goal ppf) gs

(** [state_on_error] controls whether the failure of a tactic attaches the
    current proof state to the error, as the [err_desc] argument of the
    [Fatal] exception, printed after the error message. It is enabled by
    default, and disabled by the LSP server, which has its own means of
    displaying the proof state. Errors that always reported the proof state
    (subproof-count mismatches, unfinished proofs) keep doing so regardless
    of this setting. *)
let state_on_error : bool Stdlib.ref = Stdlib.ref true

(** [error_state ?after ps] renders, for attachment to an error report, the
    proof state [ps] a failing tactic was applied to, followed, when the
    failure was only detected after the tactic was applied (a subproof-count
    mismatch), by the proof state [after] its application. *)
let error_state : ?after:proof_state -> proof_state -> string =
  fun ?after before ->
  match after with
  | None ->
      Format.asprintf "Proof state before tactic application:@.%a@."
        goals before
  | Some after ->
      Format.asprintf
        "Proof state before tactic application:@.%a@.\
         Proof state after tactic application:@.%a@."
        goals before goals after

(** [remove_solved_goals ps] removes from the proof state [ps] the typing
   goals that are solved. *)
let remove_solved_goals : proof_state -> proof_state = fun ps ->
  let f = function
    | Typ gt -> !(gt.goal_meta.meta_value) = None
    | Unif _ -> true
  in {ps with proof_goals = List.filter f ps.proof_goals}

(** [meta_of_key ps i] returns [Some m] where [m] is a meta of [ps] whose key
   is [i], or else it returns [None]. *)
let meta_of_key : proof_state -> int -> meta option = fun ps key ->
  let f = function
    | Typ {goal_meta=m;_} when m.meta_key = key -> Some m
    | _ -> None
  in
  List.find_map f ps.proof_goals

(** [focus_env ps] returns the scoping environment of the focused goal or the
   empty environment if there is none. *)
let focus_env : proof_state option -> Env.t = fun ps ->
  match ps with
  | None -> Env.empty
  | Some(ps) ->
      match ps.proof_goals with
      | [] -> Env.empty
      | g::_ -> Goal.env g