Terms #
We define various kinds of terms that form some of the most basic building blocks of
other structures like atoms and rules.
In this file we start by introducing a Signature and the VarOrConst as the most basic term type.
First of all, almost all of our definitions consider a fixed but arbitrary Signature of predicate symbols P, variables V, and constants C. Also every predicate has a fixed arity. Note that P, V, and C can be arbitrary types so there are no requirements in terms of countability or finiteness. However, intuitively you can consider them to be countably infinite sets. This would allow to pick fresh elements for example. In places where we need this property, we express this through the GetFreshInhabitant type class.
Instances For
VarOrConst #
We introduce VarOrConst as an inductive type representing a term.
The term is either a variable or a constant (thus the name).
VarOrConst is used to define FunctionFreeAtom later and is thus also the basic building block of (non-Skolemized) Rules.
As the name suggests, a VarOrConst is either a variable or a constant.
- var {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] (v : sig.V) : VarOrConst sig
- const {sig : Signature} [DecidableEq sig.C] [DecidableEq sig.V] (c : sig.C) : VarOrConst sig
Instances For
Equations
- instDecidableEqVarOrConst.decEq (VarOrConst.var a) (VarOrConst.var b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- instDecidableEqVarOrConst.decEq (VarOrConst.var v) (VarOrConst.const c) = isFalse ⋯
- instDecidableEqVarOrConst.decEq (VarOrConst.const c) (VarOrConst.var v) = isFalse ⋯
- instDecidableEqVarOrConst.decEq (VarOrConst.const a) (VarOrConst.const b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
Instances For
A VarOrConst is a variable if it was built using the VarOrConst.var constructor.
Equations
- (VarOrConst.var v).isVar = true
- (VarOrConst.const c).isVar = false
Instances For
Given a list of VarOrConst, we can filter out all the variables. Note that we do not use List.filter here since we need to change the list type on the way.
Equations
- VarOrConst.filterVars [] = []
- VarOrConst.filterVars (VarOrConst.var v :: vocs) = v :: VarOrConst.filterVars vocs
- VarOrConst.filterVars (VarOrConst.const c :: vocs) = VarOrConst.filterVars vocs
Instances For
Analogous to filterVars, we can also filter for constants.
Equations
- VarOrConst.filterConsts [] = []
- VarOrConst.filterConsts (VarOrConst.var v :: vocs) = VarOrConst.filterConsts vocs
- VarOrConst.filterConsts (VarOrConst.const c :: vocs) = c :: VarOrConst.filterConsts vocs
Instances For
Each member of filterVars is in the original list (when applying the VarOrConst.var constructor again.)
If a variable is in a list of VarOrConst, then it occurs in filterVars.
Each member of filterConsts is in the original list (when applying the VarOrConst.const constructor again.)
If a constant is in a list of VarOrConst, then it occurs in filterConsts.