package electrod
Formal analysis for the Electrod formal pivot language
Install
Dune Dependency
Authors
Maintainers
Sources
electrod-1.0.0.tbz
sha256=4da251e58d97c797d6e940e586d225a09715777fbb1b25c5527a6a2e1e3c2d58
sha512=89c45ebd0d3401b17eac4217289ed21ec87135ab5fa62bf63b2bed1ad1435a381e3434582c2ec99c2e6d8d87ce23cecfa7ba14d76234493992ae06879b808dd2
doc/src/electrod.libelectrod/Ast_to_elo.ml.html
Source file Ast_to_elo.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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
(******************************************************************************* * electrod - a model finder for relational first-order linear temporal logic * * Copyright (C) 2016-2020 ONERA * Authors: Julien Brunel (ONERA), David Chemouil (ONERA) * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * SPDX-License-Identifier: MPL-2.0 * License-Filename: LICENSE.md ******************************************************************************) open Containers (* This module is supposed to happen after a simplification that addresses: let bindings, *multiple* sim_bindings, quantified expressions, no lone/one quantifier; the input is also supposed to be arity-correct *) module E = Elo let convert_arity = function | None -> 0 | Some n when n > 0 -> n | Some _ -> assert false (* The "convert_xxx" functions handle conversion from an AST with globally-unique variable names to a hashconsed-De Bruijn-encoded representation. Essentially, we keep a stack of bounded variables (in the current call context) and, if we meet a variable reference, we return its index in the stack. So a variable equal to 0 represents a variable bound by the last binder met. *) let get_var x stack = match List.find_idx (fun v -> Var.equal x v) stack with | None -> Format.kasprintf failwith "%s.get_var: variable %a not found in %a" __MODULE__ Var.pp x Fmtc.(brackets @@ list ~sep:(sp **> comma) @@ Var.pp) stack | Some (i, _) -> i let new_env vars stack = Msg.debug (fun m -> m "Ast_to_elo.new_env: stacking %a onto %a" Fmt.(brackets @@ list ~sep:comma Ast.pp_var) (List.rev vars) Fmt.(brackets @@ list ~sep:comma Var.pp) stack); List.rev_map (function Ast.BVar v -> v) vars @ stack let rec convert_fml stack ({ prim_fml; _ } : (Ast.var, Ast.ident) Gen_goal.fml) = match prim_fml with | Qual (_, _) -> assert false (* simplified *) | Let (_, _) -> assert false (* simplified *) | Quant (_, _ :: _ :: _, _) -> assert false (* simplified *) | Quant (_, [], _) -> assert false (* impossible *) | Quant (q, [ (disj, vars, range) ], block) -> let range' = convert_exp stack range in let block' = convert_block (new_env vars stack) block in E.quant (convert_quant q) (disj, List.length vars, range') block' | True -> E.true_ | False -> E.false_ | RComp (e1, comp, e2) -> E.rcomp (convert_exp stack e1) (convert_comp_op comp) (convert_exp stack e2) | IComp (e1, comp, e2) -> E.icomp (convert_iexp stack e1) (convert_icomp_op comp) (convert_iexp stack e2) | LUn (op, f) -> E.lunary (convert_lunop op) (convert_fml stack f) | LBin (f1, op, f2) -> E.lbinary (convert_fml stack f1) (convert_lbinop op) (convert_fml stack f2) | FIte (c, t, e) -> E.fite (convert_fml stack c) (convert_fml stack t) (convert_fml stack e) | Block fmls -> E.block @@ convert_block stack fmls and convert_block stack fmls = List.map (convert_fml stack) fmls and convert_quant (q : Gen_goal.quant) = match q with | One | Lone -> assert false (* simplified *) | All -> E.all | Some_ -> E.some | No -> E.no_ and convert_comp_op (comp : Gen_goal.comp_op) = match comp with | In -> E.in_ | NotIn -> E.not_in | REq -> E.req | RNEq -> E.rneq and convert_icomp_op (comp : Gen_goal.icomp_op) = match comp with | IEq -> E.ieq | INEq -> E.ineq | Lt -> E.lt | Lte -> E.lte | Gt -> E.gt | Gte -> E.gte and convert_lunop (op : Gen_goal.lunop) = match op with | F -> E.eventually | G -> E.always | Not -> E.not_ | O -> E.once | X -> E.next | H -> E.historically | P -> E.previous and convert_lbinop (op : Gen_goal.lbinop) = match op with | And -> E.and_ | Or -> E.or_ | Imp -> E.impl | Iff -> E.iff | U -> E.until | R -> E.releases | S -> E.since | T -> E.triggered and convert_exp stack ({ prim_exp; arity; _ } : (Ast.var, Ast.ident) Gen_goal.exp) = let ar = convert_arity arity in match prim_exp with | BoxJoin (_, _) -> assert false (* simplified *) | Compr ([], _) -> assert false (* impossible *) | None_ -> E.none | Univ -> E.univ | Iden -> E.iden | Ident (Var v) -> E.var ~ar @@ get_var v stack | Ident (Name n) -> E.name ~ar n | RUn (op, e) -> E.runary ~ar (convert_runop op) (convert_exp stack e) | RBin (e1, op, e2) -> E.rbinary ~ar (convert_exp stack e1) (convert_rbinop op) (convert_exp stack e2) | RIte (c, t, e) -> E.rite ~ar (convert_fml stack c) (convert_exp stack t) (convert_exp stack e) | Prime e -> E.prime ~ar @@ convert_exp stack e | Compr (decls, block) -> let decls' = convert_sim_bindings stack decls in let vars = List.flat_map (fun (_, vars, _) -> vars) decls in let block' = convert_block (new_env vars stack) block in E.compr ~ar decls' block' |> Fun.tap (fun e -> Msg.debug (fun m -> m "Ast_to_elo.convert_Compr@ @[<hov2>%a@]@ --> @[<hov2>%a@]" Ast.pp_prim_exp prim_exp (E.pp_exp 0) e)) and convert_sim_bindings stack (decls : (Ast.var, Ast.ident) Gen_goal.sim_binding list) = match decls with | [] -> [] | (disj, vars, range) :: tl -> let hd' = (disj, List.length vars, convert_exp stack range) in hd' :: convert_sim_bindings (new_env vars stack) tl and convert_runop (op : Gen_goal.runop) = match op with | Transpose -> E.transpose | TClos -> E.tclos | RTClos -> E.rtclos and convert_rbinop (op : Gen_goal.rbinop) = match op with | Union -> E.union | Inter -> E.inter | Over -> E.over | LProj -> E.lproj | RProj -> E.rproj | Prod -> E.prod | Diff -> E.diff | Join -> E.join and convert_iexp stack ({ prim_iexp; _ } : (Ast.var, Ast.ident) Gen_goal.iexp) = match prim_iexp with | Num n -> E.num n | Card e -> E.card @@ convert_exp stack e | IUn (Neg, e) -> E.iunary E.neg @@ convert_iexp stack e | IBin (e1, op, e2) -> E.ibinary (convert_iexp stack e1) (convert_ibinop op) (convert_iexp stack e2) and convert_ibinop (op : Gen_goal.ibinop) = match op with Add -> E.add | Sub -> E.sub let convert_goal (Gen_goal.Run (fmls, expec)) = E.run (convert_block [] fmls) expec let convert (ast : Ast.t) = let invariants = convert_block [] ast.invariants in let goal = convert_goal ast.goal in E.make ast.file ast.domain ast.instance ast.sym invariants goal ast.atom_renaming ast.name_renaming
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>