Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
caisar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
caisar
Commits
a9b607d0
Commit
a9b607d0
authored
2 years ago
by
Michele Alberti
Browse files
Options
Downloads
Patches
Plain Diff
[stdlib] Add interpretation oriented standard library.
parent
d5175adc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
stdlib/interpretation.mlw
+93
-0
93 additions, 0 deletions
stdlib/interpretation.mlw
with
93 additions
and
0 deletions
stdlib/interpretation.mlw
0 → 100644
+
93
−
0
View file @
a9b607d0
(**************************************************************************)
(* *)
(* This file is part of CAISAR. *)
(* *)
(* Copyright (C) 2022 *)
(* CEA (Commissariat à l'énergie atomique et aux énergies *)
(* alternatives) *)
(* *)
(* You can redistribute it and/or modify it under the terms of the GNU *)
(* Lesser General Public License as published by the Free Software *)
(* Foundation, version 2.1. *)
(* *)
(* It is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU Lesser General Public License for more details. *)
(* *)
(* See the GNU Lesser General Public License version 2.1 *)
(* for more details (enclosed in the file licenses/LGPLv2.1). *)
(* *)
(**************************************************************************)
theory Vector
use int.Int
type vector 'a
function ([]) (v: vector 'a) (i: int) : 'a
function length (v: vector 'a) : int
function map (v: vector 'a) (f: 'a -> 'b) : vector 'b
function map2 (v1: vector 'a) (v2: vector 'b) (f: 'a -> 'b -> 'c) : vector 'c
function fold (v: vector 'a) (acc: 'b) (f: 'b -> 'a -> 'b) : 'b
function fold2 (v1: vector 'a) (v2: vector 'b) (acc: 'c) (f: 'c -> 'a -> 'b -> 'c) : 'c
scope L
predicate forall_ (v: vector 'a) (f: 'a -> bool) =
fold v True (fun acc e -> acc /\ f e)
predicate forall2 (v1: vector 'a) (v2: vector 'b) (f: 'a -> 'b -> bool) =
length(v1) = length(v2) -> fold2 v1 v2 True (fun acc e1 e2 -> acc /\ f e1 e2)
function foreach (v: vector 'a) (f: 'a -> 'b) : vector 'b =
map v f
function foreach2 (v1: vector 'a) (v2: vector 'b) (f: 'a -> 'b -> 'c) : vector 'c =
map2 v1 v2 f
end
end
theory Tensor
use int.Int
use Vector
type tensor 'a
type index = vector int
function (#) (t: tensor 'a) (v: vector int) : 'a
function (-) (t1: tensor 'a) (t2: tensor 'a) : tensor 'a
predicate equal_shape (t1: tensor 'a) (t2: tensor 'b)
predicate valid_index (t: tensor 'a) (v: index)
end
theory Classifier
use Vector
use Tensor
type classifier
type kind = ONNX | NNet | OVO
function read_classifier (f: string) (k: kind) : classifier
function (@@) (c: classifier) (t: tensor 'a) : vector 'a
end
theory Dataset
use Vector
use Tensor
type dataset 'a 'b = vector ('a, 'b)
type kind = CSV
function read_dataset (f: string) (k: kind) : dataset 'a 'b
scope L
predicate forall_ (d: dataset 'a 'b) (f: 'a -> 'b -> bool) =
Vector.L.forall_ d (fun e -> let a, b = e in f a b)
function foreach (d: dataset 'a 'b) (f: 'a -> 'b -> 'c) : vector 'c =
Vector.L.foreach d (fun e -> let a, b = e in f a b)
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment