package lambdapi
Proof assistant for the λΠ-calculus modulo rewriting
Install
dune-project
Dependency
Authors
Maintainers
Sources
lambdapi-3.0.0.tbz
sha256=1066aed2618fd8e6a400c5147dbf55ea977ce8d3fe2e518ac6785c6775a1b8be
sha512=f7f499626aba92e070ae69581299a58525973fdbfd04a160ed3ac89209fb6cbe307b816d0b23e1b75bc83467ce8b4b0530c6f9816eaf58f7a07fde65a450106c
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
(** Proofs and tactics. *) open Lplib open Base open Extra open Timed open Core open Term open Print open Common open Pos (** Type of goals. *) type goal_typ = { goal_meta : meta (** Goal metavariable. *) ; goal_hyps : Env.t (** Precomputed scoping environment. *) ; goal_type : term (** Precomputed type. *) } type goal = | Typ of goal_typ (** Typing goal. *) | Unif of constr (** Unification goal. *) let is_typ : goal -> bool = function Typ _ -> true | Unif _ -> false let is_unif : goal -> bool = function Typ _ -> false | Unif _ -> true let get_constr : goal -> constr = function Unif c -> c | Typ _ -> invalid_arg (__FILE__ ^ "get_constr") let get_names : goal -> int StrMap.t = function | Unif(c,_,_) -> Ctxt.names c | Typ gt -> Env.names gt.goal_hyps module Goal = struct type t = goal (** [ctxt g] returns the typing context of the goal [g]. *) let ctxt : goal -> ctxt = fun g -> match g with | Typ gt -> Env.to_ctxt gt.goal_hyps | Unif (c,_,_) -> c (** [env g] returns the scoping environment of the goal [g]. *) let env : goal -> Env.t = fun g -> match g with | Unif (c,_,_) -> let t, n = Ctxt.to_prod c mk_Type in (try fst (Env.of_prod_nth c n t) with Invalid_argument _ -> assert false) | Typ gt -> gt.goal_hyps (** [of_meta m] creates a goal from the meta [m]. *) let of_meta : meta -> goal = fun m -> let goal_hyps, goal_type = try Env.of_prod_nth [] m.meta_arity !(m.meta_type) with Invalid_argument _ -> assert false in Typ {goal_meta = m; goal_hyps; goal_type} (** [simpl f g] simplifies the goal [g] with the function [f]. *) let simpl : (ctxt -> term -> term) -> goal -> goal = fun f g -> match g with | Typ gt -> Typ {gt with goal_type = f (Env.to_ctxt gt.goal_hyps) gt.goal_type} | Unif (c,t,u) -> Unif (c, f c t, f c u) (** [hyps ppf g] prints on [ppf] the hypotheses of the goal [g]. *) let hyps : int StrMap.t -> goal pp = let hyps elt ppf l = if l <> [] then out ppf "%a---------------------------------------------\ ---------------------------------\n" (List.pp (fun ppf -> out ppf "%a\n" elt) "") (List.rev l); in fun idmap ppf g -> let term = term_in idmap in match g with | Typ gt -> let elt ppf (s,(_,t,u)) = match u with | None -> out ppf "%a: %a" uid s term t | Some u -> out ppf "%a ≔ %a" uid s term u in hyps elt ppf gt.goal_hyps | Unif (c,_,_) -> let elt ppf (x,a,t) = out ppf "%a: %a" var x term a; match t with | None -> () | Some t -> out ppf " ≔ %a" term t in hyps elt ppf c let pp_aux : int StrMap.t -> goal pp = fun idmap ppf g -> let term = term_in idmap in match g with | Typ gt -> out ppf "%a: %a" meta gt.goal_meta term gt.goal_type | Unif (_, t, u) -> out ppf "%a ≡ %a" term t term u (** [pp ppf g] prints on [ppf] the goal [g] with its hypotheses. *) let pp ppf g = let idmap = get_names g in hyps idmap ppf g; pp_aux idmap ppf g (** [pp_aux ppf g] prints on [ppf] the goal [g] without its hypotheses. *) let pp_no_hyp ppf g = let idmap = get_names g in pp_aux idmap ppf g end (** [add_goals_of_problem p gs] extends the list of goals [gs] with the metavariables and constraints of [p]. *) let add_goals_of_problem : problem -> goal list -> goal list = fun p gs -> let gs = MetaSet.fold (fun m gs -> Goal.of_meta m :: gs) !p.metas gs in let f gs c = Unif c :: gs in let gs = List.fold_left f gs !p.to_solve in List.fold_left f gs !p.unsolved (** 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 = get_names g in out ppf "%a0. %a@." (Goal.hyps idmap) g (Goal.pp_aux idmap) g; let goal ppf i g = out ppf "%d. %a@." (i+1) Goal.pp_no_hyp g in List.iteri (goal ppf) gs (** [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
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>