The Personnel example, annotated
Lax392996.ProvenanceExample · concepts/Lax392996/ProvenanceExample.lean · lax-392996
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Example
The -instance of the paper's Example 9, for : the tuple with id of annotated by the variable . The annotated answer has the three cities as data parts, and their annotations are the Boolean functions for Nairobi, for Paris and for Beijing, the claims being stated pointwise on the valuations of . Variables are numbered from 0 here, from 1 in the paper.
Concept map
Evidence
In the paper
- page 4 of this submission's paper
Lean source view on GitHub
| 1 | import Mathlib.Data.Fin.VecNotation |
| 2 | import Mathlib.Data.Prod.Lex |
| 3 | import Lax392996.SemiringsWithMonus |
| 4 | import Lax392996.BooleanFunctions |
| 5 | import Lax392996.Databases |
| 6 | import Lax392996.AnnotatedDatabases |
| 7 | import Lax392996.RelationalAlgebra |
| 8 | import Lax392996.AnnotatedSemantics |
| 9 | import Lax392996.ProbabilisticDatabases |
| 10 | import Lax392996.PersonnelExample |
| 11 | |
| 12 | /-! |
| 13 | --- |
| 14 | title: The Personnel example, annotated |
| 15 | type: example |
| 16 | --- |
| 17 | The -instance of the paper's Example 9, for |
| 18 | : the tuple with id of |
| 19 | annotated by the variable . The annotated answer |
| 20 | has the three |
| 21 | cities as data parts, and their annotations are the Boolean functions |
| 22 | for Nairobi, |
| 23 | for Paris and for Beijing, the claims |
| 24 | being stated pointwise on the valuations of . Variables are numbered |
| 25 | from 0 here, from 1 in the paper. |
| 26 | -/ |
| 27 | |
| 28 | namespace Lax392996.ProvenanceExample |
| 29 | |
| 30 | open Lax392996.SemiringsWithMonus Lax392996.BooleanFunctions Lax392996.Databases |
| 31 | open Lax392996.AnnotatedDatabases Lax392996.RelationalAlgebra Lax392996.AnnotatedSemantics |
| 32 | open Lax392996.ProbabilisticDatabases Lax392996.PersonnelExample |
| 33 | |
| 34 | /-- The variable `t_i`, as the Boolean function reading it off a valuation. -/ |
| 35 | def t (i : Fin 7) : BoolFunc (Fin 7) := fun ν => ν i |
| 36 | |
| 37 | /-- `Personnel` annotated: the tuple with id `i` carries `t_i`. -/ |
| 38 | def personnelB : AnnotatedRelation String (BoolFunc (Fin 7)) 4 := Multiset.ofList [ |
| 39 | toLex (!["1", "Juma", "Director", "Nairobi"], t 0), |
| 40 | toLex (!["2", "Paul", "Janitor", "Nairobi"], t 1), |
| 41 | toLex (!["3", "David", "Analyst", "Paris"], t 2), |
| 42 | toLex (!["4", "Ellen", "Field agent", "Beijing"], t 3), |
| 43 | toLex (!["5", "Aaheli", "Double agent", "Paris"], t 4), |
| 44 | toLex (!["6", "Nancy", "HR", "Paris"], t 5), |
| 45 | toLex (!["7", "Jing", "Analyst", "Beijing"], t 6)] |
| 46 | |
| 47 | /-- The `B[X]`-instance `Î`. -/ |
| 48 | def instanceB : AnnotatedDatabase String (BoolFunc (Fin 7)) := [("Personnel", ⟨4, personnelB⟩)] |
| 49 | |
| 50 | /-- Example 9, the data: the annotated answer has the three cities as data parts. -/ |
| 51 | axiom data_answer : ∀ hq : qcity.source, |
| 52 | Multiset.map Prod.fst (Query.evaluateAnnotated qcity hq instanceB) |
| 53 | = Multiset.ofList [!["Nairobi"], !["Paris"], !["Beijing"]] |
| 54 | |
| 55 | /-- Example 9, Nairobi: annotated by `t_1 ∧ t_2`. -/ |
| 56 | axiom nairobi_annotation : ∀ (hq : qcity.source) (ν : Fin 7 → Bool), |
| 57 | tupleAnnotation (Query.evaluateAnnotated qcity hq instanceB) !["Nairobi"] ν = (ν 0 && ν 1) |
| 58 | |
| 59 | /-- Example 9, Paris: annotated by `(t_3 ∧ t_5) ∨ (t_5 ∧ t_6) ∨ (t_3 ∧ t_6)`. -/ |
| 60 | axiom paris_annotation : ∀ (hq : qcity.source) (ν : Fin 7 → Bool), |
| 61 | tupleAnnotation (Query.evaluateAnnotated qcity hq instanceB) !["Paris"] ν |
| 62 | = ((ν 2 && ν 4) || (ν 4 && ν 5) || (ν 2 && ν 5)) |
| 63 | |
| 64 | /-- Example 9, Beijing: annotated by `t_4 ∧ t_7`. -/ |
| 65 | axiom beijing_annotation : ∀ (hq : qcity.source) (ν : Fin 7 → Bool), |
| 66 | tupleAnnotation (Query.evaluateAnnotated qcity hq instanceB) !["Beijing"] ν = (ν 3 && ν 6) |
| 67 | |
| 68 | end Lax392996.ProvenanceExample |
| 69 |
Builds on
Used by
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments