ladder-calculus/coq/bbencode.v

105 lines
2.2 KiB
Coq
Raw Normal View History

From Coq Require Import Strings.String.
Require Import terms.
Require Import subst.
Require Import smallstep.
Open Scope ladder_type_scope.
Open Scope ladder_expr_scope.
2024-07-24 11:20:43 +02:00
Definition bb_zero : expr_term := [{
(Λ"α"
λ"s",(%"α"% -> %"α"%)
λ"z",(%"α"%)
%"z"%)
as $""$~$"BBNat"$
}].
2024-07-24 11:20:43 +02:00
Definition bb_one : expr_term := [{
(Λ"α"
λ"s",(%"α"% -> %"α"%)
λ"z",(%"α"%)
(%"s"% %"z"%))
as $""$~$"BBNat"$
}].
Definition bb_two : expr_term := [{
(Λ"α"
λ"s",(%"α"% -> %"α"%)
λ"z",(%"α"%)
(%"s"% (%"s"% %"z"%)))
as $""$~$"BBNat"$
}].
2024-07-24 11:20:43 +02:00
Definition bb_succ : expr_term := [{
λ"n",$""$
~$"BBNat"$
~("β",(%"β'"%->%"β"%)->%"β"%->%"β"%)
((Λ"α"
λ"s",((%"α"%->%"α"%)->%"α"%->%"α"%)
λ"z",%"α"%
(%"s"% ((%"n"% # %"α"%) %"s"% %"z"%)))
as $""$~$"BBNat"$)
}].
2024-07-24 11:20:43 +02:00
Example example_reduction :
(expr_app bb_succ bb_one) -->β* bb_two
.
Proof.
2024-07-24 11:20:43 +02:00
apply Multi_Step with (y:=[{
(λ"n",$""$
~$"BBNat"$
~("β",(%"β'"%->%"β"%)->%"β"%->%"β"%)
((Λ"α"
λ"s",((%"α"%->%"α"%)->%"α"%->%"α"%)
λ"z",%"α"%
(%"s"% ((%"n"% # %"α"%) %"s"% %"z"%)))
as $""$~$"BBNat"$))
2024-07-24 11:20:43 +02:00
(Λ"β"
λ"s",(%"β"% -> %"β"%)
λ"z",(%"β"%)
(%"s"% %"z"%))
as $""$~$"BBNat"$
}]).
Admitted.
(*
apply E_Alpha.
apply E_App2.
apply EAlpha_Rename.
2024-07-24 11:20:43 +02:00
apply Multi_Step with (y:=[{
(Λ"α"
λ"s",((%"α"%->%"α"%)->%"α"%->%"α"%)
λ"z",%"α"%
(%"s"% (
(((Λ"β"
λ"s",(%"β"% -> %"β"%)
λ"z",(%"β"%)
(%"s"% %"z"%)) as $""$~$"BBNat"$)
# %"α"%) %"s"% %"z"%)))
as $""$~$"BBNat"$ }]).
2024-07-24 11:20:43 +02:00
apply E_AppLam.
2024-07-24 11:20:43 +02:00
apply Multi_Step with (y:=[{
(Λ"α"
λ"s",((%"α"%->%"α"%)->%"α"%->%"α"%)
λ"z",%"α"%
(%"s"% (
(((Λ"α'"
λ"s",(%"α'"% -> %"α'"%)
λ"z",(%"α'"%)
(%"s"% %"z"%)) as $""$~$"BBNat"$)
# %"α"%) %"s"% %"z"%)))
as $""$~$"BBNat"$ }]).
}].
2024-07-24 11:20:43 +02:00
Qed.
*)
2024-07-24 11:20:43 +02:00
Compute (expr_app bb_succ bb_zero) -->β bb_one.