I have a question about the: Record and Definition
I have this definition:
Definition rule := term -> term.
and I write a boolean function for it.
Definition beq_rule a b := beq_term a && beq_term b.
where beq_term : term -> term -> bool.
so my definition of beq_rule actually return exactly type of beq_term which is not what I want here. I want it return for me a type: rule -> rule -> bool.
So I changed a definition of rule by Record:
Record rule := mkRule {lhs : term; rhs : term}.
and
Definition beq_rule (a b : rule) : bool :=
beq_term (lhs a) (lhs b) && beq_term (rhs a) (rhs b).
My question is that:
1) What is the different between my first defined rule used Definition and another used Record?
2) If I want to define rule by Definition can I give an alias lhs and rhs likes in Record definition?
Your two definitions of
ruleare saying totally different thingsis defining rule as a type (or
Prop) alias of the function typeterm -> term. Hencewill happily compile.
As to the relation between
RecordandDefinition.Recordis just a macro that converts into anInductive. Sois the same as
plus accessor functions
You should think of
Inductiveas being fundamentally different fromDefinition.Definitiondefines an alias. Another way f saying this isDefinitions are “referentially transparent”, you can (up to variable renaming) always substitute the right hand side of a definition for any occurrence of its name.Inductiveon the other hand defines type (elements of Coqs universes) by listing off a set of constructors. In more logical way of thinking,Inductivedefines a logical proposition in terms of its elimination/introduction rules in a way that ensures “harmony”.