Generating typed views #
A theory's typed view is indexed by the sort it takes apart: Cvc.Typed.View.Arith : Typ → Type.
It is built in two layers.
- Parts. For each sort the theory's operators produce, an inductive of those operators:
View.Arith.OnBool,OnInt,OnRat, andOnAny βfor those producing a type variable —ite, oraddat{α : IsArith}. A constructor has its operator's indices, then the size and type variables its result does not fix, read off the kids' sorts, then implicit proofs — a type variable's classes as theTyppredicate each stands for, a computed result's equation with the part's parameter,n + m = wfor a concatenation — then its kids, typed. A kid whose sort mentions a type variable is indexed byTyp.Denoteof that sort. - The theory view, one constructor per part, at the part's sort:
bool (v : OnBool) : View .bool,bitVec (w) (v : OnBitVec w) : View (.bitVec w),any (v : OnAny τ.Denote) : View τ. Matching an operator refines the sort to the part's; a compound result's equation stays a proof field inside the part, so matching never unifies against anything but a sort's head.
The viewer, View.Arith.of, converts the theory's sort-erased view: that has read the kind, the
kids and the indices, and the typed view adds what the sort adds — the sort fields, read off the
kids, and the proofs. It answers none where it cannot: a kid whose sort no Typ describes, a sort
that does not fit the operator.
gen_typed_view% from <Spec module>generates and registers a theory's typed view.register_typed_view% <View> [ctor KIND, …]registers a hand-written one, whose constructors are the theory view's own.def.typed_term_view V—def.term_view Vunderopen Cvc.Typed— generates the aggregateV : Typ → Type: the leaves, a variantof<Theory>per theory,other, one@[match_pattern]abbreviation per operator, a viewerV.of, and aViewFamilyinstance.
Emitted names #
Built with mkIdent and spliced, never written in a quotation: a name written there resolves
against this module's environment, which imports neither layer.
Equations
- Cvc.TypedView.id_Cvc_Typed_View_reindex = Lean.mkIdent `Cvc.Typed.View.reindex
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typed_View_kids = Lean.mkIdent `Cvc.Typed.View.kids
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typed_View_typOfQ = Lean.mkIdent `Cvc.Typed.View.typOf?
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typed_View_proofQ = Lean.mkIdent `Cvc.Typed.View.proof?
Instances For
Equations
- Cvc.TypedView.id_Cvc_Untyped_Kids_first = Lean.mkIdent `Cvc.Untyped.Kids.first
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typed_Term_relax = Lean.mkIdent `Cvc.Typed.Term.erase
Instances For
Equations
- Cvc.TypedView.id_Cvc_Bag = Lean.mkIdent `Cvc.Bag
Instances For
Equations
- Cvc.TypedView.id_Cvc_Env = Lean.mkIdent `Cvc.Env
Instances For
Equations
- Cvc.TypedView.id_Cvc_FiniteField = Lean.mkIdent `Cvc.FiniteField
Instances For
Equations
- Cvc.TypedView.id_Cvc_Float = Lean.mkIdent `Cvc.Float
Instances For
Equations
- Cvc.TypedView.id_Cvc_Set = Lean.mkIdent `Cvc.Set
Instances For
Equations
- Cvc.TypedView.id_Cvc_ToTyp = Lean.mkIdent `Cvc.ToTyp
Instances For
Equations
- Cvc.TypedView.id_Cvc_TotalMap = Lean.mkIdent `Cvc.TotalMap
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typ = Lean.mkIdent `Cvc.Typ
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typ_Denote = Lean.mkIdent `Cvc.Typ.Denote
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typ_arrayTo = Lean.mkIdent `Cvc.Typ.arrayTo
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typ_bag = Lean.mkIdent `Cvc.Typ.bag
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typ_bitVec = Lean.mkIdent `Cvc.Typ.bitVec
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typ_finiteField = Lean.mkIdent `Cvc.Typ.finiteField
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typ_float = Lean.mkIdent `Cvc.Typ.float
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typ_function = Lean.mkIdent `Cvc.Typ.function
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typ_of = Lean.mkIdent `Cvc.Typ.of
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typ_seq = Lean.mkIdent `Cvc.Typ.seq
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typ_set = Lean.mkIdent `Cvc.Typ.set
Instances For
Equations
- Cvc.TypedView.id_Cvc_TypQ_typ = Lean.mkIdent `Cvc.Typ?.typ
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typed_BVar = Lean.mkIdent `Cvc.Typed.BVar
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typed_Kids = Lean.mkIdent `Cvc.Typed.Kids
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typed_Term = Lean.mkIdent `Cvc.Typed.Term
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typed_Term_asBVar = Lean.mkIdent `Cvc.Typed.Term.asBVar
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typed_Term_getKindQ = Lean.mkIdent `Cvc.Typed.Term.getKind?
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typed_Term_getSymbol = Lean.mkIdent `Cvc.Typed.Term.getSymbol
Instances For
Equations
- Cvc.TypedView.id_cvc5_Kind_CONSTANT = Lean.mkIdent `cvc5.Kind.CONSTANT
Instances For
Equations
- Cvc.TypedView.id_cvc5_Kind_VARIABLE = Lean.mkIdent `cvc5.Kind.VARIABLE
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typ_denoteWithOrd = Lean.mkIdent `Cvc.Typ.denoteWithOrd
Instances For
Equations
- Cvc.TypedView.id_Cvc_Typed_ViewFamily = Lean.mkIdent `Cvc.Typed.ViewFamily
Instances For
Sorts with a view #
A sort a part produces, or a wrapper views.
- name : Lean.Name
The head's name:
bool,bitVec,set, …, oranyfor every sort. - wrapper : String
- params : Array (Lean.TSyntax `Lean.Parser.Term.bracketedBinder)
The part's (and wrapper's) parameters.
Those parameters as arguments, instances excluded.
Every parameter as an argument, a hole for each instance: what an
@-application passes.- target : Lean.Term
The Lean type of the terms it views.
The kind of its values, which the wrapper's
.valueleaf reads.The parameters that carry an
Ordinstance.
Instances For
A size parameter's binder.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A type parameter's binders: the type, its order if a container keys on it, and its sort.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The heads this prototype supports. Parameters are named apart from every specification's variables, so that a result's own variable can be unified with one.
Equations
- One or more equations did not get rendered due to their size.
- Cvc.TypedView.headOf `bool = pure (Cvc.TypedView.Head.plain `bool "Bool" `_root_.Bool (some `CONST_BOOLEAN))
- Cvc.TypedView.headOf `int = pure (Cvc.TypedView.Head.plain `int "Int" `_root_.Int (some `CONST_INTEGER))
- Cvc.TypedView.headOf `real = pure (Cvc.TypedView.Head.plain `real "Rat" `_root_.Rat (some `CONST_RATIONAL))
- Cvc.TypedView.headOf `string = pure (Cvc.TypedView.Head.plain `string "String" `_root_.String (some `CONST_STRING))
- Cvc.TypedView.headOf `regex = pure (Cvc.TypedView.Head.plain `regex "Regex" `Cvc.Regex none)
- Cvc.TypedView.headOf `roundingMode = pure (Cvc.TypedView.Head.plain `roundingMode "RoundingMode" `Cvc.Float.RoundingMode (some `CONST_ROUNDINGMODE))
- Cvc.TypedView.headOf x✝ = Lean.Macro.throwError (toString "no view for sorts of head `" ++ toString x✝ ++ toString "`")
Instances For
The same binders with every explicit one made implicit, for a function whose parameters are determined by its argument's type.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The head of a result shape, if a part can be generated for it.
Equations
- Cvc.TypedView.shapeHead? Cvc.Shape.bool = some `bool
- Cvc.TypedView.shapeHead? Cvc.Shape.int = some `int
- Cvc.TypedView.shapeHead? Cvc.Shape.real = some `real
- Cvc.TypedView.shapeHead? Cvc.Shape.string = some `string
- Cvc.TypedView.shapeHead? Cvc.Shape.regex = some `regex
- Cvc.TypedView.shapeHead? Cvc.Shape.roundingMode = some `roundingMode
- Cvc.TypedView.shapeHead? (Cvc.Shape.bitVec size) = some `bitVec
- Cvc.TypedView.shapeHead? (Cvc.Shape.float exp sig) = some `float
- Cvc.TypedView.shapeHead? (Cvc.Shape.finiteField size) = some `finiteField
- Cvc.TypedView.shapeHead? elm.seq = some `seq
- Cvc.TypedView.shapeHead? elm.set = some `set
- Cvc.TypedView.shapeHead? elm.bag = some `bag
- Cvc.TypedView.shapeHead? (idx.array elm) = some `array
- Cvc.TypedView.shapeHead? (Cvc.Shape.var name) = some `any
- Cvc.TypedView.shapeHead? (dom.fn cod) = none
Instances For
What each of a head's parameters stands for in a result of that head, in parameter order.
Equations
- Cvc.TypedView.resultComps args (Cvc.Shape.bitVec e) = #[(Cvc.TypedView.Comp.size e, args[0]!)]
- Cvc.TypedView.resultComps args (Cvc.Shape.finiteField e) = #[(Cvc.TypedView.Comp.size e, args[0]!)]
- Cvc.TypedView.resultComps args (Cvc.Shape.float e s) = #[(Cvc.TypedView.Comp.size e, args[0]!), (Cvc.TypedView.Comp.size s, args[1]!)]
- Cvc.TypedView.resultComps args x_1.seq = #[(Cvc.TypedView.Comp.type x_1, args[0]!)]
- Cvc.TypedView.resultComps args x_1.set = #[(Cvc.TypedView.Comp.type x_1, args[0]!)]
- Cvc.TypedView.resultComps args x_1.bag = #[(Cvc.TypedView.Comp.type x_1, args[0]!)]
- Cvc.TypedView.resultComps args (i.array e) = #[(Cvc.TypedView.Comp.type i, args[0]!), (Cvc.TypedView.Comp.type e, args[1]!)]
- Cvc.TypedView.resultComps args (Cvc.Shape.var v) = #[(Cvc.TypedView.Comp.type (Cvc.Shape.var v), args[0]!)]
- Cvc.TypedView.resultComps args x✝ = #[]
Instances For
The Typ predicate a refinement class stands for.
Equations
- Cvc.TypedView.classPred? `IsArith = some `Cvc.Typ.isArith
- Cvc.TypedView.classPred? `HasConcat = some `Cvc.Typ.hasConcat
- Cvc.TypedView.classPred? x✝ = none
Instances For
Rendering kids #
How each variable of an entry is bound in its constructor.
Type variables that are
Typfields.Size variables that are
Natfields, read off a kid's sort.A result variable unified with the part's parameter, and the parameter.
The substituted variables whose parameter carries an
Ordinstance.
Instances For
The index of a kid of this shape: the denotation of its Typ if a Typ field occurs in it,
which reduces once the field is matched, and the Lean type it denotes otherwise.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The theory views' heads #
How a part's head appears in the sort-indexed view.
- fields : Array (Lean.TSyntax `Lean.Parser.Term.bracketedBinder)
The theory constructor's fields ahead of the part.
The arguments for those fields.
- partArgs : Array (Lean.TSyntax `Lean.Parser.Term.namedArgument)
The part's parameters, as named arguments.
- index : Lean.Term
The sort the theory constructor is indexed by.
- pattern : Lean.Term
A pattern on a node's sort matching the head, binding the fields.
- implicits : Array (Lean.TSyntax `Lean.Parser.Term.bracketedBinder)
The abbreviations' binders standing for the fields.
- ordered : Option Lean.Ident
The field whose denotation must be ordered, for the containers keyed on it.
Instances For
A part's head in the sort-indexed view.
Equations
- One or more equations did not get rendered due to their size.
- Cvc.TypedView.atHead `bitVec = Cvc.TypedView.atHead.sizes✝ `bitVec #[`w]
- Cvc.TypedView.atHead `float = Cvc.TypedView.atHead.sizes✝ `float #[`fe, `fs]
- Cvc.TypedView.atHead `finiteField = Cvc.TypedView.atHead.sizes✝ `finiteField #[`q]
- Cvc.TypedView.atHead `seq = Cvc.TypedView.atHead.types✝ `seq #[`γ] none
- Cvc.TypedView.atHead `set = Cvc.TypedView.atHead.types✝ `set #[`γ] (some `γ)
- Cvc.TypedView.atHead `bag = Cvc.TypedView.atHead.types✝ `bag #[`γ] (some `γ)
- Cvc.TypedView.atHead `array = Cvc.TypedView.atHead.types✝ `arrayTo #[`ξ, `ζ] (some `ξ)
Instances For
The registry #
A typed view's constructor, as the aggregate's abbreviations need it.
- name : Lean.Name
The operator's name, which its abbreviation takes.
For a generated view, the part holding the operator and the part's head;
nonefor a hand-written view, whose constructors are the theory view's own.
Instances For
Equations
A registered typed view.
- theory : Lean.Name
The theory,
Arith. - view : Lean.Name
The theory view,
Cvc.Typed.View.Arith. Its operators.
The kinds it takes apart.
Instances For
Equations
The registered typed views, imported ones included.
Every registered typed view.
Equations
- Cvc.TypedView.typedViews = do let __do_lift ← Lean.getEnv pure (Cvc.TypedView.typedViewExt.getState __do_lift)
Instances For
A theory's typed view #
One entry's constructor in its part, and the theory viewer's alternative for it.
- ctor : Lean.TSyntax `Lean.Parser.Command.ctor
- alt : Lean.TSyntax `Lean.Parser.Term.matchAlt
Instances For
Whether an entry's kids are an n-ary array: an n-ary entry over two arguments of one shape.
Equations
Instances For
Generates an entry's constructor in its part, and the alternative converting its sort-erased
constructor — or why it cannot be. theory names the theory view, untyped the sort-erased one.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A part's name: Cvc.Typed.View.Arith.OnBool.
Equations
- Cvc.TypedView.partName theory head = theory ++ Lean.Name.mkSimple (toString "On" ++ toString head.wrapper)
Instances For
Generates and registers a theory's typed view from its specification module.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Registers a hand-written typed view: its theory view, whose constructors are the operators, and each with the kind it owns. The theory is the view's last component.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
The typed aggregate #
Generates the typed aggregate V : Typ → Type from every registered typed view.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Declares V : Typ → Type, a term of sort τ taken apart one level, over every theory imported.
V.of τ t takes t apart; a match on the sort and the view together refines both
(| .int, .add kids gives kids : Kids Int). Besides the operators, V has the leaves .value,
.symbol and .bvar, and .other for a term no imported theory takes apart. Needs
variable [Ω] in scope.
Equations
- One or more equations did not get rendered due to their size.